diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-01-06 06:27:17 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-01-06 06:27:17 +0000 |
| commit | bcd5fc12ec4d31f7633460cb66c2e8a5436ace18 (patch) | |
| tree | 6664a87764ecf647c41520078d1328dca2dc7e75 | |
| parent | 56ea65ca5f30778f05c8882b04e3a94c869bbca4 (diff) | |
| download | busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.tar.gz busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.tar.bz2 busybox-w32-bcd5fc12ec4d31f7633460cb66c2e8a5436ace18.zip | |
tac: new applet. ~240 bytes.
Copyright (C) 2003 Yang Xiaopeng <yxp at hanwang.com.cn>
Copyright (C) 2007 Natanael Copa <natanael.copa@gmail.com>
Copyright (C) 2007 Tito Ragusa <farmatito@tiscali.it>
| -rw-r--r-- | coreutils/Config.in | 6 | ||||
| -rw-r--r-- | coreutils/Kbuild | 1 | ||||
| -rw-r--r-- | docs/nofork_noexec.txt | 25 | ||||
| -rw-r--r-- | include/applets.h | 1 | ||||
| -rw-r--r-- | include/usage.h | 5 |
5 files changed, 30 insertions, 8 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index d3cbc4213..3b3f7b333 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
| @@ -579,6 +579,12 @@ config SYNC | |||
| 579 | help | 579 | help |
| 580 | sync is used to flush filesystem buffers. | 580 | sync is used to flush filesystem buffers. |
| 581 | 581 | ||
| 582 | config TAC | ||
| 583 | bool "tac" | ||
| 584 | default n | ||
| 585 | help | ||
| 586 | tac is used to concatenate and print files in reverse. | ||
| 587 | |||
| 582 | config TAIL | 588 | config TAIL |
| 583 | bool "tail" | 589 | bool "tail" |
| 584 | default n | 590 | default n |
diff --git a/coreutils/Kbuild b/coreutils/Kbuild index ce21b3a89..8ada8b056 100644 --- a/coreutils/Kbuild +++ b/coreutils/Kbuild | |||
| @@ -66,6 +66,7 @@ lib-$(CONFIG_STAT) += stat.o | |||
| 66 | lib-$(CONFIG_STTY) += stty.o | 66 | lib-$(CONFIG_STTY) += stty.o |
| 67 | lib-$(CONFIG_SUM) += sum.o | 67 | lib-$(CONFIG_SUM) += sum.o |
| 68 | lib-$(CONFIG_SYNC) += sync.o | 68 | lib-$(CONFIG_SYNC) += sync.o |
| 69 | lib-$(CONFIG_TAC) += tac.o | ||
| 69 | lib-$(CONFIG_TAIL) += tail.o | 70 | lib-$(CONFIG_TAIL) += tail.o |
| 70 | lib-$(CONFIG_TEE) += tee.o | 71 | lib-$(CONFIG_TEE) += tee.o |
| 71 | lib-$(CONFIG_TEST) += test.o | 72 | lib-$(CONFIG_TEST) += test.o |
diff --git a/docs/nofork_noexec.txt b/docs/nofork_noexec.txt index d4abdf452..06c789aff 100644 --- a/docs/nofork_noexec.txt +++ b/docs/nofork_noexec.txt | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | Unix shells traditionally execute some commands internally in the attempt | 3 | Unix shells traditionally execute some commands internally in the attempt |
| 4 | to dramatically speed up execution. It will be slow as hell if for every | 4 | to dramatically speed up execution. It will be slow as hell if for every |
| 5 | "echo blah" shell will fork and exec /bin/echo. For this end, shells | 5 | "echo blah" shell will fork and exec /bin/echo. To this end, shells |
| 6 | have to _reimplement_ these commands internally. | 6 | have to _reimplement_ these commands internally. |
| 7 | 7 | ||
| 8 | Busybox is unique in this regard because it already is a collection | 8 | Busybox is unique in this regard because it already is a collection |
| @@ -11,14 +11,20 @@ for speeding up busybox shells, and more. NOEXEC and NOFORK applets | |||
| 11 | are exactly those applets which are eligible for these tricks. | 11 | are exactly those applets which are eligible for these tricks. |
| 12 | 12 | ||
| 13 | Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such | 13 | Applet will be subject to NOFORK/NOEXEC tricks if it is marked as such |
| 14 | in applets.h. CONFIG_FEATURE_PREFER_APPLETS is a config option which | 14 | in applets.h. FEATURE_PREFER_APPLETS is a config option which |
| 15 | globally enables usage of NOFORK/NOEXEC tricks. | 15 | globally enables usage of NOFORK/NOEXEC tricks. |
| 16 | If it is enabled, FEATURE_SH_STANDALONE can be enabled too, | ||
| 17 | and then shells will use NOFORK/NOEXEC tricks for ordinary commands. | ||
| 18 | NB: shell builtins use these tricks regardless of FEATURE_SH_STANDALONE | ||
| 19 | or FEATURE_PREFER_APPLETS. | ||
| 16 | 20 | ||
| 17 | If you want to call a program and wait for it, use spawn_and_wait(argv). | 21 | In C, if you want to call a program and wait for it, use |
| 18 | It will check whether argv[0] is an applet name and will optionally | 22 | spawn_and_wait(argv), BB_EXECVP(prog,argv) or BB_EXECLP(prog,argv0,...). |
| 19 | do NOFORK/NOEXEC thing. | 23 | They check whether program name is an applet name and optionally |
| 24 | do NOFORK/NOEXEC thing depending on configuration. | ||
| 20 | 25 | ||
| 21 | NOEXEC | 26 | |
| 27 | NOEXEC | ||
| 22 | 28 | ||
| 23 | NOEXEC applet should work correctly if another applet forks and then | 29 | NOEXEC applet should work correctly if another applet forks and then |
| 24 | executes exit(<applet>_main(argc,argv)) in the child. The rules | 30 | executes exit(<applet>_main(argc,argv)) in the child. The rules |
| @@ -32,9 +38,10 @@ roughly are: | |||
| 32 | * ... | 38 | * ... |
| 33 | 39 | ||
| 34 | NOEXEC applets save only one half of fork+exec overhead. | 40 | NOEXEC applets save only one half of fork+exec overhead. |
| 35 | NOEXEC trick is disabled for NOMMU compile. | 41 | NOEXEC trick is disabled for NOMMU build. |
| 42 | |||
| 36 | 43 | ||
| 37 | NOFORK | 44 | NOFORK |
| 38 | 45 | ||
| 39 | NOFORK applet should work correctly if another applet simply runs | 46 | NOFORK applet should work correctly if another applet simply runs |
| 40 | <applet>_main(argc,argv) and then continues with its business (xargs, | 47 | <applet>_main(argc,argv) and then continues with its business (xargs, |
| @@ -55,6 +62,8 @@ on what applet can/cannot do: | |||
| 55 | * if you allocate memory, you can use xmalloc() only on the very first | 62 | * if you allocate memory, you can use xmalloc() only on the very first |
| 56 | allocation. All other allocations should use malloc[_or_warn](). | 63 | allocation. All other allocations should use malloc[_or_warn](). |
| 57 | After first allocation, you cannot use any xfuncs. | 64 | After first allocation, you cannot use any xfuncs. |
| 65 | Otherwise, failing xfunc will return to caller applet | ||
| 66 | without freeing malloced data! | ||
| 58 | * All allocated data, opened files, signal handlers, termios settings, | 67 | * All allocated data, opened files, signal handlers, termios settings, |
| 59 | O_NONBLOCK flags etc should be freed/closed/restored prior to return. | 68 | O_NONBLOCK flags etc should be freed/closed/restored prior to return. |
| 60 | * ... | 69 | * ... |
diff --git a/include/applets.h b/include/applets.h index c6331cb05..4934d18cd 100644 --- a/include/applets.h +++ b/include/applets.h | |||
| @@ -334,6 +334,7 @@ USE_SWITCH_ROOT(APPLET(switch_root, _BB_DIR_SBIN, _BB_SUID_NEVER)) | |||
| 334 | USE_SYNC(APPLET_NOFORK(sync, sync, _BB_DIR_BIN, _BB_SUID_NEVER, sync)) | 334 | USE_SYNC(APPLET_NOFORK(sync, sync, _BB_DIR_BIN, _BB_SUID_NEVER, sync)) |
| 335 | USE_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 335 | USE_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 336 | USE_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 336 | USE_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 337 | USE_TAC(APPLET_NOEXEC(tac, tac, _BB_DIR_USR_BIN, _BB_SUID_NEVER, tac)) | ||
| 337 | USE_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 338 | USE_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 338 | USE_TAR(APPLET(tar, _BB_DIR_BIN, _BB_SUID_NEVER)) | 339 | USE_TAR(APPLET(tar, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 339 | USE_TASKSET(APPLET(taskset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 340 | USE_TASKSET(APPLET(taskset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
diff --git a/include/usage.h b/include/usage.h index 12d2cefd9..464fb614b 100644 --- a/include/usage.h +++ b/include/usage.h | |||
| @@ -3542,6 +3542,11 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when | |||
| 3542 | "$ syslogd -R masterlog:514\n" \ | 3542 | "$ syslogd -R masterlog:514\n" \ |
| 3543 | "$ syslogd -R 192.168.1.1:601\n" | 3543 | "$ syslogd -R 192.168.1.1:601\n" |
| 3544 | 3544 | ||
| 3545 | #define tac_trivial_usage \ | ||
| 3546 | "[FILE]..." | ||
| 3547 | #define tac_full_usage \ | ||
| 3548 | "Concatenates FILE(s) and prints them to stdout in reverse" | ||
| 3549 | |||
| 3545 | #define tail_trivial_usage \ | 3550 | #define tail_trivial_usage \ |
| 3546 | "[OPTION]... [FILE]..." | 3551 | "[OPTION]... [FILE]..." |
| 3547 | #define tail_full_usage \ | 3552 | #define tail_full_usage \ |
