X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcryptsetup%2Fcryptsetup-generator.c;h=46ad9b8d6004f15cf84155b29839c36ee461fb13;hp=9c98f0b617d161417060d93bb50dbd7eb9aaaf55;hb=66a5dbdf282435403f947c2caadd04bb0cdec752;hpb=2ba110900aca729f7d511c185b62149c4a28a293 diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 9c98f0b61..46ad9b8d6 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -130,11 +130,21 @@ static int create_disk( streq(password, "/dev/random") || streq(password, "/dev/hw_random")) fputs("After=systemd-random-seed.service\n", f); - else if (!streq(password, "-") && - !streq(password, "none")) - fprintf(f, - "RequiresMountsFor=%s\n", - password); + + else if (!streq(password, "-") && !streq(password, "none")) { + _cleanup_free_ char *uu = fstab_node_to_udev_node(password); + if (uu == NULL) + return log_oom(); + + if (is_device_path(uu)) { + _cleanup_free_ char *dd = unit_name_from_path(uu, ".device"); + if (dd == NULL) + return log_oom(); + + fprintf(f, "After=%1$s\nRequires=%1$s\n", dd); + } else + fprintf(f, "RequiresMountsFor=%s\n", password); + } } if (is_device_path(u))