]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/fstab-util.h
cryptenroll: allow to use a public key on a token
[thirdparty/systemd.git] / src / shared / fstab-util.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
d15d0333
ZJS
2#pragma once
3
d15d0333
ZJS
4#include <stdbool.h>
5#include <stddef.h>
6550203e 6
b9f111b9 7#include "macro.h"
d15d0333 8
1177373b
YW
9bool fstab_enabled_full(int enabled);
10static inline bool fstab_enabled(void) {
11 return fstab_enabled_full(-1);
12}
13static inline bool fstab_set_enabled(bool enabled) {
14 return fstab_enabled_full(enabled);
15}
16
bc9e5a4c 17bool fstab_is_extrinsic(const char *mount, const char *opts);
6c1921e9 18int fstab_has_fstype(const char *fstype);
6550203e 19
99299d0d
MY
20int fstab_is_mount_point_full(const char *where, const char *path);
21static inline int fstab_is_mount_point(const char *where) {
22 return fstab_is_mount_point_full(where, NULL);
23}
24c0078a
MY
24static inline int fstab_has_node(const char *path) {
25 return fstab_is_mount_point_full(NULL, path);
26}
99299d0d 27
ff0c31bc
ZJS
28int fstab_filter_options(
29 const char *opts,
30 const char *names,
31 const char **ret_namefound,
32 char **ret_value,
33 char ***ret_values,
34 char **ret_filtered);
d15d0333 35static inline bool fstab_test_option(const char *opts, const char *names) {
5d193883 36 return fstab_filter_options(opts, names, NULL, NULL, NULL, NULL);
d15d0333 37}
b9f111b9 38static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no) {
5d193883 39 const char *opt_found;
b9f111b9
ZJS
40
41 /* If first name given is last, return 1.
42 * If second name given is last or neither is found, return 0. */
43
5d193883 44 assert_se(fstab_filter_options(opts, yes_no, &opt_found, NULL, NULL, NULL) >= 0);
b9f111b9 45
5d193883 46 return opt_found == yes_no;
b9f111b9 47}
5d193883 48int fstab_find_pri(const char *opts, int *ret);
6550203e
LP
49
50char *fstab_node_to_udev_node(const char *p);
ed4ad488
ZJS
51
52static inline const char* fstab_path(void) {
53 return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab";
54}
35df78cd
MY
55
56bool fstab_is_bind(const char *options, const char *fstype);