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>
This commit is contained in:
parent
2e73a998f4
commit
2aeff7618e
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue