summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-01-23 16:08:55 +0100
committerLennart Poettering <lennart@poettering.net>2019-03-01 12:41:32 +0100
commit71f514169b14e2bd67e9465f132bae502b51af98 (patch)
treecc1acf6d8d21fc59c63d64e4893c22cf627b1a7a /src
parent57d2db22de705dec0f03d7d4d2f27171a935701d (diff)
downloadsystemd-71f514169b14e2bd67e9465f132bae502b51af98.tar.gz
fs-util: add new helper syncfs_path()
Diffstat (limited to 'src')
-rw-r--r--src/basic/fs-util.c15
-rw-r--r--src/basic/fs-util.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index 3ff8615797..0d631093b2 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -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;
diff --git a/src/basic/fs-util.h b/src/basic/fs-util.h
index 7ad030be5d..9c9044669d 100644
--- a/src/basic/fs-util.h
+++ b/src/basic/fs-util.h
@@ -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);