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.
This commit is contained in:
Franck Bui 2020-04-02 10:52:24 +02:00
parent 83cdc87094
commit b3d7aef525
3 changed files with 8 additions and 2 deletions

View File

@ -86,6 +86,10 @@
<listitem><para>Automount units acquire automatic <varname>Before=</varname> and
<varname>Conflicts=</varname> on <filename>umount.target</filename> in order to be stopped during
shutdown.</para></listitem>
<listitem><para>Automount units automatically gain an <varname>After=</varname> dependency
on <filename>local-fs-pre.target</filename>, and a <varname>Before=</varname> dependency on
<filename>local-fs.target</filename>.</para></listitem>
</itemizedlist>
</refsect2>
</refsect1>

View File

@ -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;

View File

@ -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)