[Pkg-erlang-commits] r1651 - in erlang/trunk/debian: . patches
sgolovan at alioth.debian.org
sgolovan at alioth.debian.org
Mon Jul 7 14:54:07 UTC 2014
Author: sgolovan
Date: 2014-07-07 14:54:07 +0000 (Mon, 07 Jul 2014)
New Revision: 1651
Added:
erlang/trunk/debian/patches/symlinks.patch
Modified:
erlang/trunk/debian/changelog
erlang/trunk/debian/patches/series
Log:
[erlang]
* Added patch by upstream which fixes regression in 17.1 (a few functions
in the filelib module do not follow symlinks, closes: #754083).
Modified: erlang/trunk/debian/changelog
===================================================================
--- erlang/trunk/debian/changelog 2014-07-07 08:58:15 UTC (rev 1650)
+++ erlang/trunk/debian/changelog 2014-07-07 14:54:07 UTC (rev 1651)
@@ -1,8 +1,9 @@
-erlang (1:17.1-dfsg-3) UNRELEASED; urgency=medium
+erlang (1:17.1-dfsg-3) unstable; urgency=medium
- * NOT RELEASED YET
+ * Added patch by upstream which fixes regression in 17.1 (a few functions
+ in the filelib module do not follow symlinks, closes: #754083).
- -- Sergei Golovan <sgolovan at debian.org> Mon, 07 Jul 2014 08:53:07 +0400
+ -- Sergei Golovan <sgolovan at debian.org> Mon, 07 Jul 2014 18:53:29 +0400
erlang (1:17.1-dfsg-2) unstable; urgency=medium
Modified: erlang/trunk/debian/patches/series
===================================================================
--- erlang/trunk/debian/patches/series 2014-07-07 08:58:15 UTC (rev 1650)
+++ erlang/trunk/debian/patches/series 2014-07-07 14:54:07 UTC (rev 1651)
@@ -8,3 +8,4 @@
java.patch
hppa.patch
javascript.patch
+symlinks.patch
Added: erlang/trunk/debian/patches/symlinks.patch
===================================================================
--- erlang/trunk/debian/patches/symlinks.patch (rev 0)
+++ erlang/trunk/debian/patches/symlinks.patch 2014-07-07 14:54:07 UTC (rev 1651)
@@ -0,0 +1,210 @@
+Description: This fixes a bug introduced in f11aabdc9fec593c31e6c4f3fa25c1707e9c35df where
+ filelib:eval_read_file_info/2 was made to use file:read_link_info/1 to never
+ follow symlinks. This fixed wildcard/1 but broke every other function using
+ eval_read_file_info/2.
+Author: Anthony Ramine <n.oxyde at gmail.com>
+Last-Modified: Tue, 1 Jul 2014 00:58:26 +0200
+
+--- a/erts/preloaded/src/erl_prim_loader.erl
++++ b/erts/preloaded/src/erl_prim_loader.erl
+@@ -42,11 +42,11 @@
+
+ %% Public
+ -export([start/3, set_path/1, get_path/0, get_file/1, get_files/2,
+- list_dir/1, read_file_info/1, get_cwd/0, get_cwd/1]).
++ list_dir/1, read_file_info/1, read_link_info/1, get_cwd/0, get_cwd/1]).
+
+ %% Used by erl_boot_server
+ -export([prim_init/0, prim_get_file/2, prim_list_dir/2,
+- prim_read_file_info/2, prim_get_cwd/2]).
++ prim_read_file_info/3, prim_get_cwd/2]).
+
+ %% Used by escript and code
+ -export([set_primary_archive/4, release_archives/0]).
+@@ -223,6 +223,12 @@ list_dir(Dir) ->
+ read_file_info(File) ->
+ check_file_result(read_file_info, File, request({read_file_info,File})).
+
++-spec read_link_info(Filename) -> {'ok', FileInfo} | 'error' when
++ Filename :: string(),
++ FileInfo :: file:file_info().
++read_link_info(File) ->
++ check_file_result(read_link_info, File, request({read_link_info,File})).
++
+ -spec get_cwd() -> {'ok', string()} | 'error'.
+ get_cwd() ->
+ check_file_result(get_cwd, [], request({get_cwd,[]})).
+@@ -325,6 +331,9 @@ loop(State, Parent, Paths) ->
+ {read_file_info,File} ->
+ {Res,State1} = handle_read_file_info(State, File),
+ {Res,State1,Paths};
++ {read_link_info,File} ->
++ {Res,State1} = handle_read_link_info(State, File),
++ {Res,State1,Paths};
+ {get_cwd,[]} ->
+ {Res,State1} = handle_get_cwd(State, []),
+ {Res,State1,Paths};
+@@ -387,10 +396,15 @@ handle_list_dir(State = #state{loader = inet}, Dir) ->
+ ?SAFE2(inet_list_dir(State, Dir), State).
+
+ handle_read_file_info(State = #state{loader = efile}, File) ->
+- ?SAFE2(efile_read_file_info(State, File), State);
++ ?SAFE2(efile_read_file_info(State, File, true), State);
+ handle_read_file_info(State = #state{loader = inet}, File) ->
+ ?SAFE2(inet_read_file_info(State, File), State).
+
++handle_read_link_info(State = #state{loader = efile}, File) ->
++ ?SAFE2(efile_read_file_info(State, File, false), State);
++handle_read_link_info(State = #state{loader = inet}, File) ->
++ ?SAFE2(inet_read_link_info(State, File), State).
++
+ handle_get_cwd(State = #state{loader = efile}, Drive) ->
+ ?SAFE2(efile_get_cwd(State, Drive), State);
+ handle_get_cwd(State = #state{loader = inet}, Drive) ->
+@@ -514,8 +528,8 @@ efile_list_dir(#state{prim_state = PS} = State, Dir) ->
+ {Res, PS2} = prim_list_dir(PS, Dir),
+ {Res, State#state{prim_state = PS2}}.
+
+-efile_read_file_info(#state{prim_state = PS} = State, File) ->
+- {Res, PS2} = prim_read_file_info(PS, File),
++efile_read_file_info(#state{prim_state = PS} = State, File, FollowLinks) ->
++ {Res, PS2} = prim_read_file_info(PS, File, FollowLinks),
+ {Res, State#state{prim_state = PS2}}.
+
+ efile_get_cwd(#state{prim_state = PS} = State, Drive) ->
+@@ -718,6 +732,10 @@ inet_list_dir(State, Dir) ->
+ inet_read_file_info(State, File) ->
+ inet_send_and_rcv({read_file_info,File}, read_file_info, State).
+
++%% -> {{ok,Info},State} | {{error,Reason},State}
++inet_read_link_info(State, File) ->
++ inet_send_and_rcv({read_link_info,File}, read_link_info, State).
++
+ %% -> {{ok,Cwd},State} | {{error,Reason},State}
+ inet_get_cwd(State, []) ->
+ inet_send_and_rcv(get_cwd, get_cwd, State);
+@@ -951,16 +969,18 @@ prim_list_dir(PS, Dir) ->
+ debug(PS, {return, Res2}),
+ {Res2, PS3}.
+
+--spec prim_read_file_info(prim_state(), file:filename()) ->
++-spec prim_read_file_info(prim_state(), file:filename(), boolean()) ->
+ {{'ok', #file_info{}}, prim_state()}
+ | {{'error', term()}, prim_state()}.
+-prim_read_file_info(PS, File) ->
++prim_read_file_info(PS, File, FollowLinks) ->
+ debug(PS, {read_file_info, File}),
+ {Res2, PS2} =
+ case name_split(PS#prim_state.primary_archive, File) of
+ {file, PrimFile} ->
+- Res = prim_file:read_file_info(PrimFile),
+- {Res, PS};
++ case FollowLinks of
++ true -> {prim_file:read_file_info(PrimFile), PS};
++ false -> {prim_file:read_link_info(PrimFile), PS}
++ end;
+ {archive, ArchiveFile, []} ->
+ %% Fake top directory
+ debug(PS, {archive_read_file_info, ArchiveFile}),
+--- a/lib/kernel/src/erl_boot_server.erl
++++ b/lib/kernel/src/erl_boot_server.erl
+@@ -341,9 +341,13 @@ handle_command(S, PS, Msg) ->
+ send_file_result(S, list_dir, Res),
+ PS2;
+ {read_file_info,File} ->
+- {Res, PS2} = erl_prim_loader:prim_read_file_info(PS, File),
++ {Res, PS2} = erl_prim_loader:prim_read_file_info(PS, File, true),
+ send_file_result(S, read_file_info, Res),
+ PS2;
++ {read_link_info,File} ->
++ {Res, PS2} = erl_prim_loader:prim_read_file_info(PS, File, false),
++ send_file_result(S, read_link_info, Res),
++ PS2;
+ get_cwd ->
+ {Res, PS2} = erl_prim_loader:prim_get_cwd(PS, []),
+ send_file_result(S, get_cwd, Res),
+--- a/lib/stdlib/src/filelib.erl
++++ b/lib/stdlib/src/filelib.erl
+@@ -265,7 +265,7 @@ do_wildcard(Pattern, Cwd, Mod) ->
+ lists:sort(Files).
+
+ do_wildcard_1({exists,File}, Mod) ->
+- case eval_read_file_info(File, Mod) of
++ case eval_read_link_info(File, Mod) of
+ {ok,_} -> [File];
+ _ -> []
+ end;
+@@ -488,7 +488,7 @@ badpattern(Reason) ->
+ error({badpattern,Reason}).
+
+ eval_read_file_info(File, file) ->
+- file:read_link_info(File);
++ file:read_file_info(File);
+ eval_read_file_info(File, erl_prim_loader) ->
+ case erl_prim_loader:read_file_info(File) of
+ error -> {error, erl_prim_loader};
+@@ -497,6 +497,16 @@ eval_read_file_info(File, erl_prim_loader) ->
+ eval_read_file_info(File, Mod) ->
+ Mod:read_file_info(File).
+
++eval_read_link_info(File, file) ->
++ file:read_link_info(File);
++eval_read_link_info(File, erl_prim_loader) ->
++ case erl_prim_loader:read_link_info(File) of
++ error -> {error, erl_prim_loader};
++ Res-> Res
++ end;
++eval_read_link_info(File, Mod) ->
++ Mod:read_link_info(File).
++
+ eval_list_dir(Dir, file) ->
+ file:list_dir(Dir);
+ eval_list_dir(Dir, erl_prim_loader) ->
+--- a/lib/stdlib/test/filelib_SUITE.erl
++++ b/lib/stdlib/test/filelib_SUITE.erl
+@@ -23,7 +23,8 @@
+ init_per_group/2,end_per_group/2,
+ init_per_testcase/2,end_per_testcase/2,
+ wildcard_one/1,wildcard_two/1,wildcard_errors/1,
+- fold_files/1,otp_5960/1,ensure_dir_eexist/1,symlinks/1]).
++ fold_files/1,otp_5960/1,ensure_dir_eexist/1,ensure_dir_symlink/1,
++ symlinks/1]).
+
+ -import(lists, [foreach/2]).
+
+@@ -43,7 +44,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}].
+
+ all() ->
+ [wildcard_one, wildcard_two, wildcard_errors,
+- fold_files, otp_5960, ensure_dir_eexist, symlinks].
++ fold_files, otp_5960, ensure_dir_eexist, ensure_dir_symlink, symlinks].
+
+ groups() ->
+ [].
+@@ -367,6 +368,26 @@ ensure_dir_eexist(Config) when is_list(Config) ->
+ ?line {error, eexist} = filelib:ensure_dir(NeedFileB),
+ ok.
+
++ensure_dir_symlink(Config) when is_list(Config) ->
++ PrivDir = ?config(priv_dir, Config),
++ Dir = filename:join(PrivDir, "ensure_dir_symlink"),
++ Name = filename:join(Dir, "same_name_as_file_and_dir"),
++ ok = filelib:ensure_dir(Name),
++ ok = file:write_file(Name, <<"some string\n">>),
++ %% With a symlink to the directory.
++ Symlink = filename:join(PrivDir, "ensure_dir_symlink_link"),
++ case file:make_symlink(Dir, Symlink) of
++ {error,enotsup} ->
++ {skip,"Symlinks not supported on this platform"};
++ {error,eperm} ->
++ {win32,_} = os:type(),
++ {skip,"Windows user not privileged to create symlinks"};
++ ok ->
++ SymlinkedName = filename:join(Symlink, "same_name_as_file_and_dir"),
++ ok = filelib:ensure_dir(SymlinkedName)
++ end.
++
++
+ symlinks(Config) when is_list(Config) ->
+ PrivDir = ?config(priv_dir, Config),
+ Dir = filename:join(PrivDir, ?MODULE_STRING++"_symlinks"),
More information about the Pkg-erlang-commits
mailing list