From c0495d96fd1f7015e7beb3d9363cbe949d133173 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 7 Jun 2016 13:36:47 -0400 Subject: [PATCH] Remove the last of behaviour-specific checks on EXT2_OS_LINUX 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 --- debugfs/debugfs.c | 5 ++--- e2fsck/pass1.c | 6 +++--- lib/ext2fs/csum.c | 6 ++---- misc/mke2fs.c | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index ba8be40e..b2b06fe6 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -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 >= diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index eea321b8..a4ae38a0 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -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) && diff --git a/lib/ext2fs/csum.c b/lib/ext2fs/csum.c index ccb30578..fcee07c2 100644 --- a/lib/ext2fs/csum.c +++ b/lib/ext2fs/csum.c @@ -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 && diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 7dc49b73..d98e71e0 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -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); }