diff options
author | Karel Zak | 2014-09-17 12:54:05 +0200 |
---|---|---|
committer | Karel Zak | 2014-10-07 14:55:32 +0200 |
commit | 2aeff7618e3e62b9cea594b2a23ae27b71022a35 (patch) | |
tree | 289b13e4481c2688341119607a4e4ec84c527e1c /libfdisk/src/context.c | |
parent | sfdisk: use fdisk_set_partition_type() (diff) | |
download | kernel-qcow2-util-linux-2aeff7618e3e62b9cea594b2a23ae27b71022a35.tar.gz kernel-qcow2-util-linux-2aeff7618e3e62b9cea594b2a23ae27b71022a35.tar.xz kernel-qcow2-util-linux-2aeff7618e3e62b9cea594b2a23ae27b71022a35.zip |
linfdisk: cleanup fsync usage
* always use fsync() if the device open read-write
* use sync() on demand
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index e156c671e..4c353ac32 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); |