]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/nspawn/nspawn-mount.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / nspawn / nspawn-mount.h
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
24 #include "cgroup-util.h"
25 #include "volatile-util.h"
26
27 typedef enum MountSettingsMask {
28 MOUNT_FATAL = 1 << 0, /* if set, a mount error is considered fatal */
29 MOUNT_USE_USERNS = 1 << 1, /* if set, mounts are patched considering uid/gid shifts in a user namespace */
30 MOUNT_IN_USERNS = 1 << 2, /* if set, the mount is executed in the inner child, otherwise in the outer child */
31 MOUNT_APPLY_APIVFS_RO = 1 << 3, /* if set, /proc/sys, and /sysfs will be mounted read-only, otherwise read-write. */
32 MOUNT_APPLY_APIVFS_NETNS = 1 << 4, /* if set, /proc/sys/net will be mounted read-write.
33 Works only if MOUNT_APPLY_APIVFS_RO is also set. */
34 } MountSettingsMask;
35
36 typedef enum CustomMountType {
37 CUSTOM_MOUNT_BIND,
38 CUSTOM_MOUNT_TMPFS,
39 CUSTOM_MOUNT_OVERLAY,
40 _CUSTOM_MOUNT_TYPE_MAX,
41 _CUSTOM_MOUNT_TYPE_INVALID = -1
42 } CustomMountType;
43
44 typedef struct CustomMount {
45 CustomMountType type;
46 bool read_only;
47 char *source; /* for overlayfs this is the upper directory */
48 char *destination;
49 char *options;
50 char *work_dir;
51 char **lower;
52 char *rm_rf_tmpdir;
53 } CustomMount;
54
55 CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t);
56 void custom_mount_free_all(CustomMount *l, unsigned n);
57 int custom_mount_prepare_all(const char *dest, CustomMount *l, unsigned n);
58
59 int bind_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only);
60 int tmpfs_mount_parse(CustomMount **l, unsigned *n, const char *s);
61 int overlay_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only);
62
63 int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
64 int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
65
66 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);
67 int mount_systemd_cgroup_writable(const char *dest, CGroupUnified unified_requested);
68
69 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);
70
71 int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
72 int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
73
74 int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s);
75 int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old);