diff options
| author | Rusty Russell <rusty@rustcorp.com.au> | 2013-04-04 03:07:38 -0400 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-04-04 21:18:08 -0400 |
| commit | 712f9b46843d941347e86dcd2e1d63f9d3b112cb (patch) | |
| tree | 1d92f1af1215492e8d6e4855e3cdbad1d6d5eb35 /scripts | |
| parent | d4ef1c30e89ce8e7f1030501d74b6b812c3c179d (diff) | |
modpost: add -T option to read module names from file/stdin.
Because there are too many modules in the world.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/mod/modpost.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f7a0392ad1ca..1f90961ada77 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <stdio.h> | 15 | #include <stdio.h> |
| 16 | #include <ctype.h> | 16 | #include <ctype.h> |
| 17 | #include <string.h> | 17 | #include <string.h> |
| 18 | #include <limits.h> | ||
| 18 | #include <stdbool.h> | 19 | #include <stdbool.h> |
| 19 | #include "modpost.h" | 20 | #include "modpost.h" |
| 20 | #include "../../include/generated/autoconf.h" | 21 | #include "../../include/generated/autoconf.h" |
| @@ -1763,6 +1764,27 @@ static void read_symbols(char *modname) | |||
| 1763 | mod->unres = alloc_symbol("module_layout", 0, mod->unres); | 1764 | mod->unres = alloc_symbol("module_layout", 0, mod->unres); |
| 1764 | } | 1765 | } |
| 1765 | 1766 | ||
| 1767 | static void read_symbols_from_files(const char *filename) | ||
| 1768 | { | ||
| 1769 | FILE *in = stdin; | ||
| 1770 | char fname[PATH_MAX]; | ||
| 1771 | |||
| 1772 | if (strcmp(filename, "-") != 0) { | ||
| 1773 | in = fopen(filename, "r"); | ||
| 1774 | if (!in) | ||
| 1775 | fatal("Can't open filenames file %s: %m", filename); | ||
| 1776 | } | ||
| 1777 | |||
| 1778 | while (fgets(fname, PATH_MAX, in) != NULL) { | ||
| 1779 | if (strends(fname, "\n")) | ||
| 1780 | fname[strlen(fname)-1] = '\0'; | ||
| 1781 | read_symbols(fname); | ||
| 1782 | } | ||
| 1783 | |||
| 1784 | if (in != stdin) | ||
| 1785 | fclose(in); | ||
| 1786 | } | ||
| 1787 | |||
| 1766 | #define SZ 500 | 1788 | #define SZ 500 |
| 1767 | 1789 | ||
| 1768 | /* We first write the generated file into memory using the | 1790 | /* We first write the generated file into memory using the |
| @@ -2124,13 +2146,13 @@ int main(int argc, char **argv) | |||
| 2124 | struct module *mod; | 2146 | struct module *mod; |
| 2125 | struct buffer buf = { }; | 2147 | struct buffer buf = { }; |
| 2126 | char *kernel_read = NULL, *module_read = NULL; | 2148 | char *kernel_read = NULL, *module_read = NULL; |
| 2127 | char *dump_write = NULL; | 2149 | char *dump_write = NULL, *files_source = NULL; |
| 2128 | int opt; | 2150 | int opt; |
| 2129 | int err; | 2151 | int err; |
| 2130 | struct ext_sym_list *extsym_iter; | 2152 | struct ext_sym_list *extsym_iter; |
| 2131 | struct ext_sym_list *extsym_start = NULL; | 2153 | struct ext_sym_list *extsym_start = NULL; |
| 2132 | 2154 | ||
| 2133 | while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { | 2155 | while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) { |
| 2134 | switch (opt) { | 2156 | switch (opt) { |
| 2135 | case 'i': | 2157 | case 'i': |
| 2136 | kernel_read = optarg; | 2158 | kernel_read = optarg; |
| @@ -2162,6 +2184,9 @@ int main(int argc, char **argv) | |||
| 2162 | case 'S': | 2184 | case 'S': |
| 2163 | sec_mismatch_verbose = 0; | 2185 | sec_mismatch_verbose = 0; |
| 2164 | break; | 2186 | break; |
| 2187 | case 'T': | ||
| 2188 | files_source = optarg; | ||
| 2189 | break; | ||
| 2165 | case 'w': | 2190 | case 'w': |
| 2166 | warn_unresolved = 1; | 2191 | warn_unresolved = 1; |
| 2167 | break; | 2192 | break; |
| @@ -2184,6 +2209,9 @@ int main(int argc, char **argv) | |||
| 2184 | while (optind < argc) | 2209 | while (optind < argc) |
| 2185 | read_symbols(argv[optind++]); | 2210 | read_symbols(argv[optind++]); |
| 2186 | 2211 | ||
| 2212 | if (files_source) | ||
| 2213 | read_symbols_from_files(files_source); | ||
| 2214 | |||
| 2187 | for (mod = modules; mod; mod = mod->next) { | 2215 | for (mod = modules; mod; mod = mod->next) { |
| 2188 | if (mod->skip) | 2216 | if (mod->skip) |
| 2189 | continue; | 2217 | continue; |
