summaryrefslogtreecommitdiff
path: root/src/basic/stat-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-23 14:50:53 +0200
committerLennart Poettering <lennart@poettering.net>2020-04-23 14:50:53 +0200
commit6d965610bde404f60c43accb12f570ab75d4195e (patch)
treee546dbdfb728f48db2203192c6eb4a50b7850639 /src/basic/stat-util.c
parent0f7e4b2888840e7e6a702aa8ce5d3e3b2bc077ef (diff)
downloadsystemd-6d965610bde404f60c43accb12f570ab75d4195e.tar.gz
stat-util: no need to open a file to check fs type
Diffstat (limited to 'src/basic/stat-util.c')
-rw-r--r--src/basic/stat-util.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c
index 5412ccbf7d..6a48af23ae 100644
--- a/src/basic/stat-util.c
+++ b/src/basic/stat-util.c
@@ -178,13 +178,12 @@ int fd_is_fs_type(int fd, statfs_f_type_t magic_value) {
}
int path_is_fs_type(const char *path, statfs_f_type_t magic_value) {
- _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_fs_type(fd, magic_value);
+ return is_fs_type(&s, magic_value);
}
bool is_temporary_fs(const struct statfs *s) {