more bugs fixed -- found doing regression testing

-Erik
This commit is contained in:
Eric Andersen 2001-01-24 23:34:48 +00:00
parent 26439a2991
commit f5d5e77321
11 changed files with 114 additions and 126 deletions

View File

@ -258,17 +258,11 @@
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// You must enable one or both of these features
// Support modules status from pre 2.1 kernels
//#define BB_FEATURE_LSMOD_OLD_KERNEL
// Support modules status from kernel versions after 2.1.18
#define BB_FEATURE_LSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
@ -308,7 +302,9 @@
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
#endif
#else
#undef BB_MTAB
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
@ -320,12 +316,14 @@
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#if defined BB_FEATURE_LINUXRC || defined BB_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#ifndef BB_LINUXRC
#define BB_LINUXRC
#endif
#endif
//
#ifdef BB_GZIP
#ifndef BB_GUNZIP
@ -369,8 +367,8 @@
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#if defined BB_INSMOD || defined BB_LSMOD
#ifndef BB_FEATURE_NEW_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif

View File

@ -89,7 +89,37 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
applet_name = "busybox";
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
@ -121,37 +151,6 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
argc--;
/* If we've already been here once, exit now */

View File

@ -89,7 +89,37 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
applet_name = "busybox";
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
@ -121,37 +151,6 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
argc--;
/* If we've already been here once, exit now */

View File

