BSD 4_4 release
[unix-history] / usr / src / sys / miscfs / umapfs / umap_vnops.c
index 77b702d..276632e 100644 (file)
@@ -1,15 +1,39 @@
 /*
 /*
- * Copyright (c) 1992 The Regents of the University of California
- * All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * the UCLA Ficus project.
  *
  *
  * This code is derived from software donated to Berkeley by
  * the UCLA Ficus project.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)umap_vnops.c        7.1 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  *
- * @(#)umap_vnops.c       1.5 (Berkeley) 7/10/92
+ *     @(#)umap_vnops.c        8.1 (Berkeley) 6/10/93
  */
 
 /*
  */
 
 /*
@@ -25,7 +49,7 @@
 #include <sys/namei.h>
 #include <sys/malloc.h>
 #include <sys/buf.h>
 #include <sys/namei.h>
 #include <sys/malloc.h>
 #include <sys/buf.h>
-#include <umapfs/umap.h>
+#include <miscfs/umapfs/umap.h>
 
 
 int umap_bug_bypass = 0;   /* for debugging: enables bypass printf'ing */
 
 
 int umap_bug_bypass = 0;   /* for debugging: enables bypass printf'ing */
@@ -36,7 +60,10 @@ int umap_bug_bypass = 0;   /* for debugging: enables bypass printf'ing */
  */ 
 int
 umap_bypass(ap)
  */ 
 int
 umap_bypass(ap)
-       struct vop_generic_args *ap;
+       struct vop_generic_args /* {
+               struct vnodeop_desc *a_desc;
+               <other random data follows, presumably>
+       } */ *ap;
 {
        extern int (**umap_vnodeop_p)();  /* not extern, really "forward" */
        int *mapdata, nentries ;
 {
        extern int (**umap_vnodeop_p)();  /* not extern, really "forward" */
        int *mapdata, nentries ;
@@ -225,7 +252,12 @@ umap_bypass(ap)
  */
 int
 umap_getattr(ap)
  */
 int
 umap_getattr(ap)
-       struct vop_getattr_args *ap;
+       struct vop_getattr_args /* {
+               struct vnode *a_vp;
+               struct vattr *a_vap;
+               struct ucred *a_cred;
+               struct proc *a_p;
+       } */ *ap;
 {
        short uid, gid;
        int error, tmpid, *mapdata, nentries, *gmapdata, gnentries;
 {
        short uid, gid;
        int error, tmpid, *mapdata, nentries, *gmapdata, gnentries;
@@ -233,7 +265,7 @@ umap_getattr(ap)
        struct vnodeop_desc *descp = ap->a_desc;
 
        if (error = umap_bypass(ap))
        struct vnodeop_desc *descp = ap->a_desc;
 
        if (error = umap_bypass(ap))
-               return error;
+               return (error);
        /* Requires that arguments be restored. */
        ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
 
        /* Requires that arguments be restored. */
        ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
 
@@ -287,12 +319,14 @@ umap_getattr(ap)
        } else
                ap->a_vap->va_gid = (gid_t)NULLGROUP;
        
        } else
                ap->a_vap->va_gid = (gid_t)NULLGROUP;
        
-       return 0;
+       return (0);
 }
 
 int
 }
 
 int
-umap_inactive (ap)
-       struct vop_inactive_args *ap;
+umap_inactive(ap)
+       struct vop_inactive_args /* {
+               struct vnode *a_vp;
+       } */ *ap;
 {
        /*
         * Do nothing (and _don't_ bypass).
 {
        /*
         * Do nothing (and _don't_ bypass).
@@ -301,12 +335,14 @@ umap_inactive (ap)
         * cache and reusable.
         *
         */
         * cache and reusable.
         *
         */
-       return 0;
+       return (0);
 }
 
 int
 }
 
 int
