summaryrefslogtreecommitdiffstats
path: root/src/core/mount.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-11-17 16:43:08 +0100
committerLennart Poettering <lennart@poettering.net>2017-11-21 11:54:08 +0100
commit3c7416b6cae1006388755598415e1139727b926a (patch)
treedfe4bf644447a413011162c0d918ccd5bb4a1eda /src/core/mount.c
parentcgroup-util: move Set* allocation into cg_kernel_controllers() (diff)
downloadsystemd-3c7416b6cae1006388755598415e1139727b926a.tar.xz
systemd-3c7416b6cae1006388755598415e1139727b926a.zip
core: unify common code for preparing for forking off unit processes
This introduces a new function unit_prepare_exec() that encapsulates a number of calls we do in preparation for spawning off some processes in all our unit types that do so. This allows us to neatly unify a bit of code between unit types and shorten our code.
Diffstat (limited to 'src/core/mount.c')
-rw-r--r--src/core/mount.c23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/core/mount.c b/src/core/mount.c
index 79a6e1626c..1500670b09 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -750,33 +750,21 @@ static void mount_dump(Unit *u, FILE *f, const char *prefix) {
}
static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
- pid_t pid;
- int r;
+
ExecParameters exec_params = {
.flags = EXEC_APPLY_SANDBOXING|EXEC_APPLY_CHROOT|EXEC_APPLY_TTY_STDIN,
.stdin_fd = -1,
.stdout_fd = -1,
.stderr_fd = -1,
};
+ pid_t pid;
+ int r;
assert(m);
assert(c);
assert(_pid);
- (void) unit_realize_cgroup(UNIT(m));
- if (m->reset_accounting) {
- (void) unit_reset_cpu_accounting(UNIT(m));
- (void) unit_reset_ip_accounting(UNIT(m));
- m->reset_accounting = false;
- }
-
- unit_export_state_files(UNIT(m));
-
- r = unit_setup_exec_runtime(UNIT(m));
- if (r < 0)
- return r;
-
- r = unit_setup_dynamic_creds(UNIT(m));
+ r = unit_prepare_exec(UNIT(m));
if (r < 0)
return r;
@@ -1091,7 +1079,8 @@ static int mount_start(Unit *u) {
m->result = MOUNT_SUCCESS;
m->reload_result = MOUNT_SUCCESS;
- m->reset_accounting = true;
+
+ u->reset_accounting = true;
mount_enter_mounting(m);
return 1;