From 4050625e5bf22f1a34c499c85645bf764160cde7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 3 Feb 2021 21:06:09 +0100 Subject: [PATCH] fs-util: teach syncfs_path() handle with empty path argument --- src/basic/fs-util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 7d7beb13dcf..28c7247e052 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -1527,9 +1527,13 @@ int fsync_path_and_parent_at(int at_fd, const char *path) { int syncfs_path(int atfd, const char *path) { _cleanup_close_ int fd = -1; - assert(path); + if (isempty(path)) { + if (atfd != AT_FDCWD) + return syncfs(atfd) < 0 ? -errno : 0; - fd = openat(atfd, path, O_CLOEXEC|O_RDONLY|O_NONBLOCK); + fd = open(".", O_RDONLY|O_DIRECTORY|O_CLOEXEC); + } else + fd = openat(atfd, path, O_RDONLY|O_CLOEXEC|O_NONBLOCK); if (fd < 0) return -errno;