BSD 4_4_Lite2 release
[unix-history] / usr / src / sys / miscfs / portal / portal_vfsops.c
index 5ff8a5c..8aff570 100644 (file)
@@ -1,14 +1,39 @@
 /*
 /*
- * Copyright (c) 1992 The Regents of the University of California
- * Copyright (c) 1990, 1992 Jan-Simon Pendry
- * All rights reserved.
+ * Copyright (c) 1992, 1993, 1995
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
- * %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.
  *
  *
- *     @(#)portal_vfsops.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.
+ *
+ *     @(#)portal_vfsops.c     8.11 (Berkeley) 5/14/95
  *
  * $Id: portal_vfsops.c,v 1.5 1992/05/30 10:25:27 jsp Exp jsp $
  */
  *
  * $Id: portal_vfsops.c,v 1.5 1992/05/30 10:25:27 jsp Exp jsp $
  */
 #include <sys/un.h>
 #include <miscfs/portal/portal.h>
 
 #include <sys/un.h>
 #include <miscfs/portal/portal.h>
 
-static u_short portal_mntid;
-
-int portal_init()
+int
+portal_init(vfsp)
+       struct vfsconf *vfsp;
 {
 
 {
 
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_init\n");                /* printed during system boot */
-#endif
+       return (0);
 }
 
 /*
  * Mount the per-process file descriptors (/dev/fd)
  */
 }
 
 /*
  * Mount the per-process file descriptors (/dev/fd)
  */
+int
 portal_mount(mp, path, data, ndp, p)
        struct mount *mp;
        char *path;
 portal_mount(mp, path, data, ndp, p)
        struct mount *mp;
        char *path;