@ -171,6 +171,8 @@ static unsigned short column = 0;
static unsigned short terminal_width;
static unsigned short column_width;
static unsigned short tabstops;
#else
# define column_width COLUMN_WIDTH
#endif
static int status = EXIT_SUCCESS;
@ -236,7 +238,7 @@ static void nexttabstop( void )
column++;
}
}
nexttab= column + column_width + COLUMN_GAP ;
nexttab= column + column_width + COLUMN_GAP;
}
/*----------------------------------------------------------------------*/
@ -429,8 +431,10 @@ void showfiles(struct dnode **dn, int nfiles)
;
if (column_width < len) column_width= len;
}
#endif
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
#else
ncols= TERMINAL_WIDTH;
#endif
switch (style_fmt) {
case STYLE_LONG: /* one record per line, extended info */
case STYLE_SINGLE: /* one record per line */

View File

@ -78,7 +78,7 @@
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.37 2001/01/24 19:07:09 andersen Exp $"
#ident "$Id: insmod.c,v 1.38 2001/01/24 23:34:48 andersen Exp $"
/* 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
@ -284,7 +284,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.37 2001/01/24 19:07:09 andersen Exp $"
#ident "$Id: insmod.c,v 1.38 2001/01/24 23:34:48 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
@ -519,10 +519,6 @@ int arch_init_module (struct obj_file *f, struct new_module *);
#define _PATH_MODULES "/lib/modules"
static const int STRVERSIONLEN = 32;
#if !defined(BB_FEATURE_INSMOD_NEW_KERNEL) && !defined(BB_FEATURE_INSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_INSMOD_NEW_KERNEL or BB_FEATURE_INSMOD_OLD_KERNEL defined"
#endif
/*======================================================================*/
int flag_force_load = 0;
@ -615,7 +611,7 @@ extern int delete_module(const char *);
-- Bryan Rittmeyer <bryan@ixiacom.com> */
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ks)
#endif
@ -1549,7 +1545,7 @@ old_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
/* Fetch all the symbols and divvy them up as appropriate for the modules. */
@ -1757,7 +1753,7 @@ old_init_module(const char *m_name, struct obj_file *f,
#define old_create_mod_use_count(x) TRUE
#define old_init_module(x, y, z) TRUE
#endif /* BB_FEATURE_INSMOD_OLD_KERNEL */
#endif /* BB_FEATURE_OLD_MODULE_INTERFACE */
@ -2036,7 +2032,7 @@ new_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
#ifdef BB_FEATURE_INSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
/* Fetch the loaded modules, and all currently exported symbols. */
@ -2310,7 +2306,7 @@ new_init_module(const char *m_name, struct obj_file *f,
#define new_create_module_ksymtab(x)
#define query_module(v, w, x, y, z) -1
#endif /* BB_FEATURE_INSMOD_NEW_KERNEL */
#endif /* BB_FEATURE_NEW_MODULE_INTERFACE */
/*======================================================================*/
@ -2997,7 +2993,7 @@ extern int insmod_main( int argc, char **argv)
k_new_syscalls = !query_module(NULL, 0, NULL, 0, NULL);
if (k_new_syscalls) {
#ifdef BB_FEATURE_INSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
if (!new_get_kernel_symbols())
goto out;
k_crcs = new_is_kernel_checksummed();
@ -3006,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
#endif
} else {
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
if (!old_get_kernel_symbols(m_name))
goto out;
k_crcs = old_is_kernel_checksummed();

8
ls.c
View File

@ -171,6 +171,8 @@ static unsigned short column = 0;
static unsigned short terminal_width;
static unsigned short column_width;
static unsigned short tabstops;
#else
# define column_width COLUMN_WIDTH
#endif
static int status = EXIT_SUCCESS;
@ -236,7 +238,7 @@ static void nexttabstop( void )
column++;
}
}
nexttab= column + column_width + COLUMN_GAP ;
nexttab= column + column_width + COLUMN_GAP;
}
/*----------------------------------------------------------------------*/
@ -429,8 +431,10 @@ void showfiles(struct dnode **dn, int nfiles)
;
if (column_width < len) column_width= len;
}
#endif
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
#else
ncols= TERMINAL_WIDTH;
#endif
switch (style_fmt) {
case STYLE_LONG: /* one record per line, extended info */
case STYLE_SINGLE: /* one record per line */

10
lsmod.c
View File

@ -40,11 +40,7 @@
#if !defined(BB_FEATURE_LSMOD_NEW_KERNEL) && !defined(BB_FEATURE_LSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_LSMOD_NEW_KERNEL or BB_FEATURE_LSMOD_OLD_KERNEL defined"
#endif
#ifdef BB_FEATURE_LSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
struct module_info
{
@ -132,7 +128,7 @@ extern int lsmod_main(int argc, char **argv)
return( 0);
}
#else /*BB_FEATURE_LSMOD_OLD_KERNEL*/
#else /*BB_FEATURE_OLD_MODULE_INTERFACE*/
#if ! defined BB_FEATURE_USE_PROCFS
#error Sorry, I depend on the /proc filesystem right now.
@ -157,4 +153,4 @@ extern int lsmod_main(int argc, char **argv)
return 1;
}
#endif /*BB_FEATURE_LSMOD_OLD_KERNEL*/
#endif /*BB_FEATURE_OLD_MODULE_INTERFACE*/

View File

