On Thu, Jan 06, 2022 at 11:38:58PM +0000, RVP wrote: > On Thu, 6 Jan 2022, Manuel Bouyer wrote: > > > the second issue is that it expects /emul/linux/proc/self/fd/4 to be a > > working > > symlink, and on NetBSD it's not. Note that with /bin/ls I get something > > similar: > > armandeche:/local/armandeche1/tmp#ktrace -i ls -l /proc/self/fd/ > > total 2 > > crw--w---- 1 bouyer tty 5, 0 Jan 6 17:54 0 > > crw--w---- 1 bouyer tty 5, 0 Jan 6 17:54 1 > > crw--w---- 1 bouyer tty 5, 0 Jan 6 17:54 2 > > lr-xr-xr-x 1 root wheel 2048 Jan 6 17:54 3 -> /local/armandeche1/tmp > > > > ls: /proc/self/fd//4: Invalid argument > > lr-xr-xr-x 1 root wheel 0 Jan 6 17:54 4 > > > > 22875 1 ls CALL readlink(0x7f7fffb98200,0x7f7fffb98610,0x400) > > 22875 1 ls NAMI "/proc/self/fd//4" > > 22875 1 ls RET readlink -1 errno 22 Invalid argument > > > > If I can trust the ktrace output, fd/4 should point to /etc/spwd.db > > > > On linux, strace shows it reading the link from /proc/self/exec, getting > > back > > > > This 2nd issue I think I can explain: the fd existed at the start of a > readdir(), but, then is closed sometime when the listing is still in > progress as in the code below:
It could be it, as when the directory is read, fd 4 is the directory itself. But at the time of the readlink, fd 4 is definitively open, but points to another file (I can't see a close(4) between the open("/etc/spwd.db") and the readlink()). Anyway, the issue with the linux binary is likely different. -- Manuel Bouyer <bou...@antioche.eu.org> NetBSD: 26 ans d'experience feront toujours la difference --