]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commit
xfs_db: make flist_find_ftyp() to check for field existance on disk
authorAndrey Albershteyn <aalbersh@redhat.com>
Wed, 8 Feb 2023 11:02:22 +0000 (12:02 +0100)
committerCarlos Maiolino <cem@kernel.org>
Fri, 24 Feb 2023 14:08:39 +0000 (15:08 +0100)
commita0d79cb37a36f44507038100f7ea1d8706e02f63
tree7449408435bac961bca447aa033f3d93204876c1
parentb1faed5f7875a69d475d64942d74456079fc178d
xfs_db: make flist_find_ftyp() to check for field existance on disk

flist_find_ftyp() searches for the field of the requested type. The
first found field/path is returned. However, this doesn't work when
there are multiple fields of the same type. For example, attr3 type
have a few CRC fields. Leaf block (xfs_attr_leaf_hdr ->
xfs_da3_blkinfo) and remote value block (xfs_attr3_rmt_hdr) both
have CRC but goes under attr3 type. This causes 'crc' command to be
unable to find CRC field when we are at remote attribute block as it
tries to use leaf block CRC path:

$ dd if=/dev/zero bs=4k count=10 | tr '\000' '1' > test.img
$ touch test.file
$ setfattr -n user.bigattr -v "$(cat test.img)" test.file

$ # CRC of the leaf block
$ xfs_db -r -x /dev/sda5 -c 'inode 132' -c 'ablock 0' -c 'crc'
Verifying CRC:
hdr.info.crc = 0x102b5cbf (correct)

$ # CRC of the remote value block
$ xfs_db -r -x /dev/sda5 -c 'inode 132' -c 'ablock 1' -c 'crc'
field info not found
parsing error

Solve this by making flist_find_ftyp() to also check that field in
question have non-zero count (exist at the current block).

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
db/crc.c
db/flist.c
db/flist.h