<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 30, 2022 at 1:54 PM Rob Landley <<a href="mailto:rob@landley.net">rob@landley.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/28/22 12:41, enh via Toybox wrote:<br>
> github CI caught a few failures<br>
<br>
Sigh. There's a reason this has been on the todo list for literally years. It's<br>
corner cases all the way down and I don't have a mac test environment. (Works on<br>
linux not on mac means a libc function is returning something different,<br>
possibly because a syscall did, possibly because the VFS did something funky...)<br>
<br>
> (<a href="https://github.com/landley/toybox/actions/runs/3561813808/jobs/5983047254" rel="noreferrer" target="_blank">https://github.com/landley/toybox/actions/runs/3561813808/jobs/5983047254</a>):<br>
> <br>
> PASS: realpath -s<br>
> ............................................................................<br>
> ................................................<br>
> realpath: dos/three: Not a directory<br>
<br>
Not a directory? Up top we did:<br>
<br>
mkdir -p one/two/three<br>
ln -s ./one uno<br>
ln -s one/two dos<br>
<br>
I don't THINK anything's done a cd or filesystem write since then?<br>
(one/two/three is a directory and dos points to "one/two"...)<br></blockquote><div><br></div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(170,171,37)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>~/toybox/generated/testdir/testdir$ </b></span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)">ls -Rl</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">total 8</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-rw-r--r--<span class="gmail-Apple-converted-space"> </span>1 enh<span class="gmail-Apple-converted-space"> </span>primarygroup <span class="gmail-Apple-converted-space"> </span>0 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 actual</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">lrwxr-xr-x<span class="gmail-Apple-converted-space"> </span>1 enh<span class="gmail-Apple-converted-space"> </span>primarygroup <span class="gmail-Apple-converted-space"> </span>7 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 dos -> one/two</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-rw-r--r--<span class="gmail-Apple-converted-space"> </span>1 enh<span class="gmail-Apple-converted-space"> </span>primarygroup<span class="gmail-Apple-converted-space"> </span>54 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 expected</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">-rw-r--r--<span class="gmail-Apple-converted-space"> </span>1 enh<span class="gmail-Apple-converted-space"> </span>primarygroup <span class="gmail-Apple-converted-space"> </span>0 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 file</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">drwxr-xr-x<span class="gmail-Apple-converted-space"> </span>3 enh<span class="gmail-Apple-converted-space"> </span>primarygroup<span class="gmail-Apple-converted-space"> </span>96 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 one</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">lrwxr-xr-x<span class="gmail-Apple-converted-space"> </span>1 enh<span class="gmail-Apple-converted-space"> </span>primarygroup <span class="gmail-Apple-converted-space"> </span>5 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 uno -> ./one</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:16px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">./one:</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">total 0</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">drwxr-xr-x<span class="gmail-Apple-converted-space"> </span>3 enh<span class="gmail-Apple-converted-space"> </span>primarygroup<span class="gmail-Apple-converted-space"> </span>96 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 two</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:16px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">./one/two:</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">total 0</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">drwxr-xr-x<span class="gmail-Apple-converted-space"> </span>2 enh<span class="gmail-Apple-converted-space"> </span>primarygroup<span class="gmail-Apple-converted-space"> </span>64 Dec<span class="gmail-Apple-converted-space"> </span>2 10:04 three</span></p>
<p class="gmail-p3" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0);min-height:16px"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">./one/two/three:</span></p>
<p class="gmail-p2" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">total 0</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(170,171,37)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><b>~/toybox/generated/testdir/testdir$<span class="gmail-Apple-converted-space"> </span></b></span></p></div><div> </div><div>i added a bit of printf debugging to see exactly where it's failing, and it's the openat() in the loop at the bottom of xabspath():</div><div><br></div><div>PASS: realpath -s<br>openat(4, three) 2 error<br>realpath: dos/three from /Users/enh/toybox/generated/testdir/testdir: Not a directory<br>FAIL: realpath -s link/..<br>echo -ne '' | "/Users/enh/toybox/generated/testdir/realpath" -es dos/three<br>--- expected 2022-12-02 10:17:26.000000000 -0800<br>+++ actual 2022-12-02 10:17:26.000000000 -0800<br>@@ -1 +1,8 @@<br>-/Users/enh/toybox/generated/testdir/testdir/dos/three<br>+COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME<br>+realpath 35535 enh cwd DIR 1,18 256 19337560 /Users/enh/toybox/generated/testdir/testdir<br>+realpath 35535 enh txt REG 1,18 52840 19337559 /Users/enh/toybox/generated/testdir/realpath<br>+realpath 35535 enh txt REG 1,18 2177216 1152921500312783005 /usr/lib/dyld<br>+realpath 35535 enh 0 PIPE 0x21ecbbc508f2f611 16384 <br>+realpath 35535 enh 1w REG 1,18 0 19337607 /Users/enh/toybox/generated/testdir/testdir/actual<br>+realpath 35535 enh 2u CHR 16,0 0t43970 1155 /dev/ttys000<br>+realpath 35535 enh 4r LINK 1,18 7 19337567 /Users/enh/toybox/generated/testdir/testdir/dos<br>make: *** [test_realpath] Error 1<br>~/toybox$ <br></div><div><br></div><div>(the lsof output there shows you what dirfd=4 is actually pointing to.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> FAIL: realpath -s link/..<br>
> echo -ne '' | "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es<br>
> dos/three<br>
> --- expected 2022-11-28 04:54:16.000000000 +0000<br>
> +++ actual 2022-11-28 04:54:16.000000000 +0000<br>
> @@ -1 +0,0 @@<br>
> -/Users/runner/work/toybox/toybox/generated/testdir/testdir/dos/three<br>
<br>
Debris from that failure...<br>
<br>
> PASS: realpath -s .. eats symlink<br>
> PASS: realpath -s .. eats symlink in $PWD<br>
<br>
Neither of those actually looks at the filesystem because -s (don't expand<br>
symlinks) so there's potentially a getcwd() prepend then the .. cancellation is<br>
entirely string based...<br>
<br>
> FAIL: realpath -es dangling symlink<br>
> echo -ne '' | "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es<br>
> dangling 2>/dev/null || echo ok<br>
> --- expected 2022-11-28 04:54:16.000000000 +0000<br>
> +++ actual 2022-11-28 04:54:16.000000000 +0000<br>
> @@ -1 +1 @@<br>
> -ok<br>
> +/Users/runner/work/toybox/toybox/generated/testdir/testdir/dangling<br>
<br>
Adding -e however checks if the result exists. And the failure here is it<br>
SHOULDN'T, but MacOS thinks it DOES. (How do you even...?)<br>
<br>
> PASS: realpath -ms<br>
> realpath: one/two/ichi/two/ichi/two: Not a directory<br>
<br>
Our old friend again...<br>
<br>
> FAIL: realpath -es<br>
> echo -ne '' | "/Users/runner/work/toybox/toybox/generated/testdir/realpath" -es<br>
> one/two/ichi/two/ichi/two<br>
> --- expected 2022-11-28 04:54:16.000000000 +0000<br>
> +++ actual 2022-11-28 04:54:17.000000000 +0000<br>
> @@ -1 +0,0 @@<br>
> -/Users/runner/work/toybox/toybox/generated/testdir/testdir/one/two/ichi/two/ichi/two<br>
<br>
Sigh. If I stick printfs into a commit and push to a branch it'll _sometimes_<br>
run the tests on the new commit based on github server load, correct?<br>
<br>
Lemme finish fixing cp -s first (I.E. the rest of my relative path untangling<br>
todo item)...<br>
<br>
Rob<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net" target="_blank">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div></div>