]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stat-util: no need to open a file to check fs type
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 12:50:53 +0000 (14:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 12:50:53 +0000 (14:50 +0200)
src/basic/stat-util.c

index 5412ccbf7df978cc2de5f563e01aef3ef64518be..6a48af23ae6c9e6a35f51e86483d2c6d451328c9 100644 (file)
@@ -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) {