2 * Copyright (C) 2009 by Andreas Dilger <adilger@sun.com>
4 * This file may be redistributed under the terms of the
5 * GNU Lesser General Public License.
18 /* #include <sys/uberblock_impl.h> */
19 #define UBERBLOCK_MAGIC 0x00bab10c /* oo-ba-bloc! */
20 struct zfs_uberblock {
21 uint64_t ub_magic; /* UBERBLOCK_MAGIC */
22 uint64_t ub_version; /* SPA_VERSION */
23 uint64_t ub_txg; /* txg of last sync */
24 uint64_t ub_guid_sum; /* sum of all vdev guids */
25 uint64_t ub_timestamp; /* UTC time of last sync */
26 /*blkptr_t ub_rootbp;*/ /* MOS objset_phys_t */
27 } __attribute__((packed));
29 static int probe_zfs(blkid_probe pr, const struct blkid_idmag *mag)
31 struct zfs_uberblock *ub;
35 ub = blkid_probe_get_sb(pr, mag, struct zfs_uberblock);
39 swab_endian = (ub->ub_magic == swab64(UBERBLOCK_MAGIC));
40 spa_version = swab_endian ? swab64(ub->ub_version) : ub->ub_version;
42 blkid_probe_sprintf_version(pr, "%" PRIu64, spa_version);
44 /* read nvpair data for pool name, pool GUID from the MOS, but
45 * unfortunately this is more complex than it could be */
46 blkid_probe_set_label(pr, pool_name, pool_len));
47 blkid_probe_set_uuid(pr, pool_guid);
52 const struct blkid_idinfo zfs_idinfo =
55 .usage = BLKID_USAGE_FILESYSTEM,
56 .probefunc = probe_zfs,
59 { .magic = "\0\0\x02\xf5\xb0\x07\xb1\x0c", .len = 8, .kboff = 8 },
60 { .magic = "\x1c\xb1\x07\xb0\xf5\x02\0\0", .len = 8, .kboff = 8 },
61 { .magic = "\0\0\x02\xf5\xb0\x07\xb1\x0c", .len = 8, .kboff = 264 },
62 { .magic = "\x0c\xb1\x07\xb0\xf5\x02\0\0", .len = 8, .kboff = 264 },