mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
nspawn: add volatile mode multiplexer call setup_volatile_mode()
Just some refactoring, no change in behaviour.
This commit is contained in:
@@ -856,9 +856,8 @@ int mount_custom(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setup_volatile_state(
|
||||
static int setup_volatile_state(
|
||||
const char *directory,
|
||||
VolatileMode mode,
|
||||
bool userns, uid_t uid_shift, uid_t uid_range,
|
||||
const char *selinux_apifs_context) {
|
||||
|
||||
@@ -868,11 +867,7 @@ int setup_volatile_state(
|
||||
|
||||
assert(directory);
|
||||
|
||||
if (mode != VOLATILE_STATE)
|
||||
return 0;
|
||||
|
||||
/* --volatile=state means we simply overmount /var
|
||||
with a tmpfs, and the rest read-only. */
|
||||
/* --volatile=state means we simply overmount /var with a tmpfs, and the rest read-only. */
|
||||
|
||||
r = bind_remount_recursive(directory, true, NULL);
|
||||
if (r < 0)
|
||||
@@ -893,9 +888,8 @@ int setup_volatile_state(
|
||||
return mount_verbose(LOG_ERR, "tmpfs", p, "tmpfs", MS_STRICTATIME, options);
|
||||
}
|
||||
|
||||
int setup_volatile(
|
||||
static int setup_volatile_yes(
|
||||
const char *directory,
|
||||
VolatileMode mode,
|
||||
bool userns, uid_t uid_shift, uid_t uid_range,
|
||||
const char *selinux_apifs_context) {
|
||||
|
||||
@@ -907,11 +901,8 @@ int setup_volatile(
|
||||
|
||||
assert(directory);
|
||||
|
||||
if (mode != VOLATILE_YES)
|
||||
return 0;
|
||||
|
||||
/* --volatile=yes means we mount a tmpfs to the root dir, and
|
||||
the original /usr to use inside it, and that read-only. */
|
||||
/* --volatile=yes means we mount a tmpfs to the root dir, and the original /usr to use inside it, and that
|
||||
read-only. */
|
||||
|
||||
if (!mkdtemp(template))
|
||||
return log_error_errno(errno, "Failed to create temporary directory: %m");
|
||||
@@ -968,6 +959,25 @@ fail:
|
||||
return r;
|
||||
}
|
||||
|
||||
int setup_volatile_mode(
|
||||
const char *directory,
|
||||
VolatileMode mode,
|
||||
bool userns, uid_t uid_shift, uid_t uid_range,
|
||||
const char *selinux_apifs_context) {
|
||||
|
||||
switch (mode) {
|
||||
|
||||
case VOLATILE_YES:
|
||||
return setup_volatile_yes(directory, userns, uid_shift, uid_range, selinux_apifs_context);
|
||||
|
||||
case VOLATILE_STATE:
|
||||
return setup_volatile_state(directory, userns, uid_shift, uid_range, selinux_apifs_context);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Expects *pivot_root_new and *pivot_root_old to be initialised to allocated memory or NULL. */
|
||||
int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s) {
|
||||
_cleanup_free_ char *root_new = NULL, *root_old = NULL;
|
||||
|
||||
@@ -49,8 +49,7 @@ int mount_sysfs(const char *dest, MountSettingsMask mount_settings);
|
||||
|
||||
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);
|
||||
|
||||
int setup_volatile(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
|
||||
int setup_volatile_state(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
|
||||
int setup_volatile_mode(const char *directory, VolatileMode mode, bool userns, uid_t uid_shift, uid_t uid_range, const char *selinux_apifs_context);
|
||||
|
||||
int pivot_root_parse(char **pivot_root_new, char **pivot_root_old, const char *s);
|
||||
int setup_pivot_root(const char *directory, const char *pivot_root_new, const char *pivot_root_old);
|
||||
|
||||
@@ -2933,17 +2933,7 @@ static int outer_child(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = setup_volatile(
|
||||
directory,
|
||||
arg_volatile_mode,
|
||||
arg_userns_mode != USER_NAMESPACE_NO,
|
||||
arg_uid_shift,
|
||||
arg_uid_range,
|
||||
arg_selinux_context);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = setup_volatile_state(
|
||||
r = setup_volatile_mode(
|
||||
directory,
|
||||
arg_volatile_mode,
|
||||
arg_userns_mode != USER_NAMESPACE_NO,
|
||||
|
||||
Reference in New Issue
Block a user