* [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
* Re: [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty
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
0 siblings, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2016-01-11 12:43 UTC (permalink / raw)
To: Josh Triplett; +Cc: linux-modules, 810367, kmod
On Sun, Jan 10, 2016 at 1:10 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> 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);
> --
Applied, thanks.
Lucas De Marchi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug#810367: [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty
2016-01-11 12:43 ` Lucas De Marchi
@ 2016-01-11 15:55 ` Martin Pitt
2016-01-11 16:06 ` Lucas De Marchi
0 siblings, 1 reply; 4+ messages in thread
From: Martin Pitt @ 2016-01-11 15:55 UTC (permalink / raw)
To: Lucas De Marchi, 810367; +Cc: Josh Triplett, linux-modules
Hey Josh, Lucas,
Lucas De Marchi [2016-01-11 10:43 -0200]:
> On Sun, Jan 10, 2016 at 1:10 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> > This allows tools to detect the file as empty, such as via systemd's
> > ConditionFileNotEmpty.
As pointed out on https://github.com/systemd/systemd/pull/2301: Why
does this file get created at all if it's going to be empty?
Thanks,
Martin
--
Martin Pitt | http://www.piware.de
Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug#810367: [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty
2016-01-11 15:55 ` Bug#810367: " Martin Pitt
@ 2016-01-11 16:06 ` Lucas De Marchi
0 siblings, 0 replies; 4+ messages in thread
From: Lucas De Marchi @ 2016-01-11 16:06 UTC (permalink / raw)
To: Martin Pitt; +Cc: 810367, Josh Triplett, linux-modules
Hi Martin
On Mon, Jan 11, 2016 at 1:55 PM, Martin Pitt <mpitt@debian.org> wrote:
> Hey Josh, Lucas,
>
> Lucas De Marchi [2016-01-11 10:43 -0200]:
>> On Sun, Jan 10, 2016 at 1:10 PM, Josh Triplett <josh@joshtriplett.org> wrote:
>> > This allows tools to detect the file as empty, such as via systemd's
>> > ConditionFileNotEmpty.
>
> As pointed out on https://github.com/systemd/systemd/pull/2301: Why
> does this file get created at all if it's going to be empty?
The only reason I can think of is to avoid breaking current programs
that depend on its existence since it is created since forever.
Lucas De Marchi
^ permalink raw reply [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).