From: Franck Bui Date: Thu, 2 Apr 2020 08:52:24 +0000 (+0200) Subject: automount: fix handling of default dependencies for automount units X-Git-Tag: v246-rc1~361^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3d7aef5;p=thirdparty%2Fsystemd.git automount: fix handling of default dependencies for automount units First After=local-fs-pre.target wasn't described in the man page although it's part of the default dependencies automatically set by pid1. Secondly, Before=local-fs.target was only set if the automount unit was generated from the fstab-generator because the dep was explicitly generated. It was also not documented as a default dependency. Fix it by managing the dep from pid1 instead. --- diff --git a/man/systemd.automount.xml b/man/systemd.automount.xml index f2ed7610216..35690fd22a7 100644 --- a/man/systemd.automount.xml +++ b/man/systemd.automount.xml @@ -86,6 +86,10 @@ Automount units acquire automatic Before= and Conflicts= on umount.target in order to be stopped during shutdown. + + Automount units automatically gain an After= dependency + on local-fs-pre.target, and a Before= dependency on + local-fs.target. diff --git a/src/core/automount.c b/src/core/automount.c index 0b3f498bfcb..99b4eb2c81a 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -152,6 +152,10 @@ static int automount_add_default_dependencies(Automount *a) { if (!MANAGER_IS_SYSTEM(UNIT(a)->manager)) return 0; + r = unit_add_dependency_by_name(UNIT(a), UNIT_BEFORE, SPECIAL_LOCAL_FS_TARGET, true, UNIT_DEPENDENCY_DEFAULT); + if (r < 0) + return r; + r = unit_add_dependency_by_name(UNIT(a), UNIT_AFTER, SPECIAL_LOCAL_FS_PRE_TARGET, true, UNIT_DEPENDENCY_DEFAULT); if (r < 0) return r; diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 16be342dbf3..bd022efcf2d 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -526,8 +526,6 @@ static int add_mount( "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n", source); - fprintf(f, "Before=%s\n", post); - if (opts) { r = write_after(f, opts); if (r < 0)