]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/nspawn/nspawn-mount.h
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / nspawn / nspawn-mount.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5
6 #include "cgroup-util.h"
7 #include "volatile-util.h"
8
9 typedef enum MountSettingsMask {
10 MOUNT_FATAL = 1 << 0, /* if set, a mount error is considered fatal */
11 MOUNT_USE_USERNS = 1 << 1, /* if set, mounts are patched considering uid/gid shifts in a user namespace */
12 MOUNT_IN_USERNS = 1 << 2, /* if set, the mount is executed in the inner child, otherwise in the outer child */
13 MOUNT_APPLY_APIVFS_RO = 1 << 3, /* if set, /proc/sys, and /sys will be mounted read-only, otherwise read-write. */
14 MOUNT_APPLY_APIVFS_NETNS = 1 << 4, /* if set, /proc/sys/net will be mounted read-write.
15 Works only if MOUNT_APPLY_APIVFS_RO is also set. */
16 MOUNT_INACCESSIBLE_REG = 1 << 5, /* if set, create an inaccessible regular file first and use as bind mount source */
17 } MountSettingsMask;
18
19 typedef enum CustomMountType {
20 CUSTOM_MOUNT_BIND,
21 CUSTOM_MOUNT_TMPFS,
22 CUSTOM_MOUNT_OVERLAY,
23 _CUSTOM_MOUNT_TYPE_MAX,
24 _CUSTOM_MOUNT_TYPE_INVALID = -1
25 } CustomMountType;
26
27 typedef struct CustomMount {
28 CustomMountType type;
29 bool read_only;
30 char *source; /* for overlayfs this is the upper directory */
31 char *destination;
32 char *options;
33 char *work_dir;
34 char **lower;
35 char *rm_rf_tmpdir;
36 } CustomMount;
37
38 CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t);
39 void custom_mount_free_all(CustomMount *l, size_t n);
40 int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n);
41
42 int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only);
43 int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s);
44 int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only);
45
46 int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
47 int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
48
49 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);
50 int mount_systemd_cgroup_writable(const char *dest, CGroupUnified unified_requested);
51
52 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);
53
54 int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
55 int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
56
57 int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s);
58 int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old);