From: Darrick J. Wong <djwong@xxxxxxxxxx> Ted noticed that the following command: $ xfs_io -c 'fsmap -d 0 0' /mnt xfs_io: xfsctl(XFS_IOC_GETFSMAP) iflags=0x0 ["/mnt"]: Invalid argument doesn't work on an ext4 filesystem. The above command is supposed to issue a GETFSMAP query against the "data" device. Although the manpage doesn't claim support for ext4, it turns out that this you get this trace data: xfs_io-4144 [002] 210.965642: ext4_getfsmap_low_key: dev 7:0 keydev 163:2567 block 0 len 0 owner 0 flags 0x0 xfs_io-4144 [002] 210.965645: ext4_getfsmap_high_key: dev 7:0 keydev 32:5277:0 block 0 len 0 owner -1 flags 0xffffffff Notice the random garbage in the keydev field -- this happens because openfile (in xfs_io) doesn't initialize *fs_path if the caller doesn't supply a geometry structure or the opened file isn't on an XFS filesystem. IOWs, we feed random heap garbage to the kernel, and the kernel rejects the call unnecessarily. Fix this to set the fspath information even for foreign filesystems. Reported-by: tytso@xxxxxxx Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- io/open.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/io/open.c b/io/open.c index d8072664c16..15850b5557b 100644 --- a/io/open.c +++ b/io/open.c @@ -116,7 +116,7 @@ openfile( } if (!geom || !platform_test_xfs_fd(fd)) - return fd; + goto set_fspath; if (flags & IO_PATH) { /* Can't call ioctl() on O_PATH fds */ @@ -150,6 +150,7 @@ openfile( } } +set_fspath: if (fs_path) { fsp = fs_table_lookup(path, FS_MOUNT_POINT); if (!fsp)