1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include "nulstr-util.h"
5 #include "stat-util.h"
6 #include "string-util.h"
7 
8 #define FILESYSTEM_MAGIC_MAX 10
9 
10 typedef enum FilesystemGroups {
11         /* Please leave BASIC_API first and KNOWN last, but sort the rest alphabetically */
12         FILESYSTEM_SET_BASIC_API,
13         FILESYSTEM_SET_ANONYMOUS,
14         FILESYSTEM_SET_APPLICATION,
15         FILESYSTEM_SET_AUXILIARY_API,
16         FILESYSTEM_SET_COMMON_BLOCK,
17         FILESYSTEM_SET_HISTORICAL_BLOCK,
18         FILESYSTEM_SET_NETWORK,
19         FILESYSTEM_SET_PRIVILEGED_API,
20         FILESYSTEM_SET_SECURITY,
21         FILESYSTEM_SET_TEMPORARY,
22         FILESYSTEM_SET_KNOWN,
23         _FILESYSTEM_SET_MAX,
24         _FILESYSTEM_SET_INVALID = -EINVAL,
25 } FilesystemGroups;
26 
27 typedef struct FilesystemSet {
28         const char *name;
29         const char *help;
30         const char *value;
31 } FilesystemSet;
32 
33 extern const FilesystemSet filesystem_sets[];
34 
35 const FilesystemSet *filesystem_set_find(const char *name);
36 
37 const char *fs_type_to_string(statfs_f_type_t magic);
38 int fs_type_from_string(const char *name, const statfs_f_type_t **ret);
39 int fs_in_group(const struct statfs *s, enum FilesystemGroups fs_group);
40 
41 /* gperf prototypes */
42 const struct FilesystemMagic* filesystems_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
43