@@ -56,19 +80,13 @@ portal_mount(mp, path, data, ndp, p)
        struct nameidata *ndp;
        struct proc *p;
 {
        struct nameidata *ndp;
        struct proc *p;
 {
-       int error = 0;
+       struct file *fp;
        struct portal_args args;
        struct portal_args args;
-       u_int size;
        struct portalmount *fmp;
        struct portalmount *fmp;
-       struct vnode *rvp;
-       struct sockaddr_un *unp;
-       struct file *fp;
        struct socket *so;
        struct socket *so;
-       char cfile[MAXPATHLEN];
-
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_mount(mp = %x)\n", mp);
-#endif
+       struct vnode *rvp;
+       u_int size;
+       int error;
 
        /*
         * Update is a no-op
 
        /*
         * Update is a no-op
@@ -85,7 +103,7 @@ portal_mount(mp, path, data, ndp, p)
        if (so->so_proto->pr_domain->dom_family != AF_UNIX)
                return (ESOCKTNOSUPPORT);
 
        if (so->so_proto->pr_domain->dom_family != AF_UNIX)
                return (ESOCKTNOSUPPORT);
 
-       error = getnewvnode(VT_UFS, mp, portal_vnodeop_p, &rvp); /* XXX */
+       error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */
        if (error)
                return (error);
        MALLOC(rvp->v_data, void *, sizeof(struct portalnode),
        if (error)
                return (error);
        MALLOC(rvp->v_data, void *, sizeof(struct portalnode),
@@ -98,20 +116,17 @@ portal_mount(mp, path, data, ndp, p)
        VTOPORTAL(rvp)->pt_arg = 0;
        VTOPORTAL(rvp)->pt_size = 0;
        VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
        VTOPORTAL(rvp)->pt_arg = 0;
        VTOPORTAL(rvp)->pt_size = 0;
        VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_mount: root vp = %x\n", rvp);
-#endif
        fmp->pm_root = rvp;
        fmp->pm_server = fp; fp->f_count++;
 
        mp->mnt_flag |= MNT_LOCAL;
        mp->mnt_data = (qaddr_t) fmp;
        fmp->pm_root = rvp;
        fmp->pm_server = fp; fp->f_count++;
 
        mp->mnt_flag |= MNT_LOCAL;
        mp->mnt_data = (qaddr_t) fmp;
-       getnewfsid(mp, MOUNT_PORTAL);
+       vfs_getnewfsid(mp);
 
 
-       (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
+       (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
        bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
        bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
-       (void) copyinstr(args.pa_config, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
-               &size);
+       (void)copyinstr(args.pa_config,
+           mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size);
        bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
 
 #ifdef notdef
        bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
 
 #ifdef notdef
@@ -119,13 +134,10 @@ portal_mount(mp, path, data, ndp, p)
        bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal"));
 #endif
 
        bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal"));
 #endif
 
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_mount: config %s at %s\n",
-                       mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
-#endif
        return (0);
 }
 
        return (0);
 }
 
+int
 portal_start(mp, flags, p)
        struct mount *mp;
        int flags;
 portal_start(mp, flags, p)
        struct mount *mp;
        int flags;
@@ -135,26 +147,18 @@ portal_start(mp, flags, p)
        return (0);
 }
 
        return (0);
 }
 
+int
 portal_unmount(mp, mntflags, p)
        struct mount *mp;
        int mntflags;
        struct proc *p;
 {
 portal_unmount(mp, mntflags, p)
        struct mount *mp;
        int mntflags;
        struct proc *p;
 {
-       int error;
-       int flags = 0;
-       extern int doforce;
        struct vnode *rootvp = VFSTOPORTAL(mp)->pm_root;
        struct vnode *rootvp = VFSTOPORTAL(mp)->pm_root;
+       int error, flags = 0;
 
 
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount(mp = %x)\n", mp);
-#endif
 
 
-       if (mntflags & MNT_FORCE) {
-               /* portal can never be rootfs so don't check for it */
-               if (!doforce)
-                       return (EINVAL);
+       if (mntflags & MNT_FORCE)
                flags |= FORCECLOSE;
                flags |= FORCECLOSE;
-       }
 
        /*
         * Clear out buffer cache.  I don't think we
 
        /*
         * Clear out buffer cache.  I don't think we
@@ -162,27 +166,15 @@ portal_unmount(mp, mntflags, p)
         * moment, but who knows...
         */
 #ifdef notyet
         * moment, but who knows...
         */
 #ifdef notyet
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount: calling mntflushbuf\n");
-#endif
        mntflushbuf(mp, 0); 
        mntflushbuf(mp, 0); 
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount: calling mntinvalbuf\n");
-#endif
        if (mntinvalbuf(mp, 1))
                return (EBUSY);
 #endif
        if (rootvp->v_usecount > 1)
                return (EBUSY);
        if (mntinvalbuf(mp, 1))
                return (EBUSY);
 #endif
        if (rootvp->v_usecount > 1)
                return (EBUSY);
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount: calling vflush\n");
-#endif
        if (error = vflush(mp, rootvp, flags))
                return (error);
 
        if (error = vflush(mp, rootvp, flags))
                return (error);
 
-#ifdef PORTAL_DIAGNOSTIC
-       vprint("portal root", rootvp);
-#endif  
        /*
         * Release reference on underlying root vnode
         */
        /*
         * Release reference on underlying root vnode
         */
@@ -196,17 +188,11 @@ portal_unmount(mp, mntflags, p)
         * daemon to wake up, and then the accept will get ECONNABORTED
         * which it interprets as a request to go and bury itself.
         */
         * daemon to wake up, and then the accept will get ECONNABORTED
         * which it interprets as a request to go and bury itself.
         */
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount: shutdown socket\n");
-#endif  
        soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
        /*
         * Discard reference to underlying file.  Must call closef because
         * this may be the last reference.
         */
        soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
        /*
         * Discard reference to underlying file.  Must call closef because
         * this may be the last reference.
         */
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_unmount: closef(%x)\n", VFSTOPORTAL(mp)->pm_server);
-#endif  
        closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0);
        /*
         * Finally, throw away the portalmount structure
        closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0);
        /*
         * Finally, throw away the portalmount structure
@@ -216,54 +202,31 @@ portal_unmount(mp, mntflags, p)
        return (0);
 }
 
        return (0);
 }
 
+int
 portal_root(mp, vpp)
        struct mount *mp;
        struct vnode **vpp;
 {
 portal_root(mp, vpp)
        struct mount *mp;
        struct vnode **vpp;
 {
+       struct proc *p = curproc;       /* XXX */
        struct vnode *vp;
        struct vnode *vp;
-       int error;
-
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_root(mp = %x)\n", mp);
-#endif
 
        /*
         * Return locked reference to root.
         */
        vp = VFSTOPORTAL(mp)->pm_root;
        VREF(vp);
 
        /*
         * Return locked reference to root.
         */
        vp = VFSTOPORTAL(mp)->pm_root;
        VREF(vp);
-       VOP_LOCK(vp);
+       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
        *vpp = vp;
        return (0);
 }
 
        *vpp = vp;
        return (0);
 }
 
-portal_quotactl(mp, cmd, uid, arg, p)
-       struct mount *mp;
-       int cmd;
-       uid_t uid;
-       caddr_t arg;
-       struct proc *p;
-{
-
-       return (EOPNOTSUPP);
-}
-
+int
 portal_statfs(mp, sbp, p)
        struct mount *mp;
        struct statfs *sbp;
        struct proc *p;
 {
 portal_statfs(mp, sbp, p)
        struct mount *mp;
        struct statfs *sbp;
        struct proc *p;
 {
-       struct filedesc *fdp;
-       int lim;
-       int i;
-       int last;
-       int freefd;
 
 
-#ifdef PORTAL_DIAGNOSTIC
-       printf("portal_statfs(mp = %x)\n", mp);
-#endif
-
-       sbp->f_type = MOUNT_PORTAL;
        sbp->f_flags = 0;
        sbp->f_bsize = DEV_BSIZE;
        sbp->f_iosize = DEV_BSIZE;
        sbp->f_flags = 0;
        sbp->f_bsize = DEV_BSIZE;
        sbp->f_iosize = DEV_BSIZE;
@@ -273,6 +236,7 @@ portal_statfs(mp, sbp, p)
        sbp->f_files = 1;               /* Allow for "." */
        sbp->f_ffree = 0;               /* See comments above */
        if (sbp != &mp->mnt_stat) {
        sbp->f_files = 1;               /* Allow for "." */
        sbp->f_ffree = 0;               /* See comments above */
        if (sbp != &mp->mnt_stat) {
+               sbp->f_type = mp->mnt_vfc->vfc_typenum;
                bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
                bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
                bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
                bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
                bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
                bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
@@ -280,39 +244,17 @@ portal_statfs(mp, sbp, p)
        return (0);
 }
 
        return (0);
 }
 
-portal_sync(mp, waitfor)
-       struct mount *mp;
-       int waitfor;
-{
-
-       return (0);
-}
-
-portal_vget(mp, ino, vpp)
-       struct mount *mp;
-       ino_t ino;
-       struct vnode **vpp;
-{
-
-       return (EOPNOTSUPP);
-}
-
-portal_fhtovp(mp, fhp, vpp)
-       struct mount *mp;
-       struct fid *fhp;
-       struct vnode **vpp;
-{
-
-       return (EOPNOTSUPP);
-}
-
-portal_vptofh(vp, fhp)
-       struct vnode *vp;
-       struct fid *fhp;
-{
-
-       return (EOPNOTSUPP);
-}
+#define portal_fhtovp ((int (*) __P((struct mount *, struct fid *, \
+           struct mbuf *, struct vnode **, int *, struct ucred **)))eopnotsupp)
+#define portal_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \
+           struct proc *)))eopnotsupp)
+#define portal_sync ((int (*) __P((struct mount *, int, struct ucred *, \
+           struct proc *)))nullop)
+#define portal_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \
+           size_t, struct proc *)))eopnotsupp)
+#define portal_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \
+           eopnotsupp)
+#define portal_vptofh ((int (*) __P((struct vnode *, struct fid *)))eopnotsupp)
 
 struct vfsops portal_vfsops = {
        portal_mount,
 
 struct vfsops portal_vfsops = {
        portal_mount,
@@ -326,4 +268,5 @@ struct vfsops portal_vfsops = {
        portal_fhtovp,
        portal_vptofh,
        portal_init,
        portal_fhtovp,
        portal_vptofh,
        portal_init,
+       portal_sysctl,
 };
 };