]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add support for btrfs backup superblock
authorGoffredo Baroncelli <kreijack@inwind.it>
Wed, 9 Jan 2013 21:14:43 +0000 (22:14 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 10 Jan 2013 10:26:48 +0000 (11:26 +0100)
Btrfs has three superblock. The first one is placed at 64KB, the second one at
64MB, the third one at 256GB.

If the first superblock is valid except that the "magic field" is zeroed, btrfs
skips the check of the other superblocks.  If the first superblock is fully
invalid, btrfs checks for the other superblock.

So zeroing the first superblock "magic field" at the beginning seems that the
filesystem is wiped. But when the first superblock is overwritten (eg by
another filesystem), then the other two superblock may be considered valid, and
the filesystem may resurrect.

This patch allow to find and wipe the other btrfs superblocks signature.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/btrfs.c

index 039be42c35ba91b84eded634a77c3ee9d1230447..1bd1df9ee5bb4da90f9ba3c39f8525bc76a67a81 100644 (file)
@@ -87,6 +87,14 @@ const struct blkid_idinfo btrfs_idinfo =
        .magics         =
        {
                { .magic = "_BHRfS_M", .len = 8, .kboff = 64, .sboff = 0x40 },
+               { .magic = "_BHRfS_M",
+                 .len = 8,
+                 .kboff = 64 * 1024,
+                 .sboff = 0x40 },
+               { .magic = "_BHRfS_M",
+                 .len = 8,
+                 .kboff = 256 * 1024 * 1024,
+                 .sboff = 0x40 },
                { NULL }
        }
 };