[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/17] ext2fs: use macro to check flags
From: |
Etienne Brateau |
Subject: |
[PATCH 07/17] ext2fs: use macro to check flags |
Date: |
Sun, 23 Jan 2022 05:17:05 +0100 |
* hyper.c: use macros to check flags
---
ext2fs/hyper.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/ext2fs/hyper.c b/ext2fs/hyper.c
index 93fb7dbb..6fc95eaf 100644
--- a/ext2fs/hyper.c
+++ b/ext2fs/hyper.c
@@ -60,6 +60,7 @@ get_hypermetadata (void)
{
error_t err;
size_t read = 0;
+ u_int32_t features;
if (sblock != NULL)
munmap (sblock, SBLOCK_SIZE);
@@ -112,24 +113,25 @@ get_hypermetadata (void)
inodes_per_block = block_size / EXT2_INODE_SIZE (sblock);
frag_size = EXT2_MIN_FRAG_SIZE << sblock->s_log_frag_size;
- if (frag_size)
- frags_per_block = block_size / frag_size;
- else
+ if (frag_size == 0)
ext2_panic ("frag size is zero!");
+ frags_per_block = block_size / frag_size;
if (sblock->s_rev_level > EXT2_GOOD_OLD_REV)
{
- if (sblock->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP)
- ext2_panic ("could not mount because of unsupported optional features"
- " (0x%x)",
- sblock->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP);
- if (sblock->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP)
- {
- ext2_warning ("mounted readonly because of"
- " unsupported optional features (0x%x)",
- sblock->s_feature_ro_compat &
~EXT2_FEATURE_RO_COMPAT_SUPP);
- diskfs_readonly = 1;
- }
+ features = EXT2_HAS_INCOMPAT_FEATURE(sblock,
EXT2_FEATURE_INCOMPAT_UNSUPPORTED);
+ if (features)
+ ext2_panic ("could not mount because of unsupported optional features "
+ "(0x%x)",
+ features);
+ features = EXT2_HAS_RO_COMPAT_FEATURE(sblock,
EXT2_FEATURE_RO_COMPAT_UNSUPPORTED);
+ if (features)
+ {
+ ext2_warning ("mounted readonly because of "
+ "unsupported optional features (0x%x)",
+ features);
+ diskfs_readonly = 1;
+ }
if (sblock->s_inode_size != EXT2_GOOD_OLD_INODE_SIZE)
ext2_panic ("inode size %d isn't supported", sblock->s_inode_size);
}
--
2.34.1
- [PATCH 16/17] ext2fs: remove a commented block of code, (continued)
- [PATCH 12/17] ext2fs: detect and warn when filesystem is an ext3 fs, Etienne Brateau, 2022/01/22
- [PATCH 07/17] ext2fs: use macro to check flags,
Etienne Brateau <=
- [PATCH 04/17] move to ext2_fs.h a #define, Etienne Brateau, 2022/01/22
- [PATCH 09/17] ext2fs: set the f_namelen to the correct value, Etienne Brateau, 2022/01/22
- [PATCH 15/17] Change a EIO by a ENOSPC in case where not enough space, Etienne Brateau, 2022/01/22
- Re: [PATCH 01/17] ext2fs Merge 2 headers, Samuel Thibault, 2022/01/23