Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs We must handle MNT_NODEV at open time, so add an ...



details:   https://anonhg.NetBSD.org/src/rev/292fe7998413
branches:  trunk
changeset: 467516:292fe7998413
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Thu Mar 25 13:05:41 1999 +0000

description:
We must handle MNT_NODEV at open time, so add an open op for null and union,
and do proper checks in union_open(). Fix to nullfs from OpenBSD, extended
to umap and union by me.

diffstat:

 sys/miscfs/nullfs/null_vnops.c |  25 +++++++++++++++++++++++--
 sys/miscfs/umapfs/umap_vnops.c |  25 ++++++++++++++++++++++++-
 sys/miscfs/union/union_vnops.c |  13 +++++++++++--
 3 files changed, 58 insertions(+), 5 deletions(-)

diffs (148 lines):

diff -r 1a9690540f83 -r 292fe7998413 sys/miscfs/nullfs/null_vnops.c
--- a/sys/miscfs/nullfs/null_vnops.c    Thu Mar 25 12:58:33 1999 +0000
+++ b/sys/miscfs/nullfs/null_vnops.c    Thu Mar 25 13:05:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: null_vnops.c,v 1.14 1999/03/22 17:24:21 sommerfe Exp $ */
+/*     $NetBSD: null_vnops.c,v 1.15 1999/03/25 13:05:41 bouyer Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  *
  * Ancestors:
  *     @(#)lofs_vnops.c        1.2 (Berkeley) 6/18/92
- *     $Id: null_vnops.c,v 1.14 1999/03/22 17:24:21 sommerfe Exp $
+ *     $Id: null_vnops.c,v 1.15 1999/03/25 13:05:41 bouyer Exp $
  *     ...and...
  *     @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
  */
@@ -203,6 +203,7 @@
 int    null_lookup __P((void *));
 int    null_setattr __P((void *));
 int    null_access __P((void *));
+int    null_open __P((void *));
 
 
 /*
@@ -495,6 +496,24 @@
 }
 
 /*
+ * We must handle open to be able to catch MNT_NODEV and friends.
+ */
+int
+null_open(v)
+       void *v;
+{
+       struct vop_open_args *ap = v;
+       struct vnode *vp = ap->a_vp;
+       enum vtype lower_type = NULLVPTOLOWERVP(vp)->v_type;
+
+       if (((lower_type == VBLK) || (lower_type == VCHR)) &&
+           (vp->v_mount->mnt_flag & MNT_NODEV))
+               return ENXIO;
+
+       return null_bypass(ap);
+}
+
+/*
  * We need to process our own vnode lock and then clear the
  * interlock flag as it applies only to our vnode, not the
  * vnodes below us on the stack.
@@ -694,6 +713,8 @@
        { &vop_reclaim_desc,  null_reclaim },
        { &vop_print_desc,    null_print },
 
+       { &vop_open_desc,     null_open },      /* mount option handling */
+
        { &vop_strategy_desc, null_strategy },
        { &vop_bwrite_desc,   null_bwrite },
 
diff -r 1a9690540f83 -r 292fe7998413 sys/miscfs/umapfs/umap_vnops.c
--- a/sys/miscfs/umapfs/umap_vnops.c    Thu Mar 25 12:58:33 1999 +0000
+++ b/sys/miscfs/umapfs/umap_vnops.c    Thu Mar 25 13:05:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umap_vnops.c,v 1.12 1999/03/22 17:24:22 sommerfe Exp $ */
+/*     $NetBSD: umap_vnops.c,v 1.13 1999/03/25 13:05:42 bouyer Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -67,6 +67,7 @@
 int    umap_bwrite     __P((void *));
 int    umap_lock       __P((void *));
 int    umap_unlock     __P((void *));
+int    umap_open       __P((void *));
 int    umap_fsync      __P((void *));
 
 extern int  null_bypass __P((void *));
@@ -90,6 +91,9 @@
        { &vop_inactive_desc, umap_inactive },
        { &vop_reclaim_desc, umap_reclaim },
        { &vop_print_desc, umap_print },
+
+       { &vop_open_desc, umap_open }, /* mount option handling */
+
        { &vop_rename_desc, umap_rename },
 
        { &vop_strategy_desc, umap_strategy },
@@ -441,6 +445,25 @@
        return (0);
 }
 
+/* 
+ * We must handle open to be able to catch MNT_NODEV and friends.
+ */   
+int
+umap_open(v)
+        void *v;
+{
+        struct vop_open_args *ap = v;
+        struct vnode *vp = ap->a_vp;
+        enum vtype lower_type = UMAPVPTOLOWERVP(vp)->v_type;
+
+
+        if (((lower_type == VBLK) || (lower_type == VCHR)) &&
+            (vp->v_mount->mnt_flag & MNT_NODEV))
+                return ENXIO;
+
+        return umap_bypass(ap);
+}
+
 /*ARGSUSED*/
 int
 umap_inactive(v)
diff -r 1a9690540f83 -r 292fe7998413 sys/miscfs/union/union_vnops.c
--- a/sys/miscfs/union/union_vnops.c    Thu Mar 25 12:58:33 1999 +0000
+++ b/sys/miscfs/union/union_vnops.c    Thu Mar 25 13:05:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: union_vnops.c,v 1.43 1999/03/22 17:24:22 sommerfe Exp $        */
+/*     $NetBSD: union_vnops.c,v 1.44 1999/03/25 13:05:42 bouyer Exp $  */
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry.
@@ -639,8 +639,11 @@
                }
 
                /*
-                * Just open the lower vnode
+                * Just open the lower vnode, but check for nodev mount flag
                 */
+               if ((tvp->v_type == VBLK || tvp->v_type == VCHR) &&
+                   (ap->a_vp->v_mount->mnt_flag & MNT_NODEV))
+                       return ENXIO;
                un->un_openl++;
                vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY);
                error = VOP_OPEN(tvp, mode, cred, p);
@@ -648,6 +651,12 @@
 
                return (error);
        }
+       /*
+        * Just open the upper vnode, checking for nodev mount flag first
+        */
+       if ((tvp->v_type == VBLK || tvp->v_type == VCHR) &&
+           (ap->a_vp->v_mount->mnt_flag & MNT_NODEV))
+               return ENXIO;
 
        FIXUP(un);
 



Home | Main Index | Thread Index | Old Index