From bb33c5da87d2e6e5f24d99dd51910cf42125bf1a Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 15 May 2024 21:52:47 +0800 Subject: [PATCH 1/2] core/swap: rename variable 'new' -> 'new_unit' Follow-up for ba31a5018f99864c22dd4e0f10712456c7abc934 'new' is already used as a macro for memory allocation. Let's avoid the confusion here. Addresses https://github.com/systemd/systemd/pull/31902#discussion_r1557672858 --- src/core/swap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/swap.c b/src/core/swap.c index 222241c9da..c4d2ba8f3a 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -374,7 +374,7 @@ static int swap_setup_unit( int priority, bool set_flags) { - _cleanup_(unit_freep) Unit *new = NULL; + _cleanup_(unit_freep) Unit *new_unit = NULL; _cleanup_free_ char *e = NULL; Unit *u; Swap *s; @@ -398,11 +398,11 @@ static int swap_setup_unit( "Swap appeared twice with different device paths %s and %s, refusing.", s->parameters_proc_swaps.what, what_proc_swaps); } else { - r = unit_new_for_name(m, sizeof(Swap), e, &new); + r = unit_new_for_name(m, sizeof(Swap), e, &new_unit); if (r < 0) return log_warning_errno(r, "Failed to load swap unit '%s': %m", e); - u = new; + u = new_unit; s = ASSERT_PTR(SWAP(u)); s->what = strdup(what); @@ -438,7 +438,7 @@ static int swap_setup_unit( p->priority_set = true; unit_add_to_dbus_queue(u); - TAKE_PTR(new); + TAKE_PTR(new_unit); return 0; } From bb5f3e6410f426a468b522207bb5cd913f009230 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Wed, 15 May 2024 21:49:00 +0800 Subject: [PATCH 2/2] core/mount: correctly set DefaultDependencies=no for mounts from mountinfo Follow-up for 3c0a1b1e70c1fe6e0b6707fab7dc86b1500d0f82 Before this commit, DefaultDependencies=no is set in mount_add_extras(). However, when generating mount units from /proc/self/mountinfo, we don't have a unit in memory yet, and mount_setup_new_unit() doesn't call into mount_add_extras(). Fixes #32838 --- src/core/mount.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/mount.c b/src/core/mount.c index e43a93ac21..ebafcafa92 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -604,6 +604,9 @@ static int mount_add_non_exec_dependencies(Mount *m) { if (!m->where) return 0; + if (mount_is_credentials(m)) + UNIT(m)->default_dependencies = false; + /* Adds in all dependencies directly responsible for ordering the mount, as opposed to dependencies * resulting from the ExecContext and such. */ @@ -650,9 +653,6 @@ static int mount_add_extras(Mount *m) { return r; } - if (mount_is_credentials(m)) - u->default_dependencies = false; - r = unit_patch_contexts(u); if (r < 0) return r;