summaryrefslogtreecommitdiffstats
path: root/src/veritysetup
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-06-01 14:55:26 +0200
committerLennart Poettering <lennart@poettering.net>2023-06-01 18:49:43 +0200
commit5dd02147079cc88a1c264d0a3e0fc2aa19eafae4 (patch)
tree38d3e78be5d4b0b2b587611065955ea643dcb429 /src/veritysetup
parentveritysetup-generator: imply x-initrd.attach for "usr" and "root" volumes (diff)
downloadsystemd-5dd02147079cc88a1c264d0a3e0fc2aa19eafae4.tar.xz
systemd-5dd02147079cc88a1c264d0a3e0fc2aa19eafae4.zip
veritysetup-generator: only generate one set of deps on systemd-tmpfiles-setup-dev.service
If both the data and the hash device are a regular file we might create two sets of deps on s-t-s-d.s, which is of course redundant. Shorten the code to only generate this once. No change in behaviour.
Diffstat (limited to 'src/veritysetup')
-rw-r--r--src/veritysetup/veritysetup-generator.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/veritysetup/veritysetup-generator.c b/src/veritysetup/veritysetup-generator.c
index c1a9d51af3..68ef5d458f 100644
--- a/src/veritysetup/veritysetup-generator.c
+++ b/src/veritysetup/veritysetup-generator.c
@@ -311,7 +311,7 @@ static int create_disk(
*du_escaped = NULL, *hu_escaped = NULL, *name_escaped = NULL;
_cleanup_fclose_ FILE *f = NULL;
const char *dmname;
- bool noauto, nofail, netdev;
+ bool noauto, nofail, netdev, need_loop = false;
int r;
assert(name);
@@ -386,30 +386,27 @@ static int create_disk(
"BindsTo=%s\n"
"After=%s\n",
dd, dd);
- else
- /* For loopback devices, add systemd-tmpfiles-setup-dev.service
- dependency to ensure that loopback support is available in
- the kernel (/dev/loop-control needs to exist) */
- fprintf(f,
- "RequiresMountsFor=%s\n"
- "Requires=systemd-tmpfiles-setup-dev.service\n"
- "After=systemd-tmpfiles-setup-dev.service\n",
- du_escaped);
+ else {
+ fprintf(f, "RequiresMountsFor=%s\n", du_escaped);
+ need_loop = true;
+ }
if (path_startswith(hu, "/dev/"))
fprintf(f,
"BindsTo=%s\n"
"After=%s\n",
hd, hd);
- else
- /* For loopback devices, add systemd-tmpfiles-setup-dev.service
- dependency to ensure that loopback support is available in
- the kernel (/dev/loop-control needs to exist) */
+ else {
+ fprintf(f, "RequiresMountsFor=%s\n", hu_escaped);
+ need_loop = true;
+ }
+
+ if (need_loop)
+ /* For loopback devices, add systemd-tmpfiles-setup-dev.service dependency to ensure that
+ * loopback support is available in the kernel (/dev/loop-control needs to exist) */
fprintf(f,
- "RequiresMountsFor=%s\n"
"Requires=systemd-tmpfiles-setup-dev.service\n"
- "After=systemd-tmpfiles-setup-dev.service\n",
- hu_escaped);
+ "After=systemd-tmpfiles-setup-dev.service\n");
r = generator_write_veritysetup_service_section(f, name, du_escaped, hu_escaped, roothash, options);
if (r < 0)