1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 #include <stddef.h>
6 
7 #include "macro.h"
8 
9 bool fstab_is_extrinsic(const char *mount, const char *opts);
10 int fstab_is_mount_point(const char *mount);
11 int fstab_has_fstype(const char *fstype);
12 
13 int fstab_filter_options(
14                 const char *opts,
15                 const char *names,
16                 const char **ret_namefound,
17                 char **ret_value,
18                 char ***ret_values,
19                 char **ret_filtered);
20 
fstab_test_option(const char * opts,const char * names)21 static inline bool fstab_test_option(const char *opts, const char *names) {
22         return !!fstab_filter_options(opts, names, NULL, NULL, NULL, NULL);
23 }
24 
25 int fstab_find_pri(const char *options, int *ret);
26 
fstab_test_yes_no_option(const char * opts,const char * yes_no)27 static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no) {
28         const char *opt;
29 
30         /* If first name given is last, return 1.
31          * If second name given is last or neither is found, return 0. */
32 
33         assert_se(fstab_filter_options(opts, yes_no, &opt, NULL, NULL, NULL) >= 0);
34 
35         return opt == yes_no;
36 }
37 
38 char *fstab_node_to_udev_node(const char *p);
39 
fstab_path(void)40 static inline const char* fstab_path(void) {
41         return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab";
42 }
43