ChangeLog, link.c, mkdir.c, newdir.c:

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.
bitmap-optimize
Theodore Ts'o 1999-10-23 00:58:54 +00:00
parent 7847c1d4ff
commit e6198e5a01
4 changed files with 40 additions and 6 deletions

View File

@ -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> 1999-09-24 <tytso@valinux.com>
* nt_io.c: New file which supports I/O under Windows NT. * nt_io.c: New file which supports I/O under Windows NT.

View File

@ -29,6 +29,7 @@ struct link_struct {
ino_t inode; ino_t inode;
int flags; int flags;
int done; int done;
struct ext2fs_sb *sb;
}; };
static int link_proc(struct ext2_dir_entry *dirent, 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->inode = ls->inode;
dirent->name_len = ls->namelen; dirent->name_len = ls->namelen;
strncpy(dirent->name, ls->name, 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++; ls->done++;
return DIRENT_ABORT|DIRENT_CHANGED; return DIRENT_ABORT|DIRENT_CHANGED;
} }
/*
* Note: the low 3 bits of the flags field are used as the directory
* entry filetype.
*/
#ifdef __TURBOC__ #ifdef __TURBOC__
#pragma argsused #pragma argsused
#endif #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.name = name;
ls.namelen = name ? strlen(name) : 0; ls.namelen = name ? strlen(name) : 0;
ls.inode = ino; ls.inode = ino;
ls.flags = 0; ls.flags = flags;
ls.done = 0; ls.done = 0;
ls.sb = (struct ext2fs_sb *) fs->super;
retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY, retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY,
0, link_proc, &ls); 0, link_proc, &ls);

View File

@ -31,6 +31,10 @@
#include "ext2fs.h" #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, errcode_t ext2fs_mkdir(ext2_filsys fs, ino_t parent, ino_t inum,
const char *name) 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) if (retval != EXT2_ET_FILE_NOT_FOUND)
goto cleanup; goto cleanup;
retval = ext2fs_link(fs, parent, name, ino, 0); retval = ext2fs_link(fs, parent, name, ino, EXT2_FT_DIR);
if (retval) if (retval)
goto cleanup; goto cleanup;
} }

View File

@ -23,6 +23,10 @@
#include "ext2fs.h" #include "ext2fs.h"
#ifndef EXT2_FT_DIR
#define EXT2_FT_DIR 2
#endif
/* /*
* Create new directory block * 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; errcode_t retval;
char *buf; char *buf;
int rec_len; int rec_len;
int filetype = 0;
struct ext2fs_sb *sb;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); 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; dir->rec_len = fs->blocksize;
if (dir_ino) { 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 '.' * Set up entry for '.'
*/ */
dir->inode = dir_ino; dir->inode = dir_ino;
dir->name_len = 1; dir->name_len = 1 | filetype;
dir->name[0] = '.'; dir->name[0] = '.';
rec_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(dir->name_len); dir->rec_len = EXT2_DIR_REC_LEN(1);
/* /*
* Set up entry for '..' * 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 = (struct ext2_dir_entry *) (buf + dir->rec_len);
dir->rec_len = rec_len; dir->rec_len = rec_len;
dir->inode = parent_ino; dir->inode = parent_ino;
dir->name_len = 2; dir->name_len = 2 | filetype;
dir->name[0] = '.'; dir->name[0] = '.';
dir->name[1] = '.'; dir->name[1] = '.';