aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>1999-12-21 02:55:11 +0000
committerErik Andersen <andersen@codepoet.org>1999-12-21 02:55:11 +0000
commitd387d01f11c3b9438322c951cd1eac8f29ea6afc (patch)
treeed81f0f41ce4af3de74c5025180ca158f93f5809
parentf294a0288d5f90616c5a096c2236442394112daa (diff)
downloadbusybox-w32-d387d01f11c3b9438322c951cd1eac8f29ea6afc.tar.gz
busybox-w32-d387d01f11c3b9438322c951cd1eac8f29ea6afc.tar.bz2
busybox-w32-d387d01f11c3b9438322c951cd1eac8f29ea6afc.zip
Sync to my local tree
-rw-r--r--Makefile4
-rw-r--r--busybox.def.h4
-rw-r--r--busybox.spec2
-rw-r--r--examples/busybox.spec2
-rw-r--r--insmod.c101
-rw-r--r--modutils/insmod.c101
-rw-r--r--utility.c2
7 files changed, 203 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index b50c645bc..73aa2fc90 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,10 @@ ifdef BB_INIT_RC_EXIT_CMD
84 CFLAGS += -DBB_INIT_CMD_IF_RC_SCRIPT_EXITS=${BB_INIT_RC_EXIT_CMD} 84 CFLAGS += -DBB_INIT_CMD_IF_RC_SCRIPT_EXITS=${BB_INIT_RC_EXIT_CMD}
85endif 85endif
86 86
87ifdef BB_INIT_SCRIPT
88 CFLAGS += -DBB_INIT_SCRIPT=${BB_INIT_SCRIPT}
89endif
90
87all: busybox busybox.links 91all: busybox busybox.links
88 92
89busybox: $(OBJECTS) 93busybox: $(OBJECTS)
diff --git a/busybox.def.h b/busybox.def.h
index 0655d3ec7..3a64c1a54 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -28,7 +28,7 @@
28#define BB_HEAD 28#define BB_HEAD
29#define BB_HOSTNAME 29#define BB_HOSTNAME
30#define BB_INIT 30#define BB_INIT
31#define BB_INSMOD 31//#define BB_INSMOD
32#define BB_KILL 32#define BB_KILL
33#define BB_KLOGD 33#define BB_KLOGD
34//#define BB_LENGTH 34//#define BB_LENGTH
@@ -60,7 +60,7 @@
60#define BB_REBOOT 60#define BB_REBOOT
61#define BB_RM 61#define BB_RM
62#define BB_RMDIR 62#define BB_RMDIR
63#define BB_RMMOD 63//#define BB_RMMOD
64//#define BB_SFDISK 64//#define BB_SFDISK
65#define BB_SED 65#define BB_SED
66#define BB_SLEEP 66#define BB_SLEEP
diff --git a/busybox.spec b/busybox.spec
index a0351a08e..a8520074e 100644
--- a/busybox.spec
+++ b/busybox.spec
@@ -21,7 +21,7 @@ embedded system.
21%setup -q -n %{Name}-%{Version} 21%setup -q -n %{Name}-%{Version}
22 22
23%Build 23%Build
24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" make 24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" BB_INIT_SCRIPT=\"/etc/rc.d/init.d/rcS\" make
25 25
26%Install 26%Install
27rm -rf $RPM_BUILD_ROOT 27rm -rf $RPM_BUILD_ROOT
diff --git a/examples/busybox.spec b/examples/busybox.spec
index a0351a08e..a8520074e 100644
--- a/examples/busybox.spec
+++ b/examples/busybox.spec
@@ -21,7 +21,7 @@ embedded system.
21%setup -q -n %{Name}-%{Version} 21%setup -q -n %{Name}-%{Version}
22 22
23%Build 23%Build
24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" make 24BB_INIT_RC_EXIT_CMD=\"/bin/sh\" BB_INIT_SCRIPT=\"/etc/rc.d/init.d/rcS\" make
25 25
26%Install 26%Install
27rm -rf $RPM_BUILD_ROOT 27rm -rf $RPM_BUILD_ROOT
diff --git a/insmod.c b/insmod.c
index 9a0daa73b..9cb635f40 100644
--- a/insmod.c
+++ b/insmod.c
@@ -29,6 +29,16 @@
29#include <sys/syscall.h> 29#include <sys/syscall.h>
30#include <linux/module.h> 30#include <linux/module.h>
31 31
32#define _PATH_MODULES "/lib/modules"
33
34#warning "Danger Will Robinson, Danger!!!"
35#warning " "
36#warning "insmod is still under construction. Don't use it."
37#warning " "
38#warning " You have been warned!"
39#warning " "
40
41
32/* Some firendly syscalls to cheer everyone's day... */ 42/* Some firendly syscalls to cheer everyone's day... */
33_syscall2(int, init_module, const char *, name, 43_syscall2(int, init_module, const char *, name,
34 const struct module *, info) 44 const struct module *, info)
@@ -57,6 +67,8 @@ _syscall2(unsigned long, create_module, const char *, name, size_t, size)
57#endif 67#endif
58 68
59 69
70static char m_filename[PATH_MAX] = "\0";
71static char m_fullName[PATH_MAX] ="\0";
60static const char insmod_usage[] = 72static const char insmod_usage[] =
61 "insmod [OPTION]... MODULE [symbol=value]...\n\n" 73 "insmod [OPTION]... MODULE [symbol=value]...\n\n"
62 "Loads the specified kernel modules into the kernel.\n\n" 74 "Loads the specified kernel modules into the kernel.\n\n"
@@ -65,14 +77,32 @@ static const char insmod_usage[] =
65 "\t-k\tMake module autoclean-able.\n"; 77 "\t-k\tMake module autoclean-able.\n";
66 78
67 79
80static int findNamedModule(const char *fileName, struct stat* statbuf)
81{
82 if (m_fullName[0]=='\0')
83 return( FALSE);
84 else {
85 char* tmp = strrchr( fileName, '/');
86 if (tmp == NULL)
87 tmp = (char*)fileName;
88 else
89 tmp++;
90 if (check_wildcard_match(tmp, m_fullName) == TRUE) {
91 /* Stop searching if we find a match */
92 memcpy(m_filename, fileName, strlen(fileName));
93 return( FALSE);
94 }
95 }
96 return( TRUE);
97}
98
68 99
69extern int insmod_main(int argc, char **argv) 100extern int insmod_main(int argc, char **argv)
70{ 101{
71 int len; 102 int len;
72 char m_name[PATH_MAX]; 103 char *tmp;
73 char* tmp; 104 char m_name[PATH_MAX] ="\0";
74 105 FILE *fp;
75
76 106
77 if (argc<=1) { 107 if (argc<=1) {
78 usage( insmod_usage); 108 usage( insmod_usage);
@@ -105,9 +135,72 @@ extern int insmod_main(int argc, char **argv)
105 if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') 135 if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o')
106 len -= 2; 136 len -= 2;
107 memcpy(m_name, tmp, len); 137 memcpy(m_name, tmp, len);
138 strcpy(m_fullName, m_name);
139 strcat(m_fullName, ".o");
140
141 /* Get a filedesc for the module */
142 if ((fp = fopen(*argv, "r")) == NULL) {
143 /* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
144 if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE,
145 findNamedModule, findNamedModule) == FALSE) {
146 if ( m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL)) {
147 perror("No module by that name found in " _PATH_MODULES "\n");
148 exit( FALSE);
149 }
150 }
151 } else
152 memcpy(m_filename, *argv, strlen(*argv));
108 153
154
155 fprintf(stderr, "m_filename='%s'\n", m_filename);
109 fprintf(stderr, "m_name='%s'\n", m_name); 156 fprintf(stderr, "m_name='%s'\n", m_name);
110 157
158
159 /* TODO: do something roughtly like this... */
160#if 0
161
162 if ((f = obj_load(fp)) == NULL) {
163 perror("Could not load the module\n");
164 exit( FALSE);
165 }
111 166
167 /* Let the module know about the kernel symbols. */
168 add_kernel_symbols(f);
169
170 if (!create_this_module(f, m_name)) {
171 perror("Could not create the module\n");
172 exit( FALSE);
173 }
174
175 if (!obj_check_undefineds(f, quiet)) {
176 perror("Undefined symbols in the module\n");
177 exit( FALSE);
178 }
179 obj_allocate_commons(f);
180
181 /* Perse the module's arguments */
182 while (argc-- >0 && *(argv++) != '\0') {
183 if (!process_module_arguments(f, argc - optind, argv + optind)) {
184 perror("Undefined symbols in the module\n");
185 exit( FALSE);
186 }
187 }
188
189 /* Find current size of the module */
190 m_size = obj_load_size(f);
191
192
193 errno = 0;
194 m_addr = create_module(m_name, m_size);
195 switch (errno) {
196 /* yada yada */
197 default:
198 perror("create_module: %m");
199
200 }
201
202#endif
203
204 fclose( fp);
112 exit( TRUE); 205 exit( TRUE);
113} 206}
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 9a0daa73b..9cb635f40 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -29,6 +29,16 @@
29#include <sys/syscall.h> 29#include <sys/syscall.h>
30#include <linux/module.h> 30#include <linux/module.h>
31 31
32#define _PATH_MODULES "/lib/modules"
33
34#warning "Danger Will Robinson, Danger!!!"
35#warning " "
36#warning "insmod is still under construction. Don't use it."
37#warning " "
38#warning " You have been warned!"
39#warning " "
40
41
32/* Some firendly syscalls to cheer everyone's day... */ 42/* Some firendly syscalls to cheer everyone's day... */
33_syscall2(int, init_module, const char *, name, 43_syscall2(int, init_module, const char *, name,
34 const struct module *, info) 44 const struct module *, info)
@@ -57,6 +67,8 @@ _syscall2(unsigned long, create_module, const char *, name, size_t, size)
57#endif 67#endif
58 68
59 69
70static char m_filename[PATH_MAX] = "\0";
71static char m_fullName[PATH_MAX] ="\0";
60static const char insmod_usage[] = 72static const char insmod_usage[] =
61 "insmod [OPTION]... MODULE [symbol=value]...\n\n" 73 "insmod [OPTION]... MODULE [symbol=value]...\n\n"
62 "Loads the specified kernel modules into the kernel.\n\n" 74 "Loads the specified kernel modules into the kernel.\n\n"
@@ -65,14 +77,32 @@ static const char insmod_usage[] =
65 "\t-k\tMake module autoclean-able.\n"; 77 "\t-k\tMake module autoclean-able.\n";
66 78
67 79
80static int findNamedModule(const char *fileName, struct stat* statbuf)
81{
82 if (m_fullName[0]=='\0')
83 return( FALSE);
84 else {
85 char* tmp = strrchr( fileName, '/');
86 if (tmp == NULL)
87 tmp = (char*)fileName;
88 else
89 tmp++;
90 if (check_wildcard_match(tmp, m_fullName) == TRUE) {
91 /* Stop searching if we find a match */
92 memcpy(m_filename, fileName, strlen(fileName));
93 return( FALSE);
94 }
95 }
96 return( TRUE);
97}
98
68 99
69extern int insmod_main(int argc, char **argv) 100extern int insmod_main(int argc, char **argv)
70{ 101{
71 int len; 102 int len;
72 char m_name[PATH_MAX]; 103 char *tmp;
73 char* tmp; 104 char m_name[PATH_MAX] ="\0";
74 105 FILE *fp;
75
76 106
77 if (argc<=1) { 107 if (argc<=1) {
78 usage( insmod_usage); 108 usage( insmod_usage);
@@ -105,9 +135,72 @@ extern int insmod_main(int argc, char **argv)
105 if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') 135 if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o')
106 len -= 2; 136 len -= 2;
107 memcpy(m_name, tmp, len); 137 memcpy(m_name, tmp, len);
138 strcpy(m_fullName, m_name);
139 strcat(m_fullName, ".o");
140
141 /* Get a filedesc for the module */
142 if ((fp = fopen(*argv, "r")) == NULL) {
143 /* Hmpf. Could not open it. Search through _PATH_MODULES to find a module named m_name */
144 if (recursiveAction(_PATH_MODULES, TRUE, FALSE, FALSE,
145 findNamedModule, findNamedModule) == FALSE) {
146 if ( m_filename[0] == '\0' || ((fp = fopen(m_filename, "r")) == NULL)) {
147 perror("No module by that name found in " _PATH_MODULES "\n");
148 exit( FALSE);
149 }
150 }
151 } else
152 memcpy(m_filename, *argv, strlen(*argv));
108 153
154
155 fprintf(stderr, "m_filename='%s'\n", m_filename);
109 fprintf(stderr, "m_name='%s'\n", m_name); 156 fprintf(stderr, "m_name='%s'\n", m_name);
110 157
158
159 /* TODO: do something roughtly like this... */
160#if 0
161
162 if ((f = obj_load(fp)) == NULL) {
163 perror("Could not load the module\n");
164 exit( FALSE);
165 }
111 166
167 /* Let the module know about the kernel symbols. */
168 add_kernel_symbols(f);
169
170 if (!create_this_module(f, m_name)) {
171 perror("Could not create the module\n");
172 exit( FALSE);
173 }
174
175 if (!obj_check_undefineds(f, quiet)) {
176 perror("Undefined symbols in the module\n");
177 exit( FALSE);
178 }
179 obj_allocate_commons(f);
180
181 /* Perse the module's arguments */
182 while (argc-- >0 && *(argv++) != '\0') {
183 if (!process_module_arguments(f, argc - optind, argv + optind)) {
184 perror("Undefined symbols in the module\n");
185 exit( FALSE);
186 }
187 }
188
189 /* Find current size of the module */
190 m_size = obj_load_size(f);
191
192
193 errno = 0;
194 m_addr = create_module(m_name, m_size);
195 switch (errno) {
196 /* yada yada */
197 default:
198 perror("create_module: %m");
199
200 }
201
202#endif
203
204 fclose( fp);
112 exit( TRUE); 205 exit( TRUE);
113} 206}
diff --git a/utility.c b/utility.c
index e5c177ad5..d01be9c98 100644
--- a/utility.c
+++ b/utility.c
@@ -378,7 +378,7 @@ int fullRead(int fd, char *buf, int len)
378#endif 378#endif
379 379
380 380
381#if defined (BB_CHOWN) || defined (BB_CP) || defined (BB_FIND) || defined (BB_LS) 381#if defined (BB_CHOWN) || defined (BB_CP) || defined (BB_FIND) || defined (BB_LS) || defined (BB_INSMOD)
382/* 382/*
383 * Walk down all the directories under the specified 383 * Walk down all the directories under the specified
384 * location, and do something (something specified 384 * location, and do something (something specified