<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">filelib:ensure_dir/1 is broken when there's a symlink in the path.</span><br style="font-family:arial,sans-serif;font-size:13px"><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">the offending commit:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><a href="https://github.com/erlang/otp/commit/f11aabdc9fec593c31e6c4f3fa25c1707e9c35df" target="_blank">https://github.com/erlang/otp/commit/f11aabdc9fec593c31e6c4f3fa25c1707e9c35df</a><br>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">e.g.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
<div>~ $ mkdir test</div><div>~ $ ln -s test test2</div><div><br></div><div>~ $ erl</div><div>Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]</div><div><br></div>
<div>Eshell V6.1 (abort with ^G)</div><div>1> filelib:ensure_dir("test2/foo").</div><div>{error,eexist}</div><div><br></div><div>2> file:make_dir("test2").</div><div>{error,eexist}</div></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">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. </div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">Since it really is a folder, it fails to create the new folder with {error, eexist}.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div>
<div style="font-family:arial,sans-serif;font-size:13px"><div>3> file:read_link_info("test2").</div><div>{ok,{file_info,5,symlink,read_write,</div><div> {{2014,6,26},{14,52,45}},</div><div> {{2014,6,26},{14,52,45}},</div>
<div> {{2014,6,26},{14,52,45}},</div><div> 41453,1,16777220,0,55514582,501,20}}</div><div><br></div><div>vs</div><div><br></div><div>4> file:read_file_info("test2").</div><div>{ok,{file_info,102,directory,read_write,</div>
<div> {{2014,6,26},{14,53,26}},</div><div> {{2014,6,26},{14,53,32}},</div><div> {{2014,6,26},{14,53,32}},</div><div> 16877,3,16777220,0,55514786,501,20}}</div></div>
</div>