]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: don't hardcode 'type data' size at 512b
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 22:04:31 +0000 (14:04 -0800)
committerCarlos Maiolino <cem@kernel.org>
Tue, 12 Mar 2024 14:36:32 +0000 (15:36 +0100)
On a disk with 4096-byte LBAs, the xfs_db 'type data' subcommand doesn't
work:

# xfs_io -c 'sb' -c 'type data' /dev/sda
xfs_db: read failed: Invalid argument
no current object

The cause of this is the hardcoded initialization of bb_count when we're
setting type data -- it should be the filesystem sector size, not just 1.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
db/block.c
db/io.c

index d730c77967103af1dbf6bded0d8e0a921b7713d0..22930e5a287e8f9148d15c7efe8420470456c18d 100644 (file)
@@ -124,6 +124,7 @@ daddr_f(
 {
        int64_t         d;
        char            *p;
+       int             bb_count = BTOBB(mp->m_sb.sb_sectsize);
 
        if (argc == 1) {
                xfs_daddr_t     daddr = iocur_top->off >> BBSHIFT;
@@ -144,7 +145,7 @@ daddr_f(
                return 0;
        }
        ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
-       set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+       set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
        return 0;
 }
 
diff --git a/db/io.c b/db/io.c
index 590dd1f82f7bc7f8331e41ba08a5b8eee7e323fd..9b2c6b4cf7e963f0be75670080044a7e1dfd8fe4 100644 (file)
--- a/db/io.c
+++ b/db/io.c
@@ -652,7 +652,8 @@ void
 set_iocur_type(
        const typ_t     *type)
 {
-       int             bb_count = 1;   /* type's size in basic blocks */
+       /* type's size in basic blocks */
+       int             bb_count = BTOBB(mp->m_sb.sb_sectsize);
        int             boff = iocur_top->boff;
 
        /*