From 0b0826633ebc1ec3f6feb3b32e1c7a373b73fe5a Mon Sep 17 00:00:00 2001 From: rodrigc Date: Sat, 27 Oct 2007 15:59:18 +0000 Subject: [PATCH] In nmount(), if MNT_ROOT is in the mount flags, filter it out instead of returning an error. (1) This makes the behavior consistent with mount(2). (2) This makes update mounts on the root file system work properly. (3) The explicit checks for MNT_ROOTFS in src/sbin/fsck_ffs/main.c and src/usr.sbin/mountd/mountd.c which were put in to eliminate errors during update mounts on the root file system can be removed. The only place were MNT_ROOTFS can be validly set is inside the kernel, i.e. with vfs_mountroot_try(). Reviewed by: phk MFC after: 3 days --- sys/kern/vfs_mount.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index e8fbd50690db..3628b3b98799 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -387,9 +387,13 @@ nmount(td, uap) AUDIT_ARG(fflags, uap->flags); - /* Kick out MNT_ROOTFS early as it is legal internally */ - if (uap->flags & MNT_ROOTFS) - return (EINVAL); + /* + * Filter out MNT_ROOTFS. We do not want clients of nmount() in + * userspace to set this flag, but we must filter it out if we want + * MNT_UPDATE on the root file system to work. + * MNT_ROOTFS should only be set in the kernel in vfs_mountroot_try(). + */ + uap->flags &= ~MNT_ROOTFS; iovcnt = uap->iovcnt; /* @@ -769,7 +773,12 @@ mount(td, uap) AUDIT_ARG(fflags, uap->flags); - /* Kick out MNT_ROOTFS early as it is legal internally */ + /* + * Filter out MNT_ROOTFS. We do not want clients of mount() in + * userspace to set this flag, but we must filter it out if we want + * MNT_UPDATE on the root file system to work. + * MNT_ROOTFS should only be set in the kernel in vfs_mountroot_try(). + */ uap->flags &= ~MNT_ROOTFS; fstype = malloc(MFSNAMELEN, M_TEMP, M_WAITOK);