filelib:ensure_dir/1 broken with symlinks

Louis-Philippe Gauthier <[email protected]>
Newsgroups gmane.comp.lang.erlang.bugs
Message-ID <CAGvQrRjycsJBgHG9Bh1+059uCrC00669dB2ZCUuAg9sr15e2yg@mail.gmail.com>
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}}

_______________________________________________
erlang-bugs mailing list
[email protected]
http://erlang.org/mailman/listinfo/erlang-bugs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.