Message ID | 20221219204619.2205248-8-allenwebb@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Generate modules.builtin.alias from match ids | expand |
On Mon, Dec 19, 2022 at 02:46:15PM -0600, Allen Webb wrote: > This adds an unimplemented command line flag for writing the built-in > aliases to a file. If it is unimplemented, why add it? And this needs a lot more description as to why you are changing this here, as well as documentation for the flag you added, right? thanks, greg k-h
On Tue, Dec 20, 2022 at 12:43 AM Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote: > > On Mon, Dec 19, 2022 at 02:46:15PM -0600, Allen Webb wrote: > > This adds an unimplemented command line flag for writing the built-in > > aliases to a file. > > If it is unimplemented, why add it? This is a fairly self contained change even though the code that populates mod->modalias_buf is in the next patch. I could flatten the two commits, but I was trying to keep this to a single logical change. There is somewhat of a chicken and egg problem here. If the other patch comes first it will be dead code, if this comes first it is pretty much dead code. > > And this needs a lot more description as to why you are changing this > here, as well as documentation for the flag you added, right? I might be missing something, but I don't see an obvious place where the other command line parameters for modpost are documented, so I will add a comment inside the case statement unless you have a better idea. > > thanks, > > greg k-h
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2c80da0220c3..e38d6b2ceea4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2165,6 +2165,19 @@ static void write_if_changed(struct buffer *b, const char *fname) write_buf(b, fname); } +/* Write the builtin aliases to the specified file. */ +static void write_builtin(const char *fname) +{ + struct buffer buf = { }; + struct module *mod; + + list_for_each_entry(mod, &modules, list) + buf_write(&buf, mod->modalias_buf.p, mod->modalias_buf.pos); + + write_if_changed(&buf, fname); + free(buf.p); +} + static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf = { }; @@ -2321,13 +2334,16 @@ int main(int argc, char **argv) { struct module *mod; char *missing_namespace_deps = NULL; - char *dump_write = NULL, *files_source = NULL; + char *builtin_write = NULL, *dump_write = NULL, *files_source = NULL; int opt; LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; - while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "b:ei:mnT:o:awENd:")) != -1) { switch (opt) { + case 'b': + builtin_write = optarg; + break; case 'e': external_module = true; break; @@ -2390,6 +2406,9 @@ int main(int argc, char **argv) write_mod_c_file(mod); } + if (builtin_write) + write_builtin(builtin_write); + if (missing_namespace_deps) write_namespace_deps_files(missing_namespace_deps); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 34fe5fc0b02c..c55a6aeb46bf 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -123,6 +123,7 @@ struct module { bool has_init; bool has_cleanup; struct buffer dev_table_buf; + struct buffer modalias_buf; char srcversion[25]; // Missing namespace dependencies struct list_head missing_namespaces;
This adds an unimplemented command line flag for writing the built-in aliases to a file. Signed-off-by: Allen Webb <allenwebb@google.com> --- scripts/mod/modpost.c | 23 +++++++++++++++++++++-- scripts/mod/modpost.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-)