[PATCH] xfs_mdrestore: initialize sb prior to xfs_sb_from_disk()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we xfs_mdrestore an image from a non-crc filesystem, lo
and behold the restored image has gained a CRC:

# db/xfs_metadump.sh -o /dev/sdc1 - | xfs_mdrestore - test.img
# xfs_db -c "sb 0" -c "p crc" /dev/sdc1
crc = 0 (correct)
# xfs_db -c "sb 0" -c "p crc" test.img
crc = 0xb6f8d6a0 (correct)

Obviously it can't really be correct :)

The problem is, xfs_sb_from_disk doesn't fill in the sb_crc
field.

An earlier commit:

  47de6e1 repair: ensure that unused superblock fields are zeroed

fixed this same sort of problem for xfs_repair.  Do the same
for mdrestore.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

But ... should we maybe just do this once and for all in
xfs_sb_from_disk?  I'm not sure leaving it up to every
caller is a good idea, unless somebody ahs a reason to
pre-populate some fields - I can't imagine why that would
be, though...

diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index e57bdb2..0453f17 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -104,6 +104,7 @@ perform_restore(
 			1, src_f) != 1)
 		fatal("error reading from file: %s\n", strerror(errno));
 
+	memset(&sb, 0, sizeof(struct xfs_sb));
 	libxfs_sb_from_disk(&sb, (xfs_dsb_t *)block_buffer);
 
 	if (sb.sb_magicnum != XFS_SB_MAGIC)

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux