Whamcloud - gitweb
filefrag: Fix error checking for the fiemap ioctl
authorTheodore Ts'o <tytso@mit.edu>
Tue, 2 Jun 2009 12:45:22 +0000 (08:45 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 2 Jun 2009 12:45:22 +0000 (08:45 -0400)
Thanks to Peng Tao for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/filefrag.c

index 80ac05c..7095949 100644 (file)
@@ -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;