add ufs_check_export
[unix-history] / usr / src / sys / ufs / lfs / lfs_vfsops.c
index df20507..68916b8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)lfs_vfsops.c        7.81 (Berkeley) %G%
+ *     @(#)lfs_vfsops.c        7.84 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -290,9 +290,6 @@ lfs_unmount(mp, mntflags, p)
        register struct lfs *fs;
        int i, error, flags, ronly;
 
        register struct lfs *fs;
        int i, error, flags, ronly;
 
-#ifdef VERBOSE
-       printf("lfs_unmount\n");
-#endif
        flags = 0;
        if (mntflags & MNT_FORCE) {
                if (!doforce || mp == rootfs)
        flags = 0;
        if (mntflags & MNT_FORCE) {
                if (!doforce || mp == rootfs)
@@ -318,7 +315,6 @@ lfs_unmount(mp, mntflags, p)
                 */
        }
 #endif
                 */
        }
 #endif
-       vrele(fs->lfs_ivnode);
        if (error = vflush(mp, fs->lfs_ivnode, flags))
                return (error);
        fs->lfs_clean = 1;
        if (error = vflush(mp, fs->lfs_ivnode, flags))
                return (error);
        fs->lfs_clean = 1;
@@ -326,6 +322,7 @@ lfs_unmount(mp, mntflags, p)
                return (error);
        if (fs->lfs_ivnode->v_dirtyblkhd)
                panic("lfs_unmount: still dirty blocks on ifile vnode\n");
                return (error);
        if (fs->lfs_ivnode->v_dirtyblkhd)
                panic("lfs_unmount: still dirty blocks on ifile vnode\n");
+       vrele(fs->lfs_ivnode);
        vgone(fs->lfs_ivnode);
 
        ronly = !fs->lfs_ronly;
        vgone(fs->lfs_ivnode);
 
        ronly = !fs->lfs_ronly;
@@ -346,10 +343,11 @@ lfs_statfs(mp, sbp, p)
        sbp->f_type = MOUNT_LFS;
        sbp->f_bsize = fs->lfs_bsize;
        sbp->f_iosize = fs->lfs_bsize;
        sbp->f_type = MOUNT_LFS;
        sbp->f_bsize = fs->lfs_bsize;
        sbp->f_iosize = fs->lfs_bsize;
-       sbp->f_blocks = fs->lfs_dsize;
+       sbp->f_blocks = dbtofsb(fs,fs->lfs_dsize);
        sbp->f_bfree = dbtofsb(fs, fs->lfs_bfree);
        sbp->f_bavail = (fs->lfs_dsize * (100 - fs->lfs_minfree) / 100) -
                (fs->lfs_dsize - sbp->f_bfree);
        sbp->f_bfree = dbtofsb(fs, fs->lfs_bfree);
        sbp->f_bavail = (fs->lfs_dsize * (100 - fs->lfs_minfree) / 100) -
                (fs->lfs_dsize - sbp->f_bfree);
+       sbp->f_bavail = dbtofsb(fs, sbp->f_bavail);
        sbp->f_files = fs->lfs_nfiles;
        sbp->f_ffree = sbp->f_bfree * INOPB(fs);
        if (sbp != &mp->mnt_stat) {
        sbp->f_files = fs->lfs_nfiles;
        sbp->f_ffree = sbp->f_bfree * INOPB(fs);
        if (sbp != &mp->mnt_stat) {
@@ -374,18 +372,9 @@ lfs_sync(mp, waitfor, cred, p)
        struct ucred *cred;
        struct proc *p;
 {
        struct ucred *cred;
        struct proc *p;
 {
-       extern int crashandburn, syncprt;
+       extern int syncprt;
        int error;
 
        int error;
 
-#ifdef VERBOSE
-       printf("lfs_sync\n");
-#endif
-
-#ifdef DIAGNOSTIC
-       if (crashandburn)
-               return (0);
-#endif
-
        /* All syncs must be checkpoints until roll-forward is implemented. */
        error = lfs_segwrite(mp, 1);
 #ifdef QUOTA
        /* All syncs must be checkpoints until roll-forward is implemented. */
        error = lfs_segwrite(mp, 1);
 #ifdef QUOTA
@@ -415,9 +404,6 @@ lfs_vget(mp, ino, vpp)
        dev_t dev;
        int error;
 
        dev_t dev;
        int error;
 
-#ifdef VERBOSE
-       printf("lfs_vget\n");
-#endif
        ump = VFSTOUFS(mp);
        dev = ump->um_dev;
        if ((*vpp = ufs_ihashget(dev, ino)) != NULL)
        ump = VFSTOUFS(mp);
        dev = ump->um_dev;
        if ((*vpp = ufs_ihashget(dev, ino)) != NULL)
@@ -502,7 +488,8 @@ lfs_vget(mp, ino, vpp)
  * - check that the inode number is valid
  * - call lfs_vget() to get the locked inode
  * - check for an unallocated inode (i_mode == 0)
  * - check that the inode number is valid
  * - call lfs_vget() to get the locked inode
  * - check for an unallocated inode (i_mode == 0)
- * - check that the generation number matches
+ * - check that the given client host has export rights and return
+ *   those rights via. exflagsp and credanonp
  *
  * XXX
  * use ifile to see if inode is allocated instead of reading off disk
  *
  * XXX
  * use ifile to see if inode is allocated instead of reading off disk
@@ -518,73 +505,12 @@ lfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp)
        int *exflagsp;
        struct ucred **credanonp;
 {
        int *exflagsp;
        struct ucred **credanonp;
 {
-       register struct inode *ip;
        register struct ufid *ufhp;
        register struct ufid *ufhp;
-       register struct netaddrhash *np;
-       register struct ufsmount *ump = VFSTOUFS(mp);
-       struct vnode *nvp;
-       struct sockaddr *saddr;
-       int error;
 
        ufhp = (struct ufid *)fhp;
        if (ufhp->ufid_ino < ROOTINO)
                return (ESTALE);
 
        ufhp = (struct ufid *)fhp;
        if (ufhp->ufid_ino < ROOTINO)
                return (ESTALE);
-       /*
-        * Get the export permission structure for this <mp, client> tuple.
-        */
-       if ((mp->mnt_flag & MNT_EXPORTED) == 0)
-               return (EACCES);
-       if (nam == NULL) {
-               np = (struct netaddrhash *)0;
-       } else {
-               /*
-                * First search for a network match.
-                */
-               np = ump->um_netaddr[NETMASK_HASH];
-               while (np) {
-                       if (netaddr_match(np->neth_family, &np->neth_haddr,
-                           &np->neth_hmask, nam))
-                               break;
-                       np = np->neth_next;
-               }
-
-               /*
-                * If not found, try for an address match.
-                */
-               if (np == (struct netaddrhash *)0) {
-                       saddr = mtod(nam, struct sockaddr *);
-                       np = ump->um_netaddr[NETADDRHASH(saddr)];
-                       while (np) {
-                               if (netaddr_match(np->neth_family,
-                                   &np->neth_haddr, (struct netaddrhash *)0,
-                                   nam))
-                                       break;
-                               np = np->neth_next;
-                       }
-               }
-       }
-       if (np == (struct netaddrhash *)0) {
-               /*
-                * If no address match, use the default if it exists.
-                */
-               if ((mp->mnt_flag & MNT_DEFEXPORTED) == 0)
-                       return (EACCES);
-               np = &ump->um_defexported;
-       }
-       if (error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) {
-               *vpp = NULLVP;
-               return (error);
-       }
-       ip = VTOI(nvp);
-       if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen) {
-               ufs_iput(ip);
-               *vpp = NULLVP;
-               return (ESTALE);
-       }
-       *vpp = nvp;
-       *exflagsp = np->neth_exflags;
-       *credanonp = &np->neth_anon;
-       return (0);
+       return (ufs_check_export(mp, fhp, nam, vpp, exflagsp, credanonp));
 }
 
 /*
 }
 
 /*