public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH e2fsprogs] teach libblkid about ext4(dev)
Date: Tue, 22 Jan 2008 17:11:11 -0600	[thread overview]
Message-ID: <4796780F.1000603@redhat.com> (raw)

Returns ext4dev for now; will need to change to ext4 at the appropriate
time I guess.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>

--- 

Index: e2fsprogs-1.40.4/lib/blkid/probe.c

===================================================================
--- e2fsprogs-1.40.4.orig/lib/blkid/probe.c
+++ e2fsprogs-1.40.4/lib/blkid/probe.c
@@ -148,6 +148,38 @@ 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/4 fs */
+	if (blkid_le32(es->s_feature_incompat) &
+	    EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)
+		return -BLKID_ERR_PARAM;
+
+	/* Distinguish between ext3/4 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_ro_compat) &
+	      EXT4_FEATURES_RO_COMPAT) &&
+	    !(blkid_le32(es->s_feature_incompat) &
+	      EXT4_FEATURES_INCOMPAT))
+		return -BLKID_ERR_PARAM;
+
+	get_ext2_info(probe->dev, buf);
+
+	if ((es->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) &&
+	    !uuid_is_null(es->s_journal_uuid))
+		set_uuid(probe->dev, es->s_journal_uuid, "EXT_JOURNAL");
+
+	return 0;
+}
 static int probe_ext3(struct blkid_probe *probe, 
 		      struct blkid_magic *id __BLKID_ATTR((unused)), 
 		      unsigned char *buf)
@@ -833,6 +865,7 @@ static struct blkid_magic type_array[] =
   { "oracleasm", 0,	32,  8, "ORCLDISK",		probe_oracleasm },
   { "ntfs",	 0,	 3,  8, "NTFS    ",		probe_ntfs },
   { "jbd",	 1,   0x38,  2, "\123\357",		probe_jbd },
+  { "ext4dev",	 1,   0x38,  2, "\123\357",		probe_ext4 },
   { "ext3",	 1,   0x38,  2, "\123\357",		probe_ext3 },
   { "ext2",	 1,   0x38,  2, "\123\357",		probe_ext2 },
   { "reiserfs",	 8,   0x34,  8, "ReIsErFs",		probe_reiserfs },
Index: e2fsprogs-1.40.4/lib/blkid/probe.h
===================================================================
--- e2fsprogs-1.40.4.orig/lib/blkid/probe.h
+++ e2fsprogs-1.40.4/lib/blkid/probe.h
@@ -88,6 +88,26 @@ struct ext2_super_block {
 #define EXT3_FEATURE_INCOMPAT_RECOVER		0x00000004
 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x00000008
 
+#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 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE	0x0040
+
+#define EXT4_FEATURE_INCOMPAT_EXTENTS		0x0040 /* extents support */
+#define EXT4_FEATURE_INCOMPAT_64BIT		0x0080
+#define EXT4_FEATURE_INCOMPAT_MMP		0x0100
+#define EXT4_FEATURE_INCOMPAT_FLEX_BG		0x0200
+
+#define EXT4_FEATURES_RO_COMPAT	(EXT4_FEATURE_RO_COMPAT_HUGE_FILE| \
+				 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
+				 EXT4_FEATURE_RO_COMPAT_DIR_NLINK| \
+				 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE)
+
+#define EXT4_FEATURES_INCOMPAT	(EXT4_FEATURE_INCOMPAT_EXTENTS| \
+				 EXT4_FEATURE_INCOMPAT_64BIT| \
+				 EXT4_FEATURE_INCOMPAT_MMP| \
+				 EXT4_FEATURE_INCOMPAT_FLEX_BG)
+
 struct xfs_super_block {
 	unsigned char	xs_magic[4];
 	__u32		xs_blocksize;

             reply	other threads:[~2008-01-22 23:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-22 23:11 Eric Sandeen [this message]
2008-01-22 23:25 ` [PATCH e2fsprogs] teach libblkid about ext4(dev) Theodore Tso
2008-01-27  3:27 ` Theodore Tso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4796780F.1000603@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox