]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: teach syncfs_path() handle with empty path argument 20166/head
authorLennart Poettering <lennart@poettering.net>
Wed, 3 Feb 2021 20:06:09 +0000 (21:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jul 2021 08:22:34 +0000 (10:22 +0200)
src/basic/fs-util.c

index 7d7beb13dcfc7a1229fbcba34100ce5754f84d62..28c7247e0526f58a46353b9ee7aef34bfc55a14a 100644 (file)
@@ -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;