fs-util: add new helper syncfs_path()
This commit is contained in:
parent
57d2db22de
commit
71f514169b
|
@ -1330,6 +1330,21 @@ int fsync_path_at(int at_fd, const char *path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int syncfs_path(int atfd, const char *path) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
|
||||
assert(path);
|
||||
|
||||
fd = openat(atfd, path, O_CLOEXEC|O_RDONLY|O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (syncfs(fd) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int open_parent(const char *path, int flags, mode_t mode) {
|
||||
_cleanup_free_ char *parent = NULL;
|
||||
int fd;
|
||||
|
|
|
@ -108,4 +108,6 @@ int unlinkat_deallocate(int fd, const char *name, int flags);
|
|||
int fsync_directory_of_file(int fd);
|
||||
int fsync_path_at(int at_fd, const char *path);
|
||||
|
||||
int syncfs_path(int atfd, const char *path);
|
||||
|
||||
int open_parent(const char *path, int flags, mode_t mode);
|
||||
|
|
Loading…
Reference in New Issue