From: Andreas Dilger Date: Thu, 12 Apr 2012 21:26:49 +0000 (-0600) Subject: blkid: fix ZFS device detection X-Git-Tag: v1.42.6.wc2~39 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=6babdd0d8013b7f9da83c95ec80bc2dc338d0077;p=tools%2Fe2fsprogs.git blkid: fix ZFS device detection Fix the ZFS device detection by looking at multiple uberblocks to see if any are present, rather than looking for the ZFS boot block which is not always present. There may be up to 128 uberblocks, but the first 4 are not written to disk on a newly-formatted filesystem so check several of them at different offsets within the uberblock array. Signed-off-by: Andreas Dilger --- diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index 4a929b0..1c8e415 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -1439,10 +1439,19 @@ 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 }, + /* ZFS has 128 root blocks (#4 is the first used), check only 6 of them */ + { "zfs", 128, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 128, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 132, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 132, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 136, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 136, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 384, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 384, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 388, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 388, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, + { "zfs", 392, 0, 8, "\0\0\0\0\0\xba\xb1\x0c", probe_zfs }, + { "zfs", 392, 0, 8, "\x0c\xb1\xba\0\0\0\0\0", probe_zfs }, { "hfsplus", 1, 0, 2, "BD", probe_hfsplus }, { "hfsplus", 1, 0, 2, "H+", probe_hfsplus }, { "hfsplus", 1, 0, 2, "HX", probe_hfsplus }, diff --git a/lib/blkid/probe.h b/lib/blkid/probe.h index 37e80ef..4f1687e 100644 --- a/lib/blkid/probe.h +++ b/lib/blkid/probe.h @@ -194,6 +194,16 @@ struct jfs_super_block { unsigned char js_loguuid[16]; }; +#define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */ +struct zfs_uberblock { + __u64 ub_magic; /* UBERBLOCK_MAGIC */ + __u64 ub_version; /* ZFS_VERSION */ + __u64 ub_txg; /* txg of last sync */ + __u64 ub_guid_sum; /* sum of all vdev guids */ + __u64 ub_timestamp; /* UTC time of last sync */ + char ub_rootbp; /* MOS objset_phys_t */ +}; + struct romfs_super_block { unsigned char ros_magic[8]; __u32 ros_dummy1[2];