diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-12-28 20:48:19 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-12-28 20:48:19 +0000 |
commit | 1b49ee3eb8c877858a1f6aed46946e85333e60d6 (patch) | |
tree | 6384a28ddd41cb6cdd7d6ac636ee373a55a31ff8 | |
parent | 3f0c4ca6296d5ec4706edf6976987328f125adb2 (diff) |
Use the DIP macros to uniformly access fields from UFS1 and UFS2 dinodes.
No functional change, okay tedu@.
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_lookup.c | 6 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_alloc.c | 52 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_balloc.c | 35 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 94 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_softdep.c | 58 | ||||
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 25 | ||||
-rw-r--r-- | sys/ufs/ffs/fs.h | 6 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_alloc.c | 16 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_balloc.c | 8 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_inode.c | 40 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_segment.c | 8 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_vfsops.c | 4 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_vnops.c | 32 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 88 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_bmap.c | 9 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_dirhash.c | 16 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 14 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_lookup.c | 44 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_quota.c | 18 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_readwrite.c | 32 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vfsops.c | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 219 | ||||
-rw-r--r-- | usr.bin/fstat/fstat.c | 10 | ||||
-rw-r--r-- | usr.sbin/pstat/pstat.c | 14 |
24 files changed, 449 insertions, 403 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_lookup.c b/sys/ufs/ext2fs/ext2fs_lookup.c index 561d560200a..d42f07fba4d 100644 --- a/sys/ufs/ext2fs/ext2fs_lookup.c +++ b/sys/ufs/ext2fs/ext2fs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_lookup.c,v 1.20 2005/12/16 15:37:24 pedro Exp $ */ +/* $OpenBSD: ext2fs_lookup.c,v 1.21 2005/12/28 20:48:17 pedro Exp $ */ /* $NetBSD: ext2fs_lookup.c,v 1.16 2000/08/03 20:29:26 thorpej Exp $ */ /* @@ -781,7 +781,7 @@ ext2fs_direnter(ip, dvp, cnp) newdir.e2d_namlen = cnp->cn_namelen; if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 && (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) { - newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_ffs_mode)); + newdir.e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode)); } else { newdir.e2d_type = 0; }; @@ -961,7 +961,7 @@ ext2fs_dirrewrite(dp, ip, cnp) ep->e2d_ino = h2fs32(ip->i_number); if (ip->i_e2fs->e2fs.e2fs_rev > E2FS_REV0 && (ip->i_e2fs->e2fs.e2fs_features_incompat & EXT2F_INCOMPAT_FTYPE)) { - ep->e2d_type = inot2ext2dt(IFTODT(ip->i_ffs_mode)); + ep->e2d_type = inot2ext2dt(IFTODT(ip->i_e2fs_mode)); } else { ep->e2d_type = 0; } diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index df0d2d1a1aa..4a05ecc521b 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_alloc.c,v 1.58 2005/11/06 13:22:39 pedro Exp $ */ +/* $OpenBSD: ffs_alloc.c,v 1.59 2005/12/28 20:48:17 pedro Exp $ */ /* $NetBSD: ffs_alloc.c,v 1.11 1996/05/11 18:27:09 mycroft Exp $ */ /* @@ -129,7 +129,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn, daddr_t bpref, int size, cg = dtog(fs, bpref); bno = (daddr_t)ffs_hashalloc(ip, cg, (long)bpref, size, ffs_alloccg); if (bno > 0) { - ip->i_ffs_blocks += btodb(size); + DIP_ADD(ip, blocks, btodb(size)); ip->i_flag |= IN_CHANGE | IN_UPDATE; *bnp = bno; return (0); @@ -180,11 +180,15 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, #endif /* DIAGNOSTIC */ if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0) goto nospace; - if ((bprev = ip->i_ffs_db[lbprev]) == 0) { + + bprev = DIP(ip, db[lbprev]); + + if (bprev == 0) { printf("dev = 0x%x, bsize = %d, bprev = %d, fs = %s\n", ip->i_dev, fs->fs_bsize, bprev, fs->fs_fsmnt); panic("ffs_realloccg: bad bprev"); } + /* * Allocate the extra space in the buffer. */ @@ -203,7 +207,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, */ cg = dtog(fs, bprev); if ((bno = ffs_fragextend(ip, cg, (long)bprev, osize, nsize)) != 0) { - ip->i_ffs_blocks += btodb(nsize - osize); + DIP_ADD(ip, blocks, btodb(nsize - osize)); ip->i_flag |= IN_CHANGE | IN_UPDATE; if (bpp != NULL) { if (bp->b_blkno != fsbtodb(fs, bno)) @@ -277,7 +281,7 @@ ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize, if (nsize < request) ffs_blkfree(ip, bno + numfrags(fs, nsize), (long)(request - nsize)); - ip->i_ffs_blocks += btodb(nsize - osize); + DIP_ADD(ip, blocks, btodb(nsize - osize)); ip->i_flag |= IN_CHANGE | IN_UPDATE; if (bpp != NULL) { bp->b_blkno = fsbtodb(fs, bno); @@ -394,7 +398,7 @@ ffs_reallocblks(void *v) * Get the starting offset and block map for the first block. */ if (start_lvl == 0) { - sbap = &ip->i_ffs_db[0]; + sbap = &ip->i_ffs1_db[0]; soff = start_lbn; } else { idp = &start_ap[start_lvl - 1]; @@ -461,7 +465,7 @@ ffs_reallocblks(void *v) printf(" %d,", *bap); #endif if (DOINGSOFTDEP(vp)) { - if (sbap == &ip->i_ffs_db[0] && i < ssize) + if (sbap == &ip->i_ffs1_db[0] && i < ssize) softdep_setup_allocdirect(ip, start_lbn + i, blkno, *bap, fs->fs_bsize, fs->fs_bsize, buflist->bs_children[i]); @@ -487,7 +491,7 @@ ffs_reallocblks(void *v) * We can then check below to see if it is set, and do the * synchronous write only when it has been cleared. */ - if (sbap != &ip->i_ffs_db[0]) { + if (sbap != &ip->i_ffs1_db[0]) { if (doasyncfree) bdwrite(sbp); else @@ -536,7 +540,7 @@ ffs_reallocblks(void *v) fail: if (ssize < len) brelse(ebp); - if (sbap != &ip->i_ffs_db[0]) + if (sbap != &ip->i_ffs1_db[0]) brelse(sbp); return (ENOSPC); } @@ -598,28 +602,36 @@ ffs_inode_alloc(struct inode *pip, mode_t mode, struct ucred *cred, ffs_inode_free(pip, ino, mode); return (error); } + ip = VTOI(*vpp); - if (ip->i_ffs_mode) { + + if (DIP(ip, mode)) { printf("mode = 0%o, inum = %d, fs = %s\n", - ip->i_ffs_mode, ip->i_number, fs->fs_fsmnt); + DIP(ip, mode), ip->i_number, fs->fs_fsmnt); panic("ffs_valloc: dup alloc"); } - if (ip->i_ffs_blocks) { /* XXX */ + + if (DIP(ip, blocks)) { printf("free inode %s/%d had %d blocks\n", - fs->fs_fsmnt, ino, ip->i_ffs_blocks); - ip->i_ffs_blocks = 0; + fs->fs_fsmnt, ino, DIP(ip, blocks)); + DIP_ASSIGN(ip, blocks, 0); } - ip->i_ffs_flags = 0; + + DIP_ASSIGN(ip, flags, 0); + /* * Set up a new generation number for this inode. * XXX - just increment for now, this is wrong! (millert) * Need a way to preserve randomization. */ - if (ip->i_ffs_gen == 0 || ++(ip->i_ffs_gen) == 0) - ip->i_ffs_gen = arc4random() & INT_MAX; - if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1) - ip->i_ffs_gen = 1; /* shouldn't happen */ + if (DIP(ip, gen) == 0 || ++(DIP(ip, gen)) == 0) + DIP_ASSIGN(ip, gen, arc4random() & INT_MAX); + + if (DIP(ip, gen) == 0 || DIP(ip, gen) == -1) + DIP_ASSIGN(ip, gen, 1); /* Shouldn't happen */ + return (0); + noinodes: ffs_fserr(fs, cred->cr_uid, "out of inodes"); uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt); @@ -1417,7 +1429,7 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) cg = dtog(fs, bno); if ((u_int)bno >= fs->fs_size) { printf("bad block %d, ino %u\n", bno, ip->i_number); - ffs_fserr(fs, ip->i_ffs_uid, "bad block"); + ffs_fserr(fs, DIP(ip, uid), "bad block"); return; } error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 7d3334a9c62..d0f58eb633a 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_balloc.c,v 1.24 2003/06/02 23:28:22 millert Exp $ */ +/* $OpenBSD: ffs_balloc.c,v 1.25 2005/12/28 20:48:17 pedro Exp $ */ /* $NetBSD: ffs_balloc.c,v 1.3 1996/02/09 22:22:21 christos Exp $ */ /* @@ -44,6 +44,7 @@ #include <ufs/ufs/quota.h> #include <ufs/ufs/inode.h> +#include <ufs/ufs/ufsmount.h> #include <ufs/ufs/ufs_extern.h> #include <ufs/ffs/fs.h> @@ -85,23 +86,23 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, * and the file is currently composed of a fragment * this fragment has to be extended to be a full block. */ - nb = lblkno(fs, ip->i_ffs_size); + nb = lblkno(fs, ip->i_ffs1_size); if (nb < NDADDR && nb < lbn) { osize = blksize(fs, ip, nb); if (osize < fs->fs_bsize && osize > 0) { error = ffs_realloccg(ip, nb, - ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs_db[0]), + ffs_blkpref(ip, nb, (int)nb, &ip->i_ffs1_db[0]), osize, (int)fs->fs_bsize, cred, bpp, &newb); if (error) return (error); if (DOINGSOFTDEP(vp)) softdep_setup_allocdirect(ip, nb, newb, - ip->i_ffs_db[nb], fs->fs_bsize, osize, + ip->i_ffs1_db[nb], fs->fs_bsize, osize, bpp ? *bpp : NULL); - ip->i_ffs_size = lblktosize(fs, nb + 1); - uvm_vnp_setsize(vp, ip->i_ffs_size); - ip->i_ffs_db[nb] = newb; + ip->i_ffs1_size = lblktosize(fs, nb + 1); + uvm_vnp_setsize(vp, ip->i_ffs1_size); + ip->i_ffs1_db[nb] = newb; ip->i_flag |= IN_CHANGE | IN_UPDATE; if (bpp != NULL) { if (flags & B_SYNC) @@ -115,8 +116,8 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, * The first NDADDR blocks are direct blocks */ if (lbn < NDADDR) { - nb = ip->i_ffs_db[lbn]; - if (nb != 0 && ip->i_ffs_size >= lblktosize(fs, lbn + 1)) { + nb = ip->i_ffs1_db[lbn]; + if (nb != 0 && ip->i_ffs1_size >= lblktosize(fs, lbn + 1)) { /* * The block is an already-allocated direct block * and the file already extends past this block, @@ -138,7 +139,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, /* * Consider need to reallocate a fragment. */ - osize = fragroundup(fs, blkoff(fs, ip->i_ffs_size)); + osize = fragroundup(fs, blkoff(fs, ip->i_ffs1_size)); nsize = fragroundup(fs, size); if (nsize <= osize) { /* @@ -162,7 +163,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, */ error = ffs_realloccg(ip, lbn, ffs_blkpref(ip, lbn, (int)lbn, - &ip->i_ffs_db[0]), + &ip->i_ffs1_db[0]), osize, nsize, cred, bpp, &newb); if (error) return (error); @@ -177,12 +178,12 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, * allocate a new block or fragment. */ - if (ip->i_ffs_size < lblktosize(fs, lbn + 1)) + if (ip->i_ffs1_size < lblktosize(fs, lbn + 1)) nsize = fragroundup(fs, size); else nsize = fs->fs_bsize; error = ffs_alloc(ip, lbn, - ffs_blkpref(ip, lbn, (int)lbn, &ip->i_ffs_db[0]), + ffs_blkpref(ip, lbn, (int)lbn, &ip->i_ffs1_db[0]), nsize, cred, &newb); if (error) return (error); @@ -196,7 +197,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, softdep_setup_allocdirect(ip, lbn, newb, 0, nsize, 0, bpp ? *bpp : NULL); } - ip->i_ffs_db[lbn] = newb; + ip->i_ffs1_db[lbn] = newb; ip->i_flag |= IN_CHANGE | IN_UPDATE; return (0); } @@ -215,7 +216,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, * Fetch the first indirect block allocating if necessary. */ --num; - nb = ip->i_ffs_ib[indirs[0].in_off]; + nb = ip->i_ffs1_ib[indirs[0].in_off]; allocib = NULL; allocblk = allociblk; @@ -244,7 +245,7 @@ ffs_balloc(struct inode *ip, off_t startoffset, int size, struct ucred *cred, if ((error = bwrite(bp)) != 0) goto fail; } - allocib = &ip->i_ffs_ib[indirs[0].in_off]; + allocib = &ip->i_ffs1_ib[indirs[0].in_off]; *allocib = nb; ip->i_flag |= IN_CHANGE | IN_UPDATE; } @@ -392,7 +393,7 @@ fail: */ (void)ufs_quota_free_blocks(ip, btodb(deallocated), cred); - ip->i_ffs_blocks -= btodb(deallocated); + ip->i_ffs1_blocks -= btodb(deallocated); ip->i_flag |= IN_CHANGE | IN_UPDATE; } diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index b0adb471c54..abe597fb0bc 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.41 2005/12/17 13:56:01 pedro Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.42 2005/12/28 20:48:17 pedro Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -95,19 +95,19 @@ ffs_update(struct inode *ip, struct timespec *atime, getnanotime(&ts); if (ip->i_flag & IN_ACCESS) { - ip->i_ffs_atime = atime ? atime->tv_sec : ts.tv_sec; - ip->i_ffs_atimensec = atime ? atime->tv_nsec : ts.tv_nsec; + DIP_ASSIGN(ip, atime, atime ? atime->tv_sec : ts.tv_sec); + DIP_ASSIGN(ip, atimensec, atime ? atime->tv_nsec : ts.tv_nsec); } if (ip->i_flag & IN_UPDATE) { - ip->i_ffs_mtime = mtime ? mtime->tv_sec : ts.tv_sec; - ip->i_ffs_mtimensec = mtime ? mtime->tv_nsec : ts.tv_nsec; + DIP_ASSIGN(ip, mtime, mtime ? mtime->tv_sec : ts.tv_sec); + DIP_ASSIGN(ip, mtimensec, mtime ? mtime->tv_nsec : ts.tv_nsec); ip->i_modrev++; } if (ip->i_flag & IN_CHANGE) { - ip->i_ffs_ctime = ts.tv_sec; - ip->i_ffs_ctimensec = ts.tv_nsec; + DIP_ASSIGN(ip, ctime, ts.tv_sec); + DIP_ASSIGN(ip, ctimensec, ts.tv_nsec); } ip->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE); @@ -117,9 +117,9 @@ ffs_update(struct inode *ip, struct timespec *atime, * Ensure that uid and gid are correct. This is a temporary * fix until fsck has been changed to do the update. */ - if (fs->fs_inodefmt < FS_44INODEFMT) { - ip->i_din1->di_ouid = ip->i_ffs_uid; - ip->i_din1->di_ogid = ip->i_ffs_gid; + if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_inodefmt < FS_44INODEFMT) { + ip->i_din1->di_ouid = ip->i_ffs1_uid; + ip->i_din1->di_ogid = ip->i_ffs1_gid; } error = bread(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)), @@ -131,7 +131,7 @@ ffs_update(struct inode *ip, struct timespec *atime, if (DOINGSOFTDEP(vp)) softdep_update_inodeblock(ip, bp, waitfor); - else if (ip->i_effnlink != ip->i_ffs_nlink) + else if (ip->i_effnlink != DIP(ip, nlink)) panic("ffs_update: bad link cnt"); *((struct ufs1_dinode *)bp->b_data + @@ -175,18 +175,19 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) ovp->v_type != VLNK) return (0); - if (oip->i_ffs_size == length) + if (DIP(oip, size) == length) return (0); + if (ovp->v_type == VLNK && - (oip->i_ffs_size < ovp->v_mount->mnt_maxsymlinklen || + (DIP(oip, size) < ovp->v_mount->mnt_maxsymlinklen || (ovp->v_mount->mnt_maxsymlinklen == 0 && oip->i_din1->di_blocks == 0))) { #ifdef DIAGNOSTIC if (length != 0) panic("ffs_truncate: partial truncate of symlink"); #endif - bzero((char *)&oip->i_ffs_shortlink, (u_int)oip->i_ffs_size); - oip->i_ffs_size = 0; + memset(SHORTLINK(oip), 0, (size_t) DIP(oip, size)); + DIP_ASSIGN(oip, size, 0); oip->i_flag |= IN_CHANGE | IN_UPDATE; return (UFS_UPDATE(oip, MNT_WAIT)); } @@ -213,7 +214,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) curproc)) != 0) return (error); } else { - (void)ufs_quota_free_blocks(oip, oip->i_ffs_blocks, + (void)ufs_quota_free_blocks(oip, DIP(oip, blocks), NOCRED); softdep_setup_freeblocks(oip, length); (void) vinvalbuf(ovp, 0, cred, curproc, 0, 0); @@ -223,7 +224,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) } fs = oip->i_fs; - osize = oip->i_ffs_size; + osize = DIP(oip, size); /* * Lengthen the size of the file. We must ensure that the * last byte of the file is allocated. Since the smallest @@ -239,7 +240,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) cred, aflags, &bp); if (error) return (error); - oip->i_ffs_size = length; + DIP_ASSIGN(oip, size, length); uvm_vnp_setsize(ovp, length); (void) uvm_vnp_uncache(ovp); if (aflags & B_SYNC) @@ -261,7 +262,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) */ offset = blkoff(fs, length); if (offset == 0) { - oip->i_ffs_size = length; + DIP_ASSIGN(oip, size, length); } else { lbn = lblkno(fs, length); aflags = B_CLRBUF; @@ -283,7 +284,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) fragroundup(fs, blkoff(fs, length)) < fs->fs_bsize && (error = VOP_FSYNC(ovp, cred, MNT_WAIT, curproc)) != 0) return (error); - oip->i_ffs_size = length; + DIP_ASSIGN(oip, size, length); size = blksize(fs, oip, lbn); (void) uvm_vnp_uncache(ovp); if (ovp->v_type != VDIR) @@ -306,32 +307,48 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs); lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs); nblocks = btodb(fs->fs_bsize); + /* * Update file and block pointers on disk before we start freeing * blocks. If we crash before free'ing blocks below, the blocks * will be returned to the free list. lastiblock values are also * normalized to -1 for calls to ffs_indirtrunc below. */ - bcopy((caddr_t)&oip->i_ffs_db[0], (caddr_t)oldblks, sizeof oldblks); + + if (fs->fs_magic == FS_UFS2_MAGIC) + bcopy(&oip->i_ffs2_db[0], oldblks, sizeof(oldblks)); + else + bcopy(&oip->i_ffs1_db[0], oldblks, sizeof(oldblks)); + for (level = TRIPLE; level >= SINGLE; level--) if (lastiblock[level] < 0) { - oip->i_ffs_ib[level] = 0; + DIP_ASSIGN(oip, ib[level], 0); lastiblock[level] = -1; } + for (i = NDADDR - 1; i > lastblock; i--) - oip->i_ffs_db[i] = 0; + DIP_ASSIGN(oip, db[i], 0); + oip->i_flag |= IN_CHANGE | IN_UPDATE; if ((error = UFS_UPDATE(oip, MNT_WAIT)) != 0) allerror = error; + /* * Having written the new inode to disk, save its new configuration * and put back the old block pointers long enough to process them. * Note that we save the new block configuration so we can check it * when we are done. */ - bcopy((caddr_t)&oip->i_ffs_db[0], (caddr_t)newblks, sizeof newblks); - bcopy((caddr_t)oldblks, (caddr_t)&oip->i_ffs_db[0], sizeof oldblks); - oip->i_ffs_size = osize; + + if (fs->fs_magic == FS_UFS2_MAGIC) { + bcopy(&oip->i_ffs2_db[0], newblks, sizeof(newblks)); + bcopy(oldblks, &oip->i_ffs2_db[0], sizeof(oldblks)); + } else { + bcopy(&oip->i_ffs1_db[0], newblks, sizeof(newblks)); + bcopy(oldblks, &oip->i_ffs1_db[0], sizeof(oldblks)); + } + + DIP_ASSIGN(oip, size, osize); vflags = ((length > 0) ? V_SAVE : 0) | V_SAVEMETA; allerror = vinvalbuf(ovp, vflags, cred, curproc, 0, 0); @@ -342,7 +359,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1; indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1; for (level = TRIPLE; level >= SINGLE; level--) { - bn = oip->i_ffs_ib[level]; + bn = DIP(oip, ib[level]); if (bn != 0) { error = ffs_indirtrunc(oip, indir_lbn[level], fsbtodb(fs, bn), lastiblock[level], level, &count); @@ -350,7 +367,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) allerror = error; blocksreleased += count; if (lastiblock[level] < 0) { - oip->i_ffs_ib[level] = 0; + DIP_ASSIGN(oip, ib[level], 0); ffs_blkfree(oip, bn, fs->fs_bsize); blocksreleased += nblocks; } @@ -365,10 +382,11 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) for (i = NDADDR - 1; i > lastblock; i--) { long bsize; - bn = oip->i_ffs_db[i]; + bn = DIP(oip, db[i]); if (bn == 0) continue; - oip->i_ffs_db[i] = 0; + + DIP_ASSIGN(oip, db[i], 0); bsize = blksize(fs, oip, i); ffs_blkfree(oip, bn, bsize); blocksreleased += btodb(bsize); @@ -380,7 +398,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) * Finally, look for a change in size of the * last direct block; release any frags. */ - bn = oip->i_ffs_db[lastblock]; + bn = DIP(oip, db[lastblock]); if (bn != 0) { long oldspace, newspace; @@ -389,7 +407,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) * back as old block size minus new block size. */ oldspace = blksize(fs, oip, lastblock); - oip->i_ffs_size = length; + DIP_ASSIGN(oip, size, length); newspace = blksize(fs, oip, lastblock); if (newspace == 0) panic("ffs_truncate: newspace"); @@ -407,19 +425,19 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) done: #ifdef DIAGNOSTIC for (level = SINGLE; level <= TRIPLE; level++) - if (newblks[NDADDR + level] != oip->i_ffs_ib[level]) + if (newblks[NDADDR + level] != DIP(oip, ib[level])) panic("ffs_truncate1"); for (i = 0; i < NDADDR; i++) - if (newblks[i] != oip->i_ffs_db[i]) + if (newblks[i] != DIP(oip, db[i])) panic("ffs_truncate2"); #endif /* DIAGNOSTIC */ /* * Put back the real size. */ - oip->i_ffs_size = length; - oip->i_ffs_blocks -= blocksreleased; - if (oip->i_ffs_blocks < 0) /* sanity */ - oip->i_ffs_blocks = 0; + DIP_ASSIGN(oip, size, length); + DIP_ADD(oip, blocks, -blocksreleased); + if (DIP(oip, blocks) < 0) /* Sanity */ + DIP_ASSIGN(oip, blocks, 0); oip->i_flag |= IN_CHANGE; (void)ufs_quota_free_blocks(oip, blocksreleased, NOCRED); return (allerror); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 747ed4fe0b8..092cb161f63 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_softdep.c,v 1.66 2005/12/17 13:56:01 pedro Exp $ */ +/* $OpenBSD: ffs_softdep.c,v 1.67 2005/12/28 20:48:17 pedro Exp $ */ /* * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. * @@ -1505,7 +1505,7 @@ softdep_setup_allocdirect(ip, lbn, newblkno, oldblkno, newsize, oldsize, bp) * allocate an associated pagedep to track additions and * deletions. */ - if ((ip->i_ffs_mode & IFMT) == IFDIR && + if ((DIP(ip, mode) & IFMT) == IFDIR && pagedep_lookup(ip, lbn, DEPALLOC, &pagedep) == 0) WORKLIST_INSERT(&bp->b_dep, &pagedep->pd_list); } @@ -1630,7 +1630,7 @@ newfreefrag(ip, blkno, size) panic("newfreefrag: frag size"); freefrag = pool_get(&freefrag_pool, PR_WAITOK); freefrag->ff_list.wk_type = D_FREEFRAG; - freefrag->ff_state = ip->i_ffs_uid & ~ONWORKLIST; /* used below */ + freefrag->ff_state = DIP(ip, uid) & ~ONWORKLIST; /* used below */ freefrag->ff_inum = ip->i_number; freefrag->ff_mnt = ITOV(ip)->v_mount; freefrag->ff_devvp = ip->i_devvp; @@ -1656,7 +1656,7 @@ handle_workitem_freefrag(freefrag) tip.i_ump = VFSTOUFS(freefrag->ff_mnt); tip.i_dev = freefrag->ff_devvp->v_rdev; tip.i_number = freefrag->ff_inum; - tip.i_ffs_uid = freefrag->ff_state & ~ONWORKLIST; /* set above */ + tip.i_ffs1_uid = freefrag->ff_state & ~ONWORKLIST; /* set above */ ffs_blkfree(&tip, freefrag->ff_blkno, freefrag->ff_fragsize); pool_put(&freefrag_pool, freefrag); } @@ -1733,7 +1733,7 @@ softdep_setup_allocindir_page(ip, lbn, bp, ptrno, newblkno, oldblkno, nbp) * allocate an associated pagedep to track additions and * deletions. */ - if ((ip->i_ffs_mode & IFMT) == IFDIR && + if ((DIP(ip, mode) & IFMT) == IFDIR && pagedep_lookup(ip, lbn, DEPALLOC, &pagedep) == 0) WORKLIST_INSERT(&nbp->b_dep, &pagedep->pd_list); if (nbp == NULL) { @@ -1924,23 +1924,27 @@ softdep_setup_freeblocks(ip, length) bzero(freeblks, sizeof(struct freeblks)); freeblks->fb_list.wk_type = D_FREEBLKS; freeblks->fb_state = ATTACHED; - freeblks->fb_uid = ip->i_ffs_uid; + freeblks->fb_uid = DIP(ip, uid); freeblks->fb_previousinum = ip->i_number; freeblks->fb_devvp = ip->i_devvp; freeblks->fb_mnt = ITOV(ip)->v_mount; - freeblks->fb_oldsize = ip->i_ffs_size; + freeblks->fb_oldsize = DIP(ip, size); freeblks->fb_newsize = length; - freeblks->fb_chkcnt = ip->i_ffs_blocks; + freeblks->fb_chkcnt = DIP(ip, blocks); + for (i = 0; i < NDADDR; i++) { - freeblks->fb_dblks[i] = ip->i_ffs_db[i]; - ip->i_ffs_db[i] = 0; + freeblks->fb_dblks[i] = DIP(ip, db[i]); + DIP_ASSIGN(ip, db[i], 0); } + for (i = 0; i < NIADDR; i++) { - freeblks->fb_iblks[i] = ip->i_ffs_ib[i]; - ip->i_ffs_ib[i] = 0; + freeblks->fb_iblks[i] = DIP(ip, ib[i]); + DIP_ASSIGN(ip, ib[i], 0); } - ip->i_ffs_blocks = 0; - ip->i_ffs_size = 0; + + DIP_ASSIGN(ip, blocks, 0); + DIP_ASSIGN(ip, size, 0); + /* * Push the zero'ed inode to to its disk buffer so that we are free * to delete its dependencies below. Once the dependencies are gone @@ -2382,8 +2386,8 @@ handle_workitem_freeblocks(freeblks) tip.i_number = freeblks->fb_previousinum; tip.i_ump = VFSTOUFS(freeblks->fb_mnt); tip.i_dev = freeblks->fb_devvp->v_rdev; - tip.i_ffs_size = freeblks->fb_oldsize; - tip.i_ffs_uid = freeblks->fb_uid; + tip.i_ffs1_size = freeblks->fb_oldsize; + tip.i_ffs1_uid = freeblks->fb_uid; tip.i_vnode = NULL; tmpval = 1; baselbns[0] = NDADDR; @@ -3082,12 +3086,12 @@ softdep_change_linkcnt(ip, nodelay) ACQUIRE_LOCK(&lk); (void) inodedep_lookup(ip->i_fs, ip->i_number, flags, &inodedep); - if (ip->i_ffs_nlink < ip->i_effnlink) { + if (DIP(ip, nlink) < ip->i_effnlink) { FREE_LOCK(&lk); panic("softdep_change_linkcnt: bad delta"); } - inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink; + inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink; FREE_LOCK(&lk); } @@ -3122,13 +3126,13 @@ handle_workitem_remove(dirrem) * Normal file deletion. */ if ((dirrem->dm_state & RMDIR) == 0) { - ip->i_ffs_nlink--; + DIP_ADD(ip, nlink, -1); ip->i_flag |= IN_CHANGE; - if (ip->i_ffs_nlink < ip->i_effnlink) { + if (DIP(ip, nlink) < ip->i_effnlink) { FREE_LOCK(&lk); panic("handle_workitem_remove: bad file delta"); } - inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink; + inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink; FREE_LOCK(&lk); vput(vp); num_dirrem -= 1; @@ -3142,11 +3146,11 @@ handle_workitem_remove(dirrem) * truncation completes, arrange to have the reference count on * the parent decremented to account for the loss of "..". */ - ip->i_ffs_nlink -= 2; + DIP_ADD(ip, nlink, -2); ip->i_flag |= IN_CHANGE; - if (ip->i_ffs_nlink < ip->i_effnlink) + if (DIP(ip, nlink) < ip->i_effnlink) panic("handle_workitem_remove: bad dir delta"); - inodedep->id_nlinkdelta = ip->i_ffs_nlink - ip->i_effnlink; + inodedep->id_nlinkdelta = DIP(ip, nlink) - ip->i_effnlink; FREE_LOCK(&lk); if ((error = UFS_TRUNCATE(ip, (off_t)0, 0, p->p_ucred)) != 0) softdep_error("handle_workitem_remove: truncate", error); @@ -4093,7 +4097,7 @@ softdep_load_inodeblock(ip) /* * Check for alternate nlink count. */ - ip->i_effnlink = ip->i_ffs_nlink; + ip->i_effnlink = DIP(ip, nlink); ACQUIRE_LOCK(&lk); if (inodedep_lookup(ip->i_fs, ip->i_number, 0, &inodedep) == 0) { FREE_LOCK(&lk); @@ -4133,11 +4137,11 @@ softdep_update_inodeblock(ip, bp, waitfor) ACQUIRE_LOCK(&lk); if (inodedep_lookup(ip->i_fs, ip->i_number, 0, &inodedep) == 0) { FREE_LOCK(&lk); - if (ip->i_effnlink != ip->i_ffs_nlink) + if (ip->i_effnlink != DIP(ip, nlink)) panic("softdep_update_inodeblock: bad link count"); return; } - if (inodedep->id_nlinkdelta != ip->i_ffs_nlink - ip->i_effnlink) { + if (inodedep->id_nlinkdelta != DIP(ip, nlink) - ip->i_effnlink) { FREE_LOCK(&lk); panic("softdep_update_inodeblock: bad delta"); } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index bf105f0f649..fdf473f27e8 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_vfsops.c,v 1.77 2005/12/17 13:56:01 pedro Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.78 2005/12/28 20:48:17 pedro Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -491,7 +491,7 @@ ffs_reload_vnode(struct vnode *vp, void *args) } *ip->i_din1 = *((struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fra->fs, ip->i_number)); - ip->i_effnlink = ip->i_ffs_nlink; + ip->i_effnlink = DIP(ip, nlink); brelse(bp); vput(vp); return (0); @@ -1169,7 +1169,7 @@ retry: if (DOINGSOFTDEP(vp)) softdep_load_inodeblock(ip); else - ip->i_effnlink = ip->i_ffs_nlink; + ip->i_effnlink = DIP(ip, nlink); /* * Initialize the vnode from the inode, check for aliases. @@ -1181,27 +1181,30 @@ retry: *vpp = NULL; return (error); } + /* * Set up a generation number for this inode if it does not * already have one. This should only happen on old filesystems. */ - if (ip->i_ffs_gen == 0) { - ip->i_ffs_gen = arc4random() & INT_MAX; - if (ip->i_ffs_gen == 0 || ip->i_ffs_gen == -1) - ip->i_ffs_gen = 1; /* shouldn't happen */ + if (DIP(ip, gen) == 0) { + DIP_ASSIGN(ip, gen, arc4random() & INT_MAX); + if (DIP(ip, gen) == 0 || DIP(ip, gen) == -1) + DIP_ASSIGN(ip, gen, 1); /* Shouldn't happen */ if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) ip->i_flag |= IN_MODIFIED; } + /* * Ensure that uid and gid are correct. This is a temporary * fix until fsck has been changed to do the update. */ - if (fs->fs_inodefmt < FS_44INODEFMT) { - ip->i_ffs_uid = ip->i_din1->di_ouid; - ip->i_ffs_gid = ip->i_din1->di_ogid; + if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_inodefmt < FS_44INODEFMT) { + ip->i_ffs1_uid = ip->i_din1->di_ouid; + ip->i_ffs1_gid = ip->i_din1->di_ogid; } *vpp = vp; + return (0); } @@ -1241,7 +1244,7 @@ ffs_vptofh(struct vnode *vp, struct fid *fhp) ufhp = (struct ufid *)fhp; ufhp->ufid_len = sizeof(struct ufid); ufhp->ufid_ino = ip->i_number; - ufhp->ufid_gen = ip->i_ffs_gen; + ufhp->ufid_gen = DIP(ip, gen); return (0); } diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index d62ab2dbf67..8899cefc07e 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fs.h,v 1.17 2005/03/01 13:30:50 aaron Exp $ */ +/* $OpenBSD: fs.h,v 1.18 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: fs.h,v 1.6 1995/04/12 21:21:02 mycroft Exp $ */ /* @@ -507,9 +507,9 @@ struct ocg { * Determining the size of a file block in the file system. */ #define blksize(fs, ip, lbn) \ - (((lbn) >= NDADDR || (ip)->i_ffs_size >= ((lbn) + 1) << (fs)->fs_bshift) \ + (((lbn) >= NDADDR || DIP((ip), size) >= ((lbn) + 1) << (fs)->fs_bshift) \ ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (ip)->i_ffs_size)))) + : (fragroundup(fs, blkoff(fs, DIP((ip), size))))) #define dblksize(fs, dip, lbn) \ (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \ ? (fs)->fs_bsize \ diff --git a/sys/ufs/lfs/lfs_alloc.c b/sys/ufs/lfs/lfs_alloc.c index da823b14c1d..c516b32c873 100644 --- a/sys/ufs/lfs/lfs_alloc.c +++ b/sys/ufs/lfs/lfs_alloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_alloc.c,v 1.11 2004/06/21 23:50:38 tholo Exp $ */ +/* $OpenBSD: lfs_alloc.c,v 1.12 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_alloc.c,v 1.4 1996/03/25 12:53:37 pk Exp $ */ /* @@ -97,10 +97,10 @@ lfs_valloc(v) if (fs->lfs_free == LFS_UNUSED_INUM) { vp = fs->lfs_ivnode; ip = VTOI(vp); - blkno = lblkno(fs, ip->i_ffs_size); + blkno = lblkno(fs, DIP(ip, size)); lfs_balloc(vp, 0, fs->lfs_bsize, blkno, &bp); - ip->i_ffs_size += fs->lfs_bsize; - vnode_pager_setsize(vp, (u_long)ip->i_ffs_size); + DIP_ADD(ip, size, fs->lfs_bsize); + vnode_pager_setsize(vp, (u_long) DIP(ip, size)); vnode_pager_uncache(vp); i = (blkno - fs->lfs_segtabsz - fs->lfs_cleansz) * @@ -131,7 +131,7 @@ lfs_valloc(v) /* Set a new generation number for this inode. */ if (++nextgennumber < (u_long)time_second) nextgennumber = time_second; - ip->i_ffs_gen = nextgennumber; + DIP_ASSIGN(ip, gen, nextgennumber); /* Insert into the inode hash table. */ ufs_ihashins(ip); @@ -192,9 +192,9 @@ lfs_vcreate(mp, ino, vpp) #endif ip->i_lockf = 0; ip->i_diroff = 0; - ip->i_ffs_mode = 0; - ip->i_ffs_size = 0; - ip->i_ffs_blocks = 0; + ip->i_ffs1_mode = 0; + ip->i_ffs1_size = 0; + ip->i_ffs1_blocks = 0; ++ump->um_lfs->lfs_uinodes; return (0); } diff --git a/sys/ufs/lfs/lfs_balloc.c b/sys/ufs/lfs/lfs_balloc.c index 09aae05c437..24cacd6ad66 100644 --- a/sys/ufs/lfs/lfs_balloc.c +++ b/sys/ufs/lfs/lfs_balloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_balloc.c,v 1.9 2003/06/02 23:28:23 millert Exp $ */ +/* $OpenBSD: lfs_balloc.c,v 1.10 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_balloc.c,v 1.3 1996/02/09 22:28:48 christos Exp $ */ /* @@ -124,7 +124,7 @@ lfs_balloc(vp, offset, iosize, lbn, bpp) brelse(ibp); return(ENOSPC); } else { - ip->i_ffs_blocks += bb; + ip->i_ffs1_blocks += bb; ip->i_lfs->lfs_bfree -= bb; clrbuf(ibp); if((error = VOP_BWRITE(ibp)) != 0) @@ -177,7 +177,7 @@ lfs_balloc(vp, offset, iosize, lbn, bpp) brelse(bp); return(ENOSPC); } else { - ip->i_ffs_blocks += bb; + ip->i_ffs1_blocks += bb; ip->i_lfs->lfs_bfree -= bb; if (iosize != fs->lfs_bsize) clrbuf(bp); @@ -231,7 +231,7 @@ lfs_fragextend(vp, osize, nsize, lbn, bpp) return (error); } #endif - ip->i_ffs_blocks += bb; + ip->i_ffs1_blocks += bb; ip->i_flag |= IN_CHANGE | IN_UPDATE; fs->lfs_bfree -= fragstodb(fs, numfrags(fs, (nsize - osize))); allocbuf(*bpp, nsize); diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index 4e2c15c5dde..38575121ce2 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_inode.c,v 1.10 2004/06/24 19:35:27 tholo Exp $ */ +/* $OpenBSD: lfs_inode.c,v 1.11 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_inode.c,v 1.5 1996/05/11 18:27:35 mycroft Exp $ */ /* @@ -181,8 +181,8 @@ lfs_truncate(v) if (length != 0) panic("lfs_truncate: partial truncate of symlink"); #endif - bzero((char *)&ip->i_ffs_shortlink, (u_int)ip->i_ffs_size); - ip->i_ffs_size = 0; + bzero((char *)&ip->i_ffs1_shortlink, (u_int)ip->i_ffs1_size); + ip->i_ffs1_size = 0; ip->i_flag |= IN_CHANGE | IN_UPDATE; return (VOP_UPDATE(vp, &ts, &ts, 0)); } @@ -191,7 +191,7 @@ lfs_truncate(v) fs = ip->i_lfs; /* If length is larger than the file, just update the times. */ - if (ip->i_ffs_size <= length) { + if (ip->i_ffs1_size <= length) { ip->i_flag |= IN_CHANGE | IN_UPDATE; return (VOP_UPDATE(vp, &ts, &ts, 0)); } @@ -202,7 +202,7 @@ lfs_truncate(v) * file is truncated to 0. */ lastblock = lblkno(fs, length + fs->lfs_bsize - 1); - olastblock = lblkno(fs, ip->i_ffs_size + fs->lfs_bsize - 1) - 1; + olastblock = lblkno(fs, ip->i_ffs1_size + fs->lfs_bsize - 1) - 1; /* * Update the size of the file. If the file is not being truncated to @@ -218,7 +218,7 @@ lfs_truncate(v) /* Now set oldsize to the current size of the current last block */ oldsize_lastblock = blksize(fs, ip, olastblock); if (offset == 0) - ip->i_ffs_size = length; + ip->i_ffs1_size = length; else { #ifdef QUOTA if ((e1 = getinoquota(ip)) != 0) @@ -226,7 +226,7 @@ lfs_truncate(v) #endif if ((e1 = bread(vp, lbn, fs->lfs_bsize, NOCRED, &bp)) != 0) return (e1); - ip->i_ffs_size = length; + ip->i_ffs1_size = length; (void)vnode_pager_uncache(vp); newsize = blksize(fs, ip, lbn); bzero((char *)bp->b_data + offset, (u_int)(newsize - offset)); @@ -236,7 +236,7 @@ lfs_truncate(v) } /* * Modify sup->su_nbyte counters for each deleted block; keep track - * of number of blocks removed for ip->i_ffs_blocks. + * of number of blocks removed for ip->i_ffs1_blocks. */ fragsreleased = 0; num = 0; @@ -254,9 +254,9 @@ lfs_truncate(v) switch (depth) { case 0: /* Direct block. */ - daddr = ip->i_ffs_db[lbn]; + daddr = ip->i_ffs1_db[lbn]; SEGDEC(freesize); - ip->i_ffs_db[lbn] = 0; + ip->i_ffs1_db[lbn] = 0; --lbn; break; #ifdef DIAGNOSTIC @@ -297,9 +297,9 @@ lfs_truncate(v) } if (depth == 0 && a[1].in_off == 0) { off = a[0].in_off; - daddr = ip->i_ffs_ib[off]; + daddr = ip->i_ffs1_ib[off]; SEGDEC(freesize); - ip->i_ffs_ib[off] = 0; + ip->i_ffs1_ib[off] = 0; } if (lbn == lastblock || lbn <= NDADDR) --lbn; @@ -320,13 +320,13 @@ lfs_truncate(v) } #ifdef DIAGNOSTIC - if (ip->i_ffs_blocks < fragstodb(fs, fragsreleased)) { + if (ip->i_ffs1_blocks < fragstodb(fs, fragsreleased)) { printf("lfs_truncate: frag count < 0\n"); - fragsreleased = dbtofrags(fs, ip->i_ffs_blocks); + fragsreleased = dbtofrags(fs, ip->i_ffs1_blocks); panic("lfs_truncate: frag count < 0"); } #endif - ip->i_ffs_blocks -= fragstodb(fs, fragsreleased); + ip->i_ffs1_blocks -= fragstodb(fs, fragsreleased); fs->lfs_bfree += fragstodb(fs, fragsreleased); ip->i_flag |= IN_CHANGE | IN_UPDATE; /* @@ -355,19 +355,19 @@ lfs_truncate(v) } fragsreleased = i_released; #ifdef DIAGNOSTIC - if (fragsreleased > dbtofrags(fs, ip->i_ffs_blocks)) { + if (fragsreleased > dbtofrags(fs, ip->i_ffs1_blocks)) { printf("lfs_inode: Warning! %s\n", "more frags released from inode than are in inode"); - fragsreleased = dbtofrags(fs, ip->i_ffs_blocks); + fragsreleased = dbtofrags(fs, ip->i_ffs1_blocks); panic("lfs_inode: Warning. More frags released"); } #endif fs->lfs_bfree += fragstodb(fs, fragsreleased); - ip->i_ffs_blocks -= fragstodb(fs, fragsreleased); + ip->i_ffs1_blocks -= fragstodb(fs, fragsreleased); #ifdef DIAGNOSTIC - if (length == 0 && ip->i_ffs_blocks != 0) { + if (length == 0 && ip->i_ffs1_blocks != 0) { printf("lfs_inode: Warning! %s%d%s\n", - "Truncation to zero, but ", ip->i_ffs_blocks, + "Truncation to zero, but ", ip->i_ffs1_blocks, " blocks left on inode"); panic("lfs_inode"); } diff --git a/sys/ufs/lfs/lfs_segment.c b/sys/ufs/lfs/lfs_segment.c index 18e38f828d7..05c7ed623b8 100644 --- a/sys/ufs/lfs/lfs_segment.c +++ b/sys/ufs/lfs/lfs_segment.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_segment.c,v 1.13 2005/02/17 18:07:37 jfb Exp $ */ +/* $OpenBSD: lfs_segment.c,v 1.14 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_segment.c,v 1.4 1996/02/09 22:28:54 christos Exp $ */ /* @@ -622,10 +622,10 @@ lfs_updatemeta(sp) ip = VTOI(vp); switch (num) { case 0: - ip->i_ffs_db[lbn] = off; + ip->i_ffs1_db[lbn] = off; break; case 1: - ip->i_ffs_ib[a[0].in_off] = off; + ip->i_ffs1_ib[a[0].in_off] = off; break; default: ap = &a[num - 1]; @@ -637,7 +637,7 @@ lfs_updatemeta(sp) * to get counted for the inode. */ if (bp->b_blkno == -1 && !(bp->b_flags & B_CACHE)) { - ip->i_ffs_blocks += fsbtodb(fs, 1); + ip->i_ffs1_blocks += fsbtodb(fs, 1); fs->lfs_bfree -= fragstodb(fs, fs->lfs_frag); } ((ufs_daddr_t *)bp->b_data)[ap->in_off] = off; diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index eec6edfdbb1..51188a24ca2 100644 --- a/sys/ufs/lfs/lfs_vfsops.c +++ b/sys/ufs/lfs/lfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_vfsops.c,v 1.21 2005/11/06 00:24:17 pedro Exp $ */ +/* $OpenBSD: lfs_vfsops.c,v 1.22 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_vfsops.c,v 1.11 1996/03/25 12:53:35 pk Exp $ */ /* @@ -601,7 +601,7 @@ lfs_vptofh(vp, fhp) ufhp = (struct ufid *)fhp; ufhp->ufid_len = sizeof(struct ufid); ufhp->ufid_ino = ip->i_number; - ufhp->ufid_gen = ip->i_ffs_gen; + ufhp->ufid_gen = ip->i_ffs1_gen; return (0); } diff --git a/sys/ufs/lfs/lfs_vnops.c b/sys/ufs/lfs/lfs_vnops.c index edf9a3bdbf2..dcd6bd5cd5e 100644 --- a/sys/ufs/lfs/lfs_vnops.c +++ b/sys/ufs/lfs/lfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_vnops.c,v 1.12 2005/05/28 02:02:50 pedro Exp $ */ +/* $OpenBSD: lfs_vnops.c,v 1.13 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: lfs_vnops.c,v 1.11 1996/05/11 18:27:41 mycroft Exp $ */ /* @@ -374,20 +374,20 @@ lfs_getattr(v) */ vap->va_fsid = ip->i_dev; vap->va_fileid = ip->i_number; - vap->va_mode = ip->i_ffs_mode & ~IFMT; - vap->va_nlink = ip->i_ffs_nlink; - vap->va_uid = ip->i_ffs_uid; - vap->va_gid = ip->i_ffs_gid; - vap->va_rdev = (dev_t)ip->i_ffs_rdev; - vap->va_size = ip->i_ffs_size; - vap->va_atime.tv_sec = ip->i_ffs_atime; - vap->va_atime.tv_nsec = ip->i_ffs_atimensec; - vap->va_mtime.tv_sec = ip->i_ffs_mtime; - vap->va_mtime.tv_nsec = ip->i_ffs_mtimensec; - vap->va_ctime.tv_sec = ip->i_ffs_ctime; - vap->va_ctime.tv_nsec = ip->i_ffs_ctimensec; - vap->va_flags = ip->i_ffs_flags; - vap->va_gen = ip->i_ffs_gen; + vap->va_mode = ip->i_ffs1_mode & ~IFMT; + vap->va_nlink = ip->i_ffs1_nlink; + vap->va_uid = ip->i_ffs1_uid; + vap->va_gid = ip->i_ffs1_gid; + vap->va_rdev = (dev_t)ip->i_ffs1_rdev; + vap->va_size = ip->i_ffs1_size; + vap->va_atime.tv_sec = ip->i_ffs1_atime; + vap->va_atime.tv_nsec = ip->i_ffs1_atimensec; + vap->va_mtime.tv_sec = ip->i_ffs1_mtime; + vap->va_mtime.tv_nsec = ip->i_ffs1_mtimensec; + vap->va_ctime.tv_sec = ip->i_ffs1_ctime; + vap->va_ctime.tv_nsec = ip->i_ffs1_ctimensec; + vap->va_flags = ip->i_ffs1_flags; + vap->va_gen = ip->i_ffs1_gen; /* this doesn't belong here */ if (vp->v_type == VBLK) vap->va_blocksize = BLKDEV_IOSIZE; @@ -395,7 +395,7 @@ lfs_getattr(v) vap->va_blocksize = MAXBSIZE; else vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize; - vap->va_bytes = dbtob(ip->i_ffs_blocks); + vap->va_bytes = dbtob(ip->i_ffs1_blocks); vap->va_type = vp->v_type; vap->va_filerev = ip->i_modrev; return (0); diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 37ad1ab1a1c..b7bc81d2152 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.31 2005/12/19 15:18:02 pedro Exp $ */ +/* $OpenBSD: inode.h,v 1.32 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -75,6 +75,7 @@ struct inode { struct lfs *lfs; /* LFS */ struct m_ext2fs *e2fs; /* EXT2FS */ } inode_u; + #define i_fs inode_u.fs #define i_lfs inode_u.lfs #define i_e2fs inode_u.e2fs @@ -161,44 +162,43 @@ struct inode_vtbl { #define UFS_BUFATOFF(ip, offset, res, bpp) \ ((ip)->i_vtbl->iv_bufatoff)((ip), (offset), (res), (bpp)) -#define i_ffs_atime i_din1->di_atime -#define i_ffs_atimensec i_din1->di_atimensec -#define i_ffs_blocks i_din1->di_blocks -#define i_ffs_ctime i_din1->di_ctime -#define i_ffs_ctimensec i_din1->di_ctimensec -#define i_ffs_db i_din1->di_db -#define i_ffs_flags i_din1->di_flags -#define i_ffs_gen i_din1->di_gen -#define i_ffs_gid i_din1->di_gid -#define i_ffs_ib i_din1->di_ib -#define i_ffs_mode i_din1->di_mode -#define i_ffs_mtime i_din1->di_mtime -#define i_ffs_mtimensec i_din1->di_mtimensec -#define i_ffs_nlink i_din1->di_nlink -#define i_ffs_rdev i_din1->di_rdev -#define i_ffs_shortlink i_din1->di_shortlink -#define i_ffs_size i_din1->di_size -#define i_ffs_uid i_din1->di_uid -#define i_size i_din1->di_size - -#define i_ffs2_atime i_din.ffs2_din->di_atime -#define i_ffs2_atimensec i_din.ffs2_din->di_atimensec -#define i_ffs2_blocks i_din.ffs2_din->di_blocks -#define i_ffs2_blksize i_din.ffs2_din->di_blksize -#define i_ffs2_ctime i_din.ffs2_din->di_ctime -#define i_ffs2_ctimensec i_din.ffs2_din->di_ctimensec -#define i_ffs2_db i_din.ffs2_din->di_db -#define i_ffs2_flags i_din.ffs2_din->di_flags -#define i_ffs2_gen i_din.ffs2_din->di_gen -#define i_ffs2_gid i_din.ffs2_din->di_gid -#define i_ffs2_ib i_din.ffs2_din->di_ib -#define i_ffs2_mode i_din.ffs2_din->di_mode -#define i_ffs2_mtime i_din.ffs2_din->di_mtime -#define i_ffs2_mtimensec i_din.ffs2_din->di_mtimensec -#define i_ffs2_nlink i_din.ffs2_din->di_nlink -#define i_ffs2_rdev i_din.ffs2_din->di_rdev -#define i_ffs2_size i_din.ffs2_din->di_size -#define i_ffs2_uid i_din.ffs2_din->di_uid +#define i_ffs1_atime i_din1->di_atime +#define i_ffs1_atimensec i_din1->di_atimensec +#define i_ffs1_blocks i_din1->di_blocks +#define i_ffs1_ctime i_din1->di_ctime +#define i_ffs1_ctimensec i_din1->di_ctimensec +#define i_ffs1_db i_din1->di_db +#define i_ffs1_flags i_din1->di_flags +#define i_ffs1_gen i_din1->di_gen +#define i_ffs1_gid i_din1->di_gid +#define i_ffs1_ib i_din1->di_ib +#define i_ffs1_mode i_din1->di_mode +#define i_ffs1_mtime i_din1->di_mtime +#define i_ffs1_mtimensec i_din1->di_mtimensec +#define i_ffs1_nlink i_din1->di_nlink +#define i_ffs1_rdev i_din1->di_rdev +#define i_ffs1_shortlink i_din1->di_shortlink +#define i_ffs1_size i_din1->di_size +#define i_ffs1_uid i_din1->di_uid + +#define i_ffs2_atime i_din2->di_atime +#define i_ffs2_atimensec i_din2->di_atimensec +#define i_ffs2_blocks i_din2->di_blocks +#define i_ffs2_blksize i_din2->di_blksize +#define i_ffs2_ctime i_din2->di_ctime +#define i_ffs2_ctimensec i_din2->di_ctimensec +#define i_ffs2_db i_din2->di_db +#define i_ffs2_flags i_din2->di_flags +#define i_ffs2_gen i_din2->di_gen +#define i_ffs2_gid i_din2->di_gid +#define i_ffs2_ib i_din2->di_ib +#define i_ffs2_mode i_din2->di_mode +#define i_ffs2_mtime i_din2->di_mtime +#define i_ffs2_mtimensec i_din2->di_mtimensec +#define i_ffs2_nlink i_din2->di_nlink +#define i_ffs2_rdev i_din2->di_rdev +#define i_ffs2_size i_din2->di_size +#define i_ffs2_uid i_din2->di_uid #ifndef _KERNEL /* @@ -264,7 +264,7 @@ struct inode_vtbl { */ #define DIP(ip, field) \ (((ip)->i_ump->um_fstype == UM_UFS1) ? \ - (ip)->i_din1->d##field : (ip)->i_din2->d##field) + (ip)->i_ffs1_##field : (ip)->i_ffs2_##field) #define DIP_ASSIGN(ip, field, value) \ do { \ @@ -284,7 +284,7 @@ struct inode_vtbl { #define SHORTLINK(ip) \ (((ip)->i_ump->um_fstype == UM_UFS1) ? \ - (caddr_t)(ip)->i_din1->di_db : (caddr_t)(ip)->i_din2->di_db) + (caddr_t)(ip)->i_ffs1_db : (caddr_t)(ip)->i_ffs2_db) /* * Structure used to pass around logical block paths generated by @@ -304,13 +304,13 @@ struct indir { if ((ip)->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)->i_flag |= IN_MODIFIED; \ if ((ip)->i_flag & IN_ACCESS) \ - (ip)->i_ffs_atime = (t1)->tv_sec; \ + DIP_ASSIGN((ip), atime, (t1)->tv_sec); \ if ((ip)->i_flag & IN_UPDATE) { \ - (ip)->i_ffs_mtime = (t2)->tv_sec; \ + DIP_ASSIGN((ip), mtime, (t2)->tv_sec); \ (ip)->i_modrev++; \ } \ if ((ip)->i_flag & IN_CHANGE) \ - (ip)->i_ffs_ctime = time_second; \ + DIP_ASSIGN((ip), ctime, time_second); \ (ip)->i_flag &= ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index bc436d74f83..09b25a5d6d1 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_bmap.c,v 1.18 2005/11/10 22:01:14 pedro Exp $ */ +/* $OpenBSD: ufs_bmap.c,v 1.19 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_bmap.c,v 1.3 1996/02/09 22:36:00 christos Exp $ */ /* @@ -134,19 +134,20 @@ ufs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap, num = *nump; if (num == 0) { - *bnp = blkptrtodb(ump, ip->i_ffs_db[bn]); + *bnp = blkptrtodb(ump, DIP(ip, db[bn])); if (*bnp == 0) *bnp = -1; else if (runp) for (++bn; bn < NDADDR && *runp < maxrun && - is_sequential(ump, ip->i_ffs_db[bn - 1], ip->i_ffs_db[bn]); + is_sequential(ump, DIP(ip, db[bn - 1]), + DIP(ip, db[bn])); ++bn, ++*runp); return (0); } /* Get disk address out of indirect block array */ - daddr = ip->i_ffs_ib[xap->in_off]; + daddr = DIP(ip, ib[xap->in_off]); devvp = VFSTOUFS(vp->v_mount)->um_devvp; for (bp = NULL, ++xap; --num; ++xap) { diff --git a/sys/ufs/ufs/ufs_dirhash.c b/sys/ufs/ufs/ufs_dirhash.c index 5402a10ce44..98b301799e5 100644 --- a/sys/ufs/ufs/ufs_dirhash.c +++ b/sys/ufs/ufs/ufs_dirhash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_dirhash.c,v 1.10 2005/10/13 22:03:11 mickey Exp $ */ +/* $OpenBSD: ufs_dirhash.c,v 1.11 2005/12/28 20:48:18 pedro Exp $ */ /* * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved. * @@ -116,11 +116,11 @@ ufsdirhash_build(struct inode *ip) /* Check if we can/should use dirhash. */ if (ip->i_dirhash == NULL) { - if (ip->i_size < ufs_mindirhashsize || OFSFMT(ip->i_vnode)) + if (DIP(ip, size) < ufs_mindirhashsize || OFSFMT(ip->i_vnode)) return (-1); } else { /* Hash exists, but sysctls could have changed. */ - if (ip->i_size < ufs_mindirhashsize || + if (DIP(ip, size) < ufs_mindirhashsize || ufs_dirhashmem > ufs_dirhashmaxmem) { ufsdirhash_free(ip); return (-1); @@ -138,12 +138,12 @@ ufsdirhash_build(struct inode *ip) vp = ip->i_vnode; /* Allocate 50% more entries than this dir size could ever need. */ - DIRHASH_ASSERT(ip->i_size >= DIRBLKSIZ, ("ufsdirhash_build size")); - nslots = ip->i_size / DIRECTSIZ(1); + DIRHASH_ASSERT(DIP(ip, size) >= DIRBLKSIZ, ("ufsdirhash_build size")); + nslots = DIP(ip, size) / DIRECTSIZ(1); nslots = (nslots * 3 + 1) / 2; narrays = howmany(nslots, DH_NBLKOFF); nslots = narrays * DH_NBLKOFF; - dirblocks = howmany(ip->i_size, DIRBLKSIZ); + dirblocks = howmany(DIP(ip, size), DIRBLKSIZ); nblocks = (dirblocks * 3 + 1) / 2; memreqd = sizeof(*dh) + narrays * sizeof(*dh->dh_hash) + @@ -207,7 +207,7 @@ ufsdirhash_build(struct inode *ip) bmask = VFSTOUFS(vp->v_mount)->um_mountp->mnt_stat.f_iosize - 1; pos = 0; - while (pos < ip->i_size) { + while (pos < DIP(ip, size)) { /* If necessary, get the next directory block. */ if ((pos & bmask) == 0) { if (bp != NULL) @@ -398,7 +398,7 @@ restart: continue; DIRHASH_UNLOCK(dh); - if (offset < 0 || offset >= ip->i_size) + if (offset < 0 || offset >= DIP(ip, size)) panic("ufsdirhash_lookup: bad offset in hash array"); if ((offset & ~bmask) != blkoff) { if (bp != NULL) diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index a5567576cfb..6fbade9a37b 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_inode.c,v 1.32 2005/12/17 13:56:01 pedro Exp $ */ +/* $OpenBSD: ufs_inode.c,v 1.33 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_inode.c,v 1.7 1996/05/11 18:27:52 mycroft Exp $ */ /* @@ -80,18 +80,18 @@ ufs_inactive(void *v) /* * Ignore inodes related to stale file handles. */ - if (ip->i_din1 == NULL || ip->i_ffs_mode == 0) + if (ip->i_din1 == NULL || DIP(ip, mode) == 0) goto out; - if (ip->i_ffs_nlink <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { + if (DIP(ip, nlink) <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { if (getinoquota(ip) == 0) (void)ufs_quota_free_inode(ip, NOCRED); error = UFS_TRUNCATE(ip, (off_t)0, 0, NOCRED); - ip->i_ffs_rdev = 0; - mode = ip->i_ffs_mode; - ip->i_ffs_mode = 0; + DIP_ASSIGN(ip, rdev, 0); + mode = DIP(ip, mode); + DIP_ASSIGN(ip, mode, 0); ip->i_flag |= IN_CHANGE | IN_UPDATE; /* @@ -122,7 +122,7 @@ out: * If we are done with the inode, reclaim it * so that it can be reused immediately. */ - if (ip->i_din1 == NULL || ip->i_ffs_mode == 0) + if (ip->i_din1 == NULL || DIP(ip, mode) == 0) vrecycle(vp, NULL, p); return (error); diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 8fe04244835..9c3990a0485 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_lookup.c,v 1.34 2005/11/10 22:01:14 pedro Exp $ */ +/* $OpenBSD: ufs_lookup.c,v 1.35 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_lookup.c,v 1.7 1996/02/09 22:36:06 christos Exp $ */ /* @@ -150,7 +150,7 @@ ufs_lookup(void *v) /* * Check accessiblity of directory. */ - if ((dp->i_ffs_mode & IFMT) != IFDIR) + if ((DIP(dp, mode) & IFMT) != IFDIR) return (ENOTDIR); if ((error = VOP_ACCESS(vdp, VEXEC, cred, cnp->cn_proc)) != 0) return (error); @@ -206,7 +206,7 @@ ufs_lookup(void *v) */ if (ufsdirhash_build(dp) == 0) { /* Look for a free slot if needed. */ - enduseful = dp->i_size; + enduseful = DIP(dp, size); if (slotstatus != FOUND) { slotoffset = ufsdirhash_findfree(dp, slotneeded, &slotsize); @@ -214,7 +214,7 @@ ufs_lookup(void *v) slotstatus = COMPACT; enduseful = ufsdirhash_enduseful(dp); if (enduseful < 0) - enduseful = dp->i_size; + enduseful = DIP(dp, size); } } /* Look up the component. */ @@ -228,7 +228,7 @@ ufs_lookup(void *v) goto foundentry; case ENOENT: #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ - dp->i_offset = roundup2(dp->i_size, DIRBLKSIZ); + dp->i_offset = roundup2(DIP(dp, size), DIRBLKSIZ); goto notfound; default: /* Something failed; just do a linear search. */ @@ -238,7 +238,7 @@ ufs_lookup(void *v) #endif /* UFS_DIRHASH */ if (nameiop != LOOKUP || dp->i_diroff == 0 || - dp->i_diroff >= dp->i_ffs_size) { + dp->i_diroff >= DIP(dp, size)) { entryoffsetinblock = 0; dp->i_offset = 0; numdirpasses = 1; @@ -251,7 +251,7 @@ ufs_lookup(void *v) nchstats.ncs_2passes++; } prevoff = dp->i_offset; - endsearch = roundup(dp->i_ffs_size, DIRBLKSIZ); + endsearch = roundup(DIP(dp, size), DIRBLKSIZ); enduseful = 0; searchloop: @@ -398,7 +398,7 @@ notfound: * dp->i_offset + dp->i_count. */ if (slotstatus == NONE) { - dp->i_offset = roundup(dp->i_ffs_size, DIRBLKSIZ); + dp->i_offset = roundup(DIP(dp, size), DIRBLKSIZ); dp->i_count = 0; enduseful = dp->i_offset; } else if (nameiop == DELETE) { @@ -449,9 +449,9 @@ found: * Check that directory length properly reflects presence * of this entry. */ - if (dp->i_offset + DIRSIZ(FSFMT(vdp), ep) > dp->i_ffs_size) { + if (dp->i_offset + DIRSIZ(FSFMT(vdp), ep) > DIP(dp, size)) { ufs_dirbad(dp, dp->i_offset, "i_ffs_size too small"); - dp->i_ffs_size = dp->i_offset + DIRSIZ(FSFMT(vdp), ep); + DIP_ASSIGN(dp, size, dp->i_offset + DIRSIZ(FSFMT(vdp), ep)); dp->i_flag |= IN_CHANGE | IN_UPDATE; } brelse(bp); @@ -502,10 +502,10 @@ found: * may not delete it (unless she's root). This * implements append-only directories. */ - if ((dp->i_ffs_mode & ISVTX) && + if ((DIP(dp, mode) & ISVTX) && cred->cr_uid != 0 && - cred->cr_uid != dp->i_ffs_uid && - VTOI(tdp)->i_ffs_uid != cred->cr_uid) { + cred->cr_uid != DIP(dp, uid) && + DIP(VTOI(tdp), uid) != cred->cr_uid) { vput(tdp); return (EPERM); } @@ -678,7 +678,7 @@ ufs_makedirentry(struct inode *ip, struct componentname *cnp, newdirp->d_namlen = cnp->cn_namelen; bcopy(cnp->cn_nameptr, newdirp->d_name, (unsigned)cnp->cn_namelen + 1); if (ITOV(ip)->v_mount->mnt_maxsymlinklen > 0) - newdirp->d_type = IFTODT(ip->i_ffs_mode); + newdirp->d_type = IFTODT(DIP(ip, mode)); else { newdirp->d_type = 0; # if (BYTE_ORDER == LITTLE_ENDIAN) @@ -736,9 +736,9 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, bdwrite(newdirbp); return (error); } - dp->i_ffs_size = dp->i_offset + DIRBLKSIZ; + DIP_ASSIGN(dp, size, dp->i_offset + DIRBLKSIZ); dp->i_flag |= IN_CHANGE | IN_UPDATE; - uvm_vnp_setsize(dvp, dp->i_ffs_size); + uvm_vnp_setsize(dvp, DIP(dp, size)); dirp->d_reclen = DIRBLKSIZ; blkoff = dp->i_offset & (VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_iosize - 1); @@ -813,8 +813,8 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, * * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN. */ - if (dp->i_offset + dp->i_count > dp->i_ffs_size) - dp->i_ffs_size = dp->i_offset + dp->i_count; + if (dp->i_offset + dp->i_count > DIP(dp, size)) + DIP_ASSIGN(dp, size, dp->i_offset + dp->i_count); /* * Get the block containing the space for the new directory entry. */ @@ -922,7 +922,7 @@ ufs_direnter(struct vnode *dvp, struct vnode *tvp, struct direct *dirp, * lock on the newly entered node. */ - if (error == 0 && dp->i_endoff && dp->i_endoff < dp->i_ffs_size) { + if (error == 0 && dp->i_endoff && dp->i_endoff < DIP(dp, size)) { if (tvp != NULL) VOP_UNLOCK(tvp, 0, p); #ifdef UFS_DIRHASH @@ -1006,7 +1006,7 @@ ufs_dirremove(struct vnode *dvp, struct inode *ip, int flags, int isrmdir) } else { if (ip) { ip->i_effnlink--; - ip->i_ffs_nlink--; + DIP_ADD(ip, nlink, -1); ip->i_flag |= IN_CHANGE; } if (DOINGASYNC(dvp) && dp->i_count != 0) { @@ -1045,7 +1045,7 @@ ufs_dirrewrite(struct inode *dp, struct inode *oip, ino_t newinum, int newtype, softdep_setup_directory_change(bp, dp, oip, newinum, isrmdir); bdwrite(bp); } else { - oip->i_ffs_nlink--; + DIP_ADD(oip, nlink, -1); oip->i_flag |= IN_CHANGE; if (DOINGASYNC(vdp)) { bdwrite(bp); @@ -1077,7 +1077,7 @@ ufs_dirempty(struct inode *ip, ino_t parentino, struct ucred *cred) size_t count; #define MINDIRSIZ (sizeof (struct dirtemplate) / 2) - m = ip->i_ffs_size; + m = DIP(ip, size); for (off = 0; off < m; off += dp->d_reclen) { error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off, UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0); diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index bc2c7e45c0c..a1413f7d5f7 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_quota.c,v 1.21 2005/11/30 10:35:08 pedro Exp $ */ +/* $OpenBSD: ufs_quota.c,v 1.22 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_quota.c,v 1.8 1996/02/09 22:36:09 christos Exp $ */ /* @@ -159,7 +159,7 @@ getinoquota(struct inode *ip) */ if (ip->i_dquot[USRQUOTA] == NODQUOT && (error = - dqget(vp, ip->i_ffs_uid, ump, USRQUOTA, &ip->i_dquot[USRQUOTA])) && + dqget(vp, DIP(ip, uid), ump, USRQUOTA, &ip->i_dquot[USRQUOTA])) && error != EINVAL) return (error); /* @@ -168,7 +168,7 @@ getinoquota(struct inode *ip) */ if (ip->i_dquot[GRPQUOTA] == NODQUOT && (error = - dqget(vp, ip->i_ffs_gid, ump, GRPQUOTA, &ip->i_dquot[GRPQUOTA])) && + dqget(vp, DIP(ip, gid), ump, GRPQUOTA, &ip->i_dquot[GRPQUOTA])) && error != EINVAL) return (error); return (0); @@ -267,7 +267,7 @@ chkdqchg(struct inode *ip, long change, struct ucred *cred, int type) */ if (ncurblocks >= dq->dq_bhardlimit && dq->dq_bhardlimit) { if ((dq->dq_flags & DQ_BLKS) == 0 && - ip->i_ffs_uid == cred->cr_uid) { + DIP(ip, uid) == cred->cr_uid) { uprintf("\n%s: write failed, %s disk limit reached\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type]); @@ -283,7 +283,7 @@ chkdqchg(struct inode *ip, long change, struct ucred *cred, int type) if (dq->dq_curblocks < dq->dq_bsoftlimit) { dq->dq_btime = time_second + ip->i_ump->um_btime[type]; - if (ip->i_ffs_uid == cred->cr_uid) + if (DIP(ip, uid) == cred->cr_uid) uprintf("\n%s: warning, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type], "disk quota exceeded"); @@ -291,7 +291,7 @@ chkdqchg(struct inode *ip, long change, struct ucred *cred, int type) } if (time_second > dq->dq_btime) { if ((dq->dq_flags & DQ_BLKS) == 0 && - ip->i_ffs_uid == cred->cr_uid) { + DIP(ip, uid) == cred->cr_uid) { uprintf("\n%s: write failed, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type], @@ -388,7 +388,7 @@ chkiqchg(struct inode *ip, long change, struct ucred *cred, int type) */ if (ncurinodes >= dq->dq_ihardlimit && dq->dq_ihardlimit) { if ((dq->dq_flags & DQ_INODS) == 0 && - ip->i_ffs_uid == cred->cr_uid) { + DIP(ip, uid) == cred->cr_uid) { uprintf("\n%s: write failed, %s inode limit reached\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type]); @@ -404,7 +404,7 @@ chkiqchg(struct inode *ip, long change, struct ucred *cred, int type) if (dq->dq_curinodes < dq->dq_isoftlimit) { dq->dq_itime = time_second + ip->i_ump->um_itime[type]; - if (ip->i_ffs_uid == cred->cr_uid) + if (DIP(ip, uid) == cred->cr_uid) uprintf("\n%s: warning, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type], "inode quota exceeded"); @@ -412,7 +412,7 @@ chkiqchg(struct inode *ip, long change, struct ucred *cred, int type) } if (time_second > dq->dq_itime) { if ((dq->dq_flags & DQ_INODS) == 0 && - ip->i_ffs_uid == cred->cr_uid) { + DIP(ip, uid) == cred->cr_uid) { uprintf("\n%s: write failed, %s %s\n", ITOV(ip)->v_mount->mnt_stat.f_mntonname, quotatypes[type], diff --git a/sys/ufs/ufs/ufs_readwrite.c b/sys/ufs/ufs/ufs_readwrite.c index 69ba26d4d75..0599c98c8c1 100644 --- a/sys/ufs/ufs/ufs_readwrite.c +++ b/sys/ufs/ufs/ufs_readwrite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_readwrite.c,v 1.27 2005/11/11 16:27:52 pedro Exp $ */ +/* $OpenBSD: ufs_readwrite.c,v 1.28 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_readwrite.c,v 1.9 1996/05/11 18:27:57 mycroft Exp $ */ /* @@ -84,7 +84,7 @@ READ(void *v) vp = ap->a_vp; ip = VTOI(vp); - mode = ip->i_ffs_mode; + mode = DIP(ip, mode); uio = ap->a_uio; #ifdef DIAGNOSTIC @@ -92,9 +92,9 @@ READ(void *v) panic("%s: mode", READ_S); if (vp->v_type == VLNK) { - if ((int)ip->i_ffs_size < vp->v_mount->mnt_maxsymlinklen || + if ((int)DIP(ip, size) < vp->v_mount->mnt_maxsymlinklen || (vp->v_mount->mnt_maxsymlinklen == 0 && - ip->i_ffs_blocks == 0)) + DIP(ip, blocks) == 0)) panic("%s: short symlink", READ_S); } else if (vp->v_type != VREG && vp->v_type != VDIR) panic("%s: type %d", READ_S, vp->v_type); @@ -107,7 +107,7 @@ READ(void *v) return (0); for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { - if ((bytesinfile = ip->i_ffs_size - uio->uio_offset) <= 0) + if ((bytesinfile = DIP(ip, size) - uio->uio_offset) <= 0) break; lbn = lblkno(fs, uio->uio_offset); nextlbn = lbn + 1; @@ -121,14 +121,14 @@ READ(void *v) #ifdef LFS_READWRITE (void)lfs_check(vp, lbn); - error = cluster_read(vp, &ip->i_ci, ip->i_ffs_size, lbn, + error = cluster_read(vp, &ip->i_ci, DIP(ip, size), lbn, size, NOCRED, &bp); #else - if (lblktosize(fs, nextlbn) >= ip->i_ffs_size) + if (lblktosize(fs, nextlbn) >= DIP(ip, size)) error = bread(vp, lbn, size, NOCRED, &bp); else if (doclusterread) error = cluster_read(vp, &ip->i_ci, - ip->i_ffs_size, lbn, size, NOCRED, &bp); + DIP(ip, size), lbn, size, NOCRED, &bp); else if (lbn - 1 == ip->i_ci.ci_lastr) { int nextsize = BLKSIZE(fs, ip, nextlbn); error = breadn(vp, lbn, @@ -208,8 +208,8 @@ WRITE(void *v) switch (vp->v_type) { case VREG: if (ioflag & IO_APPEND) - uio->uio_offset = ip->i_ffs_size; - if ((ip->i_ffs_flags & APPEND) && uio->uio_offset != ip->i_ffs_size) + uio->uio_offset = DIP(ip, size); + if ((DIP(ip, flags) & APPEND) && uio->uio_offset != DIP(ip, size)) return (EPERM); /* FALLTHROUGH */ case VLNK: @@ -239,7 +239,7 @@ WRITE(void *v) } resid = uio->uio_resid; - osize = ip->i_ffs_size; + osize = DIP(ip, size); flags = ioflag & IO_SYNC ? B_SYNC : 0; for (error = 0; uio->uio_resid > 0;) { @@ -256,9 +256,9 @@ WRITE(void *v) if ((error = UFS_BUF_ALLOC(ip, uio->uio_offset, xfersize, ap->a_cred, flags, &bp)) != 0) break; - if (uio->uio_offset + xfersize > ip->i_ffs_size) { - ip->i_ffs_size = uio->uio_offset + xfersize; - uvm_vnp_setsize(vp, ip->i_ffs_size); + if (uio->uio_offset + xfersize > DIP(ip, size)) { + DIP_ASSIGN(ip, size, uio->uio_offset + xfersize); + uvm_vnp_setsize(vp, DIP(ip, size)); extended = 1; } (void)uvm_vnp_uncache(vp); @@ -280,7 +280,7 @@ WRITE(void *v) (void)bwrite(bp); else if (xfersize + blkoffset == fs->fs_bsize) { if (doclusterwrite) - cluster_write(bp, &ip->i_ci, ip->i_ffs_size); + cluster_write(bp, &ip->i_ci, DIP(ip, size)); else bawrite(bp); } else @@ -296,7 +296,7 @@ WRITE(void *v) * tampering. */ if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0) - ip->i_ffs_mode &= ~(ISUID | ISGID); + DIP(ip, mode) &= ~(ISUID | ISGID); if (resid > uio->uio_resid) VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); if (error) { diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 99148f9da88..22a5f3a028d 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vfsops.c,v 1.13 2005/11/11 16:27:52 pedro Exp $ */ +/* $OpenBSD: ufs_vfsops.c,v 1.14 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_vfsops.c,v 1.4 1996/02/09 22:36:12 christos Exp $ */ /* @@ -141,7 +141,7 @@ ufs_fhtovp(struct mount *mp, struct ufid *ufhp, struct vnode **vpp) return (error); } ip = VTOI(nvp); - if (ip->i_ffs_mode == 0 || ip->i_ffs_gen != ufhp->ufid_gen) { + if (DIP(ip, mode) == 0 || DIP(ip, gen) != ufhp->ufid_gen) { vput(nvp); *vpp = NULLVP; return (ESTALE); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 9ffaca12f22..98ea0844735 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_vnops.c,v 1.70 2005/12/16 04:52:24 pedro Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.71 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -164,7 +164,7 @@ ufs_mknod(void *v) * Want to be able to use this to make badblock * inodes, so don't truncate the dev number. */ - ip->i_ffs_rdev = vap->va_rdev; + DIP_ASSIGN(ip, rdev, vap->va_rdev); } /* * Remove inode so that it will be reloaded by VFS_VGET and @@ -198,7 +198,7 @@ ufs_open(void *v) /* * Files marked append-only must be opened for appending. */ - if ((ip->i_ffs_flags & APPEND) && + if ((DIP(ip, flags) & APPEND) && (ap->a_mode & (FWRITE | O_APPEND)) == FWRITE) return (EPERM); @@ -279,11 +279,11 @@ ufs_access(void *v) } /* If immutable bit set, nobody gets to write it. */ - if ((mode & VWRITE) && (ip->i_ffs_flags & IMMUTABLE)) + if ((mode & VWRITE) && (DIP(ip, flags) & IMMUTABLE)) return (EPERM); - return (vaccess(ip->i_ffs_mode, ip->i_ffs_uid, ip->i_ffs_gid, - mode, ap->a_cred)); + return (vaccess(DIP(ip, mode), DIP(ip, uid), DIP(ip, gid), mode, + ap->a_cred)); } /* ARGSUSED */ @@ -308,20 +308,20 @@ ufs_getattr(void *v) */ vap->va_fsid = ip->i_dev; vap->va_fileid = ip->i_number; - vap->va_mode = ip->i_ffs_mode & ~IFMT; + vap->va_mode = DIP(ip, mode) & ~IFMT; vap->va_nlink = ip->i_effnlink; - vap->va_uid = ip->i_ffs_uid; - vap->va_gid = ip->i_ffs_gid; - vap->va_rdev = (dev_t)ip->i_ffs_rdev; - vap->va_size = ip->i_ffs_size; - vap->va_atime.tv_sec = ip->i_ffs_atime; - vap->va_atime.tv_nsec = ip->i_ffs_atimensec; - vap->va_mtime.tv_sec = ip->i_ffs_mtime; - vap->va_mtime.tv_nsec = ip->i_ffs_mtimensec; - vap->va_ctime.tv_sec = ip->i_ffs_ctime; - vap->va_ctime.tv_nsec = ip->i_ffs_ctimensec; - vap->va_flags = ip->i_ffs_flags; - vap->va_gen = ip->i_ffs_gen; + vap->va_uid = DIP(ip, uid); + vap->va_gid = DIP(ip, gid); + vap->va_rdev = (dev_t) DIP(ip, rdev); + vap->va_size = DIP(ip, size); + vap->va_atime.tv_sec = DIP(ip, atime); + vap->va_atime.tv_nsec = DIP(ip, atimensec); + vap->va_mtime.tv_sec = DIP(ip, mtime); + vap->va_mtime.tv_nsec = DIP(ip, mtimensec); + vap->va_ctime.tv_sec = DIP(ip, ctime); + vap->va_ctime.tv_nsec = DIP(ip, ctimensec); + vap->va_flags = DIP(ip, flags); + vap->va_gen = DIP(ip, gen); /* this doesn't belong here */ if (vp->v_type == VBLK) vap->va_blocksize = BLKDEV_IOSIZE; @@ -329,7 +329,7 @@ ufs_getattr(void *v) vap->va_blocksize = MAXBSIZE; else vap->va_blocksize = vp->v_mount->mnt_stat.f_iosize; - vap->va_bytes = dbtob((u_quad_t)ip->i_ffs_blocks); + vap->va_bytes = dbtob((u_quad_t) DIP(ip, blocks)); vap->va_type = vp->v_type; vap->va_filerev = ip->i_modrev; return (0); @@ -368,26 +368,26 @@ ufs_setattr(void *v) if (vap->va_flags != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if (cred->cr_uid != ip->i_ffs_uid && + if (cred->cr_uid != DIP(ip, uid) && (error = suser_ucred(cred))) return (error); if (cred->cr_uid == 0) { - if ((ip->i_ffs_flags & (SF_IMMUTABLE | SF_APPEND)) && + if ((DIP(ip, flags) & (SF_IMMUTABLE | SF_APPEND)) && securelevel > 0) return (EPERM); - ip->i_ffs_flags = vap->va_flags; + DIP_ASSIGN(ip, flags, vap->va_flags); } else { - if (ip->i_ffs_flags & (SF_IMMUTABLE | SF_APPEND) || + if (DIP(ip, flags) & (SF_IMMUTABLE | SF_APPEND) || (vap->va_flags & UF_SETTABLE) != vap->va_flags) return (EPERM); - ip->i_ffs_flags &= SF_SETTABLE; - ip->i_ffs_flags |= (vap->va_flags & UF_SETTABLE); + DIP(ip, flags) &= SF_SETTABLE; + DIP(ip, flags) |= (vap->va_flags & UF_SETTABLE); } ip->i_flag |= IN_CHANGE; if (vap->va_flags & (IMMUTABLE | APPEND)) return (0); } - if (ip->i_ffs_flags & (IMMUTABLE | APPEND)) + if (DIP(ip, flags) & (IMMUTABLE | APPEND)) return (EPERM); /* * Go through the fields and update if not VNOVAL. @@ -400,7 +400,7 @@ ufs_setattr(void *v) return (error); } if (vap->va_size != VNOVAL) { - oldsize = ip->i_ffs_size; + oldsize = DIP(ip, size); /* * Disallow write attempts on read-only file systems; * unless the file is a socket, fifo, or a block or @@ -425,7 +425,7 @@ ufs_setattr(void *v) if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) { if (vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if (cred->cr_uid != ip->i_ffs_uid && + if (cred->cr_uid != DIP(ip, uid) && (error = suser_ucred(cred)) && ((vap->va_vaflags & VA_UTIMES_NULL) == 0 || (error = VOP_ACCESS(vp, VWRITE, cred, p)))) @@ -458,19 +458,19 @@ ufs_chmod(struct vnode *vp, int mode, struct ucred *cred, struct proc *p) struct inode *ip = VTOI(vp); int error; - if (cred->cr_uid != ip->i_ffs_uid && + if (cred->cr_uid != DIP(ip, uid) && (error = suser_ucred(cred))) return (error); if (cred->cr_uid) { if (vp->v_type != VDIR && (mode & S_ISTXT)) return (EFTYPE); - if (!groupmember(ip->i_ffs_gid, cred) && (mode & ISGID)) + if (!groupmember(DIP(ip, gid), cred) && (mode & ISGID)) return (EPERM); } - ip->i_ffs_mode &= ~ALLPERMS; - ip->i_ffs_mode |= (mode & ALLPERMS); + DIP(ip, mode) &= ~ALLPERMS; + DIP(ip, mode) |= (mode & ALLPERMS); ip->i_flag |= IN_CHANGE; - if ((vp->v_flag & VTEXT) && (ip->i_ffs_mode & S_ISTXT) == 0) + if ((vp->v_flag & VTEXT) && (DIP(ip, mode) & S_ISTXT) == 0) (void) uvm_vnp_uncache(vp); return (0); } @@ -491,21 +491,21 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred, enum ufs_quota_flags quota_flags = 0; if (uid == (uid_t)VNOVAL) - uid = ip->i_ffs_uid; + uid = DIP(ip, uid); if (gid == (gid_t)VNOVAL) - gid = ip->i_ffs_gid; + gid = DIP(ip, gid); /* * If we don't own the file, are trying to change the owner * of the file, or are not a member of the target group, * the caller must be superuser or the call fails. */ - if ((cred->cr_uid != ip->i_ffs_uid || uid != ip->i_ffs_uid || - (gid != ip->i_ffs_gid && !groupmember((gid_t)gid, cred))) && + if ((cred->cr_uid != DIP(ip, uid) || uid != DIP(ip, uid) || + (gid != DIP(ip, gid) && !groupmember((gid_t)gid, cred))) && (error = suser_ucred(cred))) return (error); - ogid = ip->i_ffs_gid; - ouid = ip->i_ffs_uid; - change = ip->i_ffs_blocks; + ogid = DIP(ip, gid); + ouid = DIP(ip, uid); + change = DIP(ip, blocks); if (ouid == uid) quota_flags |= UFS_QUOTA_NOUID; @@ -519,8 +519,8 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred, (void) ufs_quota_free_inode2(ip, cred, quota_flags); (void) ufs_quota_delete(ip); - ip->i_ffs_gid = gid; - ip->i_ffs_uid = uid; + DIP_ASSIGN(ip, gid, gid); + DIP_ASSIGN(ip, uid, uid); if ((error = getinoquota(ip)) != 0) goto error; @@ -542,16 +542,17 @@ ufs_chown(struct vnode *vp, uid_t uid, gid_t gid, struct ucred *cred, if (ouid != uid || ogid != gid) ip->i_flag |= IN_CHANGE; if (ouid != uid && cred->cr_uid != 0) - ip->i_ffs_mode &= ~ISUID; + DIP(ip, mode) &= ~ISUID; if (ogid != gid && cred->cr_uid != 0) - ip->i_ffs_mode &= ~ISGID; + DIP(ip, mode) &= ~ISGID; return (0); error: (void) ufs_quota_delete(ip); - ip->i_ffs_gid = ogid; - ip->i_ffs_uid = ouid; + DIP_ASSIGN(ip, gid, ogid); + DIP_ASSIGN(ip, uid, ouid); + if (getinoquota(ip) == 0) { (void) ufs_quota_alloc_blocks2(ip, change, cred, quota_flags | UFS_QUOTA_FORCE); @@ -631,8 +632,8 @@ ufs_remove(void *v) int error; ip = VTOI(vp); - if (vp->v_type == VDIR || (ip->i_ffs_flags & (IMMUTABLE | APPEND)) || - (VTOI(dvp)->i_ffs_flags & APPEND)) { + if (vp->v_type == VDIR || (DIP(ip, flags) & (IMMUTABLE | APPEND)) || + (DIP(VTOI(dvp), flags) & APPEND)) { error = EPERM; goto out; } @@ -686,18 +687,18 @@ ufs_link(void *v) goto out2; } ip = VTOI(vp); - if ((nlink_t)ip->i_ffs_nlink >= LINK_MAX) { + if ((nlink_t) DIP(ip, nlink) >= LINK_MAX) { VOP_ABORTOP(dvp, cnp); error = EMLINK; goto out1; } - if (ip->i_ffs_flags & (IMMUTABLE | APPEND)) { + if (DIP(ip, flags) & (IMMUTABLE | APPEND)) { VOP_ABORTOP(dvp, cnp); error = EPERM; goto out1; } ip->i_effnlink++; - ip->i_ffs_nlink++; + DIP_ADD(ip, nlink, 1); ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(vp)) softdep_change_linkcnt(ip, 0); @@ -707,7 +708,7 @@ ufs_link(void *v) } if (error) { ip->i_effnlink--; - ip->i_ffs_nlink--; + DIP_ADD(ip, nlink, -1); ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(vp)) softdep_change_linkcnt(ip, 0); @@ -795,8 +796,8 @@ abortit: return (error); } - if (tvp && ((VTOI(tvp)->i_ffs_flags & (IMMUTABLE | APPEND)) || - (VTOI(tdvp)->i_ffs_flags & APPEND))) { + if (tvp && ((DIP(VTOI(tvp), flags) & (IMMUTABLE | APPEND)) || + (DIP(VTOI(tdvp), flags) & APPEND))) { error = EPERM; goto abortit; } @@ -848,18 +849,18 @@ abortit: /* fvp, tdvp, tvp now locked */ dp = VTOI(fdvp); ip = VTOI(fvp); - if ((nlink_t)ip->i_ffs_nlink >= LINK_MAX) { + if ((nlink_t) DIP(ip, nlink) >= LINK_MAX) { VOP_UNLOCK(fvp, 0, p); error = EMLINK; goto abortit; } - if ((ip->i_ffs_flags & (IMMUTABLE | APPEND)) || - (dp->i_ffs_flags & APPEND)) { + if ((DIP(ip, flags) & (IMMUTABLE | APPEND)) || + (DIP(dp, flags) & APPEND)) { VOP_UNLOCK(fvp, 0, p); error = EPERM; goto abortit; } - if ((ip->i_ffs_mode & IFMT) == IFDIR) { + if ((DIP(ip, mode) & IFMT) == IFDIR) { error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); if (!error && tvp) error = VOP_ACCESS(tvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); @@ -902,7 +903,7 @@ abortit: * may be wrong, but correctable. */ ip->i_effnlink++; - ip->i_ffs_nlink++; + DIP_ADD(ip, nlink, 1); ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(fvp)) softdep_change_linkcnt(ip, 0); @@ -964,19 +965,19 @@ abortit: * parent we don't fool with the link count. */ if (doingdirectory && newparent) { - if ((nlink_t)dp->i_ffs_nlink >= LINK_MAX) { + if ((nlink_t) DIP(dp, nlink) >= LINK_MAX) { error = EMLINK; goto bad; } dp->i_effnlink++; - dp->i_ffs_nlink++; + DIP_ADD(dp, nlink, 1); dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp, 0); if ((error = UFS_UPDATE(dp, !DOINGSOFTDEP(tdvp))) != 0) { dp->i_effnlink--; - dp->i_ffs_nlink--; + DIP_ADD(dp, nlink, -1); dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp, 0); @@ -987,7 +988,7 @@ abortit: if ((error = ufs_direnter(tdvp, NULL, &newdir, tcnp, NULL)) != 0) { if (doingdirectory && newparent) { dp->i_effnlink--; - dp->i_ffs_nlink--; + DIP_ADD(dp, nlink, -1); dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tdvp)) softdep_change_linkcnt(dp, 0); @@ -1011,9 +1012,9 @@ abortit: * otherwise the destination may not be changed (except by * root). This implements append-only directories. */ - if ((dp->i_ffs_mode & S_ISTXT) && tcnp->cn_cred->cr_uid != 0 && - tcnp->cn_cred->cr_uid != dp->i_ffs_uid && - xp->i_ffs_uid != tcnp->cn_cred->cr_uid) { + if ((DIP(dp, mode) & S_ISTXT) && tcnp->cn_cred->cr_uid != 0 && + tcnp->cn_cred->cr_uid != DIP(dp, uid) && + DIP(xp, uid )!= tcnp->cn_cred->cr_uid) { error = EPERM; goto bad; } @@ -1022,7 +1023,7 @@ abortit: * to it. Also, ensure source and target are compatible * (both directories, or both not directories). */ - if ((xp->i_ffs_mode & IFMT) == IFDIR) { + if ((DIP(xp, mode) & IFMT) == IFDIR) { if (xp->i_effnlink > 2 || !ufs_dirempty(xp, dp->i_number, tcnp->cn_cred)) { error = ENOTEMPTY; @@ -1039,7 +1040,7 @@ abortit: } if ((error = ufs_dirrewrite(dp, xp, ip->i_number, - IFTODT(ip->i_ffs_mode), (doingdirectory && newparent) ? + IFTODT(DIP(ip, mode)), (doingdirectory && newparent) ? newparent : doingdirectory)) != 0) goto bad; if (doingdirectory) { @@ -1065,11 +1066,11 @@ abortit: * them now. */ if (!newparent) { - dp->i_ffs_nlink--; + DIP_ADD(dp, nlink, -1); dp->i_flag |= IN_CHANGE; } - xp->i_ffs_nlink--; + DIP_ADD(xp, nlink, -1); xp->i_flag |= IN_CHANGE; if ((error = UFS_TRUNCATE(VTOI(tvp), (off_t)0, IO_SYNC, tcnp->cn_cred)) != 0) @@ -1152,7 +1153,7 @@ out: ip->i_flag &= ~IN_RENAME; if (vn_lock(fvp, LK_EXCLUSIVE, p) == 0) { ip->i_effnlink--; - ip->i_ffs_nlink--; + DIP_ADD(ip, nlink, -1); ip->i_flag |= IN_CHANGE; ip->i_flag &= ~IN_RENAME; if (DOINGSOFTDEP(fvp)) @@ -1190,7 +1191,7 @@ ufs_mkdir(void *v) panic("ufs_mkdir: no name"); #endif dp = VTOI(dvp); - if ((nlink_t)dp->i_ffs_nlink >= LINK_MAX) { + if ((nlink_t) DIP(dp, nlink) >= LINK_MAX) { error = EMLINK; goto out; } @@ -1203,9 +1204,11 @@ ufs_mkdir(void *v) */ if ((error = UFS_INODE_ALLOC(dp, dmode, cnp->cn_cred, &tvp)) != 0) goto out; + ip = VTOI(tvp); - ip->i_ffs_uid = cnp->cn_cred->cr_uid; - ip->i_ffs_gid = dp->i_ffs_gid; + + DIP_ASSIGN(ip, uid, cnp->cn_cred->cr_uid); + DIP_ASSIGN(ip, gid, DIP(dp, gid)); if ((error = getinoquota(ip)) || (error = ufs_quota_alloc_inode(ip, cnp->cn_cred))) { @@ -1217,10 +1220,10 @@ ufs_mkdir(void *v) } ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; - ip->i_ffs_mode = dmode; + DIP_ASSIGN(ip, mode, dmode); tvp->v_type = VDIR; /* Rest init'd in getnewvnode(). */ ip->i_effnlink = 2; - ip->i_ffs_nlink = 2; + DIP_ASSIGN(ip, nlink, 2); if (DOINGSOFTDEP(tvp)) softdep_change_linkcnt(ip, 0); @@ -1230,7 +1233,7 @@ ufs_mkdir(void *v) * possible if we crash. */ dp->i_effnlink++; - dp->i_ffs_nlink++; + DIP_ADD(dp, nlink, 1); dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(dvp)) softdep_change_linkcnt(dp, 0); @@ -1251,9 +1254,9 @@ ufs_mkdir(void *v) if ((error = UFS_BUF_ALLOC(ip, (off_t)0, DIRBLKSIZ, cnp->cn_cred, B_CLRBUF, &bp)) != 0) goto bad; - ip->i_ffs_size = DIRBLKSIZ; + DIP_ASSIGN(ip, size, DIRBLKSIZ); ip->i_flag |= IN_CHANGE | IN_UPDATE; - uvm_vnp_setsize(tvp, ip->i_ffs_size); + uvm_vnp_setsize(tvp, DIP(ip, size)); bcopy((caddr_t)&dirtemplate, (caddr_t)bp->b_data, sizeof dirtemplate); if (DOINGSOFTDEP(tvp)) { /* @@ -1296,7 +1299,7 @@ bad: *ap->a_vpp = tvp; } else { dp->i_effnlink--; - dp->i_ffs_nlink--; + DIP_ADD(dp, nlink, -1); dp->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(dvp)) softdep_change_linkcnt(dp, 0); @@ -1305,7 +1308,7 @@ bad: * do this for us because we set the link count to 0. */ ip->i_effnlink = 0; - ip->i_ffs_nlink = 0; + DIP_ASSIGN(ip, nlink, 0); ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tvp)) softdep_change_linkcnt(ip, 0); @@ -1364,8 +1367,8 @@ ufs_rmdir(void *v) error = ENOTEMPTY; goto out; } - if ((dp->i_ffs_flags & APPEND) || - (ip->i_ffs_flags & (IMMUTABLE | APPEND))) { + if ((DIP(dp, flags) & APPEND) || + (DIP(ip, flags) & (IMMUTABLE | APPEND))) { error = EPERM; goto out; } @@ -1402,9 +1405,9 @@ ufs_rmdir(void *v) if (!DOINGSOFTDEP(vp)) { int ioflag; - dp->i_ffs_nlink--; + DIP_ADD(dp, nlink, -1); dp->i_flag |= IN_CHANGE; - ip->i_ffs_nlink--; + DIP_ADD(ip, nlink, -1); ip->i_flag |= IN_CHANGE; ioflag = DOINGASYNC(vp) ? 0 : IO_SYNC; error = UFS_TRUNCATE(ip, (off_t)0, ioflag, cnp->cn_cred); @@ -1449,8 +1452,8 @@ ufs_symlink(void *v) len = strlen(ap->a_target); if (len < vp->v_mount->mnt_maxsymlinklen) { ip = VTOI(vp); - bcopy(ap->a_target, (char *)ip->i_ffs_shortlink, len); - ip->i_ffs_size = len; + bcopy(ap->a_target, (char *)SHORTLINK(ip), len); + DIP_ASSIGN(ip, size, len); ip->i_flag |= IN_CHANGE | IN_UPDATE; } else error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0, @@ -1575,8 +1578,10 @@ ufs_readdir(void *v) dp = (struct dirent *)((caddr_t)dp + dp->d_reclen); } } + uio->uio_resid += lost; - *ap->a_eofflag = VTOI(ap->a_vp)->i_ffs_size <= uio->uio_offset; + *ap->a_eofflag = DIP(VTOI(ap->a_vp), size) <= uio->uio_offset; + return (error); } @@ -1595,10 +1600,10 @@ ufs_readlink(void *v) struct inode *ip = VTOI(vp); int isize; - isize = ip->i_ffs_size; + isize = DIP(ip, size); if (isize < vp->v_mount->mnt_maxsymlinklen || - (vp->v_mount->mnt_maxsymlinklen == 0 && ip->i_ffs_blocks == 0)) { - uiomove((char *)ip->i_ffs_shortlink, isize, ap->a_uio); + (vp->v_mount->mnt_maxsymlinklen == 0 && DIP(ip, blocks) == 0)) { + uiomove((char *)SHORTLINK(ip), isize, ap->a_uio); return (0); } return (VOP_READ(vp, ap->a_uio, 0, ap->a_cred)); @@ -1710,9 +1715,9 @@ ufs_print(void *v) printf("tag VT_UFS, ino %d, on dev %d, %d", ip->i_number, major(ip->i_dev), minor(ip->i_dev)); printf(" flags 0x%x, effnlink %d, nlink %d\n", - ip->i_flag, ip->i_effnlink, ip->i_ffs_nlink); + ip->i_flag, ip->i_effnlink, DIP(ip, nlink)); printf("\tmode 0%o, owner %d, group %d, size %lld", - ip->i_ffs_mode, ip->i_ffs_uid, ip->i_ffs_gid, ip->i_ffs_size); + DIP(ip, mode), DIP(ip, uid), DIP(ip, gid), DIP(ip, size)); #ifdef FIFO if (vp->v_type == VFIFO) @@ -1916,7 +1921,7 @@ ufs_advlock(void *v) } */ *ap = v; struct inode *ip = VTOI(ap->a_vp); - return (lf_advlock(&ip->i_lockf, ip->i_ffs_size, ap->a_id, ap->a_op, + return (lf_advlock(&ip->i_lockf, DIP(ip, size), ap->a_id, ap->a_op, ap->a_fl, ap->a_flags)); } @@ -1934,11 +1939,11 @@ ufs_vinit(struct mount *mntp, int (**specops)(void *), vp = *vpp; ip = VTOI(vp); - switch(vp->v_type = IFTOVT(ip->i_ffs_mode)) { + switch(vp->v_type = IFTOVT(DIP(ip, mode))) { case VCHR: case VBLK: vp->v_op = specops; - if ((nvp = checkalias(vp, ip->i_ffs_rdev, mntp)) != NULL) { + if ((nvp = checkalias(vp, DIP(ip, rdev), mntp)) != NULL) { /* * Discard unneeded vnode, but save its inode. * Note that the lock is carried over in the inode @@ -2012,9 +2017,11 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp, vput(dvp); return (error); } + ip = VTOI(tvp); - ip->i_ffs_gid = pdir->i_ffs_gid; - ip->i_ffs_uid = cnp->cn_cred->cr_uid; + + DIP_ASSIGN(ip, gid, DIP(pdir, gid)); + DIP_ASSIGN(ip, uid, cnp->cn_cred->cr_uid); if ((error = getinoquota(ip)) || (error = ufs_quota_alloc_inode(ip, cnp->cn_cred))) { @@ -2026,16 +2033,16 @@ ufs_makeinode(int mode, struct vnode *dvp, struct vnode **vpp, } ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE; - ip->i_ffs_mode = mode; + DIP_ASSIGN(ip, mode, mode); tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */ ip->i_effnlink = 1; - ip->i_ffs_nlink = 1; + DIP_ASSIGN(ip, nlink, 1); if (DOINGSOFTDEP(tvp)) softdep_change_linkcnt(ip, 0); - if ((ip->i_ffs_mode & ISGID) && - !groupmember(ip->i_ffs_gid, cnp->cn_cred) && + if ((DIP(ip, mode) & ISGID) && + !groupmember(DIP(ip, gid), cnp->cn_cred) && suser_ucred(cnp->cn_cred)) - ip->i_ffs_mode &= ~ISGID; + DIP(ip, mode) &= ~ISGID; /* * Make sure inode goes to disk before directory entry. @@ -2061,7 +2068,7 @@ bad: pool_put(&namei_pool, cnp->cn_pnbuf); vput(dvp); ip->i_effnlink = 0; - ip->i_ffs_nlink = 0; + DIP_ASSIGN(ip, nlink, 0); ip->i_flag |= IN_CHANGE; if (DOINGSOFTDEP(tvp)) softdep_change_linkcnt(ip, 0); @@ -2138,7 +2145,7 @@ filt_ufsread(struct knote *kn, long hint) return (1); } - kn->kn_data = ip->i_ffs_size - kn->kn_fp->f_offset; + kn->kn_data = DIP(ip, size) - kn->kn_fp->f_offset; if (kn->kn_data == 0 && kn->kn_sfflags & NOTE_EOF) { kn->kn_fflags |= NOTE_EOF; return (1); diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index fbd81584673..57e97a890ed 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.54 2005/12/17 13:56:02 pedro Exp $ */ +/* $OpenBSD: fstat.c,v 1.55 2005/12/28 20:48:18 pedro Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$OpenBSD: fstat.c,v 1.54 2005/12/17 13:56:02 pedro Exp $"; +static char *rcsid = "$OpenBSD: fstat.c,v 1.55 2005/12/28 20:48:18 pedro Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -527,9 +527,9 @@ ufs_filestat(struct vnode *vp, struct filestat *fsp) fsp->fsid = inode.i_dev & 0xffff; fsp->fileid = (long)inode.i_number; - fsp->mode = inode.i_ffs_mode; - fsp->size = inode.i_ffs_size; - fsp->rdev = inode.i_ffs_rdev; + fsp->mode = inode.i_ffs1_mode; + fsp->size = inode.i_ffs1_size; + fsp->rdev = inode.i_ffs1_rdev; return 1; } diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index 8398c917138..ce6f1ca74d8 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pstat.c,v 1.55 2005/12/17 13:56:02 pedro Exp $ */ +/* $OpenBSD: pstat.c,v 1.56 2005/12/28 20:48:18 pedro Exp $ */ /* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */ /*- @@ -40,7 +40,7 @@ static char copyright[] = #if 0 from: static char sccsid[] = "@(#)pstat.c 8.9 (Berkeley) 2/16/94"; #else -static char *rcsid = "$OpenBSD: pstat.c,v 1.55 2005/12/17 13:56:02 pedro Exp $"; +static char *rcsid = "$OpenBSD: pstat.c,v 1.56 2005/12/28 20:48:18 pedro Exp $"; #endif #endif /* not lint */ @@ -394,16 +394,16 @@ ufs_print(struct vnode *vp) *flags = '\0'; (void)printf(" %6d %5s", ip->i_number, flagbuf); - type = ip->i_ffs_mode & S_IFMT; - if (S_ISCHR(ip->i_ffs_mode) || S_ISBLK(ip->i_ffs_mode)) + type = ip->i_ffs1_mode & S_IFMT; + if (S_ISCHR(ip->i_ffs1_mode) || S_ISBLK(ip->i_ffs1_mode)) if (usenumflag || - ((name = devname(ip->i_ffs_rdev, type)) == NULL)) + ((name = devname(ip->i_ffs1_rdev, type)) == NULL)) (void)printf(" %2d,%-2d", - major(ip->i_ffs_rdev), minor(ip->i_ffs_rdev)); + major(ip->i_ffs1_rdev), minor(ip->i_ffs1_rdev)); else (void)printf(" %7s", name); else - (void)printf(" %7qd", ip->i_ffs_size); + (void)printf(" %7qd", ip->i_ffs1_size); return (0); } |