diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-12-19 21:04:19 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-12-19 21:04:19 +0000 |
commit | 03d8091859f45a6bb5e3aadc110b279e789399f2 (patch) | |
tree | 54c744aab1045bb9fa1348b108bb479cf84017bd | |
parent | 514aeabc366d8763cb1e2437be80f3f13d135ec3 (diff) | |
download | busybox-w32-03d8091859f45a6bb5e3aadc110b279e789399f2.tar.gz busybox-w32-03d8091859f45a6bb5e3aadc110b279e789399f2.tar.bz2 busybox-w32-03d8091859f45a6bb5e3aadc110b279e789399f2.zip |
Patch from Woody Suwalski:
Erik, I think we have met online some time ago when I was in Corel/Rebel
Netwinder project....
Anyway, I would like to use BB on 2.6.0 initrd. 1.00-pre4 works OK, if
insmod is actually presented with a full path to the module. Otherwise -
problems (not to mention conflicts when 2.4 modutil is enabled)
Here are some patches for insmod and modprobe which try to walk around
the default ".o" module format for 2.2/2.4 modules (you have probably
noticed it is now .ko in 2.6 ;-)) Trying to steal as little space as
possible if 2.6 not enabled...
The modprobe is still not perfect on 2.6 - seems to be jamming on some
dependencies, but works with some (to be debugged). Anyway after the
patches it at least tries to work....
Will there be a 1.00-pre5 coming any time soon?
Thanks, Woody
-rw-r--r-- | modutils/insmod.c | 84 | ||||
-rw-r--r-- | modutils/modprobe.c | 24 |
2 files changed, 77 insertions, 31 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c index 979c41f78..554c97693 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -282,7 +282,7 @@ extern int insmod_ng_main( int argc, char **argv); | |||
282 | #ifndef MODUTILS_MODULE_H | 282 | #ifndef MODUTILS_MODULE_H |
283 | static const int MODUTILS_MODULE_H = 1; | 283 | static const int MODUTILS_MODULE_H = 1; |
284 | 284 | ||
285 | #ident "$Id: insmod.c,v 1.107 2003/12/11 01:42:13 andersen Exp $" | 285 | #ident "$Id: insmod.c,v 1.108 2003/12/19 21:04:19 andersen Exp $" |
286 | 286 | ||
287 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 287 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
288 | We do not use the kernel headers directly because we do not wish | 288 | We do not use the kernel headers directly because we do not wish |
@@ -503,7 +503,7 @@ int delete_module(const char *); | |||
503 | #ifndef MODUTILS_OBJ_H | 503 | #ifndef MODUTILS_OBJ_H |
504 | static const int MODUTILS_OBJ_H = 1; | 504 | static const int MODUTILS_OBJ_H = 1; |
505 | 505 | ||
506 | #ident "$Id: insmod.c,v 1.107 2003/12/11 01:42:13 andersen Exp $" | 506 | #ident "$Id: insmod.c,v 1.108 2003/12/19 21:04:19 andersen Exp $" |
507 | 507 | ||
508 | /* The relocatable object is manipulated using elfin types. */ | 508 | /* The relocatable object is manipulated using elfin types. */ |
509 | 509 | ||
@@ -4050,6 +4050,8 @@ extern int insmod_main( int argc, char **argv) | |||
4050 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP | 4050 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP |
4051 | int flag_print_load_map = 0; | 4051 | int flag_print_load_map = 0; |
4052 | #endif | 4052 | #endif |
4053 | int k_version = 0; | ||
4054 | struct utsname myuname; | ||
4053 | 4055 | ||
4054 | /* Parse any options */ | 4056 | /* Parse any options */ |
4055 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP | 4057 | #ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP |
@@ -4098,7 +4100,7 @@ extern int insmod_main( int argc, char **argv) | |||
4098 | bb_show_usage(); | 4100 | bb_show_usage(); |
4099 | } | 4101 | } |
4100 | } | 4102 | } |
4101 | 4103 | ||
4102 | if (argv[optind] == NULL) { | 4104 | if (argv[optind] == NULL) { |
4103 | bb_show_usage(); | 4105 | bb_show_usage(); |
4104 | } | 4106 | } |
@@ -4108,12 +4110,33 @@ extern int insmod_main( int argc, char **argv) | |||
4108 | tmp = basename(tmp1); | 4110 | tmp = basename(tmp1); |
4109 | len = strlen(tmp); | 4111 | len = strlen(tmp); |
4110 | 4112 | ||
4113 | if (uname(&myuname) == 0) { | ||
4114 | if (myuname.release[0] == '2') { | ||
4115 | k_version = myuname.release[2] - '0'; | ||
4116 | } | ||
4117 | } | ||
4118 | |||
4119 | #if defined(CONFIG_FEATURE_2_6_MODULES) | ||
4120 | if (k_version > 4 && len > 3 && tmp[len - 3] == '.' && | ||
4121 | tmp[len - 2] == 'k' && tmp[len - 1] == 'o') { | ||
4122 | len-=3; | ||
4123 | tmp[len] = '\0'; | ||
4124 | } | ||
4125 | else | ||
4126 | #endif | ||
4111 | if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') { | 4127 | if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') { |
4112 | len-=2; | 4128 | len-=2; |
4113 | tmp[len] = '\0'; | 4129 | tmp[len] = '\0'; |
4114 | } | 4130 | } |
4115 | 4131 | ||
4132 | |||
4133 | #if defined(CONFIG_FEATURE_2_6_MODULES) | ||
4134 | if (k_version > 4) | ||
4135 | bb_xasprintf(&m_fullName, "%s.ko", tmp); | ||
4136 | else | ||
4137 | #else | ||
4116 | bb_xasprintf(&m_fullName, "%s.o", tmp); | 4138 | bb_xasprintf(&m_fullName, "%s.o", tmp); |
4139 | #endif | ||
4117 | 4140 | ||
4118 | if (!m_name) { | 4141 | if (!m_name) { |
4119 | m_name = tmp; | 4142 | m_name = tmp; |
@@ -4125,28 +4148,26 @@ extern int insmod_main( int argc, char **argv) | |||
4125 | /* Get a filedesc for the module. Check we we have a complete path */ | 4148 | /* Get a filedesc for the module. Check we we have a complete path */ |
4126 | if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) || | 4149 | if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) || |
4127 | (fp = fopen(argv[optind], "r")) == NULL) { | 4150 | (fp = fopen(argv[optind], "r")) == NULL) { |
4128 | struct utsname myuname; | ||
4129 | |||
4130 | /* Hmm. Could not open it. First search under /lib/modules/`uname -r`, | 4151 | /* Hmm. Could not open it. First search under /lib/modules/`uname -r`, |
4131 | * but do not error out yet if we fail to find it... */ | 4152 | * but do not error out yet if we fail to find it... */ |
4132 | if (uname(&myuname) == 0) { | 4153 | if (k_version) { /* uname succeedd */ |
4133 | char *module_dir; | 4154 | char *module_dir; |
4134 | char *tmdn; | 4155 | char *tmdn; |
4135 | char real_module_dir[FILENAME_MAX]; | 4156 | char real_module_dir[FILENAME_MAX]; |
4136 | 4157 | ||
4137 | tmdn = concat_path_file(_PATH_MODULES, myuname.release); | 4158 | tmdn = concat_path_file(_PATH_MODULES, myuname.release); |
4138 | /* Jump through hoops in case /lib/modules/`uname -r` | 4159 | /* Jump through hoops in case /lib/modules/`uname -r` |
4139 | * is a symlink. We do not want recursive_action to | 4160 | * is a symlink. We do not want recursive_action to |
4140 | * follow symlinks, but we do want to follow the | 4161 | * follow symlinks, but we do want to follow the |
4141 | * /lib/modules/`uname -r` dir, So resolve it ourselves | 4162 | * /lib/modules/`uname -r` dir, So resolve it ourselves |
4142 | * if it is a link... */ | 4163 | * if it is a link... */ |
4143 | if (realpath (tmdn, real_module_dir) == NULL) | 4164 | if (realpath (tmdn, real_module_dir) == NULL) |
4144 | module_dir = tmdn; | 4165 | module_dir = tmdn; |
4145 | else | 4166 | else |
4146 | module_dir = real_module_dir; | 4167 | module_dir = real_module_dir; |
4147 | recursive_action(module_dir, TRUE, FALSE, FALSE, | 4168 | recursive_action(module_dir, TRUE, FALSE, FALSE, |
4148 | check_module_name_match, 0, m_fullName); | 4169 | check_module_name_match, 0, m_fullName); |
4149 | free(tmdn); | 4170 | free(tmdn); |
4150 | } | 4171 | } |
4151 | 4172 | ||
4152 | /* Check if we have found anything yet */ | 4173 | /* Check if we have found anything yet */ |
@@ -4154,17 +4175,17 @@ extern int insmod_main( int argc, char **argv) | |||
4154 | { | 4175 | { |
4155 | char module_dir[FILENAME_MAX]; | 4176 | char module_dir[FILENAME_MAX]; |
4156 | 4177 | ||
4157 | free(m_filename); | 4178 | free(m_filename); |
4158 | m_filename = 0; | 4179 | m_filename = 0; |
4159 | if (realpath (_PATH_MODULES, module_dir) == NULL) | 4180 | if (realpath (_PATH_MODULES, module_dir) == NULL) |
4160 | strcpy(module_dir, _PATH_MODULES); | 4181 | strcpy(module_dir, _PATH_MODULES); |
4161 | /* No module found under /lib/modules/`uname -r`, this | 4182 | /* No module found under /lib/modules/`uname -r`, this |
4162 | * time cast the net a bit wider. Search /lib/modules/ */ | 4183 | * time cast the net a bit wider. Search /lib/modules/ */ |
4163 | if (! recursive_action(module_dir, TRUE, FALSE, FALSE, | 4184 | if (! recursive_action(module_dir, TRUE, FALSE, FALSE, |
4164 | check_module_name_match, 0, m_fullName)) | 4185 | check_module_name_match, 0, m_fullName)) |
4165 | { | 4186 | { |
4166 | if (m_filename == 0 | 4187 | if (m_filename == 0 |
4167 | || ((fp = fopen(m_filename, "r")) == NULL)) | 4188 | || ((fp = fopen(m_filename, "r")) == NULL)) |
4168 | { | 4189 | { |
4169 | bb_error_msg("%s: no module by that name found", m_fullName); | 4190 | bb_error_msg("%s: no module by that name found", m_fullName); |
4170 | goto out; | 4191 | goto out; |
@@ -4172,17 +4193,18 @@ extern int insmod_main( int argc, char **argv) | |||
4172 | } else | 4193 | } else |
4173 | bb_error_msg_and_die("%s: no module by that name found", m_fullName); | 4194 | bb_error_msg_and_die("%s: no module by that name found", m_fullName); |
4174 | } | 4195 | } |
4175 | } else | 4196 | } else |
4176 | m_filename = bb_xstrdup(argv[optind]); | 4197 | m_filename = bb_xstrdup(argv[optind]); |
4177 | 4198 | ||
4178 | printf("Using %s\n", m_filename); | 4199 | printf("Using %s\n", m_filename); |
4179 | 4200 | ||
4180 | #ifdef CONFIG_FEATURE_2_6_MODULES | 4201 | #ifdef CONFIG_FEATURE_2_6_MODULES |
4181 | if (create_module(NULL, 0) < 0 && errno == ENOSYS) { | 4202 | if (k_version > 4) |
4203 | { | ||
4182 | optind--; | 4204 | optind--; |
4183 | argv[optind] = m_filename; | 4205 | argv[optind + 1] = m_filename; |
4184 | return insmod_ng_main(argc - optind, argv + optind); | 4206 | return insmod_ng_main(argc - optind, argv + optind); |
4185 | } | 4207 | } |
4186 | #endif | 4208 | #endif |
4187 | 4209 | ||
4188 | if ((f = obj_load(fp, LOADBITS)) == NULL) | 4210 | if ((f = obj_load(fp, LOADBITS)) == NULL) |
@@ -4264,9 +4286,9 @@ extern int insmod_main( int argc, char **argv) | |||
4264 | 4286 | ||
4265 | /* Allocate common symbols, symbol tables, and string tables. */ | 4287 | /* Allocate common symbols, symbol tables, and string tables. */ |
4266 | 4288 | ||
4267 | if (k_new_syscalls | 4289 | if (k_new_syscalls |
4268 | ? !new_create_this_module(f, m_name) | 4290 | ? !new_create_this_module(f, m_name) |
4269 | : !old_create_mod_use_count(f)) | 4291 | : !old_create_mod_use_count(f)) |
4270 | { | 4292 | { |
4271 | goto out; | 4293 | goto out; |
4272 | } | 4294 | } |
@@ -4282,8 +4304,8 @@ extern int insmod_main( int argc, char **argv) | |||
4282 | 4304 | ||
4283 | if (optind < argc) { | 4305 | if (optind < argc) { |
4284 | if (m_has_modinfo | 4306 | if (m_has_modinfo |
4285 | ? !new_process_module_arguments(f, argc - optind, argv + optind) | 4307 | ? !new_process_module_arguments(f, argc - optind, argv + optind) |
4286 | : !old_process_module_arguments(f, argc - optind, argv + optind)) | 4308 | : !old_process_module_arguments(f, argc - optind, argv + optind)) |
4287 | { | 4309 | { |
4288 | goto out; | 4310 | goto out; |
4289 | } | 4311 | } |
@@ -4326,16 +4348,16 @@ extern int insmod_main( int argc, char **argv) | |||
4326 | delete_module(m_name); | 4348 | delete_module(m_name); |
4327 | goto out; | 4349 | goto out; |
4328 | } | 4350 | } |
4329 | #endif | 4351 | #endif |
4330 | 4352 | ||
4331 | if (!obj_relocate(f, m_addr)) { | 4353 | if (!obj_relocate(f, m_addr)) { |
4332 | delete_module(m_name); | 4354 | delete_module(m_name); |
4333 | goto out; | 4355 | goto out; |
4334 | } | 4356 | } |
4335 | 4357 | ||
4336 | if (k_new_syscalls | 4358 | if (k_new_syscalls |
4337 | ? !new_init_module(m_name, f, m_size) | 4359 | ? !new_init_module(m_name, f, m_size) |
4338 | : !old_init_module(m_name, f, m_size)) | 4360 | : !old_init_module(m_name, f, m_size)) |
4339 | { | 4361 | { |
4340 | delete_module(m_name); | 4362 | delete_module(m_name); |
4341 | goto out; | 4363 | goto out; |
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index d48f36ed1..6b4405a44 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -57,6 +57,7 @@ struct mod_list_t { | |||
57 | 57 | ||
58 | static struct dep_t *depend; | 58 | static struct dep_t *depend; |
59 | static int autoclean, show_only, quiet, do_syslog, verbose; | 59 | static int autoclean, show_only, quiet, do_syslog, verbose; |
60 | static int k_version; | ||
60 | 61 | ||
61 | int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) | 62 | int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) |
62 | { | 63 | { |
@@ -116,6 +117,7 @@ static struct dep_t *build_dep ( void ) | |||
116 | char *filename = buffer; | 117 | char *filename = buffer; |
117 | int continuation_line = 0; | 118 | int continuation_line = 0; |
118 | 119 | ||
120 | k_version = 0; | ||
119 | if ( uname ( &un )) | 121 | if ( uname ( &un )) |
120 | return 0; | 122 | return 0; |
121 | 123 | ||
@@ -123,6 +125,9 @@ static struct dep_t *build_dep ( void ) | |||
123 | if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) { | 125 | if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) { |
124 | return 0; | 126 | return 0; |
125 | } | 127 | } |
128 | if (un.release[0] == '2') { | ||
129 | k_version = un.release[2] - '0'; | ||
130 | } | ||
126 | 131 | ||
127 | strcpy ( filename, "/lib/modules/" ); | 132 | strcpy ( filename, "/lib/modules/" ); |
128 | strcat ( filename, un.release ); | 133 | strcat ( filename, un.release ); |
@@ -166,6 +171,12 @@ static struct dep_t *build_dep ( void ) | |||
166 | else | 171 | else |
167 | mods++; | 172 | mods++; |
168 | 173 | ||
174 | #if defined(CONFIG_FEATURE_2_6_MODULES) | ||
175 | if ((k_version > 4) && ( *(col-3) == '.' ) && | ||
176 | ( *(col-2) == 'k' ) && ( *(col-1) == 'o' )) | ||
177 | ext = 3; | ||
178 | else | ||
179 | #endif | ||
169 | if (( *(col-2) == '.' ) && ( *(col-1) == 'o' )) | 180 | if (( *(col-2) == '.' ) && ( *(col-1) == 'o' )) |
170 | ext = 2; | 181 | ext = 2; |
171 | 182 | ||
@@ -215,6 +226,12 @@ static struct dep_t *build_dep ( void ) | |||
215 | else | 226 | else |
216 | deps++; | 227 | deps++; |
217 | 228 | ||
229 | #if defined(CONFIG_FEATURE_2_6_MODULES) | ||
230 | if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' && | ||
231 | ( *end == 'o' )) | ||
232 | ext = 3; | ||
233 | else | ||
234 | #endif | ||
218 | if (( *(end-1) == '.' ) && ( *end == 'o' )) | 235 | if (( *(end-1) == '.' ) && ( *end == 'o' )) |
219 | ext = 2; | 236 | ext = 2; |
220 | 237 | ||
@@ -383,6 +400,13 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t * | |||
383 | 400 | ||
384 | // remove .o extension | 401 | // remove .o extension |
385 | lm = bb_strlen ( mod ); | 402 | lm = bb_strlen ( mod ); |
403 | |||
404 | #if defined(CONFIG_FEATURE_2_6_MODULES) | ||
405 | if ((k_version > 4) && ( mod [lm-3] == '.' ) && | ||
406 | ( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' )) | ||
407 | mod [lm-3] = 0; | ||
408 | else | ||
409 | #endif | ||
386 | if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' )) | 410 | if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' )) |
387 | mod [lm-2] = 0; | 411 | mod [lm-2] = 0; |
388 | 412 | ||