]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/nspawn/nspawn-mount.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / nspawn / nspawn-mount.h
CommitLineData
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 24#include "cgroup-util.h"
a4c35b6b 25#include "volatile-util.h"
5da38d07 26
4f086aab
SU
27typedef 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
e83bebef
LP
36typedef 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
44typedef 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;
c7a4890c 52 char *rm_rf_tmpdir;
e83bebef
LP
53} CustomMount;
54
55CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t);
e83bebef 56void custom_mount_free_all(CustomMount *l, unsigned n);
86c0dd4a 57int custom_mount_prepare_all(const char *dest, CustomMount *l, unsigned n);
ad85779a 58
e83bebef
LP
59int bind_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only);
60int tmpfs_mount_parse(CustomMount **l, unsigned *n, const char *s);
ad85779a 61int overlay_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only);
e83bebef 62
4f086aab
SU
63int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
64int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
e83bebef 65
5da38d07
TH
66int 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);
67int mount_systemd_cgroup_writable(const char *dest, CGroupUnified unified_requested);
e83bebef
LP
68
69int 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
71int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
72int 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
73
74int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s);
75int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old);