diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-01-06 18:05:56 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-02 17:34:53 +0100 |
commit | 48acd75827066852820da105e4b895afbf7e99c1 (patch) | |
tree | a4e22a1325ee2f02e1aacbab4deafaa50ff6a1c3 | |
parent | 7d3e6e7b7220f9298eed8d1f38b66c269dfa068c (diff) | |
download | systemd-48acd75827066852820da105e4b895afbf7e99c1.tar.gz |
stat-util: don't try to open path on path_is_temporary_fs()
I mean, the old code at least used O_PATH, but still, we shouldn't
allocate/close an fd if we don't have to.
(cherry picked from commit 15308e5083391f6a1b9ce25c5b7323f37544eab8)
(cherry picked from commit a2f0da2de006c74bca64b3ce5b023e99bcca4498)
-rw-r--r-- | src/basic/stat-util.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index 904584a985..77e042ccaf 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -225,13 +225,12 @@ int fd_is_network_fs(int fd) { } int path_is_temporary_fs(const char *path) { - _cleanup_close_ int fd = -1; + struct statfs s; - fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_PATH); - if (fd < 0) + if (statfs(path, &s) < 0) return -errno; - return fd_is_temporary_fs(fd); + return is_temporary_fs(&s); } int stat_verify_regular(const struct stat *st) { |