X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/cff1d696c5f27b75871bbed7ca36af925680540a..ede9137980d8582754d6276d8d30f6c0fc02702f:/usr/src/sys/ufs/lfs/lfs_vfsops.c diff --git a/usr/src/sys/ufs/lfs/lfs_vfsops.c b/usr/src/sys/ufs/lfs/lfs_vfsops.c index 170f50aeba..34aac29662 100644 --- a/usr/src/sys/ufs/lfs/lfs_vfsops.c +++ b/usr/src/sys/ufs/lfs/lfs_vfsops.c @@ -1,10 +1,10 @@ /* - * Copyright (c) 1989, 1991 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. * * %sccs.include.redist.c% * - * @(#)lfs_vfsops.c 7.78 (Berkeley) %G% + * @(#)lfs_vfsops.c 8.6 (Berkeley) %G% */ #include @@ -81,8 +81,9 @@ lfs_mount(mp, path, data, ndp, p) return (error); /* Until LFS can do NFS right. XXX */ - if (args.exflags & MNT_EXPORTED) + if (args.export.ex_flags & MNT_EXPORTED) return (EINVAL); + /* * If updating, check whether changing from read-only to * read/write; if there is no device name, that's all we do. @@ -102,17 +103,7 @@ lfs_mount(mp, path, data, ndp, p) /* * Process export requests. */ - if (args.exflags & MNT_EXPORTED) { - if (error = ufs_hang_addrlist(mp, &args)) - return (error); - mp->mnt_flag |= MNT_EXPORTED; - } - if (args.exflags & MNT_DELEXPORT) { - ufs_free_addrlist(ump); - mp->mnt_flag &= - ~(MNT_EXPORTED | MNT_DEFEXPORTED); - } - return (0); + return (vfs_export(mp, &ump->um_export, &args.export)); } } /* @@ -186,7 +177,7 @@ lfs_mountfs(devvp, mp, p) dev_t dev; int error, i, ronly, size; - if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p)) + if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p)) return (error); if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0) @@ -211,14 +202,11 @@ lfs_mountfs(devvp, mp, p) error = EINVAL; /* XXX needs translation */ goto out; } -#ifdef DEBUG - lfs_dump_super(fs); -#endif /* Allocate the mount structure, copy the superblock into it. */ ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK); - ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK); - bcopy(bp->b_un.b_addr, ump->um_lfs, sizeof(struct lfs)); + fs = ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK); + bcopy(bp->b_data, fs, sizeof(struct lfs)); if (sizeof(struct lfs) < LFS_SBPAD) /* XXX why? */ bp->b_flags |= B_INVAL; brelse(bp); @@ -227,13 +215,13 @@ lfs_mountfs(devvp, mp, p) /* Set up the I/O information */ fs->lfs_iocount = 0; - /* Set up the ifile flags */ + /* Set up the ifile and lock aflags */ fs->lfs_doifile = 0; fs->lfs_writer = 0; fs->lfs_dirops = 0; + fs->lfs_seglock = 0; /* Set the file system readonly/modify bits. */ - fs = ump->um_lfs; fs->lfs_ronly = ronly; if (ronly == 0) fs->lfs_fmod = 1; @@ -247,6 +235,9 @@ lfs_mountfs(devvp, mp, p) ump->um_mountp = mp; ump->um_dev = dev; ump->um_devvp = devvp; + ump->um_bptrtodb = 0; + ump->um_seqinc = 1 << fs->lfs_fsbtodb; + ump->um_nindir = fs->lfs_nindir; for (i = 0; i < MAXQUOTAS; i++) ump->um_quotas[i] = NULLVP; devvp->v_specflags |= SI_MOUNTEDON; @@ -287,15 +278,12 @@ lfs_unmount(mp, mntflags, p) { extern int doforce; register struct ufsmount *ump; - register struct lfs *fs; /* LFS */ + 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) + if (!doforce || (mp->mnt_flag & MNT_ROOTFS)) return (EINVAL); flags |= FORCECLOSE; } @@ -318,13 +306,14 @@ lfs_unmount(mp, mntflags, p) */ } #endif - vrele(fs->lfs_ivnode); if (error = vflush(mp, fs->lfs_ivnode, flags)) return (error); + fs->lfs_clean = 1; if (error = VFS_SYNC(mp, 1, p->p_ucred, p)) return (error); - if (fs->lfs_ivnode->v_dirtyblkhd) + if (fs->lfs_ivnode->v_dirtyblkhd.lh_first) panic("lfs_unmount: still dirty blocks on ifile vnode\n"); + vrele(fs->lfs_ivnode); vgone(fs->lfs_ivnode); ronly = !fs->lfs_ronly; @@ -345,12 +334,13 @@ lfs_statfs(mp, sbp, p) 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_bfree = fs->lfs_bfree; + 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); + (fs->lfs_dsize - fs->lfs_bfree); + sbp->f_bavail = dbtofsb(fs, sbp->f_bavail); sbp->f_files = fs->lfs_nfiles; - sbp->f_ffree = fs->lfs_bfree * INOPB(fs); + sbp->f_ffree = sbp->f_bfree * INOPB(fs); if (sbp != &mp->mnt_stat) { bcopy((caddr_t)mp->mnt_stat.f_mntonname, (caddr_t)&sbp->f_mntonname[0], MNAMELEN); @@ -373,20 +363,10 @@ lfs_sync(mp, waitfor, cred, p) struct ucred *cred; struct proc *p; { - extern int crashandburn, syncprt; 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); + error = lfs_segwrite(mp, SEGM_CKP | (waitfor ? SEGM_SYNC : 0)); #ifdef QUOTA qsync(mp); #endif @@ -414,9 +394,6 @@ lfs_vget(mp, ino, vpp) 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) @@ -461,21 +438,17 @@ lfs_vget(mp, ino, vpp) if (error = bread(ump->um_devvp, daddr, (int)fs->lfs_bsize, NOCRED, &bp)) { /* - * The inode does not contain anything useful, so it - * would be misleading to leave it on its hash chain. - * Iput() will return it to the free list. + * The inode does not contain anything useful, so it would + * be misleading to leave it on its hash chain. With mode + * still zero, it will be unlinked and returned to the free + * list by vput(). */ - remque(ip); - ip->i_forw = ip; - ip->i_back = ip; - - /* Unlock and discard unneeded inode. */ - ufs_iput(ip); + vput(vp); brelse(bp); *vpp = NULL; return (error); } - ip->i_din = *lfs_ifind(fs, ino, bp->b_un.b_dino); + ip->i_din = *lfs_ifind(fs, ino, (struct dinode *)bp->b_data); brelse(bp); /* @@ -483,7 +456,7 @@ lfs_vget(mp, ino, vpp) * cases re-init ip, the underlying vnode/inode may have changed. */ if (error = ufs_vinit(mp, lfs_specop_p, LFS_FIFOOPS, &vp)) { - ufs_iput(ip); + vput(vp); *vpp = NULL; return (error); } @@ -503,7 +476,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 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 @@ -519,73 +493,12 @@ lfs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp) int *exflagsp; struct ucred **credanonp; { - register struct inode *ip; 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); - /* - * Get the export permission structure for this 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, ufhp, nam, vpp, exflagsp, credanonp)); } /*