1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include "filesystems-gperf.h"
6 const char *fs_type_to_string(statfs_f_type_t magic
) {
9 #include "filesystem-switch-case.h"
16 int fs_type_from_string(const char *name
, const statfs_f_type_t
**ret
) {
17 const struct FilesystemMagic
*fs_magic
;
22 fs_magic
= filesystems_gperf_lookup(name
, strlen(name
));
26 *ret
= fs_magic
->magic
;
30 bool fs_in_group(const struct statfs
*s
, FilesystemGroups fs_group
) {
33 NULSTR_FOREACH(fs
, filesystem_sets
[fs_group
].value
) {
34 const statfs_f_type_t
*magic
;
36 r
= fs_type_from_string(fs
, &magic
);
38 for (size_t i
= 0; i
< FILESYSTEM_MAGIC_MAX
; i
++) {
42 if (is_fs_type(s
, magic
[i
]))
50 const FilesystemSet filesystem_sets
[_FILESYSTEM_SET_MAX
] = {
51 [FILESYSTEM_SET_BASIC_API
] = {
53 .help
= "Basic filesystem API",
63 [FILESYSTEM_SET_ANONYMOUS
] = {
65 .help
= "Anonymous inodes",
71 [FILESYSTEM_SET_APPLICATION
] = {
72 .name
= "@application",
73 .help
= "Application virtual filesystems",
79 [FILESYSTEM_SET_AUXILIARY_API
] = {
80 .name
= "@auxiliary-api",
81 .help
= "Auxiliary filesystem API",
91 [FILESYSTEM_SET_COMMON_BLOCK
] = {
92 .name
= "@common-block",
93 .help
= "Common block device filesystems",
107 [FILESYSTEM_SET_HISTORICAL_BLOCK
] = {
108 .name
= "@historical-block",
109 .help
= "Historical block device filesystems",
115 [FILESYSTEM_SET_NETWORK
] = {
117 .help
= "Well-known network filesystems",
134 [FILESYSTEM_SET_PRIVILEGED_API
] = {
135 .name
= "@privileged-api",
136 .help
= "Privileged filesystem API",
143 [FILESYSTEM_SET_SECURITY
] = {
145 .help
= "Security/MAC API VFS",
151 [FILESYSTEM_SET_TEMPORARY
] = {
152 .name
= "@temporary",
153 .help
= "Temporary filesystems",
158 [FILESYSTEM_SET_KNOWN
] = {
160 .help
= "All known filesystems declared in the kernel",
162 #include "filesystem-list.h"
166 const FilesystemSet
*filesystem_set_find(const char *name
) {
167 if (isempty(name
) || name
[0] != '@')
170 for (FilesystemGroups i
= 0; i
< _FILESYSTEM_SET_MAX
; i
++)
171 if (streq(filesystem_sets
[i
].name
, name
))
172 return filesystem_sets
+ i
;