chiark / gitweb /
generators: add Documentation= fields that point to the generator man pages
[elogind.git] / src / fstab-generator / fstab-generator.c
index aac1a436ec6fc44bddb41af7165839d3a6019abe..248a4ceb90d4d8af4aeace4f31cb1f88c18583a1 100644 (file)
@@ -34,6 +34,7 @@
 #include "mkdir.h"
 #include "fileio.h"
 #include "generator.h"
+#include "strv.h"
 
 static const char *arg_dest = "/tmp";
 static bool arg_fstab_enabled = true;
@@ -100,7 +101,8 @@ static int add_swap(const char *what, struct mntent *me) {
         fprintf(f,
                 "# Automatically generated by systemd-fstab-generator\n\n"
                 "[Unit]\n"
-                "SourcePath=/etc/fstab\n\n"
+                "SourcePath=/etc/fstab\n"
+                "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n"
                 "[Swap]\n"
                 "What=%s\n",
                 what);
@@ -207,10 +209,11 @@ static int add_mount(
         }
 
         fprintf(f,
-              "# Automatically generated by systemd-fstab-generator\n\n"
-              "[Unit]\n"
-              "SourcePath=%s\n",
-              source);
+                "# Automatically generated by systemd-fstab-generator\n\n"
+                "[Unit]\n"
+                "SourcePath=%s\n"
+                "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n",
+                source);
 
         if (post && !noauto && !nofail && !automount)
                 fprintf(f,
@@ -277,7 +280,8 @@ static int add_mount(
                 fprintf(f,
                         "# Automatically generated by systemd-fstab-generator\n\n"
                         "[Unit]\n"
-                        "SourcePath=%s\n",
+                        "SourcePath=%s\n"
+                        "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n",
                         source);
 
                 if (post)
@@ -461,32 +465,19 @@ static int parse_new_root_from_proc_cmdline(void) {
         return (r < 0) ? r : 0;
 }
 
-static int parse_proc_cmdline_word(const char *word) {
+static int parse_proc_cmdline_item(const char *key, const char *value) {
         int r;
 
-        if (startswith(word, "fstab=")) {
+        if (STR_IN_SET(key, "fstab", "rd.fstab") && value) {
 
-                r = parse_boolean(word + 6);
+                r = parse_boolean(value);
                 if (r < 0)
-                        log_warning("Failed to parse fstab switch %s. Ignoring.", word + 6);
+                        log_warning("Failed to parse fstab switch %s. Ignoring.", value);
                 else
                         arg_fstab_enabled = r;
 
-        } else if (startswith(word, "rd.fstab=")) {
-
-                if (in_initrd()) {
-                        r = parse_boolean(word + 9);
-                        if (r < 0)
-                                log_warning("Failed to parse fstab switch %s. Ignoring.", word + 9);
-                        else
-                                arg_fstab_enabled = r;
-                }
-
-        } else if (startswith(word, "fstab.") ||
-                   (in_initrd() && startswith(word, "rd.fstab."))) {
-
-                log_warning("Unknown kernel switch %s. Ignoring.", word);
-        }
+        } else if (startswith(key, "fstab.") || startswith(key, "rd.fstab."))
+                log_warning("Unknown kernel switch %s. Ignoring.", key);
 
         return 0;
 }
@@ -508,7 +499,7 @@ int main(int argc, char *argv[]) {
 
         umask(0022);
 
-        if (parse_proc_cmdline(parse_proc_cmdline_word) < 0)
+        if (parse_proc_cmdline(parse_proc_cmdline_item) < 0)
                 return EXIT_FAILURE;
 
         /* Always honour root= in the kernel command line if we are in an initrd */