]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e83bebef LP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2015 Lennart Poettering | |
e83bebef LP |
8 | ***/ |
9 | ||
10 | #include <stdbool.h> | |
11 | ||
5da38d07 | 12 | #include "cgroup-util.h" |
a4c35b6b | 13 | #include "volatile-util.h" |
5da38d07 | 14 | |
4f086aab SU |
15 | typedef enum MountSettingsMask { |
16 | MOUNT_FATAL = 1 << 0, /* if set, a mount error is considered fatal */ | |
17 | MOUNT_USE_USERNS = 1 << 1, /* if set, mounts are patched considering uid/gid shifts in a user namespace */ | |
18 | MOUNT_IN_USERNS = 1 << 2, /* if set, the mount is executed in the inner child, otherwise in the outer child */ | |
19 | MOUNT_APPLY_APIVFS_RO = 1 << 3, /* if set, /proc/sys, and /sysfs will be mounted read-only, otherwise read-write. */ | |
20 | MOUNT_APPLY_APIVFS_NETNS = 1 << 4, /* if set, /proc/sys/net will be mounted read-write. | |
21 | Works only if MOUNT_APPLY_APIVFS_RO is also set. */ | |
22 | } MountSettingsMask; | |
23 | ||
e83bebef LP |
24 | typedef enum CustomMountType { |
25 | CUSTOM_MOUNT_BIND, | |
26 | CUSTOM_MOUNT_TMPFS, | |
27 | CUSTOM_MOUNT_OVERLAY, | |
28 | _CUSTOM_MOUNT_TYPE_MAX, | |
29 | _CUSTOM_MOUNT_TYPE_INVALID = -1 | |
30 | } CustomMountType; | |
31 | ||
32 | typedef struct CustomMount { | |
33 | CustomMountType type; | |
34 | bool read_only; | |
35 | char *source; /* for overlayfs this is the upper directory */ | |
36 | char *destination; | |
37 | char *options; | |
38 | char *work_dir; | |
39 | char **lower; | |
c7a4890c | 40 | char *rm_rf_tmpdir; |
e83bebef LP |
41 | } CustomMount; |
42 | ||
88614c8a LP |
43 | CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t); |
44 | void custom_mount_free_all(CustomMount *l, size_t n); | |
45 | int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n); | |
ad85779a | 46 | |
88614c8a LP |
47 | int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only); |
48 | int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s); | |
49 | int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only); | |
e83bebef | 50 | |
4f086aab SU |
51 | int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); |
52 | int mount_sysfs(const char *dest, MountSettingsMask mount_settings); | |
e83bebef | 53 | |
5da38d07 TH |
54 | 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); |
55 | int mount_systemd_cgroup_writable(const char *dest, CGroupUnified unified_requested); | |
e83bebef | 56 | |
88614c8a | 57 | int mount_custom(const char *dest, CustomMount *mounts, size_t n, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); |
e83bebef LP |
58 | |
59 | int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); | |
60 | int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context); | |
b53ede69 PW |
61 | |
62 | int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s); | |
63 | int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old); |