From: "Ricardo M. Correia" <Ricardo.M.Correia@Sun.COM>
To: "Theodore Ts'o" <tytso@mit.edu>, linux-ext4@vger.kernel.org
Cc: Andreas Dilger <adilger@Sun.COM>
Subject: [PATCH e2fsprogs] Add ZFS detection to libblkid
Date: Fri, 30 May 2008 19:20:47 +0100 [thread overview]
Message-ID: <1212171647.7508.46.camel@localhost> (raw)
This patch adds ZFS filesystem detection to libblkid.
It probes for VDEV_BOOT_MAGIC in the first 2 ZFS labels in big-endian
and little-endian formats.
Unfortunately the probe table doesn't support probing from the end of
the device, otherwise we could also probe in the 3rd and 4th labels (in
case the first 2 labels were accidentally overwritten)..
Eventually we would set the UUID from the ZFS pool GUID and the LABEL tag
from the pool name, but that requires parsing an XDR encoding of the pool
configuration which is not trivial.
Signed-off-by: Ricardo M. Correia <Ricardo.M.Correia@Sun.COM>
Signed-off-by: Andreas Dilger <adilger@sun.com>
---
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index c8bc840..cad0860 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -774,6 +774,18 @@ static int probe_jfs(struct blkid_probe *probe,
return 0;
}
+static int probe_zfs(struct blkid_probe *probe, struct blkid_magic *id,
+ unsigned char *buf)
+{
+ char *vdev_label;
+ const char *pool_name = 0;
+
+ /* read nvpair data for pool name, pool GUID (complex) */
+ //blkid_set_tag(probe->dev, "LABEL", pool_name, sizeof(pool_name));
+ //set_uuid(probe->dev, pool_guid, 0);
+ return 0;
+}
+
static int probe_luks(struct blkid_probe *probe,
struct blkid_magic *id __BLKID_ATTR((unused)),
unsigned char *buf)
@@ -1095,15 +1107,6 @@ static int probe_lvm2(struct blkid_probe *probe,
return 0;
}
/*
- * BLKID_BLK_OFFS is at least as large as the highest bim_kboff defined
- * in the type_array table below + bim_kbalign.
- *
- * When probing for a lot of magics, we handle everything in 1kB
buffers so
- * that we don't have to worry about reading each combination of block
sizes.
- */
-#define BLKID_BLK_OFFS 64 /* currently reiserfs */
-
-/*
* Various filesystem magics that we can check for. Note that kboff
and
* sboff are in kilobytes and bytes respectively. All magics are in
* byte strings so we don't worry about endian issues.
@@ -1153,6 +1156,10 @@ static struct blkid_magic type_array[] = {
{ "iso9660", 32, 1, 5, "CD001", probe_iso9660 },
{ "iso9660", 32, 9, 5, "CDROM", probe_iso9660 },
{ "jfs", 32, 0, 4, "JFS1", probe_jfs },
+ { "zfs", 8, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c",
probe_zfs },
+ { "zfs", 8, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0",
probe_zfs },
+ { "zfs", 264, 0, 8, "\0\0\x02\xf5\xb0\x07\xb1\x0c",
probe_zfs },
+ { "zfs", 264, 0, 8, "\x0c\xb1\x07\xb0\xf5\x02\0\0",
probe_zfs },
{ "hfsplus", 1, 0, 2, "BD", probe_hfsplus },
{ "hfsplus", 1, 0, 2, "H+", 0 },
{ "hfs", 1, 0, 2, "BD", 0 },
@@ -1288,7 +1295,7 @@ try_again:
if (!buf)
continue;
- if (memcmp(id->bim_magic, buf + (id->bim_sboff&0x3ff),
+ if (memcmp(id->bim_magic, buf + (id->bim_sboff & 0x3ff),
id->bim_len))
continue;
@@ -1318,7 +1325,7 @@ try_again:
dev = 0;
goto found_type;
}
-
+
found_type:
if (dev && type) {
dev->bid_devno = st.st_rdev;
@@ -1327,7 +1334,7 @@ found_type:
cache->bic_flags |= BLKID_BIC_FL_CHANGED;
blkid_set_tag(dev, "TYPE", type, 0);
-
+
DBG(DEBUG_PROBE, printf("%s: devno 0x%04llx, type %s\n",
dev->bid_name, (long long)st.st_rdev, type));
}
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2008-05-30 18:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-30 18:20 Ricardo M. Correia [this message]
2008-06-02 7:41 ` [PATCH e2fsprogs] Add ZFS detection to libblkid Karel Zak
2008-06-02 15:03 ` Ricardo M. Correia
[not found] ` <1212418863.7337.34.camel@localhost>
2008-06-02 20:58 ` Karel Zak
2008-06-02 21:38 ` Andreas Dilger
2008-06-02 22:31 ` Karel Zak
2008-06-02 23:11 ` Andreas Dilger
2008-06-03 0:05 ` Theodore Tso
2008-06-03 1:11 ` Theodore Tso
2009-04-04 2:39 ` Eric Sandeen
2009-04-04 13:04 ` Eric Sandeen
2009-04-04 21:25 ` Andreas Dilger
2009-04-04 21:46 ` Eric Sandeen
2009-04-06 6:25 ` Andreas Dilger
2009-04-06 19:22 ` Ricardo M. Correia
2009-04-06 20:13 ` Eric Sandeen
2009-04-13 19:18 ` Ricardo M. Correia
2009-04-13 19:27 ` Eric Sandeen
2009-04-06 20:35 ` Karel Zak
2009-04-07 7:40 ` Andreas Dilger
2009-04-13 19:29 ` Ricardo M. Correia
2009-04-17 9:51 ` Karel Zak
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=1212171647.7508.46.camel@localhost \
--to=ricardo.m.correia@sun.com \
--cc=adilger@Sun.COM \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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