]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
linfdisk: cleanup fsync usage
authorKarel Zak <kzak@redhat.com>
Wed, 17 Sep 2014 10:54:05 +0000 (12:54 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 12:55:32 +0000 (14:55 +0200)
 * always use fsync() if the device open read-write
 * use sync() on demand

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/context.c

index e156c671ec11e1c2a987e7a12c09123f8ec85da2..4c353ac329936242b1c68e02a488f1d14c24923b 100644 (file)
@@ -455,9 +455,8 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
        assert(cxt);
        assert(cxt->dev_fd >= 0);
 
-       if (cxt->readonly || nosync)
+       if (cxt->readonly)
                close(cxt->dev_fd);
-
        else {
                if (fsync(cxt->dev_fd) || close(cxt->dev_fd)) {
                        fdisk_warn(cxt, _("%s: close device failed"),
@@ -465,8 +464,10 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
                        return -errno;
                }
 
-               fdisk_info(cxt, _("Syncing disks."));
-               sync();
+               if (!nosync) {
+                       fdisk_info(cxt, _("Syncing disks."));
+                       sync();
+               }
        }
 
        free(cxt->dev_path);