rev |
line source |
pascal@1299
|
1 --- busybox-1.12.0/modutils/depmod.c
|
pascal@1299
|
2 +++ busybox-1.12.0/modutils/depmod.c
|
pascal@1299
|
3 @@ -53,27 +53,14 @@ static int FAST_FUNC fileAction(const ch
|
pascal@1299
|
4 size_t len = sb->st_size;
|
pascal@1299
|
5 void *the_module;
|
pascal@1299
|
6 char *ptr;
|
pascal@1299
|
7 - int fd;
|
pascal@1299
|
8 char *depends, *deps;
|
pascal@1299
|
9 dep_lst_t *this;
|
pascal@1299
|
10 + extern void *xalloc_load_module(const char filename[], size_t *len);
|
pascal@1299
|
11
|
pascal@1299
|
12 if (strrstr(fname, ".ko") == NULL) /* not a module */
|
pascal@1299
|
13 goto skip;
|
pascal@1299
|
14
|
pascal@1299
|
15 -/*XXX: FIXME: does not handle compressed modules!
|
pascal@1299
|
16 - * There should be a function that looks at the extension and sets up
|
pascal@1299
|
17 - * open_transformer for us.
|
pascal@1299
|
18 - */
|
pascal@1299
|
19 - fd = xopen(fname, O_RDONLY);
|
pascal@1299
|
20 - the_module = mmap(NULL, len, PROT_READ, MAP_SHARED
|
pascal@1299
|
21 -#if defined MAP_POPULATE
|
pascal@1299
|
22 - |MAP_POPULATE
|
pascal@1299
|
23 -#endif
|
pascal@1299
|
24 - , fd, 0);
|
pascal@1299
|
25 - close(fd);
|
pascal@1299
|
26 - if (the_module == MAP_FAILED)
|
pascal@1299
|
27 - bb_perror_msg_and_die("mmap");
|
pascal@1299
|
28 -
|
pascal@1299
|
29 + the_module = xalloc_load_module(fname, &len);
|
pascal@1299
|
30 this = xzalloc(sizeof(dep_lst_t));
|
pascal@1299
|
31 this->name = xstrdup(fname);
|
pascal@1299
|
32 this->next = G.lst;
|
pascal@1299
|
33 @@ -104,7 +91,7 @@ static int FAST_FUNC fileAction(const ch
|
pascal@1299
|
34 pos = (ptr - (char*)the_module);
|
pascal@1299
|
35 } while (1);
|
pascal@1299
|
36 }
|
pascal@1299
|
37 - munmap(the_module, sb->st_size);
|
pascal@1299
|
38 + free(the_module);
|
pascal@1299
|
39 skip:
|
pascal@1299
|
40 return TRUE;
|
pascal@1299
|
41 }
|
pascal@1299
|
42
|
pascal@1299
|
43 --- busybox-1.12.0/modutils/insmod.c
|
pascal@1299
|
44 +++ busybox-1.12.0/modutils/insmod.c
|
pascal@1299
|
45 @@ -59,6 +59,7 @@
|
pascal@1299
|
46 */
|
pascal@1299
|
47
|
pascal@1299
|
48 #include "libbb.h"
|
pascal@1299
|
49 +#include "unarchive.h"
|
pascal@1299
|
50 #include <libgen.h>
|
pascal@1299
|
51 #include <sys/utsname.h>
|
pascal@1299
|
52
|
pascal@1397
|
53 @@ -4212,6 +4213,48 @@ static const char *moderror(int err)
|
pascal@1299
|
54 }
|
pascal@1299
|
55 }
|
pascal@1299
|
56
|
pascal@1299
|
57 +void *xalloc_load_module(const char filename[], size_t *len);
|
pascal@1299
|
58 +void *xalloc_load_module(const char filename[], size_t *len)
|
pascal@1299
|
59 +{
|
pascal@1299
|
60 + int fd, max;
|
pascal@1299
|
61 + unsigned char head[16];
|
pascal@1299
|
62 + void *map;
|
pascal@1299
|
63 + size_t l;
|
pascal@1299
|
64 +
|
pascal@1299
|
65 + max = 8 * 1024;
|
pascal@1299
|
66 + fd = open(filename, O_RDONLY);
|
pascal@1299
|
67 + if (fd < 0) return NULL;
|
pascal@1299
|
68 + xread(fd,head,sizeof(head));
|
pascal@1299
|
69 + lseek(fd,0L,SEEK_SET);
|
pascal@1299
|
70 + if (head[0] == 0x1f && head[1] == 0x8b) { /* gzip */
|
pascal@1397
|
71 +#if BB_MMU
|
pascal@1397
|
72 + xread(fd,head,2); // bb wierdness...
|
pascal@1397
|
73 +#endif
|
pascal@1299
|
74 + open_transformer(fd, unpack_gz_stream, "gunzip");
|
pascal@1299
|
75 + }
|
pascal@1299
|
76 + else if (head[0] == 'B' && head[1] == 'Z' &&
|
pascal@1299
|
77 + head[2] == 'h' && isdigit(head[3])) { /* bzip2 */
|
pascal@1299
|
78 + open_transformer(fd, unpack_bz2_stream, "bunzip2");
|
pascal@1299
|
79 + }
|
pascal@1299
|
80 + else if (head[1] != 'E' || head[2] != 'L' || head[3] != 'F') {
|
pascal@1299
|
81 + open_transformer(fd, unpack_lzma_stream, "unlzma");
|
pascal@1299
|
82 + if (* (unsigned *) (head + 9) == 0)
|
pascal@1299
|
83 + max = 1 + head[5] + (head[6]<<8)
|
pascal@1299
|
84 + + (head[7]<<16) + (head[8]<<24);
|
pascal@1299
|
85 + }
|
pascal@1299
|
86 + l = 0;
|
pascal@1299
|
87 + map = xmalloc(max);
|
pascal@1299
|
88 + while (1) {
|
pascal@1299
|
89 + l += full_read(fd, l + (char *) map, max - l);
|
pascal@1299
|
90 + if (l != max) break;
|
pascal@1299
|
91 + max <<= 1;
|
pascal@1299
|
92 + map = xrealloc(map, max);
|
pascal@1299
|
93 + }
|
pascal@1299
|
94 + if (len)
|
pascal@1299
|
95 + *len = l;
|
pascal@1299
|
96 + return xrealloc(map, l);
|
pascal@1299
|
97 +}
|
pascal@1299
|
98 +
|
pascal@1299
|
99 #if !ENABLE_FEATURE_2_4_MODULES
|
pascal@1299
|
100 int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
pascal@1299
|
101 int insmod_main(int argc UNUSED_PARAM, char **argv)
|
pascal@1397
|
102 @@ -4264,8 +4307,7 @@ static int insmod_ng_main(int argc UNUSE
|
pascal@1299
|
103 xread(fd, map, len);
|
pascal@1299
|
104 }
|
pascal@1299
|
105 #else
|
pascal@1299
|
106 - len = MAXINT(ssize_t);
|
pascal@1299
|
107 - map = xmalloc_open_read_close(filename, &len);
|
pascal@1299
|
108 + map = xalloc_load_module(filename, &len);
|
pascal@1299
|
109 #endif
|
pascal@1299
|
110
|
pascal@1299
|
111 if (init_module(map, len, options) != 0)
|
pascal@1299
|
112
|
pascal@1299
|
113 --- busybox-1.12.0/modutils/modprobe.c
|
pascal@1299
|
114 +++ busybox-1.12.0/modutils/modprobe.c
|
pascal@1299
|
115 @@ -396,6 +396,29 @@ static int include_conf_file2(struct inc
|
pascal@1299
|
116 return include_conf_file(conf, oldname);
|
pascal@1299
|
117 }
|
pascal@1299
|
118
|
pascal@1299
|
119 +static int ext_size(char *end USE_FEATURE_2_6_MODULES(, int k_version))
|
pascal@1299
|
120 +{
|
pascal@1299
|
121 + int ext;
|
pascal@1299
|
122 + char *next;
|
pascal@1299
|
123 +
|
pascal@1299
|
124 + ext = 0;
|
pascal@1299
|
125 + if (end[-2] == '.' && end[-1] == 'g' && end[0] == 'z')
|
pascal@1299
|
126 + ext = 3;
|
pascal@1299
|
127 + if (end[-3] == '.' && end[-2] == 'b' && end[-1] == 'z' && end[0] == '2')
|
pascal@1299
|
128 + ext = 4;
|
pascal@1299
|
129 + next = end - ext;
|
pascal@1299
|
130 +#if ENABLE_FEATURE_2_6_MODULES
|
pascal@1299
|
131 + if (ENABLE_FEATURE_2_6_MODULES
|
pascal@1299
|
132 + && (k_version > 4) && (next[-2] == '.')
|
pascal@1299
|
133 + && (next[-1] == 'k') && (next[0] == 'o'))
|
pascal@1299
|
134 + ext += 3;
|
pascal@1299
|
135 + else
|
pascal@1299
|
136 +#endif
|
pascal@1299
|
137 + if ((next[-1] == '.') && (next[0] == 'o'))
|
pascal@1299
|
138 + ext += 2;
|
pascal@1299
|
139 + return ext;
|
pascal@1299
|
140 +}
|
pascal@1299
|
141 +
|
pascal@1299
|
142 /*
|
pascal@1299
|
143 * This function builds a list of dependency rules from /lib/modules/`uname -r`/modules.dep.
|
pascal@1299
|
144 * It then fills every modules and aliases with their default options, found by parsing
|
pascal@1299
|
145 @@ -464,12 +487,7 @@ static struct dep_t *build_dep(void)
|
pascal@1299
|
146 if (!modpath)
|
pascal@1299
|
147 modpath = line_buffer; /* module with no path */
|
pascal@1299
|
148 /* find the end of the module name in the file name */
|
pascal@1299
|
149 - if (ENABLE_FEATURE_2_6_MODULES &&
|
pascal@1299
|
150 - (k_version > 4) && (col[-3] == '.') &&
|
pascal@1299
|
151 - (col[-2] == 'k') && (col[-1] == 'o'))
|
pascal@1299
|
152 - dot = col - 3;
|
pascal@1299
|
153 - else if ((col[-2] == '.') && (col[-1] == 'o'))
|
pascal@1299
|
154 - dot = col - 2;
|
pascal@1299
|
155 + dot = col - ext_size(col - 1 USE_FEATURE_2_6_MODULES(, k_version));
|
pascal@1299
|
156
|
pascal@1299
|
157 mod = xstrndup(mods, dot - mods);
|
pascal@1299
|
158
|
pascal@1299
|
159 @@ -522,12 +540,7 @@ static struct dep_t *build_dep(void)
|
pascal@1299
|
160 deps = skip_whitespace(deps);
|
pascal@1299
|
161
|
pascal@1299
|
162 /* find the end of the module name in the file name */
|
pascal@1299
|
163 - if (ENABLE_FEATURE_2_6_MODULES
|
pascal@1299
|
164 - && (k_version > 4) && (next[-2] == '.')
|
pascal@1299
|
165 - && (next[-1] == 'k') && (next[0] == 'o'))
|
pascal@1299
|
166 - ext = 3;
|
pascal@1299
|
167 - else if ((next[-1] == '.') && (next[0] == 'o'))
|
pascal@1299
|
168 - ext = 2;
|
pascal@1299
|
169 + ext = ext_size(next USE_FEATURE_2_6_MODULES(, k_version));
|
pascal@1299
|
170
|
pascal@1299
|
171 /* Cope with blank lines */
|
pascal@1299
|
172 if ((next - deps - ext + 1) <= 0)
|
pascal@1478
|
173
|
pascal@1478
|
174 --- busybox-1.12.0/modutils/depmod.c
|
pascal@1478
|
175 +++ busybox-1.12.0/modutils/depmod.c
|
pascal@1478
|
176 @@ -109,11 +109,15 @@
|
pascal@1478
|
177 ARG_b = (1<<2), /* not /lib/modules/$(uname -r)/ but this base-dir */
|
pascal@1478
|
178 ARG_e = (1<<3), /* with -F, print unresolved symbols */
|
pascal@1478
|
179 ARG_F = (1<<4), /* System.map that contains the symbols */
|
pascal@1478
|
180 - ARG_n = (1<<5) /* dry-run, print to stdout only */
|
pascal@1478
|
181 + ARG_n = (1<<5), /* dry-run, print to stdout only */
|
pascal@1478
|
182 + ARG_u = (1<<6), /* unresolved-error: ignored */
|
pascal@1478
|
183 + ARG_q = (1<<7), /* quiet: ignored */
|
pascal@1478
|
184 + ARG_r = (1<<8), /* root: ignored */
|
pascal@1478
|
185 + ARG_C = (1<<9) /* config: ignored */
|
pascal@1478
|
186 };
|
pascal@1478
|
187 INIT_G();
|
pascal@1478
|
188
|
pascal@1478
|
189 - getopt32(argv, "aAb:eF:n", &moddir_base, &system_map);
|
pascal@1478
|
190 + getopt32(argv, "aAb:eF:nuqrC", &moddir_base, &system_map);
|
pascal@1478
|
191 argv += optind;
|
pascal@1478
|
192
|
pascal@1478
|
193 /* If a version is provided, then that kernel version’s module directory
|
pascal@1636
|
194
|
pascal@1636
|
195 --- busybox-1.12.0/modutils/depmod.c
|
pascal@1636
|
196 +++ busybox-1.12.0/modutils/depmod.c
|
pascal@1636
|
197 @@ -141,6 +141,11 @@
|
pascal@1636
|
198
|
pascal@1636
|
199 if (!(option_mask32 & ARG_n)) { /* --dry-run */
|
pascal@1636
|
200 chp = concat_path_file(moddir, CONFIG_DEFAULT_DEPMOD_FILE);
|
pascal@1636
|
201 + if (option_mask32 & ARG_b) {
|
pascal@1636
|
202 + char *s = concat_path_file(moddir_base, chp);
|
pascal@1636
|
203 + free(chp);
|
pascal@1636
|
204 + chp = s;
|
pascal@1636
|
205 + }
|
pascal@1636
|
206 filedes = xfopen_for_write(chp);
|
pascal@1636
|
207 if (ENABLE_FEATURE_CLEAN_UP)
|
pascal@1636
|
208 free(chp);
|