<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 3, 2022 at 1:05 AM 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"><br>
<br>
On 12/2/22 12:19, enh wrote:<br>
> <br>
> <br>
> On Wed, Nov 30, 2022 at 1:54 PM Rob Landley <<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a><br>
> <mailto:<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>>> wrote:<br>
> <br>
> 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>
> <<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>
> <br>
> <br>
> *~/toybox/generated/testdir/testdir$ *ls -Rl<br>
> <br>
> total 8<br>
> <br>
> -rw-r--r-- 1 enh primarygroup 0 Dec 2 10:04 actual<br>
> <br>
> lrwxr-xr-x 1 enh primarygroup 7 Dec 2 10:04 dos -> one/two<br>
> <br>
> -rw-r--r-- 1 enh primarygroup 54 Dec 2 10:04 expected<br>
> <br>
> -rw-r--r-- 1 enh primarygroup 0 Dec 2 10:04 file<br>
> <br>
> drwxr-xr-x 3 enh primarygroup 96 Dec 2 10:04 one<br>
> <br>
> lrwxr-xr-x 1 enh primarygroup 5 Dec 2 10:04 uno -> ./one<br>
> <br>
> <br>
> ./one:<br>
> <br>
> total 0<br>
> <br>
> drwxr-xr-x 3 enh primarygroup 96 Dec 2 10:04 two<br>
> <br>
> <br>
> ./one/two:<br>
> <br>
> total 0<br>
> <br>
> drwxr-xr-x 2 enh primarygroup 64 Dec 2 10:04 three<br>
> <br>
> <br>
> ./one/two/three:<br>
> <br>
> total 0<br>
> <br>
> *~/toybox/generated/testdir/testdir$ *<br>
> <br>
> i added a bit of printf debugging to see exactly where it's failing, and it's<br>
> the openat() in the loop at the bottom of xabspath():<br>
> <br>
> PASS: realpath -s<br>
> openat(4, three) 2 error<br>
> realpath: dos/three from /Users/enh/toybox/generated/testdir/testdir: Not a<br>
> directory<br>
<br>
Let's see what freebsd does... Sigh, freebsd 11 is apparently a bit stale.<br>
<br>
Did you know that if you wget<br>
<a href="https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-RELEASE/amd64/Latest/FreeBSD-13.0-RELEASE-amd64.raw.xz" rel="noreferrer" target="_blank">https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-RELEASE/amd64/Latest/FreeBSD-13.0-RELEASE-amd64.raw.xz</a><br>
and unxz it and do "kvm FreeBSD-13*.raw -m 4096" and log in as root and "pkg<br>
install gmake" and gsed and bash and git (over 20 packages?!?) and then "adduser<br>
landley" and answer far too many questions (just DO it will you?) and then "su -<br>
landley" and git clone <a href="https://github.com/landley/toybox" rel="noreferrer" target="_blank">https://github.com/landley/toybox</a> it says the filesystem<br>
is out of space?<br>
<br>
The filesystem resizing dance (more or less from<br>
<a href="https://people.freebsd.org/~rodrigc/doc/handbook/disks-growing.html" rel="noreferrer" target="_blank">https://people.freebsd.org/~rodrigc/doc/handbook/disks-growing.html</a>) is:<br>
<br>
kill kvm ("shutdown -h now" if you like but halt didn't exit.)<br>
truncate -s 8G Freebsd-13*.raw<br>
kvm -drive format=raw,file=freebsd-13.raw -m 4096<br>
# because the qemu loons decided to punish normal -hda for NO REASON<br>
gpart recover ada0<br>
gpart show ada0 # add last two sizes...<br>
gpart resize -i 4 -a 4k -s 14613342 ada0<br>
sysctl kern.geom.debugflags=16<br>
growfs /<br>
<br>
(Yes the web page says growfs /dev/ada0p4 but that doesn't work, you have to<br>
give it the mounted directory. And I could ignore the swap partition fiddling<br>
because 13 has it before the filesystem rather than after.)<br>
<br>
Anyway, THEN I could git clone the thing, and go:<br>
<br>
cd toybox<br>
gmake clean bsd_defconfig toybox<br>
<br>
At which point it dies trying to build openvt and not finding linux/vt.h so I<br>
remove CONFIG_CHVT=y from kconfig/freebsd_miniconfig and try again, and now the<br>
linker failed with undefined symbol get_block_device_size because<br>
lib/portability.c has #if defined(__APPLE__) elif defined(__linux__) #elif<br>
defined(__OpenBSD__) and I need to step away from the keyboard for a bit.<br></blockquote><div><br></div><div>yeah, if they'd spent less time fighting each other, they might have had more direct impact (rather than indirect through having bits reused in Android/macOS/Windows)!</div><div><br></div><div>i think the ifdefs are mostly my fault, because i was only thinking in terms of __APPLE__ and __linux__, and since __linux__ was the default for toybox _without_ portability.c, i was using #if defined(__APPLE__) as a "here's the weird special case".</div><div><br></div><div>but if we're expecting to support macOS/iOS _and_ the three main BSDs (and we haven't even heard from the really niche ones yet, which have their _own_ #defines!), maybe</div><div><br></div><div>#if defined(__linux__)</div><div>#else // Some kind of BSD</div><div>#endif</div><div><br></div><div>should be the default idiom? and we can just add #elif as/when needed for genuine special cases?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +realpath 35535 enh 4r LINK 1,18 7 19337567<br>
> /Users/enh/toybox/generated/testdir/testdir/dos<br>
> make: *** [test_realpath] Error 1<br>
> ~/toybox$ <br>
> <br>
> (the lsof output there shows you what dirfd=4 is actually pointing to.)<br>
<br>
MacOS opened the symlink. And then refuses to use that as an openat() base<br>
because the symlink points to a directory but is not itself a directory. Great.<br>
<br>
Note I did _NOT_ give it O_NOFOLLOW. In fact the Linux man 2 openat says that<br>
O_NOFOLLOW is a FreeBSD extension. I wonder if FreeBSD gets it right?<br></blockquote><div><br></div><div>yeah, hard to know without trying it. i've no idea how much apple's BSD "personality" grafted on to the mach stuff actually shares code with BSD. (or whether it _did_ once but effectively forked in the 1980s in the NeXT days, and has gone its own path since then.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Rob<br>
</blockquote></div></div>