diff options
-rw-r--r-- | lib/ext2fs/ChangeLog | 13 | ||||
-rw-r--r-- | lib/ext2fs/link.c | 10 | ||||
-rw-r--r-- | lib/ext2fs/mkdir.c | 6 | ||||
-rw-r--r-- | lib/ext2fs/newdir.c | 17 |
4 files changed, 40 insertions, 6 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 5496f16f..3b431106 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,16 @@ +1999-10-22 <tytso@valinux.com> + + * mkdir.c (ext2fs_mkdir): Pass EXT2_FT_DIR flag to ext2fs_link(). + + * link.c (ext2fs_link): This call now uses the low three bits of + the flags parameter to pass the directory filetype + information; it will set the directory entry FILETYPE + information if the filesystem supports it. + + * newdir.c (ext2fs_new_dir_block): If the FILETYPE superblock + option is set, then create the '.' and '..' entries with + the filetype set to EXT2_FT_DIR. + 1999-09-24 <tytso@valinux.com> * nt_io.c: New file which supports I/O under Windows NT. diff --git a/lib/ext2fs/link.c b/lib/ext2fs/link.c index 2bef3dcb..293a085e 100644 --- a/lib/ext2fs/link.c +++ b/lib/ext2fs/link.c @@ -29,6 +29,7 @@ struct link_struct { ino_t inode; int flags; int done; + struct ext2fs_sb *sb; }; static int link_proc(struct ext2_dir_entry *dirent, @@ -84,11 +85,17 @@ static int link_proc(struct ext2_dir_entry *dirent, dirent->inode = ls->inode; dirent->name_len = ls->namelen; strncpy(dirent->name, ls->name, ls->namelen); + if (ls->sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) + dirent->name_len |= (ls->flags & 0x7) << 8; ls->done++; return DIRENT_ABORT|DIRENT_CHANGED; } +/* + * Note: the low 3 bits of the flags field are used as the directory + * entry filetype. + */ #ifdef __TURBOC__ #pragma argsused #endif @@ -106,8 +113,9 @@ errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name, ino_t ino, ls.name = name; ls.namelen = name ? strlen(name) : 0; ls.inode = ino; - ls.flags = 0; + ls.flags = flags; ls.done = 0; + ls.sb = (struct ext2fs_sb *) fs->super; retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, 0, link_proc, &ls); diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c index b2e8094d..06fd9032 100644 --- a/lib/ext2fs/mkdir.c +++ b/lib/ext2fs/mkdir.c @@ -31,6 +31,10 @@ #include "ext2fs.h" +#ifndef EXT2_FT_DIR +#define EXT2_FT_DIR 2 +#endif + errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, const char *name) { @@ -116,7 +120,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum, } if (retval != EXT2_ET_FILE_NOT_FOUND) goto cleanup; - retval = ext2fs_link(fs, parent, name, ino, 0); + retval = ext2fs_link(fs, parent, name, ino, EXT2_FT_DIR); if (retval) goto cleanup; } diff --git a/lib/ext2fs/newdir.c b/lib/ext2fs/newdir.c index 8c0511ec..230ebafe 100644 --- a/lib/ext2fs/newdir.c +++ b/lib/ext2fs/newdir.c @@ -23,6 +23,10 @@ #include "ext2fs.h" +#ifndef EXT2_FT_DIR +#define EXT2_FT_DIR 2 +#endif + /* * Create new directory block */ @@ -33,6 +37,8 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, ino_t parent_ino, errcode_t retval; char *buf; int rec_len; + int filetype = 0; + struct ext2fs_sb *sb; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); @@ -44,14 +50,17 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, ino_t parent_ino, dir->rec_len = fs->blocksize; if (dir_ino) { + sb = (struct ext2fs_sb *) fs->super; + if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE) + filetype = EXT2_FT_DIR << 8; /* * Set up entry for '.' */ dir->inode = dir_ino; - dir->name_len = 1; + dir->name_len = 1 | filetype; dir->name[0] = '.'; - rec_len = dir->rec_len - EXT2_DIR_REC_LEN(dir->name_len); - dir->rec_len = EXT2_DIR_REC_LEN(dir->name_len); + rec_len = dir->rec_len - EXT2_DIR_REC_LEN(1); + dir->rec_len = EXT2_DIR_REC_LEN(1); /* * Set up entry for '..' @@ -59,7 +68,7 @@ errcode_t ext2fs_new_dir_block(ext2_filsys fs, ino_t dir_ino, ino_t parent_ino, dir = (struct ext2_dir_entry *) (buf + dir->rec_len); dir->rec_len = rec_len; dir->inode = parent_ino; - dir->name_len = 2; + dir->name_len = 2 | filetype; dir->name[0] = '.'; dir->name[1] = '.'; |