]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/nspawn/nspawn-mount.h
nspawn: fix user namespace support
[thirdparty/systemd.git] / src / nspawn / nspawn-mount.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6 This file is part of systemd.
7
8 Copyright 2015 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <stdbool.h>
25
26 typedef enum VolatileMode {
27 VOLATILE_NO,
28 VOLATILE_YES,
29 VOLATILE_STATE,
30 _VOLATILE_MODE_MAX,
31 _VOLATILE_MODE_INVALID = -1
32 } VolatileMode;
33
34 typedef enum CustomMountType {
35 CUSTOM_MOUNT_BIND,
36 CUSTOM_MOUNT_TMPFS,
37 CUSTOM_MOUNT_OVERLAY,
38 _CUSTOM_MOUNT_TYPE_MAX,
39 _CUSTOM_MOUNT_TYPE_INVALID = -1
40 } CustomMountType;
41
42 typedef struct CustomMount {
43 CustomMountType type;
44 bool read_only;
45 char *source; /* for overlayfs this is the upper directory */
46 char *destination;
47 char *options;
48 char *work_dir;
49 char **lower;
50 } CustomMount;
51
52 CustomMount* custom_mount_add(CustomMount **l, unsigned *n, CustomMountType t);
53
54 void custom_mount_free_all(CustomMount *l, unsigned n);
55 int bind_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_only);
56 int tmpfs_mount_parse(CustomMount **l, unsigned *n, const char *s);
57
58 int custom_mount_compare(const void *a, const void *b);
59
60 int mount_all(const char *dest, bool use_userns, bool in_userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
61
62 int mount_cgroups(const char *dest, bool unified_requested, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
63 int mount_systemd_cgroup_writable(const char *dest, bool unified_requested);
64
65 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);
66
67 int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
68 int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
69
70 VolatileMode volatile_mode_from_string(const char *s);