| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
|
| 3 |
#include "filesystems-gperf.h" |
| 4 |
#include "stat-util.h" |
| 5 |
#include "string-util.h" |
| 6 |
|
| 7 |
int fs_type_from_string(const char *name, const statfs_f_type_t **ret) { |
| 8 |
const struct FilesystemMagic *fs_magic; |
| 9 |
|
| 10 |
assert(name); |
| 11 |
assert(ret); |
| 12 |
|
| 13 |
fs_magic = filesystems_gperf_lookup(name, strlen(name)); |
| 14 |
if (!fs_magic) |
| 15 |
return -EINVAL; |
| 16 |
|
| 17 |
*ret = fs_magic->magic; |
| 18 |
return 0; |
| 19 |
} |
| 20 |
|
| 21 |
const FilesystemSet* filesystem_set_find(const char *name) { |
| 22 |
if (isempty(name) || name[0] != '@') |
| 23 |
return NULL; |
| 24 |
|
| 25 |
for (FilesystemGroups i = 0; i < _FILESYSTEM_SET_MAX; i++) |
| 26 |
if (streq(filesystem_sets[i].name, name)) |
| 27 |
return filesystem_sets + i; |
| 28 |
|
| 29 |
return NULL; |
| 30 |
} |