diff options
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 4 | ||||
-rw-r--r-- | sys/ufs/lfs/lfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/ufs/ufs/dir.h | 17 | ||||
-rw-r--r-- | sys/ufs/ufs/inode.h | 31 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 31 | ||||
-rw-r--r-- | sys/ufs/ufs/ufsmount.h | 3 |
6 files changed, 62 insertions, 30 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 4cba7974dd2..ee4c214d7b4 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.5 1996/06/24 03:35:01 downsj Exp $ */ +/* $OpenBSD: ffs_vfsops.c,v 1.6 1996/06/27 06:42:06 downsj Exp $ */ /* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */ /* @@ -531,6 +531,7 @@ ffs_mountfs(devvp, mp, p) ump->um_nindir = fs->fs_nindir; ump->um_bptrtodb = fs->fs_fsbtodb; ump->um_seqinc = fs->fs_frag; + ump->um_dirops = &ffs_dirops; for (i = 0; i < MAXQUOTAS; i++) ump->um_quotas[i] = NULLVP; devvp->v_specflags |= SI_MOUNTEDON; @@ -803,7 +804,6 @@ ffs_vget(mp, ino, vpp) ip->i_fs = fs = ump->um_fs; ip->i_dev = dev; ip->i_number = ino; - ip->i_dirops = &ffs_dirops; #ifdef QUOTA { int i; diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index b000bd4b019..ac8ee6d327f 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.4 1996/06/24 03:35:02 downsj Exp $ */ +/* $OpenBSD: lfs_vfsops.c,v 1.5 1996/06/27 06:42:07 downsj Exp $ */ /* $NetBSD: lfs_vfsops.c,v 1.11 1996/03/25 12:53:35 pk Exp $ */ /* @@ -79,7 +79,7 @@ struct vfsops lfs_vfsops = { lfs_init, }; -static struct ufs_dirops lfs_dirops = { +static struct ufs_dirops xlfs_dirops = { ufs_dirremove, ufs_direnter, ufs_dirempty, @@ -318,6 +318,7 @@ lfs_mountfs(devvp, mp, p) ump->um_bptrtodb = 0; ump->um_seqinc = 1 << fs->lfs_fsbtodb; ump->um_nindir = fs->lfs_nindir; + ump->um_dirops = &xlfs_dirops; for (i = 0; i < MAXQUOTAS; i++) ump->um_quotas[i] = NULLVP; devvp->v_specflags |= SI_MOUNTEDON; @@ -523,7 +524,6 @@ lfs_vget(mp, ino, vpp) * Ask Kirk. */ ip->i_lfs = ump->um_lfs; - ip->i_dirops = &lfs_dirops; /* Read in the disk contents for the inode, copy into the inode. */ error = bread(ump->um_devvp, daddr, (int)fs->lfs_bsize, NOCRED, &bp); diff --git a/sys/ufs/ufs/dir.h b/sys/ufs/ufs/dir.h index 336d9e0cc0a..7fdf465b6f1 100644 --- a/sys/ufs/ufs/dir.h +++ b/sys/ufs/ufs/dir.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dir.h,v 1.4 1996/06/24 23:16:01 tholo Exp $ */ +/* $OpenBSD: dir.h,v 1.5 1996/06/27 06:42:08 downsj Exp $ */ /* $NetBSD: dir.h,v 1.8 1996/03/09 19:42:41 scottr Exp $ */ /* @@ -178,6 +178,21 @@ struct ufs_dirops { int (*checkpath) __P((struct inode *, struct inode *, struct ucred *)); }; + +/* + * Macros for accessing the above. + */ +#define VN_DIRREMOVE(vn, cm) \ + VFSTOUFS(vn->v_mount)->um_dirops->dirremove(vn, cm) +#define VN_DIRENTER(in, vn, cm) \ + VFSTOUFS(vn->v_mount)->um_dirops->direnter(in, vn, cm) +#define VN_DIREMPTY(vn, in, it, uc) \ + VFSTOUFS(vn->v_mount)->um_dirops->dirempty(in, it, uc) +#define VN_DIRREWRITE(vn, in1, in2, cm) \ + VFSTOUFS(vn->v_mount)->um_dirops->dirrewrite(in1, in2, cm) +#define VN_CHECKPATH(vn, in1, in2, uc) \ + VFSTOUFS(vn->v_mount)->um_dirops->checkpath(in1, in2, uc) + #endif /* _KERNEL */ #endif /* !_DIR_H_ */ diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index ef294ff55a3..809374c1edd 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: inode.h,v 1.3 1996/06/24 10:23:22 downsj Exp $ */ +/* $OpenBSD: inode.h,v 1.4 1996/06/27 06:42:08 downsj Exp $ */ /* $NetBSD: inode.h,v 1.8 1995/06/15 23:22:50 cgd Exp $ */ /* @@ -45,6 +45,17 @@ #include <ufs/ufs/dir.h> /* + * Per-filesystem inode extensions. + */ +struct ext2_inode_ext { + int32_t block_group; + int32_t next_alloc_block; + int32_t next_alloc_goal; + int32_t prealloc_block; + int32_t prealloc_count; +}; + +/* * The inode is used to describe each active (or recently active) file in the * UFS filesystem. It is composed of two types of information. The first part * is the information that is needed only while the file is active (such as @@ -85,14 +96,20 @@ struct inode { doff_t i_offset; /* Offset of free space in directory. */ ino_t i_ino; /* Inode number of found directory. */ u_int32_t i_reclen; /* Size of found directory entry. */ + /* - * Directory operations pointers. - */ - struct ufs_dirops *i_dirops; - /* - * Ext2fs inode extensions. + * Inode extensions. */ - struct ext2_inode_info *i_e2ext; + union { + /* Other extensions could go here... */ + struct ext2_inode_ext e2ext; + } inode_ext; +#define i_block_group inode_ext.e2ext.block_group +#define i_next_alloc_block inode_ext.e2ext.next_alloc_block +#define i_next_alloc_goal inode_ext.e2ext.next_alloc_goal +#define i_prealloc_block inode_ext.e2ext.prealloc_block +#define i_prealloc_count inode_ext.e2ext.prealloc_count + /* * The on-disk dinode itself. */ diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 80bc2beac92..6a936e630b6 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.5 1996/06/24 03:35:04 downsj Exp $ */ +/* $OpenBSD: ufs_vnops.c,v 1.6 1996/06/27 06:42:09 downsj Exp $ */ /* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */ /* @@ -633,7 +633,7 @@ ufs_remove(v) error = EPERM; goto out; } - error = VTOI(dvp)->i_dirops->dirremove(dvp, ap->a_cnp); + error = VN_DIRREMOVE(dvp, ap->a_cnp); if (error == 0) { ip->i_nlink--; ip->i_flag |= IN_CHANGE; @@ -700,7 +700,7 @@ ufs_link(v) TIMEVAL_TO_TIMESPEC(&time, &ts); error = VOP_UPDATE(vp, &ts, &ts, 1); if (!error) - error = VTOI(dvp)->i_dirops->direnter(ip, dvp, cnp); + error = VN_DIRENTER(ip, dvp, cnp); if (error) { ip->i_nlink--; @@ -752,7 +752,7 @@ ufs_whiteout(v) newdir.d_namlen = cnp->cn_namelen; bcopy(cnp->cn_nameptr, newdir.d_name, (unsigned)cnp->cn_namelen + 1); newdir.d_type = DT_WHT; - error = ufs_direnter2(dvp, &newdir, cnp->cn_cred, cnp->cn_proc); + error = ufs_direnter2(dvp, &newdir, cnp->cn_cred, cnp->cn_proc); /* FIXME */ break; case DELETE: @@ -763,7 +763,7 @@ ufs_whiteout(v) #endif cnp->cn_flags &= ~DOWHITEOUT; - error = ufs_dirremove(dvp, cnp); + error = VN_DIRREMOVE(dvp, cnp); break; } if (cnp->cn_flags & HASBUF) { @@ -946,7 +946,7 @@ abortit: goto bad; if (xp != NULL) vput(tvp); - error = VTOI(tdvp)->i_dirops->checkpath(ip, dp, tcnp->cn_cred); + error = VN_CHECKPATH(tdvp, ip, dp, tcnp->cn_cred); if (error != 0) goto out; if ((tcnp->cn_flags & SAVESTART) == 0) @@ -983,7 +983,7 @@ abortit: if ((error = VOP_UPDATE(tdvp, &ts, &ts, 1)) != 0) goto bad; } - error = VTOI(tdvp)->i_dirops->direnter(ip, tdvp, tcnp); + error = VN_DIRENTER(ip, tdvp, tcnp); if (error != 0) { if (doingdirectory && newparent) { dp->i_nlink--; @@ -1019,9 +1019,8 @@ abortit: * (both directories, or both not directories). */ if ((xp->i_mode&IFMT) == IFDIR) { - if (! xp->i_dirops->dirempty - (xp, dp->i_number, tcnp->cn_cred) || - xp->i_nlink > 2) { + if (!VN_DIREMPTY(ITOV(xp), xp, dp->i_number, + tcnp->cn_cred) || xp->i_nlink > 2) { error = ENOTEMPTY; goto bad; } @@ -1034,7 +1033,7 @@ abortit: error = EISDIR; goto bad; } - error = dp->i_dirops->dirrewrite(dp, ip, tcnp); + error = VN_DIRREWRITE(ITOV(dp), dp, ip, tcnp); if (error != 0) goto bad; /* @@ -1149,7 +1148,7 @@ abortit: } } } - error = VTOI(fdvp)->i_dirops->dirremove(fdvp, fcnp); + error = VN_DIRREMOVE(fdvp, fcnp); if (!error) { xp->i_nlink--; xp->i_flag |= IN_CHANGE; @@ -1303,7 +1302,7 @@ ufs_mkdir(v) } /* Directory set up, now install it's entry in the parent directory. */ - error = VTOI(dvp)->i_dirops->direnter(ip, dvp, cnp); + error = VN_DIRENTER(ip, dvp, cnp); if (error != 0) { dp->i_nlink--; dp->i_flag |= IN_CHANGE; @@ -1366,7 +1365,7 @@ ufs_rmdir(v) */ error = 0; if (ip->i_nlink != 2 || - !ip->i_dirops->dirempty(ip, dp->i_number, cnp->cn_cred)) { + !VN_DIREMPTY(ITOV(ip), ip, dp->i_number, cnp->cn_cred)) { error = ENOTEMPTY; goto out; } @@ -1379,7 +1378,7 @@ ufs_rmdir(v) * inode. If we crash in between, the directory * will be reattached to lost+found, */ - error = VTOI(dvp)->i_dirops->dirremove(dvp, cnp); + error = VN_DIRREMOVE(dvp, cnp); if (error != 0) goto out; dp->i_nlink--; @@ -2082,7 +2081,7 @@ ufs_makeinode(mode, dvp, vpp, cnp) TIMEVAL_TO_TIMESPEC(&time, &ts); if ((error = VOP_UPDATE(tvp, &ts, &ts, 1)) != 0) goto bad; - error = VTOI(dvp)->i_dirops->direnter(ip, dvp, cnp); + error = VN_DIRENTER(ip, dvp, cnp); if (error != 0) goto bad; if ((cnp->cn_flags & SAVESTART) == 0) diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 1c7c0c6f192..cc4f2308b06 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ufsmount.h,v 1.2 1996/06/24 03:35:05 downsj Exp $ */ +/* $OpenBSD: ufsmount.h,v 1.3 1996/06/27 06:42:09 downsj Exp $ */ /* $NetBSD: ufsmount.h,v 1.4 1994/12/21 20:00:23 mycroft Exp $ */ /* @@ -71,6 +71,7 @@ struct ufsmount { char um_qflags[MAXQUOTAS]; /* quota specific flags */ struct netexport um_export; /* export information */ u_int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */ + struct ufs_dirops *um_dirops; /* per-fs directory ops. */ }; /* |