From: Karel Zak Date: Wed, 17 Sep 2014 10:54:05 +0000 (+0200) Subject: linfdisk: cleanup fsync usage X-Git-Tag: v2.26-rc1~374 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2aeff7618e3e62b9cea594b2a23ae27b71022a35;p=thirdparty%2Futil-linux.git linfdisk: cleanup fsync usage * always use fsync() if the device open read-write * use sync() on demand Signed-off-by: Karel Zak --- diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index e156c671ec..4c353ac329 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -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);