1 /* SPDX-License-Identifier: LGPL-2.1+ */
6 #include "cgroup-util.h"
7 #include "volatile-util.h"
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_APPLY_TMPFS_TMP
= 1 << 5, /* if set, /tmp will be mounted as tmpfs */
19 typedef enum CustomMountType
{
23 CUSTOM_MOUNT_INACCESSIBLE
,
24 CUSTOM_MOUNT_ARBITRARY
,
25 _CUSTOM_MOUNT_TYPE_MAX
,
26 _CUSTOM_MOUNT_TYPE_INVALID
= -1
29 typedef struct CustomMount
{
32 char *source
; /* for overlayfs this is the upper directory */
38 char *type_argument
; /* only for CUSTOM_MOUNT_ARBITRARY */
43 CustomMount
* custom_mount_add(CustomMount
**l
, size_t *n
, CustomMountType t
);
44 void custom_mount_free_all(CustomMount
*l
, size_t n
);
45 int custom_mount_prepare_all(const char *dest
, CustomMount
*l
, size_t n
);
47 int bind_mount_parse(CustomMount
**l
, size_t *n
, const char *s
, bool read_only
);
48 int tmpfs_mount_parse(CustomMount
**l
, size_t *n
, const char *s
);
49 int overlay_mount_parse(CustomMount
**l
, size_t *n
, const char *s
, bool read_only
);
50 int inaccessible_mount_parse(CustomMount
**l
, size_t *n
, const char *s
);
52 int mount_all(const char *dest
, MountSettingsMask mount_settings
, uid_t uid_shift
, const char *selinux_apifs_context
);
53 int mount_sysfs(const char *dest
, MountSettingsMask mount_settings
);
55 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
, bool in_userns
);
57 int setup_volatile_mode(const char *directory
, VolatileMode mode
, bool userns
, uid_t uid_shift
, uid_t uid_range
, const char *selinux_apifs_context
);
59 int pivot_root_parse(char **pivot_root_new
, char **pivot_root_old
, const char *s
);
60 int setup_pivot_root(const char *directory
, const char *pivot_root_new
, const char *pivot_root_old
);
62 int tmpfs_patch_options(const char *options
,uid_t uid_shift
, const char *selinux_apifs_context
, char **ret
);