Subject: Re: Transient MNT_* flags left in mp->mnt_flag ?
To: Christos Zoulas <christos@zoulas.com>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-kern
Date: 10/13/2003 11:00:46
--Apple-Mail-5--285983268
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
On Monday, October 13, 2003, at 10:17 AM, Christos Zoulas wrote:
> Well, we are already using it in two places, so at least factor it out
> in the source file... It will be easier to spot where we clear the
> flags
> in the future.
Eh. There's lots of flags used in two places in sys_mount(). If I do
group flags together, I'd like to do it as a separate commit.
In the mean time, I've made a couple of other readability adjustments
to the existing code, and added one extra bit of code to allow
MNT_FORCE to be set on new mounts.
Attached is the patch I'll be checking in.
-- Jason R. Thorpe <thorpej@wasabisystems.com>
--Apple-Mail-5--285983268
Content-Disposition: attachment;
filename=mnt-patch.txt
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
x-unix-mode=0644;
name="mnt-patch.txt"
Index: vfs_syscalls.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.194
diff -u -r1.194 vfs_syscalls.c
--- vfs_syscalls.c 13 Sep 2003 08:32:14 -0000 1.194
+++ vfs_syscalls.c 13 Oct 2003 17:56:43 -0000
@@ -179,7 +179,7 @@
SCARG(uap, flags) != MNT_GETARGS &&
SCARG(uap, flags) !=
(mp->mnt_flag | MNT_RDONLY |
- MNT_RELOAD | MNT_FORCE | MNT_UPDATE)) {
+ MNT_RELOAD | MNT_FORCE | MNT_UPDATE)) {
vput(vp);
return (EPERM);
}
@@ -298,7 +298,14 @@
mp->mnt_vnodecovered = vp;
mp->mnt_stat.f_owner = p->p_ucred->cr_uid;
mp->mnt_unmounter = NULL;
-update:
+
+ /*
+ * The underlying file system may refuse the mount for
+ * various reasons. Allow root to force it to happen.
+ */
+ if (p->p_ucred->cr_uid == 0)
+ mp->mnt_flag |= SCARG(uap, flags) & MNT_FORCE;
+ update:
/*
* Set the mount level flags.
*/
@@ -306,13 +313,15 @@
mp->mnt_flag |= MNT_RDONLY;
else if (mp->mnt_flag & MNT_RDONLY)
mp->mnt_flag |= MNT_WANTRDWR;
- mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
+ mp->mnt_flag &=
+ ~(MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOCOREDUMP |
MNT_NOATIME | MNT_NODEVMTIME | MNT_SYMPERM | MNT_SOFTDEP);
- mp->mnt_flag |= SCARG(uap, flags) & (MNT_NOSUID | MNT_NOEXEC |
- MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC |
- MNT_NOCOREDUMP | MNT_IGNORE | MNT_NOATIME | MNT_NODEVMTIME |
- MNT_SYMPERM | MNT_SOFTDEP);
+ mp->mnt_flag |= SCARG(uap, flags) &
+ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
+ MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOCOREDUMP |
+ MNT_NOATIME | MNT_NODEVMTIME | MNT_SYMPERM | MNT_SOFTDEP |
+ MNT_IGNORE);
/*
* Mount the filesystem.
*/
@@ -323,8 +332,8 @@
if (error || (mp->mnt_flag & MNT_GETARGS))
mp->mnt_flag = flag;
mp->mnt_flag &=~
- (MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR |
- MNT_GETARGS);
+ (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_GETARGS |
+ MNT_WANTRDWR);
if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0) {
if (mp->mnt_syncer == NULL)
error = vfs_allocate_syncvnode(mp);
@@ -342,6 +351,9 @@
*/
cache_purge(vp);
if (!error) {
+ mp->mnt_flag &=~
+ (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_GETARGS |
+ MNT_WANTRDWR);
vp->v_mountedhere = mp;
simple_lock(&mountlist_slock);
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
--Apple-Mail-5--285983268--