BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / nfs / nfs_vfsops.c
index c1c9394..d08c12d 100644 (file)
@@ -5,9 +5,35 @@
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
  * This code is derived from software contributed to Berkeley by
  * Rick Macklem at The University of Guelph.
  *
- * %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.
  *
  *
- *     @(#)nfs_vfsops.c        7.28 (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.
+ *
+ *     @(#)nfs_vfsops.c        7.31 (Berkeley) 5/6/91
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -197,8 +223,6 @@ nfs_mountroot()
                swapdev_vp = vp;
                VREF(vp);
                swdevt[0].sw_vp = vp;
                swapdev_vp = vp;
                VREF(vp);
                swdevt[0].sw_vp = vp;
-               VREF(vp);
-               argdev_vp = vp;
        }
 
        /*
        }
 
        /*
@@ -260,21 +284,21 @@ nfs_mount(mp, path, data, ndp, p)
        struct mbuf *nam;
        struct vnode *vp;
        char pth[MNAMELEN], hst[MNAMELEN];
        struct mbuf *nam;
        struct vnode *vp;
        char pth[MNAMELEN], hst[MNAMELEN];
-       int len;
+       u_int len;
        nfsv2fh_t nfh;
 
        if (mp->mnt_flag & MNT_UPDATE)
                return (0);
        if (error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args)))
                return (error);
        nfsv2fh_t nfh;
 
        if (mp->mnt_flag & MNT_UPDATE)
                return (0);
        if (error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args)))
                return (error);
-       if (error=copyin((caddr_t)args.fh, (caddr_t)&nfh, sizeof (nfsv2fh_t)))
+       if (error = copyin((caddr_t)args.fh, (caddr_t)&nfh, sizeof (nfsv2fh_t)))
                return (error);
        if (error = copyinstr(path, pth, MNAMELEN-1, &len))
                return (error);
                return (error);
        if (error = copyinstr(path, pth, MNAMELEN-1, &len))
                return (error);
-       bzero(&pth[len], MNAMELEN-len);
+       bzero(&pth[len], MNAMELEN - len);
        if (error = copyinstr(args.hostname, hst, MNAMELEN-1, &len))
                return (error);
        if (error = copyinstr(args.hostname, hst, MNAMELEN-1, &len))
                return (error);
-       bzero(&hst[len], MNAMELEN-len);
+       bzero(&hst[len], MNAMELEN - len);
        /* sockargs() call must be after above copyin() calls */
        if (error = sockargs(&nam, (caddr_t)args.addr,
                sizeof (struct sockaddr), MT_SONAME))
        /* sockargs() call must be after above copyin() calls */
        if (error = sockargs(&nam, (caddr_t)args.addr,
                sizeof (struct sockaddr), MT_SONAME))
@@ -341,7 +365,6 @@ mountnfs(argp, mp, nam, pth, hst, vpp)
        nmp->nm_wsize = NFS_WSIZE;
        nmp->nm_rsize = NFS_RSIZE;
        bcopy((caddr_t)argp->fh, (caddr_t)&nmp->nm_fh, sizeof(nfsv2fh_t));
        nmp->nm_wsize = NFS_WSIZE;
        nmp->nm_rsize = NFS_RSIZE;
        bcopy((caddr_t)argp->fh, (caddr_t)&nmp->nm_fh, sizeof(nfsv2fh_t));
-       mp->mnt_stat.f_type = MOUNT_NFS;
        bcopy(hst, mp->mnt_stat.f_mntfromname, MNAMELEN);
        bcopy(pth, mp->mnt_stat.f_mntonname, MNAMELEN);
        nmp->nm_nam = nam;
        bcopy(hst, mp->mnt_stat.f_mntfromname, MNAMELEN);
        bcopy(pth, mp->mnt_stat.f_mntonname, MNAMELEN);
        nmp->nm_nam = nam;
@@ -429,11 +452,11 @@ nfs_unmount(mp, mntflags, p)
        register struct nfsmount *nmp;
        struct nfsnode *np;
        struct vnode *vp;
        register struct nfsmount *nmp;
        struct nfsnode *np;
        struct vnode *vp;
-       int flags = 0;
-       int error;
+       int error, flags = 0;
+       extern int doforce;
 
        if (mntflags & MNT_FORCE) {
 
        if (mntflags & MNT_FORCE) {
-               if (mp == rootfs)
+               if (!doforce || mp == rootfs)
                        return (EINVAL);
                flags |= FORCECLOSE;
        }
                        return (EINVAL);
                flags |= FORCECLOSE;
        }