filefrag: Fix error checking for the fiemap ioctl

Thanks to Peng Tao for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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 @@
 		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;