From fc47f29c64601554da697a295151ba21d2d0f8aa Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Fri, 3 Mar 2000 08:00:27 +0000 Subject: [PATCH] MFS (ext2_lookup.c 1.17.2.2, ext2_vnops.c 1.42.2.2: fix "filetype" support). Approved by: jkh --- sys/gnu/ext2fs/ext2_lookup.c | 2 +- sys/gnu/ext2fs/ext2_vnops.c | 34 ++++++++++++++++++++++----------- sys/gnu/fs/ext2fs/ext2_lookup.c | 2 +- sys/gnu/fs/ext2fs/ext2_vnops.c | 34 ++++++++++++++++++++++----------- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c index 79eb7cd63d87..985dcf395fce 100644 --- a/sys/gnu/ext2fs/ext2_lookup.c +++ b/sys/gnu/ext2fs/ext2_lookup.c @@ -1039,7 +1039,7 @@ ext2_checkpath(source, target, cred) IO_NODELOCKED, cred, (int *)0, (struct proc *)0); if (error != 0) break; - namlen = ((struct odirtemplate *)&dirbuf)->dotdot_namlen; /* XXX */ + namlen = dirbuf.dotdot_type; /* like ufs little-endian */ if (namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c index d7b84adf75c9..0e57f30af44c 100644 --- a/sys/gnu/ext2fs/ext2_vnops.c +++ b/sys/gnu/ext2fs/ext2_vnops.c @@ -76,6 +76,7 @@ #include #include #include +#include static int ext2_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); @@ -146,6 +147,21 @@ static struct vnodeopv_desc ext2fs_fifoop_opv_desc = #include +/* + * A virgin directory (no blushing please). + * Note that the type and namlen fields are reversed relative to ufs. + * Also, we don't use `struct odirtemplate', since it would just cause + * endianness problems. + */ +static struct dirtemplate mastertemplate = { + 0, 12, 1, EXT2_FT_DIR, ".", + 0, DIRBLKSIZ - 12, 2, EXT2_FT_DIR, ".." +}; +static struct dirtemplate omastertemplate = { + 0, 12, 1, EXT2_FT_UNKNOWN, ".", + 0, DIRBLKSIZ - 12, 2, EXT2_FT_UNKNOWN, ".." +}; + /* * Create a regular file */ @@ -719,8 +735,8 @@ ext2_rename(ap) UIO_SYSSPACE, IO_NODELOCKED, tcnp->cn_cred, (int *)0, (struct proc *)0); if (error == 0) { - namlen = ((struct odirtemplate *) - &dirbuf)->dotdot_namlen; + /* Like ufs little-endian: */ + namlen = dirbuf.dotdot_type; if (namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { @@ -770,14 +786,6 @@ ext2_rename(ap) return (error); } -/* - * A virgin directory (no blushing please). - */ -static struct odirtemplate omastertemplate = { - 0, 12, 1, { '.', 0 }, - 0, DIRBLKSIZ - 12, 2, { '.', '.', 0 } -}; - /* * Mkdir system call */ @@ -897,7 +905,11 @@ ext2_mkdir(ap) goto bad; /* Initialize directory with "." and ".." from static template. */ - dtp = (struct dirtemplate *)&omastertemplate; + if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs->s_es, + EXT2_FEATURE_INCOMPAT_FILETYPE)) + dtp = &mastertemplate; + else + dtp = &omastertemplate; dirtemplate = *dtp; dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number; diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c index 79eb7cd63d87..985dcf395fce 100644 --- a/sys/gnu/fs/ext2fs/ext2_lookup.c +++ b/sys/gnu/fs/ext2fs/ext2_lookup.c @@ -1039,7 +1039,7 @@ ext2_checkpath(source, target, cred) IO_NODELOCKED, cred, (int *)0, (struct proc *)0); if (error != 0) break; - namlen = ((struct odirtemplate *)&dirbuf)->dotdot_namlen; /* XXX */ + namlen = dirbuf.dotdot_type; /* like ufs little-endian */ if (namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c index d7b84adf75c9..0e57f30af44c 100644 --- a/sys/gnu/fs/ext2fs/ext2_vnops.c +++ b/sys/gnu/fs/ext2fs/ext2_vnops.c @@ -76,6 +76,7 @@ #include #include #include +#include static int ext2_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); @@ -146,6 +147,21 @@ static struct vnodeopv_desc ext2fs_fifoop_opv_desc = #include +/* + * A virgin directory (no blushing please). + * Note that the type and namlen fields are reversed relative to ufs. + * Also, we don't use `struct odirtemplate', since it would just cause + * endianness problems. + */ +static struct dirtemplate mastertemplate = { + 0, 12, 1, EXT2_FT_DIR, ".", + 0, DIRBLKSIZ - 12, 2, EXT2_FT_DIR, ".." +}; +static struct dirtemplate omastertemplate = { + 0, 12, 1, EXT2_FT_UNKNOWN, ".", + 0, DIRBLKSIZ - 12, 2, EXT2_FT_UNKNOWN, ".." +}; + /* * Create a regular file */ @@ -719,8 +735,8 @@ ext2_rename(ap) UIO_SYSSPACE, IO_NODELOCKED, tcnp->cn_cred, (int *)0, (struct proc *)0); if (error == 0) { - namlen = ((struct odirtemplate *) - &dirbuf)->dotdot_namlen; + /* Like ufs little-endian: */ + namlen = dirbuf.dotdot_type; if (namlen != 2 || dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[1] != '.') { @@ -770,14 +786,6 @@ ext2_rename(ap) return (error); } -/* - * A virgin directory (no blushing please). - */ -static struct odirtemplate omastertemplate = { - 0, 12, 1, { '.', 0 }, - 0, DIRBLKSIZ - 12, 2, { '.', '.', 0 } -}; - /* * Mkdir system call */ @@ -897,7 +905,11 @@ ext2_mkdir(ap) goto bad; /* Initialize directory with "." and ".." from static template. */ - dtp = (struct dirtemplate *)&omastertemplate; + if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs->s_es, + EXT2_FEATURE_INCOMPAT_FILETYPE)) + dtp = &mastertemplate; + else + dtp = &omastertemplate; dirtemplate = *dtp; dirtemplate.dot_ino = ip->i_number; dirtemplate.dotdot_ino = dp->i_number;