MFS (ext2_lookup.c 1.17.2.2, ext2_vnops.c 1.42.2.2: fix "filetype" support).

Approved by:	jkh
This commit is contained in:
Bruce Evans 2000-03-03 08:00:27 +00:00
parent 1765c30eb8
commit fc47f29c64
4 changed files with 48 additions and 24 deletions

View File

@ -1039,7 +1039,7 @@ ext2_checkpath(source, target, cred)
IO_NODELOCKED, cred, (int *)0, (struct proc *)0); IO_NODELOCKED, cred, (int *)0, (struct proc *)0);
if (error != 0) if (error != 0)
break; break;
namlen = ((struct odirtemplate *)&dirbuf)->dotdot_namlen; /* XXX */ namlen = dirbuf.dotdot_type; /* like ufs little-endian */
if (namlen != 2 || if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') { dirbuf.dotdot_name[1] != '.') {

View File

@ -76,6 +76,7 @@
#include <gnu/ext2fs/ext2_fs_sb.h> #include <gnu/ext2fs/ext2_fs_sb.h>
#include <gnu/ext2fs/fs.h> #include <gnu/ext2fs/fs.h>
#include <gnu/ext2fs/ext2_extern.h> #include <gnu/ext2fs/ext2_extern.h>
#include <gnu/ext2fs/ext2_fs.h>
static int ext2_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); 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 <gnu/ext2fs/ext2_readwrite.c> #include <gnu/ext2fs/ext2_readwrite.c>
/*
* 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 * Create a regular file
*/ */
@ -719,8 +735,8 @@ ext2_rename(ap)
UIO_SYSSPACE, IO_NODELOCKED, UIO_SYSSPACE, IO_NODELOCKED,
tcnp->cn_cred, (int *)0, (struct proc *)0); tcnp->cn_cred, (int *)0, (struct proc *)0);
if (error == 0) { if (error == 0) {
namlen = ((struct odirtemplate *) /* Like ufs little-endian: */
&dirbuf)->dotdot_namlen; namlen = dirbuf.dotdot_type;
if (namlen != 2 || if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') { dirbuf.dotdot_name[1] != '.') {
@ -770,14 +786,6 @@ ext2_rename(ap)
return (error); return (error);
} }
/*
* A virgin directory (no blushing please).
*/
static struct odirtemplate omastertemplate = {
0, 12, 1, { '.', 0 },
0, DIRBLKSIZ - 12, 2, { '.', '.', 0 }
};
/* /*
* Mkdir system call * Mkdir system call
*/ */
@ -897,7 +905,11 @@ ext2_mkdir(ap)
goto bad; goto bad;
/* Initialize directory with "." and ".." from static template. */ /* 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 = *dtp;
dirtemplate.dot_ino = ip->i_number; dirtemplate.dot_ino = ip->i_number;
dirtemplate.dotdot_ino = dp->i_number; dirtemplate.dotdot_ino = dp->i_number;

View File

@ -1039,7 +1039,7 @@ ext2_checkpath(source, target, cred)
IO_NODELOCKED, cred, (int *)0, (struct proc *)0); IO_NODELOCKED, cred, (int *)0, (struct proc *)0);
if (error != 0) if (error != 0)
break; break;
namlen = ((struct odirtemplate *)&dirbuf)->dotdot_namlen; /* XXX */ namlen = dirbuf.dotdot_type; /* like ufs little-endian */
if (namlen != 2 || if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') { dirbuf.dotdot_name[1] != '.') {

View File

@ -76,6 +76,7 @@
#include <gnu/ext2fs/ext2_fs_sb.h> #include <gnu/ext2fs/ext2_fs_sb.h>
#include <gnu/ext2fs/fs.h> #include <gnu/ext2fs/fs.h>
#include <gnu/ext2fs/ext2_extern.h> #include <gnu/ext2fs/ext2_extern.h>
#include <gnu/ext2fs/ext2_fs.h>
static int ext2_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *)); 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 <gnu/ext2fs/ext2_readwrite.c> #include <gnu/ext2fs/ext2_readwrite.c>
/*
* 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 * Create a regular file
*/ */
@ -719,8 +735,8 @@ ext2_rename(ap)
UIO_SYSSPACE, IO_NODELOCKED, UIO_SYSSPACE, IO_NODELOCKED,
tcnp->cn_cred, (int *)0, (struct proc *)0); tcnp->cn_cred, (int *)0, (struct proc *)0);
if (error == 0) { if (error == 0) {
namlen = ((struct odirtemplate *) /* Like ufs little-endian: */
&dirbuf)->dotdot_namlen; namlen = dirbuf.dotdot_type;
if (namlen != 2 || if (namlen != 2 ||
dirbuf.dotdot_name[0] != '.' || dirbuf.dotdot_name[0] != '.' ||
dirbuf.dotdot_name[1] != '.') { dirbuf.dotdot_name[1] != '.') {
@ -770,14 +786,6 @@ ext2_rename(ap)
return (error); return (error);
} }
/*
* A virgin directory (no blushing please).
*/
static struct odirtemplate omastertemplate = {
0, 12, 1, { '.', 0 },
0, DIRBLKSIZ - 12, 2, { '.', '.', 0 }
};
/* /*
* Mkdir system call * Mkdir system call
*/ */
@ -897,7 +905,11 @@ ext2_mkdir(ap)
goto bad; goto bad;
/* Initialize directory with "." and ".." from static template. */ /* 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 = *dtp;
dirtemplate.dot_ino = ip->i_number; dirtemplate.dot_ino = ip->i_number;
dirtemplate.dotdot_ino = dp->i_number; dirtemplate.dotdot_ino = dp->i_number;