Re: mount_mfs: why chdir?

Mouse <[email protected]> Sun, 30 Mar 2025 10:56:55 -0400 (EDT)
Newsgroups gmane.os.netbsd.devel.userlevel
Message-ID <[email protected]>
>> In sbin/newfs/newfs.c, I see, inter alia,

>> 		(void) chdir("/");
>> ...
>> 		if (mount(MOUNT_MFS, ...) =3D=3D -1)

>> Does anyone happen to know why the chdir to / is there?  [...]

> Maybe it's just for the case where you're mounting on top of one of
> your parent directories?  In that case you'd be in a directory that
> no longer can be reached.

Perhaps, but that's equally true of every other mount operation
(except, to a partial extent, union mounts).  Why would mount_mfs get
special treatment?  I don't see any chdir call in, for example,
mount_ffs.  It's tedious to check current, but on 9.1 and 5.2, grepping
for chdir in /usr/src/*/mount*/*.c finds up one call in mount_nfs and
nothing else (well, on 5.2, it also finds one hit in a comment).  (It
doesn't find the mount_mfs one because mount_mfs is built in
sbin/newfs.)

/~\ 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