[PATCH] libparted: uninit_bg and flex_bg features should indicate ext4
Colin Watson
cjwatson at ubuntu.com
Mon Apr 12 23:11:13 UTC 2010
According to tune2fs(8), the uninit_bg and flex_bg features are only
supported by ext4, so libparted should treat their presence as
indicating ext4. Reported by C de-Avillez in
https://bugs.launchpad.net/ubuntu/+source/parted/+bug/561599.
* libparted/fs/ext2/ext2_fs.h: Define EXT4_FEATURE_RO_COMPAT_GDT_CSUM
and EXT4_FEATURE_INCOMPAT_FLEX_BG.
* libparted/fs/ext2/interface.c (_ext2_generic_probe): Test for
EXT4_FEATURE_RO_COMPAT_GDT_CSUM and EXT4_FEATURE_INCOMPAT_FLEX_BG when
probing for ext4.
* tests/t1700-ext-probe.sh: Test for this.
* NEWS (Bug fixes): Mention this.
---
NEWS | 3 +++
libparted/fs/ext2/ext2_fs.h | 2 ++
libparted/fs/ext2/interface.c | 6 +++++-
tests/t1700-ext-probe.sh | 14 ++++++++++++++
4 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/NEWS b/NEWS
index 2471b8b..8e678db 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,9 @@ GNU parted NEWS -*- outline -*-
Similarly, msdos_partition_get_flag(p,PED_PARTITION_HIDDEN) always returns 0
for an extended partition.
+ libparted uses a more accurate heuristic to distinguish between
+ ext4 and ext3 partitions.
+
** Changes in behavior
libparted no longer issues an exception/warning about >512-byte
diff --git a/libparted/fs/ext2/ext2_fs.h b/libparted/fs/ext2/ext2_fs.h
index 11bb6d7..f9ecd85 100644
--- a/libparted/fs/ext2/ext2_fs.h
+++ b/libparted/fs/ext2/ext2_fs.h
@@ -57,12 +57,14 @@
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
+#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
/*
* Special inodes numbers
diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c
index df771a9..95ef759 100644
--- a/libparted/fs/ext2/interface.c
+++ b/libparted/fs/ext2/interface.c
@@ -55,11 +55,15 @@ _ext2_generic_probe (PedGeometry* geom, int expect_ext_ver)
is_ext4 = ((EXT2_SUPER_FEATURE_RO_COMPAT (*sb)
& EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
|| (EXT2_SUPER_FEATURE_RO_COMPAT (*sb)
+ & EXT4_FEATURE_RO_COMPAT_GDT_CSUM)
+ || (EXT2_SUPER_FEATURE_RO_COMPAT (*sb)
& EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
|| (EXT2_SUPER_FEATURE_INCOMPAT (*sb)
& EXT4_FEATURE_INCOMPAT_EXTENTS)
|| (EXT2_SUPER_FEATURE_INCOMPAT (*sb)
- & EXT4_FEATURE_INCOMPAT_64BIT));
+ & EXT4_FEATURE_INCOMPAT_64BIT)
+ || (EXT2_SUPER_FEATURE_INCOMPAT (*sb)
+ & EXT4_FEATURE_INCOMPAT_FLEX_BG));
if (is_ext4)
is_ext3 = 0;
}
diff --git a/tests/t1700-ext-probe.sh b/tests/t1700-ext-probe.sh
index 4b3a5a4..62ca8e5 100755
--- a/tests/t1700-ext-probe.sh
+++ b/tests/t1700-ext-probe.sh
@@ -45,4 +45,18 @@ for type in ext2 ext3 ext4; do
done
+# Some features should indicate ext4 by themselves.
+for feature in uninit_bg flex_bg; do
+ # create an ext3 file system
+ dd if=/dev/zero of=$dev bs=1024 count=4096 >/dev/null || fail=1
+ mkfs.ext3 -F $dev >/dev/null || fail=1
+
+ # set the feature
+ tune2fs -O $feature $dev || fail=1
+
+ # probe the file system, which should now be ext4
+ parted -m -s $dev u s print >out 2>&1 || fail=1
+ grep '^1:.*:ext4::;$' out || fail=1
+done
+
Exit $fail
--
1.7.1.rc1.248.gcefbb
More information about the parted-devel
mailing list