wok view busybox/stuff/busybox-1.12.0-zmodules.u @ rev 3771

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