1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

fs-util: add fsync_path_and_parent_at()

This commit is contained in:
Lennart Poettering 2021-02-03 20:53:32 +01:00
parent 814a7e0345
commit 32a3041656
2 changed files with 17 additions and 0 deletions

View File

@ -1508,6 +1508,22 @@ int fsync_parent_at(int at_fd, const char *path) {
return fsync_directory_of_file(opened_fd);
}
int fsync_path_and_parent_at(int at_fd, const char *path) {
_cleanup_close_ int opened_fd = -1;
if (isempty(path)) {
if (at_fd != AT_FDCWD)
return fsync_full(at_fd);
opened_fd = open(".", O_RDONLY|O_DIRECTORY|O_CLOEXEC);
} else
opened_fd = openat(at_fd, path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC);
if (opened_fd < 0)
return -errno;
return fsync_full(opened_fd);
}
int syncfs_path(int atfd, const char *path) {
_cleanup_close_ int fd = -1;

View File

@ -141,6 +141,7 @@ int fsync_directory_of_file(int fd);
int fsync_full(int fd);
int fsync_path_at(int at_fd, const char *path);
int fsync_parent_at(int at_fd, const char *path);
int fsync_path_and_parent_at(int at_fd, const char *path);
int syncfs_path(int atfd, const char *path);