* always use fsync() if the device open read-write
* use sync() on demand
Signed-off-by: Karel Zak <kzak@redhat.com>
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"),
return -errno;
}
- fdisk_info(cxt, _("Syncing disks."));
- sync();
+ if (!nosync) {
+ fdisk_info(cxt, _("Syncing disks."));
+ sync();
+ }
}
free(cxt->dev_path);