[parted-devel] [PATCH 2/2] libparted: Do not detect ext4 without journal as ext2

Brian C. Lane bcl at redhat.com
Wed May 28 20:03:25 BST 2025


From: Pascal Hambourg <pascal at plouf.fr.eu.org>

ext4 may have other incompatible features than journal and cannot be
mounted as ext2 by linux, so detect it as ext4 even without journal
if it has other incompatible features.
---
 libparted/fs/ext2/interface.c | 33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c
index 7e0b197..5f64ab3 100644
--- a/libparted/fs/ext2/interface.c
+++ b/libparted/fs/ext2/interface.c
@@ -52,24 +52,21 @@ _ext2_generic_probe (PedGeometry* geom, int expect_ext_ver)
 		int is_ext3 = 0;
 		int is_ext4 = 0;
 
-		is_ext3 = (EXT2_SUPER_FEATURE_COMPAT (*sb)
-			   & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0;
-		if (is_ext3) {
-			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)
-				   || (EXT2_SUPER_FEATURE_INCOMPAT (*sb)
-				       & EXT4_FEATURE_INCOMPAT_FLEX_BG));
-			if (is_ext4)
-				is_ext3 = 0;
-		}
+		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)
+			   || (EXT2_SUPER_FEATURE_INCOMPAT (*sb)
+			       & EXT4_FEATURE_INCOMPAT_FLEX_BG));
+		if (!is_ext4)
+			is_ext3 = (EXT2_SUPER_FEATURE_COMPAT (*sb)
+				   & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0;
 		if (expect_ext_ver == 2 && (is_ext3 || is_ext4))
 			return NULL;
 		if (expect_ext_ver == 3 && !is_ext3)
-- 
2.49.0




More information about the parted-devel mailing list