depmod: do not output .bin to stdout
PATCH 1/2 depmod: do not output .bin to stdout
index_write() relies on fseek/ftell to manage the position to which we are write and thus needs the file stream to support it.
Right now when trying to write the index to stdout we fail with:
depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed. Aborted (core dumped)
We have no interest in outputting our index to stdout, so just skip it like is done with other indexes.
While at it, add/remove some newlines to improve readability.
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
--- tools/depmod.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/depmod.c +5 -1
@@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)struct index_node *idx;struct kmod_list *l, *builtin =NULL ; - idx =index_create (); +if (out == stdout) +return 0 ; + idx =index_create ();if (idx ==NULL ) { ret = -ENOMEM ; goto fail;
@@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)if (count)index_write (idx, out); +index_destroy (idx); + fail:if (builtin)kmod_module_unref_list (builtin);
Signature · 1 line
2.25.1
PATCH 2/2 depmod: just add .bin suffix to builtin.modinfo
For all the other indexes what we do is to add a .bin to the original filename to denote it's the indexed version of that file. It was kernel's decision to name it modules.builtin.modinfo, so respect that.
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
--- tools/depmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/depmod.c +2 -2
@@ -2402,7 +2402,7 @@ static int output_devname(struct depmod *depmod, FILE *out)return 0 ; } -static int output_builtin_alias_bin (struct depmod *depmod,FILE *out) +static int output_builtin_modinfo_bin (struct depmod *depmod,FILE *out) {int ret =0 , count =0 ;struct index_node *idx;
@@ -2482,7 +2482,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) { "modules.symbols", output_symbols }, { "modules.symbols.bin", output_symbols_bin }, { "modules.builtin.bin", output_builtin_bin }, - { "modules.builtin.alias.bin", output_builtin_alias_bin }, + { "modules.builtin.modinfo.bin", output_builtin_modinfo_bin }, { "modules.devname", output_devname }, { } };
Signature · 1 line
2.25.1
Re: [PATCH 2/2] depmod: just add .bin suffix to builtin.modinfo
Quoted 23 lines · Lucas De Marchi
For all the other indexes what we do is to add a .bin to the original filename to denote it's the indexed version of that file. It was kernel's decision to name it modules.builtin.modinfo, so respect that.
Fix:
b866b2165ae6("Lookup aliases in the modules.builtin.modinfo")--- tools/depmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/depmod.c +1
-1@@ -2402,7 +2402,7 @@ static int output_devname(struct depmod *depmod, FILE *out)return 0 ; } -static int output_builtin_alias_bin (struct depmod *depmod,FILE *out) +static int output_builtin_modinfo_bin (struct depmod *depmod,FILE *out) {int ret =0 , count =0 ;struct index_node *idx;
tools/depmod.c static int depmod_output(struct depmod *depmod, FILE *out) · line 2485
Quoted 5 lines
tools/depmod.c +1
-1@@ -2482,7 +2482,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) { "modules.symbols", output_symbols }, { "modules.symbols.bin", output_symbols_bin }, { "modules.builtin.bin", output_builtin_bin }, - { "modules.builtin.alias.bin", output_builtin_alias_bin }, + { "modules.builtin.modinfo.bin", output_builtin_modinfo_bin },
This file does not contain all whole modinfo. Now the function name and index name will be confusing. But it's up to you.
Quoted 6 lines
tools/depmod.c +0
-0{ "modules.devname", output_devname }, { } };Signature · 1 line
2.25.1
Signature · 1 line
Rgrds, legion
Re: [PATCH 2/2] depmod: just add .bin suffix to builtin.modinfo
Quoted 19 lines · Alexey Gladkov
Quoted 17 lines · Lucas De Marchi
For all the other indexes what we do is to add a .bin to the original filename to denote it's the indexed version of that file. It was kernel's decision to name it modules.builtin.modinfo, so respect that.
Fix:
b866b2165ae6("Lookup aliases in the modules.builtin.modinfo")--- tools/depmod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/depmod.c +0
-0@@ -2402,7 +2402,7 @@ static int output_devname(struct depmod *depmod, FILE *out)return 0 ; }
Quoted 14 lines
tools/depmod.c static int depmod_output(struct depmod *depmod, FILE *out) · line 2485
Quoted 11 lines
tools/depmod.c +2
-2-static int output_builtin_alias_bin (struct depmod *depmod,FILE *out) +static int output_builtin_modinfo_bin (struct depmod *depmod,FILE *out) {int ret =0 , count =0 ;struct index_node *idx;@@ -2482,7 +2482,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) { "modules.symbols", output_symbols }, { "modules.symbols.bin", output_symbols_bin }, { "modules.builtin.bin", output_builtin_bin }, - { "modules.builtin.alias.bin", output_builtin_alias_bin }, + { "modules.builtin.modinfo.bin", output_builtin_modinfo_bin },This file does not contain all whole modinfo. Now the function name and index name will be confusing. But it's up to you.
Indeed. I'd also have to fix the libkmod counterpart, otherwise it would look for the wrong file.
This index contains only the alias -> module, like our modules.alias file.
I think it would be better to leave it with this name. It would probably be good to output
modules.builtin.alias though to make it similar to the modules.alias/modules.alias.bin case.
Another option is to just add those aliases to modules.alias and lookup modules.builtin to decide
if that's builtin, but I think I prefer to keep them separate.
thanks
Lucas De Marchi
Quoted 11 lines
Quoted 7 lines
tools/depmod.c +0
-1{ "modules.devname", output_devname }, { } }; --2.25.1
--
Rgrds, legion
Signature · 1 line
Lucas De Marchi