diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-02-26 15:08:14 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-02-26 15:08:14 -0500 |
commit | 885bf6b83252672eb2e9bd2fb6fd45a1978b0661 (patch) | |
tree | daa44fdb58fbef742d5118c67bda8a7d1aab87a9 | |
parent | 7c4a2ef5946a52b9efa70b110d5abcf8f4fb6abe (diff) | |
download | e2fsprogs-885bf6b83252672eb2e9bd2fb6fd45a1978b0661.tar.gz |
tune2fs: Cleanup feature handling to avoid merge conflicts
Use a more abstract set of feature tests to avoid merge conflicts as
we add support for new features in the maint, master, next, and pu git
branches.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r-- | misc/tune2fs.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/misc/tune2fs.c b/misc/tune2fs.c index ad1d6461..ee7af4b1 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -301,25 +301,23 @@ static void update_mntopts(ext2_filsys fs, char *mntopts) */ static void update_feature_set(ext2_filsys fs, char *features) { - int sparse, old_sparse, filetype, old_filetype; - int journal, old_journal, dxdir, old_dxdir; struct ext2_super_block *sb= fs->super; __u32 old_compat, old_incompat, old_ro_compat; + __u32 old_features[3]; int type_err; unsigned int mask_err; - old_compat = sb->s_feature_compat; - old_ro_compat = sb->s_feature_ro_compat; - old_incompat = sb->s_feature_incompat; +#define FEATURE_ON(type, mask) (!(old_features[(type)] & (mask)) && \ + ((&sb->s_feature_compat)[(type)] & (mask))) +#define FEATURE_OFF(type, mask) ((old_features[(type)] & (mask)) && \ + !((&sb->s_feature_compat)[(type)] & (mask))) +#define FEATURE_CHANGED(type, mask) ((mask) & \ + (old_features[(type)] ^ (&sb->s_feature_compat)[(type)])) + + old_features[E2P_FEATURE_COMPAT] = sb->s_feature_compat; + old_features[E2P_FEATURE_INCOMPAT] = sb->s_feature_incompat; + old_features[E2P_FEATURE_RO_INCOMPAT] = sb->s_feature_ro_compat; - old_sparse = sb->s_feature_ro_compat & - EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; - old_filetype = sb->s_feature_incompat & - 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_feature2(features, &sb->s_feature_compat, ok_features, clear_ok_features, &type_err, &mask_err)) { @@ -339,15 +337,8 @@ static void update_feature_set(ext2_filsys fs, char *features) e2p_feature2string(type_err, mask_err)); exit(1); } - sparse = sb->s_feature_ro_compat & - EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER; - filetype = sb->s_feature_incompat & - 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 (FEATURE_OFF(E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { if ((mount_flags & EXT2_MF_MOUNTED) && !(mount_flags & EXT2_MF_READONLY)) { fputs(_("The has_journal flag may only be " @@ -370,7 +361,8 @@ static void update_feature_set(ext2_filsys fs, char *features) remove_journal_device(fs); } } - if (journal && !old_journal) { + + if (FEATURE_ON(E2P_FEATURE_COMPAT, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { /* * If adding a journal flag, let the create journal * code below handle creating setting the flag and @@ -381,7 +373,8 @@ 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 (FEATURE_ON(E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_DIR_INDEX)) { if (!sb->s_def_hash_version) sb->s_def_hash_version = EXT2_HASH_TEA; if (uuid_is_null((unsigned char *) sb->s_hash_seed)) @@ -392,14 +385,18 @@ static void update_feature_set(ext2_filsys fs, char *features) (sb->s_feature_compat || sb->s_feature_ro_compat || sb->s_feature_incompat)) ext2fs_update_dynamic_rev(fs); - if ((sparse != old_sparse) || - (filetype != old_filetype)) { + + if (FEATURE_CHANGED(E2P_FEATURE_RO_INCOMPAT, + EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER) || + FEATURE_CHANGED(E2P_FEATURE_INCOMPAT, + EXT2_FEATURE_INCOMPAT_FILETYPE)) { sb->s_state &= ~EXT2_VALID_FS; printf("\n%s\n", _(please_fsck)); } - if ((old_compat != sb->s_feature_compat) || - (old_ro_compat != sb->s_feature_ro_compat) || - (old_incompat != sb->s_feature_incompat)) + + if ((old_features[E2P_FEATURE_COMPAT] != sb->s_feature_compat) || + (old_features[E2P_FEATURE_INCOMPAT] != sb->s_feature_incompat) || + (old_features[E2P_FEATURE_RO_INCOMPAT] != sb->s_feature_ro_compat)) ext2fs_mark_super_dirty(fs); } |