diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-14 22:16:57 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-14 22:16:57 +0000 |
commit | 3c163822d88105450806fdb6a29fdfc2511267d1 (patch) | |
tree | 4c67645bbc6677ad2217da3cdf6c0a748e0ca88d /init | |
parent | 2c1030177e0a6f849ba557400e3e4867de455ce9 (diff) | |
download | busybox-w32-3c163822d88105450806fdb6a29fdfc2511267d1.tar.gz busybox-w32-3c163822d88105450806fdb6a29fdfc2511267d1.tar.bz2 busybox-w32-3c163822d88105450806fdb6a29fdfc2511267d1.zip |
Fixed cp -[aR] and some other stuf.
Diffstat (limited to 'init')
-rw-r--r-- | init/init.c | 128 |
1 files changed, 66 insertions, 62 deletions
diff --git a/init/init.c b/init/init.c index 2860272f9..19cbec130 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -66,11 +66,8 @@ waitfor(int pid) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | static int | 68 | static int |
69 | run( | 69 | run(const char* program, const char* const* arguments, |
70 | const char * program | 70 | const char* terminal, int get_enter) |
71 | ,const char * const * arguments | ||
72 | ,const char * terminal | ||
73 | ,int get_enter) | ||
74 | { | 71 | { |
75 | static const char control_characters[] = { | 72 | static const char control_characters[] = { |
76 | '\003', | 73 | '\003', |
@@ -137,7 +134,8 @@ run( | |||
137 | * before the user wants it. This is critical if swap is not | 134 | * before the user wants it. This is critical if swap is not |
138 | * enabled and the system has low memory. Generally this will | 135 | * enabled and the system has low memory. Generally this will |
139 | * be run on the second virtual console, and the first will | 136 | * be run on the second virtual console, and the first will |
140 | * be allowed to start a shell or the installation system. | 137 | * be allowed to start a shell or whatever an init script |
138 | * specifies. | ||
141 | */ | 139 | */ |
142 | char c; | 140 | char c; |
143 | write(1, press_enter, sizeof(press_enter) - 1); | 141 | write(1, press_enter, sizeof(press_enter) - 1); |
@@ -246,26 +244,49 @@ exit_signal(int sig) | |||
246 | } | 244 | } |
247 | 245 | ||
248 | void | 246 | void |
249 | configure_terminals( int serial_cons ); | 247 | configure_terminals( int serial_cons ) |
248 | { | ||
249 | //struct stat statbuf; | ||
250 | char *tty; | ||
251 | |||
252 | switch (serial_cons) { | ||
253 | case 1: | ||
254 | strcpy( console, "/dev/ttyS0" ); | ||
255 | break; | ||
256 | case 2: | ||
257 | strcpy( console, "/dev/ttyS1" ); | ||
258 | break; | ||
259 | default: | ||
260 | tty = ttyname(0); | ||
261 | if (tty) { | ||
262 | strcpy( console, tty ); | ||
263 | if (!strncmp( tty, "/dev/ttyS", 9 )) | ||
264 | serial_cons=1; | ||
265 | } | ||
266 | else | ||
267 | /* falls back to /dev/tty1 if an error occurs */ | ||
268 | strcpy( console, default_console ); | ||
269 | } | ||
270 | if (!first_terminal) | ||
271 | first_terminal = console; | ||
272 | if (serial_cons && !strncmp(term_ptr,"TERM=linux",10)) | ||
273 | term_ptr = "TERM=vt100"; | ||
274 | } | ||
250 | 275 | ||
251 | extern int | 276 | extern int |
252 | init_main(int argc, char * * argv) | 277 | init_main(int argc, char * * argv) |
253 | { | 278 | { |
254 | static const char * const rc = "etc/rc"; | 279 | static const char* const rc = "etc/rc"; |
255 | const char * arguments[100]; | 280 | const char * arguments[100]; |
256 | int run_rc = 1; | 281 | int run_rc = 1; |
257 | int j; | 282 | int j; |
258 | int pid1 = 0; | 283 | int pid1 = 0; |
259 | int pid2 = 0; | 284 | int pid2 = 0; |
260 | int create_swap= -1; | 285 | int create_swap= -1; |
261 | struct stat statbuf; | 286 | struct stat statbuf; |
262 | #ifndef INCLUDE_DINSTALL | 287 | const char * tty_commands[2] = { "bin/sh", "bin/sh"}; |
263 | const char * tty_commands[2] = { "bin/sh", "bin/sh"}; | 288 | char swap[20]; |
264 | #else | 289 | int serial_console = 0; |
265 | const char * tty_commands[2] = { "sbin/dinstall", "bin/sh"}; | ||
266 | #endif | ||
267 | char swap[20]; | ||
268 | int serial_console = 0; | ||
269 | 290 | ||
270 | /* | 291 | /* |
271 | * If I am started as /linuxrc instead of /sbin/init, I don't have the | 292 | * If I am started as /linuxrc instead of /sbin/init, I don't have the |
@@ -330,17 +351,13 @@ init_main(int argc, char * * argv) | |||
330 | 351 | ||
331 | set_free_pages(); | 352 | set_free_pages(); |
332 | 353 | ||
333 | if (mem_total() < 3500) { /* not enough memory for standard install */ | 354 | /* not enough memory to do anything useful*/ |
355 | if (mem_total() < 2000) { | ||
334 | int retval; | 356 | int retval; |
335 | retval= stat("/etc/swappartition",&statbuf); | 357 | retval= stat("/etc/swappartition",&statbuf); |
336 | if (retval) { | 358 | if (retval) { |
337 | printf(" | 359 | printf("You do not have enough RAM, sorry.\n"); |
338 | You do not have enough RAM, hence you must boot using the Boot Disk | 360 | while (1) { sleep(1);} |
339 | for Low Memory systems. | ||
340 | |||
341 | Read the instructions in the install.html file. | ||
342 | "); | ||
343 | while (1) {;} | ||
344 | } else { /* everything OK */ | 361 | } else { /* everything OK */ |
345 | FILE *f; | 362 | FILE *f; |
346 | 363 | ||
@@ -371,8 +388,13 @@ Read the instructions in the install.html file. | |||
371 | arguments[j] = 0; | 388 | arguments[j] = 0; |
372 | 389 | ||
373 | if ( run_rc ) { | 390 | if ( run_rc ) { |
374 | printf("running %s\n",rc); | 391 | printf("running %s with args \"",rc); |
392 | for ( j = 0; j < argc; j++ ) { | ||
393 | printf("%s ", arguments[j]); | ||
394 | } | ||
395 | printf("\" on console %s\n", console); | ||
375 | waitfor(run(rc, arguments, console, 0)); | 396 | waitfor(run(rc, arguments, console, 0)); |
397 | printf("done.\n"); | ||
376 | } | 398 | } |
377 | 399 | ||
378 | if ( 0 == create_swap) { | 400 | if ( 0 == create_swap) { |
@@ -392,10 +414,21 @@ Read the instructions in the install.html file. | |||
392 | /* | 414 | /* |
393 | arguments[0] = tty_commands[0]; | 415 | arguments[0] = tty_commands[0]; |
394 | */ | 416 | */ |
395 | pid1 = run(tty_commands[0], arguments, first_terminal, 0); | 417 | printf("running %s with args \"",tty_commands[0]); |
418 | for ( j = 0; j < argc; j++ ) { | ||
419 | printf("%s ", arguments[j]); | ||
420 | } | ||
421 | printf("\" on console %s\n", first_terminal); | ||
422 | pid1 = run(tty_commands[0], arguments, first_terminal, 1); | ||
396 | } | 423 | } |
397 | if ( pid2 == 0 && tty_commands[1] ) | 424 | if ( pid2 == 0 && tty_commands[1] ) { |
425 | printf("running %s with args \"",tty_commands[0]); | ||
426 | for ( j = 0; j < argc; j++ ) { | ||
427 | printf("%s ", arguments[j]); | ||
428 | } | ||
429 | printf("\" on console %s\n", first_terminal); | ||
398 | pid2 = run(tty_commands[1], arguments, second_terminal, 1); | 430 | pid2 = run(tty_commands[1], arguments, second_terminal, 1); |
431 | } | ||
399 | wpid = wait(&status); | 432 | wpid = wait(&status); |
400 | if ( wpid > 0 ) { | 433 | if ( wpid > 0 ) { |
401 | /* DEBUGGING */ | 434 | /* DEBUGGING */ |
@@ -409,32 +442,3 @@ Read the instructions in the install.html file. | |||
409 | } | 442 | } |
410 | } | 443 | } |
411 | 444 | ||
412 | void | ||
413 | configure_terminals( int serial_cons ) | ||
414 | { | ||
415 | //struct stat statbuf; | ||
416 | char *tty; | ||
417 | |||
418 | switch (serial_cons) { | ||
419 | case 1: | ||
420 | strcpy( console, "/dev/ttyS0" ); | ||
421 | break; | ||
422 | case 2: | ||
423 | strcpy( console, "/dev/ttyS1" ); | ||
424 | break; | ||
425 | default: | ||
426 | tty = ttyname(0); | ||
427 | if (tty) { | ||
428 | strcpy( console, tty ); | ||
429 | if (!strncmp( tty, "/dev/ttyS", 9 )) | ||
430 | serial_cons=1; | ||
431 | } | ||
432 | else | ||
433 | /* falls back to /dev/tty1 if an error occurs */ | ||
434 | strcpy( console, default_console ); | ||
435 | } | ||
436 | if (!first_terminal) | ||
437 | first_terminal = console; | ||
438 | if (serial_cons && !strncmp(term_ptr,"TERM=linux",10)) | ||
439 | term_ptr = "TERM=vt100"; | ||
440 | } | ||