diff options
author | dyson <dyson@FreeBSD.org> | 1995-11-05 23:36:07 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1995-11-05 23:36:07 +0000 |
commit | aa3705d78b7fc12ce3cf9e9a7437407154f241c8 (patch) | |
tree | 094e249a07c170c776bf0f48af3af60a7a2e1f6e /sys/ufs | |
parent | 65a271ba6d03e08c6a9486e645d658f5a04f03a6 (diff) | |
download | FreeBSD-src-aa3705d78b7fc12ce3cf9e9a7437407154f241c8.zip FreeBSD-src-aa3705d78b7fc12ce3cf9e9a7437407154f241c8.tar.gz |
Changes to existing files for ext2fs support. The UFS mods need rework
in the future as they are a bit crufty -- but at least the stuff is in the
tree now.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ufs/inode.h | 4 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_inode.c | 5 | ||||
-rw-r--r-- | sys/ufs/ufs/ufs_vnops.c | 126 | ||||
-rw-r--r-- | sys/ufs/ufs/ufsmount.h | 5 |
4 files changed, 132 insertions, 8 deletions
diff --git a/sys/ufs/ufs/inode.h b/sys/ufs/ufs/inode.h index 00105ea..7ff725b 100644 --- a/sys/ufs/ufs/inode.h +++ b/sys/ufs/ufs/inode.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)inode.h 8.4 (Berkeley) 1/21/94 - * $Id: inode.h,v 1.5 1995/04/24 05:13:11 dyson Exp $ + * $Id: inode.h,v 1.6 1995/05/30 08:15:30 rgrimes Exp $ */ #ifndef _UFS_UFS_INODE_H_ @@ -74,9 +74,11 @@ struct inode { union { /* Associated filesystem. */ struct fs *fs; /* FFS */ struct lfs *lfs; /* LFS */ + struct ext2_sb_info *e2fs; /* EXT2FS */ } inode_u; #define i_fs inode_u.fs #define i_lfs inode_u.lfs +#define i_e2fs inode_u.e2fs struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */ u_quad_t i_modrev; /* Revision level for lease. */ struct lockf *i_lockf; /* Head of byte-level lock list. */ diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index c3e4c51..54c6247 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_inode.c 8.4 (Berkeley) 1/21/94 - * $Id: ufs_inode.c,v 1.5 1994/10/15 04:08:44 ache Exp $ + * $Id: ufs_inode.c,v 1.6 1995/01/04 23:48:04 gibbs Exp $ */ #include <sys/param.h> @@ -173,6 +173,9 @@ ufs_reclaim(ap) } #endif switch (vp->v_mount->mnt_stat.f_type) { + case MOUNT_EXT2FS: + type = M_FFSNODE; + break; case MOUNT_UFS: type = M_FFSNODE; break; diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index ae3cb2f..e229d68 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)ufs_vnops.c 8.10 (Berkeley) 4/1/94 - * $Id: ufs_vnops.c,v 1.30 1995/10/07 10:13:41 bde Exp $ + * $Id: ufs_vnops.c,v 1.31 1995/10/22 09:32:48 davidg Exp $ */ #include <sys/param.h> @@ -70,6 +70,12 @@ static int ufs_chmod __P((struct vnode *, int, struct ucred *, struct proc *)); static int ufs_chown __P((struct vnode *, uid_t, gid_t, struct ucred *, struct proc *)); +#if EXT2FS +#include <gnu/ext2fs/ext2_extern.h> +#include <gnu/ext2fs/ext2_fs.h> +#include <gnu/ext2fs/ext2_fs_sb.h> +#endif /* EXT2FS */ + union _qcvt { quad_t qcvt; long val[2]; @@ -667,7 +673,16 @@ ufs_remove(ap) error = EPERM; goto out; } - if ((error = ufs_dirremove(dvp, ap->a_cnp)) == 0) { +#if EXT2FS + if (IS_EXT2_VNODE(dvp)) { + error = ext2_dirremove(dvp, ap->a_cnp); + } else { + error = ufs_dirremove(dvp, ap->a_cnp); + } +#else + error = ufs_dirremove(dvp, ap->a_cnp); +#endif /* EXT2FS */ + if (error == 0) { ip->i_nlink--; ip->i_flag |= IN_CHANGE; } @@ -726,8 +741,18 @@ ufs_link(ap) ip->i_flag |= IN_CHANGE; tv = time; error = VOP_UPDATE(vp, &tv, &tv, 1); - if (!error) + if (!error) { +#if EXT2FS + if (IS_EXT2_VNODE(tdvp)) { + error = ext2_direnter(ip, tdvp, cnp); + } else { + error = ufs_direnter(ip, tdvp, cnp); + } +#else error = ufs_direnter(ip, tdvp, cnp); +#endif /* EXT2FS */ + } + if (error) { ip->i_nlink--; ip->i_flag |= IN_CHANGE; @@ -915,7 +940,15 @@ abortit: goto bad; if (xp != NULL) vput(tvp); +#if EXT2FS + if (IS_EXT2_VNODE(tdvp)) { + error = ext2_checkpath(ip, dp, tcnp->cn_cred); + } else { + error = ufs_checkpath(ip, dp, tcnp->cn_cred); + } +#else error = ufs_checkpath(ip, dp, tcnp->cn_cred); +#endif /* EXT2FS */ if (error) goto out; if ((tcnp->cn_flags & SAVESTART) == 0) @@ -954,7 +987,15 @@ abortit: if (error) goto bad; } +#if EXT2FS + if (IS_EXT2_VNODE(tdvp)) { + error = ext2_direnter(ip, tdvp, tcnp); + } else { + error = ufs_direnter(ip, tdvp, tcnp); + } +#else error = ufs_direnter(ip, tdvp, tcnp); +#endif /* EXT2FS */ if (error) { if (doingdirectory && newparent) { dp->i_nlink--; @@ -990,7 +1031,13 @@ abortit: * (both directories, or both not directories). */ if ((xp->i_mode&IFMT) == IFDIR) { - if (!ufs_dirempty(xp, dp->i_number, tcnp->cn_cred) || +#if EXT2FS + if (! (IS_EXT2_VNODE(ITOV(xp)) ? + ext2_dirempty : ufs_dirempty) +#else + if (! ufs_dirempty +#endif /* EXT2FS */ + (xp, dp->i_number, tcnp->cn_cred) || xp->i_nlink > 2) { error = ENOTEMPTY; goto bad; @@ -1004,7 +1051,15 @@ abortit: error = EISDIR; goto bad; } +#if EXT2FS + if (IS_EXT2_VNODE(ITOV(dp))) { + error = ext2_dirrewrite(dp, ip, tcnp); + } else { + error = ufs_dirrewrite(dp, ip, tcnp); + } +#else error = ufs_dirrewrite(dp, ip, tcnp); +#endif /* EXT2FS */ if (error) goto bad; /* @@ -1096,6 +1151,11 @@ abortit: # else namlen = dirbuf.dotdot_namlen; # endif +#if EXT2FS + if(IS_EXT2_VNODE(fvp)) + namlen = ((struct odirtemplate *) + &dirbuf)->dotdot_namlen; +#endif /* EXT2FS */ if (namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { @@ -1114,7 +1174,15 @@ abortit: } } } +#if EXT2FS + if (IS_EXT2_VNODE(fdvp)) { + error = ext2_dirremove(fdvp, fcnp); + } else { + error = ufs_dirremove(fdvp, fcnp); + } +#else error = ufs_dirremove(fdvp, fcnp); +#endif /* EXT2FS */ if (!error) { xp->i_nlink--; xp->i_flag |= IN_CHANGE; @@ -1228,13 +1296,28 @@ ufs_mkdir(ap) goto bad; /* Initialize directory with "." and ".." from static template. */ - if (dvp->v_mount->mnt_maxsymlinklen > 0) + if (dvp->v_mount->mnt_maxsymlinklen > 0 +#if EXT2FS + /* omastertemplate is want we want for EXT2 */ + && !IS_EXT2_VNODE(dvp) +#endif /* EXT2FS */ + ) dtp = &mastertemplate; else dtp = (struct dirtemplate *)&omastertemplate; dirtemplate = *dtp; dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; +#if EXT2FS + /* note that in ext2 DIRBLKSIZ == blocksize, not DEV_BSIZE + * so let's just redefine it - for this function only + */ +#undef DIRBLKSIZ +#define DIRBLKSIZ (IS_EXT2_VNODE(dvp) ? \ + VTOI(dvp)->i_e2fs->s_blocksize : DEV_BSIZE) + if(IS_EXT2_VNODE(dvp)) + dirtemplate.dotdot_reclen = DIRBLKSIZ - 12; +#endif /* EXT2FS */ error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate, sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0); @@ -1251,7 +1334,15 @@ ufs_mkdir(ap) } /* Directory set up, now install it's entry in the parent directory. */ +#if EXT2FS + if (IS_EXT2_VNODE(dvp)) { + error = ext2_direnter(ip, dvp, cnp); + } else { + error = ufs_direnter(ip, dvp, cnp); + } +#else error = ufs_direnter(ip, dvp, cnp); +#endif /* EXT2FS */ if (error) { dp->i_nlink--; dp->i_flag |= IN_CHANGE; @@ -1271,6 +1362,10 @@ out: FREE(cnp->cn_pnbuf, M_NAMEI); vput(dvp); return (error); +#if EXT2FS +#undef DIRBLKSIZ +#define DIRBLKSIZ DEV_BSIZE +#endif /* EXT2FS */ } /* @@ -1309,7 +1404,12 @@ ufs_rmdir(ap) */ error = 0; if (ip->i_nlink != 2 || +#if EXT2FS + !(IS_EXT2_VNODE(ITOV(ip)) ? ext2_dirempty : ufs_dirempty) + (ip, dp->i_number, cnp->cn_cred)) { +#else !ufs_dirempty(ip, dp->i_number, cnp->cn_cred)) { +#endif /* EXT2FS */ error = ENOTEMPTY; goto out; } @@ -1322,7 +1422,15 @@ ufs_rmdir(ap) * inode. If we crash in between, the directory * will be reattached to lost+found, */ +#if EXT2FS + if (IS_EXT2_VNODE(dvp)) { + error = ext2_dirremove(dvp, cnp); + } else { + error = ufs_dirremove(dvp, cnp); + } +#else error = ufs_dirremove(dvp, cnp); +#endif /* EXT2FS */ if (error) goto out; dp->i_nlink--; @@ -2014,7 +2122,15 @@ ufs_makeinode(mode, dvp, vpp, cnp) error = VOP_UPDATE(tvp, &tv, &tv, 1); if (error) goto bad; +#if EXT2FS + if (IS_EXT2_VNODE(dvp)) { + error = ext2_direnter(ip, dvp, cnp); + } else { + error = ufs_direnter(ip, dvp, cnp); + } +#else error = ufs_direnter(ip, dvp, cnp); +#endif /* EXT2FS */ if (error) goto bad; if ((cnp->cn_flags & SAVESTART) == 0) diff --git a/sys/ufs/ufs/ufsmount.h b/sys/ufs/ufs/ufsmount.h index 02fdff2..e085b8b 100644 --- a/sys/ufs/ufs/ufsmount.h +++ b/sys/ufs/ufs/ufsmount.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ufsmount.h 8.2 (Berkeley) 1/12/94 - * $Id: ufsmount.h,v 1.2 1994/08/02 07:55:04 davidg Exp $ + * $Id: ufsmount.h,v 1.3 1994/08/21 07:16:18 paul Exp $ */ #ifndef _UFS_UFS_UFSMOUNT_H_ @@ -54,9 +54,12 @@ struct ufsmount { union { /* pointer to superblock */ struct lfs *lfs; /* LFS */ struct fs *fs; /* FFS */ + struct ext2_sb_info *e2fs; /* EXT2FS */ } ufsmount_u; #define um_fs ufsmount_u.fs #define um_lfs ufsmount_u.lfs +#define um_e2fs ufsmount_u.e2fs +#define um_e2fsb ufsmount_u.e2fs->s_es struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */ struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */ u_long um_nindir; /* indirect ptrs per block */ |