Re: mount_mfs: why chdir?

Mouse <[email protected]> Mon, 31 Mar 2025 10:22:55 -0400 (EDT)
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
>> I think [chdir] should be done _after_ the mount() call,
> If you do it that way, there would be a race with an immediately
> following umount, which would fail if attemted between the mount and
> the chdir which follows.

That happens only if cwd is the mount-on directory (at least in 5.2);
if a process's cwd is in a subdir of the mount-on directory, its cwd
after the mount is still under the covered directory, not the covering
directory.  (I also would argue it's a bug that cwds equaling the
covered directory are silently moved to the covering directory, but
that's a separate issue.)

mlelstv pointed out upthread that 10.1 (and presumably current)
mount_mfs absolutifies relative mount-on paths before mounting, so all
that's needed is that the chdir happen after converting the path; I
haven't checked that (cvsweb seems to be handing out 403s at the
moment), but would assume it's so.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		[email protected]
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B