Whamcloud - gitweb
ext2fs: check if Lustre filesystem is mounted
[tools/e2fsprogs.git] / lib / ext2fs / flushb.c
index fe1d3e7..bb7daf4 100644 (file)
@@ -64,18 +64,25 @@ errcode_t ext2fs_sync_device(int fd, int flushb)
 #endif
 
        if (flushb) {
+               errcode_t       retval = 0;
 
 #ifdef BLKFLSBUF
                if (ioctl (fd, BLKFLSBUF, 0) == 0)
                        return 0;
+               retval = errno;
 #elif defined(__linux__)
 #warning BLKFLSBUF not defined
 #endif
 #ifdef FDFLUSH
-               return ioctl(fd, FDFLUSH, 0);   /* In case this is a floppy */
+               /* In case this is a floppy */
+               if (ioctl(fd, FDFLUSH, 0) == 0)
+                       return 0;
+               if (retval == 0)
+                       retval = errno;
 #elif defined(__linux__)
 #warning FDFLUSH not defined
 #endif
+               return retval;
        }
        return 0;
 }