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
This commit is contained in:
parent
514aeabc36
commit
03d8091859
@ -282,7 +282,7 @@ extern int insmod_ng_main( int argc, char **argv);
|
|||||||
#ifndef MODUTILS_MODULE_H
|
#ifndef MODUTILS_MODULE_H
|
||||||
static const int MODUTILS_MODULE_H = 1;
|
static const int MODUTILS_MODULE_H = 1;
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.107 2003/12/11 01:42:13 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.108 2003/12/19 21:04:19 andersen Exp $"
|
||||||
|
|
||||||
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
/* This file contains the structures used by the 2.0 and 2.1 kernels.
|
||||||
We do not use the kernel headers directly because we do not wish
|
We do not use the kernel headers directly because we do not wish
|
||||||
@ -503,7 +503,7 @@ int delete_module(const char *);
|
|||||||
#ifndef MODUTILS_OBJ_H
|
#ifndef MODUTILS_OBJ_H
|
||||||
static const int MODUTILS_OBJ_H = 1;
|
static const int MODUTILS_OBJ_H = 1;
|
||||||
|
|
||||||
#ident "$Id: insmod.c,v 1.107 2003/12/11 01:42:13 andersen Exp $"
|
#ident "$Id: insmod.c,v 1.108 2003/12/19 21:04:19 andersen Exp $"
|
||||||
|
|
||||||
/* The relocatable object is manipulated using elfin types. */
|
/* The relocatable object is manipulated using elfin types. */
|
||||||
|
|
||||||
@ -4050,6 +4050,8 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
|
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
|
||||||
int flag_print_load_map = 0;
|
int flag_print_load_map = 0;
|
||||||
#endif
|
#endif
|
||||||
|
int k_version = 0;
|
||||||
|
struct utsname myuname;
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
|
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
|
||||||
@ -4098,7 +4100,7 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[optind] == NULL) {
|
if (argv[optind] == NULL) {
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
@ -4108,12 +4110,33 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
tmp = basename(tmp1);
|
tmp = basename(tmp1);
|
||||||
len = strlen(tmp);
|
len = strlen(tmp);
|
||||||
|
|
||||||
|
if (uname(&myuname) == 0) {
|
||||||
|
if (myuname.release[0] == '2') {
|
||||||
|
k_version = myuname.release[2] - '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
|
if (k_version > 4 && len > 3 && tmp[len - 3] == '.' &&
|
||||||
|
tmp[len - 2] == 'k' && tmp[len - 1] == 'o') {
|
||||||
|
len-=3;
|
||||||
|
tmp[len] = '\0';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
|
if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
|
||||||
len-=2;
|
len-=2;
|
||||||
tmp[len] = '\0';
|
tmp[len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
|
if (k_version > 4)
|
||||||
|
bb_xasprintf(&m_fullName, "%s.ko", tmp);
|
||||||
|
else
|
||||||
|
#else
|
||||||
bb_xasprintf(&m_fullName, "%s.o", tmp);
|
bb_xasprintf(&m_fullName, "%s.o", tmp);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!m_name) {
|
if (!m_name) {
|
||||||
m_name = tmp;
|
m_name = tmp;
|
||||||
@ -4125,28 +4148,26 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
/* Get a filedesc for the module. Check we we have a complete path */
|
/* Get a filedesc for the module. Check we we have a complete path */
|
||||||
if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
|
if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
|
||||||
(fp = fopen(argv[optind], "r")) == NULL) {
|
(fp = fopen(argv[optind], "r")) == NULL) {
|
||||||
struct utsname myuname;
|
|
||||||
|
|
||||||
/* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
|
/* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
|
||||||
* but do not error out yet if we fail to find it... */
|
* but do not error out yet if we fail to find it... */
|
||||||
if (uname(&myuname) == 0) {
|
if (k_version) { /* uname succeedd */
|
||||||
char *module_dir;
|
char *module_dir;
|
||||||
char *tmdn;
|
char *tmdn;
|
||||||
char real_module_dir[FILENAME_MAX];
|
char real_module_dir[FILENAME_MAX];
|
||||||
|
|
||||||
tmdn = concat_path_file(_PATH_MODULES, myuname.release);
|
tmdn = concat_path_file(_PATH_MODULES, myuname.release);
|
||||||
/* Jump through hoops in case /lib/modules/`uname -r`
|
/* Jump through hoops in case /lib/modules/`uname -r`
|
||||||
* is a symlink. We do not want recursive_action to
|
* is a symlink. We do not want recursive_action to
|
||||||
* follow symlinks, but we do want to follow the
|
* follow symlinks, but we do want to follow the
|
||||||
* /lib/modules/`uname -r` dir, So resolve it ourselves
|
* /lib/modules/`uname -r` dir, So resolve it ourselves
|
||||||
* if it is a link... */
|
* if it is a link... */
|
||||||
if (realpath (tmdn, real_module_dir) == NULL)
|
if (realpath (tmdn, real_module_dir) == NULL)
|
||||||
module_dir = tmdn;
|
module_dir = tmdn;
|
||||||
else
|
else
|
||||||
module_dir = real_module_dir;
|
module_dir = real_module_dir;
|
||||||
recursive_action(module_dir, TRUE, FALSE, FALSE,
|
recursive_action(module_dir, TRUE, FALSE, FALSE,
|
||||||
check_module_name_match, 0, m_fullName);
|
check_module_name_match, 0, m_fullName);
|
||||||
free(tmdn);
|
free(tmdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we have found anything yet */
|
/* Check if we have found anything yet */
|
||||||
@ -4154,17 +4175,17 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char module_dir[FILENAME_MAX];
|
char module_dir[FILENAME_MAX];
|
||||||
|
|
||||||
free(m_filename);
|
free(m_filename);
|
||||||
m_filename = 0;
|
m_filename = 0;
|
||||||
if (realpath (_PATH_MODULES, module_dir) == NULL)
|
if (realpath (_PATH_MODULES, module_dir) == NULL)
|
||||||
strcpy(module_dir, _PATH_MODULES);
|
strcpy(module_dir, _PATH_MODULES);
|
||||||
/* No module found under /lib/modules/`uname -r`, this
|
/* No module found under /lib/modules/`uname -r`, this
|
||||||
* time cast the net a bit wider. Search /lib/modules/ */
|
* time cast the net a bit wider. Search /lib/modules/ */
|
||||||
if (! recursive_action(module_dir, TRUE, FALSE, FALSE,
|
if (! recursive_action(module_dir, TRUE, FALSE, FALSE,
|
||||||
check_module_name_match, 0, m_fullName))
|
check_module_name_match, 0, m_fullName))
|
||||||
{
|
{
|
||||||
if (m_filename == 0
|
if (m_filename == 0
|
||||||
|| ((fp = fopen(m_filename, "r")) == NULL))
|
|| ((fp = fopen(m_filename, "r")) == NULL))
|
||||||
{
|
{
|
||||||
bb_error_msg("%s: no module by that name found", m_fullName);
|
bb_error_msg("%s: no module by that name found", m_fullName);
|
||||||
goto out;
|
goto out;
|
||||||
@ -4172,17 +4193,18 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
} else
|
} else
|
||||||
bb_error_msg_and_die("%s: no module by that name found", m_fullName);
|
bb_error_msg_and_die("%s: no module by that name found", m_fullName);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
m_filename = bb_xstrdup(argv[optind]);
|
m_filename = bb_xstrdup(argv[optind]);
|
||||||
|
|
||||||
printf("Using %s\n", m_filename);
|
printf("Using %s\n", m_filename);
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_2_6_MODULES
|
#ifdef CONFIG_FEATURE_2_6_MODULES
|
||||||
if (create_module(NULL, 0) < 0 && errno == ENOSYS) {
|
if (k_version > 4)
|
||||||
|
{
|
||||||
optind--;
|
optind--;
|
||||||
argv[optind] = m_filename;
|
argv[optind + 1] = m_filename;
|
||||||
return insmod_ng_main(argc - optind, argv + optind);
|
return insmod_ng_main(argc - optind, argv + optind);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((f = obj_load(fp, LOADBITS)) == NULL)
|
if ((f = obj_load(fp, LOADBITS)) == NULL)
|
||||||
@ -4264,9 +4286,9 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
|
|
||||||
/* Allocate common symbols, symbol tables, and string tables. */
|
/* Allocate common symbols, symbol tables, and string tables. */
|
||||||
|
|
||||||
if (k_new_syscalls
|
if (k_new_syscalls
|
||||||
? !new_create_this_module(f, m_name)
|
? !new_create_this_module(f, m_name)
|
||||||
: !old_create_mod_use_count(f))
|
: !old_create_mod_use_count(f))
|
||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -4282,8 +4304,8 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
if (m_has_modinfo
|
if (m_has_modinfo
|
||||||
? !new_process_module_arguments(f, argc - optind, argv + optind)
|
? !new_process_module_arguments(f, argc - optind, argv + optind)
|
||||||
: !old_process_module_arguments(f, argc - optind, argv + optind))
|
: !old_process_module_arguments(f, argc - optind, argv + optind))
|
||||||
{
|
{
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -4326,16 +4348,16 @@ extern int insmod_main( int argc, char **argv)
|
|||||||
delete_module(m_name);
|
delete_module(m_name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!obj_relocate(f, m_addr)) {
|
if (!obj_relocate(f, m_addr)) {
|
||||||
delete_module(m_name);
|
delete_module(m_name);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k_new_syscalls
|
if (k_new_syscalls
|
||||||
? !new_init_module(m_name, f, m_size)
|
? !new_init_module(m_name, f, m_size)
|
||||||
: !old_init_module(m_name, f, m_size))
|
: !old_init_module(m_name, f, m_size))
|
||||||
{
|
{
|
||||||
delete_module(m_name);
|
delete_module(m_name);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -57,6 +57,7 @@ struct mod_list_t {
|
|||||||
|
|
||||||
static struct dep_t *depend;
|
static struct dep_t *depend;
|
||||||
static int autoclean, show_only, quiet, do_syslog, verbose;
|
static int autoclean, show_only, quiet, do_syslog, verbose;
|
||||||
|
static int k_version;
|
||||||
|
|
||||||
int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
|
int parse_tag_value ( char *buffer, char **ptag, char **pvalue )
|
||||||
{
|
{
|
||||||
@ -116,6 +117,7 @@ static struct dep_t *build_dep ( void )
|
|||||||
char *filename = buffer;
|
char *filename = buffer;
|
||||||
int continuation_line = 0;
|
int continuation_line = 0;
|
||||||
|
|
||||||
|
k_version = 0;
|
||||||
if ( uname ( &un ))
|
if ( uname ( &un ))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -123,6 +125,9 @@ static struct dep_t *build_dep ( void )
|
|||||||
if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) {
|
if ( bb_strlen ( un.release ) > ( sizeof( buffer ) - 64 )) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (un.release[0] == '2') {
|
||||||
|
k_version = un.release[2] - '0';
|
||||||
|
}
|
||||||
|
|
||||||
strcpy ( filename, "/lib/modules/" );
|
strcpy ( filename, "/lib/modules/" );
|
||||||
strcat ( filename, un.release );
|
strcat ( filename, un.release );
|
||||||
@ -166,6 +171,12 @@ static struct dep_t *build_dep ( void )
|
|||||||
else
|
else
|
||||||
mods++;
|
mods++;
|
||||||
|
|
||||||
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
|
if ((k_version > 4) && ( *(col-3) == '.' ) &&
|
||||||
|
( *(col-2) == 'k' ) && ( *(col-1) == 'o' ))
|
||||||
|
ext = 3;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
|
if (( *(col-2) == '.' ) && ( *(col-1) == 'o' ))
|
||||||
ext = 2;
|
ext = 2;
|
||||||
|
|
||||||
@ -215,6 +226,12 @@ static struct dep_t *build_dep ( void )
|
|||||||
else
|
else
|
||||||
deps++;
|
deps++;
|
||||||
|
|
||||||
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
|
if ((k_version > 4) && ( *(end-2) == '.' ) && *(end-1) == 'k' &&
|
||||||
|
( *end == 'o' ))
|
||||||
|
ext = 3;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (( *(end-1) == '.' ) && ( *end == 'o' ))
|
if (( *(end-1) == '.' ) && ( *end == 'o' ))
|
||||||
ext = 2;
|
ext = 2;
|
||||||
|
|
||||||
@ -383,6 +400,13 @@ static void check_dep ( char *mod, struct mod_list_t **head, struct mod_list_t *
|
|||||||
|
|
||||||
// remove .o extension
|
// remove .o extension
|
||||||
lm = bb_strlen ( mod );
|
lm = bb_strlen ( mod );
|
||||||
|
|
||||||
|
#if defined(CONFIG_FEATURE_2_6_MODULES)
|
||||||
|
if ((k_version > 4) && ( mod [lm-3] == '.' ) &&
|
||||||
|
( mod [lm-2] == 'k' ) && ( mod [lm-1] == 'o' ))
|
||||||
|
mod [lm-3] = 0;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
|
if (( mod [lm-2] == '.' ) && ( mod [lm-1] == 'o' ))
|
||||||
mod [lm-2] = 0;
|
mod [lm-2] = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user