From: Eric Sandeen Date: Sun, 2 Oct 2016 23:56:00 +0000 (+1100) Subject: xfs_io: fix inode command with "-n" for bogus inode X-Git-Tag: v4.8.0-rc3~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=197069505b88b83d215662b5e62be1d89ba00d5d;p=thirdparty%2Fxfsprogs-dev.git xfs_io: fix inode command with "-n" for bogus inode If we ask for the next allocated inode after a number for which no other inode exists, the bulkstat returns success, but with count == 0. If we ignore this fact, we print a garbage result from bstat.bs_ino in this case, so fix it. Signed-off-by: Eric Sandeen Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/io/open.c b/io/open.c index 7d952a08d..8f934eedc 100644 --- a/io/open.c +++ b/io/open.c @@ -882,10 +882,16 @@ inode_f( exitcode = 1; return 0; } - } else if (ret_next) /* The next inode in use */ - result_ino = bstat.bs_ino; - else /* The inode we asked about */ + } else if (ret_next) { + /* The next inode in use, or 0 if none */ + if (*bulkreq.ocount) + result_ino = bstat.bs_ino; + else + result_ino = 0; + } else { + /* The inode we asked about */ result_ino = userino; + } } if (verbose && result_ino) {