basic: use filesystem database
This commit is contained in:
committed by
Iago Lopez Galeiras
parent
1315ce3120
commit
659d19243c
@@ -375,6 +375,34 @@ run_target(
|
||||
|
||||
############################################################
|
||||
|
||||
filesystem_includes = ['linux/magic.h',
|
||||
'linux/gfs2_ondisk.h']
|
||||
|
||||
check_filesystems = find_program('check-filesystems.sh')
|
||||
r = run_command([check_filesystems, cpp, 'filesystems-gperf.gperf'] + filesystem_includes)
|
||||
if r.returncode() != 0
|
||||
error('found unknown filesystem(s) defined in kernel headers:\n\n' + r.stdout())
|
||||
r.stdout()
|
||||
endif
|
||||
|
||||
filesystems_gperf_h = custom_target(
|
||||
'filesystems-gperf.h',
|
||||
input : 'filesystems-gperf.gperf',
|
||||
output : 'filesystems-gperf.h',
|
||||
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
|
||||
|
||||
generate_filesystem_list = find_program('generate-filesystem-list.py')
|
||||
fname = 'filesystem-list.h'
|
||||
filesystem_list_h = custom_target(
|
||||
fname,
|
||||
input : 'filesystems-gperf.gperf',
|
||||
output : fname,
|
||||
command : [generate_filesystem_list,
|
||||
'@INPUT@'],
|
||||
capture : true)
|
||||
|
||||
basic_sources += [filesystem_list_h, filesystems_gperf_h]
|
||||
|
||||
libbasic = static_library(
|
||||
'basic',
|
||||
basic_sources,
|
||||
|
||||
+20
-32
@@ -8,11 +8,13 @@
|
||||
#include "chase-symlinks.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "filesystems.h"
|
||||
#include "fs-util.h"
|
||||
#include "missing_stat.h"
|
||||
#include "missing_syscall.h"
|
||||
#include "mkdir.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
#include "stat-util.h"
|
||||
@@ -366,48 +368,34 @@ bool fstype_is_network(const char *fstype) {
|
||||
if (x)
|
||||
fstype = x;
|
||||
|
||||
if (nulstr_contains(filesystem_sets[FILESYSTEM_SET_NETWORK].value, fstype))
|
||||
return true;
|
||||
|
||||
/* Filesystems not present in the internal database */
|
||||
return STR_IN_SET(fstype,
|
||||
"afs",
|
||||
"ceph",
|
||||
"cifs",
|
||||
"smb3",
|
||||
"smbfs",
|
||||
"sshfs",
|
||||
"ncpfs",
|
||||
"ncp",
|
||||
"nfs",
|
||||
"nfs4",
|
||||
"gfs",
|
||||
"gfs2",
|
||||
"davfs",
|
||||
"glusterfs",
|
||||
"pvfs2", /* OrangeFS */
|
||||
"ocfs2",
|
||||
"lustre",
|
||||
"davfs");
|
||||
"sshfs");
|
||||
}
|
||||
|
||||
bool fstype_is_api_vfs(const char *fstype) {
|
||||
const FilesystemSet *fs;
|
||||
|
||||
FOREACH_POINTER(fs,
|
||||
filesystem_sets + FILESYSTEM_SET_BASIC_API,
|
||||
filesystem_sets + FILESYSTEM_SET_AUXILIARY_API,
|
||||
filesystem_sets + FILESYSTEM_SET_PRIVILEGED_API,
|
||||
filesystem_sets + FILESYSTEM_SET_TEMPORARY)
|
||||
if (nulstr_contains(fs->value, fstype))
|
||||
return true;
|
||||
|
||||
/* Filesystems not present in the internal database */
|
||||
return STR_IN_SET(fstype,
|
||||
"autofs",
|
||||
"bpf",
|
||||
"cgroup",
|
||||
"cgroup2",
|
||||
"configfs",
|
||||
"cpuset",
|
||||
"debugfs",
|
||||
"devpts",
|
||||
"devtmpfs",
|
||||
"efivarfs",
|
||||
"fusectl",
|
||||
"hugetlbfs",
|
||||
"mqueue",
|
||||
"proc",
|
||||
"pstore",
|
||||
"ramfs",
|
||||
"securityfs",
|
||||
"sysfs",
|
||||
"tmpfs",
|
||||
"tracefs");
|
||||
"devtmpfs");
|
||||
}
|
||||
|
||||
bool fstype_is_blockdev_backed(const char *fstype) {
|
||||
|
||||
+5
-10
@@ -13,10 +13,13 @@
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "filesystems.h"
|
||||
#include "fs-util.h"
|
||||
#include "macro.h"
|
||||
#include "missing_fs.h"
|
||||
#include "missing_magic.h"
|
||||
#include "missing_syscall.h"
|
||||
#include "nulstr-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "stat-util.h"
|
||||
#include "string-util.h"
|
||||
@@ -198,19 +201,11 @@ int path_is_fs_type(const char *path, statfs_f_type_t magic_value) {
|
||||
}
|
||||
|
||||
bool is_temporary_fs(const struct statfs *s) {
|
||||
return is_fs_type(s, TMPFS_MAGIC) ||
|
||||
is_fs_type(s, RAMFS_MAGIC);
|
||||
return fs_in_group(s, FILESYSTEM_SET_TEMPORARY);
|
||||
}
|
||||
|
||||
bool is_network_fs(const struct statfs *s) {
|
||||
return is_fs_type(s, CIFS_MAGIC_NUMBER) ||
|
||||
is_fs_type(s, CODA_SUPER_MAGIC) ||
|
||||
is_fs_type(s, NCP_SUPER_MAGIC) ||
|
||||
is_fs_type(s, NFS_SUPER_MAGIC) ||
|
||||
is_fs_type(s, SMB_SUPER_MAGIC) ||
|
||||
is_fs_type(s, V9FS_MAGIC) ||
|
||||
is_fs_type(s, AFS_SUPER_MAGIC) ||
|
||||
is_fs_type(s, OCFS2_SUPER_MAGIC);
|
||||
return fs_in_group(s, FILESYSTEM_SET_NETWORK);
|
||||
}
|
||||
|
||||
int fd_is_temporary_fs(int fd) {
|
||||
|
||||
Reference in New Issue
Block a user