From: Lennart Poettering Date: Wed, 3 Feb 2021 20:06:09 +0000 (+0100) Subject: fs-util: teach syncfs_path() handle with empty path argument X-Git-Tag: v250-rc1~971^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F20166%2Fhead;p=thirdparty%2Fsystemd.git fs-util: teach syncfs_path() handle with empty path argument --- 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;