From: Goffredo Baroncelli Date: Wed, 9 Jan 2013 21:14:43 +0000 (+0100) Subject: libblkid: add support for btrfs backup superblock X-Git-Tag: v2.23-rc1~364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4a276491269b6502c15e0089fba6b616f5c5df8;p=thirdparty%2Futil-linux.git libblkid: add support for btrfs backup superblock 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 --- diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c index 039be42c35..1bd1df9ee5 100644 --- a/libblkid/src/superblocks/btrfs.c +++ b/libblkid/src/superblocks/btrfs.c @@ -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 } } };