xfs_db: fix multiple dblock commands
PATCH 1/1 xfs_db: fix multiple dblock commands
From: Darrick J. Wong <[email protected]>
Tom Samstag reported that running the following sequence of commands no longer works quite right:
Quoted 8 lines
inode [inodenum]
dblock 0
p
dblock 1
p
dblock 2
p
[etc]
Mr. Samstag looked into the source code and discovered that the dblock_f is incorrectly accessing iocur_top->data outside of the push_cur -> set_cur_inode -> pop_cur sequence that this function uses to compute the type of the file data. In other words, it's using whatever's on top of the stack at the start of the function. For the "dblock 0" case above this is the inode, but for the "dblock 1" case this is the contents of file data block 0, not an inode.
Fix this by relocating the check to the correct place.
--- db/block.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
db/block.c +3 -1
@@ -246,6 +246,7 @@ dblock_f(int nb;xfs_extnum_t nex;char *p; +bool isrt;typnm_t type; bno = (xfs_fileoff_t )strtoull (argv[1 ], &p,0 );
@@ -255,6 +256,7 @@ dblock_f( }push_cur ();set_cur_inode (iocur_top->ino); + isrt =is_rtfile (iocur_top->data); type =inode_next_type ();pop_cur ();if (type ==TYP_NONE ) {
@@ -273,7 +275,7 @@ dblock_f(ASSERT (typtab[type].typnm == type);if (nex >1 )make_bbmap (&bbmap, nex, bmp); -if (is_rtfile (iocur_top->data)) +if (isrt)set_rt_cur (&typtab[type],xfs_rtb_to_daddr (mp, dfsbno), nb * blkbb,DB_RING_ADD , nex >1 ? &bbmap :NULL );
Looks good: