summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/superblocks/zfs.c
diff options
context:
space:
mode:
authorAndreas Dilger2010-02-17 10:21:27 +0100
committerKarel Zak2010-02-17 10:23:55 +0100
commite54a76ca076625b1883ddf0595162eb8de81d5d1 (patch)
treee922e7dc9202bcd423730447f0ab2aaff39cc264 /shlibs/blkid/src/superblocks/zfs.c
parentswapon: fix swapsize calculation (diff)
downloadkernel-qcow2-util-linux-e54a76ca076625b1883ddf0595162eb8de81d5d1.tar.gz
kernel-qcow2-util-linux-e54a76ca076625b1883ddf0595162eb8de81d5d1.tar.xz
kernel-qcow2-util-linux-e54a76ca076625b1883ddf0595162eb8de81d5d1.zip
libblkid: fix ZSF 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. [kzak@redhat.com: - port e2fsprogs patch to util-linux-ng] Signed-off-by: Andreas Dilger <adilger@sun.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/superblocks/zfs.c')
-rw-r--r--shlibs/blkid/src/superblocks/zfs.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/shlibs/blkid/src/superblocks/zfs.c b/shlibs/blkid/src/superblocks/zfs.c
index 0f5802622..3ee936965 100644
--- a/shlibs/blkid/src/superblocks/zfs.c
+++ b/shlibs/blkid/src/superblocks/zfs.c
@@ -23,21 +23,22 @@ struct zfs_uberblock {
uint64_t ub_txg; /* txg of last sync */
uint64_t ub_guid_sum; /* sum of all vdev guids */
uint64_t ub_timestamp; /* UTC time of last sync */
- /*blkptr_t ub_rootbp;*/ /* MOS objset_phys_t */
+ char ub_rootbp; /* MOS objset_phys_t */
} __attribute__((packed));
static int probe_zfs(blkid_probe pr, const struct blkid_idmag *mag)
{
struct zfs_uberblock *ub;
- int swab_endian;
uint64_t spa_version;
ub = blkid_probe_get_sb(pr, mag, struct zfs_uberblock);
if (!ub)
return -1;
- swab_endian = (ub->ub_magic == swab64(UBERBLOCK_MAGIC));
- spa_version = swab_endian ? swab64(ub->ub_version) : ub->ub_version;
+ if (ub->ub_magic == be64_to_cpu(UBERBLOCK_MAGIC))
+ spa_version = be64_to_cpu(ub->ub_version);
+ else
+ spa_version = le64_to_cpu(ub->ub_version);
blkid_probe_sprintf_version(pr, "%" PRIu64, spa_version);
#if 0
@@ -57,10 +58,19 @@ const struct blkid_idinfo zfs_idinfo =
.minsz = 64 * 1024 * 1024,
.magics =
{
- { .magic = "\0\0\x02\xf5\xb0\x07\xb1\x0c", .len = 8, .kboff = 8 },
- { .magic = "\x1c\xb1\x07\xb0\xf5\x02\0\0", .len = 8, .kboff = 8 },
- { .magic = "\0\0\x02\xf5\xb0\x07\xb1\x0c", .len = 8, .kboff = 264 },
- { .magic = "\x0c\xb1\x07\xb0\xf5\x02\0\0", .len = 8, .kboff = 264 },
+ /* ZFS has 128 root blocks (#4 is the first used), check only 6 of them */
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 128 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 128 },
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 132 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 132 },
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 136 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 136 },
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 384 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 384 },
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 388 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 388 },
+ { .magic = "\0\0\0\0\0\xba\xb1\x0c", .len = 8, .kboff = 392 },
+ { .magic = "\x0c\xb1\xba\0\0\0\0\0", .len = 8, .kboff = 392 },
{ NULL }
}
};