Also, move all the default dependency logic into core, this introduces a functional change compared to the fstab generator:
We no longer care about the type (network or local) or options (nofail) of filesystem corresponding to the automount, but consider an automount unit as a local mount point which is not allowed to fail. In the initrd the automount is unconditionally Before and RequiredBy both initrd-root-fs.target and initrd-fs.target. In the real root the automount is unconditionally Before and RequiredBy local-fs.target. --- src/core/automount.c | 14 ++++++++++++++ src/fstab-generator/fstab-generator.c | 23 +++-------------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/core/automount.c b/src/core/automount.c index a20d534..27d96ce 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -163,6 +163,20 @@ static int automount_add_default_dependencies(Automount *a) { if (UNIT(a)->manager->running_as != SYSTEMD_SYSTEM) return 0; + if (in_initrd()) { + r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_REQUIRED_BY, SPECIAL_INITRD_ROOT_FS_TARGET, NULL, true); + if (r < 0) + return r; + + r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_REQUIRED_BY, SPECIAL_INITRD_FS_TARGET, NULL, true); + if (r < 0) + return r; + } else { + r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_REQUIRED_BY, SPECIAL_LOCAL_FS_TARGET, NULL, true); + if (r < 0) + return r; + } + r = unit_add_two_dependencies_by_name(UNIT(a), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_UMOUNT_TARGET, NULL, true); if (r < 0) return r; diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 6ebe8aa..02052ea 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -252,17 +252,11 @@ static int add_mount( fprintf(f, "# Automatically generated by systemd-fstab-generator\n\n" "[Unit]\n" - "SourcePath=%s\n", - source); - - if (post) - fprintf(f, - "Before= %s\n", - post); - - fprintf(f, + "SourcePath=%s\n" + "\n" "[Automount]\n" "Where=%s\n", + source, where); fflush(f); @@ -270,17 +264,6 @@ static int add_mount( log_error("Failed to write unit file %s: %m", automount_unit); return -errno; } - - free(lnk); - lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL); - if (!lnk) - return log_oom(); - - mkdir_parents_label(lnk, 0755); - if (symlink(automount_unit, lnk) < 0) { - log_error("Failed to create symlink %s: %m", lnk); - return -errno; - } } return 0; -- 1.8.4 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel