Subject: Re: patch to fix mount_nfs(8) problem with relative mount point
To: George Abdelmalik <gabdelmalik@avdat.com.au>
From: Peter Postma <peter@pointless.nl>
List: netbsd-users
Date: 01/28/2005 14:12:06
[reply-to set to tech-userlevel]

On Sat, Jan 29, 2005 at 04:57:24AM +1100, George Abdelmalik wrote:
> 
> From those who are interested, I've produced a patch for a problem in 
> mount_nfs(8) which arises when specify a relative path for the mount point.
> 
> I'm running 2-0-RELEASE, and have also verified this with a recent -current, 
> but have only tested the patch on 2-0.
> 
> See attached file mount_nfs.c.diff, this patch was created against HEAD.
> 
> If somebody what to bring the patch into the source tree that fine with me.
> 
> An example that illustrates the problem is presented as follows.
> 
> 
> => contents of /etc/exports:
> 
> /mnt/shared -mapall=gabdelmalik:users tb10
> 
> 
> => display currtenly mount directories
> 
> bash-3.00# mount
> 
> /dev/wd0a on / type ffs (NFS exported, local)
> 
> => change to /tmp ?and list
> 
> bash-3.00# cd /tmp
> bash-3.00# ls -l
> drwxr-xr-x ?2 root ? ? ? ? wheel ?512 Jan 29 03:26 mnt
> 
> => nfs mount /mnt/shared onto mnt
> 
> bash-3.00# mount_nfs tb10:/mnt/shared mnt
> 
> => display currently mounted directories
> 
> bash-3.00# mount
> /dev/wd0a on / type ffs (NFS exported, local)
> tb10:/mnt/shared on mnt type nfs
> ? ? ? ? ? ? ? ? ? ? ^^^ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
> ? ? ? ? ? ? ? ? ? ? ?|
> ? ? ? ? ? ? ? ? ? ? ?|-Note that mount point is listed with relative path
> 
> => the contents of the mount fs can be listed successfully
> 
> bash-3.00# ls mnt
> total 82
> -rw-r--r-- ?1 root ?wheel ?43779 Jan 29 03:26 NetBSD.png
> -rw-r--r-- ?1 root ?wheel ? ? ?1 Jan 29 03:26 SEE.altq.conf.manpage
> -rw-r--r-- ?1 root ?wheel ? ? ?1 Jan 29 03:26 SEE.chflags.manpage
> -rw-r--r-- ?1 root ?wheel ? ? ?1 Jan 29 03:26 SEE.dumpfs.manpage
> -rwxr-xr-x ?1 root ?wheel ? 9050 Jan 29 03:26 cpuflags.NetBSD
> -rwxr-xr-x ?1 root ?wheel ? ?645 Jan 29 03:26 dos2unix.sh
> -rwxr-xr-x ?1 root ?wheel ? ? 21 Jan 29 03:26 dos2unix.vi
> -rwx------ ?1 root ?wheel ? ?598 Jan 29 03:26 retouch.sh
> -rwxr-xr-x ?1 root ?wheel ?11736 Jan 29 03:26 slocc.sh
> -rwxr-xr-x ?1 root ?wheel ? ?243 Jan 29 03:26 spawn
> -rw-r--r-- ?1 root ?wheel ? ?419 Jan 29 03:26 trix
> 
> 
> => attempting to umount the fs using the mount point results in an error
> 
> bash-3.00# umount mnt
> umount: /tmp/mnt: not currently mounted
> 
> 
> => unmounting is only possible using rhost:path
> 
> bash-3.00# umount tb10:/mnt/shared
> bash-3.00# mount
> /dev/wd0a on / type ffs (NFS exported, local)
> 
> 
> => moding src/sbin/mount_nfs/mount_nfs.c ?to use realpath(3) [see diff 
> attached], allows a relative mount point to be specified with the mount_nfs 
> command, and be able to umount that fs in the normal may.
> 
> => using the newly built mount_nfs yields
> 
> 
> bash-3.00# mount_nfs tb10:/mnt/shared mnt
> bash-3.00# mount
> /dev/wd0a on / type ffs (NFS exported, local)
> tb10:/mnt/shared on /tmp/mnt type nfs
> ? ? ? ? ? ? ? ? ? ? ^^^^^^^^
> ? ? ? ? ? ? ? ? ? ? ? ?|
> ? ? ? ? ? ? ? ? ? ? ? ?|-Note that mount point is now shown with absolute path
> bash-3.00# umount mnt
> bash-3.00# mount
> /dev/wd0a on / type ffs (NFS exported, local)
> 
> 


I think this is very reasonable to do, and by using realpath(3) it also
fixes the trailing slash problem which has few PRs (3205, 25156, 28644).

But I think it's better to change all mount utils at once, instead
only mount_nfs. PR 3617 (from Eric Haszlakiewicz) seems to have to most
complete patches, but they're rather old.

Eric, will you take a look at this? (the PR is set to your responsibility :)

-- 
Peter Postma