Whamcloud - gitweb
ChangeLog, link.c, mkdir.c, newdir.c:
authorTheodore Ts'o <tytso@mit.edu>
Sat, 23 Oct 1999 00:58:54 +0000 (00:58 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 23 Oct 1999 00:58:54 +0000 (00:58 +0000)
  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.

lib/ext2fs/ChangeLog
lib/ext2fs/link.c
lib/ext2fs/mkdir.c
lib/ext2fs/newdir.c

index 5496f16..3b43110 100644 (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>
 
        * nt_io.c: New file which supports I/O under Windows NT.
index 2bef3dc..293a085 100644 (file)
@@ -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);
index b2e8094..06fd903 100644 (file)
 
 #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;
        }
index 8c0511e..230ebaf 100644 (file)
 
 #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] = '.';