stat-util: no need to open a file to check fs type

This commit is contained in:
Lennart Poettering 2020-04-23 14:50:53 +02:00
parent 0f7e4b2888
commit 6d965610bd
1 changed files with 3 additions and 4 deletions

View 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) {