mbox series

[0/1] btrfs-progs: Implement dump-raw command

Message ID 20210228000448.41694-1-davispuh@gmail.com (mailing list archive)
Headers show
Series btrfs-progs: Implement dump-raw command | expand

Message

Dāvis Mosāns Feb. 28, 2021, 12:04 a.m. UTC
Currently there doesn't seem to be any tool to dump raw contents of a block,
so here I implemented such command.
It also shows info about block's location which is useful if there's a need
to patch block directly on disk.
It's based on dump-tree command - basically copied it with some changes.


Usage example:

$ btrfs inspect dump-raw -b 5242880 /dev/sdx | hexdump -n 64
btrfs-progs v5.10.1
block 5242880, mirror 0: reading 16384 bytes from device b0e0bb24-c654-4d79-872c-ad195bf995f1 at offset 5242880
0000000 1dbb f93d 69d7 d129 0000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 0000 0000
0000020 b993 bc9b 9fff 6e41 62ac dc4e 31e1 6adc
0000030 0000 0050 0000 0000 0001 0000 0000 0100
0000040


Can also dump corrupted block from speciific mirror

$ btrfs inspect dump-raw -b 5357568 --force -m 1 /dev/sdy | hexdump -n 64
btrfs-progs v5.10.1
block 5357568: using mirror 1 from 2 mirrors
block 5357568, mirror 1: reading 16384 bytes from device 002aa837-9fea-4b7a-9455-9be943bae1f5 at offset 5357568
checksum verify failed on 5357568 found 8242B9AD6E5A1308 wanted F1D148C22AF2D15B
0000000 d15b 2af2 48c2 f1d1 0000 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 0000 0000
0000020 af51 62c3 876d 984a 0fbc 9237 8d29 ec8d
0000030 c000 0051 0000 0000 0001 0000 0000 0100
0000040


Dāvis Mosāns (1):
  btrfs-progs: Implement dump-raw command

 Android.mk              |   3 +-
 Makefile                |   3 +-
 cmds/commands.h         |   1 +
 cmds/inspect-dump-raw.c | 341 ++++++++++++++++++++++++++++++++++++++++
 cmds/inspect.c          |   1 +
 5 files changed, 347 insertions(+), 2 deletions(-)
 create mode 100644 cmds/inspect-dump-raw.c