fstab-generator: add x-systemd.wants

This is an analog of x-systemd.requires that adds a Wants dependency
instead. This is useful for filesystems that support mounting in
degraded states (such as multi-device filesystems).
This commit is contained in:
chayleaf 2024-07-14 09:15:39 +07:00 committed by Lennart Poettering
parent 99d4575e54
commit 21aa180b4a
2 changed files with 20 additions and 0 deletions

View File

@ -216,6 +216,17 @@
<xi:include href="version-info.xml" xpointer="v220"/></listitem>
</varlistentry>
<varlistentry>
<term><option>x-systemd.wants=</option></term>
<listitem><para>Configures a <varname>Wants=</varname> and
an <varname>After=</varname> dependency between the created
mount unit and another systemd unit, similar to the
<varname>x-systemd.requires=</varname> option.</para>
<xi:include href="version-info.xml" xpointer="v257"/></listitem>
</varlistentry>
<varlistentry>
<term><option>x-systemd.before=</option></term>
<term><option>x-systemd.after=</option></term>

View File

@ -416,6 +416,11 @@ static int write_requires_after(FILE *f, const char *where, const char *opts) {
"x-systemd.requires\0", STRV_MAKE_CONST("Requires", "After"));
}
static int write_wants_after(FILE *f, const char *where, const char *opts) {
return write_dependency(f, where, opts,
"x-systemd.wants\0", STRV_MAKE_CONST("Wants", "After"));
}
static int write_before(FILE *f, const char *where, const char *opts) {
return write_dependency(f, where, opts,
"x-systemd.before\0", STRV_MAKE_CONST("Before"));
@ -469,6 +474,10 @@ static int write_extra_dependencies(FILE *f, const char *where, const char *opts
if (r < 0)
return r;
r = write_wants_after(f, where, opts);
if (r < 0)
return r;
r = write_before(f, where, opts);
if (r < 0)
return r;