PSA: So you want to be a good kid, and understand that UNIX file system paths are kind wonky, and not stable references to inodes. So you drink the Linux cool-aid, and become a heavy O_PATH user: you pin all inodes via fds, validate them before you open them, use openat() heavily to get from one inode to descendents and are extra careful everywhere. And you think you saw the light.

But then one day, you realize, you *actually* have been doing it all wrong.

Because here's the thing: if you go from one dir for which you have an O_PATH fd to another dir contained in it, via openat(fd, name, O_PATH|O_CLOEXEC), then this actually doesn't trigger autofs mounts. So if "name" actually is an autofs mount, you end up pinning an inode on the autofs, and not one on the file system it's supposed to be overmounted with. So if you then use openat(…, O_PATH|O_CLOEXEC) to go further down, it will *always* fail, because the autofs doesn't contain any further…

Follow

@pid_eins 'ls' misbehaves on automounted NFS, probably because of this. 'ls /mnt/point' fails until you do 'ls /mnt/point/' once.
@alg0w

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.