svn commit: r292573 - head/sbin/mount

Alan Somers asomers at FreeBSD.org
Mon Dec 21 22:19:23 UTC 2015


Author: asomers
Date: Mon Dec 21 22:19:22 2015
New Revision: 292573
URL: https://svnweb.freebsd.org/changeset/base/292573

Log:
  Fix "mount -a" for NFS and ZFS filesystems with shared mountpoints
  
  sbin/mount.c
  	Check whether an fstab entry has the same fstype as a mounted
  	filesystem before declaring it to be mounted. This will allow NFS
  	filesystems that share a mountpoint with a local filesystem to be
  	automatically mounted at boot.
  
  	This is not such an unusual situation. For example, if somebody uses
  	the standard installer with a ZFS root, he'll get a /usr/home
  	filesystem, even though he may choose to mount /usr/home over NFS.
  
  Reviewed by:	trasz
  MFC after:	4 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D4556

Modified:
  head/sbin/mount/mount.c

Modified: head/sbin/mount/mount.c
==============================================================================
--- head/sbin/mount/mount.c	Mon Dec 21 22:16:09 2015	(r292572)
+++ head/sbin/mount/mount.c	Mon Dec 21 22:19:22 2015	(r292573)
@@ -485,10 +485,18 @@ ismounted(struct fstab *fs, struct statf
 		strlcpy(realfsfile, fs->fs_file, sizeof(realfsfile));
 	}
 
+	/* 
+	 * Consider the filesystem to be mounted if:
+	 * It has the same mountpoint as a mounted filesytem, and
+	 * It has the same type as that same mounted filesystem, and
+	 * It has the same device name as that same mounted filesystem, OR
+	 *     It is a nonremountable filesystem
+	 */
 	for (i = mntsize - 1; i >= 0; --i)
 		if (strcmp(realfsfile, mntbuf[i].f_mntonname) == 0 &&
+		    strcmp(fs->fs_vfstype, mntbuf[i].f_fstypename) == 0 && 
 		    (!isremountable(fs->fs_vfstype) ||
-		     strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
+		     (strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0)))
 			return (1);
 	return (0);
 }


More information about the svn-src-all mailing list