-umap_reclaim (ap)
-       struct vop_reclaim_args *ap;
+umap_reclaim(ap)
+       struct vop_reclaim_args /* {
+               struct vnode *a_vp;
+       } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
        struct umap_node *xp = VTOUMAP(vp);
 {
        struct vnode *vp = ap->a_vp;
        struct umap_node *xp = VTOUMAP(vp);
@@ -318,12 +354,14 @@ umap_reclaim (ap)
        FREE(vp->v_data, M_TEMP);
        vp->v_data = NULL;
        vrele (lowervp);
        FREE(vp->v_data, M_TEMP);
        vp->v_data = NULL;
        vrele (lowervp);
-       return 0;
+       return (0);
 }
 
 int
 }
 
 int
-umap_strategy (ap)
-       struct vop_strategy_args *ap;
+umap_strategy(ap)
+       struct vop_strategy_args /* {
+               struct buf *a_bp;
+       } */ *ap;
 {
        struct buf *bp = ap->a_bp;
        int error;
 {
        struct buf *bp = ap->a_bp;
        int error;
@@ -336,12 +374,14 @@ umap_strategy (ap)
 
        bp->b_vp = savedvp;
 
 
        bp->b_vp = savedvp;
 
-       return error;
+       return (error);
 }
 
 int
 }
 
 int
-umap_bwrite (ap)
-       struct vop_bwrite_args *ap;
+umap_bwrite(ap)
+       struct vop_bwrite_args /* {
+               struct buf *a_bp;
+       } */ *ap;
 {
        struct buf *bp = ap->a_bp;
        int error;
 {
        struct buf *bp = ap->a_bp;
        int error;
@@ -354,30 +394,41 @@ umap_bwrite (ap)
 
        bp->b_vp = savedvp;
 
 
        bp->b_vp = savedvp;
 
-       return error;
+       return (error);
 }
 
 
 int
 }
 
 
 int
-umap_print (ap)
-       struct vop_print_args *ap;
+umap_print(ap)
+       struct vop_print_args /* {
+               struct vnode *a_vp;
+       } */ *ap;
 {
        register struct vnode *vp = ap->a_vp;
        printf ("\ttag VT_UMAPFS, vp=%x, lowervp=%x\n", vp, UMAPVPTOLOWERVP(vp));
 {
        register struct vnode *vp = ap->a_vp;
        printf ("\ttag VT_UMAPFS, vp=%x, lowervp=%x\n", vp, UMAPVPTOLOWERVP(vp));
-       return 0;
+       return (0);
 }
 
 int
 umap_rename(ap)
 }
 
 int
 umap_rename(ap)
-       struct vop_rename_args *ap;
+       struct vop_rename_args  /* {
+               struct vnode *a_fdvp;
+               struct vnode *a_fvp;
+               struct componentname *a_fcnp;
+               struct vnode *a_tdvp;
+               struct vnode *a_tvp;
+               struct componentname *a_tcnp;
+       } */ *ap;
 {
        int error;
        struct componentname *compnamep;
        struct ucred *compcredp, *savecompcredp;
        struct vnode *vp;
 
 {
        int error;
        struct componentname *compnamep;
        struct ucred *compcredp, *savecompcredp;
        struct vnode *vp;
 
-       /* Now map the second componentname structure kept in this vop's
-        * arguments. 
+       /*
+        * Rename is irregular, having two componentname structures.
+        * We need to map the cre in the second structure,
+        * and then bypass takes care of the rest.
         */
 
        vp = ap->a_fdvp;
         */
 
        vp = ap->a_fdvp;
@@ -399,14 +450,14 @@ umap_rename(ap)
                printf("umap_rename: rename component credit user now %d, group %d\n", 
                    compcredp->cr_uid,compcredp->cr_gid);
 
                printf("umap_rename: rename component credit user now %d, group %d\n", 
                    compcredp->cr_uid,compcredp->cr_gid);
 
-       if (error = umap_bypass(ap))
-               return error;
+       error = umap_bypass(ap);
        
        /* Restore the additional mapped componentname cred structure. */
 
        crfree(compcredp);
        compnamep->cn_cred = savecompcredp;
        
        /* Restore the additional mapped componentname cred structure. */
 
        crfree(compcredp);
        compnamep->cn_cred = savecompcredp;
-       
+
+       return error;
 }
 
 /*
 }
 
 /*
@@ -425,6 +476,7 @@ struct vnodeopv_entry_desc umap_vnodeop_entries[] = {
        { &vop_inactive_desc, umap_inactive },
        { &vop_reclaim_desc, umap_reclaim },
        { &vop_print_desc, umap_print },
        { &vop_inactive_desc, umap_inactive },
        { &vop_reclaim_desc, umap_reclaim },
        { &vop_print_desc, umap_print },
+       { &vop_rename_desc, umap_rename },
 
        { &vop_strategy_desc, umap_strategy },
        { &vop_bwrite_desc, umap_bwrite },
 
        { &vop_strategy_desc, umap_strategy },
        { &vop_bwrite_desc, umap_bwrite },