]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_db: allow recalculating CRCs on invalid metadata
authorDave Chinner <dchinner@redhat.com>
Mon, 30 May 2016 00:32:41 +0000 (10:32 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 30 May 2016 00:32:41 +0000 (10:32 +1000)
commit86769b32d01827daeda160ebcfbf814a49a4ef74
treeea4ab9b26c8b52ab1645fd83d8169aa171f54bfd
parentc5d584c06b52b5d30f4fa2904d9d6f9297b56862
xfs_db: allow recalculating CRCs on invalid metadata

Currently we can't write corrupt structures with valid CRCs on v5
filesystems via xfs_db. TO emulate certain types of corruption
result from software bugs in the kernel code, we need this
capability to set up the corrupted state. i.e. corrupt state with a
valid CRC needs to appear on disk.

This requires us to avoid running the verifier that would otherwise
prevent writing corrupt state to disk. To enable this, add the CRC
offset to the type table for different buffers and add a new flag to
the write command to trigger running a CRC calculation base don this
type table. We can then insert the calculated value into the correct
location in the buffer...

Because some objects are not directly buffer based, we can't easily
do this CRC trick. Those object types will be marked as
TYP_NO_CRC_OFF, and as a result will emit an error such as:

# xfs_db -x -c "inode 96" -c "write -d magic 0x4949" /dev/ram0
Cannot recalculate CRCs on this type of object
#

All v4 superblock types are configured this way, as are inode,
dquots and other v5 metadata types that either don't have CRCs or
don't have a fixed offset into a buffer to store their CRC.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/io.c
db/io.h
db/type.c
db/type.h
db/write.c