From: Dave Chinner Date: Fri, 7 Jun 2013 00:26:04 +0000 (+1000) Subject: xfs_mdrestore: recalculate sb CRC before writing X-Git-Tag: v3.2.0-alpha1~91 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3ece21152f91c905edd90e2565de0181f747b60;p=thirdparty%2Fxfsprogs-dev.git xfs_mdrestore: recalculate sb CRC before writing xfs_mdrestore writes the superblock after modifying it, and so the CRC is not necessarily correct. Make sure the CRC is correct before we write the superblock back. Signed-off-by: Dave Chinner Reviewed-by: Ben Myers Signed-off-by: Ben Myers --- diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c index 479e677db..e57bdb210 100644 --- a/mdrestore/xfs_mdrestore.c +++ b/mdrestore/xfs_mdrestore.c @@ -169,6 +169,11 @@ perform_restore( memset(block_buffer, 0, sb.sb_sectsize); sb.sb_inprogress = 0; libxfs_sb_to_disk((xfs_dsb_t *)block_buffer, &sb, XFS_SB_ALL_BITS); + if (xfs_sb_version_hascrc(&sb)) { + xfs_update_cksum(block_buffer, sb.sb_sectsize, + offsetof(struct xfs_sb, sb_crc)); + } + if (pwrite(dst_fd, block_buffer, sb.sb_sectsize, 0) < 0) fatal("error writing primary superblock: %s\n", strerror(errno));