diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-05-19 05:35:19 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-05-19 05:35:19 +0000 |
commit | 330fd2b5767110f29544131d4c72c77e0506b6df (patch) | |
tree | aa360774a903d3ebb0b2b5f3031c2e359f9c3afb | |
parent | d356c6e9d1bc091c64200ecc401aa9b6ffb53151 (diff) | |
download | busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.tar.gz busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.tar.bz2 busybox-w32-330fd2b5767110f29544131d4c72c77e0506b6df.zip |
More libc portability updates, add in the website (which has not been
archived previously). Wrote 'which' during the meeting today.
-Erik
-rw-r--r-- | Changelog | 18 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README | 42 | ||||
-rw-r--r-- | TODO | 35 | ||||
-rw-r--r-- | applets/busybox.c | 17 | ||||
-rw-r--r-- | archival/gunzip.c | 151 | ||||
-rw-r--r-- | archival/gzip.c | 6 | ||||
-rw-r--r-- | basename.c | 16 | ||||
-rw-r--r-- | busybox.c | 17 | ||||
-rw-r--r-- | busybox.def.h | 8 | ||||
-rw-r--r-- | coreutils/basename.c | 16 | ||||
-rw-r--r-- | coreutils/printf.c | 1 | ||||
-rw-r--r-- | coreutils/tr.c | 29 | ||||
-rw-r--r-- | dmesg.c | 1 | ||||
-rw-r--r-- | docs/busybox.net/BusyBox.html | 2460 | ||||
-rw-r--r-- | docs/busybox.net/images/background.png | bin | 0 -> 4711 bytes | |||
-rw-r--r-- | docs/busybox.net/images/busybox2.jpg | bin | 0 -> 8204 bytes | |||
-rw-r--r-- | docs/busybox.net/index.html | 434 | ||||
-rw-r--r-- | findutils/which.c | 73 | ||||
-rw-r--r-- | gunzip.c | 151 | ||||
-rw-r--r-- | gzip.c | 6 | ||||
-rw-r--r-- | hostname.c | 3 | ||||
-rw-r--r-- | init.c | 2 | ||||
-rw-r--r-- | init/init.c | 2 | ||||
-rw-r--r-- | internal.h | 1 | ||||
-rw-r--r-- | lash.c | 21 | ||||
-rw-r--r-- | messages.c | 25 | ||||
-rw-r--r-- | mkfs_minix.c | 128 | ||||
-rw-r--r-- | networking/hostname.c | 3 | ||||
-rw-r--r-- | printf.c | 1 | ||||
-rw-r--r-- | regexp.c | 2 | ||||
-rw-r--r-- | sh.c | 21 | ||||
-rw-r--r-- | shell/lash.c | 21 | ||||
-rw-r--r-- | tr.c | 29 | ||||
-rw-r--r-- | util-linux/dmesg.c | 1 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 128 | ||||
-rw-r--r-- | utility.c | 5 | ||||
-rw-r--r-- | which.c | 73 |
38 files changed, 3428 insertions, 521 deletions
@@ -5,8 +5,14 @@ | |||
5 | * Added setkeycodes, for those that have wierd keyboard buttons. | 5 | * Added setkeycodes, for those that have wierd keyboard buttons. |
6 | * Added cut and tr from minix, since due to the license change, | 6 | * Added cut and tr from minix, since due to the license change, |
7 | we can now use minix code. Minix tr saves 4k. | 7 | we can now use minix code. Minix tr saves 4k. |
8 | * Added the -v option (inverted search) to grep, | 8 | * Added 'grep -v' option (inverted search) and updated |
9 | updated docs/busybox.pod accordingly. -beppu | 9 | docs accordingly. -beppu |
10 | * Wrote which | ||
11 | * BusyBox sh (lash) now supports being used as a standalone shell. When | ||
12 | BB_FEATURE_STANDALONE_SHELL is defined, all the busybox commands may | ||
13 | be invoked as shell internals. Best used when compiling staticly | ||
14 | (i.e. DOSTATIC=true) | ||
15 | * BusyBox sh (lash) internals now behave as expected wrt pipes and redirects. | ||
10 | * Fixed ping warnings -- fix from Sascha Ziemann <szi@aibon.ping.de> | 16 | * Fixed ping warnings -- fix from Sascha Ziemann <szi@aibon.ping.de> |
11 | * Fixed update segfault | 17 | * Fixed update segfault |
12 | * Fixed mknod -- minor number was always 0 | 18 | * Fixed mknod -- minor number was always 0 |
@@ -28,16 +34,12 @@ | |||
28 | to xiong jianxin <jxiong@uiuc.edu> | 34 | to xiong jianxin <jxiong@uiuc.edu> |
29 | * cp -fa now works as expected for symlinks (it didn't before) | 35 | * cp -fa now works as expected for symlinks (it didn't before) |
30 | * zcat now works (wasn't working since option parsing was broken) | 36 | * zcat now works (wasn't working since option parsing was broken) |
31 | * Renamed "mnc" to the more correct "nc". | 37 | * Renamed "mnc" to the more correct "nc" (for netcat). |
32 | * Makefile intelligence updates | 38 | * Makefile intelligence updates |
33 | * BusyBox sh (lash) internals now behave wrt pipes and redirects. | ||
34 | * BusyBox sh (lash) now supports being used as a standalone shell. When | ||
35 | BB_FEATURE_STANDALONE_SHELL is defined, all the busybox commands may | ||
36 | be invoked as shell internals. | ||
37 | * More doc updates | 39 | * More doc updates |
38 | 40 | ||
39 | 41 | ||
40 | -Erik | 42 | -Erik Andersen |
41 | 43 | ||
42 | 44 | ||
43 | 45 | ||
@@ -26,7 +26,7 @@ export VERSION | |||
26 | # Set the following to `true' to make a debuggable build. | 26 | # Set the following to `true' to make a debuggable build. |
27 | # Leave this set to `false' for production use. | 27 | # Leave this set to `false' for production use. |
28 | # eg: `make DODEBUG=true tests' | 28 | # eg: `make DODEBUG=true tests' |
29 | DODEBUG = false | 29 | DODEBUG = true |
30 | 30 | ||
31 | # If you want a static binary, turn this on. | 31 | # If you want a static binary, turn this on. |
32 | DOSTATIC = false | 32 | DOSTATIC = false |
@@ -1,23 +1,33 @@ | |||
1 | Please see the LICENSE file for copyright information. | 1 | Please see the LICENSE file for copyright information. |
2 | |||
3 | BusyBox combines tiny versions of many common UNIX utilities into a single | ||
4 | small executable. It provides minimalist replacements for most of the utilities | ||
5 | you usually find in fileutils, shellutils, findutils, textutils, grep, gzip, | ||
6 | tar, etc. BusyBox provides a fairly complete POSIX environment for any small or | ||
7 | emdedded system. The utilities in BusyBox generally have fewer options then | ||
8 | their full featured GNU cousins; however, the options that are included provide | ||
9 | the expected functionality and behave very much like their GNU counterparts. | ||
2 | 10 | ||
3 | BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It | 11 | BusyBox has been written with size-optimization and limited resources in mind. |
4 | provides a pretty complete POSIX environment in a very small package. | 12 | It is also extremely modular so you can easily include or exclude commands (or |
5 | Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and | 13 | features) at compile time. This makes it easy to customize your embedded |
6 | an editor such as "elvis-tiny" or "ae", and you have a working system. | 14 | systems. To create a working system, just add a kernel, a shell (such as ash), |
7 | Busybox was begun to support the Debian Rescue/Install disks, but it | 15 | and an editor (such as elvis-tiny or ae). |
8 | also makes an excellent environment for any small or embedded system. | ||
9 | 16 | ||
10 | As of version 0.20 there is a version number. : ) Also as of version 0.20, BB | 17 | Busybox was originally written to support the Debian Rescue/Install disks, but |
11 | is now modularized to easily allow you to build only the BB parts you need, | 18 | it also makes an excellent environment for any small or embedded system. |
12 | thereby reducing binary size. To turn off unwanted Busybox components, simply | ||
13 | edit the file busybox.def.h and comment out the parts you do not need using C++ | ||
14 | style (//) comments. | ||
15 | 19 | ||
16 | After the build is complete a busybox.links file is generated which is | 20 | As of version 0.20 there is a version number. : ) Also as of version 0.20, |
17 | then used by 'make install' to create symlinks to the busybox binary | 21 | BusyBox is now modularized to easily allow you to build only the components you |
18 | for all compiled in functions. By default, 'make install' will place | 22 | need, thereby reducing binary size. To turn off unwanted Busybox components, |
19 | the symlink forest into `pwd`/_install unless you have defined the | 23 | simply edit the file busybox.def.h and comment out the components you do not |
20 | PREFIX environment variable (i.e. make PREFIX="/tmp/foo" install) | 24 | need using C++ style (//) comments. |
25 | |||
26 | After the build is complete a busybox.links file is generated which is then | ||
27 | used by 'make install' to create symlinks to the busybox binary for all | ||
28 | compiled in functions. By default, 'make install' will place the symlink | ||
29 | forest into `pwd`/_install unless you have defined the PREFIX environment | ||
30 | variable (i.e. make PREFIX="/tmp/foo" install) | ||
21 | 31 | ||
22 | Please feed suggestions, bug reports, insults, and bribes back to: | 32 | Please feed suggestions, bug reports, insults, and bribes back to: |
23 | Erik Andersen | 33 | Erik Andersen |
@@ -7,9 +7,10 @@ around to it some time. If you have any good ideas, please let me know. | |||
7 | needed or wanted in busybox (or else I'd have to link to libcrypt). | 7 | needed or wanted in busybox (or else I'd have to link to libcrypt). |
8 | 8 | ||
9 | * Networking apps are probably going to be split out some time soon into a | 9 | * Networking apps are probably going to be split out some time soon into a |
10 | separate package (named perhaps tiny-netkit?). This currently includes | 10 | separate package (named perhaps netkit-tiny?). This would remove the |
11 | hostid, hostname, mnc, and ping. | 11 | following items from BusyBox: hostid, hostname, nc, nslookup, telnet, |
12 | 12 | and ping. nfs mounting and syslogd (when it supports network logging) | |
13 | will remain in BusyBox. | ||
13 | 14 | ||
14 | -Erik | 15 | -Erik |
15 | 16 | ||
@@ -20,17 +21,6 @@ Bugs that need fixing: | |||
20 | - 'grep foo$ file' doesn't work | 21 | - 'grep foo$ file' doesn't work |
21 | - 'grep *foo file' segfaults | 22 | - 'grep *foo file' segfaults |
22 | - ps dirent race bug (need to stat the file before attempting chdir) | 23 | - ps dirent race bug (need to stat the file before attempting chdir) |
23 | - # ls -la | ||
24 | /etc/passwd: No such file or directory | ||
25 | /etc/group: No such file or directory | ||
26 | drwxrwxr-x 3 1000 1000 54 May 14 22:30 . | ||
27 | /etc/passwd: No such file or directory | ||
28 | /etc/group: No such file or directory | ||
29 | drwxrwxr-x 3 1000 1000 54 May 14 22:30 .. | ||
30 | /etc/passwd: No such file or directory | ||
31 | /etc/group: No such file or directory | ||
32 | drwxrwxr-x 2 1000 1000 74 May 14 22:33 bin | ||
33 | / | ||
34 | 24 | ||
35 | ----------- | 25 | ----------- |
36 | 26 | ||
@@ -69,23 +59,6 @@ Most wanted list: | |||
69 | Policy violation. getgroups uses libc nss, which is unlikely | 59 | Policy violation. getgroups uses libc nss, which is unlikely |
70 | to be present in an embedded system. | 60 | to be present in an embedded system. |
71 | 61 | ||
72 | To be replaced with a non-getopt parser. | ||
73 | |||
74 | [andersen@slag busybox]$ grep -l getopt *.[ch] | ||
75 | dmesg.c | ||
76 | gunzip.c | ||
77 | hostname.c | ||
78 | mkfs_minix.c | ||
79 | printf.c | ||
80 | sfdisk.c | ||
81 | |||
82 | This includes the symbols: | ||
83 | getopt_long | ||
84 | optarg | ||
85 | opterr | ||
86 | optind | ||
87 | |||
88 | |||
89 | To be replaced with a busybox local glob routine: | 62 | To be replaced with a busybox local glob routine: |
90 | 63 | ||
91 | [andersen@slag busybox]$ grep -l glob *.[ch] | 64 | [andersen@slag busybox]$ grep -l glob *.[ch] |
diff --git a/applets/busybox.c b/applets/busybox.c index 07caa3446..bf0591d66 100644 --- a/applets/busybox.c +++ b/applets/busybox.c | |||
@@ -35,9 +35,7 @@ const struct BB_applet applets[] = { | |||
35 | #ifdef BB_BASENAME | 35 | #ifdef BB_BASENAME |
36 | {"basename", basename_main, _BB_DIR_USR_BIN}, | 36 | {"basename", basename_main, _BB_DIR_USR_BIN}, |
37 | #endif | 37 | #endif |
38 | #ifdef BB_BUSYBOX | ||
39 | {"busybox", busybox_main, _BB_DIR_BIN}, | 38 | {"busybox", busybox_main, _BB_DIR_BIN}, |
40 | #endif | ||
41 | #ifdef BB_BLOCK_DEVICE | 39 | #ifdef BB_BLOCK_DEVICE |
42 | {"block_device", block_device_main, _BB_DIR_SBIN}, | 40 | {"block_device", block_device_main, _BB_DIR_SBIN}, |
43 | #endif | 41 | #endif |
@@ -329,6 +327,9 @@ const struct BB_applet applets[] = { | |||
329 | #ifdef BB_WC | 327 | #ifdef BB_WC |
330 | {"wc", wc_main, _BB_DIR_USR_BIN}, | 328 | {"wc", wc_main, _BB_DIR_USR_BIN}, |
331 | #endif | 329 | #endif |
330 | #ifdef BB_WHICH | ||
331 | {"which", which_main, _BB_DIR_USR_BIN}, | ||
332 | #endif | ||
332 | #ifdef BB_WHOAMI | 333 | #ifdef BB_WHOAMI |
333 | {"whoami", whoami_main, _BB_DIR_USR_BIN}, | 334 | {"whoami", whoami_main, _BB_DIR_USR_BIN}, |
334 | #endif | 335 | #endif |
@@ -386,16 +387,14 @@ int busybox_main(int argc, char **argv) | |||
386 | if (been_there_done_that == 1 || argc < 1) { | 387 | if (been_there_done_that == 1 || argc < 1) { |
387 | const struct BB_applet *a = applets; | 388 | const struct BB_applet *a = applets; |
388 | 389 | ||
389 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", | 390 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n" |
390 | BB_VER, BB_BT); | 391 | "Usage: busybox [function] [arguments]...\n" |
391 | fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); | 392 | " or: [function] [arguments]...\n\n" |
392 | fprintf(stderr, " or: [function] [arguments]...\n\n"); | ||
393 | fprintf(stderr, | ||
394 | "\tBusyBox is a multi-call binary that combines many common Unix\n" | 393 | "\tBusyBox is a multi-call binary that combines many common Unix\n" |
395 | "\tutilities into a single executable. Most people will create a\n" | 394 | "\tutilities into a single executable. Most people will create a\n" |
396 | "\tlink to busybox for each function they wish to use, and BusyBox\n" | 395 | "\tlink to busybox for each function they wish to use, and BusyBox\n" |
397 | "\twill act like whatever it was invoked as.\n"); | 396 | "\twill act like whatever it was invoked as.\n" |
398 | fprintf(stderr, "\nCurrently defined functions:\n"); | 397 | "\nCurrently defined functions:\n", BB_VER, BB_BT); |
399 | 398 | ||
400 | while (a->name != 0) { | 399 | while (a->name != 0) { |
401 | col += | 400 | col += |
diff --git a/archival/gunzip.c b/archival/gunzip.c index 11fc3a8f9..78ee1d3c1 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c | |||
@@ -367,25 +367,23 @@ void send_bits (int value, int length); | |||
367 | unsigned bi_reverse (unsigned value, int length); | 367 | unsigned bi_reverse (unsigned value, int length); |
368 | void bi_windup (void); | 368 | void bi_windup (void); |
369 | void copy_block (char *buf, unsigned len, int header); | 369 | void copy_block (char *buf, unsigned len, int header); |
370 | extern int (*read_buf) (char *buf, unsigned size); | ||
371 | 370 | ||
372 | /* in util.c: */ | 371 | /* in util.c: */ |
373 | extern int copy (int in, int out); | ||
374 | extern ulg updcrc (uch * s, unsigned n); | 372 | extern ulg updcrc (uch * s, unsigned n); |
375 | extern void clear_bufs (void); | 373 | extern void clear_bufs (void); |
376 | extern int fill_inbuf (int eof_ok); | 374 | static int fill_inbuf (int eof_ok); |
377 | extern void flush_outbuf (void); | 375 | extern void flush_outbuf (void); |
378 | extern void flush_window (void); | 376 | static void flush_window (void); |
379 | extern void write_buf (int fd, void * buf, unsigned cnt); | 377 | extern void write_buf (int fd, void * buf, unsigned cnt); |
380 | 378 | ||
381 | #ifndef __linux__ | 379 | #ifndef __linux__ |
382 | extern char *basename (char *fname); | 380 | static char *basename (char *fname); |
383 | #endif /* not __linux__ */ | 381 | #endif /* not __linux__ */ |
384 | extern void read_error (void); | 382 | void read_error_msg (void); |
385 | extern void write_error (void); | 383 | void write_error_msg (void); |
386 | 384 | ||
387 | /* in inflate.c */ | 385 | /* in inflate.c */ |
388 | extern int inflate (void); | 386 | static int inflate (void); |
389 | 387 | ||
390 | /* #include "lzw.h" */ | 388 | /* #include "lzw.h" */ |
391 | 389 | ||
@@ -450,133 +448,6 @@ extern int unlzw (int in, int out); | |||
450 | # undef LZW | 448 | # undef LZW |
451 | #endif | 449 | #endif |
452 | 450 | ||
453 | /* #include "getopt.h" */ | ||
454 | |||
455 | /* Declarations for getopt. | ||
456 | Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | ||
457 | |||
458 | This program is free software; you can redistribute it and/or modify it | ||
459 | under the terms of the GNU General Public License as published by the | ||
460 | Free Software Foundation; either version 2, or (at your option) any | ||
461 | later version. | ||
462 | |||
463 | This program is distributed in the hope that it will be useful, | ||
464 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
465 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
466 | GNU General Public License for more details. | ||
467 | |||
468 | You should have received a copy of the GNU General Public License | ||
469 | along with this program; if not, write to the Free Software | ||
470 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
471 | |||
472 | #ifndef _GETOPT_H | ||
473 | #define _GETOPT_H 1 | ||
474 | |||
475 | #ifdef __cplusplus | ||
476 | extern "C" { | ||
477 | #endif | ||
478 | /* For communication from `getopt' to the caller. | ||
479 | When `getopt' finds an option that takes an argument, | ||
480 | the argument value is returned here. | ||
481 | Also, when `ordering' is RETURN_IN_ORDER, | ||
482 | each non-option ARGV-element is returned here. */ | ||
483 | extern char *optarg; | ||
484 | |||
485 | /* Index in ARGV of the next element to be scanned. | ||
486 | This is used for communication to and from the caller | ||
487 | and for communication between successive calls to `getopt'. | ||
488 | |||
489 | On entry to `getopt', zero means this is the first call; initialize. | ||
490 | |||
491 | When `getopt' returns EOF, this is the index of the first of the | ||
492 | non-option elements that the caller should itself scan. | ||
493 | |||
494 | Otherwise, `optind' communicates from one call to the next | ||
495 | how much of ARGV has been scanned so far. */ | ||
496 | |||
497 | extern int optind; | ||
498 | |||
499 | /* Callers store zero here to inhibit the error message `getopt' prints | ||
500 | for unrecognized options. */ | ||
501 | |||
502 | extern int opterr; | ||
503 | |||
504 | /* Set to an option character which was unrecognized. */ | ||
505 | |||
506 | extern int optopt; | ||
507 | |||
508 | /* Describe the long-named options requested by the application. | ||
509 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector | ||
510 | of `struct option' terminated by an element containing a name which is | ||
511 | zero. | ||
512 | |||
513 | The field `has_arg' is: | ||
514 | no_argument (or 0) if the option does not take an argument, | ||
515 | required_argument (or 1) if the option requires an argument, | ||
516 | optional_argument (or 2) if the option takes an optional argument. | ||
517 | |||
518 | If the field `flag' is not NULL, it points to a variable that is set | ||
519 | to the value given in the field `val' when the option is found, but | ||
520 | left unchanged if the option is not found. | ||
521 | |||
522 | To have a long-named option do something other than set an `int' to | ||
523 | a compiled-in constant, such as set a value from `optarg', set the | ||
524 | option's `flag' field to zero and its `val' field to a nonzero | ||
525 | value (the equivalent single-letter option character, if there is | ||
526 | one). For long options that have a zero `flag' field, `getopt' | ||
527 | returns the contents of the `val' field. */ | ||
528 | |||
529 | struct option { | ||
530 | #if __STDC__ | ||
531 | const char *name; | ||
532 | #else | ||
533 | char *name; | ||
534 | #endif | ||
535 | /* has_arg can't be an enum because some compilers complain about | ||
536 | type mismatches in all the code that assumes it is an int. */ | ||
537 | int has_arg; | ||
538 | int *flag; | ||
539 | int val; | ||
540 | }; | ||
541 | |||
542 | /* Names for the values of the `has_arg' field of `struct option'. */ | ||
543 | |||
544 | #define no_argument 0 | ||
545 | #define required_argument 1 | ||
546 | #define optional_argument 2 | ||
547 | |||
548 | #if __STDC__ || defined(PROTO) | ||
549 | #if defined(__GNU_LIBRARY__) | ||
550 | /* Many other libraries have conflicting prototypes for getopt, with | ||
551 | differences in the consts, in stdlib.h. To avoid compilation | ||
552 | errors, only prototype getopt for the GNU C library. */ | ||
553 | extern int getopt(int argc, char *const *argv, const char *shortopts); | ||
554 | #endif /* not __GNU_LIBRARY__ */ | ||
555 | extern int getopt_long(int argc, char *const *argv, | ||
556 | const char *shortopts, | ||
557 | const struct option *longopts, int *longind); | ||
558 | extern int getopt_long_only(int argc, char *const *argv, | ||
559 | const char *shortopts, | ||
560 | const struct option *longopts, | ||
561 | int *longind); | ||
562 | |||
563 | /* Internal only. Users should not call this directly. */ | ||
564 | extern int _getopt_internal(int argc, char *const *argv, | ||
565 | const char *shortopts, | ||
566 | const struct option *longopts, | ||
567 | int *longind, int long_only); | ||
568 | #else /* not __STDC__ */ | ||
569 | extern int getopt(); | ||
570 | extern int getopt_long(); | ||
571 | extern int getopt_long_only(); | ||
572 | |||
573 | extern int _getopt_internal(); | ||
574 | #endif /* not __STDC__ */ | ||
575 | |||
576 | #ifdef __cplusplus | ||
577 | } | ||
578 | #endif | ||
579 | #endif /* _GETOPT_H */ | ||
580 | #include <time.h> | 451 | #include <time.h> |
581 | #include <fcntl.h> | 452 | #include <fcntl.h> |
582 | #include <unistd.h> | 453 | #include <unistd.h> |
@@ -1161,7 +1032,7 @@ unsigned n; /* number of bytes in s[] */ | |||
1161 | /* =========================================================================== | 1032 | /* =========================================================================== |
1162 | * Clear input and output buffers | 1033 | * Clear input and output buffers |
1163 | */ | 1034 | */ |
1164 | void clear_bufs() | 1035 | void clear_bufs(void) |
1165 | { | 1036 | { |
1166 | outcnt = 0; | 1037 | outcnt = 0; |
1167 | insize = inptr = 0; | 1038 | insize = inptr = 0; |
@@ -1189,7 +1060,7 @@ int eof_ok; /* set if EOF acceptable as a result */ | |||
1189 | if (insize == 0) { | 1060 | if (insize == 0) { |
1190 | if (eof_ok) | 1061 | if (eof_ok) |
1191 | return EOF; | 1062 | return EOF; |
1192 | read_error(); | 1063 | read_error_msg(); |
1193 | } | 1064 | } |
1194 | bytes_in += (ulg) insize; | 1065 | bytes_in += (ulg) insize; |
1195 | inptr = 1; | 1066 | inptr = 1; |
@@ -1240,7 +1111,7 @@ unsigned cnt; | |||
1240 | 1111 | ||
1241 | while ((n = write(fd, buf, cnt)) != cnt) { | 1112 | while ((n = write(fd, buf, cnt)) != cnt) { |
1242 | if (n == (unsigned) (-1)) { | 1113 | if (n == (unsigned) (-1)) { |
1243 | write_error(); | 1114 | write_error_msg(); |
1244 | } | 1115 | } |
1245 | cnt -= n; | 1116 | cnt -= n; |
1246 | buf = (void *) ((char *) buf + n); | 1117 | buf = (void *) ((char *) buf + n); |
@@ -1306,7 +1177,7 @@ const char *reject; | |||
1306 | /* ======================================================================== | 1177 | /* ======================================================================== |
1307 | * Error handlers. | 1178 | * Error handlers. |
1308 | */ | 1179 | */ |
1309 | void read_error() | 1180 | void read_error_msg() |
1310 | { | 1181 | { |
1311 | fprintf(stderr, "\n"); | 1182 | fprintf(stderr, "\n"); |
1312 | if (errno != 0) { | 1183 | if (errno != 0) { |
@@ -1317,7 +1188,7 @@ void read_error() | |||
1317 | abort_gzip(); | 1188 | abort_gzip(); |
1318 | } | 1189 | } |
1319 | 1190 | ||
1320 | void write_error() | 1191 | void write_error_msg() |
1321 | { | 1192 | { |
1322 | fprintf(stderr, "\n"); | 1193 | fprintf(stderr, "\n"); |
1323 | perror(""); | 1194 | perror(""); |
diff --git a/archival/gzip.c b/archival/gzip.c index 17ebf6cb7..a971229d3 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -329,8 +329,8 @@ extern void flush_window (void); | |||
329 | extern void write_buf (int fd, void * buf, unsigned cnt); | 329 | extern void write_buf (int fd, void * buf, unsigned cnt); |
330 | extern char *strlwr (char *s); | 330 | extern char *strlwr (char *s); |
331 | extern char *add_envopt (int *argcp, char ***argvp, char *env); | 331 | extern char *add_envopt (int *argcp, char ***argvp, char *env); |
332 | extern void read_error (void); | 332 | extern void read_error_msg (void); |
333 | extern void write_error (void); | 333 | extern void write_error_msg (void); |
334 | extern void display_ratio (long num, long den, FILE * file); | 334 | extern void display_ratio (long num, long den, FILE * file); |
335 | 335 | ||
336 | /* in inflate.c */ | 336 | /* in inflate.c */ |
@@ -3138,7 +3138,7 @@ int in, out; /* input and output file descriptors */ | |||
3138 | insize = read(in, (char *) inbuf, INBUFSIZ); | 3138 | insize = read(in, (char *) inbuf, INBUFSIZ); |
3139 | } | 3139 | } |
3140 | if ((int) insize == EOF && errno != 0) { | 3140 | if ((int) insize == EOF && errno != 0) { |
3141 | read_error(); | 3141 | read_error_msg(); |
3142 | } | 3142 | } |
3143 | bytes_in = bytes_out; | 3143 | bytes_in = bytes_out; |
3144 | return OK; | 3144 | return OK; |
diff --git a/basename.c b/basename.c index 10ae76188..78265a5e6 100644 --- a/basename.c +++ b/basename.c | |||
@@ -24,19 +24,23 @@ | |||
24 | #include "internal.h" | 24 | #include "internal.h" |
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | 26 | ||
27 | const char *basename_usage="basename FILE [SUFFIX]\n" | ||
28 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
29 | "\nStrips directory path and suffixes from FILE.\n" | ||
30 | "If specified, also removes any trailing SUFFIX.\n" | ||
31 | #endif | ||
32 | ; | ||
33 | |||
34 | |||
27 | extern int basename_main(int argc, char **argv) | 35 | extern int basename_main(int argc, char **argv) |
28 | { | 36 | { |
29 | int m, n; | 37 | int m, n; |
30 | char *s, *s1; | 38 | char *s, *s1; |
31 | 39 | ||
32 | if ((argc < 2) || (**(argv + 1) == '-')) { | 40 | if ((argc < 2) || (**(argv + 1) == '-')) { |
33 | usage("basename FILE [SUFFIX]\n" | 41 | usage(basename_usage); |
34 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
35 | "\nStrips directory path and suffixes from FILE.\n" | ||
36 | "If specified, also removes any trailing SUFFIX.\n" | ||
37 | #endif | ||
38 | ); | ||
39 | } | 42 | } |
43 | |||
40 | argv++; | 44 | argv++; |
41 | 45 | ||
42 | s1=*argv+strlen(*argv)-1; | 46 | s1=*argv+strlen(*argv)-1; |
@@ -35,9 +35,7 @@ const struct BB_applet applets[] = { | |||
35 | #ifdef BB_BASENAME | 35 | #ifdef BB_BASENAME |
36 | {"basename", basename_main, _BB_DIR_USR_BIN}, | 36 | {"basename", basename_main, _BB_DIR_USR_BIN}, |
37 | #endif | 37 | #endif |
38 | #ifdef BB_BUSYBOX | ||
39 | {"busybox", busybox_main, _BB_DIR_BIN}, | 38 | {"busybox", busybox_main, _BB_DIR_BIN}, |
40 | #endif | ||
41 | #ifdef BB_BLOCK_DEVICE | 39 | #ifdef BB_BLOCK_DEVICE |
42 | {"block_device", block_device_main, _BB_DIR_SBIN}, | 40 | {"block_device", block_device_main, _BB_DIR_SBIN}, |
43 | #endif | 41 | #endif |
@@ -329,6 +327,9 @@ const struct BB_applet applets[] = { | |||
329 | #ifdef BB_WC | 327 | #ifdef BB_WC |
330 | {"wc", wc_main, _BB_DIR_USR_BIN}, | 328 | {"wc", wc_main, _BB_DIR_USR_BIN}, |
331 | #endif | 329 | #endif |
330 | #ifdef BB_WHICH | ||
331 | {"which", which_main, _BB_DIR_USR_BIN}, | ||
332 | #endif | ||
332 | #ifdef BB_WHOAMI | 333 | #ifdef BB_WHOAMI |
333 | {"whoami", whoami_main, _BB_DIR_USR_BIN}, | 334 | {"whoami", whoami_main, _BB_DIR_USR_BIN}, |
334 | #endif | 335 | #endif |
@@ -386,16 +387,14 @@ int busybox_main(int argc, char **argv) | |||
386 | if (been_there_done_that == 1 || argc < 1) { | 387 | if (been_there_done_that == 1 || argc < 1) { |
387 | const struct BB_applet *a = applets; | 388 | const struct BB_applet *a = applets; |
388 | 389 | ||
389 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", | 390 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n" |
390 | BB_VER, BB_BT); | 391 | "Usage: busybox [function] [arguments]...\n" |
391 | fprintf(stderr, "Usage: busybox [function] [arguments]...\n"); | 392 | " or: [function] [arguments]...\n\n" |
392 | fprintf(stderr, " or: [function] [arguments]...\n\n"); | ||
393 | fprintf(stderr, | ||
394 | "\tBusyBox is a multi-call binary that combines many common Unix\n" | 393 | "\tBusyBox is a multi-call binary that combines many common Unix\n" |
395 | "\tutilities into a single executable. Most people will create a\n" | 394 | "\tutilities into a single executable. Most people will create a\n" |
396 | "\tlink to busybox for each function they wish to use, and BusyBox\n" | 395 | "\tlink to busybox for each function they wish to use, and BusyBox\n" |
397 | "\twill act like whatever it was invoked as.\n"); | 396 | "\twill act like whatever it was invoked as.\n" |
398 | fprintf(stderr, "\nCurrently defined functions:\n"); | 397 | "\nCurrently defined functions:\n", BB_VER, BB_BT); |
399 | 398 | ||
400 | while (a->name != 0) { | 399 | while (a->name != 0) { |
401 | col += | 400 | col += |
diff --git a/busybox.def.h b/busybox.def.h index 8eb32bfb8..ea17a3982 100644 --- a/busybox.def.h +++ b/busybox.def.h | |||
@@ -97,6 +97,7 @@ | |||
97 | #define BB_UPTIME | 97 | #define BB_UPTIME |
98 | #define BB_USLEEP | 98 | #define BB_USLEEP |
99 | #define BB_WC | 99 | #define BB_WC |
100 | #define BB_WHICH | ||
100 | #define BB_WHOAMI | 101 | #define BB_WHOAMI |
101 | #define BB_UMOUNT | 102 | #define BB_UMOUNT |
102 | #define BB_UNIQ | 103 | #define BB_UNIQ |
@@ -200,7 +201,7 @@ | |||
200 | #define BB_FEATURE_SORT_REVERSE | 201 | #define BB_FEATURE_SORT_REVERSE |
201 | // | 202 | // |
202 | // Enable command line editing in the shell | 203 | // Enable command line editing in the shell |
203 | //#define BB_FEATURE_SH_COMMAND_EDITING | 204 | #define BB_FEATURE_SH_COMMAND_EDITING |
204 | // | 205 | // |
205 | //Allow the shell to invoke all the compiled in BusyBox commands as if they | 206 | //Allow the shell to invoke all the compiled in BusyBox commands as if they |
206 | //were shell builtins. Nice for staticly linking an emergency rescue shell | 207 | //were shell builtins. Nice for staticly linking an emergency rescue shell |
@@ -261,3 +262,8 @@ | |||
261 | #define BB_NFSMOUNT | 262 | #define BB_NFSMOUNT |
262 | #endif | 263 | #endif |
263 | // | 264 | // |
265 | #if defined BB_FEATURE_STANDALONE_SHELL | ||
266 | #ifndef BB_FEATURE_USE_TERMIOS | ||
267 | #define BB_FEATURE_USE_TERMIOS | ||
268 | #endif | ||
269 | #endif | ||
diff --git a/coreutils/basename.c b/coreutils/basename.c index 10ae76188..78265a5e6 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
@@ -24,19 +24,23 @@ | |||
24 | #include "internal.h" | 24 | #include "internal.h" |
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | 26 | ||
27 | const char *basename_usage="basename FILE [SUFFIX]\n" | ||
28 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
29 | "\nStrips directory path and suffixes from FILE.\n" | ||
30 | "If specified, also removes any trailing SUFFIX.\n" | ||
31 | #endif | ||
32 | ; | ||
33 | |||
34 | |||
27 | extern int basename_main(int argc, char **argv) | 35 | extern int basename_main(int argc, char **argv) |
28 | { | 36 | { |
29 | int m, n; | 37 | int m, n; |
30 | char *s, *s1; | 38 | char *s, *s1; |
31 | 39 | ||
32 | if ((argc < 2) || (**(argv + 1) == '-')) { | 40 | if ((argc < 2) || (**(argv + 1) == '-')) { |
33 | usage("basename FILE [SUFFIX]\n" | 41 | usage(basename_usage); |
34 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
35 | "\nStrips directory path and suffixes from FILE.\n" | ||
36 | "If specified, also removes any trailing SUFFIX.\n" | ||
37 | #endif | ||
38 | ); | ||
39 | } | 42 | } |
43 | |||
40 | argv++; | 44 | argv++; |
41 | 45 | ||
42 | s1=*argv+strlen(*argv)-1; | 46 | s1=*argv+strlen(*argv)-1; |
diff --git a/coreutils/printf.c b/coreutils/printf.c index 28a011dcd..4e9a94049 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c | |||
@@ -51,7 +51,6 @@ | |||
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <stdio.h> | 52 | #include <stdio.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <getopt.h> | ||
55 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
56 | #include <string.h> | 55 | #include <string.h> |
57 | #include <errno.h> | 56 | #include <errno.h> |
diff --git a/coreutils/tr.c b/coreutils/tr.c index ebb64799f..3e7ba583c 100644 --- a/coreutils/tr.c +++ b/coreutils/tr.c | |||
@@ -30,6 +30,20 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #define BB_DECLARE_EXTERN | ||
34 | #define bb_need_write_error | ||
35 | #include "messages.c" | ||
36 | |||
37 | const char *tr_usage="tr [-cds] STRING1 [STRING2]\n" | ||
38 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
39 | "\nTranslate, squeeze, and/or delete characters from\n" | ||
40 | "standard input, writing to standard output.\n\n" | ||
41 | "Options:\n" | ||
42 | "\t-c\ttake complement of STRING1\n" | ||
43 | "\t-d\tdelete input characters coded STRING1\n" | ||
44 | "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" | ||
45 | #endif | ||
46 | ; | ||
33 | 47 | ||
34 | 48 | ||
35 | 49 | ||
@@ -60,7 +74,7 @@ static void convert() | |||
60 | if (in_index == read_chars) { | 74 | if (in_index == read_chars) { |
61 | if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { | 75 | if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { |
62 | if (write(1, (char *) output, out_index) != out_index) | 76 | if (write(1, (char *) output, out_index) != out_index) |
63 | write(2, "Bad write\n", 10); | 77 | write(2, write_error, strlen(write_error)); |
64 | exit(0); | 78 | exit(0); |
65 | } | 79 | } |
66 | in_index = 0; | 80 | in_index = 0; |
@@ -74,7 +88,7 @@ static void convert() | |||
74 | output[out_index++] = last = coded; | 88 | output[out_index++] = last = coded; |
75 | if (out_index == BUFSIZ) { | 89 | if (out_index == BUFSIZ) { |
76 | if (write(1, (char *) output, out_index) != out_index) { | 90 | if (write(1, (char *) output, out_index) != out_index) { |
77 | write(2, "Bad write\n", 10); | 91 | write(2, write_error, strlen(write_error)); |
78 | exit(1); | 92 | exit(1); |
79 | } | 93 | } |
80 | out_index = 0; | 94 | out_index = 0; |
@@ -167,16 +181,7 @@ extern int tr_main(int argc, char **argv) | |||
167 | sq_fl = TRUE; | 181 | sq_fl = TRUE; |
168 | break; | 182 | break; |
169 | default: | 183 | default: |
170 | usage("tr [-cds] STRING1 [STRING2]\n" | 184 | usage(tr_usage); |
171 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
172 | "\nTranslate, squeeze, and/or delete characters from\n" | ||
173 | "standard input, writing to standard output.\n\n" | ||
174 | "Options:\n" | ||
175 | "\t-c\ttake complement of STRING1\n" | ||
176 | "\t-d\tdelete input characters coded STRING1\n" | ||
177 | "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" | ||
178 | #endif | ||
179 | ); | ||
180 | } | 185 | } |
181 | } | 186 | } |
182 | index++; | 187 | index++; |
@@ -18,7 +18,6 @@ | |||
18 | #include "internal.h" | 18 | #include "internal.h" |
19 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <getopt.h> | ||
22 | #include <stdlib.h> | 21 | #include <stdlib.h> |
23 | 22 | ||
24 | #if __GNU_LIBRARY__ < 5 | 23 | #if __GNU_LIBRARY__ < 5 |
diff --git a/docs/busybox.net/BusyBox.html b/docs/busybox.net/BusyBox.html new file mode 100644 index 000000000..5a65db127 --- /dev/null +++ b/docs/busybox.net/BusyBox.html | |||
@@ -0,0 +1,2460 @@ | |||
1 | <HTML> | ||
2 | <HEAD> | ||
3 | <TITLE>BusyBox - The Swiss Army Knife of Embedded Linux</TITLE> | ||
4 | <LINK REV="made" HREF="mailto:none"> | ||
5 | </HEAD> | ||
6 | |||
7 | <BODY> | ||
8 | |||
9 | <!-- INDEX BEGIN --> | ||
10 | |||
11 | <UL> | ||
12 | |||
13 | <LI><A HREF="#NAME">NAME</A> | ||
14 | <LI><A HREF="#SYNTAX">SYNTAX</A> | ||
15 | <LI><A HREF="#DESCRIPTION">DESCRIPTION</A> | ||
16 | <LI><A HREF="#USAGE">USAGE</A> | ||
17 | <LI><A HREF="#COMMON_OPTIONS">COMMON OPTIONS</A> | ||
18 | <LI><A HREF="#COMMANDS">COMMANDS</A> | ||
19 | <LI><A HREF="#LIBC_NSS">LIBC NSS</A> | ||
20 | <LI><A HREF="#SEE_ALSO">SEE ALSO</A> | ||
21 | <LI><A HREF="#MAINTAINER">MAINTAINER</A> | ||
22 | <LI><A HREF="#AUTHORS">AUTHORS</A> | ||
23 | </UL> | ||
24 | <!-- INDEX END --> | ||
25 | |||
26 | <HR> | ||
27 | <P> | ||
28 | <H1><A NAME="NAME">NAME</A></H1> | ||
29 | <P> | ||
30 | BusyBox - The Swiss Army Knife of Embedded Linux | ||
31 | |||
32 | <P> | ||
33 | <HR> | ||
34 | <H1><A NAME="SYNTAX">SYNTAX</A></H1> | ||
35 | <P> | ||
36 | <PRE> BusyBox <function> [arguments...] # or | ||
37 | </PRE> | ||
38 | <P> | ||
39 | <PRE> <function> [arguments...] # if symlinked | ||
40 | </PRE> | ||
41 | <P> | ||
42 | <HR> | ||
43 | <H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1> | ||
44 | <P> | ||
45 | BusyBox combines tiny versions of many common UNIX utilities into a single | ||
46 | small executable. It provides minimalist replacements for most of the | ||
47 | utilities you usually find in fileutils, shellutils, findutils, textutils, | ||
48 | grep, gzip, tar, etc. BusyBox provides a fairly complete POSIX environment | ||
49 | for any small or emdedded system. The utilities in BusyBox generally have | ||
50 | fewer options then their full featured GNU cousins; however, the options | ||
51 | that are included provide the expected functionality and behave very much | ||
52 | like their GNU counterparts. | ||
53 | |||
54 | <P> | ||
55 | BusyBox has been written with size-optimization and limited resources in | ||
56 | mind. It is also extremely modular so you can easily include or exclude | ||
57 | commands (or features) at compile time. This makes it easy to customize | ||
58 | your embedded systems. To create a working system, just add a kernel, a | ||
59 | shell (such as ash), and an editor (such as elvis-tiny or ae). | ||
60 | |||
61 | <P> | ||
62 | <HR> | ||
63 | <H1><A NAME="USAGE">USAGE</A></H1> | ||
64 | <P> | ||
65 | When you create a link to BusyBox for the function you wish to use, when | ||
66 | BusyBox is called using that link it will behave as if the command itself | ||
67 | has been invoked. | ||
68 | |||
69 | <P> | ||
70 | For example, entering | ||
71 | |||
72 | <P> | ||
73 | <PRE> ln -s ./BusyBox ls | ||
74 | ./ls | ||
75 | </PRE> | ||
76 | <P> | ||
77 | will cause BusyBox to behave as 'ls' (if the 'ls' command has been compiled | ||
78 | into BusyBox). | ||
79 | |||
80 | <P> | ||
81 | You can also invoke BusyBox by issuing the command as an argument on the | ||
82 | command line. For example, entering | ||
83 | |||
84 | <P> | ||
85 | <PRE> ./BusyBox ls | ||
86 | </PRE> | ||
87 | <P> | ||
88 | will also cause BusyBox to behave as 'ls'. | ||
89 | |||
90 | <P> | ||
91 | <HR> | ||
92 | <H1><A NAME="COMMON_OPTIONS">COMMON OPTIONS</A></H1> | ||
93 | <P> | ||
94 | Most BusyBox commands support the <STRONG>--help</STRONG> option to provide a terse runtime description of their behavior. | ||
95 | |||
96 | <P> | ||
97 | <HR> | ||
98 | <H1><A NAME="COMMANDS">COMMANDS</A></H1> | ||
99 | <P> | ||
100 | Currently defined functions include: | ||
101 | |||
102 | <P> | ||
103 | basename, cat, chgrp, chmod, chown, chroot, clear, chvt, cp, cut, date, dd, | ||
104 | df, dirname, dmesg, du, dutmp, echo, false, fbset, fdflush, find, free, | ||
105 | freeramdisk, deallocvt, fsck.minix, grep, gunzip, gzip, halt, head, hostid, | ||
106 | hostname, id, init, kill, killall, length, ln, loadacm, loadfont, loadkmap, | ||
107 | logger, logname, ls, lsmod, makedevs, math, mkdir, mkfifo, mkfs.minix, | ||
108 | mknod, mkswap, mktemp, nc, more, mount, mt, mv, nslookup, ping, poweroff, | ||
109 | printf, ps, pwd, reboot, rm, rmdir, rmmod, sed, setkeycodes, sh, sfdisk, | ||
110 | sleep, sort, sync, syslogd, swapon, swapoff, tail, tar, test, tee, touch, | ||
111 | tr, true, tty, umount, uname, uniq, update, uptime, usleep, wc, whoami, | ||
112 | yes, zcat, [ | ||
113 | |||
114 | <P> | ||
115 | ------------------------------- | ||
116 | |||
117 | <DL> | ||
118 | <DT><STRONG><A NAME="item_basename">basename</A></STRONG><DD> | ||
119 | <P> | ||
120 | Usage: basename FILE [SUFFIX] | ||
121 | |||
122 | <P> | ||
123 | Strips directory path and suffixes from FILE. If specified, also removes | ||
124 | any trailing SUFFIX. | ||
125 | |||
126 | <P> | ||
127 | Example: | ||
128 | |||
129 | <P> | ||
130 | <PRE> $ basename /usr/local/bin/foo | ||
131 | foo | ||
132 | $ basename /usr/local/bin/ | ||
133 | bin | ||
134 | $ basename /foo/bar.txt .txt | ||
135 | bar | ||
136 | </PRE> | ||
137 | <P> | ||
138 | ------------------------------- | ||
139 | |||
140 | <DT><STRONG><A NAME="item_cat">cat</A></STRONG><DD> | ||
141 | <P> | ||
142 | Usage: cat [FILE ...] | ||
143 | |||
144 | <P> | ||
145 | Concatenates <CODE>FILE(s)</CODE> and prints them to the standard output. | ||
146 | |||
147 | <P> | ||
148 | Example: | ||
149 | |||
150 | <P> | ||
151 | <PRE> $ cat /proc/uptime | ||
152 | 110716.72 17.67 | ||
153 | </PRE> | ||
154 | <P> | ||
155 | ------------------------------- | ||
156 | |||
157 | <DT><STRONG><A NAME="item_chgrp">chgrp</A></STRONG><DD> | ||
158 | <P> | ||
159 | Usage: chgrp [OPTION]... GROUP FILE... | ||
160 | |||
161 | <P> | ||
162 | Change the group membership of each FILE to GROUP. | ||
163 | |||
164 | <P> | ||
165 | Options: | ||
166 | |||
167 | <P> | ||
168 | <PRE> -R change files and directories recursively | ||
169 | </PRE> | ||
170 | <P> | ||
171 | Example: | ||
172 | |||
173 | <P> | ||
174 | <PRE> $ ls -l /tmp/foo | ||
175 | -r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo | ||
176 | $ chgrp root /tmp/foo | ||
177 | $ ls -l /tmp/foo | ||
178 | -r--r--r-- 1 andersen root 0 Apr 12 18:25 /tmp/foo | ||
179 | </PRE> | ||
180 | <P> | ||
181 | ------------------------------- | ||
182 | |||
183 | <DT><STRONG><A NAME="item_chmod">chmod</A></STRONG><DD> | ||
184 | <P> | ||
185 | Usage: chmod [<STRONG>-R</STRONG>] MODE[,MODE]... FILE... | ||
186 | |||
187 | <P> | ||
188 | Changes file access permissions for the specified <CODE>FILE(s)</CODE> (or | ||
189 | directories). Each MODE is defined by combining the letters for WHO has | ||
190 | access to the file, an OPERATOR for selecting how the permissions should be | ||
191 | changed, and a PERISSION for <CODE>FILE(s)</CODE> (or directories). | ||
192 | |||
193 | <P> | ||
194 | WHO may be chosen from | ||
195 | |||
196 | <P> | ||
197 | <PRE> u User who owns the file | ||
198 | g Users in the file's Group | ||
199 | o Other users not in the file's group | ||
200 | a All users | ||
201 | </PRE> | ||
202 | <P> | ||
203 | OPERATOR may be chosen from | ||
204 | |||
205 | <P> | ||
206 | <PRE> + Add a permission | ||
207 | - Remove a permission | ||
208 | = Assign a permission | ||
209 | |||
210 | PERMISSION may be chosen from | ||
211 | </PRE> | ||
212 | <P> | ||
213 | <PRE> r Read | ||
214 | w Write | ||
215 | x Execute (or access for directories) | ||
216 | s Set user (or group) ID bit | ||
217 | t Stickey bit (for directories prevents removing files by non-owners) | ||
218 | </PRE> | ||
219 | <P> | ||
220 | Alternately, permissions can be set numerically where the first three | ||
221 | numbers are calculated by adding the octal values, such as | ||
222 | |||
223 | <P> | ||
224 | <PRE> 4 Read | ||
225 | 2 Write | ||
226 | 1 Execute | ||
227 | </PRE> | ||
228 | <P> | ||
229 | An optional fourth digit can also be used to specify | ||
230 | |||
231 | <P> | ||
232 | <PRE> 4 Set user ID | ||
233 | 2 Set group ID | ||
234 | 1 Stickey bit | ||
235 | </PRE> | ||
236 | <P> | ||
237 | Options: | ||
238 | |||
239 | <P> | ||
240 | <PRE> -R Change files and directories recursively. | ||
241 | |||
242 | Example: | ||
243 | </PRE> | ||
244 | <P> | ||
245 | <PRE> $ ls -l /tmp/foo | ||
246 | -rw-rw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo | ||
247 | $ chmod u+x /tmp/foo | ||
248 | $ ls -l /tmp/foo | ||
249 | -rwxrw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo* | ||
250 | $ chmod 444 /tmp/foo | ||
251 | $ ls -l /tmp/foo | ||
252 | -r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo | ||
253 | </PRE> | ||
254 | <P> | ||
255 | ------------------------------- | ||
256 | |||
257 | <DT><STRONG><A NAME="item_chown">chown</A></STRONG><DD> | ||
258 | <P> | ||
259 | Usage: chown [OPTION]... OWNER[<.|:>[GROUP] FILE... | ||
260 | |||
261 | <P> | ||
262 | Changes the owner and/or group of each FILE to OWNER and/or GROUP. | ||
263 | |||
264 | <P> | ||
265 | Options: | ||
266 | |||
267 | <P> | ||
268 | <PRE> -R Changes files and directories recursively | ||
269 | </PRE> | ||
270 | <P> | ||
271 | Example: | ||
272 | |||
273 | <P> | ||
274 | <PRE> $ ls -l /tmp/foo | ||
275 | -r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo | ||
276 | $ chown root /tmp/foo | ||
277 | $ ls -l /tmp/foo | ||
278 | -r--r--r-- 1 root andersen 0 Apr 12 18:25 /tmp/foo | ||
279 | $ chown root.root /tmp/foo | ||
280 | ls -l /tmp/foo | ||
281 | -r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo | ||
282 | </PRE> | ||
283 | <P> | ||
284 | ------------------------------- | ||
285 | |||
286 | <DT><STRONG><A NAME="item_chroot">chroot</A></STRONG><DD> | ||
287 | <P> | ||
288 | Usage: chroot NEWROOT [COMMAND...] | ||
289 | |||
290 | <P> | ||
291 | Run COMMAND with root directory set to NEWROOT. Example: | ||
292 | |||
293 | <P> | ||
294 | <PRE> $ ls -l /bin/ls | ||
295 | lrwxrwxrwx 1 root root 12 Apr 13 00:46 /bin/ls -> /BusyBox | ||
296 | $ mount /dev/hdc1 /mnt -t minix | ||
297 | $ chroot /mnt | ||
298 | $ ls -l /bin/ls | ||
299 | -rwxr-xr-x 1 root root 40816 Feb 5 07:45 /bin/ls* | ||
300 | </PRE> | ||
301 | <P> | ||
302 | ------------------------------- | ||
303 | |||
304 | <DT><STRONG><A NAME="item_clear">clear</A></STRONG><DD> | ||
305 | <P> | ||
306 | Clears the screen. | ||
307 | |||
308 | <P> | ||
309 | ------------------------------- | ||
310 | |||
311 | <DT><STRONG><A NAME="item_chvt">chvt</A></STRONG><DD> | ||
312 | <P> | ||
313 | Usage: chvt N | ||
314 | |||
315 | <P> | ||
316 | Changes the foreground virtual terminal to /dev/ttyN | ||
317 | |||
318 | <P> | ||
319 | ------------------------------- | ||
320 | |||
321 | <DT><STRONG><A NAME="item_cp">cp</A></STRONG><DD> | ||
322 | <P> | ||
323 | Usage: cp [OPTION]... SOURCE DEST | ||
324 | |||
325 | <P> | ||
326 | <PRE> or: cp [OPTION]... SOURCE... DIRECTORY | ||
327 | </PRE> | ||
328 | <P> | ||
329 | Copies SOURCE to DEST, or multiple <CODE>SOURCE(s)</CODE> to DIRECTORY. | ||
330 | |||
331 | <P> | ||
332 | Options: | ||
333 | |||
334 | <P> | ||
335 | <PRE> -a Same as -dpR | ||
336 | -d Preserves links | ||
337 | -p Preserves file attributes if possable | ||
338 | -R Copies directories recursively | ||
339 | </PRE> | ||
340 | <P> | ||
341 | ------------------------------- | ||
342 | |||
343 | <DT><STRONG><A NAME="item_cut">cut</A></STRONG><DD> | ||
344 | <P> | ||
345 | Usage: cut [OPTION]... [FILE]... | ||
346 | |||
347 | <P> | ||
348 | Prints selected fields from each input FILE to standard output. | ||
349 | |||
350 | <P> | ||
351 | Options: | ||
352 | |||
353 | <P> | ||
354 | <PRE> -b LIST Output only bytes from LIST | ||
355 | -c LIST Output only characters from LIST | ||
356 | -d DELIM Use DELIM instead of tab as the field delimiter | ||
357 | -f N Print only these fields | ||
358 | -n Ignored | ||
359 | </PRE> | ||
360 | <P> | ||
361 | Example: | ||
362 | |||
363 | <P> | ||
364 | <PRE> $ echo "Hello world" | cut -f 1 -d ' ' | ||
365 | Hello | ||
366 | $ echo "Hello world" | cut -f 2 -d ' ' | ||
367 | world | ||
368 | </PRE> | ||
369 | <P> | ||
370 | ------------------------------- | ||
371 | |||
372 | <DT><STRONG><A NAME="item_date">date</A></STRONG><DD> | ||
373 | <P> | ||
374 | Usage: date [OPTION]... [+FORMAT] | ||
375 | |||
376 | <P> | ||
377 | <PRE> or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]] | ||
378 | </PRE> | ||
379 | <P> | ||
380 | Displays the current time in the given FORMAT, or sets the system date. | ||
381 | |||
382 | <P> | ||
383 | Options: | ||
384 | |||
385 | <P> | ||
386 | <PRE> -R Outputs RFC-822 compliant date string | ||
387 | -s Sets time described by STRING | ||
388 | -u Prints or sets Coordinated Universal Time | ||
389 | </PRE> | ||
390 | <P> | ||
391 | Example: | ||
392 | |||
393 | <P> | ||
394 | <PRE> $ date | ||
395 | Wed Apr 12 18:52:41 MDT 2000 | ||
396 | </PRE> | ||
397 | <P> | ||
398 | ------------------------------- | ||
399 | |||
400 | <DT><STRONG><A NAME="item_dd">dd</A></STRONG><DD> | ||
401 | <P> | ||
402 | Usage: dd [if=name] [of=name] [bs=n] [count=n] [skip=n] [seek=n] | ||
403 | |||
404 | <P> | ||
405 | Copy a file, converting and formatting according to options | ||
406 | |||
407 | <P> | ||
408 | <PRE> if=FILE read from FILE instead of stdin | ||
409 | of=FILE write to FILE instead of stdout | ||
410 | bs=n read and write n bytes at a time | ||
411 | count=n copy only n input blocks | ||
412 | skip=n skip n input blocks | ||
413 | seek=n skip n output blocks | ||
414 | </PRE> | ||
415 | <P> | ||
416 | Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2) | ||
417 | Example: | ||
418 | |||
419 | <P> | ||
420 | <PRE> $ dd if=/dev/zero of=/dev/ram1 bs=1M count=4 | ||
421 | 4+0 records in | ||
422 | 4+0 records out | ||
423 | </PRE> | ||
424 | <P> | ||
425 | ------------------------------- | ||
426 | |||
427 | <DT><STRONG><A NAME="item_df">df</A></STRONG><DD> | ||
428 | <P> | ||
429 | Usage: df [filesystem ...] | ||
430 | |||
431 | <P> | ||
432 | Prints the filesystem space used and space available. | ||
433 | |||
434 | <P> | ||
435 | Example: | ||
436 | |||
437 | <P> | ||
438 | <PRE> $ df | ||
439 | Filesystem 1k-blocks Used Available Use% Mounted on | ||
440 | /dev/sda3 8690864 8553540 137324 98% / | ||
441 | /dev/sda1 64216 36364 27852 57% /boot | ||
442 | $ df /dev/sda3 | ||
443 | Filesystem 1k-blocks Used Available Use% Mounted on | ||
444 | /dev/sda3 8690864 8553540 137324 98% / | ||
445 | </PRE> | ||
446 | <P> | ||
447 | ------------------------------- | ||
448 | |||
449 | <DT><STRONG><A NAME="item_dirname">dirname</A></STRONG><DD> | ||
450 | <P> | ||
451 | Usage: dirname NAME | ||
452 | |||
453 | <P> | ||
454 | Strip non-directory suffix from file name | ||
455 | |||
456 | <P> | ||
457 | Example: | ||
458 | |||
459 | <P> | ||
460 | <PRE> $ dirname /tmp/foo | ||
461 | /tmp | ||
462 | $ dirname /tmp/foo/ | ||
463 | /tmp | ||
464 | </PRE> | ||
465 | <P> | ||
466 | ------------------------------- | ||
467 | |||
468 | <DT><STRONG><A NAME="item_dmesg">dmesg</A></STRONG><DD> | ||
469 | <P> | ||
470 | Usage: dmesg [<STRONG>-c</STRONG>] [<STRONG>-n</STRONG> level] [<STRONG>-s</STRONG> bufsize] Print or controls the kernel ring buffer. | ||
471 | |||
472 | <P> | ||
473 | ------------------------------- | ||
474 | |||
475 | <DT><STRONG><A NAME="item_du">du</A></STRONG><DD> | ||
476 | <P> | ||
477 | Usage: du [OPTION]... [FILE]... | ||
478 | |||
479 | <P> | ||
480 | Summarize disk space used for each FILE and/or directory. Disk space is | ||
481 | printed in units of 1k (i.e. 1024 bytes). | ||
482 | |||
483 | <P> | ||
484 | Options: | ||
485 | |||
486 | <P> | ||
487 | <PRE> -l count sizes many times if hard linked | ||
488 | -s display only a total for each argument | ||
489 | </PRE> | ||
490 | <P> | ||
491 | Example: | ||
492 | |||
493 | <P> | ||
494 | <PRE> $ ./BusyBox du | ||
495 | 16 ./CVS | ||
496 | 12 ./kernel-patches/CVS | ||
497 | 80 ./kernel-patches | ||
498 | 12 ./tests/CVS | ||
499 | 36 ./tests | ||
500 | 12 ./scripts/CVS | ||
501 | 16 ./scripts | ||
502 | 12 ./docs/CVS | ||
503 | 104 ./docs | ||
504 | 2417 . | ||
505 | |||
506 | ------------------------------- | ||
507 | </PRE> | ||
508 | <DT><STRONG><A NAME="item_dutmp">dutmp</A></STRONG><DD> | ||
509 | <P> | ||
510 | Usage: dutmp [FILE] | ||
511 | |||
512 | <P> | ||
513 | Dump utmp file format (pipe delimited) from FILE or stdin to stdout. | ||
514 | |||
515 | <P> | ||
516 | Example: | ||
517 | |||
518 | <P> | ||
519 | <PRE> $ dutmp /var/run/utmp | ||
520 | 8|7||si|||0|0|0|955637625|760097|0 | ||
521 | 2|0|~|~~|reboot||0|0|0|955637625|782235|0 | ||
522 | 1|20020|~|~~|runlevel||0|0|0|955637625|800089|0 | ||
523 | 8|125||l4|||0|0|0|955637629|998367|0 | ||
524 | 6|245|tty1|1|LOGIN||0|0|0|955637630|998974|0 | ||
525 | 6|246|tty2|2|LOGIN||0|0|0|955637630|999498|0 | ||
526 | 7|336|pts/0|vt00andersen|andersen|:0.0|0|0|0|955637763|0|0 | ||
527 | |||
528 | ------------------------------- | ||
529 | </PRE> | ||
530 | <DT><STRONG><A NAME="item_echo">echo</A></STRONG><DD> | ||
531 | <P> | ||
532 | Usage: echo [-neE] [ARG ...] | ||
533 | |||
534 | <P> | ||
535 | Prints the specified ARGs to stdout | ||
536 | |||
537 | <P> | ||
538 | Options: | ||
539 | |||
540 | <P> | ||
541 | <PRE> -n suppress trailing newline | ||
542 | -e interpret backslash-escaped characters (i.e. \t=tab etc) | ||
543 | -E disable interpretation of backslash-escaped characters | ||
544 | </PRE> | ||
545 | <P> | ||
546 | Example: | ||
547 | |||
548 | <P> | ||
549 | <PRE> $ echo "Erik is cool" | ||
550 | Erik is cool | ||
551 | $ echo -e "Erik\nis\ncool" | ||
552 | Erik | ||
553 | is | ||
554 | cool | ||
555 | $ echo "Erik\nis\ncool" | ||
556 | Erik\nis\ncool | ||
557 | |||
558 | ------------------------------- | ||
559 | </PRE> | ||
560 | <DT><STRONG><A NAME="item_false">false</A></STRONG><DD> | ||
561 | <P> | ||
562 | Returns an exit code of FALSE (1) | ||
563 | |||
564 | <P> | ||
565 | Example: | ||
566 | |||
567 | <P> | ||
568 | <PRE> $ false | ||
569 | $ echo $? | ||
570 | 1 | ||
571 | </PRE> | ||
572 | <P> | ||
573 | ------------------------------- | ||
574 | |||
575 | <DT><STRONG><A NAME="item_fbset">fbset</A></STRONG><DD> | ||
576 | <P> | ||
577 | Usage: fbset [options] [mode] | ||
578 | |||
579 | <P> | ||
580 | Show and modify frame buffer device settings | ||
581 | |||
582 | <P> | ||
583 | Options: | ||
584 | |||
585 | <P> | ||
586 | <PRE> -h | ||
587 | -fb | ||
588 | -db | ||
589 | -a | ||
590 | -i | ||
591 | -g | ||
592 | -t | ||
593 | -accel | ||
594 | -hsync | ||
595 | -vsync | ||
596 | -laced | ||
597 | -double | ||
598 | </PRE> | ||
599 | <P> | ||
600 | Example: | ||
601 | |||
602 | <P> | ||
603 | <PRE> $ fbset | ||
604 | mode "1024x768-76" | ||
605 | # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz | ||
606 | geometry 1024 768 1024 768 16 | ||
607 | timings 12714 128 32 16 4 128 4 | ||
608 | accel false | ||
609 | rgba 5/11,6/5,5/0,0/0 | ||
610 | endmode | ||
611 | </PRE> | ||
612 | <P> | ||
613 | ------------------------------- | ||
614 | |||
615 | <DT><STRONG><A NAME="item_fdflush">fdflush</A></STRONG><DD> | ||
616 | <P> | ||
617 | Usage: fdflush device | ||
618 | |||
619 | <P> | ||
620 | Force floppy disk drive to detect disk change | ||
621 | |||
622 | <P> | ||
623 | ------------------------------- | ||
624 | |||
625 | <DT><STRONG><A NAME="item_find">find</A></STRONG><DD> | ||
626 | <P> | ||
627 | Usage: find [PATH...] [EXPRESSION] | ||
628 | |||
629 | <P> | ||
630 | Search for files in a directory hierarchy. The default PATH is the current | ||
631 | directory; default EXPRESSION is '-print' | ||
632 | |||
633 | <P> | ||
634 | EXPRESSION may consist of: | ||
635 | |||
636 | <P> | ||
637 | <PRE> -follow Dereference symbolic links. | ||
638 | -name PATTERN File name (leading directories removed) matches PATTERN. | ||
639 | -print print the full file name followed by a newline to stdout. | ||
640 | </PRE> | ||
641 | <P> | ||
642 | Example: | ||
643 | |||
644 | <P> | ||
645 | <PRE> $ find / -name /etc/passwd | ||
646 | /etc/passwd | ||
647 | </PRE> | ||
648 | <P> | ||
649 | ------------------------------- | ||
650 | |||
651 | <DT><STRONG><A NAME="item_free">free</A></STRONG><DD> | ||
652 | <P> | ||
653 | Usage: free | ||
654 | |||
655 | <P> | ||
656 | Displays the amount of free and used system memory. | ||
657 | |||
658 | <P> | ||
659 | Example: | ||
660 | |||
661 | <P> | ||
662 | <PRE> $ free | ||
663 | total used free shared buffers | ||
664 | Mem: 257628 248724 8904 59644 93124 | ||
665 | Swap: 128516 8404 120112 | ||
666 | Total: 386144 257128 129016 | ||
667 | </PRE> | ||
668 | <P> | ||
669 | ------------------------------- | ||
670 | |||
671 | <DT><STRONG><A NAME="item_freeramdisk">freeramdisk</A></STRONG><DD> | ||
672 | <P> | ||
673 | Usage: freeramdisk DEVICE | ||
674 | |||
675 | <P> | ||
676 | Frees all memory used by the specified ramdisk. | ||
677 | |||
678 | <P> | ||
679 | Example: | ||
680 | |||
681 | <P> | ||
682 | <PRE> $ freeramdisk /dev/ram2 | ||
683 | </PRE> | ||
684 | <P> | ||
685 | ------------------------------- | ||
686 | |||
687 | <DT><STRONG><A NAME="item_deallocvt">deallocvt</A></STRONG><DD> | ||
688 | <P> | ||
689 | Usage: deallocvt N | ||
690 | |||
691 | <P> | ||
692 | Deallocates unused virtual terminal /dev/ttyN | ||
693 | |||
694 | <P> | ||
695 | ------------------------------- | ||
696 | |||
697 | <DT><STRONG><A NAME="item_fsck">fsck.minix</A></STRONG><DD> | ||
698 | <P> | ||
699 | Usage: fsck.minix [<STRONG>-larvsmf</STRONG>] /dev/name | ||
700 | |||
701 | <P> | ||
702 | Performs a consistency check for MINIX filesystems. | ||
703 | |||
704 | <P> | ||
705 | OPTIONS: | ||
706 | |||
707 | <P> | ||
708 | <PRE> -l Lists all filenames | ||
709 | -r Perform interactive repairs | ||
710 | -a Perform automatic repairs | ||
711 | -v verbose | ||
712 | -s Outputs super-block information | ||
713 | -m Activates MINIX-like "mode not cleared" warnings | ||
714 | -f Force file system check. | ||
715 | </PRE> | ||
716 | <P> | ||
717 | ------------------------------- | ||
718 | |||
719 | <DT><STRONG><A NAME="item_grep">grep</A></STRONG><DD> | ||
720 | <P> | ||
721 | Usage: grep [OPTIONS]... PATTERN [FILE]... | ||
722 | |||
723 | <P> | ||
724 | Search for PATTERN in each FILE or standard input. | ||
725 | |||
726 | <P> | ||
727 | OPTIONS: | ||
728 | |||
729 | <P> | ||
730 | <PRE> -h suppress the prefixing filename on output | ||
731 | -i ignore case distinctions | ||
732 | -n print line number with output lines | ||
733 | -q be quiet. Returns 0 if result was found, 1 otherwise | ||
734 | -v select non-matching lines | ||
735 | </PRE> | ||
736 | <P> | ||
737 | This version of grep matches full regular expresions. | ||
738 | |||
739 | <P> | ||
740 | Example: | ||
741 | |||
742 | <P> | ||
743 | <PRE> $ grep root /etc/passwd | ||
744 | root:x:0:0:root:/root:/bin/bash | ||
745 | $ grep ^[rR]oo. /etc/passwd | ||
746 | root:x:0:0:root:/root:/bin/bash | ||
747 | </PRE> | ||
748 | <P> | ||
749 | ------------------------------- | ||
750 | |||
751 | <DT><STRONG><A NAME="item_gunzip">gunzip</A></STRONG><DD> | ||
752 | <P> | ||
753 | Usage: gunzip [OPTION]... FILE | ||
754 | |||
755 | <P> | ||
756 | Uncompress FILE (or standard input if FILE is '-'). | ||
757 | |||
758 | <P> | ||
759 | Options: | ||
760 | |||
761 | <P> | ||
762 | <PRE> -c Write output to standard output | ||
763 | -t Test compressed file integrity | ||
764 | </PRE> | ||
765 | <P> | ||
766 | Example: | ||
767 | |||
768 | <P> | ||
769 | <PRE> $ ls -la /tmp/BusyBox* | ||
770 | -rw-rw-r-- 1 andersen andersen 557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz | ||
771 | $ gunzip /tmp/BusyBox-0.43.tar.gz | ||
772 | $ ls -la /tmp/BusyBox* | ||
773 | -rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar | ||
774 | </PRE> | ||
775 | <P> | ||
776 | ------------------------------- | ||
777 | |||
778 | <DT><STRONG><A NAME="item_gzip">gzip</A></STRONG><DD> | ||
779 | <P> | ||
780 | Usage: gzip [OPTION]... FILE | ||
781 | |||
782 | <P> | ||
783 | Compress FILE with maximum compression. When FILE is '-', reads standard | ||
784 | input. Implies <STRONG>-c</STRONG>. | ||
785 | |||
786 | <P> | ||
787 | Options: | ||
788 | |||
789 | <P> | ||
790 | <PRE> -c Write output to standard output instead of FILE.gz | ||
791 | </PRE> | ||
792 | <P> | ||
793 | Example: | ||
794 | |||
795 | <P> | ||
796 | <PRE> $ ls -la /tmp/BusyBox* | ||
797 | -rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar | ||
798 | $ gzip /tmp/BusyBox-0.43.tar | ||
799 | $ ls -la /tmp/BusyBox* | ||
800 | -rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/BusyBox-0.43.tar.gz | ||
801 | </PRE> | ||
802 | <P> | ||
803 | ------------------------------- | ||
804 | |||
805 | <DT><STRONG><A NAME="item_halt">halt</A></STRONG><DD> | ||
806 | <P> | ||
807 | Usage: halt | ||
808 | |||
809 | <P> | ||
810 | This comand halts the system. | ||
811 | |||
812 | <P> | ||
813 | ------------------------------- | ||
814 | |||
815 | <DT><STRONG><A NAME="item_head">head</A></STRONG><DD> | ||
816 | <P> | ||
817 | Usage: head [OPTION] [FILE]... | ||
818 | |||
819 | <P> | ||
820 | Print first 10 lines of each FILE to standard output. With more than one | ||
821 | FILE, precede each with a header giving the file name. With no FILE, or | ||
822 | when FILE is -, read standard input. | ||
823 | |||
824 | <P> | ||
825 | Options: | ||
826 | |||
827 | <P> | ||
828 | <PRE> -n NUM Print first NUM lines instead of first 10 | ||
829 | </PRE> | ||
830 | <P> | ||
831 | Example: | ||
832 | |||
833 | <P> | ||
834 | <PRE> $ head -n 2 /etc/passwd | ||
835 | root:x:0:0:root:/root:/bin/bash | ||
836 | daemon:x:1:1:daemon:/usr/sbin:/bin/sh | ||
837 | </PRE> | ||
838 | <P> | ||
839 | ------------------------------- | ||
840 | |||
841 | <DT><STRONG><A NAME="item_hostid">hostid</A></STRONG><DD> | ||
842 | <P> | ||
843 | Usage: hostid | ||
844 | |||
845 | <P> | ||
846 | Prints out a unique 32-bit identifier for the current machine. The 32-bit | ||
847 | identifier is intended to be unique among all UNIX systems in existence. | ||
848 | |||
849 | <P> | ||
850 | ------------------------------- | ||
851 | |||
852 | <DT><STRONG><A NAME="item_hostname">hostname</A></STRONG><DD> | ||
853 | <P> | ||
854 | Usage: hostname [OPTION] {hostname | <STRONG>-F</STRONG> file} | ||
855 | |||
856 | <P> | ||
857 | Get or set the hostname or DNS domain name. If a hostname is given (or a | ||
858 | file with the <STRONG>-F</STRONG> parameter), the host name will be set. | ||
859 | |||
860 | <P> | ||
861 | Options: | ||
862 | |||
863 | <P> | ||
864 | <PRE> -s Short | ||
865 | -i Addresses for the hostname | ||
866 | -d DNS domain name | ||
867 | -F FILE Use the contents of FILE to specify the hostname | ||
868 | </PRE> | ||
869 | <P> | ||
870 | Example: | ||
871 | |||
872 | <P> | ||
873 | <PRE> $ hostname | ||
874 | slag | ||
875 | </PRE> | ||
876 | <P> | ||
877 | ------------------------------- | ||
878 | |||
879 | <DT><STRONG><A NAME="item_id">id</A></STRONG><DD> | ||
880 | <P> | ||
881 | Print information for USERNAME or the current user | ||
882 | |||
883 | <P> | ||
884 | Options: | ||
885 | |||
886 | <P> | ||
887 | <PRE> -g prints only the group ID | ||
888 | -u prints only the user ID | ||
889 | -r prints the real user ID instead of the effective ID (with -ug) | ||
890 | </PRE> | ||
891 | <P> | ||
892 | Example: | ||
893 | |||
894 | <P> | ||
895 | <PRE> $ id | ||
896 | uid=1000(andersen) gid=1000(andersen) | ||
897 | </PRE> | ||
898 | <P> | ||
899 | ------------------------------- | ||
900 | |||
901 | <DT><STRONG><A NAME="item_init">init</A></STRONG><DD> | ||
902 | <P> | ||
903 | Usage: init | ||
904 | |||
905 | <P> | ||
906 | Init is the parent of all processes. | ||
907 | |||
908 | <P> | ||
909 | This version of init is designed to be run only by the kernel. | ||
910 | |||
911 | <P> | ||
912 | BusyBox init doesn't support multiple runlevels. The runlevels field of the | ||
913 | /etc/inittab file is completely ignored by BusyBox init. If you want | ||
914 | runlevels, use sysvinit. | ||
915 | |||
916 | <P> | ||
917 | BusyBox init works just fine without an inittab. If no inittab is found, it | ||
918 | has the following default behavior: | ||
919 | |||
920 | <P> | ||
921 | <PRE> ::sysinit:/etc/init.d/rcS | ||
922 | ::askfirst:/bin/sh | ||
923 | </PRE> | ||
924 | <P> | ||
925 | if it detects that /dev/console is _not_ a serial console, it will also | ||
926 | run: | ||
927 | |||
928 | <P> | ||
929 | <PRE> tty2::askfirst:/bin/sh | ||
930 | </PRE> | ||
931 | <P> | ||
932 | If you choose to use an /etc/inittab file, the inittab entry format is as | ||
933 | follows: | ||
934 | |||
935 | <P> | ||
936 | <PRE> <id>:<runlevels>:<action>:<process> | ||
937 | </PRE> | ||
938 | <P> | ||
939 | <PRE> <id>: | ||
940 | </PRE> | ||
941 | <P> | ||
942 | <PRE> WARNING: This field has a non-traditional meaning for BusyBox init! | ||
943 | The id field is used by BusyBox init to specify the controlling tty for | ||
944 | the specified process to run on. The contents of this field are | ||
945 | appended to "/dev/" and used as-is. There is no need for this field to | ||
946 | be unique, although if it isn't you may have strange results. If this | ||
947 | field is left blank, it is completely ignored. Also note that if | ||
948 | BusyBox detects that a serial console is in use, then all entries | ||
949 | containing non-empty id fields will _not_ be run. BusyBox init does | ||
950 | nothing with utmp. We don't need no stinkin' utmp. | ||
951 | </PRE> | ||
952 | <P> | ||
953 | <PRE> <runlevels>: | ||
954 | </PRE> | ||
955 | <P> | ||
956 | <PRE> The runlevels field is completely ignored. | ||
957 | </PRE> | ||
958 | <P> | ||
959 | <PRE> <action>: | ||
960 | </PRE> | ||
961 | <P> | ||
962 | <PRE> Valid actions include: sysinit, respawn, askfirst, wait, | ||
963 | once, and ctrlaltdel. | ||
964 | </PRE> | ||
965 | <P> | ||
966 | <PRE> askfirst acts just like respawn, but before running the specified | ||
967 | process it displays the line "Please press Enter to activate this | ||
968 | console." and then waits for the user to press enter before starting | ||
969 | the specified process. | ||
970 | </PRE> | ||
971 | <P> | ||
972 | <PRE> Unrecognised actions (like initdefault) will cause init to emit | ||
973 | an error message, and then go along with its business. | ||
974 | </PRE> | ||
975 | <P> | ||
976 | <PRE> <process>: | ||
977 | </PRE> | ||
978 | <P> | ||
979 | <PRE> Specifies the process to be executed and it's command line. | ||
980 | </PRE> | ||
981 | <P> | ||
982 | Example /etc/inittab file: | ||
983 | |||
984 | <P> | ||
985 | <PRE> # This is run first except when booting in single-user mode. | ||
986 | # | ||
987 | ::sysinit:/etc/init.d/rcS | ||
988 | </PRE> | ||
989 | <P> | ||
990 | <PRE> # /bin/sh invocations on selected ttys | ||
991 | # | ||
992 | # Start an "askfirst" shell on the console (whatever that may be) | ||
993 | ::askfirst:/bin/sh | ||
994 | # Start an "askfirst" shell on /dev/tty2 | ||
995 | tty2::askfirst:/bin/sh | ||
996 | </PRE> | ||
997 | <P> | ||
998 | <PRE> # /sbin/getty invocations for selected ttys | ||
999 | # | ||
1000 | tty4::respawn:/sbin/getty 38400 tty4 | ||
1001 | tty5::respawn:/sbin/getty 38400 tty5 | ||
1002 | </PRE> | ||
1003 | <P> | ||
1004 | <PRE> # Example of how to put a getty on a serial line (for a terminal) | ||
1005 | # | ||
1006 | #ttyS0::respawn:/sbin/getty -L ttyS0 9600 vt100 | ||
1007 | #ttyS1::respawn:/sbin/getty -L ttyS1 9600 vt100 | ||
1008 | # | ||
1009 | # Example how to put a getty on a modem line. | ||
1010 | #ttyS2::respawn:/sbin/getty -x0 -s 57600 ttyS2 | ||
1011 | </PRE> | ||
1012 | <P> | ||
1013 | <PRE> # Stuff to do before rebooting | ||
1014 | ::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1 | ||
1015 | ::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1 | ||
1016 | </PRE> | ||
1017 | <P> | ||
1018 | ------------------------------- | ||
1019 | |||
1020 | <DT><STRONG><A NAME="item_kill">kill</A></STRONG><DD> | ||
1021 | <P> | ||
1022 | Usage: kill [<STRONG>-signal</STRONG>] process-id [process-id ...] | ||
1023 | |||
1024 | <P> | ||
1025 | Send a signal (default is SIGTERM) to the specified | ||
1026 | <CODE>process(es).</CODE> | ||
1027 | |||
1028 | <P> | ||
1029 | Options: | ||
1030 | |||
1031 | <P> | ||
1032 | <PRE> -l List all signal names and numbers. | ||
1033 | </PRE> | ||
1034 | <P> | ||
1035 | Example: | ||
1036 | |||
1037 | <P> | ||
1038 | <PRE> $ ps | grep apache | ||
1039 | 252 root root S [apache] | ||
1040 | 263 www-data www-data S [apache] | ||
1041 | 264 www-data www-data S [apache] | ||
1042 | 265 www-data www-data S [apache] | ||
1043 | 266 www-data www-data S [apache] | ||
1044 | 267 www-data www-data S [apache] | ||
1045 | $ kill 252 | ||
1046 | </PRE> | ||
1047 | <P> | ||
1048 | ------------------------------- | ||
1049 | |||
1050 | <DT><STRONG><A NAME="item_killall">killall</A></STRONG><DD> | ||
1051 | <P> | ||
1052 | Usage: killall [<STRONG>-signal</STRONG>] process-name [process-name ...] | ||
1053 | |||
1054 | <P> | ||
1055 | Send a signal (default is SIGTERM) to the specified | ||
1056 | <CODE>process(es).</CODE> | ||
1057 | |||
1058 | <P> | ||
1059 | Options: | ||
1060 | |||
1061 | <P> | ||
1062 | <PRE> -l List all signal names and numbers. | ||
1063 | </PRE> | ||
1064 | <P> | ||
1065 | Example: | ||
1066 | |||
1067 | <P> | ||
1068 | <PRE> $ killall apache | ||
1069 | </PRE> | ||
1070 | <P> | ||
1071 | ------------------------------- | ||
1072 | |||
1073 | <DT><STRONG><A NAME="item_length">length</A></STRONG><DD> | ||
1074 | <P> | ||
1075 | Usage: length STRING | ||
1076 | |||
1077 | <P> | ||
1078 | Prints out the length of the specified STRING. | ||
1079 | |||
1080 | <P> | ||
1081 | Example: | ||
1082 | |||
1083 | <P> | ||
1084 | <PRE> $ length "Hello" | ||
1085 | 5 | ||
1086 | </PRE> | ||
1087 | <P> | ||
1088 | ------------------------------- | ||
1089 | |||
1090 | <DT><STRONG><A NAME="item_ln">ln</A></STRONG><DD> | ||
1091 | <P> | ||
1092 | Usage: ln [OPTION] TARGET... LINK_NAME|DIRECTORY | ||
1093 | |||
1094 | <P> | ||
1095 | Create a link named LINK_NAME or DIRECTORY to the specified TARGET Options: | ||
1096 | |||
1097 | <P> | ||
1098 | <PRE> -s make symbolic links instead of hard links | ||
1099 | -f remove existing destination files | ||
1100 | |||
1101 | Example: | ||
1102 | </PRE> | ||
1103 | <P> | ||
1104 | <PRE> $ ln -s BusyBox /tmp/ls | ||
1105 | $ ls -l /tmp/ls | ||
1106 | lrwxrwxrwx 1 root root 7 Apr 12 18:39 ls -> BusyBox* | ||
1107 | </PRE> | ||
1108 | <P> | ||
1109 | ------------------------------- | ||
1110 | |||
1111 | <DT><STRONG><A NAME="item_loadacm">loadacm</A></STRONG><DD> | ||
1112 | <P> | ||
1113 | Usage: loadacm | ||
1114 | |||
1115 | <P> | ||
1116 | Loads an acm from standard input. | ||
1117 | |||
1118 | <P> | ||
1119 | Example: | ||
1120 | |||
1121 | <P> | ||
1122 | <PRE> $ loadacm < /etc/i18n/acmname | ||
1123 | </PRE> | ||
1124 | <P> | ||
1125 | ------------------------------- | ||
1126 | |||
1127 | <DT><STRONG><A NAME="item_loadfont">loadfont</A></STRONG><DD> | ||
1128 | <P> | ||
1129 | Usage: loadfont | ||
1130 | |||
1131 | <P> | ||
1132 | Loads a console font from standard input. | ||
1133 | |||
1134 | <P> | ||
1135 | Example: | ||
1136 | |||
1137 | <P> | ||
1138 | <PRE> $ loadfont < /etc/i18n/fontname | ||
1139 | </PRE> | ||
1140 | <P> | ||
1141 | ------------------------------- | ||
1142 | |||
1143 | <DT><STRONG><A NAME="item_loadkmap">loadkmap</A></STRONG><DD> | ||
1144 | <P> | ||
1145 | Usage: loadkmap | ||
1146 | |||
1147 | <P> | ||
1148 | Loads a binary keyboard translation table from standard input. | ||
1149 | |||
1150 | <P> | ||
1151 | Example: | ||
1152 | |||
1153 | <P> | ||
1154 | <PRE> $ loadkmap < /etc/i18n/lang-keymap | ||
1155 | </PRE> | ||
1156 | <P> | ||
1157 | ------------------------------- | ||
1158 | |||
1159 | <DT><STRONG><A NAME="item_logger">logger</A></STRONG><DD> | ||
1160 | <P> | ||
1161 | Usage: logger [OPTION]... [MESSAGE] | ||
1162 | |||
1163 | <P> | ||
1164 | Write MESSAGE to the system log. If MESSAGE is '-', log stdin. | ||
1165 | |||
1166 | <P> | ||
1167 | Options: | ||
1168 | |||
1169 | <P> | ||
1170 | <PRE> -s Log to stderr as well as the system log. | ||
1171 | -t Log using the specified tag (defaults to user name). | ||
1172 | -p Enter the message with the specified priority. | ||
1173 | This may be numerical or a ``facility.level'' pair. | ||
1174 | </PRE> | ||
1175 | <P> | ||
1176 | Example: | ||
1177 | |||
1178 | <P> | ||
1179 | <PRE> $ logger "hello" | ||
1180 | </PRE> | ||
1181 | <P> | ||
1182 | ------------------------------- | ||
1183 | |||
1184 | <DT><STRONG><A NAME="item_logname">logname</A></STRONG><DD> | ||
1185 | <P> | ||
1186 | Usage: logname | ||
1187 | |||
1188 | <P> | ||
1189 | Print the name of the current user. | ||
1190 | |||
1191 | <P> | ||
1192 | Example: | ||
1193 | |||
1194 | <P> | ||
1195 | <PRE> $ logname | ||
1196 | root | ||
1197 | </PRE> | ||
1198 | <P> | ||
1199 | ------------------------------- | ||
1200 | |||
1201 | <DT><STRONG><A NAME="item_ls">ls</A></STRONG><DD> | ||
1202 | <P> | ||
1203 | Usage: ls [<STRONG>-1acdelnpuxACF</STRONG>] [filenames...] | ||
1204 | |||
1205 | <P> | ||
1206 | Options: | ||
1207 | |||
1208 | <P> | ||
1209 | <PRE> -a do not hide entries starting with . | ||
1210 | -c with -l: show ctime (the time of last | ||
1211 | modification of file status information) | ||
1212 | -d list directory entries instead of contents | ||
1213 | -e list both full date and full time | ||
1214 | -l use a long listing format | ||
1215 | -n list numeric UIDs and GIDs instead of names | ||
1216 | -p append indicator (one of /=@|) to entries | ||
1217 | -u with -l: show access time (the time of last | ||
1218 | access of the file) | ||
1219 | -x list entries by lines instead of by columns | ||
1220 | -A do not list implied . and .. | ||
1221 | -C list entries by columns | ||
1222 | -F append indicator (one of */=@|) to entries | ||
1223 | </PRE> | ||
1224 | <P> | ||
1225 | ------------------------------- | ||
1226 | |||
1227 | <DT><STRONG><A NAME="item_lsmod">lsmod</A></STRONG><DD> | ||
1228 | <P> | ||
1229 | Usage: lsmod | ||
1230 | |||
1231 | <P> | ||
1232 | Shows a list of all currently loaded kernel modules. | ||
1233 | |||
1234 | <P> | ||
1235 | ------------------------------- | ||
1236 | |||
1237 | <DT><STRONG><A NAME="item_makedevs">makedevs</A></STRONG><DD> | ||
1238 | <P> | ||
1239 | Usage: makedevs NAME TYPE MAJOR MINOR FIRST LAST [s] | ||
1240 | |||
1241 | <P> | ||
1242 | Creates a range of block or character special files | ||
1243 | |||
1244 | <P> | ||
1245 | TYPEs include: | ||
1246 | |||
1247 | <P> | ||
1248 | <PRE> b: Make a block (buffered) device. | ||
1249 | c or u: Make a character (un-buffered) device. | ||
1250 | p: Make a named pipe. MAJOR and MINOR are ignored for named pipes. | ||
1251 | </PRE> | ||
1252 | <P> | ||
1253 | FIRST specifies the number appended to NAME to create the first device. | ||
1254 | LAST specifies the number of the last item that should be created. If 's' | ||
1255 | is the last argument, the base device is created as well. | ||
1256 | |||
1257 | <P> | ||
1258 | Example: | ||
1259 | |||
1260 | <P> | ||
1261 | <PRE> $ makedevs /dev/ttyS c 4 66 2 63 | ||
1262 | [creates ttyS2-ttyS63] | ||
1263 | $ makedevs /dev/hda b 3 0 0 8 s | ||
1264 | [creates hda,hda1-hda8] | ||
1265 | </PRE> | ||
1266 | <P> | ||
1267 | ------------------------------- | ||
1268 | |||
1269 | <DT><STRONG><A NAME="item_math">math</A></STRONG><DD> | ||
1270 | <P> | ||
1271 | Usage: math expression ... | ||
1272 | |||
1273 | <P> | ||
1274 | This is a Tiny RPN calculator that understands the following operations: +, | ||
1275 | -, /, *, and, or, not, eor. | ||
1276 | |||
1277 | <P> | ||
1278 | Example: | ||
1279 | |||
1280 | <P> | ||
1281 | <PRE> $ math 2 2 add | ||
1282 | 4 | ||
1283 | $ math 8 8 \* 2 2 + / | ||
1284 | 16 | ||
1285 | $ math 0 1 and | ||
1286 | 0 | ||
1287 | $ math 0 1 or | ||
1288 | 1 | ||
1289 | </PRE> | ||
1290 | <P> | ||
1291 | ------------------------------- | ||
1292 | |||
1293 | <DT><STRONG><A NAME="item_mkdir">mkdir</A></STRONG><DD> | ||
1294 | <P> | ||
1295 | Usage: mkdir [OPTION] DIRECTORY... | ||
1296 | |||
1297 | <P> | ||
1298 | Create the <CODE>DIRECTORY(ies),</CODE> if they do not already exist | ||
1299 | |||
1300 | <P> | ||
1301 | Options: | ||
1302 | |||
1303 | <P> | ||
1304 | <PRE> -m set permission mode (as in chmod), not rwxrwxrwx - umask | ||
1305 | -p no error if dir exists, make parent directories as needed | ||
1306 | </PRE> | ||
1307 | <P> | ||
1308 | Example: | ||
1309 | |||
1310 | <P> | ||
1311 | <PRE> $ mkdir /tmp/foo | ||
1312 | $ mkdir /tmp/foo | ||
1313 | /tmp/foo: File exists | ||
1314 | $ mkdir /tmp/foo/bar/baz | ||
1315 | /tmp/foo/bar/baz: No such file or directory | ||
1316 | $ mkdir -p /tmp/foo/bar/baz | ||
1317 | </PRE> | ||
1318 | <P> | ||
1319 | ------------------------------- | ||
1320 | |||
1321 | <DT><STRONG><A NAME="item_mkfifo">mkfifo</A></STRONG><DD> | ||
1322 | <P> | ||
1323 | Usage: mkfifo [OPTIONS] name | ||
1324 | |||
1325 | <P> | ||
1326 | Creates a named pipe (identical to 'mknod name p') | ||
1327 | |||
1328 | <P> | ||
1329 | Options: | ||
1330 | |||
1331 | <P> | ||
1332 | <PRE> -m create the pipe using the specified mode (default a=rw) | ||
1333 | </PRE> | ||
1334 | <P> | ||
1335 | ------------------------------- | ||
1336 | |||
1337 | <DT><STRONG><A NAME="item_mkfs">mkfs.minix</A></STRONG><DD> | ||
1338 | <P> | ||
1339 | Usage: mkfs.minix [<STRONG>-c</STRONG> | <STRONG>-l</STRONG> filename] [<STRONG>-nXX</STRONG>] [<STRONG>-iXX</STRONG>] /dev/name [blocks] | ||
1340 | |||
1341 | <P> | ||
1342 | Make a MINIX filesystem. | ||
1343 | |||
1344 | <P> | ||
1345 | OPTIONS: | ||
1346 | |||
1347 | <P> | ||
1348 | <PRE> -c Check the device for bad blocks | ||
1349 | -n [14|30] Specify the maximum length of filenames | ||
1350 | -i Specify the number of inodes for the filesystem | ||
1351 | -l FILENAME Read the bad blocks list from FILENAME | ||
1352 | -v Make a Minix version 2 filesystem | ||
1353 | </PRE> | ||
1354 | <P> | ||
1355 | ------------------------------- | ||
1356 | |||
1357 | <DT><STRONG><A NAME="item_mknod">mknod</A></STRONG><DD> | ||
1358 | <P> | ||
1359 | Usage: mknod [OPTIONS] NAME TYPE MAJOR MINOR | ||
1360 | |||
1361 | <P> | ||
1362 | Create a special file (block, character, or pipe). | ||
1363 | |||
1364 | <P> | ||
1365 | Options: | ||
1366 | |||
1367 | <P> | ||
1368 | <PRE> -m create the special file using the specified mode (default a=rw) | ||
1369 | </PRE> | ||
1370 | <P> | ||
1371 | TYPEs include: b: Make a block (buffered) device. c or u: Make a character | ||
1372 | (un-buffered) device. p: Make a named pipe. MAJOR and MINOR are ignored for | ||
1373 | named pipes. | ||
1374 | |||
1375 | <P> | ||
1376 | Example: | ||
1377 | |||
1378 | <P> | ||
1379 | <PRE> $ mknod /dev/fd0 b 2 0 | ||
1380 | $ mknod -m 644 /tmp/pipe p | ||
1381 | </PRE> | ||
1382 | <P> | ||
1383 | ------------------------------- | ||
1384 | |||
1385 | <DT><STRONG><A NAME="item_mkswap">mkswap</A></STRONG><DD> | ||
1386 | <P> | ||
1387 | Usage: mkswap [<STRONG>-c</STRONG>] [<STRONG>-v0</STRONG>|<STRONG>-v1</STRONG>] device [block-count] | ||
1388 | |||
1389 | <P> | ||
1390 | Prepare a disk partition to be used as a swap partition. | ||
1391 | |||
1392 | <P> | ||
1393 | Options: | ||
1394 | |||
1395 | <P> | ||
1396 | <PRE> -c Check for read-ability. | ||
1397 | -v0 Make version 0 swap [max 128 Megs]. | ||
1398 | -v1 Make version 1 swap [big!] (default for kernels > 2.1.117). | ||
1399 | block-count Number of block to use (default is entire partition). | ||
1400 | </PRE> | ||
1401 | <P> | ||
1402 | ------------------------------- | ||
1403 | |||
1404 | <DT><STRONG><A NAME="item_mktemp">mktemp</A></STRONG><DD> | ||
1405 | <P> | ||
1406 | Usage: mktemp [<STRONG>-q</STRONG>] TEMPLATE | ||
1407 | |||
1408 | <P> | ||
1409 | Creates a temporary file with its name based on TEMPLATE. TEMPLATE is any | ||
1410 | name with six `Xs' (i.e. /tmp/temp.XXXXXX). | ||
1411 | |||
1412 | <P> | ||
1413 | Example: | ||
1414 | |||
1415 | <P> | ||
1416 | <PRE> $ mktemp /tmp/temp.XXXXXX | ||
1417 | /tmp/temp.mWiLjM | ||
1418 | $ ls -la /tmp/temp.mWiLjM | ||
1419 | -rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM | ||
1420 | </PRE> | ||
1421 | <P> | ||
1422 | ------------------------------- | ||
1423 | |||
1424 | <DT><STRONG><A NAME="item_nc">nc</A></STRONG><DD> | ||
1425 | <P> | ||
1426 | Usage: nc [IP] [port] | ||
1427 | |||
1428 | <P> | ||
1429 | Netcat opens a pipe to IP:port | ||
1430 | |||
1431 | <P> | ||
1432 | Example: | ||
1433 | |||
1434 | <P> | ||
1435 | <PRE> $ nc foobar.somedomain.com 25 | ||
1436 | 220 foobar ESMTP Exim 3.12 #1 Sat, 15 Apr 2000 00:03:02 -0600 | ||
1437 | help | ||
1438 | 214-Commands supported: | ||
1439 | 214- HELO EHLO MAIL RCPT DATA AUTH | ||
1440 | 214 NOOP QUIT RSET HELP | ||
1441 | quit | ||
1442 | 221 foobar closing connection | ||
1443 | |||
1444 | ------------------------------- | ||
1445 | </PRE> | ||
1446 | <DT><STRONG><A NAME="item_more">more</A></STRONG><DD> | ||
1447 | <P> | ||
1448 | Usage: more [file ...] | ||
1449 | |||
1450 | <P> | ||
1451 | More is a filter for paging through text one screenful at a time. | ||
1452 | |||
1453 | <P> | ||
1454 | Example: | ||
1455 | |||
1456 | <P> | ||
1457 | <PRE> $ dmesg | more | ||
1458 | </PRE> | ||
1459 | <P> | ||
1460 | ------------------------------- | ||
1461 | |||
1462 | <DT><STRONG><A NAME="item_mount">mount</A></STRONG><DD> | ||
1463 | <P> | ||
1464 | Usage: mount [flags] mount [flags] device directory [<STRONG>-o</STRONG> options,more-options] | ||
1465 | |||
1466 | <P> | ||
1467 | Flags: | ||
1468 | |||
1469 | <P> | ||
1470 | <PRE> -a: Mount all file systems in fstab. | ||
1471 | -o option: One of many filesystem options, listed below. | ||
1472 | -r: Mount the filesystem read-only. | ||
1473 | -t fs-type: Specify the filesystem type. | ||
1474 | -w: Mount for reading and writing (default). | ||
1475 | </PRE> | ||
1476 | <P> | ||
1477 | Options for use with the ``<STRONG>-o</STRONG>'' flag: | ||
1478 | |||
1479 | <P> | ||
1480 | <PRE> async/sync: Writes are asynchronous / synchronous. | ||
1481 | atime/noatime: Enable / disable updates to inode access times. | ||
1482 | dev/nodev: Allow use of special device files / disallow them. | ||
1483 | exec/noexec: Allow use of executable files / disallow them. | ||
1484 | loop: Mounts a file via loop device. | ||
1485 | suid/nosuid: Allow set-user-id-root programs / disallow them. | ||
1486 | remount: Re-mount a currently-mounted filesystem, changing its flags. | ||
1487 | ro/rw: Mount for read-only / read-write. | ||
1488 | There are EVEN MORE flags that are specific to each filesystem. | ||
1489 | You'll have to see the written documentation for those. | ||
1490 | </PRE> | ||
1491 | <P> | ||
1492 | Example: | ||
1493 | |||
1494 | <P> | ||
1495 | <PRE> $ mount | ||
1496 | /dev/hda3 on / type minix (rw) | ||
1497 | proc on /proc type proc (rw) | ||
1498 | devpts on /dev/pts type devpts (rw) | ||
1499 | $ mount /dev/fd0 /mnt -t msdos -o ro | ||
1500 | $ mount /tmp/diskimage /opt -t ext2 -o loop | ||
1501 | </PRE> | ||
1502 | <P> | ||
1503 | ------------------------------- | ||
1504 | |||
1505 | <DT><STRONG><A NAME="item_mt">mt</A></STRONG><DD> | ||
1506 | <P> | ||
1507 | Usage: mt [<STRONG>-f</STRONG> device] opcode value | ||
1508 | |||
1509 | <P> | ||
1510 | Control magnetic tape drive operation | ||
1511 | |||
1512 | <P> | ||
1513 | ------------------------------- | ||
1514 | |||
1515 | <DT><STRONG><A NAME="item_mv">mv</A></STRONG><DD> | ||
1516 | <P> | ||
1517 | Usage: mv SOURCE DEST | ||
1518 | |||
1519 | <P> | ||
1520 | <PRE> or: mv SOURCE... DIRECTORY | ||
1521 | </PRE> | ||
1522 | <P> | ||
1523 | Rename SOURCE to DEST, or move <CODE>SOURCE(s)</CODE> to DIRECTORY. | ||
1524 | |||
1525 | <P> | ||
1526 | Example: | ||
1527 | |||
1528 | <P> | ||
1529 | <PRE> $ mv /tmp/foo /bin/bar | ||
1530 | </PRE> | ||
1531 | <P> | ||
1532 | ------------------------------- | ||
1533 | |||
1534 | <DT><STRONG><A NAME="item_nslookup">nslookup</A></STRONG><DD> | ||
1535 | <P> | ||
1536 | Usage: nslookup [HOST] | ||
1537 | |||
1538 | <P> | ||
1539 | Queries the nameserver for the IP address of the given HOST | ||
1540 | |||
1541 | <P> | ||
1542 | Example: | ||
1543 | |||
1544 | <P> | ||
1545 | <PRE> $ nslookup localhost | ||
1546 | Server: default | ||
1547 | Address: default | ||
1548 | </PRE> | ||
1549 | <P> | ||
1550 | <PRE> Name: debian | ||
1551 | Address: 127.0.0.1 | ||
1552 | </PRE> | ||
1553 | <P> | ||
1554 | ------------------------------- | ||
1555 | |||
1556 | <DT><STRONG><A NAME="item_ping">ping</A></STRONG><DD> | ||
1557 | <P> | ||
1558 | Usage: ping [OPTION]... host | ||
1559 | |||
1560 | <P> | ||
1561 | Send ICMP ECHO_REQUEST packets to network hosts. | ||
1562 | |||
1563 | <P> | ||
1564 | Options: | ||
1565 | |||
1566 | <P> | ||
1567 | <PRE> -c COUNT Send only COUNT pings. | ||
1568 | -q Quiet mode, only displays output at start | ||
1569 | and when finished. | ||
1570 | Example: | ||
1571 | </PRE> | ||
1572 | <P> | ||
1573 | <PRE> $ ping localhost | ||
1574 | PING slag (127.0.0.1): 56 data bytes | ||
1575 | 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=20.1 ms | ||
1576 | </PRE> | ||
1577 | <P> | ||
1578 | <PRE> --- debian ping statistics --- | ||
1579 | 1 packets transmitted, 1 packets received, 0% packet loss | ||
1580 | round-trip min/avg/max = 20.1/20.1/20.1 ms | ||
1581 | </PRE> | ||
1582 | <P> | ||
1583 | ------------------------------- | ||
1584 | |||
1585 | <DT><STRONG><A NAME="item_poweroff">poweroff</A></STRONG><DD> | ||
1586 | <P> | ||
1587 | Shuts down the system, and requests that the kernel turn off power upon | ||
1588 | halting. | ||
1589 | |||
1590 | <P> | ||
1591 | ------------------------------- | ||
1592 | |||
1593 | <DT><STRONG><A NAME="item_printf">printf</A></STRONG><DD> | ||
1594 | <P> | ||
1595 | Usage: printf format [argument...] | ||
1596 | |||
1597 | <P> | ||
1598 | Formats and prints the given data in a manner similar to the C printf | ||
1599 | command. | ||
1600 | |||
1601 | <P> | ||
1602 | Example: | ||
1603 | |||
1604 | <P> | ||
1605 | <PRE> $ printf "Val=%d\n" 5 | ||
1606 | Val=5 | ||
1607 | </PRE> | ||
1608 | <P> | ||
1609 | ------------------------------- | ||
1610 | |||
1611 | <DT><STRONG><A NAME="item_ps">ps</A></STRONG><DD> | ||
1612 | <P> | ||
1613 | Usage: ps | ||
1614 | |||
1615 | <P> | ||
1616 | Report process status | ||
1617 | |||
1618 | <P> | ||
1619 | This version of ps accepts no options. | ||
1620 | |||
1621 | <P> | ||
1622 | Example: | ||
1623 | |||
1624 | <P> | ||
1625 | <PRE> $ ps | ||
1626 | PID Uid Gid State Command | ||
1627 | 1 root root S init | ||
1628 | 2 root root S [kflushd] | ||
1629 | 3 root root S [kupdate] | ||
1630 | 4 root root S [kpiod] | ||
1631 | 5 root root S [kswapd] | ||
1632 | 742 andersen andersen S [bash] | ||
1633 | 743 andersen andersen S -bash | ||
1634 | 745 root root S [getty] | ||
1635 | 2990 andersen andersen R ps | ||
1636 | </PRE> | ||
1637 | <P> | ||
1638 | ------------------------------- | ||
1639 | |||
1640 | <DT><STRONG><A NAME="item_pwd">pwd</A></STRONG><DD> | ||
1641 | <P> | ||
1642 | Prints the full filename of the current working directory. | ||
1643 | |||
1644 | <P> | ||
1645 | Example: | ||
1646 | |||
1647 | <P> | ||
1648 | <PRE> $ pwd | ||
1649 | /root | ||
1650 | </PRE> | ||
1651 | <P> | ||
1652 | ------------------------------- | ||
1653 | |||
1654 | <DT><STRONG><A NAME="item_reboot">reboot</A></STRONG><DD> | ||
1655 | <P> | ||
1656 | Instructs the kernel to reboot the system. | ||
1657 | |||
1658 | <P> | ||
1659 | ------------------------------- | ||
1660 | |||
1661 | <DT><STRONG><A NAME="item_rm">rm</A></STRONG><DD> | ||
1662 | <P> | ||
1663 | Usage: rm [OPTION]... FILE... | ||
1664 | |||
1665 | <P> | ||
1666 | Remove (unlink) the <CODE>FILE(s).</CODE> | ||
1667 | |||
1668 | <P> | ||
1669 | Options: | ||
1670 | |||
1671 | <P> | ||
1672 | <PRE> -f remove existing destinations, never prompt | ||
1673 | -r or -R remove the contents of directories recursively | ||
1674 | </PRE> | ||
1675 | <P> | ||
1676 | Example: | ||
1677 | |||
1678 | <P> | ||
1679 | <PRE> $ rm -rf /tmp/foo | ||
1680 | </PRE> | ||
1681 | <P> | ||
1682 | ------------------------------- | ||
1683 | |||
1684 | <DT><STRONG><A NAME="item_rmdir">rmdir</A></STRONG><DD> | ||
1685 | <P> | ||
1686 | Usage: rmdir [OPTION]... DIRECTORY... | ||
1687 | |||
1688 | <P> | ||
1689 | Remove the <CODE>DIRECTORY(ies),</CODE> if they are empty. | ||
1690 | |||
1691 | <P> | ||
1692 | Example: | ||
1693 | |||
1694 | <P> | ||
1695 | <PRE> # rmdir /tmp/foo | ||
1696 | </PRE> | ||
1697 | <P> | ||
1698 | ------------------------------- | ||
1699 | |||
1700 | <DT><STRONG><A NAME="item_rmmod">rmmod</A></STRONG><DD> | ||
1701 | <P> | ||
1702 | Usage: rmmod [OPTION]... [MODULE]... | ||
1703 | |||
1704 | <P> | ||
1705 | Unloads the specified kernel modules from the kernel. | ||
1706 | |||
1707 | <P> | ||
1708 | Options: | ||
1709 | |||
1710 | <P> | ||
1711 | <PRE> -a Try to remove all unused kernel modules. | ||
1712 | </PRE> | ||
1713 | <P> | ||
1714 | Example: | ||
1715 | |||
1716 | <P> | ||
1717 | <PRE> $ rmmod tulip | ||
1718 | </PRE> | ||
1719 | <P> | ||
1720 | ------------------------------- | ||
1721 | |||
1722 | <DT><STRONG><A NAME="item_sed">sed</A></STRONG><DD> | ||
1723 | <P> | ||
1724 | Usage: sed [<STRONG>-n</STRONG>] <STRONG>-e</STRONG> script [file...] | ||
1725 | |||
1726 | <P> | ||
1727 | Allowed sed scripts come in the following form: | ||
1728 | |||
1729 | <P> | ||
1730 | <PRE> 'ADDR [!] COMMAND' | ||
1731 | </PRE> | ||
1732 | <P> | ||
1733 | <PRE> where address ADDR can be: | ||
1734 | NUMBER Match specified line number | ||
1735 | $ Match last line | ||
1736 | /REGEXP/ Match specified regexp | ||
1737 | (! inverts the meaning of the match) | ||
1738 | </PRE> | ||
1739 | <P> | ||
1740 | <PRE> and COMMAND can be: | ||
1741 | s/regexp/replacement/[igp] | ||
1742 | which attempt to match regexp against the pattern space | ||
1743 | and if successful replaces the matched portion with replacement. | ||
1744 | </PRE> | ||
1745 | <P> | ||
1746 | <PRE> aTEXT | ||
1747 | which appends TEXT after the pattern space | ||
1748 | </PRE> | ||
1749 | <P> | ||
1750 | Options: | ||
1751 | |||
1752 | <P> | ||
1753 | <PRE> -e add the script to the commands to be executed | ||
1754 | -n suppress automatic printing of pattern space | ||
1755 | </PRE> | ||
1756 | <P> | ||
1757 | This version of sed matches full regular expresions. | ||
1758 | |||
1759 | <P> | ||
1760 | Example: | ||
1761 | |||
1762 | <P> | ||
1763 | <PRE> $ echo "foo" | sed -e 's/f[a-zA-Z]o/bar/g' | ||
1764 | bar | ||
1765 | </PRE> | ||
1766 | <P> | ||
1767 | ------------------------------- | ||
1768 | |||
1769 | <DT><STRONG><A NAME="item_setkeycodes">setkeycodes</A></STRONG><DD> | ||
1770 | <P> | ||
1771 | Usage: setkeycodes SCANCODE KEYCODE ... | ||
1772 | |||
1773 | <P> | ||
1774 | Set entries into the kernel's scancode-to-keycode map, allowing unusual | ||
1775 | keyboards to generate usable keycodes. | ||
1776 | |||
1777 | <P> | ||
1778 | SCANCODE may be either xx or e0xx (hexadecimal), and KEYCODE is given in | ||
1779 | decimal | ||
1780 | |||
1781 | <P> | ||
1782 | Example: | ||
1783 | |||
1784 | <P> | ||
1785 | <PRE> # setkeycodes e030 127 | ||
1786 | </PRE> | ||
1787 | <P> | ||
1788 | ------------------------------- | ||
1789 | |||
1790 | <DT><STRONG><A NAME="item_sh">sh</A></STRONG><DD> | ||
1791 | <P> | ||
1792 | Usage: sh | ||
1793 | |||
1794 | <P> | ||
1795 | lash -- the BusyBox LAme SHell (command interpreter) | ||
1796 | |||
1797 | <P> | ||
1798 | This command does not yet have proper documentation. | ||
1799 | |||
1800 | <P> | ||
1801 | Use lash just as you would use any other shell. It properly handles pipes, | ||
1802 | redirects, job control, can be used as the shell for scripts (#!/bin/sh), | ||
1803 | and has a sufficient set of builtins to do what is needed. It does not | ||
1804 | (yet) support Bourne Shell syntax. If you need things like | ||
1805 | ``if-then-else'', ``while'', and such, use ash or bash. If you just need a | ||
1806 | very simple and extremely small shell, this will do the job. | ||
1807 | |||
1808 | <P> | ||
1809 | ------------------------------- | ||
1810 | |||
1811 | <DT><STRONG><A NAME="item_sfdisk">sfdisk</A></STRONG><DD> | ||
1812 | <P> | ||
1813 | Usage: sfdisk [options] device ... | ||
1814 | |||
1815 | <P> | ||
1816 | device: something like /dev/hda or /dev/sda | ||
1817 | |||
1818 | <P> | ||
1819 | useful options: | ||
1820 | |||
1821 | <P> | ||
1822 | <PRE> -s [or --show-size]: list size of a partition | ||
1823 | -c [or --id]: print or change partition Id | ||
1824 | -l [or --list]: list partitions of each device | ||
1825 | -d [or --dump]: idem, but in a format suitable for later input | ||
1826 | -i [or --increment]: number cylinders etc. from 1 instead of from 0 | ||
1827 | -uS, -uB, -uC, -uM: accept/report in units of sectors/blocks/cylinders/MB | ||
1828 | -T [or --list-types]:list the known partition types | ||
1829 | -D [or --DOS]: for DOS-compatibility: waste a little space | ||
1830 | -R [or --re-read]: make kernel reread partition table | ||
1831 | -N# : change only the partition with number # | ||
1832 | -n : do not actually write to disk | ||
1833 | -O file : save the sectors that will be overwritten to file | ||
1834 | -I file : restore these sectors again | ||
1835 | -v [or --version]: print version | ||
1836 | -? [or --help]: print this message | ||
1837 | </PRE> | ||
1838 | <P> | ||
1839 | dangerous options: | ||
1840 | |||
1841 | <P> | ||
1842 | <PRE> -g [or --show-geometry]: print the kernel's idea of the geometry | ||
1843 | -x [or --show-extended]: also list extended partitions on output | ||
1844 | </PRE> | ||
1845 | <P> | ||
1846 | <PRE> or expect descriptors for them on input | ||
1847 | -L [or --Linux]: do not complain about things irrelevant for Linux | ||
1848 | -q [or --quiet]: suppress warning messages | ||
1849 | You can override the detected geometry using: | ||
1850 | -C# [or --cylinders #]:set the number of cylinders to use | ||
1851 | -H# [or --heads #]: set the number of heads to use | ||
1852 | -S# [or --sectors #]: set the number of sectors to use | ||
1853 | </PRE> | ||
1854 | <P> | ||
1855 | You can disable all consistency checking with: | ||
1856 | |||
1857 | <P> | ||
1858 | <PRE> -f [or --force]: do what I say, even if it is stupid | ||
1859 | </PRE> | ||
1860 | <P> | ||
1861 | ------------------------------- | ||
1862 | |||
1863 | <DT><STRONG><A NAME="item_sleep">sleep</A></STRONG><DD> | ||
1864 | <P> | ||
1865 | Usage: sleep N | ||
1866 | |||
1867 | <P> | ||
1868 | Pause for N seconds. | ||
1869 | |||
1870 | <P> | ||
1871 | Example: | ||
1872 | |||
1873 | <P> | ||
1874 | <PRE> $ sleep 2 | ||
1875 | [2 second delay results] | ||
1876 | </PRE> | ||
1877 | <P> | ||
1878 | ------------------------------- | ||
1879 | |||
1880 | <DT><STRONG><A NAME="item_sort">sort</A></STRONG><DD> | ||
1881 | <P> | ||
1882 | Usage: sort [<STRONG>-n</STRONG>] [<STRONG>-r</STRONG>] [FILE]... | ||
1883 | |||
1884 | <P> | ||
1885 | Sorts lines of text in the specified files | ||
1886 | |||
1887 | <P> | ||
1888 | Example: | ||
1889 | |||
1890 | <P> | ||
1891 | <PRE> $ echo -e "e\nf\nb\nd\nc\na" | sort | ||
1892 | a | ||
1893 | b | ||
1894 | c | ||
1895 | d | ||
1896 | e | ||
1897 | f | ||
1898 | </PRE> | ||
1899 | <P> | ||
1900 | ------------------------------- | ||
1901 | |||
1902 | <DT><STRONG><A NAME="item_sync">sync</A></STRONG><DD> | ||
1903 | <P> | ||
1904 | Usage: sync | ||
1905 | |||
1906 | <P> | ||
1907 | Write all buffered filesystem blocks to disk. | ||
1908 | |||
1909 | <P> | ||
1910 | ------------------------------- | ||
1911 | |||
1912 | <DT><STRONG><A NAME="item_syslogd">syslogd</A></STRONG><DD> | ||
1913 | <P> | ||
1914 | Usage: syslogd [OPTION]... | ||
1915 | |||
1916 | <P> | ||
1917 | Linux system and kernel (provides klogd) logging utility. Note that this | ||
1918 | version of syslogd/klogd ignores /etc/syslog.conf. | ||
1919 | |||
1920 | <P> | ||
1921 | Options: | ||
1922 | |||
1923 | <P> | ||
1924 | <PRE> -m Change the mark timestamp interval. default=20min. 0=off | ||
1925 | -n Do not fork into the background (for when run by init) | ||
1926 | -K Do not start up the klogd process (by default syslogd spawns klogd). | ||
1927 | -O Specify an alternate log file. default=/var/log/messages | ||
1928 | </PRE> | ||
1929 | <P> | ||
1930 | ------------------------------- | ||
1931 | |||
1932 | <DT><STRONG><A NAME="item_swapon">swapon</A></STRONG><DD> | ||
1933 | <P> | ||
1934 | Usage: swapon [OPTION] [device] | ||
1935 | |||
1936 | <P> | ||
1937 | Start swapping virtual memory pages on the given device. | ||
1938 | |||
1939 | <P> | ||
1940 | Options: | ||
1941 | |||
1942 | <P> | ||
1943 | <PRE> -a Start swapping on all swap devices | ||
1944 | </PRE> | ||
1945 | <P> | ||
1946 | ------------------------------- | ||
1947 | |||
1948 | <DT><STRONG><A NAME="item_swapoff">swapoff</A></STRONG><DD> | ||
1949 | <P> | ||
1950 | Usage: swapoff [OPTION] [device] | ||
1951 | |||
1952 | <P> | ||
1953 | Stop swapping virtual memory pages on the given device. | ||
1954 | |||
1955 | <P> | ||
1956 | Options: | ||
1957 | |||
1958 | <P> | ||
1959 | <PRE> -a Stop swapping on all swap devices | ||
1960 | </PRE> | ||
1961 | <P> | ||
1962 | ------------------------------- | ||
1963 | |||
1964 | <DT><STRONG><A NAME="item_tail">tail</A></STRONG><DD> | ||
1965 | <P> | ||
1966 | Usage: tail [OPTION] [FILE]... | ||
1967 | |||
1968 | <P> | ||
1969 | Print last 10 lines of each FILE to standard output. With more than one | ||
1970 | FILE, precede each with a header giving the file name. With no FILE, or | ||
1971 | when FILE is -, read standard input. | ||
1972 | |||
1973 | <P> | ||
1974 | Options: | ||
1975 | |||
1976 | <P> | ||
1977 | <PRE> -n NUM Print last NUM lines instead of first 10 | ||
1978 | -f Output data as the file grows. This version | ||
1979 | of 'tail -f' supports only one file at a time. | ||
1980 | </PRE> | ||
1981 | <P> | ||
1982 | Example: | ||
1983 | |||
1984 | <P> | ||
1985 | <PRE> $ tail -n 1 /etc/resolv.conf | ||
1986 | nameserver 10.0.0.1 | ||
1987 | </PRE> | ||
1988 | <P> | ||
1989 | ------------------------------- | ||
1990 | |||
1991 | <DT><STRONG><A NAME="item_tar">tar</A></STRONG><DD> | ||
1992 | <P> | ||
1993 | Usage: tar -[cxtvO] [<STRONG>--exclude</STRONG> File] [<STRONG>-f</STRONG> tarFile] [FILE] ... | ||
1994 | |||
1995 | <P> | ||
1996 | Create, extract, or list files from a tar file. Note that this version of | ||
1997 | tar treats hard links as separate files. | ||
1998 | |||
1999 | <P> | ||
2000 | Main operation mode: | ||
2001 | |||
2002 | <P> | ||
2003 | <PRE> c create | ||
2004 | x extract | ||
2005 | t list | ||
2006 | </PRE> | ||
2007 | <P> | ||
2008 | File selection: | ||
2009 | |||
2010 | <P> | ||
2011 | <PRE> f name of tarfile or "-" for stdin | ||
2012 | O extract to stdout | ||
2013 | --exclude file to exclude | ||
2014 | </PRE> | ||
2015 | <P> | ||
2016 | Informative output: | ||
2017 | |||
2018 | <P> | ||
2019 | <PRE> v verbosely list files processed | ||
2020 | </PRE> | ||
2021 | <P> | ||
2022 | Example: | ||
2023 | |||
2024 | <P> | ||
2025 | <PRE> $ zcat /tmp/tarball.tar.gz | tar -xf - | ||
2026 | $ tar -cf /tmp/tarball.tar /usr/local | ||
2027 | </PRE> | ||
2028 | <P> | ||
2029 | ------------------------------- | ||
2030 | |||
2031 | <DT><STRONG><A NAME="item_test">test, [</A></STRONG><DD> | ||
2032 | <P> | ||
2033 | Usage: test EXPRESSION or [ EXPRESSION ] | ||
2034 | |||
2035 | <P> | ||
2036 | Checks file types and compares values returning an exit code determined by | ||
2037 | the value of EXPRESSION. | ||
2038 | |||
2039 | <P> | ||
2040 | Example: | ||
2041 | |||
2042 | <P> | ||
2043 | <PRE> $ test 1 -eq 2 | ||
2044 | $ echo $? | ||
2045 | 1 | ||
2046 | $ test 1 -eq 1 | ||
2047 | $ echo $? | ||
2048 | 0 | ||
2049 | $ [ -d /etc ] | ||
2050 | $ echo $? | ||
2051 | 0 | ||
2052 | $ [ -d /junk ] | ||
2053 | $ echo $? | ||
2054 | 1 | ||
2055 | </PRE> | ||
2056 | <P> | ||
2057 | ------------------------------- | ||
2058 | |||
2059 | <DT><STRONG><A NAME="item_tee">tee</A></STRONG><DD> | ||
2060 | <P> | ||
2061 | Usage: tee [OPTION]... [FILE]... | ||
2062 | |||
2063 | <P> | ||
2064 | Copy standard input to each FILE, and also to standard output. | ||
2065 | |||
2066 | <P> | ||
2067 | Options: | ||
2068 | |||
2069 | <P> | ||
2070 | <PRE> -a append to the given FILEs, do not overwrite | ||
2071 | </PRE> | ||
2072 | <P> | ||
2073 | Example: | ||
2074 | |||
2075 | <P> | ||
2076 | <PRE> $ echo "Hello" | tee /tmp/foo | ||
2077 | $ cat /tmp/foo | ||
2078 | Hello | ||
2079 | </PRE> | ||
2080 | <P> | ||
2081 | ------------------------------- | ||
2082 | |||
2083 | <DT><STRONG><A NAME="item_touch">touch</A></STRONG><DD> | ||
2084 | <P> | ||
2085 | Usage: touch [<STRONG>-c</STRONG>] file [file ...] | ||
2086 | |||
2087 | <P> | ||
2088 | Update the last-modified date on (or create) the selected file[s]. | ||
2089 | |||
2090 | <P> | ||
2091 | Example: | ||
2092 | |||
2093 | <P> | ||
2094 | <PRE> $ ls -l /tmp/foo | ||
2095 | /bin/ls: /tmp/foo: No such file or directory | ||
2096 | $ touch /tmp/foo | ||
2097 | $ ls -l /tmp/foo | ||
2098 | -rw-rw-r-- 1 andersen andersen 0 Apr 15 01:11 /tmp/foo | ||
2099 | </PRE> | ||
2100 | <P> | ||
2101 | ------------------------------- | ||
2102 | |||
2103 | <DT><STRONG><A NAME="item_tr">tr</A></STRONG><DD> | ||
2104 | <P> | ||
2105 | Usage: tr [-cds] STRING1 [STRING2] | ||
2106 | |||
2107 | <P> | ||
2108 | Translate, squeeze, and/or delete characters from standard input, writing | ||
2109 | to standard output. | ||
2110 | |||
2111 | <P> | ||
2112 | Options: | ||
2113 | |||
2114 | <P> | ||
2115 | <PRE> -c take complement of STRING1 | ||
2116 | -d delete input characters coded STRING1 | ||
2117 | -s squeeze multiple output characters of STRING2 into one character | ||
2118 | </PRE> | ||
2119 | <P> | ||
2120 | Example: | ||
2121 | |||
2122 | <P> | ||
2123 | <PRE> $ echo "gdkkn vnqkc" | tr [a-y] [b-z] | ||
2124 | hello world | ||
2125 | </PRE> | ||
2126 | <P> | ||
2127 | ------------------------------- | ||
2128 | |||
2129 | <DT><STRONG><A NAME="item_true">true</A></STRONG><DD> | ||
2130 | <P> | ||
2131 | Returns an exit code of TRUE (0) | ||
2132 | |||
2133 | <P> | ||
2134 | Example: | ||
2135 | |||
2136 | <P> | ||
2137 | <PRE> $ true | ||
2138 | $ echo $? | ||
2139 | 0 | ||
2140 | </PRE> | ||
2141 | <P> | ||
2142 | ------------------------------- | ||
2143 | |||
2144 | <DT><STRONG><A NAME="item_tty">tty</A></STRONG><DD> | ||
2145 | <P> | ||
2146 | Usage: tty | ||
2147 | |||
2148 | <P> | ||
2149 | Print the file name of the terminal connected to standard input. | ||
2150 | |||
2151 | <P> | ||
2152 | Options: | ||
2153 | |||
2154 | <P> | ||
2155 | <PRE> -s print nothing, only return an exit status | ||
2156 | </PRE> | ||
2157 | <P> | ||
2158 | Example: | ||
2159 | |||
2160 | <P> | ||
2161 | <PRE> $ tty | ||
2162 | /dev/tty2 | ||
2163 | </PRE> | ||
2164 | <P> | ||
2165 | ------------------------------- | ||
2166 | |||
2167 | <DT><STRONG><A NAME="item_umount">umount</A></STRONG><DD> | ||
2168 | <P> | ||
2169 | Usage: umount [flags] filesystem|directory | ||
2170 | |||
2171 | <P> | ||
2172 | Flags: | ||
2173 | |||
2174 | <P> | ||
2175 | <PRE> -a: Unmount all file systems | ||
2176 | -r: Try to remount devices as read-only if mount is busy | ||
2177 | -f: Force filesystem umount (i.e. unreachable NFS server) | ||
2178 | -l: Do not free loop device (if a loop device has been used) | ||
2179 | </PRE> | ||
2180 | <P> | ||
2181 | Example: | ||
2182 | |||
2183 | <P> | ||
2184 | <PRE> $ umount /dev/hdc1 | ||
2185 | </PRE> | ||
2186 | <P> | ||
2187 | ------------------------------- | ||
2188 | |||
2189 | <DT><STRONG><A NAME="item_uname">uname</A></STRONG><DD> | ||
2190 | <P> | ||
2191 | Usage: uname [OPTION]... | ||
2192 | |||
2193 | <P> | ||
2194 | Print certain system information. With no OPTION, same as <STRONG>-s</STRONG>. | ||
2195 | |||
2196 | <P> | ||
2197 | Options: | ||
2198 | |||
2199 | <P> | ||
2200 | <PRE> -a print all information | ||
2201 | -m the machine (hardware) type | ||
2202 | -n print the machine's network node hostname | ||
2203 | -r print the operating system release | ||
2204 | -s print the operating system name | ||
2205 | -p print the host processor type | ||
2206 | -v print the operating system version | ||
2207 | </PRE> | ||
2208 | <P> | ||
2209 | Example: | ||
2210 | |||
2211 | <P> | ||
2212 | <PRE> $ uname -a | ||
2213 | Linux debian 2.2.15pre13 #5 Tue Mar 14 16:03:50 MST 2000 i686 unknown | ||
2214 | </PRE> | ||
2215 | <P> | ||
2216 | ------------------------------- | ||
2217 | |||
2218 | <DT><STRONG><A NAME="item_uniq">uniq</A></STRONG><DD> | ||
2219 | <P> | ||
2220 | Usage: uniq [OPTION]... [INPUT [OUTPUT]] | ||
2221 | |||
2222 | <P> | ||
2223 | Discard all but one of successive identical lines from INPUT (or standard | ||
2224 | input), writing to OUTPUT (or standard output). | ||
2225 | |||
2226 | <P> | ||
2227 | Example: | ||
2228 | |||
2229 | <P> | ||
2230 | <PRE> $ echo -e "a\na\nb\nc\nc\na" | sort | uniq | ||
2231 | a | ||
2232 | b | ||
2233 | c | ||
2234 | </PRE> | ||
2235 | <P> | ||
2236 | ------------------------------- | ||
2237 | |||
2238 | <DT><STRONG><A NAME="item_update">update</A></STRONG><DD> | ||
2239 | <P> | ||
2240 | Usage: update [options] | ||
2241 | |||
2242 | <P> | ||
2243 | Periodically flushes filesystem buffers. | ||
2244 | |||
2245 | <P> | ||
2246 | Options: | ||
2247 | |||
2248 | <P> | ||
2249 | <PRE> -S force use of sync(2) instead of flushing | ||
2250 | -s SECS call sync this often (default 30) | ||
2251 | -f SECS flush some buffers this often (default 5) | ||
2252 | </PRE> | ||
2253 | <P> | ||
2254 | ------------------------------- | ||
2255 | |||
2256 | <DT><STRONG><A NAME="item_uptime">uptime</A></STRONG><DD> | ||
2257 | <P> | ||
2258 | Usage: uptime | ||
2259 | |||
2260 | <P> | ||
2261 | Tells how long the system has been running since boot. | ||
2262 | |||
2263 | <P> | ||
2264 | Example: | ||
2265 | |||
2266 | <P> | ||
2267 | <PRE> $ uptime | ||
2268 | 1:55pm up 2:30, load average: 0.09, 0.04, 0.00 | ||
2269 | </PRE> | ||
2270 | <P> | ||
2271 | ------------------------------- | ||
2272 | |||
2273 | <DT><STRONG><A NAME="item_usleep">usleep</A></STRONG><DD> | ||
2274 | <P> | ||
2275 | Usage: usleep N | ||
2276 | |||
2277 | <P> | ||
2278 | Pauses for N microseconds. | ||
2279 | |||
2280 | <P> | ||
2281 | Example: | ||
2282 | |||
2283 | <P> | ||
2284 | <PRE> $ usleep 1000000 | ||
2285 | [pauses for 1 second] | ||
2286 | </PRE> | ||
2287 | <P> | ||
2288 | ------------------------------- | ||
2289 | |||
2290 | <DT><STRONG><A NAME="item_wc">wc</A></STRONG><DD> | ||
2291 | <P> | ||
2292 | Usage: wc [OPTION]... [FILE]... | ||
2293 | |||
2294 | <P> | ||
2295 | Print line, word, and byte counts for each FILE, and a total line if more | ||
2296 | than one FILE is specified. With no FILE, read standard input. | ||
2297 | |||
2298 | <P> | ||
2299 | Options: | ||
2300 | |||
2301 | <P> | ||
2302 | <PRE> -c print the byte counts | ||
2303 | -l print the newline counts | ||
2304 | -L print the length of the longest line | ||
2305 | -w print the word counts | ||
2306 | </PRE> | ||
2307 | <P> | ||
2308 | Example: | ||
2309 | |||
2310 | <P> | ||
2311 | <PRE> $ wc /etc/passwd | ||
2312 | 31 46 1365 /etc/passwd | ||
2313 | </PRE> | ||
2314 | <P> | ||
2315 | ------------------------------- | ||
2316 | |||
2317 | <DT><STRONG><A NAME="item_whoami">whoami</A></STRONG><DD> | ||
2318 | <P> | ||
2319 | Usage: whoami | ||
2320 | |||
2321 | <P> | ||
2322 | Prints the user name associated with the current effective user id. | ||
2323 | |||
2324 | <P> | ||
2325 | Example: | ||
2326 | |||
2327 | <P> | ||
2328 | <PRE> $ whoami | ||
2329 | andersen | ||
2330 | </PRE> | ||
2331 | <P> | ||
2332 | ------------------------------- | ||
2333 | |||
2334 | <DT><STRONG><A NAME="item_yes">yes</A></STRONG><DD> | ||
2335 | <P> | ||
2336 | Usage: yes [OPTION]... [STRING]... | ||
2337 | |||
2338 | <P> | ||
2339 | Repeatedly outputs a line with all specified <CODE>STRING(s),</CODE> or | ||
2340 | `y'. | ||
2341 | |||
2342 | <P> | ||
2343 | ------------------------------- | ||
2344 | |||
2345 | <DT><STRONG><A NAME="item_zcat">zcat</A></STRONG><DD> | ||
2346 | <P> | ||
2347 | This is essentially an alias for invoking ``gunzip <STRONG>-c</STRONG>'', where it decompresses the file inquestion and send the output to | ||
2348 | stdout. | ||
2349 | |||
2350 | <P> | ||
2351 | ------------------------------- | ||
2352 | |||
2353 | </DL> | ||
2354 | <P> | ||
2355 | <HR> | ||
2356 | <H1><A NAME="LIBC_NSS">LIBC NSS</A></H1> | ||
2357 | <P> | ||
2358 | GNU Libc uses the Name Service Switch (NSS) to configure the behavior of | ||
2359 | the C library for the local environment, and to configure how it reads | ||
2360 | system data, such as passwords and group information. BusyBox has made it | ||
2361 | Policy that it will never use NSS, and will never use and libc calls that | ||
2362 | make use of NSS. This allows you to run an embedded system without the need | ||
2363 | for installing an /etc/nsswitch.conf file and without and /lib/libnss_* | ||
2364 | libraries installed. | ||
2365 | |||
2366 | <P> | ||
2367 | If you are using a system that is using a remote LDAP server for | ||
2368 | authentication via GNU libc NSS, and you want to use BusyBox, then you will | ||
2369 | need to adjust the BusyBox source. Chances are though, that if you have | ||
2370 | enough space to install of that stuff on your system, then you probably | ||
2371 | want the full GNU utilities. | ||
2372 | |||
2373 | <P> | ||
2374 | <HR> | ||
2375 | <H1><A NAME="SEE_ALSO">SEE ALSO</A></H1> | ||
2376 | <P> | ||
2377 | <CODE>textutils(1),</CODE> <CODE>shellutils(1),</CODE> etc... | ||
2378 | |||
2379 | <P> | ||
2380 | <HR> | ||
2381 | <H1><A NAME="MAINTAINER">MAINTAINER</A></H1> | ||
2382 | <P> | ||
2383 | Erik Andersen <<A | ||
2384 | HREF="mailto:andersee@debian.org">andersee@debian.org</A>> <<A | ||
2385 | HREF="mailto:andersen@lineo.com">andersen@lineo.com</A>> | ||
2386 | |||
2387 | <P> | ||
2388 | <HR> | ||
2389 | <H1><A NAME="AUTHORS">AUTHORS</A></H1> | ||
2390 | <P> | ||
2391 | The following people have contributed code to BusyBox whether they know it | ||
2392 | or not. | ||
2393 | |||
2394 | <P> | ||
2395 | Erik Andersen <<A | ||
2396 | HREF="mailto:andersee@debian.org">andersee@debian.org</A>> | ||
2397 | |||
2398 | <br> | ||
2399 | |||
2400 | <P> | ||
2401 | John Beppu <<A HREF="mailto:beppu@lineo.com">beppu@lineo.com</A>> | ||
2402 | |||
2403 | <br> | ||
2404 | |||
2405 | <P> | ||
2406 | Brian Candler <<A | ||
2407 | HREF="mailto:B.Candler@pobox.com">B.Candler@pobox.com</A>> | ||
2408 | |||
2409 | <br> | ||
2410 | |||
2411 | <P> | ||
2412 | Randolph Chung <<A | ||
2413 | HREF="mailto:tausq@debian.org">tausq@debian.org</A>> | ||
2414 | |||
2415 | <br> | ||
2416 | |||
2417 | <P> | ||
2418 | Dave Cinege <<A | ||
2419 | HREF="mailto:dcinege@psychosis.com">dcinege@psychosis.com</A>> | ||
2420 | |||
2421 | <br> | ||
2422 | |||
2423 | <P> | ||
2424 | Karl M. Hegbloom <<A | ||
2425 | HREF="mailto:karlheg@debian.org">karlheg@debian.org</A>> | ||
2426 | |||
2427 | <br> | ||
2428 | |||
2429 | <P> | ||
2430 | John Lombardo <<A | ||
2431 | HREF="mailto:john@deltanet.com">john@deltanet.com</A>> | ||
2432 | |||
2433 | <br> | ||
2434 | |||
2435 | <P> | ||
2436 | Bruce Perens <<A HREF="mailto:bruce@perens.com">bruce@perens.com</A>> | ||
2437 | |||
2438 | <br> | ||
2439 | |||
2440 | <P> | ||
2441 | Linus Torvalds <<A | ||
2442 | HREF="mailto:torvalds@transmeta.com">torvalds@transmeta.com</A>> | ||
2443 | |||
2444 | <br> | ||
2445 | |||
2446 | <P> | ||
2447 | Charles P. Wright <<A | ||
2448 | HREF="mailto:cpwright@villagenet.com">cpwright@villagenet.com</A>> | ||
2449 | |||
2450 | <br> | ||
2451 | |||
2452 | <P> | ||
2453 | Enrique Zanardi <<A | ||
2454 | HREF="mailto:ezanardi@ull.es">ezanardi@ull.es</A>> | ||
2455 | |||
2456 | <br> | ||
2457 | |||
2458 | </BODY> | ||
2459 | |||
2460 | </HTML> | ||
diff --git a/docs/busybox.net/images/background.png b/docs/busybox.net/images/background.png new file mode 100644 index 000000000..11666cedb --- /dev/null +++ b/docs/busybox.net/images/background.png | |||
Binary files differ | |||
diff --git a/docs/busybox.net/images/busybox2.jpg b/docs/busybox.net/images/busybox2.jpg new file mode 100644 index 000000000..abf8f0610 --- /dev/null +++ b/docs/busybox.net/images/busybox2.jpg | |||
Binary files differ | |||
diff --git a/docs/busybox.net/index.html b/docs/busybox.net/index.html new file mode 100644 index 000000000..ff865dc1e --- /dev/null +++ b/docs/busybox.net/index.html | |||
@@ -0,0 +1,434 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> | ||
2 | |||
3 | <HTML> | ||
4 | <HEAD> | ||
5 | <TITLE>BusyBox</TITLE> | ||
6 | </HEAD> | ||
7 | |||
8 | <body text="#000000" alink="#660000" link="#660000" bgcolor="#ffffff" vlink="#660000" background="images/background.png" > | ||
9 | |||
10 | <basefont face="lucida, helvetica, arial" size="3"> | ||
11 | |||
12 | |||
13 | <CENTER> | ||
14 | <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2> | ||
15 | <TR> | ||
16 | <td bgcolor="#000000"> | ||
17 | <FONT FACE="lucida, helvetica" COLOR="#ccccc0"> | ||
18 | <B>B u s y B o x</B> | ||
19 | </FONT> | ||
20 | </TD> | ||
21 | </TR> | ||
22 | </TABLE> | ||
23 | <a href="/"><IMG SRC="images/busybox2.jpg" alt="BusyBox" border="0" width="360" height="230"</a><BR> | ||
24 | |||
25 | |||
26 | <!-- Begin Introduction section --> | ||
27 | |||
28 | |||
29 | <TABLE WIDTH=95% CELLSPACING=1 CELLPADDING=4 BORDER=1> | ||
30 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
31 | <A NAME="intro"> <BIG><B> | ||
32 | The Swiss Army Knife of Embedded Linux | ||
33 | </font> | ||
34 | </A></B></BIG> | ||
35 | </TD></TR> | ||
36 | <TR><TD BGCOLOR="#eeeee0"> | ||
37 | |||
38 | BusyBox combines tiny versions of many common UNIX utilities into a single | ||
39 | small executable. It provides minimalist replacements for most of the utilities | ||
40 | you usually find in fileutils, shellutils, findutils, textutils, grep, gzip, | ||
41 | tar, etc. BusyBox provides a fairly complete POSIX environment for any small | ||
42 | or emdedded system. The utilities in BusyBox generally have fewer options then | ||
43 | their full featured GNU cousins; however, the options that are included provide | ||
44 | the expected functionality and behave very much like their GNU counterparts. | ||
45 | <p> | ||
46 | BusyBox has been written with size-optimization and limited resources in mind. | ||
47 | It is also extremely modular so you can easily include or exclude commands (or | ||
48 | features) at compile time. This makes it easy to customize your embedded | ||
49 | systems. To create a working system, just add a kernel, a shell (such as ash), | ||
50 | and an editor (such as elvis-tiny or ae). | ||
51 | <p> | ||
52 | |||
53 | BusyBox is now maintained by | ||
54 | <a href="http://www.xmission.com/~andersen/erik/erik.html"> | ||
55 | Erik Andersen</a>, and its ongoing development is being sponsored by | ||
56 | <a href="http://www.lineo.com/">Lineo</a>. | ||
57 | <p> | ||
58 | BusyBox is licensed under the | ||
59 | <a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a> | ||
60 | |||
61 | |||
62 | <!-- Begin Download section --> | ||
63 | |||
64 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
65 | <A NAME="download"><BIG><B> | ||
66 | Download | ||
67 | </A></B></BIG> | ||
68 | </TD></TR> | ||
69 | <TR><TD BGCOLOR="#eeeee0"> | ||
70 | <ul> | ||
71 | <li> Source for the latest release can always be downloaded from | ||
72 | <a href="ftp://ftp.lineo.com/pub/busybox">ftp://ftp.lineo.com/pub/busybox</a>. | ||
73 | </ul> | ||
74 | |||
75 | |||
76 | <!-- Begin Latest News section --> | ||
77 | |||
78 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
79 | <A NAME="news"> | ||
80 | <BIG><B> | ||
81 | Latest News</A> | ||
82 | </B></BIG> | ||
83 | </A> | ||
84 | </TD></TR> | ||
85 | <TR><TD BGCOLOR="#eeeee0"> | ||
86 | |||
87 | <ul> | ||
88 | |||
89 | <p> <li> <b>19 April 2000 -- syslogd bugfix</b> | ||
90 | <br> | ||
91 | Turns out that there was still a bug in busybox syslogd. | ||
92 | For example, with the following test app: | ||
93 | <pre> | ||
94 | #include <syslog.h> | ||
95 | |||
96 | int do_log(char* msg, int delay) | ||
97 | { | ||
98 | openlog("testlog", LOG_PID, LOG_DAEMON); | ||
99 | while(1) { | ||
100 | syslog(LOG_ERR, "%s: testing one, two, three\n", msg); | ||
101 | sleep(delay); | ||
102 | } | ||
103 | closelog(); | ||
104 | return(0); | ||
105 | }; | ||
106 | |||
107 | int main(void) | ||
108 | { | ||
109 | if (fork()==0) | ||
110 | do_log("A", 2); | ||
111 | do_log("B", 3); | ||
112 | } | ||
113 | </pre> | ||
114 | it should be logging stuff from both "A" and "B". As released in 0.43 only stuff | ||
115 | from "A" would have been logged. This means that if init tries to log something | ||
116 | while say ppp has the syslog open, init would block (which is bad, bad, bad). | ||
117 | <p> | ||
118 | Karl M. Hegbloom has created a | ||
119 | <a href="ftp://ftp.lineo.com/pub/busybox/busybox-0.43-syslog_patch">fix for the problem</a>. | ||
120 | Thanks Karl! | ||
121 | |||
122 | |||
123 | <p> <li> <b>18 April 2000 -- BusyBox 0.43 released (finally!)</b> | ||
124 | <br> | ||
125 | I have finally gotten everything into a state where I feel pretty | ||
126 | good about things. This is definitely the most stable, solid release | ||
127 | so far. A lot of bugs have been fixed, and the following new apps | ||
128 | have been added: sh, basename, dirname, killall, uptime, | ||
129 | freeramdisk, tr, echo, test, and usleep. Tar has been completely | ||
130 | rewritten from scratch. Bss size has also been greatly reduced. | ||
131 | More details are available in the | ||
132 | <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a>. | ||
133 | Oh, and as a special bonus, I wrote some fairly comprehensive | ||
134 | <em>documentation</em>, complete with examples and full usage information. | ||
135 | |||
136 | <p> | ||
137 | Many thanks go out to the fine people that have helped by submitting patches | ||
138 | and bug reports; particularly instrumental in helping for this release were | ||
139 | Karl Hegbloom, Pavel Roskin, Friedrich Vedder, Emanuele Caratti, | ||
140 | Bob Tinsley, Nicolas Pitre, Avery Pennarun, Arne Bernin, John Beppu, and Jim Gleason. | ||
141 | There were others so if I somehow forgot to mention you, I'm very sorry. | ||
142 | <p> | ||
143 | |||
144 | You can grab BusyBox 0.43 tarballs <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>. | ||
145 | |||
146 | <p> <li> <b>9 April 2000 -- BusyBox 0.43 pre release</b> | ||
147 | <br> | ||
148 | Unfortunately, I have not yet finished all the things I want to | ||
149 | do for BusyBox 0.43, so I am posting this pre-release for people | ||
150 | to poke at. This contains my complete rewrite of tar, which now weighs in at | ||
151 | 5k (7k with all options turned on) and works for reading and writing | ||
152 | tarballs (which it does correctly for everything I have been able to throw | ||
153 | at it). Tar also (optionally) supports the "--exclude" option (mainly because | ||
154 | the Linux Router Project folks asked for it). This also has a pre-release | ||
155 | of the micro shell I have been writing. This pre-release should be stable | ||
156 | enough for production use -- it just isn't a release since I have some structural | ||
157 | changes I still want to make. | ||
158 | <p> | ||
159 | The pre-release can be found <a href="ftp://ftp.lineo.com/pub/busybox/">here</a>. | ||
160 | Please let me know ASAP if you find <em>any</em> bugs. | ||
161 | |||
162 | <p> <li> <b>28 March 2000 -- Andersen Baby Boy release</b> | ||
163 | <br> | ||
164 | I am pleased to announce that on Tuesday March 28th at 5:48pm, weighing in at 7 | ||
165 | lbs. 12 oz, Micah Erik Andersen was born at LDS Hospital here in Salt Lake City. | ||
166 | He was born in the emergency room less then 5 minutes after we arrived -- and | ||
167 | it was such a relief that we even made it to the hospital at all. Despite the | ||
168 | fact that I was driving at an amazingly unlawful speed and honking at everybody | ||
169 | and thinking decidely unkind thoughts about the people in our way, my wife | ||
170 | (inconsiderate of my feelings and complete lack of medical training) was lying | ||
171 | down in the back seat saying things like "I think I need to start pushing now" | ||
172 | (which she then proceeded to do despite my best encouraging statements to the | ||
173 | contrary). | ||
174 | <p> | ||
175 | Anyway, I'm glad to note that despite the much-faster-than-we-were-expecting | ||
176 | labor, both Shaunalei and our new baby boy are doing wonderfuly. | ||
177 | <p> | ||
178 | So now that I am done with my excuse for the slow release cycle... | ||
179 | Progress on the next release of BusyBox has been slow but steady. I expect | ||
180 | to have a release sometime during the first week of April. This release will | ||
181 | include a number of important changes, including the addition of a shell, a | ||
182 | re-write of tar (to accomodate the Linux Router Project), and syslogd can now | ||
183 | accept multiple concurrent connections, fixing lots of unexpected blocking | ||
184 | problems. | ||
185 | |||
186 | |||
187 | <p> <li> <b>11 February 2000 -- BusyBox 0.42 released</b> | ||
188 | <br> | ||
189 | |||
190 | This is the most solid BusyBox release so far. Many, many | ||
191 | bugs have been fixed. See the | ||
192 | <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for details. | ||
193 | |||
194 | Of particular interest, init will now cleanly unmount | ||
195 | filesystems on reboot, cp and mv have been rewritten and | ||
196 | behave much better, and mount and umount no longer leak | ||
197 | loop devices. Many thanks go out to Randolph Chung, | ||
198 | Karl M. Hegbloom, Taketoshi Sano, and Pavel Roskin for | ||
199 | their hard work on this release of BusyBox. Please pound | ||
200 | on it and let me know if you find any bugs. | ||
201 | |||
202 | <p> <li> <b>19 January 2000 -- BusyBox 0.41 released</b> | ||
203 | <br> | ||
204 | |||
205 | This release includes bugfixes to cp, mv, logger, true, false, | ||
206 | mkdir, syslogd, and init. New apps include wc, hostid, | ||
207 | logname, tty, whoami, and yes. New features include loop device | ||
208 | support in mount and umount, and better TERM handling by init. | ||
209 | The changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>. | ||
210 | |||
211 | <p> <li> <b>7 January 2000 -- BusyBox 0.40 released</b> | ||
212 | <br> | ||
213 | |||
214 | This release includes bugfixes to init (now includes inittab support), | ||
215 | syslogd, head, logger, du, grep, cp, mv, sed, dmesg, ls, kill, gunzip, and mknod. | ||
216 | New apps include sort, uniq, lsmod, rmmod, fbset, and loadacm. | ||
217 | In particular, this release fixes an important bug in tar which | ||
218 | in some cases produced serious security problems. | ||
219 | As always, the changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>. | ||
220 | |||
221 | <p> <li> <b>11 December 1999 -- BusyBox Website</b> | ||
222 | <br> | ||
223 | I have received permission from Bruce Perens (the original author of BusyBox) | ||
224 | to set up this site as the new primary website for BusyBox. This website | ||
225 | will always contain pointers to the latest and greatest, and will also | ||
226 | contain the latest documentation on how to use BusyBox, what it can do, | ||
227 | what arguments its apps support, etc. | ||
228 | |||
229 | <p> <li> <b>10 December 1999 -- BusyBox 0.39 released</b> | ||
230 | <br> | ||
231 | This release includes fixes to init, reboot, halt, kill, and ls, and contains | ||
232 | the new apps ping, hostname, mkfifo, free, tail, du, tee, and head. A full | ||
233 | changelog can be found <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">here</a>. | ||
234 | <p> <li> <b>5 December 1999 -- BusyBox 0.38 released</b> | ||
235 | <br> | ||
236 | This release includes fixes to tar, cat, ls, dd, rm, umount, find, df, | ||
237 | and make install, and includes new apps syslogd/klogd and logger. | ||
238 | </ul> | ||
239 | |||
240 | |||
241 | <!-- Begin Docs section --> | ||
242 | |||
243 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
244 | <A NAME="docs"><BIG><B> | ||
245 | Documentation | ||
246 | </A></B></BIG> | ||
247 | </TD></TR> | ||
248 | <TR><TD BGCOLOR="#eeeee0"> | ||
249 | Current documentation for BusyBox includes: | ||
250 | <ul> | ||
251 | <li> <a href="BusyBox.html">BusyBox.html</a> | ||
252 | This is a list of the all the available commands in BusyBox with complete | ||
253 | usage information and examples of how to use each app. I spent | ||
254 | a <em>lot</em> of time updating these docs and trying to make them | ||
255 | fairly comprehensive for the BusyBox 0.43 release. If you find any | ||
256 | errors (factual, grammatical, whatever) please let me know. | ||
257 | |||
258 | <li> More documentation will follow. | ||
259 | </ul> | ||
260 | |||
261 | |||
262 | <!-- Begin Links section --> | ||
263 | |||
264 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
265 | <A NAME="related"> | ||
266 | <BIG><B> | ||
267 | Related Software</A> | ||
268 | </B></BIG> | ||
269 | </A> | ||
270 | </TD></TR> | ||
271 | <TR><TD BGCOLOR="#eeeee0"> | ||
272 | |||
273 | <ul> | ||
274 | |||
275 | <li><a href="http://www.debian.org/Packages/unstable/shells/ash.html">ash</a> | ||
276 | is a very small Bourne shell. If you need a shell for your embedded systems, this is it. | ||
277 | <p> | ||
278 | |||
279 | <li><a href="http://www.debian.org/Packages/unstable/base/ae.html">ae</a> | ||
280 | is a tiny full-screen text editor with both modal (vi-like) and modeless | ||
281 | (emacs-like) modes, determined by an ae.rc config file. It makes a nice editor | ||
282 | if people that don't know "vi" will need to work on your embedded system. | ||
283 | <p> | ||
284 | |||
285 | <li> <a href="http://www.debian.org/Packages/unstable/base/elvis-tiny.html">elvis-tiny</a> | ||
286 | is based on a 1991 Minix version of the elvis "vi" clone. It behaves as one would | ||
287 | expect a minamalist vi to behave, and is very small. | ||
288 | <p> | ||
289 | |||
290 | <li> <a href="http://www.asty.org/nano/">nano</a> | ||
291 | A small GPLed pico clone that makes a nice editor for people that don't know "vi". | ||
292 | <p> | ||
293 | |||
294 | <li><a href="http://www.debian.org/Packages/unstable/net/iproute.html">iproute</a> | ||
295 | Much more flexible replacement for ifconfig, route, etc. It is quite small, and for | ||
296 | most networking applications, it is all you need. It also provides support for extremely | ||
297 | advanced networking and provides Quality of Service(QoS) support, but most people will | ||
298 | just need to use the "ip" command and will not even need to install the rest. | ||
299 | <p> | ||
300 | |||
301 | <li><a href="http://www.debian.org/Packages/unstable/net/pump.html">Pump</a> | ||
302 | This is the DHCP/BOOTP client written by RedHat. When compiled properly, it | ||
303 | gives you dhcp client support for about 35k. | ||
304 | <p> | ||
305 | |||
306 | <li><a href="http://www.pcug.org.au/~dbell/">sash</a> | ||
307 | The Stand Alone SHell. This is a small shell (not Bourne shell compatable) | ||
308 | that is similar to busybox in that it provides a number of common utilities as built-ins. | ||
309 | <p> | ||
310 | |||
311 | <li><a href="http://sourceware.cygnus.com/newlib/">NewLib</a> | ||
312 | This is a small C library intended for use on embedded systems. If you are finding | ||
313 | GNU libc is a bit too big for your applications, try NewLib and it may help. | ||
314 | <p> | ||
315 | |||
316 | <li><a href="http://linuxassembly.org/asmutils.html">asmutils</a> | ||
317 | asmutils is similar to BusyBox in that it provides a number of common application | ||
318 | for embedded systems that are very tiny. In fact, they are a _lot_ smaller than the | ||
319 | equivalent apps in busybox -- but the price you pay for the size is reduced portability | ||
320 | (x86 only) and interfaces that are tied directly to a perticular kernel (no libc involved). | ||
321 | <p> | ||
322 | |||
323 | <li><a href="http://tinylogin.lineo.com/">TinyLogin</a> | ||
324 | is a nice embedded tool for handling authentication, changing passwords, | ||
325 | and similar tasks, and which nicely complements BusyBox. | ||
326 | <p> | ||
327 | |||
328 | </ul> | ||
329 | |||
330 | <!-- Begin Projects section --> | ||
331 | |||
332 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
333 | <A NAME="docs"><BIG><B> | ||
334 | Projects using BusyBox | ||
335 | </A></B></BIG> | ||
336 | </TD></TR> | ||
337 | <TR><TD BGCOLOR="#eeeee0"> | ||
338 | I know of the following projects that use BusyBox | ||
339 | <ul> | ||
340 | <li> <a href="http://www.lineo.com/products/embedix.html">Lineo Embedix Linux</a> | ||
341 | <li> <a href="http://cvs.debian.org/boot-floppies/">Debian boot floppies project</a> | ||
342 | <li> <a href="http://www.linuxrouter.org/">Linux Router Project </a> | ||
343 | <li> <a href="http://linux-embedded.org/">LEM</a> | ||
344 | <li> <a href="http://www.toms.net/rb/">tomsrtbt</a> | ||
345 | |||
346 | </ul> | ||
347 | Do you use BusyBox? I'd love to know about it and I'd be happy to link to you. | ||
348 | |||
349 | |||
350 | |||
351 | <!-- Begin Links section --> | ||
352 | |||
353 | <TR><TD BGCOLOR="#ccccc0" ALIGN=center> | ||
354 | <A NAME="links"> | ||
355 | <BIG><B> | ||
356 | Important Links</A> | ||
357 | </B></BIG> | ||
358 | </A> | ||
359 | </TD></TR> | ||
360 | <TR><TD BGCOLOR="#eeeee0"> | ||
361 | |||
362 | <ul> | ||
363 | |||
364 | <li> <A HREF="http://perens.com/FreeSoftware/"> | ||
365 | Free Software from Bruce Perens</A><br> | ||
366 | The original idea for BusyBox, and all versions up to 0.26 were written | ||
367 | by <A HREF="mailto:bruce@perens.com">Bruce Perens</a>. This is his BusyBox website. | ||
368 | <p> | ||
369 | |||
370 | <li> <A HREF="http://freshmeat.net/appindex/1999/04/11/923859921.html"> | ||
371 | Freshmeat AppIndex record for BusyBox</A> | ||
372 | <p> | ||
373 | |||
374 | <li> <A HREF="http://www.lineo.com/">Lineo</A> is sponsoring BusyBox development. | ||
375 | <p> | ||
376 | |||
377 | </ul> | ||
378 | |||
379 | |||
380 | |||
381 | |||
382 | <!-- End of Table --> | ||
383 | |||
384 | </TD></TR> | ||
385 | </TABLE> | ||
386 | </P> | ||
387 | |||
388 | |||
389 | |||
390 | <!-- Footer --> | ||
391 | <HR> | ||
392 | <TABLE WIDTH="100%"> | ||
393 | <TR> | ||
394 | <TD> | ||
395 | <font size="-1" face="arial, helvetica, sans-serif"> | ||
396 | Mail all comments, insults, suggestions and bribes to | ||
397 | <a href="mailto:andersen@lineo.com">Erik Andersen</a><BR> | ||
398 | The Busybox logo is copyright 1999,2000, Erik Andersen. | ||
399 | </font> | ||
400 | </TD> | ||
401 | |||
402 | <TD> | ||
403 | <a href="http://www.vim.org"><img border=0 width=88 height=32 | ||
404 | src="images/anim.written.in.vi.gif" | ||
405 | alt="This site created with the vi editor"></a> | ||
406 | </TD> | ||
407 | |||
408 | <TD> | ||
409 | <a href="http://www.gimp.org/"><img border=0 width=88 height=38 | ||
410 | src="images/gfx_by_gimp.gif" alt="Graphics by GIMP"></a> | ||
411 | </TD> | ||
412 | |||
413 | <TD> | ||
414 | <a href="http://www.linuxtoday.com"><img width=90 height=36 | ||
415 | src="images/ltbutton2.jpg" alt="Linux Today"></a> | ||
416 | </TD> | ||
417 | |||
418 | <TD> | ||
419 | <p><a href="http://slashdot.org"><img width=90 height=36 | ||
420 | src="images/sdsmall.gif" alt="Slashdot"></a> | ||
421 | </TD> | ||
422 | |||
423 | <TD> | ||
424 | <a href="http://freshmeat.net"><img width=90 height=36 | ||
425 | src="images/fm.mini.jpg" alt="Freshmeat"></a> | ||
426 | </TD> | ||
427 | |||
428 | </TR> | ||
429 | </TABLE> | ||
430 | |||
431 | |||
432 | </BODY> | ||
433 | </HTML> | ||
434 | |||
diff --git a/findutils/which.c b/findutils/which.c new file mode 100644 index 000000000..46c2204a5 --- /dev/null +++ b/findutils/which.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Which implementation for busybox | ||
4 | * | ||
5 | * Copyright (C) 2000 by Lineo, inc. | ||
6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "internal.h" | ||
25 | #include <stdio.h> | ||
26 | #include <dirent.h> | ||
27 | |||
28 | |||
29 | extern int which_main(int argc, char **argv) | ||
30 | { | ||
31 | char *path_list, *test, *tmp; | ||
32 | struct dirent *next; | ||
33 | |||
34 | if (**(argv + 1) == '-') { | ||
35 | usage("which [COMMAND ...]\n" | ||
36 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
37 | "\nLocates a COMMAND.\n" | ||
38 | #endif | ||
39 | ); | ||
40 | } | ||
41 | argc--; | ||
42 | |||
43 | path_list = getenv("PATH"); | ||
44 | if (!path_list) | ||
45 | path_list = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"; | ||
46 | |||
47 | while(argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) { | ||
48 | for( test=path_list; (tmp=strchr(test, ':')) && (tmp+1)!=NULL; test=++tmp) { | ||
49 | DIR *dir; | ||
50 | *tmp='\0'; | ||
51 | //printf("Checking directory '%s'\n", test); | ||
52 | dir = opendir(test); | ||
53 | if (!dir) | ||
54 | continue; | ||
55 | while ((next = readdir(dir)) != NULL) { | ||
56 | //printf("Checking file '%s'\n", next->d_name); | ||
57 | if ((strcmp(next->d_name, *argv) == 0)) { | ||
58 | printf("%s/%s\n", test, next->d_name); | ||
59 | exit(TRUE); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | exit(TRUE); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | Local Variables: | ||
69 | c-file-style: "linux" | ||
70 | c-basic-offset: 4 | ||
71 | tab-width: 4 | ||
72 | End: | ||
73 | */ | ||
@@ -367,25 +367,23 @@ void send_bits (int value, int length); | |||
367 | unsigned bi_reverse (unsigned value, int length); | 367 | unsigned bi_reverse (unsigned value, int length); |
368 | void bi_windup (void); | 368 | void bi_windup (void); |
369 | void copy_block (char *buf, unsigned len, int header); | 369 | void copy_block (char *buf, unsigned len, int header); |
370 | extern int (*read_buf) (char *buf, unsigned size); | ||
371 | 370 | ||
372 | /* in util.c: */ | 371 | /* in util.c: */ |
373 | extern int copy (int in, int out); | ||
374 | extern ulg updcrc (uch * s, unsigned n); | 372 | extern ulg updcrc (uch * s, unsigned n); |
375 | extern void clear_bufs (void); | 373 | extern void clear_bufs (void); |
376 | extern int fill_inbuf (int eof_ok); | 374 | static int fill_inbuf (int eof_ok); |
377 | extern void flush_outbuf (void); | 375 | extern void flush_outbuf (void); |
378 | extern void flush_window (void); | 376 | static void flush_window (void); |
379 | extern void write_buf (int fd, void * buf, unsigned cnt); | 377 | extern void write_buf (int fd, void * buf, unsigned cnt); |
380 | 378 | ||
381 | #ifndef __linux__ | 379 | #ifndef __linux__ |
382 | extern char *basename (char *fname); | 380 | static char *basename (char *fname); |
383 | #endif /* not __linux__ */ | 381 | #endif /* not __linux__ */ |
384 | extern void read_error (void); | 382 | void read_error_msg (void); |
385 | extern void write_error (void); | 383 | void write_error_msg (void); |
386 | 384 | ||
387 | /* in inflate.c */ | 385 | /* in inflate.c */ |
388 | extern int inflate (void); | 386 | static int inflate (void); |
389 | 387 | ||
390 | /* #include "lzw.h" */ | 388 | /* #include "lzw.h" */ |
391 | 389 | ||
@@ -450,133 +448,6 @@ extern int unlzw (int in, int out); | |||
450 | # undef LZW | 448 | # undef LZW |
451 | #endif | 449 | #endif |
452 | 450 | ||
453 | /* #include "getopt.h" */ | ||
454 | |||
455 | /* Declarations for getopt. | ||
456 | Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc. | ||
457 | |||
458 | This program is free software; you can redistribute it and/or modify it | ||
459 | under the terms of the GNU General Public License as published by the | ||
460 | Free Software Foundation; either version 2, or (at your option) any | ||
461 | later version. | ||
462 | |||
463 | This program is distributed in the hope that it will be useful, | ||
464 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
465 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
466 | GNU General Public License for more details. | ||
467 | |||
468 | You should have received a copy of the GNU General Public License | ||
469 | along with this program; if not, write to the Free Software | ||
470 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
471 | |||
472 | #ifndef _GETOPT_H | ||
473 | #define _GETOPT_H 1 | ||
474 | |||
475 | #ifdef __cplusplus | ||
476 | extern "C" { | ||
477 | #endif | ||
478 | /* For communication from `getopt' to the caller. | ||
479 | When `getopt' finds an option that takes an argument, | ||
480 | the argument value is returned here. | ||
481 | Also, when `ordering' is RETURN_IN_ORDER, | ||
482 | each non-option ARGV-element is returned here. */ | ||
483 | extern char *optarg; | ||
484 | |||
485 | /* Index in ARGV of the next element to be scanned. | ||
486 | This is used for communication to and from the caller | ||
487 | and for communication between successive calls to `getopt'. | ||
488 | |||
489 | On entry to `getopt', zero means this is the first call; initialize. | ||
490 | |||
491 | When `getopt' returns EOF, this is the index of the first of the | ||
492 | non-option elements that the caller should itself scan. | ||
493 | |||
494 | Otherwise, `optind' communicates from one call to the next | ||
495 | how much of ARGV has been scanned so far. */ | ||
496 | |||
497 | extern int optind; | ||
498 | |||
499 | /* Callers store zero here to inhibit the error message `getopt' prints | ||
500 | for unrecognized options. */ | ||
501 | |||
502 | extern int opterr; | ||
503 | |||
504 | /* Set to an option character which was unrecognized. */ | ||
505 | |||
506 | extern int optopt; | ||
507 | |||
508 | /* Describe the long-named options requested by the application. | ||
509 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector | ||
510 | of `struct option' terminated by an element containing a name which is | ||
511 | zero. | ||
512 | |||
513 | The field `has_arg' is: | ||
514 | no_argument (or 0) if the option does not take an argument, | ||
515 | required_argument (or 1) if the option requires an argument, | ||
516 | optional_argument (or 2) if the option takes an optional argument. | ||
517 | |||
518 | If the field `flag' is not NULL, it points to a variable that is set | ||
519 | to the value given in the field `val' when the option is found, but | ||
520 | left unchanged if the option is not found. | ||
521 | |||
522 | To have a long-named option do something other than set an `int' to | ||
523 | a compiled-in constant, such as set a value from `optarg', set the | ||
524 | option's `flag' field to zero and its `val' field to a nonzero | ||
525 | value (the equivalent single-letter option character, if there is | ||
526 | one). For long options that have a zero `flag' field, `getopt' | ||
527 | returns the contents of the `val' field. */ | ||
528 | |||
529 | struct option { | ||
530 | #if __STDC__ | ||
531 | const char *name; | ||
532 | #else | ||
533 | char *name; | ||
534 | #endif | ||
535 | /* has_arg can't be an enum because some compilers complain about | ||
536 | type mismatches in all the code that assumes it is an int. */ | ||
537 | int has_arg; | ||
538 | int *flag; | ||
539 | int val; | ||
540 | }; | ||
541 | |||
542 | /* Names for the values of the `has_arg' field of `struct option'. */ | ||
543 | |||
544 | #define no_argument 0 | ||
545 | #define required_argument 1 | ||
546 | #define optional_argument 2 | ||
547 | |||
548 | #if __STDC__ || defined(PROTO) | ||
549 | #if defined(__GNU_LIBRARY__) | ||
550 | /* Many other libraries have conflicting prototypes for getopt, with | ||
551 | differences in the consts, in stdlib.h. To avoid compilation | ||
552 | errors, only prototype getopt for the GNU C library. */ | ||
553 | extern int getopt(int argc, char *const *argv, const char *shortopts); | ||
554 | #endif /* not __GNU_LIBRARY__ */ | ||
555 | extern int getopt_long(int argc, char *const *argv, | ||
556 | const char *shortopts, | ||
557 | const struct option *longopts, int *longind); | ||
558 | extern int getopt_long_only(int argc, char *const *argv, | ||
559 | const char *shortopts, | ||
560 | const struct option *longopts, | ||
561 | int *longind); | ||
562 | |||
563 | /* Internal only. Users should not call this directly. */ | ||
564 | extern int _getopt_internal(int argc, char *const *argv, | ||
565 | const char *shortopts, | ||
566 | const struct option *longopts, | ||
567 | int *longind, int long_only); | ||
568 | #else /* not __STDC__ */ | ||
569 | extern int getopt(); | ||
570 | extern int getopt_long(); | ||
571 | extern int getopt_long_only(); | ||
572 | |||
573 | extern int _getopt_internal(); | ||
574 | #endif /* not __STDC__ */ | ||
575 | |||
576 | #ifdef __cplusplus | ||
577 | } | ||
578 | #endif | ||
579 | #endif /* _GETOPT_H */ | ||
580 | #include <time.h> | 451 | #include <time.h> |
581 | #include <fcntl.h> | 452 | #include <fcntl.h> |
582 | #include <unistd.h> | 453 | #include <unistd.h> |
@@ -1161,7 +1032,7 @@ unsigned n; /* number of bytes in s[] */ | |||
1161 | /* =========================================================================== | 1032 | /* =========================================================================== |
1162 | * Clear input and output buffers | 1033 | * Clear input and output buffers |
1163 | */ | 1034 | */ |
1164 | void clear_bufs() | 1035 | void clear_bufs(void) |
1165 | { | 1036 | { |
1166 | outcnt = 0; | 1037 | outcnt = 0; |
1167 | insize = inptr = 0; | 1038 | insize = inptr = 0; |
@@ -1189,7 +1060,7 @@ int eof_ok; /* set if EOF acceptable as a result */ | |||
1189 | if (insize == 0) { | 1060 | if (insize == 0) { |
1190 | if (eof_ok) | 1061 | if (eof_ok) |
1191 | return EOF; | 1062 | return EOF; |
1192 | read_error(); | 1063 | read_error_msg(); |
1193 | } | 1064 | } |
1194 | bytes_in += (ulg) insize; | 1065 | bytes_in += (ulg) insize; |
1195 | inptr = 1; | 1066 | inptr = 1; |
@@ -1240,7 +1111,7 @@ unsigned cnt; | |||
1240 | 1111 | ||
1241 | while ((n = write(fd, buf, cnt)) != cnt) { | 1112 | while ((n = write(fd, buf, cnt)) != cnt) { |
1242 | if (n == (unsigned) (-1)) { | 1113 | if (n == (unsigned) (-1)) { |
1243 | write_error(); | 1114 | write_error_msg(); |
1244 | } | 1115 | } |
1245 | cnt -= n; | 1116 | cnt -= n; |
1246 | buf = (void *) ((char *) buf + n); | 1117 | buf = (void *) ((char *) buf + n); |
@@ -1306,7 +1177,7 @@ const char *reject; | |||
1306 | /* ======================================================================== | 1177 | /* ======================================================================== |
1307 | * Error handlers. | 1178 | * Error handlers. |
1308 | */ | 1179 | */ |
1309 | void read_error() | 1180 | void read_error_msg() |
1310 | { | 1181 | { |
1311 | fprintf(stderr, "\n"); | 1182 | fprintf(stderr, "\n"); |
1312 | if (errno != 0) { | 1183 | if (errno != 0) { |
@@ -1317,7 +1188,7 @@ void read_error() | |||
1317 | abort_gzip(); | 1188 | abort_gzip(); |
1318 | } | 1189 | } |
1319 | 1190 | ||
1320 | void write_error() | 1191 | void write_error_msg() |
1321 | { | 1192 | { |
1322 | fprintf(stderr, "\n"); | 1193 | fprintf(stderr, "\n"); |
1323 | perror(""); | 1194 | perror(""); |
@@ -329,8 +329,8 @@ extern void flush_window (void); | |||
329 | extern void write_buf (int fd, void * buf, unsigned cnt); | 329 | extern void write_buf (int fd, void * buf, unsigned cnt); |
330 | extern char *strlwr (char *s); | 330 | extern char *strlwr (char *s); |
331 | extern char *add_envopt (int *argcp, char ***argvp, char *env); | 331 | extern char *add_envopt (int *argcp, char ***argvp, char *env); |
332 | extern void read_error (void); | 332 | extern void read_error_msg (void); |
333 | extern void write_error (void); | 333 | extern void write_error_msg (void); |
334 | extern void display_ratio (long num, long den, FILE * file); | 334 | extern void display_ratio (long num, long den, FILE * file); |
335 | 335 | ||
336 | /* in inflate.c */ | 336 | /* in inflate.c */ |
@@ -3138,7 +3138,7 @@ int in, out; /* input and output file descriptors */ | |||
3138 | insize = read(in, (char *) inbuf, INBUFSIZ); | 3138 | insize = read(in, (char *) inbuf, INBUFSIZ); |
3139 | } | 3139 | } |
3140 | if ((int) insize == EOF && errno != 0) { | 3140 | if ((int) insize == EOF && errno != 0) { |
3141 | read_error(); | 3141 | read_error_msg(); |
3142 | } | 3142 | } |
3143 | bytes_in = bytes_out; | 3143 | bytes_in = bytes_out; |
3144 | return OK; | 3144 | return OK; |
diff --git a/hostname.c b/hostname.c index ef921024b..0df9fed75 100644 --- a/hostname.c +++ b/hostname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $ | 3 | * $Id: hostname.c,v 1.9 2000/05/19 05:35:18 erik Exp $ |
4 | * Mini hostname implementation for busybox | 4 | * Mini hostname implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -104,7 +104,6 @@ int hostname_main(int argc, char **argv) | |||
104 | opt_domain = 1; | 104 | opt_domain = 1; |
105 | break; | 105 | break; |
106 | case 'F': | 106 | case 'F': |
107 | filename = optarg; | ||
108 | if (--argc == 0) { | 107 | if (--argc == 0) { |
109 | usage(hostname_usage); | 108 | usage(hostname_usage); |
110 | } | 109 | } |
@@ -46,7 +46,7 @@ | |||
46 | #include <sys/fcntl.h> | 46 | #include <sys/fcntl.h> |
47 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
48 | #include <sys/mount.h> | 48 | #include <sys/mount.h> |
49 | #include <sys/sysmacros.h> | 49 | //#include <sys/sysmacros.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/vt.h> /* for vt_stat */ | 51 | #include <sys/vt.h> /* for vt_stat */ |
52 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
diff --git a/init/init.c b/init/init.c index 29d8f48f9..38e913121 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <sys/fcntl.h> | 46 | #include <sys/fcntl.h> |
47 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> |
48 | #include <sys/mount.h> | 48 | #include <sys/mount.h> |
49 | #include <sys/sysmacros.h> | 49 | //#include <sys/sysmacros.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/vt.h> /* for vt_stat */ | 51 | #include <sys/vt.h> /* for vt_stat */ |
52 | #include <sys/wait.h> | 52 | #include <sys/wait.h> |
diff --git a/internal.h b/internal.h index eb498be43..9c55f5a49 100644 --- a/internal.h +++ b/internal.h | |||
@@ -195,6 +195,7 @@ extern int uniq_main(int argc, char** argv); | |||
195 | extern int update_main(int argc, char** argv); | 195 | extern int update_main(int argc, char** argv); |
196 | extern int usleep_main(int argc, char** argv); | 196 | extern int usleep_main(int argc, char** argv); |
197 | extern int wc_main(int argc, char** argv); | 197 | extern int wc_main(int argc, char** argv); |
198 | extern int which_main(int argc, char** argv); | ||
198 | extern int whoami_main(int argc, char** argv); | 199 | extern int whoami_main(int argc, char** argv); |
199 | extern int yes_main(int argc, char** argv); | 200 | extern int yes_main(int argc, char** argv); |
200 | 201 | ||
@@ -113,13 +113,18 @@ static int busy_loop(FILE * input); | |||
113 | static struct builtInCommand bltins[] = { | 113 | static struct builtInCommand bltins[] = { |
114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, | 114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, |
115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, | 115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, |
116 | {"env", "Print all environment variables", "env", shell_env}, | ||
117 | {"exit", "Exit from shell()", "exit", shell_exit}, | 116 | {"exit", "Exit from shell()", "exit", shell_exit}, |
118 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, | 117 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, |
119 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, | 118 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, |
120 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
121 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, | 119 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, |
122 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, | 120 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, |
121 | {NULL, NULL, NULL, NULL} | ||
122 | }; | ||
123 | |||
124 | /* Table of built-in functions */ | ||
125 | static struct builtInCommand bltins_forking[] = { | ||
126 | {"env", "Print all environment variables", "env", shell_env}, | ||
127 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
123 | {".", "Source-in and run commands in a file", ". filename", shell_source}, | 128 | {".", "Source-in and run commands in a file", ". filename", shell_source}, |
124 | {"help", "List shell built-in commands", "help", shell_help}, | 129 | {"help", "List shell built-in commands", "help", shell_help}, |
125 | {NULL, NULL, NULL, NULL} | 130 | {NULL, NULL, NULL, NULL} |
@@ -247,6 +252,9 @@ static int shell_help(struct job *cmd, struct jobSet *junk) | |||
247 | for (x = bltins; x->cmd; x++) { | 252 | for (x = bltins; x->cmd; x++) { |
248 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | 253 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); |
249 | } | 254 | } |
255 | for (x = bltins_forking; x->cmd; x++) { | ||
256 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | ||
257 | } | ||
250 | fprintf(stdout, "\n\n"); | 258 | fprintf(stdout, "\n\n"); |
251 | return TRUE; | 259 | return TRUE; |
252 | } | 260 | } |
@@ -743,6 +751,13 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
743 | nextout = 1; | 751 | nextout = 1; |
744 | } | 752 | } |
745 | 753 | ||
754 | /* Match any built-ins here */ | ||
755 | for (x = bltins; x->cmd; x++) { | ||
756 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | ||
757 | return (x->function(&newJob, jobList)); | ||
758 | } | ||
759 | } | ||
760 | |||
746 | if (!(newJob.progs[i].pid = fork())) { | 761 | if (!(newJob.progs[i].pid = fork())) { |
747 | signal(SIGTTOU, SIG_DFL); | 762 | signal(SIGTTOU, SIG_DFL); |
748 | 763 | ||
@@ -760,7 +775,7 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
760 | setupRedirections(newJob.progs + i); | 775 | setupRedirections(newJob.progs + i); |
761 | 776 | ||
762 | /* Match any built-ins here */ | 777 | /* Match any built-ins here */ |
763 | for (x = bltins; x->cmd; x++) { | 778 | for (x = bltins_forking; x->cmd; x++) { |
764 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | 779 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { |
765 | exit (x->function(&newJob, jobList)); | 780 | exit (x->function(&newJob, jobList)); |
766 | } | 781 | } |
diff --git a/messages.c b/messages.c index 73d64276d..2f8aab515 100644 --- a/messages.c +++ b/messages.c | |||
@@ -27,26 +27,28 @@ | |||
27 | * may make the binary slightly smaller. | 27 | * may make the binary slightly smaller. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | // TO use, do something like this | 30 | // To use this header file, include something like this: |
31 | // | 31 | // |
32 | //#define BB_DECLARE_EXTERN | 32 | //#define BB_DECLARE_EXTERN |
33 | //#define bb_need_memory_exhausted | 33 | //#define bb_need_memory_exhausted |
34 | //#include "messages.c" | 34 | //#include "messages.c" |
35 | // | 35 | // |
36 | //Then just use the string memory_exhausted when it is needed. | ||
37 | // | ||
38 | |||
39 | #include "internal.h" | ||
36 | #ifndef _BB_MESSAGES_C | 40 | #ifndef _BB_MESSAGES_C |
37 | #define _BB_MESSAGES_C | 41 | #define _BB_MESSAGES_C |
38 | 42 | ||
39 | #define _BB_DEF_MESSAGE_PROTO(symbol) extern const char *symbol; | ||
40 | #define _BB_DEF_MESSAGE_INITIALIZE(symbol, string_const) const char *symbol = string_const; | ||
41 | |||
42 | #ifdef BB_DECLARE_EXTERN | 43 | #ifdef BB_DECLARE_EXTERN |
43 | # define BB_DEF_MESSAGE(symbol, string_const) _BB_DEF_MESSAGE_PROTO(symbol) | 44 | # define BB_DEF_MESSAGE(symbol, string_const) extern const char *symbol; |
44 | #else | 45 | #else |
45 | # define BB_DEF_MESSAGE(symbol, string_const) _BB_DEF_MESSAGE_INITIALIZE(symbol, string_const) | 46 | # define BB_DEF_MESSAGE(symbol, string_const) const char *symbol = string_const; |
46 | #endif | 47 | #endif |
47 | 48 | ||
49 | |||
48 | #if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN | 50 | #if defined bb_need_name_too_long || ! defined BB_DECLARE_EXTERN |
49 | BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n") | 51 | BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n") |
50 | #endif | 52 | #endif |
51 | #if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN | 53 | #if defined bb_need_omitting_directory || ! defined BB_DECLARE_EXTERN |
52 | BB_DEF_MESSAGE(omitting_directory, "%s: %s: omitting directory\n") | 54 | BB_DEF_MESSAGE(omitting_directory, "%s: %s: omitting directory\n") |
@@ -69,6 +71,13 @@ BB_DEF_MESSAGE(name_too_long, "%s: file name too long\n") | |||
69 | #if defined bb_need_help || ! defined BB_DECLARE_EXTERN | 71 | #if defined bb_need_help || ! defined BB_DECLARE_EXTERN |
70 | BB_DEF_MESSAGE(dash_dash_help, "--help") | 72 | BB_DEF_MESSAGE(dash_dash_help, "--help") |
71 | #endif | 73 | #endif |
74 | #if defined bb_need_write_error || ! defined BB_DECLARE_EXTERN | ||
75 | BB_DEF_MESSAGE(write_error, "Write Error\n") | ||
76 | #endif | ||
77 | |||
78 | |||
79 | |||
80 | |||
72 | 81 | ||
73 | #endif /* _BB_MESSAGES_C */ | 82 | #endif /* _BB_MESSAGES_C */ |
74 | 83 | ||
diff --git a/mkfs_minix.c b/mkfs_minix.c index bf4bda9fd..f4f1d0997 100644 --- a/mkfs_minix.c +++ b/mkfs_minix.c | |||
@@ -57,6 +57,9 @@ | |||
57 | * | 57 | * |
58 | * The device may be a block device or a image of one, but this isn't | 58 | * The device may be a block device or a image of one, but this isn't |
59 | * enforced (but it's not much fun on a character device :-). | 59 | * enforced (but it's not much fun on a character device :-). |
60 | * | ||
61 | * Modified for BusyBox by Erik Andersen <andersen@debian.org> -- | ||
62 | * removed getopt based parser and added a hand rolled one. | ||
60 | */ | 63 | */ |
61 | 64 | ||
62 | #include "internal.h" | 65 | #include "internal.h" |
@@ -72,7 +75,6 @@ | |||
72 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
73 | #include <sys/ioctl.h> | 76 | #include <sys/ioctl.h> |
74 | #include <mntent.h> | 77 | #include <mntent.h> |
75 | #include <getopt.h> | ||
76 | 78 | ||
77 | #include <linux/fs.h> | 79 | #include <linux/fs.h> |
78 | #include <linux/minix_fs.h> | 80 | #include <linux/minix_fs.h> |
@@ -174,6 +176,7 @@ static volatile void die(char *str) | |||
174 | exit(8); | 176 | exit(8); |
175 | } | 177 | } |
176 | 178 | ||
179 | static volatile void show_usage() __attribute__ ((noreturn)); | ||
177 | static volatile void show_usage() | 180 | static volatile void show_usage() |
178 | { | 181 | { |
179 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", | 182 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", |
@@ -648,6 +651,7 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
648 | char *tmp; | 651 | char *tmp; |
649 | struct stat statbuf; | 652 | struct stat statbuf; |
650 | char *listfile = NULL; | 653 | char *listfile = NULL; |
654 | int stopIt=FALSE; | ||
651 | 655 | ||
652 | if (argc && *argv) | 656 | if (argc && *argv) |
653 | program_name = *argv; | 657 | program_name = *argv; |
@@ -657,57 +661,86 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
657 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 661 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
658 | die("bad inode size"); | 662 | die("bad inode size"); |
659 | #endif | 663 | #endif |
660 | opterr = 0; | 664 | |
661 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) | 665 | /* Parse options */ |
662 | switch (i) { | 666 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
663 | case 'c': | 667 | argv++; |
664 | check = 1; | 668 | while (--argc >= 0 && *argv && **argv) { |
665 | break; | 669 | if (**argv == '-') { |
666 | case 'i': | 670 | stopIt=FALSE; |
667 | req_nr_inodes = (unsigned long) atol(optarg); | 671 | while (i > 0 && *++(*argv) && stopIt==FALSE) { |
668 | break; | 672 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
669 | case 'l': | 673 | switch (**argv) { |
670 | listfile = optarg; | 674 | case 'c': |
671 | break; | 675 | check = 1; |
672 | case 'n': | 676 | break; |
673 | i = strtoul(optarg, &tmp, 0); | 677 | case 'i': |
674 | if (*tmp) | 678 | if (--argc == 0) { |
675 | show_usage(); | 679 | goto goodbye; |
676 | if (i == 14) | 680 | } |
677 | magic = MINIX_SUPER_MAGIC; | 681 | req_nr_inodes = (unsigned long) atol(*(++argv)); |
678 | else if (i == 30) | 682 | break; |
679 | magic = MINIX_SUPER_MAGIC2; | 683 | case 'l': |
680 | else | 684 | if (--argc == 0) { |
681 | show_usage(); | 685 | goto goodbye; |
682 | namelen = i; | 686 | } |
683 | dirsize = i + 2; | 687 | listfile = *(++argv); |
684 | break; | 688 | break; |
685 | case 'v': | 689 | case 'n': |
690 | { | ||
691 | char *cp=NULL; | ||
692 | |||
693 | if (--argc == 0) { | ||
694 | goto goodbye; | ||
695 | } | ||
696 | if (*(*argv+1) != 0) { | ||
697 | cp = ++(*argv); | ||
698 | } else { | ||
699 | cp = *(++argv); | ||
700 | } | ||
701 | i = strtoul(cp, &tmp, 0); | ||
702 | //printf("cp='%s' i='%d'\n", cp, i); | ||
703 | if (*tmp) | ||
704 | show_usage(); | ||
705 | if (i == 14) | ||
706 | magic = MINIX_SUPER_MAGIC; | ||
707 | else if (i == 30) | ||
708 | magic = MINIX_SUPER_MAGIC2; | ||
709 | else | ||
710 | show_usage(); | ||
711 | namelen = i; | ||
712 | dirsize = i + 2; | ||
713 | stopIt=TRUE; | ||
714 | break; | ||
715 | } | ||
716 | case 'v': | ||
686 | #ifdef HAVE_MINIX2 | 717 | #ifdef HAVE_MINIX2 |
687 | version2 = 1; | 718 | version2 = 1; |
688 | #else | 719 | #else |
689 | fprintf(stderr, "%s: not compiled with minix v2 support\n", | 720 | fprintf(stderr, "%s: not compiled with minix v2 support\n", |
690 | program_name, device_name); | 721 | program_name, device_name); |
691 | exit(-1); | 722 | exit(-1); |
692 | #endif | 723 | #endif |
693 | break; | 724 | break; |
694 | default: | 725 | case '-': |
695 | show_usage(); | 726 | case 'h': |
727 | default: | ||
728 | goodbye: | ||
729 | show_usage(); | ||
730 | } | ||
731 | } | ||
732 | } else { | ||
733 | //printf("else: argc='%d' argv='%s'\n", argc, *argv); | ||
734 | if (device_name == NULL) | ||
735 | device_name = *argv; | ||
736 | else if (BLOCKS == 0) | ||
737 | BLOCKS = strtol(*argv, &tmp, 0); | ||
738 | else { | ||
739 | goto goodbye; | ||
740 | } | ||
696 | } | 741 | } |
697 | argc -= optind; | ||
698 | argv += optind; | ||
699 | if (argc > 0 && !device_name) { | ||
700 | device_name = argv[0]; | ||
701 | argc--; | ||
702 | argv++; | 742 | argv++; |
703 | } | 743 | } |
704 | if (argc > 0) { | ||
705 | BLOCKS = strtol(argv[0], &tmp, 0); | ||
706 | if (*tmp) { | ||
707 | printf("strtol error: number of blocks not specified"); | ||
708 | show_usage(); | ||
709 | } | ||
710 | } | ||
711 | 744 | ||
712 | if (device_name && !BLOCKS) | 745 | if (device_name && !BLOCKS) |
713 | BLOCKS = get_size(device_name) / 1024; | 746 | BLOCKS = get_size(device_name) / 1024; |
@@ -760,5 +793,6 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
760 | } | 793 | } |
761 | mark_good_blocks(); | 794 | mark_good_blocks(); |
762 | write_tables(); | 795 | write_tables(); |
763 | return 0; | 796 | exit( 0); |
797 | |||
764 | } | 798 | } |
diff --git a/networking/hostname.c b/networking/hostname.c index ef921024b..0df9fed75 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * $Id: hostname.c,v 1.8 2000/05/12 19:41:47 erik Exp $ | 3 | * $Id: hostname.c,v 1.9 2000/05/19 05:35:18 erik Exp $ |
4 | * Mini hostname implementation for busybox | 4 | * Mini hostname implementation for busybox |
5 | * | 5 | * |
6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> | 6 | * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> |
@@ -104,7 +104,6 @@ int hostname_main(int argc, char **argv) | |||
104 | opt_domain = 1; | 104 | opt_domain = 1; |
105 | break; | 105 | break; |
106 | case 'F': | 106 | case 'F': |
107 | filename = optarg; | ||
108 | if (--argc == 0) { | 107 | if (--argc == 0) { |
109 | usage(hostname_usage); | 108 | usage(hostname_usage); |
110 | } | 109 | } |
@@ -51,7 +51,6 @@ | |||
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <stdio.h> | 52 | #include <stdio.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <getopt.h> | ||
55 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
56 | #include <string.h> | 55 | #include <string.h> |
57 | #include <errno.h> | 56 | #include <errno.h> |
@@ -474,7 +474,7 @@ extern regexp *regcomp(char *text) | |||
474 | int token; | 474 | int token; |
475 | int peek; | 475 | int peek; |
476 | char *build; | 476 | char *build; |
477 | regexp *re; // Ignore compiler whining. If we longjmp, we don't use re anymore. | 477 | regexp *re; |
478 | 478 | ||
479 | 479 | ||
480 | /* prepare for error handling */ | 480 | /* prepare for error handling */ |
@@ -113,13 +113,18 @@ static int busy_loop(FILE * input); | |||
113 | static struct builtInCommand bltins[] = { | 113 | static struct builtInCommand bltins[] = { |
114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, | 114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, |
115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, | 115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, |
116 | {"env", "Print all environment variables", "env", shell_env}, | ||
117 | {"exit", "Exit from shell()", "exit", shell_exit}, | 116 | {"exit", "Exit from shell()", "exit", shell_exit}, |
118 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, | 117 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, |
119 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, | 118 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, |
120 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
121 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, | 119 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, |
122 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, | 120 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, |
121 | {NULL, NULL, NULL, NULL} | ||
122 | }; | ||
123 | |||
124 | /* Table of built-in functions */ | ||
125 | static struct builtInCommand bltins_forking[] = { | ||
126 | {"env", "Print all environment variables", "env", shell_env}, | ||
127 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
123 | {".", "Source-in and run commands in a file", ". filename", shell_source}, | 128 | {".", "Source-in and run commands in a file", ". filename", shell_source}, |
124 | {"help", "List shell built-in commands", "help", shell_help}, | 129 | {"help", "List shell built-in commands", "help", shell_help}, |
125 | {NULL, NULL, NULL, NULL} | 130 | {NULL, NULL, NULL, NULL} |
@@ -247,6 +252,9 @@ static int shell_help(struct job *cmd, struct jobSet *junk) | |||
247 | for (x = bltins; x->cmd; x++) { | 252 | for (x = bltins; x->cmd; x++) { |
248 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | 253 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); |
249 | } | 254 | } |
255 | for (x = bltins_forking; x->cmd; x++) { | ||
256 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | ||
257 | } | ||
250 | fprintf(stdout, "\n\n"); | 258 | fprintf(stdout, "\n\n"); |
251 | return TRUE; | 259 | return TRUE; |
252 | } | 260 | } |
@@ -743,6 +751,13 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
743 | nextout = 1; | 751 | nextout = 1; |
744 | } | 752 | } |
745 | 753 | ||
754 | /* Match any built-ins here */ | ||
755 | for (x = bltins; x->cmd; x++) { | ||
756 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | ||
757 | return (x->function(&newJob, jobList)); | ||
758 | } | ||
759 | } | ||
760 | |||
746 | if (!(newJob.progs[i].pid = fork())) { | 761 | if (!(newJob.progs[i].pid = fork())) { |
747 | signal(SIGTTOU, SIG_DFL); | 762 | signal(SIGTTOU, SIG_DFL); |
748 | 763 | ||
@@ -760,7 +775,7 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
760 | setupRedirections(newJob.progs + i); | 775 | setupRedirections(newJob.progs + i); |
761 | 776 | ||
762 | /* Match any built-ins here */ | 777 | /* Match any built-ins here */ |
763 | for (x = bltins; x->cmd; x++) { | 778 | for (x = bltins_forking; x->cmd; x++) { |
764 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | 779 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { |
765 | exit (x->function(&newJob, jobList)); | 780 | exit (x->function(&newJob, jobList)); |
766 | } | 781 | } |
diff --git a/shell/lash.c b/shell/lash.c index 9d4c27a9a..8ea5e305b 100644 --- a/shell/lash.c +++ b/shell/lash.c | |||
@@ -113,13 +113,18 @@ static int busy_loop(FILE * input); | |||
113 | static struct builtInCommand bltins[] = { | 113 | static struct builtInCommand bltins[] = { |
114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, | 114 | {"bg", "Resume a job in the background", "bg [%%job]", shell_fg_bg}, |
115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, | 115 | {"cd", "Change working directory", "cd [dir]", shell_cd}, |
116 | {"env", "Print all environment variables", "env", shell_env}, | ||
117 | {"exit", "Exit from shell()", "exit", shell_exit}, | 116 | {"exit", "Exit from shell()", "exit", shell_exit}, |
118 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, | 117 | {"fg", "Bring job into the foreground", "fg [%%job]", shell_fg_bg}, |
119 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, | 118 | {"jobs", "Lists the active jobs", "jobs", shell_jobs}, |
120 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
121 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, | 119 | {"export", "Set environment variable", "export [VAR=value]", shell_export}, |
122 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, | 120 | {"unset", "Unset environment variable", "unset VAR", shell_unset}, |
121 | {NULL, NULL, NULL, NULL} | ||
122 | }; | ||
123 | |||
124 | /* Table of built-in functions */ | ||
125 | static struct builtInCommand bltins_forking[] = { | ||
126 | {"env", "Print all environment variables", "env", shell_env}, | ||
127 | {"pwd", "Print current directory", "pwd", shell_pwd}, | ||
123 | {".", "Source-in and run commands in a file", ". filename", shell_source}, | 128 | {".", "Source-in and run commands in a file", ". filename", shell_source}, |
124 | {"help", "List shell built-in commands", "help", shell_help}, | 129 | {"help", "List shell built-in commands", "help", shell_help}, |
125 | {NULL, NULL, NULL, NULL} | 130 | {NULL, NULL, NULL, NULL} |
@@ -247,6 +252,9 @@ static int shell_help(struct job *cmd, struct jobSet *junk) | |||
247 | for (x = bltins; x->cmd; x++) { | 252 | for (x = bltins; x->cmd; x++) { |
248 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | 253 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); |
249 | } | 254 | } |
255 | for (x = bltins_forking; x->cmd; x++) { | ||
256 | fprintf(stdout, "%s\t%s\n", x->cmd, x->descr); | ||
257 | } | ||
250 | fprintf(stdout, "\n\n"); | 258 | fprintf(stdout, "\n\n"); |
251 | return TRUE; | 259 | return TRUE; |
252 | } | 260 | } |
@@ -743,6 +751,13 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
743 | nextout = 1; | 751 | nextout = 1; |
744 | } | 752 | } |
745 | 753 | ||
754 | /* Match any built-ins here */ | ||
755 | for (x = bltins; x->cmd; x++) { | ||
756 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | ||
757 | return (x->function(&newJob, jobList)); | ||
758 | } | ||
759 | } | ||
760 | |||
746 | if (!(newJob.progs[i].pid = fork())) { | 761 | if (!(newJob.progs[i].pid = fork())) { |
747 | signal(SIGTTOU, SIG_DFL); | 762 | signal(SIGTTOU, SIG_DFL); |
748 | 763 | ||
@@ -760,7 +775,7 @@ static int runCommand(struct job newJob, struct jobSet *jobList, int inBg) | |||
760 | setupRedirections(newJob.progs + i); | 775 | setupRedirections(newJob.progs + i); |
761 | 776 | ||
762 | /* Match any built-ins here */ | 777 | /* Match any built-ins here */ |
763 | for (x = bltins; x->cmd; x++) { | 778 | for (x = bltins_forking; x->cmd; x++) { |
764 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { | 779 | if (!strcmp(newJob.progs[i].argv[0], x->cmd)) { |
765 | exit (x->function(&newJob, jobList)); | 780 | exit (x->function(&newJob, jobList)); |
766 | } | 781 | } |
@@ -30,6 +30,20 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/types.h> | 32 | #include <sys/types.h> |
33 | #define BB_DECLARE_EXTERN | ||
34 | #define bb_need_write_error | ||
35 | #include "messages.c" | ||
36 | |||
37 | const char *tr_usage="tr [-cds] STRING1 [STRING2]\n" | ||
38 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
39 | "\nTranslate, squeeze, and/or delete characters from\n" | ||
40 | "standard input, writing to standard output.\n\n" | ||
41 | "Options:\n" | ||
42 | "\t-c\ttake complement of STRING1\n" | ||
43 | "\t-d\tdelete input characters coded STRING1\n" | ||
44 | "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" | ||
45 | #endif | ||
46 | ; | ||
33 | 47 | ||
34 | 48 | ||
35 | 49 | ||
@@ -60,7 +74,7 @@ static void convert() | |||
60 | if (in_index == read_chars) { | 74 | if (in_index == read_chars) { |
61 | if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { | 75 | if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) { |
62 | if (write(1, (char *) output, out_index) != out_index) | 76 | if (write(1, (char *) output, out_index) != out_index) |
63 | write(2, "Bad write\n", 10); | 77 | write(2, write_error, strlen(write_error)); |
64 | exit(0); | 78 | exit(0); |
65 | } | 79 | } |
66 | in_index = 0; | 80 | in_index = 0; |
@@ -74,7 +88,7 @@ static void convert() | |||
74 | output[out_index++] = last = coded; | 88 | output[out_index++] = last = coded; |
75 | if (out_index == BUFSIZ) { | 89 | if (out_index == BUFSIZ) { |
76 | if (write(1, (char *) output, out_index) != out_index) { | 90 | if (write(1, (char *) output, out_index) != out_index) { |
77 | write(2, "Bad write\n", 10); | 91 | write(2, write_error, strlen(write_error)); |
78 | exit(1); | 92 | exit(1); |
79 | } | 93 | } |
80 | out_index = 0; | 94 | out_index = 0; |
@@ -167,16 +181,7 @@ extern int tr_main(int argc, char **argv) | |||
167 | sq_fl = TRUE; | 181 | sq_fl = TRUE; |
168 | break; | 182 | break; |
169 | default: | 183 | default: |
170 | usage("tr [-cds] STRING1 [STRING2]\n" | 184 | usage(tr_usage); |
171 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
172 | "\nTranslate, squeeze, and/or delete characters from\n" | ||
173 | "standard input, writing to standard output.\n\n" | ||
174 | "Options:\n" | ||
175 | "\t-c\ttake complement of STRING1\n" | ||
176 | "\t-d\tdelete input characters coded STRING1\n" | ||
177 | "\t-s\tsqueeze multiple output characters of STRING2 into one character\n" | ||
178 | #endif | ||
179 | ); | ||
180 | } | 185 | } |
181 | } | 186 | } |
182 | index++; | 187 | index++; |
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index 6fa17b5fb..c4f4fb408 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "internal.h" | 18 | #include "internal.h" |
19 | #include <linux/unistd.h> | 19 | #include <linux/unistd.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <getopt.h> | ||
22 | #include <stdlib.h> | 21 | #include <stdlib.h> |
23 | 22 | ||
24 | #if __GNU_LIBRARY__ < 5 | 23 | #if __GNU_LIBRARY__ < 5 |
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index bf4bda9fd..f4f1d0997 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -57,6 +57,9 @@ | |||
57 | * | 57 | * |
58 | * The device may be a block device or a image of one, but this isn't | 58 | * The device may be a block device or a image of one, but this isn't |
59 | * enforced (but it's not much fun on a character device :-). | 59 | * enforced (but it's not much fun on a character device :-). |
60 | * | ||
61 | * Modified for BusyBox by Erik Andersen <andersen@debian.org> -- | ||
62 | * removed getopt based parser and added a hand rolled one. | ||
60 | */ | 63 | */ |
61 | 64 | ||
62 | #include "internal.h" | 65 | #include "internal.h" |
@@ -72,7 +75,6 @@ | |||
72 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
73 | #include <sys/ioctl.h> | 76 | #include <sys/ioctl.h> |
74 | #include <mntent.h> | 77 | #include <mntent.h> |
75 | #include <getopt.h> | ||
76 | 78 | ||
77 | #include <linux/fs.h> | 79 | #include <linux/fs.h> |
78 | #include <linux/minix_fs.h> | 80 | #include <linux/minix_fs.h> |
@@ -174,6 +176,7 @@ static volatile void die(char *str) | |||
174 | exit(8); | 176 | exit(8); |
175 | } | 177 | } |
176 | 178 | ||
179 | static volatile void show_usage() __attribute__ ((noreturn)); | ||
177 | static volatile void show_usage() | 180 | static volatile void show_usage() |
178 | { | 181 | { |
179 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", | 182 | fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n\n", |
@@ -648,6 +651,7 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
648 | char *tmp; | 651 | char *tmp; |
649 | struct stat statbuf; | 652 | struct stat statbuf; |
650 | char *listfile = NULL; | 653 | char *listfile = NULL; |
654 | int stopIt=FALSE; | ||
651 | 655 | ||
652 | if (argc && *argv) | 656 | if (argc && *argv) |
653 | program_name = *argv; | 657 | program_name = *argv; |
@@ -657,57 +661,86 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
657 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) | 661 | if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) |
658 | die("bad inode size"); | 662 | die("bad inode size"); |
659 | #endif | 663 | #endif |
660 | opterr = 0; | 664 | |
661 | while ((i = getopt(argc, argv, "ci:l:n:v")) != EOF) | 665 | /* Parse options */ |
662 | switch (i) { | 666 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
663 | case 'c': | 667 | argv++; |
664 | check = 1; | 668 | while (--argc >= 0 && *argv && **argv) { |
665 | break; | 669 | if (**argv == '-') { |
666 | case 'i': | 670 | stopIt=FALSE; |
667 | req_nr_inodes = (unsigned long) atol(optarg); | 671 | while (i > 0 && *++(*argv) && stopIt==FALSE) { |
668 | break; | 672 | //printf("argc='%d' argv='%s'\n", argc, *argv); |
669 | case 'l': | 673 | switch (**argv) { |
670 | listfile = optarg; | 674 | case 'c': |
671 | break; | 675 | check = 1; |
672 | case 'n': | 676 | break; |
673 | i = strtoul(optarg, &tmp, 0); | 677 | case 'i': |
674 | if (*tmp) | 678 | if (--argc == 0) { |
675 | show_usage(); | 679 | goto goodbye; |
676 | if (i == 14) | 680 | } |
677 | magic = MINIX_SUPER_MAGIC; | 681 | req_nr_inodes = (unsigned long) atol(*(++argv)); |
678 | else if (i == 30) | 682 | break; |
679 | magic = MINIX_SUPER_MAGIC2; | 683 | case 'l': |
680 | else | 684 | if (--argc == 0) { |
681 | show_usage(); | 685 | goto goodbye; |
682 | namelen = i; | 686 | } |
683 | dirsize = i + 2; | 687 | listfile = *(++argv); |
684 | break; | 688 | break; |
685 | case 'v': | 689 | case 'n': |
690 | { | ||
691 | char *cp=NULL; | ||
692 | |||
693 | if (--argc == 0) { | ||
694 | goto goodbye; | ||
695 | } | ||
696 | if (*(*argv+1) != 0) { | ||
697 | cp = ++(*argv); | ||
698 | } else { | ||
699 | cp = *(++argv); | ||
700 | } | ||
701 | i = strtoul(cp, &tmp, 0); | ||
702 | //printf("cp='%s' i='%d'\n", cp, i); | ||
703 | if (*tmp) | ||
704 | show_usage(); | ||
705 | if (i == 14) | ||
706 | magic = MINIX_SUPER_MAGIC; | ||
707 | else if (i == 30) | ||
708 | magic = MINIX_SUPER_MAGIC2; | ||
709 | else | ||
710 | show_usage(); | ||
711 | namelen = i; | ||
712 | dirsize = i + 2; | ||
713 | stopIt=TRUE; | ||
714 | break; | ||
715 | } | ||
716 | case 'v': | ||
686 | #ifdef HAVE_MINIX2 | 717 | #ifdef HAVE_MINIX2 |
687 | version2 = 1; | 718 | version2 = 1; |
688 | #else | 719 | #else |
689 | fprintf(stderr, "%s: not compiled with minix v2 support\n", | 720 | fprintf(stderr, "%s: not compiled with minix v2 support\n", |
690 | program_name, device_name); | 721 | program_name, device_name); |
691 | exit(-1); | 722 | exit(-1); |
692 | #endif | 723 | #endif |
693 | break; | 724 | break; |
694 | default: | 725 | case '-': |
695 | show_usage(); | 726 | case 'h': |
727 | default: | ||
728 | goodbye: | ||
729 | show_usage(); | ||
730 | } | ||
731 | } | ||
732 | } else { | ||
733 | //printf("else: argc='%d' argv='%s'\n", argc, *argv); | ||
734 | if (device_name == NULL) | ||
735 | device_name = *argv; | ||
736 | else if (BLOCKS == 0) | ||
737 | BLOCKS = strtol(*argv, &tmp, 0); | ||
738 | else { | ||
739 | goto goodbye; | ||
740 | } | ||
696 | } | 741 | } |
697 | argc -= optind; | ||
698 | argv += optind; | ||
699 | if (argc > 0 && !device_name) { | ||
700 | device_name = argv[0]; | ||
701 | argc--; | ||
702 | argv++; | 742 | argv++; |
703 | } | 743 | } |
704 | if (argc > 0) { | ||
705 | BLOCKS = strtol(argv[0], &tmp, 0); | ||
706 | if (*tmp) { | ||
707 | printf("strtol error: number of blocks not specified"); | ||
708 | show_usage(); | ||
709 | } | ||
710 | } | ||
711 | 744 | ||
712 | if (device_name && !BLOCKS) | 745 | if (device_name && !BLOCKS) |
713 | BLOCKS = get_size(device_name) / 1024; | 746 | BLOCKS = get_size(device_name) / 1024; |
@@ -760,5 +793,6 @@ extern int mkfs_minix_main(int argc, char **argv) | |||
760 | } | 793 | } |
761 | mark_good_blocks(); | 794 | mark_good_blocks(); |
762 | write_tables(); | 795 | write_tables(); |
763 | return 0; | 796 | exit( 0); |
797 | |||
764 | } | 798 | } |
@@ -801,12 +801,13 @@ unsigned long my_getid(const char *filename, char *name, unsigned long id, unsig | |||
801 | { | 801 | { |
802 | FILE *file; | 802 | FILE *file; |
803 | char *rname, *start, *end, buf[128]; | 803 | char *rname, *start, *end, buf[128]; |
804 | id_t rid; | 804 | unsigned long rid; |
805 | unsigned long rgid = 0; | 805 | unsigned long rgid = 0; |
806 | 806 | ||
807 | file = fopen(filename, "r"); | 807 | file = fopen(filename, "r"); |
808 | if (file == NULL) { | 808 | if (file == NULL) { |
809 | perror(filename); | 809 | /* Do not complain. It is ok for /etc/password and |
810 | * friends to be missing... */ | ||
810 | return (-1); | 811 | return (-1); |
811 | } | 812 | } |
812 | 813 | ||
diff --git a/which.c b/which.c new file mode 100644 index 000000000..46c2204a5 --- /dev/null +++ b/which.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * Which implementation for busybox | ||
4 | * | ||
5 | * Copyright (C) 2000 by Lineo, inc. | ||
6 | * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "internal.h" | ||
25 | #include <stdio.h> | ||
26 | #include <dirent.h> | ||
27 | |||
28 | |||
29 | extern int which_main(int argc, char **argv) | ||
30 | { | ||
31 | char *path_list, *test, *tmp; | ||
32 | struct dirent *next; | ||
33 | |||
34 | if (**(argv + 1) == '-') { | ||
35 | usage("which [COMMAND ...]\n" | ||
36 | #ifndef BB_FEATURE_TRIVIAL_HELP | ||
37 | "\nLocates a COMMAND.\n" | ||
38 | #endif | ||
39 | ); | ||
40 | } | ||
41 | argc--; | ||
42 | |||
43 | path_list = getenv("PATH"); | ||
44 | if (!path_list) | ||
45 | path_list = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"; | ||
46 | |||
47 | while(argc-- > 0 && *(argv++) != '\0' && strlen(*argv)) { | ||
48 | for( test=path_list; (tmp=strchr(test, ':')) && (tmp+1)!=NULL; test=++tmp) { | ||
49 | DIR *dir; | ||
50 | *tmp='\0'; | ||
51 | //printf("Checking directory '%s'\n", test); | ||
52 | dir = opendir(test); | ||
53 | if (!dir) | ||
54 | continue; | ||
55 | while ((next = readdir(dir)) != NULL) { | ||
56 | //printf("Checking file '%s'\n", next->d_name); | ||
57 | if ((strcmp(next->d_name, *argv) == 0)) { | ||
58 | printf("%s/%s\n", test, next->d_name); | ||
59 | exit(TRUE); | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | exit(TRUE); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | Local Variables: | ||
69 | c-file-style: "linux" | ||
70 | c-basic-offset: 4 | ||
71 | tab-width: 4 | ||
72 | End: | ||
73 | */ | ||