OSDN Git Service

Remove the last of behaviour-specific checks on EXT2_OS_LINUX
authorTheodore Ts'o <tytso@mit.edu>
Tue, 7 Jun 2016 17:36:47 +0000 (13:36 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 7 Jun 2016 17:36:47 +0000 (13:36 -0400)
If there is a feature check, we can just depend on the feature check.
If it is something that can't be checked via a feature flag, then
instead of checking for EXT2_OS_LINUX, we should instead check for
*NOT* EXT2_OS_HURD. since HURD is the special case.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/debugfs.c
e2fsck/pass1.c
lib/ext2fs/csum.c
misc/mke2fs.c

index ba8be40..b2b06fe 100644 (file)
@@ -851,7 +851,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
                        inode->i_file_acl | ((long long)
                                (inode->osd2.linux2.l_i_file_acl_high) << 32),
                        LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0);
-       if (os == EXT2_OS_LINUX)
+       if (os != EXT2_OS_HURD)
                fprintf(out, "%sLinks: %d   Blockcount: %llu\n",
                        prefix, inode->i_links_count,
                        (((unsigned long long)
@@ -908,8 +908,7 @@ void internal_dump_inode(FILE *out, const char *prefix,
                internal_dump_inode_extra(out, prefix, inode_num,
                                          (struct ext2_inode_large *) inode);
        dump_inode_attributes(out, inode_num);
-       if (current_fs->super->s_creator_os == EXT2_OS_LINUX &&
-           ext2fs_has_feature_metadata_csum(current_fs->super)) {
+       if (ext2fs_has_feature_metadata_csum(current_fs->super)) {
                __u32 crc = inode->i_checksum_lo;
                if (is_large_inode &&
                    large_inode->i_extra_isize >=
index eea321b..a4ae38a 100644 (file)
@@ -1710,11 +1710,11 @@ void e2fsck_pass1(e2fsck_t ctx)
                if (inode->i_faddr || frag || fsize ||
                    (LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl))
                        mark_inode_bad(ctx, ino);
-               if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
+               if ((fs->super->s_creator_os != EXT2_OS_HURD) &&
                    !ext2fs_has_feature_64bit(fs->super) &&
                    inode->osd2.linux2.l_i_file_acl_high != 0)
                        mark_inode_bad(ctx, ino);
-               if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
+               if ((fs->super->s_creator_os != EXT2_OS_HURD) &&
                    !ext2fs_has_feature_huge_file(fs->super) &&
                    (inode->osd2.linux2.l_i_blocks_hi != 0))
                        mark_inode_bad(ctx, ino);
@@ -3253,7 +3253,7 @@ static void check_blocks(e2fsck_t ctx, struct problem_context *pctx,
        if (LINUX_S_ISREG(inode->i_mode) &&
            ext2fs_needs_large_file_feature(EXT2_I_SIZE(inode)))
                ctx->large_files++;
-       if ((fs->super->s_creator_os == EXT2_OS_LINUX) &&
+       if ((fs->super->s_creator_os != EXT2_OS_HURD) &&
            ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
             (ext2fs_has_feature_huge_file(fs->super) &&
              (inode->i_flags & EXT4_HUGE_FILE_FL) &&
index ccb3057..fcee07c 100644 (file)
@@ -664,8 +664,7 @@ int ext2fs_inode_csum_verify(ext2_filsys fs, ext2_ino_t inum,
        unsigned int i, has_hi;
        char *cp;
 
-       if (fs->super->s_creator_os != EXT2_OS_LINUX ||
-           !ext2fs_has_feature_metadata_csum(fs->super))
+       if (!ext2fs_has_feature_metadata_csum(fs->super))
                return 1;
 
        has_hi = (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE &&
@@ -707,8 +706,7 @@ errcode_t ext2fs_inode_csum_set(ext2_filsys fs, ext2_ino_t inum,
        __u32 crc;
        int has_hi;
 
-       if (fs->super->s_creator_os != EXT2_OS_LINUX ||
-           !ext2fs_has_feature_metadata_csum(fs->super))
+       if (!ext2fs_has_feature_metadata_csum(fs->super))
                return 0;
 
        has_hi = (EXT2_INODE_SIZE(fs->super) > EXT2_GOOD_OLD_INODE_SIZE &&
index 7dc49b7..d98e71e 100644 (file)
@@ -444,8 +444,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag, int itable_zeroed)
                                      _("done                            \n"));
 
        /* Reserved inodes must always have correct checksums */
-       if (fs->super->s_creator_os == EXT2_OS_LINUX &&
-           ext2fs_has_feature_metadata_csum(fs->super))
+       if (ext2fs_has_feature_metadata_csum(fs->super))
                write_reserved_inodes(fs);
 }