1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-14 05:57:40 +03:00

loop-util: define API for syncing loopback device

This commit is contained in:
Lennart Poettering 2020-07-30 18:48:52 +02:00
parent 0de3c4f4b7
commit 8dbc208cc1
2 changed files with 16 additions and 0 deletions

View File

@ -472,3 +472,18 @@ int loop_device_flock(LoopDevice *d, int operation) {
return 0;
}
int loop_device_sync(LoopDevice *d) {
assert(d);
/* We also do this implicitly in loop_device_unref(). Doing this explicitly here has the benefit that
* we can check the return value though. */
if (d->fd < 0)
return -EBADF;
if (fsync(d->fd) < 0)
return -errno;
return 0;
}

View File

@ -26,3 +26,4 @@ void loop_device_relinquish(LoopDevice *d);
int loop_device_refresh_size(LoopDevice *d, uint64_t offset, uint64_t size);
int loop_device_flock(LoopDevice *d, int operation);
int loop_device_sync(LoopDevice *d);