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

fs-util: teach syncfs_path() handle with empty path argument

This commit is contained in:
Lennart Poettering 2021-02-03 21:06:09 +01:00
parent 32a3041656
commit 4050625e5b

View 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;