]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: fix ZFS superblok offset for SBMAGIC
authorKarel Zak <kzak@redhat.com>
Wed, 10 Apr 2013 13:13:02 +0000 (15:13 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 10 Apr 2013 13:13:02 +0000 (15:13 +0200)
 # wipefs /dev/sdd1

 offset               type
 ----------------------------------------------------------------
 0x65000              zfs_member   [raid]
                      LABEL: zm1
                      UUID:  18067835215330778964

 and "wipefs -o 0x65000 /dev/sdd1" seems to run in an endless loop.

Reported-by: Helmut Hullen <Hullen@t-online.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/zfs.c

index 04036c471ce0541d5967aaf7472055e1c82c3118..fb86aec77dec9c63e12e9344ab3745c725c71442 100644 (file)
@@ -168,7 +168,7 @@ static int probe_zfs(blkid_probe pr,
        uint64_t swab_magic = swab64(UBERBLOCK_MAGIC);
        struct zfs_uberblock *ub;
        int swab_endian;
-       loff_t offset;
+       loff_t offset, ub_offset;
        int tried;
        int found;
 
@@ -187,11 +187,15 @@ static int probe_zfs(blkid_probe pr,
                if (ub == NULL)
                        return -1;
 
-               if (ub->ub_magic == UBERBLOCK_MAGIC)
+               if (ub->ub_magic == UBERBLOCK_MAGIC) {
+                       ub_offset = offset;
                        found++;
+               }
 
-               if ((swab_endian = (ub->ub_magic == swab_magic)))
+               if ((swab_endian = (ub->ub_magic == swab_magic))) {
+                       ub_offset = offset;
                        found++;
+               }
 
                zdebug("probe_zfs: found %s-endian uberblock at %llu\n",
                       swab_endian ? "big" : "little", offset >> 10);
@@ -207,7 +211,7 @@ static int probe_zfs(blkid_probe pr,
 
        zfs_extract_guid_name(pr, offset);
 
-       if (blkid_probe_set_magic(pr, offset,
+       if (blkid_probe_set_magic(pr, ub_offset,
                                sizeof(ub->ub_magic),
                                (unsigned char *) &ub->ub_magic))
                return -1;