e2fsprogs/e2fsprogs-blkid_probe_ext4.patch

66 lines
2.3 KiB
Diff

Index: e2fsprogs-1.40/lib/blkid/probe.c
===================================================================
--- e2fsprogs-1.40.orig/lib/blkid/probe.c
+++ e2fsprogs-1.40/lib/blkid/probe.c
@@ -148,6 +148,39 @@ static void get_ext2_info(blkid_dev dev,
set_uuid(dev, es->s_uuid, 0);
}
+static int probe_ext4(struct blkid_probe *probe,
+ struct blkid_magic *id __BLKID_ATTR((unused)),
+ unsigned char *buf)
+{
+ struct ext2_super_block *es;
+ es = (struct ext2_super_block *)buf;
+
+ /* Distinguish between jbd and ext2/3 fs */
+ if (blkid_le32(es->s_feature_incompat) &
+ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
+ return -BLKID_ERR_PARAM;
+
+ /* Distinguish between ext3 and ext2 */
+ if (!(blkid_le32(es->s_feature_compat) &
+ EXT3_FEATURE_COMPAT_HAS_JOURNAL))
+ return -BLKID_ERR_PARAM;
+
+ /* Distinguish between ext4 and ext3 */
+ if (!(blkid_le32(es->s_feature_incompat) &
+ EXT3_FEATURE_INCOMPAT_EXTENTS))
+ return -BLKID_ERR_PARAM;
+
+ get_ext2_info(probe->dev, buf);
+
+ if ((es->s_feature_incompat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+ !uuid_is_null(es->s_journal_uuid))
+ set_uuid(probe->dev, es->s_journal_uuid, "EXT_JOURNAL");
+
+ blkid_set_tag(probe->dev, "SEC_TYPE", "ext2", sizeof("ext2"));
+
+ return 0;
+}
+
static int probe_ext3(struct blkid_probe *probe,
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
@@ -830,6 +863,7 @@ static struct blkid_magic type_array[] =
/* type kboff sboff len magic probe */
{ "oracleasm", 0, 32, 8, "ORCLDISK", probe_oracleasm },
{ "ntfs", 0, 3, 8, "NTFS ", probe_ntfs },
+ { "ext4dev", 1, 0x38, 2, "\123\357", probe_ext4 },
{ "jbd", 1, 0x38, 2, "\123\357", probe_jbd },
{ "ext3", 1, 0x38, 2, "\123\357", probe_ext3 },
{ "ext2", 1, 0x38, 2, "\123\357", probe_ext2 },
Index: e2fsprogs-1.40/lib/blkid/probe.h
===================================================================
--- e2fsprogs-1.40.orig/lib/blkid/probe.h
+++ e2fsprogs-1.40/lib/blkid/probe.h
@@ -87,6 +87,8 @@ struct ext2_super_block {
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x00000004
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x00000004
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x00000008
+#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x00000040
+
struct xfs_super_block {
unsigned char xs_magic[4];