aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/escript_SUITE_data
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2012-08-07 17:23:26 +0200
committerSiri Hansen <[email protected]>2012-08-07 17:36:18 +0200
commitaf23ae42edcd582ec72e6c97540f82ea03bb36fe (patch)
treedf5964cf242a9e151341ec2eb03b8d923fb4933f /lib/stdlib/test/escript_SUITE_data
parent85a5f71087785c4eada6a4101ffeef6a15f5c409 (diff)
downloadotp-af23ae42edcd582ec72e6c97540f82ea03bb36fe.tar.gz
otp-af23ae42edcd582ec72e6c97540f82ea03bb36fe.tar.bz2
otp-af23ae42edcd582ec72e6c97540f82ea03bb36fe.zip
Fix flattening of paths in erl_prim_loader
When correcting OTP-10071, a new error was introduced in erl_prim_loader. In order to improve ability to detect if a file was inside the primary archive, all paths were flattened - i.e. "." and ".." were removed. This implementation had some faults, and it did not take symlinks into account. This has been corrected.
Diffstat (limited to 'lib/stdlib/test/escript_SUITE_data')
-rw-r--r--lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl b/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
index 226a8675db..b03c8ba70d 100644
--- a/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
+++ b/lib/stdlib/test/escript_SUITE_data/archive_script_file_access/archive_script_file_access.erl
@@ -23,12 +23,9 @@
-include_lib("kernel/include/file.hrl").
-main(MainArgs) ->
- io:format("file_access:~p\n", [MainArgs]),
- ArchiveFile = escript:script_name(),
+main([RelArchiveFile]) ->
- AbsArchiveFile = filename:absname(ArchiveFile),
- RelArchiveFile = filename:basename(ArchiveFile),
+ AbsArchiveFile = filename:absname(RelArchiveFile),
DotSlashArchiveFile = "./" ++ RelArchiveFile,
Beam = atom_to_list(?MODULE) ++ ".beam",
@@ -39,6 +36,10 @@ main(MainArgs) ->
AbsDir = filename:join(AbsArchiveFile,Dir),
RelDir = filename:join(RelArchiveFile,Dir),
DotSlashDir = filename:join(DotSlashArchiveFile,Dir),
+ SubDir = "subdir1",
+ AbsSubDir = filename:join(AbsDir,SubDir),
+ RelSubDir = filename:join(RelDir,SubDir),
+ DotSlashSubDir = filename:join(DotSlashDir,SubDir),
{ok,List1} = erl_prim_loader:list_dir(AbsArchiveFile),
{ok,List1} = erl_prim_loader:list_dir(RelArchiveFile),
@@ -48,8 +49,26 @@ main(MainArgs) ->
{ok,List1} = erl_prim_loader:list_dir(filename:join([AbsDir,".."])),
{ok,List1} = erl_prim_loader:list_dir(filename:join([RelDir,".."])),
{ok,List1} = erl_prim_loader:list_dir(filename:join([DotSlashDir,".."])),
+ {ok,List1} = erl_prim_loader:list_dir(filename:join([AbsSubDir,"..",".."])),
+ {ok,List1} = erl_prim_loader:list_dir(filename:join([RelSubDir,"..",".."])),
+ {ok,List1} = erl_prim_loader:list_dir(filename:join([DotSlashSubDir,"..",".."])),
false = lists:member([],List1),
+ %% If symlinks are supported on this platform...
+ RelSymlinkArchiveFile = "symlink_to_" ++ RelArchiveFile,
+ case file:read_link(RelSymlinkArchiveFile) of
+ {ok,_} ->
+ DotSlashSymlinkArchiveFile = "./" ++ RelSymlinkArchiveFile,
+ AbsSymlinkArchiveFile=filename:join(filename:dirname(AbsArchiveFile),
+ RelSymlinkArchiveFile),
+ {ok,List1} = erl_prim_loader:list_dir(AbsSymlinkArchiveFile),
+ {ok,List1} = erl_prim_loader:list_dir(RelSymlinkArchiveFile),
+ {ok,List1} = erl_prim_loader:list_dir(DotSlashSymlinkArchiveFile);
+ _ -> % not supported
+ ok
+ end,
+
+
{ok,List2} = erl_prim_loader:list_dir(AbsDir),
{ok,List2} = erl_prim_loader:list_dir(RelDir),
{ok,List2} = erl_prim_loader:list_dir(DotSlashDir),