Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Add special handling of VFS_GETARGS (similar to VFS...



details:   https://anonhg.NetBSD.org/src/rev/1b40ec0309d0
branches:  trunk
changeset: 536760:1b40ec0309d0
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Sep 21 18:07:52 2002 +0000

description:
Add special handling of VFS_GETARGS (similar to VFS_UPDATE) so that it
can be done non-root, and it does not affect the mount lists.

diffstat:

 sys/kern/vfs_syscalls.c |  32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diffs (87 lines):

diff -r 628d70342319 -r 1b40ec0309d0 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Sat Sep 21 18:06:08 2002 +0000
+++ b/sys/kern/vfs_syscalls.c   Sat Sep 21 18:07:52 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.176 2002/09/04 01:32:50 matt Exp $  */
+/*     $NetBSD: vfs_syscalls.c,v 1.177 2002/09/21 18:07:52 christos Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.176 2002/09/04 01:32:50 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.177 2002/09/21 18:07:52 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_43.h"
@@ -131,7 +131,8 @@
        struct nameidata nd;
        struct vfsops *vfs;
 
-       if (dovfsusermount == 0 && (error = suser(p->p_ucred, &p->p_acflag)))
+       if (dovfsusermount == 0 && (SCARG(uap, flags) & MNT_GETARGS) == 0 &&
+           (error = suser(p->p_ucred, &p->p_acflag)))
                return (error);
        /*
         * Get vnode to be covered
@@ -146,7 +147,7 @@
         * lock this vnode again, so make the lock resursive.
         */
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_SETRECURSE);
-       if (SCARG(uap, flags) & MNT_UPDATE) {
+       if (SCARG(uap, flags) & (MNT_UPDATE | MNT_GETARGS)) {
                if ((vp->v_flag & VROOT) == 0) {
                        vput(vp);
                        return (EINVAL);
@@ -166,22 +167,24 @@
                /*
                 * In "highly secure" mode, don't let the caller do anything
                 * but downgrade a filesystem from read-write to read-only.
-                * (see also below; MNT_UPDATE is required.)
+                * (see also below; MNT_UPDATE or MNT_GETARGS is required.)
                 */
                if (securelevel >= 2 &&
-                   (SCARG(uap, flags) !=
+                   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);
                }
-               mp->mnt_flag |=
-                   SCARG(uap, flags) & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
+               mp->mnt_flag |= SCARG(uap, flags) &
+                   (MNT_RELOAD | MNT_FORCE | MNT_UPDATE | MNT_GETARGS);
                /*
                 * Only root, or the user that did the original mount is
                 * permitted to update it.
                 */
-               if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid &&
+               if ((mp->mnt_flag & MNT_GETARGS) == 0 &&
+                   mp->mnt_stat.f_owner != p->p_ucred->cr_uid &&
                    (error = suser(p->p_ucred, &p->p_acflag)) != 0) {
                        vput(vp);
                        return (error);
@@ -308,13 +311,14 @@
         * Mount the filesystem.
         */
        error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p);
-       if (mp->mnt_flag & MNT_UPDATE) {
+       if (mp->mnt_flag & (MNT_UPDATE | MNT_GETARGS)) {
                if (mp->mnt_flag & MNT_WANTRDWR)
                        mp->mnt_flag &= ~MNT_RDONLY;
+               if (error || (mp->mnt_flag & MNT_GETARGS))
+                       mp->mnt_flag = flag;
                mp->mnt_flag &=~
-                   (MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR);
-               if (error)
-                       mp->mnt_flag = flag;
+                   (MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR |
+                    MNT_GETARGS);
                if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0) {
                        if (mp->mnt_syncer == NULL)
                                error = vfs_allocate_syncvnode(mp);



Home | Main Index | Thread Index | Old Index