[erlang-bugs] filelib:ensure_dir/1 broken with symlinks

Louis-Philippe Gauthier louis-philippe.gauthier@REDACTED
Fri Jun 27 12:01:30 CEST 2014


filelib:ensure_dir/1 is broken when there's a symlink in the path.

the offending commit:

https://github.com/erlang/otp/commit/f11aabdc9fec593c31e6c4f3fa25c1707e9c35df

e.g.

~ $ mkdir test
~ $ ln -s test test2

~ $ erl
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10]
[hipe] [kernel-poll:false] [dtrace]

Eshell V6.1  (abort with ^G)
1> filelib:ensure_dir("test2/foo").
{error,eexist}

2> file:make_dir("test2").
{error,eexist}

This happens because eval_read_file_info/2 uses read_link_info/1 instead of
read_file_info/1. The file_info type is link instead of folder.

Since it really is a folder, it fails to create the new folder with {error,
eexist}.

3> file:read_link_info("test2").
{ok,{file_info,5,symlink,read_write,
               {{2014,6,26},{14,52,45}},
               {{2014,6,26},{14,52,45}},
               {{2014,6,26},{14,52,45}},
               41453,1,16777220,0,55514582,501,20}}

vs

4> file:read_file_info("test2").
{ok,{file_info,102,directory,read_write,
               {{2014,6,26},{14,53,26}},
               {{2014,6,26},{14,53,32}},
               {{2014,6,26},{14,53,32}},
               16877,3,16777220,0,55514786,501,20}}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140627/1c67d19a/attachment.htm>


More information about the erlang-bugs mailing list