summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-09-17 12:54:05 +0200
committerKarel Zak <kzak@redhat.com>2014-10-24 11:10:06 +0200
commit007fd134835e3f3cec8144e9b76949b6db296579 (patch)
treeda108d4199c9fd618d70fa5be8ab194579e3ea77
parent0e0003fde09408d2853d2018cec309ec35269fa5 (diff)
downloadutil-linux-007fd134835e3f3cec8144e9b76949b6db296579.tar.gz
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>
-rw-r--r--libfdisk/src/context.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 61a6ce30a..6f9b4cfc1 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -299,9 +299,8 @@ int fdisk_context_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"),
@@ -309,8 +308,10 @@ int fdisk_context_deassign_device(struct fdisk_context *cxt, int nosync)
return -errno;
}
- fdisk_info(cxt, _("Syncing disks."));
- sync();
+ if (!nosync) {
+ fdisk_info(cxt, _("Syncing disks."));
+ sync();
+ }
}
cxt->dev_fd = -1;
return 0;