@ -78,7 +78,7 @@
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.37 2001/01/24 19:07:09 andersen Exp $"
#ident "$Id: insmod.c,v 1.38 2001/01/24 23:34:48 andersen Exp $"
/* 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
@ -284,7 +284,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.37 2001/01/24 19:07:09 andersen Exp $"
#ident "$Id: insmod.c,v 1.38 2001/01/24 23:34:48 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
@ -519,10 +519,6 @@ int arch_init_module (struct obj_file *f, struct new_module *);
#define _PATH_MODULES "/lib/modules"
static const int STRVERSIONLEN = 32;
#if !defined(BB_FEATURE_INSMOD_NEW_KERNEL) && !defined(BB_FEATURE_INSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_INSMOD_NEW_KERNEL or BB_FEATURE_INSMOD_OLD_KERNEL defined"
#endif
/*======================================================================*/
int flag_force_load = 0;
@ -615,7 +611,7 @@ extern int delete_module(const char *);
-- Bryan Rittmeyer <bryan@ixiacom.com> */
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
_syscall1(int, get_kernel_syms, struct old_kernel_sym *, ks)
#endif
@ -1549,7 +1545,7 @@ old_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
/* Fetch all the symbols and divvy them up as appropriate for the modules. */
@ -1757,7 +1753,7 @@ old_init_module(const char *m_name, struct obj_file *f,
#define old_create_mod_use_count(x) TRUE
#define old_init_module(x, y, z) TRUE
#endif /* BB_FEATURE_INSMOD_OLD_KERNEL */
#endif /* BB_FEATURE_OLD_MODULE_INTERFACE */
@ -2036,7 +2032,7 @@ new_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
#ifdef BB_FEATURE_INSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
/* Fetch the loaded modules, and all currently exported symbols. */
@ -2310,7 +2306,7 @@ new_init_module(const char *m_name, struct obj_file *f,
#define new_create_module_ksymtab(x)
#define query_module(v, w, x, y, z) -1
#endif /* BB_FEATURE_INSMOD_NEW_KERNEL */
#endif /* BB_FEATURE_NEW_MODULE_INTERFACE */
/*======================================================================*/
@ -2997,7 +2993,7 @@ extern int insmod_main( int argc, char **argv)
k_new_syscalls = !query_module(NULL, 0, NULL, 0, NULL);
if (k_new_syscalls) {
#ifdef BB_FEATURE_INSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
if (!new_get_kernel_symbols())
goto out;
k_crcs = new_is_kernel_checksummed();
@ -3006,7 +3002,7 @@ extern int insmod_main( int argc, char **argv)
goto out;
#endif
} else {
#ifdef BB_FEATURE_INSMOD_OLD_KERNEL
#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
if (!old_get_kernel_symbols(m_name))
goto out;
k_crcs = old_is_kernel_checksummed();

View File

@ -40,11 +40,7 @@
#if !defined(BB_FEATURE_LSMOD_NEW_KERNEL) && !defined(BB_FEATURE_LSMOD_OLD_KERNEL)
#error "Must have ether BB_FEATURE_LSMOD_NEW_KERNEL or BB_FEATURE_LSMOD_OLD_KERNEL defined"
#endif
#ifdef BB_FEATURE_LSMOD_NEW_KERNEL
#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
struct module_info
{
@ -132,7 +128,7 @@ extern int lsmod_main(int argc, char **argv)
return( 0);
}
#else /*BB_FEATURE_LSMOD_OLD_KERNEL*/
#else /*BB_FEATURE_OLD_MODULE_INTERFACE*/
#if ! defined BB_FEATURE_USE_PROCFS
#error Sorry, I depend on the /proc filesystem right now.
@ -157,4 +153,4 @@ extern int lsmod_main(int argc, char **argv)
return 1;
}
#endif /*BB_FEATURE_LSMOD_OLD_KERNEL*/
#endif /*BB_FEATURE_OLD_MODULE_INTERFACE*/

Binary file not shown.

View File

@ -137,7 +137,7 @@ extern void perror_msg_and_die(const char *s, ...)
exit(EXIT_FAILURE);
}
#if defined BB_INIT || defined BB_MKSWAP || defined BB_MOUNT
#if defined BB_INIT || defined BB_MKSWAP || defined BB_MOUNT || defined BB_NFSMOUNT
/* Returns kernel version encoded as major*65536 + minor*256 + patch,
* so, for example, to check if the kernel is greater than 2.2.11:
* if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> }
@ -1386,7 +1386,7 @@ extern void *xcalloc(size_t nmemb, size_t size)
}
#endif
#if defined BB_FEATURE_NFSMOUNT || defined BB_LS || defined BB_SH || defined BB_WGET
#if defined BB_NFSMOUNT || defined BB_LS || defined BB_SH || defined BB_WGET
# ifndef DMALLOC
extern char * xstrdup (const char *s) {
char *t;
@ -1404,7 +1404,7 @@ extern char * xstrdup (const char *s) {
# endif
#endif
#if defined BB_FEATURE_NFSMOUNT
#if defined BB_NFSMOUNT
extern char * xstrndup (const char *s, int n) {
char *t;