aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Config.h30
-rw-r--r--applets/busybox.c63
-rw-r--r--busybox.c63
-rw-r--r--coreutils/ls.c8
-rw-r--r--insmod.c22
-rw-r--r--ls.c8
-rw-r--r--lsmod.c10
-rw-r--r--modutils/insmod.c22
-rw-r--r--modutils/lsmod.c10
-rwxr-xr-xtests/busybox.REGRESS.shbin4068 -> 4078 bytes
-rw-r--r--utility.c6
11 files changed, 115 insertions, 127 deletions
diff --git a/Config.h b/Config.h
index 22882b6c2..1df72f301 100644
--- a/Config.h
+++ b/Config.h
@@ -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
-//
-// 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 post 2.1 kernels
+//#define BB_FEATURE_NEW_MODULE_INTERFACE
+//
+// 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
diff --git a/applets/busybox.c b/applets/busybox.c
index 0439fb566..5eb9dfa64 100644
--- a/applets/busybox.c
+++ b/applets/busybox.c
@@ -89,37 +89,6 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
- applet_name = "busybox";
-
-#ifdef BB_FEATURE_INSTALLER
- /*
- * This style of argument parsing doesn't scale well
- * in the event that busybox starts wanting more --options.
- * If someone has a cleaner approach, by all means implement it.
- */
- if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
- int use_symbolic_links = 0;
- int rc = 0;
- char *busybox;
-
- /* to use symlinks, or not to use symlinks... */
- if (argc > 2) {
- if ((strcmp(argv[2], "-s") == 0)) {
- use_symbolic_links = 1;
- }
- }
-
- /* link */
- busybox = busybox_fullpath();
- if (busybox) {
- install_links(busybox, use_symbolic_links);
- free(busybox);
- } else {
- rc = 1;
- }
- return rc;
- }
-#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
@@ -144,7 +113,7 @@ int main(int argc, char **argv)
exit((*(applet->main)) (argc, argv));
}
- return(busybox_main(argc, argv));
+ error_msg_and_die("applet not found\n");
}
@@ -152,6 +121,36 @@ int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
+#ifdef BB_FEATURE_INSTALLER
+ /*
+ * This style of argument parsing doesn't scale well
+ * in the event that busybox starts wanting more --options.
+ * If someone has a cleaner approach, by all means implement it.
+ */
+ if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
+ int use_symbolic_links = 0;
+ int rc = 0;
+ char *busybox;
+
+ /* to use symlinks, or not to use symlinks... */
+ if (argc > 2) {
+ if ((strcmp(argv[2], "-s") == 0)) {
+ use_symbolic_links = 1;
+ }
+ }
+
+ /* link */
+ busybox = busybox_fullpath();
+ if (busybox) {
+ install_links(busybox, use_symbolic_links);
+ free(busybox);
+ } else {
+ rc = 1;
+ }
+ return rc;
+ }
+#endif /* BB_FEATURE_INSTALLER */
+
argc--;
/* If we've already been here once, exit now */
diff --git a/busybox.c b/busybox.c
index 0439fb566..5eb9dfa64 100644
--- a/busybox.c
+++ b/busybox.c
@@ -89,37 +89,6 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
- applet_name = "busybox";
-
-#ifdef BB_FEATURE_INSTALLER
- /*
- * This style of argument parsing doesn't scale well
- * in the event that busybox starts wanting more --options.
- * If someone has a cleaner approach, by all means implement it.
- */
- if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
- int use_symbolic_links = 0;
- int rc = 0;
- char *busybox;
-
- /* to use symlinks, or not to use symlinks... */
- if (argc > 2) {
- if ((strcmp(argv[2], "-s") == 0)) {
- use_symbolic_links = 1;
- }
- }
-
- /* link */
- busybox = busybox_fullpath();
- if (busybox) {
- install_links(busybox, use_symbolic_links);
- free(busybox);
- } else {
- rc = 1;
- }
- return rc;
- }
-#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
@@ -144,7 +113,7 @@ int main(int argc, char **argv)
exit((*(applet->main)) (argc, argv));
}
- return(busybox_main(argc, argv));
+ error_msg_and_die("applet not found\n");
}
@@ -152,6 +121,36 @@ int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
+#ifdef BB_FEATURE_INSTALLER
+ /*
+ * This style of argument parsing doesn't scale well
+ * in the event that busybox starts wanting more --options.
+ * If someone has a cleaner approach, by all means implement it.
+ */
+ if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
+ int use_symbolic_links = 0;
+ int rc = 0;
+ char *busybox;
+
+ /* to use symlinks, or not to use symlinks... */
+ if (argc > 2) {
+ if ((strcmp(argv[2], "-s") == 0)) {
+ use_symbolic_links = 1;
+ }
+ }
+
+ /* link */
+ busybox = busybox_fullpath();
+ if (busybox) {
+ install_links(busybox, use_symbolic_links);
+ free(busybox);
+ } else {
+ rc = 1;
+ }
+ return rc;
+ }
+#endif /* BB_FEATURE_INSTALLER */
+
argc--;
/* If we've already been here once, exit now */
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 080768027..64e5bf828 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -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 */
diff --git a/insmod.c b/insmod.c
index a134fea87..e52da91e4 100644
--- a/insmod.c
+++ b/insmod.c
@@ -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();
diff --git a/ls.c b/ls.c
index 080768027..64e5bf828 100644
--- a/ls.c
+++ b/ls.c
@@ -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 */
diff --git a/lsmod.c b/lsmod.c
index 586920d63..41575585f 100644
--- a/lsmod.c
+++ b/lsmod.c
@@ -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*/
diff --git a/modutils/insmod.c b/modutils/insmod.c
index a134fea87..e52da91e4 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -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();
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 586920d63..41575585f 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -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*/
diff --git a/tests/busybox.REGRESS.sh b/tests/busybox.REGRESS.sh
index a5a31ad77..00deaf26f 100755
--- a/tests/busybox.REGRESS.sh
+++ b/tests/busybox.REGRESS.sh
Binary files differ
diff --git a/utility.c b/utility.c
index 6b637de04..50bf507b8 100644
--- a/utility.c
+++ b/utility.c
@@ -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;