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);
|
||||||
assert(cxt->dev_fd >= 0);
|
assert(cxt->dev_fd >= 0);
|
||||||
|
|
||||||
if (cxt->readonly || nosync)
|
if (cxt->readonly)
|
||||||
close(cxt->dev_fd);
|
close(cxt->dev_fd);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if (fsync(cxt->dev_fd) || close(cxt->dev_fd)) {
|
if (fsync(cxt->dev_fd) || close(cxt->dev_fd)) {
|
||||||
fdisk_warn(cxt, _("%s: close device failed"),
|
fdisk_warn(cxt, _("%s: close device failed"),
|
||||||
|
@ -465,8 +464,10 @@ int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdisk_info(cxt, _("Syncing disks."));
|
if (!nosync) {
|
||||||
sync();
|
fdisk_info(cxt, _("Syncing disks."));
|
||||||
|
sync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(cxt->dev_path);
|
free(cxt->dev_path);
|
||||||
|
|
Loading…
Reference in New Issue