From e78968f7a42fb1fa75c356dd323d957b307b887f Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 2 Jun 2009 08:45:22 -0400 Subject: [PATCH] filefrag: Fix error checking for the fiemap ioctl Thanks to Peng Tao for reporting this problem. Signed-off-by: "Theodore Ts'o" --- misc/filefrag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/misc/filefrag.c b/misc/filefrag.c index 80ac05c..7095949 100644 --- a/misc/filefrag.c +++ b/misc/filefrag.c @@ -201,15 +201,14 @@ int filefrag_fiemap(int fd, int blk_shift, int *num_extents) fiemap->fm_flags = flags; fiemap->fm_extent_count = count; rc = ioctl(fd, FS_IOC_FIEMAP, (unsigned long) fiemap); - if (rc == -EBADR) { - if (fiemap_incompat_printed == 0) { + if (rc < 0) { + if (errno == EBADR && fiemap_incompat_printed == 0) { printf("FIEMAP failed with unsupported " "flags %x\n", fiemap->fm_flags); fiemap_incompat_printed = 1; } - } - if (rc) return rc; + } if (!verbose) { *num_extents = fiemap->fm_mapped_extents; -- 1.8.3.1