]>
Commit | Line | Data |
---|---|---|
e83bebef LP |
1 | #pragma once |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2015 Lennart Poettering | |
7 | ||
8 | systemd is free software; you can redistribute it and/or modify it | |
9 | under the terms of the GNU Lesser General Public License as published by | |
10 | the Free Software Foundation; either version 2.1 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | systemd is distributed in the hope that it will be useful, but | |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public License | |
19 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
20 | ***/ | |
21 | ||
22 | #include <stdbool.h> | |
23 | ||
5da38d07 TH |
24 | #include "cgroup-util.h" |
25 | ||
4f086aab SU |
26 | typedef enum MountSettingsMask { |
27 | MOUNT_FATAL = 1 << 0, /* if set, a mount error is considered fatal */ | |
28 | MOUNT_USE_USERNS = 1 << 1, /* if set, mounts are patched considering uid/gid shifts in a user namespace */ | |
29 | MOUNT_IN_USERNS = 1 << 2, /* if set, the mount is executed in the inner child, otherwise in the outer child */ | |
30 | MOUNT_APPLY_APIVFS_RO = 1 << 3, /* if set, /proc/sys, and /sysfs will be mounted read-only, otherwise read-write. */ | |
31 | MOUNT_APPLY_APIVFS_NETNS = 1 << 4, /* if set, /proc/sys/net will be mounted read-write. | |
32 | Works only if MOUNT_APPLY_APIVFS_RO is also set. */ | |
33 | } MountSettingsMask; | |
34 | ||
e83bebef LP |
35 | typedef enum VolatileMode { |
36 | VOLATILE_NO, | |
37 | VOLATILE_YES, | |
38 | VOLATILE_STATE, | |
39 | _VOLATILE_MODE_MAX, | |
40 | _VOLATILE_MODE_INVALID = -1 | |
41 | } VolatileMode; | |
42 | ||
43 | typedef enum CustomMountType { | |
44 | CUSTOM_MOUNT_BIND, | |
45 | CUSTOM_MOUNT_TMPFS, | |
46 | CUSTOM_MOUNT_OVERLAY, | |
47 | _CUSTOM_MOUNT_TYPE_MAX, | |
48 | _CUSTOM_MOUNT_TYPE_INVALID = -1 | |
49 | } CustomMountType; | |
50 | ||
51 | typedef struct CustomMount { | |
52 | CustomMountType type; | |
53 | bool read_only; | |
54 | char *source; /* for overlayfs this is the upper directory */ | |
55 | char *destination; | |
56 | char *options; | |
57 | char *work_dir; | |
58 | char **lower; | |
c7a4890c | 59 | char *rm_rf_tmpdir; |
e83bebef LP |
60 | } CustomMount; |
61 | ||
62 | CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t); | |
e83bebef | 63 | void custom_mount_free_all(CustomMount *l, unsigned n); |
86c0dd4a | 64 | int custom_mount_prepare_all(const char *dest, CustomMount *l, unsigned n); |
ad85779a | 65 | |
e83bebef LP |
66 | int bind_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only); |
67 | int tmpfs_mount_parse(CustomMount **l, unsigned *n, const char *s); | |
ad85779a | 68 | int overlay_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only); |
e83bebef | 69 | |
4f086aab SU |
70 | int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); |
71 | int mount_sysfs(const char *dest, MountSettingsMask mount_settings); | |
e83bebef | 72 | |
5da38d07 TH |
73 | int mount_cgroups(const char *dest, CGroupUnified unified_requested, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context, bool use_cgns); |
74 | int mount_systemd_cgroup_writable(const char *dest, CGroupUnified unified_requested); | |
e83bebef LP |
75 | |
76 | int mount_custom(const char *dest, CustomMount *mounts, unsigned n, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); | |
77 | ||
78 | int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); | |
79 | int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); | |
80 | ||
81 | VolatileMode volatile_mode_from_string(const char *s); |