linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty
@ 2016-01-10 15:10 Josh Triplett
  2016-01-11 12:43 ` Lucas De Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2016-01-10 15:10 UTC (permalink / raw)
  To: linux-modules; +Cc: 810367, kmod

This allows tools to detect the file as empty, such as via systemd's
ConditionFileNotEmpty.
---

The string constant extends past 80 columns, per CODING-STYLE.

The motivation for this patch came from Debian bug 810367.  This change
would allow kmod-static-nodes.service to use ConditionFileNotEmpty
instead of ConditionPathExists.

 tools/depmod.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/depmod.c b/tools/depmod.c
index a585d47..6e9bb4d 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -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);
-- 
2.7.0.rc3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-11 16:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-10 15:10 [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty Josh Triplett
2016-01-11 12:43 ` Lucas De Marchi
2016-01-11 15:55   ` Bug#810367: " Martin Pitt
2016-01-11 16:06     ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).