]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Don't insert comment in modules.devname if otherwise empty
authorJosh Triplett <josh@joshtriplett.org>
Sun, 10 Jan 2016 15:10:25 +0000 (07:10 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 11 Jan 2016 12:25:31 +0000 (10:25 -0200)
This allows tools to detect the file as empty, such as via systemd's
ConditionFileNotEmpty.

tools/depmod.c

index a585d47516ff7a5b3b833cc666a8f2348d190a98..6e9bb4dbc2ad65a65c45050f36af2ad985ec4dc0 100644 (file)
@@ -1999,8 +1999,7 @@ static int output_builtin_bin(struct depmod *depmod, FILE *out)
 static int output_devname(struct depmod *depmod, FILE *out)
 {
        size_t i;
-
-       fputs("# Device nodes to trigger on-demand module loading.\n", out);
+       bool empty = true;
 
        for (i = 0; i < depmod->modules.count; i++) {
                const struct mod *mod = depmod->modules.array[i];
@@ -2036,10 +2035,15 @@ static int output_devname(struct depmod *depmod, FILE *out)
                }
 
                if (devname != NULL) {
-                       if (type != '\0')
+                       if (type != '\0') {
+                               if (empty) {
+                                       fputs("# Device nodes to trigger on-demand module loading.\n",
+                                             out);
+                                       empty = false;
+                               }
                                fprintf(out, "%s %s %c%u:%u\n", mod->modname,
                                        devname, type, major, minor);
-                       else
+                        } else
                                ERR("Module '%s' has devname (%s) but "
                                    "lacks major and minor information. "
                                    "Ignoring.\n", mod->modname, devname);