From d4a276491269b6502c15e0089fba6b616f5c5df8 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Wed, 9 Jan 2013 22:14:43 +0100 Subject: [PATCH] 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 --- libblkid/src/superblocks/btrfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libblkid/src/superblocks/btrfs.c b/libblkid/src/superblocks/btrfs.c index 039be42..1bd1df9 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 } } }; -- 1.7.11.7