]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/nspawn/nspawn-mount.h
tree-wide: use -EINVAL for enum invalid values
[thirdparty/systemd.git] / src / nspawn / nspawn-mount.h
CommitLineData
db9ecf05 1/* SPDX-License-Identifier: LGPL-2.1-or-later */
e83bebef
LP
2#pragma once
3
e83bebef
LP
4#include <stdbool.h>
5
5da38d07 6#include "cgroup-util.h"
a4c35b6b 7#include "volatile-util.h"
5da38d07 8
4f086aab 9typedef enum MountSettingsMask {
ef31828d
LP
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.
d4b653c5 15 Works only if MOUNT_APPLY_APIVFS_RO is also set. */
de40a303 16 MOUNT_APPLY_TMPFS_TMP = 1 << 5, /* if set, /tmp will be mounted as tmpfs */
5f0a6347
DDM
17 MOUNT_ROOT_ONLY = 1 << 6, /* if set, only root mounts are mounted */
18 MOUNT_NON_ROOT_ONLY = 1 << 7, /* if set, only non-root mounts are mounted */
dcff2fa5 19 MOUNT_MKDIR = 1 << 8, /* if set, make directory to mount over first */
e1bb4b0d 20 MOUNT_TOUCH = 1 << 9, /* if set, touch file to mount over first */
d64e32c2 21 MOUNT_PREFIX_ROOT = 1 << 10,/* if set, prefix the source path with the container's root directory */
511a8cfe 22 MOUNT_FOLLOW_SYMLINKS = 1 << 11,/* if set, we'll follow symlinks for the mount target */
4f086aab
SU
23} MountSettingsMask;
24
e83bebef
LP
25typedef enum CustomMountType {
26 CUSTOM_MOUNT_BIND,
27 CUSTOM_MOUNT_TMPFS,
28 CUSTOM_MOUNT_OVERLAY,
de40a303
LP
29 CUSTOM_MOUNT_INACCESSIBLE,
30 CUSTOM_MOUNT_ARBITRARY,
e83bebef 31 _CUSTOM_MOUNT_TYPE_MAX,
2d93c20e 32 _CUSTOM_MOUNT_TYPE_INVALID = -EINVAL,
e83bebef
LP
33} CustomMountType;
34
35typedef struct CustomMount {
36 CustomMountType type;
37 bool read_only;
38 char *source; /* for overlayfs this is the upper directory */
39 char *destination;
40 char *options;
41 char *work_dir;
42 char **lower;
c7a4890c 43 char *rm_rf_tmpdir;
de40a303
LP
44 char *type_argument; /* only for CUSTOM_MOUNT_ARBITRARY */
45 bool graceful;
46 bool in_userns;
e83bebef
LP
47} CustomMount;
48
88614c8a
LP
49CustomMount* custom_mount_add(CustomMount **l, size_t *n, CustomMountType t);
50void custom_mount_free_all(CustomMount *l, size_t n);
51int custom_mount_prepare_all(const char *dest, CustomMount *l, size_t n);
ad85779a 52
88614c8a
LP
53int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only);
54int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s);
55int overlay_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only);
de40a303 56int inaccessible_mount_parse(CustomMount **l, size_t *n, const char *s);
e83bebef 57
2fa017f1 58int mount_all(const char *dest, MountSettingsMask mount_settings, uid_t uid_shift, const char *selinux_apifs_context);
4f086aab 59int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
e83bebef 60
e091a5df 61int mount_custom(const char *dest, CustomMount *mounts, size_t n, uid_t uid_shift, const char *selinux_apifs_context, MountSettingsMask mount_settings);
bbd407ea 62bool has_custom_root_mount(const CustomMount *mounts, size_t n);
e83bebef 63
e091a5df 64int setup_volatile_mode(const char *directory, VolatileMode mode, uid_t uid_shift, const char *selinux_apifs_context);
b53ede69
PW
65
66int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s);
67int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old);
04029482
LS
68
69int tmpfs_patch_options(const char *options,uid_t uid_shift, const char *selinux_apifs_context, char **ret);