]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fstab-generator: add x-systemd.wants
authorchayleaf <chayleaf-git@pavluk.org>
Sun, 14 Jul 2024 02:15:39 +0000 (09:15 +0700)
committerLennart Poettering <lennart@poettering.net>
Mon, 15 Jul 2024 08:18:18 +0000 (10:18 +0200)
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).

man/systemd.mount.xml
src/fstab-generator/fstab-generator.c

index d061736b733e9cae49981ad4c077d67e0ea06cc6..9c6c2140961a67a81dfbcb201c06fb4e55462abc 100644 (file)
         <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>
index b4df9d23c2a4a003174432fe89f2d8297f42a1d0..6b7445b201d9b306727061e69c61f069a0129a0a 100644 (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;