Whamcloud - gitweb
mke2fs.c (main): Enable directory indexing by default.
authorTheodore Ts'o <tytso@mit.edu>
Sun, 22 Sep 2002 19:37:40 +0000 (15:37 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 22 Sep 2002 19:37:40 +0000 (15:37 -0400)
tune2fs.c (update_feature_set): Allow directory indexing flag to
be set.  If so, set the default hash to be TEA, and
initialize the hash seed to a random value.

misc/ChangeLog
misc/mke2fs.c
misc/tune2fs.c

index c467f37..ed5e105 100644 (file)
@@ -1,3 +1,11 @@
+2002-09-22  root  <tytso@mit.edu>
+
+       * mke2fs.c (main): Enable directory indexing by default.
+
+       * tune2fs.c (update_feature_set): Allow directory indexing flag to
+               be set.  If so, set the default hash to be TEA, and
+               initialize the hash seed to a random value.
+
 2002-09-21  Theodore Ts'o  <tytso@mit.edu>
 
        * get_device_by_label.c (init_lvm): Fix bug which caused
index 0f5f1e0..c37eecc 100644 (file)
@@ -777,7 +777,8 @@ static void parse_raid_opts(const char *opts)
 }      
 
 static __u32 ok_features[3] = {
-       EXT3_FEATURE_COMPAT_HAS_JOURNAL,        /* Compat */
+       EXT3_FEATURE_COMPAT_HAS_JOURNAL |
+               EXT2_FEATURE_COMPAT_DIR_INDEX,  /* Compat */
        EXT2_FEATURE_INCOMPAT_FILETYPE|         /* Incompat */
                EXT3_FEATURE_INCOMPAT_JOURNAL_DEV,
        EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
@@ -841,7 +842,8 @@ static void PRS(int argc, char *argv[])
        param.s_rev_level = 1;  /* Create revision 1 filesystems now */
        param.s_feature_incompat |= EXT2_FEATURE_INCOMPAT_FILETYPE;
        param.s_feature_ro_compat |= EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER;
-               
+       param.s_feature_compat |= EXT2_FEATURE_COMPAT_DIR_INDEX;
+
 #ifdef __linux__
        if (uname(&ut)) {
                perror("uname");
@@ -1242,6 +1244,12 @@ int main (int argc, char *argv[])
        uuid_generate(fs->super->s_uuid);
 
        /*
+        * Initialize the directory index variables
+        */
+       fs->super->s_def_hash_version = EXT2_HASH_TEA;
+       uuid_generate((unsigned char *) fs->super->s_hash_seed);
+
+       /*
         * Add "jitter" to the superblock's check interval so that we
         * don't check all the filesystems at the same time.  We use a
         * kludgy hack of using the UUID to derive a random jitter value.
index a644bb4..9a8801b 100644 (file)
@@ -87,7 +87,8 @@ static void usage(void)
 }
 
 static __u32 ok_features[3] = {
-       EXT3_FEATURE_COMPAT_HAS_JOURNAL,        /* Compat */
+       EXT3_FEATURE_COMPAT_HAS_JOURNAL |
+               EXT2_FEATURE_COMPAT_DIR_INDEX,  /* Compat */
        EXT2_FEATURE_INCOMPAT_FILETYPE,         /* Incompat */
        EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     /* R/O compat */
 };
@@ -251,7 +252,7 @@ static void remove_journal_inode(ext2_filsys fs)
 static void update_feature_set(ext2_filsys fs, char *features)
 {
        int sparse, old_sparse, filetype, old_filetype;
-       int journal, old_journal;
+       int journal, old_journal, dxdir, old_dxdir;
        struct ext2_super_block *sb= fs->super;
 
        old_sparse = sb->s_feature_ro_compat &
@@ -260,6 +261,8 @@ static void update_feature_set(ext2_filsys fs, char *features)
                EXT2_FEATURE_INCOMPAT_FILETYPE;
        old_journal = sb->s_feature_compat &
                EXT3_FEATURE_COMPAT_HAS_JOURNAL;
+       old_dxdir = sb->s_feature_compat &
+               EXT2_FEATURE_COMPAT_DIR_INDEX;
        if (e2p_edit_feature(features, &sb->s_feature_compat,
                             ok_features)) {
                fprintf(stderr, _("Invalid filesystem option set: %s\n"),
@@ -272,6 +275,8 @@ static void update_feature_set(ext2_filsys fs, char *features)
                EXT2_FEATURE_INCOMPAT_FILETYPE;
        journal = sb->s_feature_compat &
                EXT3_FEATURE_COMPAT_HAS_JOURNAL;
+       dxdir = sb->s_feature_compat &
+               EXT2_FEATURE_COMPAT_DIR_INDEX;
        if (old_journal && !journal) {
                if ((mount_flags & EXT2_MF_MOUNTED) &&
                    !(mount_flags & EXT2_MF_READONLY)) {
@@ -308,6 +313,12 @@ static void update_feature_set(ext2_filsys fs, char *features)
                        journal_size = -1;
                sb->s_feature_compat &= ~EXT3_FEATURE_COMPAT_HAS_JOURNAL;
        }
+       if (dxdir && !old_dxdir) {
+               if (!sb->s_def_hash_version)
+                       sb->s_def_hash_version = EXT2_HASH_TEA;
+               if (uuid_is_null((unsigned char *) sb->s_hash_seed))
+                       uuid_generate((unsigned char *) sb->s_hash_seed);
+       }
 
        if (sb->s_rev_level == EXT2_GOOD_OLD_REV &&
            (sb->s_feature_compat || sb->s_feature_ro_compat ||