diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-27 07:27:42 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-02-27 07:27:42 +0000 |
commit | e1d50524a19b291d7ddb25c7d05b8086df55b1c0 (patch) | |
tree | 6b1fba1880af780494d2e8df73cabcf9d30b36c6 /sys/ufs/ffs/ffs_vfsops.c | |
parent | 6fbea858373322940c41a040e3a5dce6edf08661 (diff) |
From NetBSD: update to 960217 sources
Diffstat (limited to 'sys/ufs/ffs/ffs_vfsops.c')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 87 |
1 files changed, 54 insertions, 33 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 3e19b2a0e7b..eecb3c01d98 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,5 @@ -/* $NetBSD: ffs_vfsops.c,v 1.18 1995/12/19 23:27:53 cgd Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.4 1996/02/27 07:27:39 niklas Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -87,6 +88,7 @@ extern u_long nextgennumber; */ #define ROOTNAME "root_device" +int ffs_mountroot() { extern struct vnode *rootvp; @@ -107,11 +109,11 @@ ffs_mountroot() bzero((char *)mp, (u_long)sizeof(struct mount)); mp->mnt_op = &ffs_vfsops; mp->mnt_flag = MNT_RDONLY; - if (error = ffs_mountfs(rootvp, mp, p)) { + if ((error = ffs_mountfs(rootvp, mp, p)) != 0) { free(mp, M_MOUNT); return (error); } - if (error = vfs_lock(mp)) { + if ((error = vfs_lock(mp)) != 0) { (void)ffs_unmount(mp, 0, p); free(mp, M_MOUNT); return (error); @@ -147,13 +149,14 @@ ffs_mount(mp, path, data, ndp, p) { struct vnode *devvp; struct ufs_args args; - struct ufsmount *ump; + struct ufsmount *ump = NULL; register struct fs *fs; size_t size; int error, flags; mode_t accessmode; - if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) + error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)); + if (error) return (error); /* * If updating, check whether changing from read-only to @@ -193,8 +196,9 @@ ffs_mount(mp, path, data, ndp, p) if (p->p_ucred->cr_uid != 0) { devvp = ump->um_devvp; VOP_LOCK(devvp); - if (error = VOP_ACCESS(devvp, VREAD | VWRITE, - p->p_ucred, p)) { + error = VOP_ACCESS(devvp, VREAD | VWRITE, + p->p_ucred, p); + if (error) { VOP_UNLOCK(devvp); return (error); } @@ -216,7 +220,7 @@ ffs_mount(mp, path, data, ndp, p) * and verify that it refers to a sensible block device. */ NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p); - if (error = namei(ndp)) + if ((error = namei(ndp)) != 0) return (error); devvp = ndp->ni_vp; @@ -237,7 +241,8 @@ ffs_mount(mp, path, data, ndp, p) if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; VOP_LOCK(devvp); - if (error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) { + error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); + if (error) { vput(devvp); return (error); } @@ -288,6 +293,7 @@ ffs_mount(mp, path, data, ndp, p) * 5) invalidate all cached file data. * 6) re-read inode data for all active vnodes. */ +int ffs_reload(mountp, cred, p) register struct mount *mountp; struct ucred *cred; @@ -317,7 +323,8 @@ ffs_reload(mountp, cred, p) size = DEV_BSIZE; else size = dpart.disklab->d_secsize; - if (error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp)) + error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, NOCRED, &bp); + if (error) return (error); newfs = (struct fs *)bp->b_data; if (newfs->fs_magic != FS_MAGIC || newfs->fs_bsize > MAXBSIZE || @@ -348,8 +355,9 @@ ffs_reload(mountp, cred, p) size = fs->fs_bsize; if (i + fs->fs_frag > blks) size = (blks - i) * fs->fs_fsize; - if (error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, - NOCRED, &bp)) + error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, + NOCRED, &bp); + if (error) return (error); bcopy(bp->b_data, fs->fs_csp[fragstoblks(fs, i)], (u_int)size); brelse(bp); @@ -384,9 +392,9 @@ loop: * Step 6: re-read inode data for all active vnodes. */ ip = VTOI(vp); - if (error = - bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), - (int)fs->fs_bsize, NOCRED, &bp)) { + error = bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), + (int)fs->fs_bsize, NOCRED, &bp); + if (error) { vput(vp); return (error); } @@ -430,15 +438,16 @@ ffs_mountfs(devvp, mp, p) * (except for root, which might share swap device for miniroot). * Flush out any old buffers remaining from a previous use. */ - if (error = vfs_mountedon(devvp)) + if ((error = vfs_mountedon(devvp)) != 0) return (error); if (vcount(devvp) > 1 && devvp != rootvp) return (EBUSY); - if (error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0)) + if ((error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0)) != 0) return (error); ronly = (mp->mnt_flag & MNT_RDONLY) != 0; - if (error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p)) + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); + if (error) return (error); if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0) size = DEV_BSIZE; @@ -447,7 +456,8 @@ ffs_mountfs(devvp, mp, p) bp = NULL; ump = NULL; - if (error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, cred, &bp)) + error = bread(devvp, (daddr_t)(SBOFF / size), SBSIZE, cred, &bp); + if (error) goto out; fs = (struct fs *)bp->b_data; if (fs->fs_magic != FS_MAGIC || fs->fs_bsize > MAXBSIZE || @@ -484,8 +494,9 @@ ffs_mountfs(devvp, mp, p) size = fs->fs_bsize; if (i + fs->fs_frag > blks) size = (blks - i) * fs->fs_fsize; - if (error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, - cred, &bp)) { + error = bread(devvp, fsbtodb(fs, fs->fs_csaddr + i), size, + cred, &bp); + if (error) { free(base, M_UFSMNT); goto out; } @@ -537,6 +548,7 @@ out: * * XXX - goes away some day. */ +int ffs_oldfscompat(fs) struct fs *fs; { @@ -576,7 +588,7 @@ ffs_unmount(mp, mntflags, p) flags = 0; if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - if (error = ffs_flushfiles(mp, flags, p)) + if ((error = ffs_flushfiles(mp, flags, p)) != 0) return (error); ump = VFSTOUFS(mp); fs = ump->um_fs; @@ -601,6 +613,7 @@ ffs_unmount(mp, mntflags, p) /* * Flush out all the files in a filesystem. */ +int ffs_flushfiles(mp, flags, p) register struct mount *mp; int flags; @@ -608,14 +621,15 @@ ffs_flushfiles(mp, flags, p) { extern int doforce; register struct ufsmount *ump; - int i, error; + int error; if (!doforce) flags &= ~FORCECLOSE; ump = VFSTOUFS(mp); #ifdef QUOTA if (mp->mnt_flag & MNT_QUOTA) { - if (error = vflush(mp, NULLVP, SKIPSYSTEM|flags)) + int i; + if ((error = vflush(mp, NULLVP, SKIPSYSTEM|flags)) != 0) return (error); for (i = 0; i < MAXQUOTAS; i++) { if (ump->um_quotas[i] == NULLVP) @@ -727,14 +741,14 @@ loop: continue; if (vget(vp, 1)) goto loop; - if (error = VOP_FSYNC(vp, cred, waitfor, p)) + if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0) allerror = error; vput(vp); } /* * Force stale file system control information to be flushed. */ - if (error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) + if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) != 0) allerror = error; #ifdef QUOTA qsync(mp); @@ -760,7 +774,7 @@ ffs_vget(mp, ino, vpp) struct buf *bp; struct vnode *vp; dev_t dev; - int i, type, error; + int type, error; ump = VFSTOUFS(mp); dev = ump->um_dev; @@ -768,7 +782,7 @@ ffs_vget(mp, ino, vpp) return (0); /* Allocate a new vnode/inode. */ - if (error = getnewvnode(VT_UFS, mp, ffs_vnodeop_p, &vp)) { + if ((error = getnewvnode(VT_UFS, mp, ffs_vnodeop_p, &vp)) != 0) { *vpp = NULL; return (error); } @@ -781,8 +795,12 @@ ffs_vget(mp, ino, vpp) ip->i_dev = dev; ip->i_number = ino; #ifdef QUOTA - for (i = 0; i < MAXQUOTAS; i++) - ip->i_dquot[i] = NODQUOT; + { + int i; + + for (i = 0; i < MAXQUOTAS; i++) + ip->i_dquot[i] = NODQUOT; + } #endif /* * Put it onto its hash chain and lock it so that other requests for @@ -793,8 +811,9 @@ ffs_vget(mp, ino, vpp) ufs_ihashins(ip); /* Read in the disk contents for the inode, copy into the inode. */ - if (error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)), - (int)fs->fs_bsize, NOCRED, &bp)) { + error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)), + (int)fs->fs_bsize, NOCRED, &bp); + if (error) { /* * The inode does not contain anything useful, so it would * be misleading to leave it on its hash chain. With mode @@ -813,7 +832,8 @@ ffs_vget(mp, ino, vpp) * Initialize the vnode from the inode, check for aliases. * Note that the underlying vnode may have changed. */ - if (error = ufs_vinit(mp, ffs_specop_p, FFS_FIFOOPS, &vp)) { + error = ufs_vinit(mp, ffs_specop_p, FFS_FIFOOPS, &vp); + if (error) { vput(vp); *vpp = NULL; return (error); @@ -881,6 +901,7 @@ ffs_fhtovp(mp, fhp, nam, vpp, exflagsp, credanonp) * Vnode pointer to File handle */ /* ARGSUSED */ +int ffs_vptofh(vp, fhp) struct vnode *vp; struct fid *fhp; |