aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TEST_config_nommu (renamed from TODO_config_nommu)0
-rw-r--r--TEST_config_noprintf16
-rw-r--r--archival/Config.src2
-rw-r--r--archival/Kbuild.src3
-rw-r--r--archival/dpkg_deb.c9
-rw-r--r--archival/libunarchive/Kbuild.src2
-rw-r--r--archival/libunarchive/data_extract_all.c31
-rw-r--r--console-tools/Config.src2
-rw-r--r--console-tools/Kbuild.src2
-rw-r--r--console-tools/clear.c6
-rw-r--r--coreutils/Kbuild.src1
-rw-r--r--coreutils/basename.c12
-rw-r--r--coreutils/date.c13
-rw-r--r--coreutils/libcoreutils/Kbuild.src2
-rw-r--r--coreutils/stat.c41
-rw-r--r--debianutils/Config.src2
-rw-r--r--debianutils/Kbuild.src2
-rw-r--r--debianutils/mktemp.c23
-rw-r--r--e2fsprogs/Config.src2
-rw-r--r--e2fsprogs/Kbuild.src2
-rw-r--r--e2fsprogs/old_e2fsprogs/Config.src2
-rw-r--r--e2fsprogs/old_e2fsprogs/Kbuild.src2
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/Kbuild.src3
-rw-r--r--e2fsprogs/old_e2fsprogs/e2p/Kbuild.src3
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src3
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/Kbuild.src2
-rw-r--r--editors/Config.src2
-rw-r--r--editors/Kbuild.src2
-rw-r--r--editors/sed.c2
-rw-r--r--findutils/find.c90
-rw-r--r--findutils/grep.c63
-rw-r--r--findutils/xargs.c519
-rw-r--r--include/applets.src.h5
-rw-r--r--include/libbb.h2
-rw-r--r--include/usage.src.h252
-rw-r--r--init/Config.src2
-rw-r--r--init/Kbuild.src2
-rw-r--r--libbb/Config.src2
-rw-r--r--libbb/Kbuild.src2
-rw-r--r--libbb/appletlib.c7
-rw-r--r--libbb/xfuncs.c54
-rw-r--r--loginutils/Config.src2
-rw-r--r--loginutils/Kbuild.src2
-rw-r--r--loginutils/getty.c3
-rw-r--r--mailutils/Config.src2
-rw-r--r--mailutils/Kbuild.src2
-rw-r--r--miscutils/Config.src4
-rw-r--r--miscutils/Kbuild.src2
-rw-r--r--miscutils/bbconfig.c2
-rw-r--r--miscutils/ubi_attach_detach.c88
-rw-r--r--modutils/Kbuild.src1
-rw-r--r--modutils/insmod.c22
-rw-r--r--modutils/modinfo.c2
-rw-r--r--modutils/modprobe-small.c13
-rw-r--r--modutils/modprobe.c171
-rw-r--r--modutils/modutils.h41
-rw-r--r--networking/Config.src5
-rw-r--r--networking/Kbuild.src2
-rw-r--r--networking/libiproute/Kbuild.src2
-rw-r--r--networking/telnet.c4
-rw-r--r--networking/tftp.c6
-rw-r--r--networking/udhcp/Config.src2
-rw-r--r--networking/udhcp/Kbuild.src2
-rw-r--r--printutils/Config.src2
-rw-r--r--procps/Config.src2
-rw-r--r--procps/Kbuild.src2
-rw-r--r--procps/fuser.c44
-rw-r--r--runit/Config.src2
-rw-r--r--runit/Kbuild.src3
-rw-r--r--scripts/basic/fixdep.c13
-rw-r--r--scripts/basic/split-include.c7
-rw-r--r--scripts/echo.c2
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh2
-rwxr-xr-xscripts/mkconfigs3
-rw-r--r--selinux/Config.src2
-rw-r--r--selinux/Kbuild.src2
-rw-r--r--shell/Config.src107
-rw-r--r--shell/Kbuild.src3
-rw-r--r--shell/hush.c2
-rw-r--r--sysklogd/Config.src2
-rw-r--r--sysklogd/Kbuild.src2
-rwxr-xr-xtestsuite/cpio.tests30
-rwxr-xr-xtestsuite/xargs.tests15
-rw-r--r--util-linux/Config.src2
-rw-r--r--util-linux/Kbuild.src2
-rw-r--r--util-linux/losetup.c2
-rw-r--r--util-linux/volume_id/Kbuild.src2
87 files changed, 1033 insertions, 796 deletions
diff --git a/TODO_config_nommu b/TEST_config_nommu
index 911f02f6b..911f02f6b 100644
--- a/TODO_config_nommu
+++ b/TEST_config_nommu
diff --git a/TEST_config_noprintf b/TEST_config_noprintf
index f787e7a14..ba003a1fb 100644
--- a/TEST_config_noprintf
+++ b/TEST_config_noprintf
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Busybox version: 1.17.0.git 3# Busybox version: 1.17.0.git
4# Sun Jun 6 21:38:58 2010 4# Mon Jun 7 13:37:55 2010
5# 5#
6CONFIG_HAVE_DOT_CONFIG=y 6CONFIG_HAVE_DOT_CONFIG=y
7 7
@@ -579,7 +579,7 @@ CONFIG_VOLUMEID=y
579# Miscellaneous Utilities 579# Miscellaneous Utilities
580# 580#
581# CONFIG_ADJTIMEX is not set 581# CONFIG_ADJTIMEX is not set
582# CONFIG_BBCONFIG is not set 582CONFIG_BBCONFIG=y
583# CONFIG_BEEP is not set 583# CONFIG_BEEP is not set
584CONFIG_FEATURE_BEEP_FREQ=0 584CONFIG_FEATURE_BEEP_FREQ=0
585CONFIG_FEATURE_BEEP_LENGTH_MS=0 585CONFIG_FEATURE_BEEP_LENGTH_MS=0
@@ -872,12 +872,6 @@ CONFIG_SV_DEFAULT_SERVICE_DIR=""
872# 872#
873# Shells 873# Shells
874# 874#
875# CONFIG_FEATURE_SH_IS_ASH is not set
876# CONFIG_FEATURE_SH_IS_HUSH is not set
877CONFIG_FEATURE_SH_IS_NONE=y
878# CONFIG_FEATURE_BASH_IS_ASH is not set
879# CONFIG_FEATURE_BASH_IS_HUSH is not set
880CONFIG_FEATURE_BASH_IS_NONE=y
881# CONFIG_ASH is not set 875# CONFIG_ASH is not set
882# CONFIG_ASH_BASH_COMPAT is not set 876# CONFIG_ASH_BASH_COMPAT is not set
883# CONFIG_ASH_JOB_CONTROL is not set 877# CONFIG_ASH_JOB_CONTROL is not set
@@ -904,6 +898,12 @@ CONFIG_FEATURE_BASH_IS_NONE=y
904# CONFIG_HUSH_LOCAL is not set 898# CONFIG_HUSH_LOCAL is not set
905# CONFIG_HUSH_EXPORT_N is not set 899# CONFIG_HUSH_EXPORT_N is not set
906# CONFIG_HUSH_RANDOM_SUPPORT is not set 900# CONFIG_HUSH_RANDOM_SUPPORT is not set
901# CONFIG_FEATURE_SH_IS_ASH is not set
902# CONFIG_FEATURE_SH_IS_HUSH is not set
903CONFIG_FEATURE_SH_IS_NONE=y
904# CONFIG_FEATURE_BASH_IS_ASH is not set
905# CONFIG_FEATURE_BASH_IS_HUSH is not set
906CONFIG_FEATURE_BASH_IS_NONE=y
907# CONFIG_LASH is not set 907# CONFIG_LASH is not set
908# CONFIG_MSH is not set 908# CONFIG_MSH is not set
909# CONFIG_SH_MATH_SUPPORT is not set 909# CONFIG_SH_MATH_SUPPORT is not set
diff --git a/archival/Config.src b/archival/Config.src
index de453bc21..3dbd3aea1 100644
--- a/archival/Config.src
+++ b/archival/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Archival Utilities" 6menu "Archival Utilities"
7 7
8INSERT
9
8config FEATURE_SEAMLESS_XZ 10config FEATURE_SEAMLESS_XZ
9 bool "Make tar, rpm, modprobe etc understand .xz data" 11 bool "Make tar, rpm, modprobe etc understand .xz data"
10 default y 12 default y
diff --git a/archival/Kbuild.src b/archival/Kbuild.src
index 3300ea90f..076e58278 100644
--- a/archival/Kbuild.src
+++ b/archival/Kbuild.src
@@ -7,6 +7,9 @@
7libs-y += libunarchive/ 7libs-y += libunarchive/
8 8
9lib-y:= 9lib-y:=
10
11INSERT
12
10lib-$(CONFIG_AR) += ar.o 13lib-$(CONFIG_AR) += ar.o
11lib-$(CONFIG_CPIO) += cpio.o 14lib-$(CONFIG_CPIO) += cpio.o
12lib-$(CONFIG_DPKG) += dpkg.o 15lib-$(CONFIG_DPKG) += dpkg.o
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index cfbd78420..45a791bba 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -32,14 +32,17 @@ int dpkg_deb_main(int argc, char **argv)
32 ar_archive->filter = filter_accept_list_reassign; 32 ar_archive->filter = filter_accept_list_reassign;
33 33
34#if ENABLE_FEATURE_SEAMLESS_GZ 34#if ENABLE_FEATURE_SEAMLESS_GZ
35 llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz"); 35 llist_add_to(&ar_archive->accept, (char*)"data.tar.gz");
36 llist_add_to(&control_tar_llist, (char*)"control.tar.gz"); 36 llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
37#endif 37#endif
38
39#if ENABLE_FEATURE_SEAMLESS_BZ2 38#if ENABLE_FEATURE_SEAMLESS_BZ2
40 llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2"); 39 llist_add_to(&ar_archive->accept, (char*)"data.tar.bz2");
41 llist_add_to(&control_tar_llist, (char*)"control.tar.bz2"); 40 llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
42#endif 41#endif
42#if ENABLE_FEATURE_SEAMLESS_LZMA
43 llist_add_to(&ar_archive->accept, (char*)"data.tar.lzma");
44 llist_add_to(&control_tar_llist, (char*)"control.tar.lzma");
45#endif
43 46
44 opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX"; 47 opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
45 opt = getopt32(argv, "cefXx"); 48 opt = getopt32(argv, "cefXx");
diff --git a/archival/libunarchive/Kbuild.src b/archival/libunarchive/Kbuild.src
index ed8e85793..81854558b 100644
--- a/archival/libunarchive/Kbuild.src
+++ b/archival/libunarchive/Kbuild.src
@@ -33,6 +33,8 @@ DPKG_FILES:= \
33 get_header_tar.o \ 33 get_header_tar.o \
34 filter_accept_list_reassign.o 34 filter_accept_list_reassign.o
35 35
36INSERT
37
36lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o 38lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
37lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o 39lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
38lib-$(CONFIG_UNLZMA) += decompress_unlzma.o 40lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c
index 815261036..c4ffe7ef8 100644
--- a/archival/libunarchive/data_extract_all.c
+++ b/archival/libunarchive/data_extract_all.c
@@ -152,35 +152,32 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
152 bb_error_msg_and_die("unrecognized file type"); 152 bb_error_msg_and_die("unrecognized file type");
153 } 153 }
154 154
155 if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) { 155 if (!S_ISLNK(file_header->mode)) {
156#if ENABLE_FEATURE_TAR_UNAME_GNAME 156 if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
157 if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
158 uid_t uid = file_header->uid; 157 uid_t uid = file_header->uid;
159 gid_t gid = file_header->gid; 158 gid_t gid = file_header->gid;
160 159#if ENABLE_FEATURE_TAR_UNAME_GNAME
161 if (file_header->tar__uname) { 160 if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
161 if (file_header->tar__uname) {
162//TODO: cache last name/id pair? 162//TODO: cache last name/id pair?
163 struct passwd *pwd = getpwnam(file_header->tar__uname); 163 struct passwd *pwd = getpwnam(file_header->tar__uname);
164 if (pwd) uid = pwd->pw_uid; 164 if (pwd) uid = pwd->pw_uid;
165 } 165 }
166 if (file_header->tar__gname) { 166 if (file_header->tar__gname) {
167 struct group *grp = getgrnam(file_header->tar__gname); 167 struct group *grp = getgrnam(file_header->tar__gname);
168 if (grp) gid = grp->gr_gid; 168 if (grp) gid = grp->gr_gid;
169 }
169 } 170 }
171#endif
170 /* GNU tar 1.15.1 uses chown, not lchown */ 172 /* GNU tar 1.15.1 uses chown, not lchown */
171 chown(file_header->name, uid, gid); 173 chown(file_header->name, uid, gid);
172 } else 174 }
173#endif
174 chown(file_header->name, file_header->uid, file_header->gid);
175 }
176 if (!S_ISLNK(file_header->mode)) {
177 /* uclibc has no lchmod, glibc is even stranger - 175 /* uclibc has no lchmod, glibc is even stranger -
178 * it has lchmod which seems to do nothing! 176 * it has lchmod which seems to do nothing!
179 * so we use chmod... */ 177 * so we use chmod... */
180 if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) { 178 if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) {
181 chmod(file_header->name, file_header->mode); 179 chmod(file_header->name, file_header->mode);
182 } 180 }
183 /* same for utime */
184 if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) { 181 if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
185 struct timeval t[2]; 182 struct timeval t[2];
186 183
diff --git a/console-tools/Config.src b/console-tools/Config.src
index 1a8e2e128..6e3191ada 100644
--- a/console-tools/Config.src
+++ b/console-tools/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Console Utilities" 6menu "Console Utilities"
7 7
8INSERT
9
8config CHVT 10config CHVT
9 bool "chvt" 11 bool "chvt"
10 default y 12 default y
diff --git a/console-tools/Kbuild.src b/console-tools/Kbuild.src
index ad8b8ce77..17f660638 100644
--- a/console-tools/Kbuild.src
+++ b/console-tools/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_CHVT) += chvt.o 10lib-$(CONFIG_CHVT) += chvt.o
9lib-$(CONFIG_FGCONSOLE) += fgconsole.o 11lib-$(CONFIG_FGCONSOLE) += fgconsole.o
10lib-$(CONFIG_CLEAR) += clear.o 12lib-$(CONFIG_CLEAR) += clear.o
diff --git a/console-tools/clear.c b/console-tools/clear.c
index b0c6d65d2..cac716394 100644
--- a/console-tools/clear.c
+++ b/console-tools/clear.c
@@ -5,16 +5,12 @@
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 *
9 */ 8 */
10
11/* no options, no getopt */
12
13#include "libbb.h" 9#include "libbb.h"
14 10
15int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 11int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
16int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 12int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
17{ 13{
18 /* home; clear to the end of screen */ 14 /* home; clear to the end of screen */
19 return printf("\033[H""\033[J") != 6; 15 return full_write1_str("\033[H""\033[J") != 6;
20} 16}
diff --git a/coreutils/Kbuild.src b/coreutils/Kbuild.src
index 57ea7d6c4..1c846a75f 100644
--- a/coreutils/Kbuild.src
+++ b/coreutils/Kbuild.src
@@ -7,6 +7,7 @@
7libs-y += libcoreutils/ 7libs-y += libcoreutils/
8 8
9lib-y:= 9lib-y:=
10
10INSERT 11INSERT
11lib-$(CONFIG_CAL) += cal.o 12lib-$(CONFIG_CAL) += cal.o
12lib-$(CONFIG_CATV) += catv.o 13lib-$(CONFIG_CATV) += catv.o
diff --git a/coreutils/basename.c b/coreutils/basename.c
index d1ad91ba1..b79d561c2 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -5,13 +5,8 @@
5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> 5 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 *
9 */ 8 */
10 9
11/* BB_AUDIT SUSv3 compliant */
12/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
13
14
15/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org) 10/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
16 * 11 *
17 * Changes: 12 * Changes:
@@ -20,6 +15,9 @@
20 * 3) Save some space by using strcmp(). Calling strncmp() here was silly. 15 * 3) Save some space by using strcmp(). Calling strncmp() here was silly.
21 */ 16 */
22 17
18/* BB_AUDIT SUSv3 compliant */
19/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
20
23//kbuild:lib-$(CONFIG_BASENAME) += basename.o 21//kbuild:lib-$(CONFIG_BASENAME) += basename.o
24 22
25//config:config BASENAME 23//config:config BASENAME
@@ -40,7 +38,7 @@ int basename_main(int argc, char **argv)
40 size_t m, n; 38 size_t m, n;
41 char *s; 39 char *s;
42 40
43 if (((unsigned int)(argc-2)) >= 2) { 41 if ((unsigned)(argc-2) >= 2) {
44 bb_show_usage(); 42 bb_show_usage();
45 } 43 }
46 44
@@ -50,7 +48,7 @@ int basename_main(int argc, char **argv)
50 m = strlen(s); 48 m = strlen(s);
51 if (*++argv) { 49 if (*++argv) {
52 n = strlen(*argv); 50 n = strlen(*argv);
53 if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { 51 if ((m > n) && (strcmp(s+m-n, *argv) == 0)) {
54 m -= n; 52 m -= n;
55 /*s[m] = '\0'; - redundant */ 53 /*s[m] = '\0'; - redundant */
56 } 54 }
diff --git a/coreutils/date.c b/coreutils/date.c
index 3d78a5336..c737f09f3 100644
--- a/coreutils/date.c
+++ b/coreutils/date.c
@@ -93,6 +93,9 @@
93//config: MMDDhhmm[[YY]YY][.ss] format. 93//config: MMDDhhmm[[YY]YY][.ss] format.
94 94
95#include "libbb.h" 95#include "libbb.h"
96#if ENABLE_FEATURE_DATE_NANO
97# include <sys/syscall.h>
98#endif
96 99
97enum { 100enum {
98 OPT_RFC2822 = (1 << 0), /* R */ 101 OPT_RFC2822 = (1 << 0), /* R */
@@ -204,17 +207,15 @@ int date_main(int argc UNUSED_PARAM, char **argv)
204 xstat(filename, &statbuf); 207 xstat(filename, &statbuf);
205 ts.tv_sec = statbuf.st_mtime; 208 ts.tv_sec = statbuf.st_mtime;
206#if ENABLE_FEATURE_DATE_NANO 209#if ENABLE_FEATURE_DATE_NANO
207# if defined __GLIBC__ && !defined __UCLIBC__
208 ts.tv_nsec = statbuf.st_mtim.tv_nsec; 210 ts.tv_nsec = statbuf.st_mtim.tv_nsec;
209# else
210 ts.tv_nsec = statbuf.st_mtimensec;
211# endif
212#endif 211#endif
213 } else { 212 } else {
214#if ENABLE_FEATURE_DATE_NANO 213#if ENABLE_FEATURE_DATE_NANO
215 clock_gettime(CLOCK_REALTIME, &ts); 214 /* libc has incredibly messy way of doing this,
215 * typically requiring -lrt. We just skip all this mess */
216 syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
216#else 217#else
217 time(&ts.tv_nsec); 218 time(&ts.tv_sec);
218#endif 219#endif
219 } 220 }
220 localtime_r(&ts.tv_sec, &tm_time); 221 localtime_r(&ts.tv_sec, &tm_time);
diff --git a/coreutils/libcoreutils/Kbuild.src b/coreutils/libcoreutils/Kbuild.src
index 755d01f86..981b60628 100644
--- a/coreutils/libcoreutils/Kbuild.src
+++ b/coreutils/libcoreutils/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball. 5# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_MKFIFO) += getopt_mk_fifo_nod.o 10lib-$(CONFIG_MKFIFO) += getopt_mk_fifo_nod.o
9lib-$(CONFIG_MKNOD) += getopt_mk_fifo_nod.o 11lib-$(CONFIG_MKNOD) += getopt_mk_fifo_nod.o
10lib-$(CONFIG_INSTALL) += cp_mv_stat.o 12lib-$(CONFIG_INSTALL) += cp_mv_stat.o
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 57f1f145a..e7c24e642 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -216,10 +216,7 @@ static void FAST_FUNC print_stat(char *pformat, const char m,
216 char *linkname = xmalloc_readlink_or_warn(filename); 216 char *linkname = xmalloc_readlink_or_warn(filename);
217 if (linkname == NULL) 217 if (linkname == NULL)
218 return; 218 return;
219 /*printf("\"%s\" -> \"%s\"", filename, linkname); */ 219 printf("'%s' -> '%s'", filename, linkname);
220 printf(pformat, filename);
221 printf(" -> ");
222 printf(pformat, linkname);
223 free(linkname); 220 free(linkname);
224 } else { 221 } else {
225 printf(pformat, filename); 222 printf(pformat, filename);
@@ -320,24 +317,28 @@ static void print_it(const char *masterformat,
320 317
321 b = format; 318 b = format;
322 while (b) { 319 while (b) {
320 /* Each iteration finds next %spec,
321 * prints preceding string and handles found %spec
322 */
323 size_t len; 323 size_t len;
324 char *p = strchr(b, '%'); 324 char *p = strchr(b, '%');
325 if (!p) { 325 if (!p) {
326 /* coreutils 6.3 always prints <cr> at the end */ 326 /* coreutils 6.3 always prints newline at the end */
327 /*fputs(b, stdout);*/ 327 /*fputs(b, stdout);*/
328 puts(b); 328 puts(b);
329 break; 329 break;
330 } 330 }
331 *p++ = '\0';
332 fputs(b, stdout);
333 331
334 /* dest = "%<modifiers>" */ 332 /* dest = "%<modifiers>" */
335 len = strspn(p, "#-+.I 0123456789"); 333 len = 1 + strspn(p + 1, "#-+.I 0123456789");
336 dest[0] = '%'; 334 memcpy(dest, p, len);
337 memcpy(dest + 1, p, len); 335 dest[len] = '\0';
338 dest[1 + len] = '\0';
339 p += len;
340 336
337 /* print preceding string */
338 *p = '\0';
339 fputs(b, stdout);
340
341 p += len;
341 b = p + 1; 342 b = p + 1;
342 switch (*p) { 343 switch (*p) {
343 case '\0': 344 case '\0':
@@ -508,7 +509,7 @@ static bool do_stat(const char *filename, const char *format)
508 } else { 509 } else {
509 if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) { 510 if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
510 format = 511 format =
511 " File: \"%N\"\n" 512 " File: %N\n"
512 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 513 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
513 "Device: %Dh/%dd\tInode: %-10i Links: %-5h" 514 "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
514 " Device type: %t,%T\n" 515 " Device type: %t,%T\n"
@@ -516,7 +517,7 @@ static bool do_stat(const char *filename, const char *format)
516 "Access: %x\n" "Modify: %y\n" "Change: %z\n"; 517 "Access: %x\n" "Modify: %y\n" "Change: %z\n";
517 } else { 518 } else {
518 format = 519 format =
519 " File: \"%N\"\n" 520 " File: %N\n"
520 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 521 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
521 "Device: %Dh/%dd\tInode: %-10i Links: %h\n" 522 "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
522 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" 523 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
@@ -531,14 +532,14 @@ static bool do_stat(const char *filename, const char *format)
531 } else { 532 } else {
532 if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) { 533 if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
533 format = (option_mask32 & OPT_SELINUX ? 534 format = (option_mask32 & OPT_SELINUX ?
534 " File: \"%N\"\n" 535 " File: %N\n"
535 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 536 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
536 "Device: %Dh/%dd\tInode: %-10i Links: %-5h" 537 "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
537 " Device type: %t,%T\n" 538 " Device type: %t,%T\n"
538 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" 539 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
539 " S_Context: %C\n" 540 " S_Context: %C\n"
540 "Access: %x\n" "Modify: %y\n" "Change: %z\n": 541 "Access: %x\n" "Modify: %y\n" "Change: %z\n":
541 " File: \"%N\"\n" 542 " File: %N\n"
542 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 543 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
543 "Device: %Dh/%dd\tInode: %-10i Links: %-5h" 544 "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
544 " Device type: %t,%T\n" 545 " Device type: %t,%T\n"
@@ -546,13 +547,13 @@ static bool do_stat(const char *filename, const char *format)
546 "Access: %x\n" "Modify: %y\n" "Change: %z\n"); 547 "Access: %x\n" "Modify: %y\n" "Change: %z\n");
547 } else { 548 } else {
548 format = (option_mask32 & OPT_SELINUX ? 549 format = (option_mask32 & OPT_SELINUX ?
549 " File: \"%N\"\n" 550 " File: %N\n"
550 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 551 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
551 "Device: %Dh/%dd\tInode: %-10i Links: %h\n" 552 "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
552 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" 553 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
553 "S_Context: %C\n" 554 "S_Context: %C\n"
554 "Access: %x\n" "Modify: %y\n" "Change: %z\n": 555 "Access: %x\n" "Modify: %y\n" "Change: %z\n":
555 " File: \"%N\"\n" 556 " File: %N\n"
556 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n" 557 " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
557 "Device: %Dh/%dd\tInode: %-10i Links: %h\n" 558 "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
558 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n" 559 "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
@@ -601,9 +602,9 @@ static bool do_stat(const char *filename, const char *format)
601 if (S_ISLNK(statbuf.st_mode)) 602 if (S_ISLNK(statbuf.st_mode))
602 linkname = xmalloc_readlink_or_warn(filename); 603 linkname = xmalloc_readlink_or_warn(filename);
603 if (linkname) 604 if (linkname)
604 printf(" File: \"%s\" -> \"%s\"\n", filename, linkname); 605 printf(" File: '%s' -> '%s'\n", filename, linkname);
605 else 606 else
606 printf(" File: \"%s\"\n", filename); 607 printf(" File: '%s'\n", filename);
607 608
608 printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n" 609 printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n"
609 "Device: %llxh/%llud\tInode: %-10llu Links: %-5lu", 610 "Device: %llxh/%llud\tInode: %-10llu Links: %-5lu",
diff --git a/debianutils/Config.src b/debianutils/Config.src
index 9bce0498c..838d8f00c 100644
--- a/debianutils/Config.src
+++ b/debianutils/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Debian Utilities" 6menu "Debian Utilities"
7 7
8INSERT
9
8config MKTEMP 10config MKTEMP
9 bool "mktemp" 11 bool "mktemp"
10 default y 12 default y
diff --git a/debianutils/Kbuild.src b/debianutils/Kbuild.src
index bcf6126ad..da34e4e4f 100644
--- a/debianutils/Kbuild.src
+++ b/debianutils/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_MKTEMP) += mktemp.o 10lib-$(CONFIG_MKTEMP) += mktemp.o
9lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o 11lib-$(CONFIG_PIPE_PROGRESS) += pipe_progress.o
10lib-$(CONFIG_RUN_PARTS) += run_parts.o 12lib-$(CONFIG_RUN_PARTS) += run_parts.o
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 0dcb1e826..c40211476 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -39,23 +39,20 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
39{ 39{
40 const char *path; 40 const char *path;
41 char *chp; 41 char *chp;
42 unsigned opt; 42 unsigned opts;
43 43
44 path = getenv("TMPDIR");
45 if (!path || path[0] == '\0')
46 path = "/tmp";
47
48 /* -q and -t are ignored */
44 opt_complementary = "?1"; /* 1 argument max */ 49 opt_complementary = "?1"; /* 1 argument max */
45 opt = getopt32(argv, "dqtp:", &path); 50 opts = getopt32(argv, "dqtp:", &path);
46 chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
47 51
48 if (opt & (4|8)) { /* -t and/or -p */ 52 chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
49 const char *dir = getenv("TMPDIR"); 53 chp = concat_path_file(path, chp);
50 if (dir && *dir != '\0')
51 path = dir;
52 else if (!(opt & 8)) /* no -p */
53 path = "/tmp/";
54 /* else path comes from -p DIR */
55 chp = concat_path_file(path, chp);
56 }
57 54
58 if (opt & 1) { /* -d */ 55 if (opts & 1) { /* -d */
59 if (mkdtemp(chp) == NULL) 56 if (mkdtemp(chp) == NULL)
60 return EXIT_FAILURE; 57 return EXIT_FAILURE;
61 } else { 58 } else {
diff --git a/e2fsprogs/Config.src b/e2fsprogs/Config.src
index e331ee5ef..f362c6b0a 100644
--- a/e2fsprogs/Config.src
+++ b/e2fsprogs/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Linux Ext2 FS Progs" 6menu "Linux Ext2 FS Progs"
7 7
8INSERT
9
8config CHATTR 10config CHATTR
9 bool "chattr" 11 bool "chattr"
10 default y 12 default y
diff --git a/e2fsprogs/Kbuild.src b/e2fsprogs/Kbuild.src
index 0fdc9d215..31c271238 100644
--- a/e2fsprogs/Kbuild.src
+++ b/e2fsprogs/Kbuild.src
@@ -6,6 +6,8 @@
6 6
7lib-y:= 7lib-y:=
8 8
9INSERT
10
9lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o 11lib-$(CONFIG_CHATTR) += chattr.o e2fs_lib.o
10lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o 12lib-$(CONFIG_LSATTR) += lsattr.o e2fs_lib.o
11 13
diff --git a/e2fsprogs/old_e2fsprogs/Config.src b/e2fsprogs/old_e2fsprogs/Config.src
index 5990f556c..bbec08e7e 100644
--- a/e2fsprogs/old_e2fsprogs/Config.src
+++ b/e2fsprogs/old_e2fsprogs/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Linux Ext2 FS Progs" 6menu "Linux Ext2 FS Progs"
7 7
8INSERT
9
8config CHATTR 10config CHATTR
9 bool "chattr" 11 bool "chattr"
10 default n 12 default n
diff --git a/e2fsprogs/old_e2fsprogs/Kbuild.src b/e2fsprogs/old_e2fsprogs/Kbuild.src
index b05bb92e1..07a09ca3d 100644
--- a/e2fsprogs/old_e2fsprogs/Kbuild.src
+++ b/e2fsprogs/old_e2fsprogs/Kbuild.src
@@ -6,6 +6,8 @@
6 6
7lib-y:= 7lib-y:=
8 8
9INSERT
10
9lib-$(CONFIG_CHATTR) += chattr.o 11lib-$(CONFIG_CHATTR) += chattr.o
10lib-$(CONFIG_E2FSCK) += e2fsck.o util.o 12lib-$(CONFIG_E2FSCK) += e2fsck.o util.o
11lib-$(CONFIG_FSCK) += fsck.o util.o 13lib-$(CONFIG_FSCK) += fsck.o util.o
diff --git a/e2fsprogs/old_e2fsprogs/blkid/Kbuild.src b/e2fsprogs/old_e2fsprogs/blkid/Kbuild.src
index ddcfdfd9a..bae77fe63 100644
--- a/e2fsprogs/old_e2fsprogs/blkid/Kbuild.src
+++ b/e2fsprogs/old_e2fsprogs/blkid/Kbuild.src
@@ -10,6 +10,9 @@ NEEDED-$(CONFIG_MKE2FS) = y
10NEEDED-$(CONFIG_TUNE2FS) = y 10NEEDED-$(CONFIG_TUNE2FS) = y
11 11
12lib-y:= 12lib-y:=
13
14INSERT
15
13lib-$(NEEDED-y) += cache.o dev.o devname.o devno.o blkid_getsize.o \ 16lib-$(NEEDED-y) += cache.o dev.o devname.o devno.o blkid_getsize.o \
14 probe.o read.o resolve.o save.o tag.o list.o 17 probe.o read.o resolve.o save.o tag.o list.o
15 18
diff --git a/e2fsprogs/old_e2fsprogs/e2p/Kbuild.src b/e2fsprogs/old_e2fsprogs/e2p/Kbuild.src
index c0ff824e3..194870788 100644
--- a/e2fsprogs/old_e2fsprogs/e2p/Kbuild.src
+++ b/e2fsprogs/old_e2fsprogs/e2p/Kbuild.src
@@ -10,6 +10,9 @@ NEEDED-$(CONFIG_MKE2FS) = y
10NEEDED-$(CONFIG_TUNE2FS) = y 10NEEDED-$(CONFIG_TUNE2FS) = y
11 11
12lib-y:= 12lib-y:=
13
14INSERT
15
13lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \ 16lib-$(NEEDED-y) += fgetsetflags.o fgetsetversion.o pf.o iod.o mntopts.o \
14 feature.o ls.o uuid.o pe.o ostype.o ps.o hashstr.o \ 17 feature.o ls.o uuid.o pe.o ostype.o ps.o hashstr.o \
15 parse_num.o 18 parse_num.o
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src b/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src
index 185887a44..8ca65ee90 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/Kbuild.src
@@ -10,6 +10,9 @@ NEEDED-$(CONFIG_MKE2FS) = y
10NEEDED-$(CONFIG_TUNE2FS) = y 10NEEDED-$(CONFIG_TUNE2FS) = y
11 11
12lib-y:= 12lib-y:=
13
14INSERT
15
13lib-$(NEEDED-y) += gen_bitmap.o bitops.o ismounted.o mkjournal.o unix_io.o \ 16lib-$(NEEDED-y) += gen_bitmap.o bitops.o ismounted.o mkjournal.o unix_io.o \
14 rw_bitmaps.o initialize.o bitmaps.o block.o \ 17 rw_bitmaps.o initialize.o bitmaps.o block.o \
15 ind_block.o inode.o freefs.o alloc_stats.o closefs.o \ 18 ind_block.o inode.o freefs.o alloc_stats.o closefs.o \
diff --git a/e2fsprogs/old_e2fsprogs/uuid/Kbuild.src b/e2fsprogs/old_e2fsprogs/uuid/Kbuild.src
index dde981840..9454faba7 100644
--- a/e2fsprogs/old_e2fsprogs/uuid/Kbuild.src
+++ b/e2fsprogs/old_e2fsprogs/uuid/Kbuild.src
@@ -10,5 +10,7 @@ NEEDED-$(CONFIG_MKE2FS) = y
10NEEDED-$(CONFIG_TUNE2FS) = y 10NEEDED-$(CONFIG_TUNE2FS) = y
11 11
12lib-y:= 12lib-y:=
13
14INSERT
13lib-$(NEEDED-y) += compare.o gen_uuid.o pack.o parse.o unpack.o unparse.o \ 15lib-$(NEEDED-y) += compare.o gen_uuid.o pack.o parse.o unpack.o unparse.o \
14 uuid_time.o 16 uuid_time.o
diff --git a/editors/Config.src b/editors/Config.src
index 6cf21919c..fc824ccd5 100644
--- a/editors/Config.src
+++ b/editors/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Editors" 6menu "Editors"
7 7
8INSERT
9
8config AWK 10config AWK
9 bool "awk" 11 bool "awk"
10 default y 12 default y
diff --git a/editors/Kbuild.src b/editors/Kbuild.src
index 76302aa76..9d4b9d053 100644
--- a/editors/Kbuild.src
+++ b/editors/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_AWK) += awk.o 10lib-$(CONFIG_AWK) += awk.o
9lib-$(CONFIG_CMP) += cmp.o 11lib-$(CONFIG_CMP) += cmp.o
10lib-$(CONFIG_DIFF) += diff.o 12lib-$(CONFIG_DIFF) += diff.o
diff --git a/editors/sed.c b/editors/sed.c
index a5ef400fc..28f0c7318 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1365,6 +1365,8 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
1365 1365
1366 /* Set permissions/owner of output file */ 1366 /* Set permissions/owner of output file */
1367 fstat(fileno(file), &statbuf); 1367 fstat(fileno(file), &statbuf);
1368 /* chmod'ing AFTER chown would preserve suid/sgid bits,
1369 * but GNU sed 4.2.1 does not preserve them either */
1368 fchmod(nonstdoutfd, statbuf.st_mode); 1370 fchmod(nonstdoutfd, statbuf.st_mode);
1369 fchown(nonstdoutfd, statbuf.st_uid, statbuf.st_gid); 1371 fchown(nonstdoutfd, statbuf.st_uid, statbuf.st_gid);
1370 add_input_file(file); 1372 add_input_file(file);
diff --git a/findutils/find.c b/findutils/find.c
index ca630b6c5..297081489 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -53,8 +53,10 @@
53 * diff -u /tmp/std_find /tmp/bb_find && echo Identical 53 * diff -u /tmp/std_find /tmp/bb_find && echo Identical
54 */ 54 */
55 55
56//applet:IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find))
57
56//kbuild:lib-$(CONFIG_FIND) += find.o 58//kbuild:lib-$(CONFIG_FIND) += find.o
57//config: 59
58//config:config FIND 60//config:config FIND
59//config: bool "find" 61//config: bool "find"
60//config: default y 62//config: default y
@@ -1044,6 +1046,92 @@ static action*** parse_params(char **argv)
1044#undef ALLOC_ACTION 1046#undef ALLOC_ACTION
1045} 1047}
1046 1048
1049//usage:#define find_trivial_usage
1050//usage: "[PATH]... [EXPRESSION]"
1051//usage:#define find_full_usage "\n\n"
1052//usage: "Search for files. The default PATH is the current directory,\n"
1053//usage: "default EXPRESSION is '-print'\n"
1054//usage: "\nEXPRESSION may consist of:"
1055//usage: "\n -follow Follow symlinks"
1056//usage: IF_FEATURE_FIND_XDEV(
1057//usage: "\n -xdev Don't descend directories on other filesystems"
1058//usage: )
1059//usage: IF_FEATURE_FIND_MAXDEPTH(
1060//usage: "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies"
1061//usage: "\n tests/actions to command line arguments only"
1062//usage: )
1063//usage: "\n -mindepth N Don't act on first N levels"
1064//usage: "\n -name PATTERN File name (w/o directory name) matches PATTERN"
1065//usage: "\n -iname PATTERN Case insensitive -name"
1066//usage: IF_FEATURE_FIND_PATH(
1067//usage: "\n -path PATTERN Path matches PATTERN"
1068//usage: )
1069//usage: IF_FEATURE_FIND_REGEX(
1070//usage: "\n -regex PATTERN Path matches regex PATTERN"
1071//usage: )
1072//usage: IF_FEATURE_FIND_TYPE(
1073//usage: "\n -type X File type is X (X is one of: f,d,l,b,c,...)"
1074//usage: )
1075//usage: IF_FEATURE_FIND_PERM(
1076//usage: "\n -perm NNN Permissions match any of (+NNN), all of (-NNN),"
1077//usage: "\n or exactly NNN"
1078//usage: )
1079//usage: IF_FEATURE_FIND_MTIME(
1080//usage: "\n -mtime DAYS Modified time is greater than (+N), less than (-N),"
1081//usage: "\n or exactly N days"
1082//usage: )
1083//usage: IF_FEATURE_FIND_MMIN(
1084//usage: "\n -mmin MINS Modified time is greater than (+N), less than (-N),"
1085//usage: "\n or exactly N minutes"
1086//usage: )
1087//usage: IF_FEATURE_FIND_NEWER(
1088//usage: "\n -newer FILE Modified time is more recent than FILE's"
1089//usage: )
1090//usage: IF_FEATURE_FIND_INUM(
1091//usage: "\n -inum N File has inode number N"
1092//usage: )
1093//usage: IF_FEATURE_FIND_USER(
1094//usage: "\n -user NAME File is owned by user NAME (numeric user ID allowed)"
1095//usage: )
1096//usage: IF_FEATURE_FIND_GROUP(
1097//usage: "\n -group NAME File belongs to group NAME (numeric group ID allowed)"
1098//usage: )
1099//usage: IF_FEATURE_FIND_DEPTH(
1100//usage: "\n -depth Process directory name after traversing it"
1101//usage: )
1102//usage: IF_FEATURE_FIND_SIZE(
1103//usage: "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))"
1104//usage: "\n +/-N: file size is bigger/smaller than N"
1105//usage: )
1106//usage: IF_FEATURE_FIND_LINKS(
1107//usage: "\n -links N Number of links is greater than (+N), less than (-N),"
1108//usage: "\n or exactly N"
1109//usage: )
1110//usage: "\n -print Print (default and assumed)"
1111//usage: IF_FEATURE_FIND_PRINT0(
1112//usage: "\n -print0 Delimit output with null characters rather than"
1113//usage: "\n newlines"
1114//usage: )
1115//usage: IF_FEATURE_FIND_CONTEXT(
1116//usage: "\n -context File has specified security context"
1117//usage: )
1118//usage: IF_FEATURE_FIND_EXEC(
1119//usage: "\n -exec CMD ARG ; Run CMD with all instances of {} replaced by the"
1120//usage: "\n matching files"
1121//usage: )
1122//usage: IF_FEATURE_FIND_PRUNE(
1123//usage: "\n -prune Stop traversing current subtree"
1124//usage: )
1125//usage: IF_FEATURE_FIND_DELETE(
1126//usage: "\n -delete Delete files, turns on -depth option"
1127//usage: )
1128//usage: IF_FEATURE_FIND_PAREN(
1129//usage: "\n (EXPR) Group an expression"
1130//usage: )
1131//usage:
1132//usage:#define find_example_usage
1133//usage: "$ find / -name passwd\n"
1134//usage: "/etc/passwd\n"
1047 1135
1048int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1136int find_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1049int find_main(int argc UNUSED_PARAM, char **argv) 1137int find_main(int argc UNUSED_PARAM, char **argv)
diff --git a/findutils/grep.c b/findutils/grep.c
index fedf12d8a..9eb5e5a1b 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -14,13 +14,16 @@
14 * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> - 14 * 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> -
15 * correction "-e pattern1 -e pattern2" logic and more optimizations. 15 * correction "-e pattern1 -e pattern2" logic and more optimizations.
16 * precompiled regex 16 * precompiled regex
17 */ 17 *
18/*
19 * (C) 2006 Jac Goudsmit added -o option 18 * (C) 2006 Jac Goudsmit added -o option
20 */ 19 */
21 20
21//applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP))
22//applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep))
23//applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep))
24
22//kbuild:lib-$(CONFIG_GREP) += grep.o 25//kbuild:lib-$(CONFIG_GREP) += grep.o
23//config: 26
24//config:config GREP 27//config:config GREP
25//config: bool "grep" 28//config: bool "grep"
26//config: default y 29//config: default y
@@ -57,17 +60,67 @@
57#include "libbb.h" 60#include "libbb.h"
58#include "xregex.h" 61#include "xregex.h"
59 62
63
60/* options */ 64/* options */
65//usage:#define grep_trivial_usage
66//usage: "[-HhnlLoqvsriw"
67//usage: "F"
68//usage: IF_FEATURE_GREP_EGREP_ALIAS("E")
69//usage: IF_EXTRA_COMPAT("z")
70//usage: "] [-m N] "
71//usage: IF_FEATURE_GREP_CONTEXT("[-A/B/C N] ")
72//usage: "PATTERN/-e PATTERN.../-f FILE [FILE]..."
73//usage:#define grep_full_usage "\n\n"
74//usage: "Search for PATTERN in FILEs (or stdin)\n"
75//usage: "\nOptions:"
76//usage: "\n -H Add 'filename:' prefix"
77//usage: "\n -h Do not add 'filename:' prefix"
78//usage: "\n -n Add 'line_no:' prefix"
79//usage: "\n -l Show only names of files that match"
80//usage: "\n -L Show only names of files that don't match"
81//usage: "\n -c Show only count of matching lines"
82//usage: "\n -o Show only the matching part of line"
83//usage: "\n -q Quiet. Return 0 if PATTERN is found, 1 otherwise"
84//usage: "\n -v Select non-matching lines"
85//usage: "\n -s Suppress open and read errors"
86//usage: "\n -r Recurse"
87//usage: "\n -i Ignore case"
88//usage: "\n -w Match whole words only"
89//usage: "\n -F PATTERN is a literal (not regexp)"
90//usage: IF_FEATURE_GREP_EGREP_ALIAS(
91//usage: "\n -E PATTERN is an extended regexp"
92//usage: )
93//usage: IF_EXTRA_COMPAT(
94//usage: "\n -z Input is NUL terminated"
95//usage: )
96//usage: "\n -m N Match up to N times per file"
97//usage: IF_FEATURE_GREP_CONTEXT(
98//usage: "\n -A N Print N lines of trailing context"
99//usage: "\n -B N Print N lines of leading context"
100//usage: "\n -C N Same as '-A N -B N'"
101//usage: )
102//usage: "\n -e PTRN Pattern to match"
103//usage: "\n -f FILE Read pattern from file"
104//usage:
105//usage:#define grep_example_usage
106//usage: "$ grep root /etc/passwd\n"
107//usage: "root:x:0:0:root:/root:/bin/bash\n"
108//usage: "$ grep ^[rR]oo. /etc/passwd\n"
109//usage: "root:x:0:0:root:/root:/bin/bash\n"
110//usage:
111//usage:#define egrep_trivial_usage NOUSAGE_STR
112//usage:#define egrep_full_usage ""
113//usage:#define fgrep_trivial_usage NOUSAGE_STR
114//usage:#define fgrep_full_usage ""
115
61#define OPTSTR_GREP \ 116#define OPTSTR_GREP \
62 "lnqvscFiHhe:f:Lorm:w" \ 117 "lnqvscFiHhe:f:Lorm:w" \
63 IF_FEATURE_GREP_CONTEXT("A:B:C:") \ 118 IF_FEATURE_GREP_CONTEXT("A:B:C:") \
64 IF_FEATURE_GREP_EGREP_ALIAS("E") \ 119 IF_FEATURE_GREP_EGREP_ALIAS("E") \
65 IF_EXTRA_COMPAT("z") \ 120 IF_EXTRA_COMPAT("z") \
66 "aI" 121 "aI"
67
68/* ignored: -a "assume all files to be text" */ 122/* ignored: -a "assume all files to be text" */
69/* ignored: -I "assume binary files have no matches" */ 123/* ignored: -I "assume binary files have no matches" */
70
71enum { 124enum {
72 OPTBIT_l, /* list matched file names only */ 125 OPTBIT_l, /* list matched file names only */
73 OPTBIT_n, /* print line# */ 126 OPTBIT_n, /* print line# */
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 9133b8f6c..46a62cbf1 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -1,7 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Mini xargs implementation for busybox 3 * Mini xargs implementation for busybox
4 * Options are supported: "-prtx -n max_arg -s max_chars -e[ouf_str]"
5 * 4 *
6 * (C) 2002,2003 by Vladimir Oleynik <dzo@simtreas.ru> 5 * (C) 2002,2003 by Vladimir Oleynik <dzo@simtreas.ru>
7 * 6 *
@@ -14,11 +13,12 @@
14 * 13 *
15 * xargs is described in the Single Unix Specification v3 at 14 * xargs is described in the Single Unix Specification v3 at
16 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html 15 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html
17 *
18 */ 16 */
19 17
18//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs))
19
20//kbuild:lib-$(CONFIG_XARGS) += xargs.o 20//kbuild:lib-$(CONFIG_XARGS) += xargs.o
21//config: 21
22//config:config XARGS 22//config:config XARGS
23//config: bool "xargs" 23//config: bool "xargs"
24//config: default y 24//config: default y
@@ -59,10 +59,6 @@
59//config: are not special. 59//config: are not special.
60 60
61#include "libbb.h" 61#include "libbb.h"
62
63/* This is a NOEXEC applet. Be very careful! */
64
65
66/* COMPAT: SYSV version defaults size (and has a max value of) to 470. 62/* COMPAT: SYSV version defaults size (and has a max value of) to 470.
67 We try to make it as large as possible. */ 63 We try to make it as large as possible. */
68#if !defined(ARG_MAX) && defined(_SC_ARG_MAX) 64#if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
@@ -72,6 +68,12 @@
72# define ARG_MAX 470 68# define ARG_MAX 470
73#endif 69#endif
74 70
71/* This is a NOEXEC applet. Be very careful! */
72
73
74//#define dbg_msg(...) bb_error_msg(__VA_ARGS__)
75#define dbg_msg(...) ((void)0)
76
75 77
76#ifdef TEST 78#ifdef TEST
77# ifndef ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 79# ifndef ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION
@@ -88,26 +90,36 @@
88# endif 90# endif
89#endif 91#endif
90 92
93
94struct globals {
95 char **args;
96 const char *eof_str;
97 int idx;
98} FIX_ALIASING;
99#define G (*(struct globals*)&bb_common_bufsiz1)
100#define INIT_G() do { } while (0)
101
102
91/* 103/*
92 This function has special algorithm. 104 * This function has special algorithm.
93 Don't use fork and include to main! 105 * Don't use fork and include to main!
94*/ 106 */
95static int xargs_exec(char **args) 107static int xargs_exec(void)
96{ 108{
97 int status; 109 int status;
98 110
99 status = spawn_and_wait(args); 111 status = spawn_and_wait(G.args);
100 if (status < 0) { 112 if (status < 0) {
101 bb_simple_perror_msg(args[0]); 113 bb_simple_perror_msg(G.args[0]);
102 return errno == ENOENT ? 127 : 126; 114 return errno == ENOENT ? 127 : 126;
103 } 115 }
104 if (status == 255) { 116 if (status == 255) {
105 bb_error_msg("%s: exited with status 255; aborting", args[0]); 117 bb_error_msg("%s: exited with status 255; aborting", G.args[0]);
106 return 124; 118 return 124;
107 } 119 }
108 if (status >= 0x180) { 120 if (status >= 0x180) {
109 bb_error_msg("%s: terminated by signal %d", 121 bb_error_msg("%s: terminated by signal %d",
110 args[0], status - 0x180); 122 G.args[0], status - 0x180);
111 return 125; 123 return 125;
112 } 124 }
113 if (status) 125 if (status)
@@ -115,75 +127,75 @@ static int xargs_exec(char **args)
115 return 0; 127 return 0;
116} 128}
117 129
130/* In POSIX/C locale isspace is only these chars: "\t\n\v\f\r" and space.
131 * "\t\n\v\f\r" happen to have ASCII codes 9,10,11,12,13.
132 */
133#define ISSPACE(a) ({ unsigned char xargs__isspace = (a) - 9; xargs__isspace == (' ' - 9) || xargs__isspace <= (13 - 9); })
118 134
119typedef struct xlist_t { 135static void store_param(char *s)
120 struct xlist_t *link; 136{
121 size_t length; 137 /* Grow by 256 elements at once */
122 char xstr[1]; 138 if (!(G.idx & 0xff)) { /* G.idx == N*256 */
123} xlist_t; 139 /* Enlarge, make G.args[(N+1)*256 - 1] last valid idx */
124 140 G.args = xrealloc(G.args, sizeof(G.args[0]) * (G.idx + 0x100));
125static smallint eof_stdin_detected; 141 }
142 G.args[G.idx++] = s;
143}
126 144
127#define ISBLANK(c) ((c) == ' ' || (c) == '\t') 145/* process[0]_stdin:
128#define ISSPACE(c) (ISBLANK(c) || (c) == '\n' || (c) == '\r' \ 146 * Read characters into buf[n_max_chars+1], and when parameter delimiter
129 || (c) == '\f' || (c) == '\v') 147 * is seen, store the address of a new parameter to args[].
148 * If reading discovers that last chars do not form the complete
149 * parameter, the pointer to the first such "tail character" is returned.
150 * (buf has extra byte at the end to accomodate terminating NUL
151 * of "tail characters" string).
152 * Otherwise, the returned pointer points to NUL byte.
153 * On entry, buf[] may contain some "seed chars" which are to become
154 * the beginning of the first parameter.
155 */
130 156
131#if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES 157#if ENABLE_FEATURE_XARGS_SUPPORT_QUOTES
132static xlist_t *process_stdin(xlist_t *list_arg, 158static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf)
133 const char *eof_str, size_t mc, char *buf)
134{ 159{
135#define NORM 0 160#define NORM 0
136#define QUOTE 1 161#define QUOTE 1
137#define BACKSLASH 2 162#define BACKSLASH 2
138#define SPACE 4 163#define SPACE 4
139 164 char q = '\0'; /* quote char */
140 char *s = NULL; /* start word */
141 char *p = NULL; /* pointer to end word */
142 char q = '\0'; /* quote char */
143 char state = NORM; 165 char state = NORM;
144 char eof_str_detected = 0; 166 char *s = buf; /* start of the word */
145 size_t line_l = 0; /* size loaded args line */ 167 char *p = s + strlen(buf); /* end of the word */
146 int c; /* current char */
147 xlist_t *cur;
148 xlist_t *prev;
149 168
150 prev = cur = list_arg; 169 buf += n_max_chars; /* past buffer's end */
151 while (1) { 170
152 if (!cur) break; 171 /* "goto ret" is used instead of "break" to make control flow
153 prev = cur; 172 * more obvious: */
154 line_l += cur->length;
155 cur = cur->link;
156 }
157 173
158 while (!eof_stdin_detected) { 174 while (1) {
159 c = getchar(); 175 int c = getchar();
160 if (c == EOF) { 176 if (c == EOF) {
161 eof_stdin_detected = 1; 177 if (p != s)
162 if (s) 178 goto close_word;
163 goto unexpected_eof; 179 goto ret;
164 break;
165 } 180 }
166 if (eof_str_detected)
167 continue;
168 if (state == BACKSLASH) { 181 if (state == BACKSLASH) {
169 state = NORM; 182 state = NORM;
170 goto set; 183 goto set;
171 } else if (state == QUOTE) { 184 }
185 if (state == QUOTE) {
172 if (c != q) 186 if (c != q)
173 goto set; 187 goto set;
174 q = '\0'; 188 q = '\0';
175 state = NORM; 189 state = NORM;
176 } else { /* if (state == NORM) */ 190 } else { /* if (state == NORM) */
177 if (ISSPACE(c)) { 191 if (ISSPACE(c)) {
178 if (s) { 192 if (p != s) {
179 unexpected_eof: 193 close_word:
180 state = SPACE; 194 state = SPACE;
181 c = '\0'; 195 c = '\0';
182 goto set; 196 goto set;
183 } 197 }
184 } else { 198 } else {
185 if (s == NULL)
186 s = p = buf;
187 if (c == '\\') { 199 if (c == '\\') {
188 state = BACKSLASH; 200 state = BACKSLASH;
189 } else if (c == '\'' || c == '"') { 201 } else if (c == '\'' || c == '"') {
@@ -191,8 +203,6 @@ static xlist_t *process_stdin(xlist_t *list_arg,
191 state = QUOTE; 203 state = QUOTE;
192 } else { 204 } else {
193 set: 205 set:
194 if ((size_t)(p - buf) >= mc)
195 bb_error_msg_and_die("argument line too long");
196 *p++ = c; 206 *p++ = c;
197 } 207 }
198 } 208 }
@@ -202,105 +212,122 @@ static xlist_t *process_stdin(xlist_t *list_arg,
202 bb_error_msg_and_die("unmatched %s quote", 212 bb_error_msg_and_die("unmatched %s quote",
203 q == '\'' ? "single" : "double"); 213 q == '\'' ? "single" : "double");
204 } 214 }
205 /* word loaded */ 215 /* A full word is loaded */
206 if (eof_str) { 216 if (G.eof_str) {
207 eof_str_detected = (strcmp(s, eof_str) == 0); 217 if (strcmp(s, G.eof_str) == 0) {
208 } 218 while (getchar() != EOF)
209 if (!eof_str_detected) { 219 continue;
210 size_t length = (p - buf); 220 p = s;
211 /* Dont xzalloc - it can be quite big */ 221 goto ret;
212 cur = xmalloc(offsetof(xlist_t, xstr) + length);
213 cur->link = NULL;
214 cur->length = length;
215 memcpy(cur->xstr, s, length);
216 if (prev == NULL) {
217 list_arg = cur;
218 } else {
219 prev->link = cur;
220 }
221 prev = cur;
222 line_l += length;
223 if (line_l > mc) {
224 /* stop memory usage :-) */
225 break;
226 } 222 }
227 } 223 }
228 s = NULL; 224 store_param(s);
225 dbg_msg("args[]:'%s'", s);
226 s = p;
227 n_max_arg--;
228 if (n_max_arg == 0) {
229 goto ret;
230 }
229 state = NORM; 231 state = NORM;
230 } 232 }
233 if (p == buf) {
234 goto ret;
235 }
231 } 236 }
232 return list_arg; 237 ret:
238 *p = '\0';
239 /* store_param(NULL) - caller will do it */
240 dbg_msg("return:'%s'", s);
241 return s;
233} 242}
234#else 243#else
235/* The variant does not support single quotes, double quotes or backslash */ 244/* The variant does not support single quotes, double quotes or backslash */
236static xlist_t *process_stdin(xlist_t *list_arg, 245static char* FAST_FUNC process_stdin(int n_max_chars, int n_max_arg, char *buf)
237 const char *eof_str, size_t mc, char *buf)
238{ 246{
247 char *s = buf; /* start of the word */
248 char *p = s + strlen(buf); /* end of the word */
239 249
240 int c; /* current char */ 250 buf += n_max_chars; /* past buffer's end */
241 char eof_str_detected = 0;
242 char *s = NULL; /* start word */
243 char *p = NULL; /* pointer to end word */
244 size_t line_l = 0; /* size loaded args line */
245 xlist_t *cur;
246 xlist_t *prev;
247 251
248 prev = cur = list_arg;
249 while (1) { 252 while (1) {
250 if (!cur) break; 253 int c = getchar();
251 prev = cur;
252 line_l += cur->length;
253 cur = cur->link;
254 }
255
256 while (!eof_stdin_detected) {
257 c = getchar();
258 if (c == EOF) { 254 if (c == EOF) {
259 eof_stdin_detected = 1; 255 if (p == s)
256 goto ret;
260 } 257 }
261 if (eof_str_detected)
262 continue;
263 if (c == EOF || ISSPACE(c)) { 258 if (c == EOF || ISSPACE(c)) {
264 if (s == NULL) 259 if (p == s)
265 continue; 260 continue;
266 c = EOF; 261 c = EOF;
267 } 262 }
268 if (s == NULL)
269 s = p = buf;
270 if ((size_t)(p - buf) >= mc)
271 bb_error_msg_and_die("argument line too long");
272 *p++ = (c == EOF ? '\0' : c); 263 *p++ = (c == EOF ? '\0' : c);
273 if (c == EOF) { /* word's delimiter or EOF detected */ 264 if (c == EOF) { /* word's delimiter or EOF detected */
274 /* word loaded */ 265 /* A full word is loaded */
275 if (eof_str) { 266 if (G.eof_str) {
276 eof_str_detected = (strcmp(s, eof_str) == 0); 267 if (strcmp(s, G.eof_str) == 0) {
277 } 268 while (getchar() != EOF)
278 if (!eof_str_detected) { 269 continue;
279 size_t length = (p - buf); 270 p = s;
280 /* Dont xzalloc - it can be quite big */ 271 goto ret;
281 cur = xmalloc(offsetof(xlist_t, xstr) + length);
282 cur->link = NULL;
283 cur->length = length;
284 memcpy(cur->xstr, s, length);
285 if (prev == NULL) {
286 list_arg = cur;
287 } else {
288 prev->link = cur;
289 } 272 }
290 prev = cur;
291 line_l += length;
292 if (line_l > mc) {
293 /* stop memory usage :-) */
294 break;
295 }
296 s = NULL;
297 } 273 }
274 store_param(s);
275 dbg_msg("args[]:'%s'", s);
276 s = p;
277 n_max_arg--;
278 if (n_max_arg == 0) {
279 goto ret;
280 }
281 }
282 if (p == buf) {
283 goto ret;
298 } 284 }
299 } 285 }
300 return list_arg; 286 ret:
287 *p = '\0';
288 /* store_param(NULL) - caller will do it */
289 dbg_msg("return:'%s'", s);
290 return s;
301} 291}
302#endif /* FEATURE_XARGS_SUPPORT_QUOTES */ 292#endif /* FEATURE_XARGS_SUPPORT_QUOTES */
303 293
294#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
295static char* FAST_FUNC process0_stdin(int n_max_chars, int n_max_arg, char *buf)
296{
297 char *s = buf; /* start of the word */
298 char *p = s + strlen(buf); /* end of the word */
299
300 buf += n_max_chars; /* past buffer's end */
301
302 while (1) {
303 int c = getchar();
304 if (c == EOF) {
305 if (p == s)
306 goto ret;
307 c = '\0';
308 }
309 *p++ = c;
310 if (c == '\0') { /* word's delimiter or EOF detected */
311 /* A full word is loaded */
312 store_param(s);
313 dbg_msg("args[]:'%s'", s);
314 s = p;
315 n_max_arg--;
316 if (n_max_arg == 0) {
317 goto ret;
318 }
319 }
320 if (p == buf) {
321 goto ret;
322 }
323 }
324 ret:
325 *p = '\0';
326 /* store_param(NULL) - caller will do it */
327 dbg_msg("return:'%s'", s);
328 return s;
329}
330#endif /* FEATURE_XARGS_SUPPORT_ZERO_TERM */
304 331
305#if ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION 332#if ENABLE_FEATURE_XARGS_SUPPORT_CONFIRMATION
306/* Prompt the user for a response, and 333/* Prompt the user for a response, and
@@ -322,65 +349,30 @@ static int xargs_ask_confirmation(void)
322} 349}
323#else 350#else
324# define xargs_ask_confirmation() 1 351# define xargs_ask_confirmation() 1
325#endif /* FEATURE_XARGS_SUPPORT_CONFIRMATION */ 352#endif
326
327#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
328static xlist_t *process0_stdin(xlist_t *list_arg,
329 const char *eof_str UNUSED_PARAM, size_t mc, char *buf)
330{
331 int c; /* current char */
332 char *s = NULL; /* start word */
333 char *p = NULL; /* pointer to end word */
334 size_t line_l = 0; /* size loaded args line */
335 xlist_t *cur;
336 xlist_t *prev;
337
338 prev = cur = list_arg;
339 while (1) {
340 if (!cur) break;
341 prev = cur;
342 line_l += cur->length;
343 cur = cur->link;
344 }
345 353
346 while (!eof_stdin_detected) { 354//usage:#define xargs_trivial_usage
347 c = getchar(); 355//usage: "[OPTIONS] [PROG ARGS]"
348 if (c == EOF) { 356//usage:#define xargs_full_usage "\n\n"
349 eof_stdin_detected = 1; 357//usage: "Run PROG on every item given by stdin\n"
350 if (s == NULL) 358//usage: "\nOptions:"
351 break; 359//usage: IF_FEATURE_XARGS_SUPPORT_CONFIRMATION(
352 c = '\0'; 360//usage: "\n -p Ask user whether to run each command"
353 } 361//usage: )
354 if (s == NULL) 362//usage: "\n -r Don't run command if input is empty"
355 s = p = buf; 363//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(
356 if ((size_t)(p - buf) >= mc) 364//usage: "\n -0 Input is separated by NUL characters"
357 bb_error_msg_and_die("argument line too long"); 365//usage: )
358 *p++ = c; 366//usage: "\n -t Print the command on stderr before execution"
359 if (c == '\0') { /* word's delimiter or EOF detected */ 367//usage: "\n -e[STR] STR stops input processing"
360 /* word loaded */ 368//usage: "\n -n N Pass no more than N args to PROG"
361 size_t length = (p - buf); 369//usage: "\n -s N Pass command line of no more than N bytes"
362 /* Dont xzalloc - it can be quite big */ 370//usage: IF_FEATURE_XARGS_SUPPORT_TERMOPT(
363 cur = xmalloc(offsetof(xlist_t, xstr) + length); 371//usage: "\n -x Exit if size is exceeded"
364 cur->link = NULL; 372//usage: )
365 cur->length = length; 373//usage:#define xargs_example_usage
366 memcpy(cur->xstr, s, length); 374//usage: "$ ls | xargs gzip\n"
367 if (prev == NULL) { 375//usage: "$ find . -name '*.c' -print | xargs rm\n"
368 list_arg = cur;
369 } else {
370 prev->link = cur;
371 }
372 prev = cur;
373 line_l += length;
374 if (line_l > mc) {
375 /* stop memory usage :-) */
376 break;
377 }
378 s = NULL;
379 }
380 }
381 return list_arg;
382}
383#endif /* FEATURE_XARGS_SUPPORT_ZERO_TERM */
384 376
385/* Correct regardless of combination of CONFIG_xxx */ 377/* Correct regardless of combination of CONFIG_xxx */
386enum { 378enum {
@@ -412,44 +404,42 @@ enum {
412int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 404int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
413int xargs_main(int argc, char **argv) 405int xargs_main(int argc, char **argv)
414{ 406{
415 char **args; 407 int i;
416 int i, n;
417 xlist_t *list = NULL;
418 xlist_t *cur;
419 int child_error = 0; 408 int child_error = 0;
420 char *max_args, *max_chars; 409 char *max_args;
421 int n_max_arg; 410 char *max_chars;
422 const char *eof_str = NULL; 411 char *buf;
423 unsigned opt; 412 unsigned opt;
424 size_t n_max_chars; 413 int n_max_chars;
414 int n_max_arg;
425#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM 415#if ENABLE_FEATURE_XARGS_SUPPORT_ZERO_TERM
426 xlist_t* (*read_args)(xlist_t*, const char*, size_t, char*) = process_stdin; 416 char* FAST_FUNC (*read_args)(int, int, char*) = process_stdin;
427#else 417#else
428#define read_args process_stdin 418#define read_args process_stdin
429#endif 419#endif
430 420
431 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &eof_str, &eof_str); 421 INIT_G();
422
423 G.eof_str = NULL;
424 opt = getopt32(argv, OPTION_STR, &max_args, &max_chars, &G.eof_str, &G.eof_str);
432 425
433 /* -E ""? You may wonder why not just omit -E? 426 /* -E ""? You may wonder why not just omit -E?
434 * This is used for portability: 427 * This is used for portability:
435 * old xargs was using "_" as default for -E / -e */ 428 * old xargs was using "_" as default for -E / -e */
436 if ((opt & OPT_EOF_STRING1) && eof_str[0] == '\0') 429 if ((opt & OPT_EOF_STRING1) && G.eof_str[0] == '\0')
437 eof_str = NULL; 430 G.eof_str = NULL;
438 431
439 if (opt & OPT_ZEROTERM) 432 if (opt & OPT_ZEROTERM)
440 IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin); 433 IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(read_args = process0_stdin);
441 434
442 argv += optind; 435 argv += optind;
443 argc -= optind; 436 argc -= optind;
444 if (!argc) { 437 if (!argv[0]) {
445 /* default behavior is to echo all the filenames */ 438 /* default behavior is to echo all the filenames */
446 *argv = (char*)"echo"; 439 *--argv = (char*)"echo";
447 argc++; 440 argc++;
448 } 441 }
449 442
450 n_max_chars = ARG_MAX; /* might be calling sysconf(_SC_ARG_MAX) */
451 if (n_max_chars < 4*1024); /* paranoia */
452 n_max_chars = LONG_MAX;
453 /* The Open Group Base Specifications Issue 6: 443 /* The Open Group Base Specifications Issue 6:
454 * "The xargs utility shall limit the command line length such that 444 * "The xargs utility shall limit the command line length such that
455 * when the command line is invoked, the combined argument 445 * when the command line is invoked, the combined argument
@@ -457,101 +447,94 @@ int xargs_main(int argc, char **argv)
457 * in the System Interfaces volume of IEEE Std 1003.1-2001) 447 * in the System Interfaces volume of IEEE Std 1003.1-2001)
458 * shall not exceed {ARG_MAX}-2048 bytes". 448 * shall not exceed {ARG_MAX}-2048 bytes".
459 */ 449 */
450 n_max_chars = ARG_MAX; /* might be calling sysconf(_SC_ARG_MAX) */
451 if (n_max_chars < 4*1024); /* paranoia */
452 n_max_chars = 4*1024;
460 n_max_chars -= 2048; 453 n_max_chars -= 2048;
461 /* Sanity check for systems with huge ARG_MAX defines (e.g., Suns which 454 /* Sanity check for systems with huge ARG_MAX defines (e.g., Suns which
462 * have it at 1 meg). Things will work fine with a large ARG_MAX but it 455 * have it at 1 meg). Things will work fine with a large ARG_MAX
463 * will probably hurt the system more than it needs to; an array of this 456 * but it will probably hurt the system more than it needs to;
464 * size is allocated. 457 * an array of this size is allocated.
465 */ 458 */
466 if (n_max_chars > 20 * 1024) 459 if (n_max_chars > 20 * 1024)
467 n_max_chars = 20 * 1024; 460 n_max_chars = 20 * 1024;
468 461
469 if (opt & OPT_UPTO_SIZE) { 462 if (opt & OPT_UPTO_SIZE) {
470 size_t n_chars = 0; 463 size_t n_chars = 0;
471 n_max_chars = xatoul_range(max_chars, 1, n_max_chars); 464 n_max_chars = xatou_range(max_chars, 1, INT_MAX);
472 for (i = 0; i < argc; i++) { 465 for (i = 0; argv[i]; i++) {
473 n_chars += strlen(*argv) + 1; 466 n_chars += strlen(argv[i]) + 1;
474 } 467 }
475 if (n_max_chars <= n_chars) { 468 n_max_chars -= n_chars;
469 if (n_max_chars <= 0) {
476 bb_error_msg_and_die("can't fit single argument within argument list size limit"); 470 bb_error_msg_and_die("can't fit single argument within argument list size limit");
477 } 471 }
478 n_max_chars -= n_chars;
479 } 472 }
480 max_chars = xmalloc(n_max_chars);
481 473
474 buf = xzalloc(n_max_chars + 1);
475
476 n_max_arg = n_max_chars;
482 if (opt & OPT_UPTO_NUMBER) { 477 if (opt & OPT_UPTO_NUMBER) {
483 n_max_arg = xatoul_range(max_args, 1, INT_MAX); 478 n_max_arg = xatou_range(max_args, 1, INT_MAX);
484 } else {
485 n_max_arg = n_max_chars;
486 } 479 }
487 480
488 while ((list = read_args(list, eof_str, n_max_chars, max_chars)) != NULL || 481 /* Allocate pointers for execvp */
489 !(opt & OPT_NO_EMPTY)) 482 /* We can statically allocate (argc + n_max_arg + 1) elements
490 { 483 * and do not bother with resizing args[], but on 64-bit machines
491 size_t n_chars = 0; 484 * this results in args[] vector which is ~8 times bigger
492 opt |= OPT_NO_EMPTY; 485 * than n_max_chars! That is, with n_max_chars == 20k,
493 n = 0; 486 * args[] will take 160k (!), which will most likely be
494#if ENABLE_FEATURE_XARGS_SUPPORT_TERMOPT 487 * almost entirely unused.
495 for (cur = list; cur;) { 488 */
496 n_chars += cur->length; 489 /* See store_param() for matching 256-step growth logic */
497 n++; 490 G.args = xmalloc(sizeof(G.args[0]) * ((argc + 0xff) & ~0xff));
498 cur = cur->link; 491
499 if (n_chars > n_max_chars || (n == n_max_arg && cur)) { 492 /* Store the command to be executed, part 1 */
500 if (opt & OPT_TERMINATE) 493 for (i = 0; argv[i]; i++)
501 bb_error_msg_and_die("argument list too long"); 494 G.args[i] = argv[i];
502 break; 495
503 } 496 while (1) {
504 } 497 char *rem;
505#else 498
506 for (cur = list; cur; cur = cur->link) { 499 G.idx = argc;
507 n_chars += cur->length; 500 rem = read_args(n_max_chars, n_max_arg, buf);
508 n++; 501 store_param(NULL);
509 if (n_chars > n_max_chars || n == n_max_arg) { 502
503 if (!G.args[argc]) {
504 if (*rem != '\0')
505 bb_error_msg_and_die("argument line too long");
506 if (opt & OPT_NO_EMPTY)
510 break; 507 break;
511 }
512 }
513#endif /* FEATURE_XARGS_SUPPORT_TERMOPT */
514
515 /* allocate pointers for execvp:
516 argc*arg, n*arg from stdin, NULL */
517 args = xzalloc((n + argc + 1) * sizeof(char *));
518
519 /* store the command to be executed
520 (taken from the command line) */
521 for (i = 0; i < argc; i++)
522 args[i] = argv[i];
523 /* (taken from stdin) */
524 for (cur = list; n; cur = cur->link) {
525 args[i++] = cur->xstr;
526 n--;
527 } 508 }
509 opt |= OPT_NO_EMPTY;
528 510
529 if (opt & (OPT_INTERACTIVE | OPT_VERBOSE)) { 511 if (opt & (OPT_INTERACTIVE | OPT_VERBOSE)) {
512 const char *fmt = " %s" + 1;
513 char **args = G.args;
530 for (i = 0; args[i]; i++) { 514 for (i = 0; args[i]; i++) {
531 if (i) 515 fprintf(stderr, fmt, args[i]);
532 bb_putchar_stderr(' '); 516 fmt = " %s";
533 fputs(args[i], stderr);
534 } 517 }
535 if (!(opt & OPT_INTERACTIVE)) 518 if (!(opt & OPT_INTERACTIVE))
536 bb_putchar_stderr('\n'); 519 bb_putchar_stderr('\n');
537 } 520 }
521
538 if (!(opt & OPT_INTERACTIVE) || xargs_ask_confirmation()) { 522 if (!(opt & OPT_INTERACTIVE) || xargs_ask_confirmation()) {
539 child_error = xargs_exec(args); 523 child_error = xargs_exec();
540 } 524 }
541 525
542 /* clean up */
543 for (i = argc; args[i]; i++) {
544 cur = list;
545 list = list->link;
546 free(cur);
547 }
548 free(args);
549 if (child_error > 0 && child_error != 123) { 526 if (child_error > 0 && child_error != 123) {
550 break; 527 break;
551 } 528 }
529
530 overlapping_strcpy(buf, rem);
552 } /* while */ 531 } /* while */
553 if (ENABLE_FEATURE_CLEAN_UP) 532
554 free(max_chars); 533 if (ENABLE_FEATURE_CLEAN_UP) {
534 free(G.args);
535 free(buf);
536 }
537
555 return child_error; 538 return child_error;
556} 539}
557 540
diff --git a/include/applets.src.h b/include/applets.src.h
index 2998a0ea9..9162b66c7 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -136,7 +136,6 @@ IF_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_DROP))
136//IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP, e2label)) 136//IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP, e2label))
137IF_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_DROP, echo)) 137IF_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_DROP, echo))
138IF_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_DROP)) 138IF_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_DROP))
139IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep))
140IF_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 139IF_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_DROP))
141IF_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_DROP, env)) 140IF_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_DROP, env))
142IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envdir)) 141IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envdir))
@@ -152,8 +151,6 @@ IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_DROP, fdfl
152IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 151IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP))
153IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) 152IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP))
154IF_FGCONSOLE(APPLET(fgconsole, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 153IF_FGCONSOLE(APPLET(fgconsole, _BB_DIR_USR_BIN, _BB_SUID_DROP))
155IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep))
156IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find))
157IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE)) 154IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE))
158IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 155IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
159IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_lock)) 156IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_lock))
@@ -176,7 +173,6 @@ IF_GETENFORCE(APPLET(getenforce, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
176IF_GETOPT(APPLET(getopt, _BB_DIR_BIN, _BB_SUID_DROP)) 173IF_GETOPT(APPLET(getopt, _BB_DIR_BIN, _BB_SUID_DROP))
177IF_GETSEBOOL(APPLET(getsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) 174IF_GETSEBOOL(APPLET(getsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP))
178IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP)) 175IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP))
179IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP))
180IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP)) 176IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP))
181IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP)) 177IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP))
182IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP)) 178IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP))
@@ -433,7 +429,6 @@ IF_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_DROP))
433IF_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 429IF_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_DROP))
434IF_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 430IF_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_DROP))
435IF_WHOAMI(APPLET_NOFORK(whoami, whoami, _BB_DIR_USR_BIN, _BB_SUID_DROP, whoami)) 431IF_WHOAMI(APPLET_NOFORK(whoami, whoami, _BB_DIR_USR_BIN, _BB_SUID_DROP, whoami))
436IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs))
437IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xzcat)) 432IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xzcat))
438IF_XZ(APPLET_ODDNAME(xz, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xz)) 433IF_XZ(APPLET_ODDNAME(xz, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xz))
439IF_YES(APPLET_NOFORK(yes, yes, _BB_DIR_USR_BIN, _BB_SUID_DROP, yes)) 434IF_YES(APPLET_NOFORK(yes, yes, _BB_DIR_USR_BIN, _BB_SUID_DROP, yes))
diff --git a/include/libbb.h b/include/libbb.h
index 1e3df0930..0836b684e 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -687,6 +687,8 @@ extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC;
687extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC; 687extern ssize_t full_write(int fd, const void *buf, size_t count) FAST_FUNC;
688extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC; 688extern void xwrite(int fd, const void *buf, size_t count) FAST_FUNC;
689extern void xwrite_str(int fd, const char *str) FAST_FUNC; 689extern void xwrite_str(int fd, const char *str) FAST_FUNC;
690extern ssize_t full_write1_str(const char *str) FAST_FUNC;
691extern ssize_t full_write2_str(const char *str) FAST_FUNC;
690extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC; 692extern void xopen_xwrite_close(const char* file, const char *str) FAST_FUNC;
691 693
692/* Close fd, but check for failures (some types of write errors) */ 694/* Close fd, but check for failures (some types of write errors) */
diff --git a/include/usage.src.h b/include/usage.src.h
index f9f457871..f30edbc54 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -1280,72 +1280,6 @@ INSERT
1280#define findfs_example_usage \ 1280#define findfs_example_usage \
1281 "$ findfs LABEL=MyDevice" 1281 "$ findfs LABEL=MyDevice"
1282 1282
1283#define find_trivial_usage \
1284 "[PATH]... [EXPRESSION]"
1285#define find_full_usage "\n\n" \
1286 "Search for files. The default PATH is the current directory,\n" \
1287 "default EXPRESSION is '-print'\n" \
1288 "\nEXPRESSION may consist of:" \
1289 "\n -follow Follow symlinks" \
1290 IF_FEATURE_FIND_XDEV( \
1291 "\n -xdev Don't descend directories on other filesystems") \
1292 IF_FEATURE_FIND_MAXDEPTH( \
1293 "\n -maxdepth N Descend at most N levels. -maxdepth 0 applies" \
1294 "\n tests/actions to command line arguments only") \
1295 "\n -mindepth N Don't act on first N levels" \
1296 "\n -name PATTERN File name (w/o directory name) matches PATTERN" \
1297 "\n -iname PATTERN Case insensitive -name" \
1298 IF_FEATURE_FIND_PATH( \
1299 "\n -path PATTERN Path matches PATTERN") \
1300 IF_FEATURE_FIND_REGEX( \
1301 "\n -regex PATTERN Path matches regex PATTERN") \
1302 IF_FEATURE_FIND_TYPE( \
1303 "\n -type X File type is X (X is one of: f,d,l,b,c,...)") \
1304 IF_FEATURE_FIND_PERM( \
1305 "\n -perm NNN Permissions match any of (+NNN), all of (-NNN)," \
1306 "\n or exactly NNN") \
1307 IF_FEATURE_FIND_MTIME( \
1308 "\n -mtime DAYS Modified time is greater than (+N), less than (-N)," \
1309 "\n or exactly N days") \
1310 IF_FEATURE_FIND_MMIN( \
1311 "\n -mmin MINS Modified time is greater than (+N), less than (-N)," \
1312 "\n or exactly N minutes") \
1313 IF_FEATURE_FIND_NEWER( \
1314 "\n -newer FILE Modified time is more recent than FILE's") \
1315 IF_FEATURE_FIND_INUM( \
1316 "\n -inum N File has inode number N") \
1317 IF_FEATURE_FIND_USER( \
1318 "\n -user NAME File is owned by user NAME (numeric user ID allowed)") \
1319 IF_FEATURE_FIND_GROUP( \
1320 "\n -group NAME File belongs to group NAME (numeric group ID allowed)") \
1321 IF_FEATURE_FIND_DEPTH( \
1322 "\n -depth Process directory name after traversing it") \
1323 IF_FEATURE_FIND_SIZE( \
1324 "\n -size N[bck] File size is N (c:bytes,k:kbytes,b:512 bytes(def.))" \
1325 "\n +/-N: file size is bigger/smaller than N") \
1326 IF_FEATURE_FIND_LINKS( \
1327 "\n -links N Number of links is greater than (+N), less than (-N)," \
1328 "\n or exactly N") \
1329 "\n -print Print (default and assumed)" \
1330 IF_FEATURE_FIND_PRINT0( \
1331 "\n -print0 Delimit output with null characters rather than" \
1332 "\n newlines") \
1333 IF_FEATURE_FIND_CONTEXT ( \
1334 "\n -context File has specified security context") \
1335 IF_FEATURE_FIND_EXEC( \
1336 "\n -exec CMD ARG ; Run CMD with all instances of {} replaced by the" \
1337 "\n matching files") \
1338 IF_FEATURE_FIND_PRUNE( \
1339 "\n -prune Stop traversing current subtree") \
1340 IF_FEATURE_FIND_DELETE( \
1341 "\n -delete Delete files, turns on -depth option") \
1342 IF_FEATURE_FIND_PAREN( \
1343 "\n (EXPR) Group an expression") \
1344
1345#define find_example_usage \
1346 "$ find / -name passwd\n" \
1347 "/etc/passwd\n"
1348
1349#define flash_lock_trivial_usage \ 1283#define flash_lock_trivial_usage \
1350 "MTD_DEVICE OFFSET SECTORS" 1284 "MTD_DEVICE OFFSET SECTORS"
1351#define flash_lock_full_usage "\n\n" \ 1285#define flash_lock_full_usage "\n\n" \
@@ -1575,58 +1509,6 @@ INSERT
1575 "\n -I INITSTR Send INITSTR before anything else" \ 1509 "\n -I INITSTR Send INITSTR before anything else" \
1576 "\n -H HOST Log HOST into the utmp file as the hostname" \ 1510 "\n -H HOST Log HOST into the utmp file as the hostname" \
1577 1511
1578#define grep_trivial_usage \
1579 "[-HhnlLoqvsriw" \
1580 "F" \
1581 IF_FEATURE_GREP_EGREP_ALIAS("E") \
1582 IF_EXTRA_COMPAT("z") \
1583 "] [-m N] " \
1584 IF_FEATURE_GREP_CONTEXT("[-A/B/C N] ") \
1585 "PATTERN/-e PATTERN.../-f FILE [FILE]..."
1586#define grep_full_usage "\n\n" \
1587 "Search for PATTERN in FILEs (or stdin)\n" \
1588 "\nOptions:" \
1589 "\n -H Add 'filename:' prefix" \
1590 "\n -h Do not add 'filename:' prefix" \
1591 "\n -n Add 'line_no:' prefix" \
1592 "\n -l Show only names of files that match" \
1593 "\n -L Show only names of files that don't match" \
1594 "\n -c Show only count of matching lines" \
1595 "\n -o Show only the matching part of line" \
1596 "\n -q Quiet. Return 0 if PATTERN is found, 1 otherwise" \
1597 "\n -v Select non-matching lines" \
1598 "\n -s Suppress open and read errors" \
1599 "\n -r Recurse" \
1600 "\n -i Ignore case" \
1601 "\n -w Match whole words only" \
1602 "\n -F PATTERN is a literal (not regexp)" \
1603 IF_FEATURE_GREP_EGREP_ALIAS( \
1604 "\n -E PATTERN is an extended regexp" \
1605 ) \
1606 IF_EXTRA_COMPAT( \
1607 "\n -z Input is NUL terminated" \
1608 ) \
1609 "\n -m N Match up to N times per file" \
1610 IF_FEATURE_GREP_CONTEXT( \
1611 "\n -A N Print N lines of trailing context" \
1612 "\n -B N Print N lines of leading context" \
1613 "\n -C N Same as '-A N -B N'" \
1614 ) \
1615 "\n -e PTRN Pattern to match" \
1616 "\n -f FILE Read pattern from file" \
1617
1618#define grep_example_usage \
1619 "$ grep root /etc/passwd\n" \
1620 "root:x:0:0:root:/root:/bin/bash\n" \
1621 "$ grep ^[rR]oo. /etc/passwd\n" \
1622 "root:x:0:0:root:/root:/bin/bash\n"
1623
1624#define egrep_trivial_usage NOUSAGE_STR
1625#define egrep_full_usage ""
1626
1627#define fgrep_trivial_usage NOUSAGE_STR
1628#define fgrep_full_usage ""
1629
1630#define gunzip_trivial_usage \ 1512#define gunzip_trivial_usage \
1631 "[OPTIONS] [FILE]..." 1513 "[OPTIONS] [FILE]..."
1632#define gunzip_full_usage "\n\n" \ 1514#define gunzip_full_usage "\n\n" \
@@ -2148,28 +2030,6 @@ INSERT
2148 "\ninotifyd waits for PROG to exit." \ 2030 "\ninotifyd waits for PROG to exit." \
2149 "\nWhen x event happens for all FILEs, inotifyd exits." \ 2031 "\nWhen x event happens for all FILEs, inotifyd exits." \
2150 2032
2151/* 2.6 style insmod has no options and required filename
2152 * (not module name - .ko can't be omitted) */
2153#define insmod_trivial_usage \
2154 IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ") \
2155 IF_NOT_FEATURE_2_4_MODULES("FILE ") \
2156 "[symbol=value]..."
2157#define insmod_full_usage "\n\n" \
2158 "Load the specified kernel modules into the kernel" \
2159 IF_FEATURE_2_4_MODULES( "\n" \
2160 "\nOptions:" \
2161 "\n -f Force module to load into the wrong kernel version" \
2162 "\n -k Make module autoclean-able" \
2163 "\n -v Verbose" \
2164 "\n -q Quiet" \
2165 "\n -L Lock to prevent simultaneous loads of a module" \
2166 IF_FEATURE_INSMOD_LOAD_MAP( \
2167 "\n -m Output load map to stdout" \
2168 ) \
2169 "\n -o NAME Set internal module name to NAME" \
2170 "\n -x Don't export externs" \
2171 )
2172
2173/* -v, -b, -c are ignored */ 2033/* -v, -b, -c are ignored */
2174#define install_trivial_usage \ 2034#define install_trivial_usage \
2175 "[-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST" 2035 "[-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST"
@@ -2973,95 +2833,6 @@ INSERT
2973 "$ ls -la /tmp/temp.mWiLjM\n" \ 2833 "$ ls -la /tmp/temp.mWiLjM\n" \
2974 "-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n" 2834 "-rw------- 1 andersen andersen 0 Apr 25 17:10 /tmp/temp.mWiLjM\n"
2975 2835
2976#define modprobe_trivial_usage \
2977 IF_MODPROBE_SMALL("[-qfwrsv] MODULE [symbol=value]...") \
2978 IF_NOT_MODPROBE_SMALL("[-" \
2979 IF_FEATURE_2_4_MODULES("k")"nqrsv" \
2980 IF_FEATURE_MODPROBE_BLACKLIST("b")"] MODULE [symbol=value]...")
2981#define modprobe_full_usage "\n\n" \
2982 "Options:" \
2983 IF_MODPROBE_SMALL( \
2984 "\n -q Quiet" \
2985 "\n -f Force" \
2986 "\n -w Wait for unload" \
2987 "\n -r Remove module (stacks) or do autoclean" \
2988 "\n -s Report via syslog instead of stderr" \
2989 "\n -v Verbose" \
2990 ) \
2991 IF_NOT_MODPROBE_SMALL( \
2992 IF_FEATURE_2_4_MODULES( \
2993 "\n -k Make module autoclean-able" \
2994 ) \
2995 "\n -n Dry run" \
2996 "\n -q Quiet" \
2997 "\n -r Remove module (stacks) or do autoclean" \
2998 "\n -s Report via syslog instead of stderr" \
2999 "\n -v Verbose" \
3000 IF_FEATURE_MODPROBE_BLACKLIST( \
3001 "\n -b Apply blacklist to module names too" \
3002 ) \
3003 )
3004
3005#define modprobe_notes_usage \
3006"modprobe can (un)load a stack of modules, passing each module options (when\n" \
3007"loading). modprobe uses a configuration file to determine what option(s) to\n" \
3008"pass each module it loads.\n" \
3009"\n" \
3010"The configuration file is searched (in this order):\n" \
3011"\n" \
3012" /etc/modprobe.conf (2.6 only)\n" \
3013" /etc/modules.conf\n" \
3014" /etc/conf.modules (deprecated)\n" \
3015"\n" \
3016"They all have the same syntax (see below). If none is present, it is\n" \
3017"_not_ an error; each loaded module is then expected to load without\n" \
3018"options. Once a file is found, the others are tested for.\n" \
3019"\n" \
3020"/etc/modules.conf entry format:\n" \
3021"\n" \
3022" alias <alias_name> <mod_name>\n" \
3023" Makes it possible to modprobe alias_name, when there is no such module.\n" \
3024" It makes sense if your mod_name is long, or you want a more representative\n" \
3025" name for that module (eg. 'scsi' in place of 'aha7xxx').\n" \
3026" This makes it also possible to use a different set of options (below) for\n" \
3027" the module and the alias.\n" \
3028" A module can be aliased more than once.\n" \
3029"\n" \
3030" options <mod_name|alias_name> <symbol=value...>\n" \
3031" When loading module mod_name (or the module aliased by alias_name), pass\n" \
3032" the \"symbol=value\" pairs as option to that module.\n" \
3033"\n" \
3034"Sample /etc/modules.conf file:\n" \
3035"\n" \
3036" options tulip irq=3\n" \
3037" alias tulip tulip2\n" \
3038" options tulip2 irq=4 io=0x308\n" \
3039"\n" \
3040"Other functionality offered by 'classic' modprobe is not available in\n" \
3041"this implementation.\n" \
3042"\n" \
3043"If module options are present both in the config file, and on the command line,\n" \
3044"then the options from the command line will be passed to the module _after_\n" \
3045"the options from the config file. That way, you can have defaults in the config\n" \
3046"file, and override them for a specific usage from the command line.\n"
3047#define modprobe_example_usage \
3048 "(with the above /etc/modules.conf):\n\n" \
3049 "$ modprobe tulip\n" \
3050 " will load the module 'tulip' with default option 'irq=3'\n\n" \
3051 "$ modprobe tulip irq=5\n" \
3052 " will load the module 'tulip' with option 'irq=5', thus overriding the default\n\n" \
3053 "$ modprobe tulip2\n" \
3054 " will load the module 'tulip' with default options 'irq=4 io=0x308',\n" \
3055 " which are the default for alias 'tulip2'\n\n" \
3056 "$ modprobe tulip2 irq=8\n" \
3057 " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=8',\n" \
3058 " which are the default for alias 'tulip2' overridden by the option 'irq=8'\n\n" \
3059 " from the command line\n\n" \
3060 "$ modprobe tulip2 irq=2 io=0x210\n" \
3061 " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=4 io=0x210',\n" \
3062 " which are the default for alias 'tulip2' overridden by the options 'irq=2 io=0x210'\n\n" \
3063 " from the command line\n"
3064
3065#define more_trivial_usage \ 2836#define more_trivial_usage \
3066 "[FILE]..." 2837 "[FILE]..."
3067#define more_full_usage "\n\n" \ 2838#define more_full_usage "\n\n" \
@@ -5208,34 +4979,13 @@ INSERT
5208#define who_full_usage "\n\n" \ 4979#define who_full_usage "\n\n" \
5209 "Show who is logged on\n" \ 4980 "Show who is logged on\n" \
5210 "\nOptions:" \ 4981 "\nOptions:" \
5211 "\n -a show all" \ 4982 "\n -a Show all" \
5212 4983
5213#define whoami_trivial_usage \ 4984#define whoami_trivial_usage \
5214 "" 4985 ""
5215#define whoami_full_usage "\n\n" \ 4986#define whoami_full_usage "\n\n" \
5216 "Print the user name associated with the current effective user id" 4987 "Print the user name associated with the current effective user id"
5217 4988
5218#define xargs_trivial_usage \
5219 "[OPTIONS] [PROG ARGS]"
5220#define xargs_full_usage "\n\n" \
5221 "Run PROG on every item given by stdin\n" \
5222 "\nOptions:" \
5223 IF_FEATURE_XARGS_SUPPORT_CONFIRMATION( \
5224 "\n -p Ask user whether to run each command") \
5225 "\n -r Don't run command if input is empty" \
5226 IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( \
5227 "\n -0 Input is separated by NUL characters") \
5228 "\n -t Print the command on stderr before execution" \
5229 "\n -e[STR] STR stops input processing" \
5230 "\n -n N Pass no more than N args to PROG" \
5231 "\n -s N Pass command line of no more than N bytes" \
5232 IF_FEATURE_XARGS_SUPPORT_TERMOPT( \
5233 "\n -x Exit if size is exceeded") \
5234
5235#define xargs_example_usage \
5236 "$ ls | xargs gzip\n" \
5237 "$ find . -name '*.c' -print | xargs rm\n"
5238
5239#define zcat_trivial_usage \ 4989#define zcat_trivial_usage \
5240 "FILE" 4990 "FILE"
5241#define zcat_full_usage "\n\n" \ 4991#define zcat_full_usage "\n\n" \
diff --git a/init/Config.src b/init/Config.src
index e8121c96a..2e9208150 100644
--- a/init/Config.src
+++ b/init/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Init Utilities" 6menu "Init Utilities"
7 7
8INSERT
9
8config INIT 10config INIT
9 bool "init" 11 bool "init"
10 default y 12 default y
diff --git a/init/Kbuild.src b/init/Kbuild.src
index ce3f30256..6095a78bb 100644
--- a/init/Kbuild.src
+++ b/init/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_HALT) += halt.o 10lib-$(CONFIG_HALT) += halt.o
9lib-$(CONFIG_INIT) += init.o 11lib-$(CONFIG_INIT) += init.o
10lib-$(CONFIG_MESG) += mesg.o 12lib-$(CONFIG_MESG) += mesg.o
diff --git a/libbb/Config.src b/libbb/Config.src
index a0aeb3683..80b1e0d21 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Busybox Library Tuning" 6menu "Busybox Library Tuning"
7 7
8INSERT
9
8config PASSWORD_MINLEN 10config PASSWORD_MINLEN
9 int "Minimum password length" 11 int "Minimum password length"
10 default 6 12 default 6
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 9374feb17..2a50a1ae3 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -6,6 +6,8 @@
6 6
7lib-y:= 7lib-y:=
8 8
9INSERT
10
9lib-y += appletlib.o 11lib-y += appletlib.o
10lib-y += ask_confirmation.o 12lib-y += ask_confirmation.o
11lib-y += bb_askpass.o 13lib-y += bb_askpass.o
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index cb18a688e..922f7d26b 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -98,13 +98,6 @@ static const char *unpack_usage_messages(void)
98#endif /* FEATURE_COMPRESS_USAGE */ 98#endif /* FEATURE_COMPRESS_USAGE */
99 99
100 100
101static void full_write2_str(const char *str)
102{
103 // This uses stdio:
104 //xwrite_str(STDERR_FILENO, str);
105 write(STDERR_FILENO, str, strlen(str));
106}
107
108void FAST_FUNC bb_show_usage(void) 101void FAST_FUNC bb_show_usage(void)
109{ 102{
110 if (ENABLE_SHOW_USAGE) { 103 if (ENABLE_SHOW_USAGE) {
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 6200fc600..65437211d 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -49,23 +49,35 @@ char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src)
49} 49}
50 50
51 51
52// Convert unsigned integer to ascii, writing into supplied buffer. 52/* Convert unsigned integer to ascii, writing into supplied buffer.
53// A truncated result contains the first few digits of the result ala strncpy. 53 * A truncated result contains the first few digits of the result ala strncpy.
54// Returns a pointer past last generated digit, does _not_ store NUL. 54 * Returns a pointer past last generated digit, does _not_ store NUL.
55void BUG_sizeof_unsigned_not_4(void); 55 */
56void BUG_sizeof(void);
56char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen) 57char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen)
57{ 58{
58 unsigned i, out, res; 59 unsigned i, out, res;
59 if (sizeof(unsigned) != 4) 60
60 BUG_sizeof_unsigned_not_4();
61 if (buflen) { 61 if (buflen) {
62 out = 0; 62 out = 0;
63 for (i = 1000000000; i; i /= 10) { 63 if (sizeof(n) == 4)
64 // 2^32-1 = 4294967295
65 i = 1000000000;
66#if UINT_MAX > 4294967295 /* prevents warning about "const too large" */
67 else
68 if (sizeof(n) == 8)
69 // 2^64-1 = 18446744073709551615
70 i = 10000000000000000000;
71#endif
72 else
73 BUG_sizeof();
74 for (; i; i /= 10) {
64 res = n / i; 75 res = n / i;
76 n = n % i;
65 if (res || out || i == 1) { 77 if (res || out || i == 1) {
66 if (!--buflen) break; 78 if (--buflen == 0)
79 break;
67 out++; 80 out++;
68 n -= res*i;
69 *buf++ = '0' + res; 81 *buf++ = '0' + res;
70 } 82 }
71 } 83 }
@@ -76,7 +88,9 @@ char* FAST_FUNC utoa_to_buf(unsigned n, char *buf, unsigned buflen)
76/* Convert signed integer to ascii, like utoa_to_buf() */ 88/* Convert signed integer to ascii, like utoa_to_buf() */
77char* FAST_FUNC itoa_to_buf(int n, char *buf, unsigned buflen) 89char* FAST_FUNC itoa_to_buf(int n, char *buf, unsigned buflen)
78{ 90{
79 if (buflen && n < 0) { 91 if (!buflen)
92 return buf;
93 if (n < 0) {
80 n = -n; 94 n = -n;
81 *buf++ = '-'; 95 *buf++ = '-';
82 buflen--; 96 buflen--;
@@ -87,16 +101,16 @@ char* FAST_FUNC itoa_to_buf(int n, char *buf, unsigned buflen)
87// The following two functions use a static buffer, so calling either one a 101// The following two functions use a static buffer, so calling either one a
88// second time will overwrite previous results. 102// second time will overwrite previous results.
89// 103//
90// The largest 32 bit integer is -2 billion plus null terminator, or 12 bytes. 104// The largest 32 bit integer is -2 billion plus NUL, or 1+10+1=12 bytes.
91// It so happens that sizeof(int) * 3 is enough for 32+ bits. 105// It so happens that sizeof(int) * 3 is enough for 32+ bit ints.
92// (sizeof(int) * 3 + 2 is correct for any width, even 8-bit) 106// (sizeof(int) * 3 + 2 is correct for any width, even 8-bit)
93 107
94static char local_buf[sizeof(int) * 3]; 108static char local_buf[sizeof(int) * 3];
95 109
96// Convert unsigned integer to ascii using a static buffer (returned). 110/* Convert unsigned integer to ascii using a static buffer (returned). */
97char* FAST_FUNC utoa(unsigned n) 111char* FAST_FUNC utoa(unsigned n)
98{ 112{
99 *(utoa_to_buf(n, local_buf, sizeof(local_buf))) = '\0'; 113 *(utoa_to_buf(n, local_buf, sizeof(local_buf) - 1)) = '\0';
100 114
101 return local_buf; 115 return local_buf;
102} 116}
@@ -104,7 +118,7 @@ char* FAST_FUNC utoa(unsigned n)
104/* Convert signed integer to ascii using a static buffer (returned). */ 118/* Convert signed integer to ascii using a static buffer (returned). */
105char* FAST_FUNC itoa(int n) 119char* FAST_FUNC itoa(int n)
106{ 120{
107 *(itoa_to_buf(n, local_buf, sizeof(local_buf))) = '\0'; 121 *(itoa_to_buf(n, local_buf, sizeof(local_buf) - 1)) = '\0';
108 122
109 return local_buf; 123 return local_buf;
110} 124}
@@ -204,6 +218,16 @@ int FAST_FUNC bb_putchar_stderr(char ch)
204 return write(STDERR_FILENO, &ch, 1); 218 return write(STDERR_FILENO, &ch, 1);
205} 219}
206 220
221ssize_t FAST_FUNC full_write1_str(const char *str)
222{
223 return full_write(STDOUT_FILENO, str, strlen(str));
224}
225
226ssize_t FAST_FUNC full_write2_str(const char *str)
227{
228 return full_write(STDERR_FILENO, str, strlen(str));
229}
230
207static int wh_helper(int value, int def_val, const char *env_name, int *err) 231static int wh_helper(int value, int def_val, const char *env_name, int *err)
208{ 232{
209 if (value == 0) { 233 if (value == 0) {
diff --git a/loginutils/Config.src b/loginutils/Config.src
index 982d5d669..5d497c4dc 100644
--- a/loginutils/Config.src
+++ b/loginutils/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Login/Password Management Utilities" 6menu "Login/Password Management Utilities"
7 7
8INSERT
9
8config FEATURE_SHADOWPASSWDS 10config FEATURE_SHADOWPASSWDS
9 bool "Support for shadow passwords" 11 bool "Support for shadow passwords"
10 default y 12 default y
diff --git a/loginutils/Kbuild.src b/loginutils/Kbuild.src
index 3d0d777e8..fd1ea06c1 100644
--- a/loginutils/Kbuild.src
+++ b/loginutils/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_ADDGROUP) += addgroup.o 10lib-$(CONFIG_ADDGROUP) += addgroup.o
9lib-$(CONFIG_ADDUSER) += adduser.o 11lib-$(CONFIG_ADDUSER) += adduser.o
10lib-$(CONFIG_CRYPTPW) += cryptpw.o 12lib-$(CONFIG_CRYPTPW) += cryptpw.o
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 7fb861f9d..a5e8e906a 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -673,8 +673,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
673 /* Write the modem init string and DON'T flush the buffers */ 673 /* Write the modem init string and DON'T flush the buffers */
674 if (options.flags & F_INITSTRING) { 674 if (options.flags & F_INITSTRING) {
675 debug("writing init string\n"); 675 debug("writing init string\n");
676 /* todo: use xwrite_str? */ 676 full_write1_str(options.initstring);
677 full_write(STDOUT_FILENO, options.initstring, strlen(options.initstring));
678 } 677 }
679 678
680 /* Optionally detect the baud rate from the modem status message */ 679 /* Optionally detect the baud rate from the modem status message */
diff --git a/mailutils/Config.src b/mailutils/Config.src
index baa04331a..2a9c5c074 100644
--- a/mailutils/Config.src
+++ b/mailutils/Config.src
@@ -1,5 +1,7 @@
1menu "Mail Utilities" 1menu "Mail Utilities"
2 2
3INSERT
4
3config MAKEMIME 5config MAKEMIME
4 bool "makemime" 6 bool "makemime"
5 default y 7 default y
diff --git a/mailutils/Kbuild.src b/mailutils/Kbuild.src
index 871e87981..b2fb73515 100644
--- a/mailutils/Kbuild.src
+++ b/mailutils/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_MAKEMIME) += mime.o mail.o 10lib-$(CONFIG_MAKEMIME) += mime.o mail.o
9lib-$(CONFIG_POPMAILDIR) += popmaildir.o mail.o 11lib-$(CONFIG_POPMAILDIR) += popmaildir.o mail.o
10lib-$(CONFIG_REFORMIME) += mime.o mail.o 12lib-$(CONFIG_REFORMIME) += mime.o mail.o
diff --git a/miscutils/Config.src b/miscutils/Config.src
index a822f2a19..012132e7b 100644
--- a/miscutils/Config.src
+++ b/miscutils/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Miscellaneous Utilities" 6menu "Miscellaneous Utilities"
7 7
8INSERT
9
8config ADJTIMEX 10config ADJTIMEX
9 bool "adjtimex" 11 bool "adjtimex"
10 default y 12 default y
@@ -547,7 +549,7 @@ config READAHEAD
547 549
548config RFKILL 550config RFKILL
549 bool "rfkill" 551 bool "rfkill"
550 default y 552 default n
551 help 553 help
552 Enable/disable wireless devices. 554 Enable/disable wireless devices.
553 555
diff --git a/miscutils/Kbuild.src b/miscutils/Kbuild.src
index 3c8ce42ba..d9bf14312 100644
--- a/miscutils/Kbuild.src
+++ b/miscutils/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_ADJTIMEX) += adjtimex.o 10lib-$(CONFIG_ADJTIMEX) += adjtimex.o
9lib-$(CONFIG_BBCONFIG) += bbconfig.o 11lib-$(CONFIG_BBCONFIG) += bbconfig.o
10lib-$(CONFIG_BEEP) += beep.o 12lib-$(CONFIG_BEEP) += beep.o
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c
index 689052e86..0d649b4e5 100644
--- a/miscutils/bbconfig.c
+++ b/miscutils/bbconfig.c
@@ -7,6 +7,6 @@
7int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 7int bbconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
8int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 8int bbconfig_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
9{ 9{
10 printf(bbconfig_config); 10 full_write1_str(bbconfig_config);
11 return 0; 11 return 0;
12} 12}
diff --git a/miscutils/ubi_attach_detach.c b/miscutils/ubi_attach_detach.c
new file mode 100644
index 000000000..7b92a8afc
--- /dev/null
+++ b/miscutils/ubi_attach_detach.c
@@ -0,0 +1,88 @@
1/* Ported to busybox from mtd-utils.
2 *
3 * Licensed under GPLv2, see file LICENSE in this tarball for details.
4 */
5
6//applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubiattach))
7//applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubidetach))
8
9//kbuild:lib-$(CONFIG_UBIATTACH) += ubi_attach_detach.o
10//kbuild:lib-$(CONFIG_UBIDETACH) += ubi_attach_detach.o
11
12//config:config UBIATTACH
13//config: bool "ubiattach"
14//config: default n
15//config: help
16//config: Attach MTD device to an UBI device.
17//config:
18//config:config UBIDETACH
19//config: bool "ubidetach"
20//config: default n
21//config: help
22//config: Detach MTD device from an UBI device.
23
24#include "libbb.h"
25#include <mtd/ubi-user.h>
26
27#define OPTION_M (1 << 0)
28#define OPTION_D (1 << 1)
29
30#define do_attach (ENABLE_UBIATTACH && \
31 (!ENABLE_UBIDETACH || (applet_name[3] == 'a')))
32
33//usage:#define ubiattach_trivial_usage
34//usage: "-m MTD_NUM [-d UBI_NUM] UBI_CTRL_DEV"
35//usage:#define ubiattach_full_usage "\n\n"
36//usage: "Attach MTD device to UBI\n"
37//usage: "\nOptions:"
38//usage: "\n -m MTD_NUM MTD device number to attach"
39//usage: "\n -d UBI_NUM UBI device number to assign"
40//usage:
41//usage:#define ubidetach_trivial_usage
42//usage: "-d UBI_NUM UBI_CTRL_DEV"
43//usage:#define ubidetach_full_usage "\n\n"
44//usage: "Detach MTD device from UBI\n"
45//usage: "\nOptions:"
46//usage: "\n -d UBI_NUM UBI device number"
47
48int ubi_attach_detach_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
49int ubi_attach_detach_main(int argc UNUSED_PARAM, char **argv)
50{
51 unsigned opts;
52 char *ubi_ctrl;
53 //struct stat st;
54 struct ubi_attach_req req;
55 int fd;
56 int mtd_num;
57 int dev_num = UBI_DEV_NUM_AUTO;
58
59 opt_complementary = "=1:m+:d+";
60 opts = getopt32(argv, "m:d:", &mtd_num, &dev_num);
61 ubi_ctrl = argv[optind];
62
63 fd = xopen(ubi_ctrl, O_RDWR);
64 //fstat(fd, &st);
65 //if (!S_ISCHR(st.st_mode))
66 // bb_error_msg_and_die("'%s' is not a char device", ubi_ctrl);
67
68 if (do_attach) {
69 if (!(opts & OPTION_M))
70 bb_error_msg_and_die("%s device not specified", "MTD");
71
72 memset(&req, 0, sizeof(req));
73 req.mtd_num = mtd_num;
74 req.ubi_num = dev_num;
75
76 xioctl(fd, UBI_IOCATT, &req);
77 } else { /* detach */
78 if (!(opts & OPTION_D))
79 bb_error_msg_and_die("%s device not specified", "UBI");
80
81 xioctl(fd, UBI_IOCDET, &dev_num);
82 }
83
84 if (ENABLE_FEATURE_CLEAN_UP)
85 close(fd);
86
87 return EXIT_SUCCESS;
88}
diff --git a/modutils/Kbuild.src b/modutils/Kbuild.src
index fc0808d7f..a512f6066 100644
--- a/modutils/Kbuild.src
+++ b/modutils/Kbuild.src
@@ -5,6 +5,7 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
8INSERT 9INSERT
9lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o 10lib-$(CONFIG_MODPROBE_SMALL) += modprobe-small.o
10lib-$(CONFIG_DEPMOD) += depmod.o modutils.o 11lib-$(CONFIG_DEPMOD) += depmod.o modutils.o
diff --git a/modutils/insmod.c b/modutils/insmod.c
index c4fb9279d..b88446c10 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -10,6 +10,28 @@
10#include "libbb.h" 10#include "libbb.h"
11#include "modutils.h" 11#include "modutils.h"
12 12
13/* 2.6 style insmod has no options and required filename
14 * (not module name - .ko can't be omitted) */
15
16//usage:#define insmod_trivial_usage
17//usage: IF_FEATURE_2_4_MODULES("[OPTIONS] MODULE ")
18//usage: IF_NOT_FEATURE_2_4_MODULES("FILE ")
19//usage: "[symbol=value]..."
20//usage:#define insmod_full_usage "\n\n"
21//usage: "Load the specified kernel modules into the kernel"
22//usage: IF_FEATURE_2_4_MODULES( "\n"
23//usage: "\nOptions:"
24//usage: "\n -f Force module to load into the wrong kernel version"
25//usage: "\n -k Make module autoclean-able"
26//usage: "\n -v Verbose"
27//usage: "\n -q Quiet"
28//usage: "\n -L Lock: prevent simultaneous loads"
29//usage: IF_FEATURE_INSMOD_LOAD_MAP(
30//usage: "\n -m Output load map to stdout"
31//usage: )
32//usage: "\n -x Don't export externs"
33//usage: )
34
13int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 35int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
14int insmod_main(int argc UNUSED_PARAM, char **argv) 36int insmod_main(int argc UNUSED_PARAM, char **argv)
15{ 37{
diff --git a/modutils/modinfo.c b/modutils/modinfo.c
index c68d2e974..321ad78f4 100644
--- a/modutils/modinfo.c
+++ b/modutils/modinfo.c
@@ -8,7 +8,7 @@
8 8
9//applet:IF_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_DROP)) 9//applet:IF_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_DROP))
10 10
11//kbuild:lib-$(CONFIG_MODINFO) += modinfo.o 11//kbuild:lib-$(CONFIG_MODINFO) += modinfo.o modutils.o
12 12
13//config:config MODINFO 13//config:config MODINFO
14//config: bool "modinfo" 14//config: bool "modinfo"
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index cf22b9471..0e1874ed4 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -685,6 +685,19 @@ The following options are useful for people managing distributions:
685 Use the file instead of the current kernel symbols 685 Use the file instead of the current kernel symbols
686*/ 686*/
687 687
688//usage:#if ENABLE_MODPROBE_SMALL
689//usage:#define modprobe_trivial_usage
690//usage: "[-qfwrsv] MODULE [symbol=value]..."
691//usage:#define modprobe_full_usage "\n\n"
692//usage: "Options:"
693//usage: "\n -r Remove MODULE (stacks) or do autoclean"
694//usage: "\n -q Quiet"
695//usage: "\n -v Verbose"
696//usage: "\n -f Force"
697//usage: "\n -w Wait for unload"
698//usage: "\n -s Report via syslog instead of stderr"
699//usage:#endif /* ENABLE_MODPROBE_SMALL */
700
688int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 701int modprobe_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
689int modprobe_main(int argc UNUSED_PARAM, char **argv) 702int modprobe_main(int argc UNUSED_PARAM, char **argv)
690{ 703{
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 69b9e4687..b4de65b1f 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -20,6 +20,104 @@
20//#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__) 20//#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__)
21#define DBG(...) ((void)0) 21#define DBG(...) ((void)0)
22 22
23//usage:#if !ENABLE_MODPROBE_SMALL
24//usage:#define modprobe_notes_usage
25//usage: "modprobe can (un)load a stack of modules, passing each module options (when\n"
26//usage: "loading). modprobe uses a configuration file to determine what option(s) to\n"
27//usage: "pass each module it loads.\n"
28//usage: "\n"
29//usage: "The configuration file is searched (in this order):\n"
30//usage: "\n"
31//usage: " /etc/modprobe.conf (2.6 only)\n"
32//usage: " /etc/modules.conf\n"
33//usage: " /etc/conf.modules (deprecated)\n"
34//usage: "\n"
35//usage: "They all have the same syntax (see below). If none is present, it is\n"
36//usage: "_not_ an error; each loaded module is then expected to load without\n"
37//usage: "options. Once a file is found, the others are tested for.\n"
38//usage: "\n"
39//usage: "/etc/modules.conf entry format:\n"
40//usage: "\n"
41//usage: " alias <alias_name> <mod_name>\n"
42//usage: " Makes it possible to modprobe alias_name, when there is no such module.\n"
43//usage: " It makes sense if your mod_name is long, or you want a more representative\n"
44//usage: " name for that module (eg. 'scsi' in place of 'aha7xxx').\n"
45//usage: " This makes it also possible to use a different set of options (below) for\n"
46//usage: " the module and the alias.\n"
47//usage: " A module can be aliased more than once.\n"
48//usage: "\n"
49//usage: " options <mod_name|alias_name> <symbol=value...>\n"
50//usage: " When loading module mod_name (or the module aliased by alias_name), pass\n"
51//usage: " the \"symbol=value\" pairs as option to that module.\n"
52//usage: "\n"
53//usage: "Sample /etc/modules.conf file:\n"
54//usage: "\n"
55//usage: " options tulip irq=3\n"
56//usage: " alias tulip tulip2\n"
57//usage: " options tulip2 irq=4 io=0x308\n"
58//usage: "\n"
59//usage: "Other functionality offered by 'classic' modprobe is not available in\n"
60//usage: "this implementation.\n"
61//usage: "\n"
62//usage: "If module options are present both in the config file, and on the command line,\n"
63//usage: "then the options from the command line will be passed to the module _after_\n"
64//usage: "the options from the config file. That way, you can have defaults in the config\n"
65//usage: "file, and override them for a specific usage from the command line.\n"
66//usage:#define modprobe_example_usage
67//usage: "(with the above /etc/modules.conf):\n\n"
68//usage: "$ modprobe tulip\n"
69//usage: " will load the module 'tulip' with default option 'irq=3'\n\n"
70//usage: "$ modprobe tulip irq=5\n"
71//usage: " will load the module 'tulip' with option 'irq=5', thus overriding the default\n\n"
72//usage: "$ modprobe tulip2\n"
73//usage: " will load the module 'tulip' with default options 'irq=4 io=0x308',\n"
74//usage: " which are the default for alias 'tulip2'\n\n"
75//usage: "$ modprobe tulip2 irq=8\n"
76//usage: " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=8',\n"
77//usage: " which are the default for alias 'tulip2' overridden by the option 'irq=8'\n\n"
78//usage: " from the command line\n\n"
79//usage: "$ modprobe tulip2 irq=2 io=0x210\n"
80//usage: " will load the module 'tulip' with default options 'irq=4 io=0x308 irq=4 io=0x210',\n"
81//usage: " which are the default for alias 'tulip2' overridden by the options 'irq=2 io=0x210'\n\n"
82//usage: " from the command line\n"
83//usage:
84//usage:#define modprobe_trivial_usage
85//usage: "[-alrqvs"
86//usage: IF_FEATURE_MODPROBE_BLACKLIST("b")
87//usage: "] MODULE [symbol=value]..."
88//usage:#define modprobe_full_usage "\n\n"
89//usage: "Options:"
90//usage: "\n -a Load multiple MODULEs"
91//usage: "\n -l List (MODULE is a pattern)"
92//usage: "\n -r Remove MODULE (stacks) or do autoclean"
93//usage: "\n -q Quiet"
94//usage: "\n -v Verbose"
95//usage: "\n -s Log to syslog"
96//usage: IF_FEATURE_MODPROBE_BLACKLIST(
97//usage: "\n -b Apply blacklist to module names too"
98//usage: )
99//usage:#endif /* !ENABLE_MODPROBE_SMALL */
100
101/* Note that usage text doesn't document various 2.4 options
102 * we pull in through INSMOD_OPTS define */
103
104#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--ar:a--lr:r--al"
105#define MODPROBE_OPTS "alr" IF_FEATURE_MODPROBE_BLACKLIST("b")
106//#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--acr:a--lr:r--al"
107//#define MODPROBE_OPTS "acd:lnrt:C:" IF_FEATURE_MODPROBE_BLACKLIST("b")
108enum {
109 MODPROBE_OPT_INSERT_ALL = (INSMOD_OPT_UNUSED << 0), /* a */
110 //MODPROBE_OPT_DUMP_ONLY= (INSMOD_OPT_UNUSED << x), /* c */
111 //MODPROBE_OPT_DIRNAME = (INSMOD_OPT_UNUSED << x), /* d */
112 MODPROBE_OPT_LIST_ONLY = (INSMOD_OPT_UNUSED << 1), /* l */
113 //MODPROBE_OPT_SHOW_ONLY= (INSMOD_OPT_UNUSED << x), /* n */
114 MODPROBE_OPT_REMOVE = (INSMOD_OPT_UNUSED << 2), /* r */
115 //MODPROBE_OPT_RESTRICT = (INSMOD_OPT_UNUSED << x), /* t */
116 //MODPROBE_OPT_VERONLY = (INSMOD_OPT_UNUSED << x), /* V */
117 //MODPROBE_OPT_CONFIGFILE=(INSMOD_OPT_UNUSED << x), /* C */
118 MODPROBE_OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 3) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
119};
120
23#define MODULE_FLAG_LOADED 0x0001 121#define MODULE_FLAG_LOADED 0x0001
24#define MODULE_FLAG_NEED_DEPS 0x0002 122#define MODULE_FLAG_NEED_DEPS 0x0002
25/* "was seen in modules.dep": */ 123/* "was seen in modules.dep": */
@@ -37,32 +135,6 @@ struct module_entry { /* I'll call it ME. */
37 llist_t *deps; /* strings. modules we depend on */ 135 llist_t *deps; /* strings. modules we depend on */
38}; 136};
39 137
40/* NB: INSMOD_OPT_SILENT bit suppresses ONLY non-existent modules,
41 * not deleted ones (those are still listed in modules.dep).
42 * module-init-tools version 3.4:
43 * # modprobe bogus
44 * FATAL: Module bogus not found. [exitcode 1]
45 * # modprobe -q bogus [silent, exitcode still 1]
46 * but:
47 * # rm kernel/drivers/net/dummy.ko
48 * # modprobe -q dummy
49 * FATAL: Could not open '/lib/modules/xxx/kernel/drivers/net/dummy.ko': No such file or directory
50 * [exitcode 1]
51 */
52#define MODPROBE_OPTS "acdlnrt:VC:" IF_FEATURE_MODPROBE_BLACKLIST("b")
53enum {
54 MODPROBE_OPT_INSERT_ALL = (INSMOD_OPT_UNUSED << 0), /* a */
55 MODPROBE_OPT_DUMP_ONLY = (INSMOD_OPT_UNUSED << 1), /* c */
56 MODPROBE_OPT_D = (INSMOD_OPT_UNUSED << 2), /* d */
57 MODPROBE_OPT_LIST_ONLY = (INSMOD_OPT_UNUSED << 3), /* l */
58 MODPROBE_OPT_SHOW_ONLY = (INSMOD_OPT_UNUSED << 4), /* n */
59 MODPROBE_OPT_REMOVE = (INSMOD_OPT_UNUSED << 5), /* r */
60 MODPROBE_OPT_RESTRICT = (INSMOD_OPT_UNUSED << 6), /* t */
61 MODPROBE_OPT_VERONLY = (INSMOD_OPT_UNUSED << 7), /* V */
62 MODPROBE_OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << 8), /* C */
63 MODPROBE_OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 9) * ENABLE_FEATURE_MODPROBE_BLACKLIST,
64};
65
66struct globals { 138struct globals {
67 llist_t *db; /* MEs of all modules ever seen (caching for speed) */ 139 llist_t *db; /* MEs of all modules ever seen (caching for speed) */
68 llist_t *probes; /* MEs of module(s) requested on cmdline */ 140 llist_t *probes; /* MEs of module(s) requested on cmdline */
@@ -264,6 +336,18 @@ static char *parse_and_add_kcmdline_module_options(char *options, const char *mo
264 * -errno on open/read error, 336 * -errno on open/read error,
265 * errno on init_module() error 337 * errno on init_module() error
266 */ 338 */
339/* NB: INSMOD_OPT_SILENT bit suppresses ONLY non-existent modules,
340 * not deleted ones (those are still listed in modules.dep).
341 * module-init-tools version 3.4:
342 * # modprobe bogus
343 * FATAL: Module bogus not found. [exitcode 1]
344 * # modprobe -q bogus [silent, exitcode still 1]
345 * but:
346 * # rm kernel/drivers/net/dummy.ko
347 * # modprobe -q dummy
348 * FATAL: Could not open '/lib/modules/xxx/kernel/drivers/net/dummy.ko': No such file or directory
349 * [exitcode 1]
350 */
267static int do_modprobe(struct module_entry *m) 351static int do_modprobe(struct module_entry *m)
268{ 352{
269 struct module_entry *m2 = m2; /* for compiler */ 353 struct module_entry *m2 = m2; /* for compiler */
@@ -395,13 +479,38 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
395 unsigned opt; 479 unsigned opt;
396 struct module_entry *me; 480 struct module_entry *me;
397 481
398 opt_complementary = "q-v:v-q"; 482 opt_complementary = MODPROBE_COMPLEMENTARY;
399 opt = getopt32(argv, INSMOD_OPTS MODPROBE_OPTS INSMOD_ARGS, NULL, NULL); 483 opt = getopt32(argv, INSMOD_OPTS MODPROBE_OPTS INSMOD_ARGS);
400 argv += optind; 484 argv += optind;
401 485
402 if (opt & (MODPROBE_OPT_DUMP_ONLY | MODPROBE_OPT_LIST_ONLY | 486 if (opt & MODPROBE_OPT_LIST_ONLY) {
403 MODPROBE_OPT_SHOW_ONLY)) 487 char name[MODULE_NAME_LEN];
404 bb_error_msg_and_die("not supported"); 488 char *colon, *tokens[2];
489 parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read);
490
491 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
492 colon = last_char_is(tokens[0], ':');
493 if (!colon)
494 continue;
495 *colon = '\0';
496 filename2modname(tokens[0], name);
497 if (!argv[0])
498 puts(tokens[0]);
499 else {
500 int i;
501 for (i = 0; argv[i]; i++) {
502 if (fnmatch(argv[i], name, 0) == 0) {
503 puts(tokens[0]);
504 }
505 }
506 }
507 }
508 return EXIT_SUCCESS;
509 }
510
511 /* Yes, for some reason -l ignores -s... */
512 if (opt & INSMOD_OPT_SYSLOG)
513 logmode = LOGMODE_SYSLOG;
405 514
406 if (!argv[0]) { 515 if (!argv[0]) {
407 if (opt & MODPROBE_OPT_REMOVE) { 516 if (opt & MODPROBE_OPT_REMOVE) {
diff --git a/modutils/modutils.h b/modutils/modutils.h
index 131a5087b..d46870ca6 100644
--- a/modutils/modutils.h
+++ b/modutils/modutils.h
@@ -23,32 +23,27 @@ int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
23char *filename2modname(const char *filename, char *modname) FAST_FUNC; 23char *filename2modname(const char *filename, char *modname) FAST_FUNC;
24char *parse_cmdline_module_options(char **argv) FAST_FUNC; 24char *parse_cmdline_module_options(char **argv) FAST_FUNC;
25 25
26/* insmod for 2.4 and modprobe's options (insmod 2.6 has no options at all): */
26#define INSMOD_OPTS \ 27#define INSMOD_OPTS \
27 "vq" \ 28 "vqs" \
28 IF_FEATURE_2_4_MODULES("sLo:fkx") \ 29 IF_FEATURE_2_4_MODULES("Lfkx" IF_FEATURE_INSMOD_LOAD_MAP("m"))
29 IF_FEATURE_INSMOD_LOAD_MAP("m") 30#define INSMOD_ARGS /* (was meant to support -o NAME) , NULL */
30
31#define INSMOD_ARGS IF_FEATURE_2_4_MODULES(, NULL)
32 31
33enum { 32enum {
34 INSMOD_OPT_VERBOSE = 0x0001, 33 INSMOD_OPT_VERBOSE = (1 << 0),
35 INSMOD_OPT_SILENT = 0x0002, 34 INSMOD_OPT_SILENT = (1 << 1),
36 INSMOD_OPT_SYSLOG = 0x0004 * ENABLE_FEATURE_2_4_MODULES, 35 INSMOD_OPT_SYSLOG = (1 << 2),
37 INSMOD_OPT_LOCK = 0x0008 * ENABLE_FEATURE_2_4_MODULES, 36 //INSMOD_OPT_OUTPUTNAME = (1 << x) - not supported yet
38 INSMOD_OPT_OUTPUTNAME = 0x0010 * ENABLE_FEATURE_2_4_MODULES, 37 INSMOD_OPT_LOCK = (1 << 3) * ENABLE_FEATURE_2_4_MODULES,
39 INSMOD_OPT_FORCE = 0x0020 * ENABLE_FEATURE_2_4_MODULES, 38 INSMOD_OPT_FORCE = (1 << 4) * ENABLE_FEATURE_2_4_MODULES,
40 INSMOD_OPT_KERNELD = 0x0040 * ENABLE_FEATURE_2_4_MODULES, 39 INSMOD_OPT_KERNELD = (1 << 5) * ENABLE_FEATURE_2_4_MODULES,
41 INSMOD_OPT_NO_EXPORT = 0x0080 * ENABLE_FEATURE_2_4_MODULES, 40 INSMOD_OPT_NO_EXPORT = (1 << 6) * ENABLE_FEATURE_2_4_MODULES,
42 INSMOD_OPT_PRINT_MAP = 0x0100 * ENABLE_FEATURE_INSMOD_LOAD_MAP, 41 INSMOD_OPT_PRINT_MAP = (1 << 7) * ENABLE_FEATURE_INSMOD_LOAD_MAP,
43#if ENABLE_FEATURE_2_4_MODULES 42 INSMOD_OPT_UNUSED =
44# if ENABLE_FEATURE_INSMOD_LOAD_MAP 43 (INSMOD_OPT_PRINT_MAP ? INSMOD_OPT_PRINT_MAP
45 INSMOD_OPT_UNUSED = 0x0200, 44 : INSMOD_OPT_NO_EXPORT ? INSMOD_OPT_NO_EXPORT
46# else 45 : INSMOD_OPT_SYSLOG
47 INSMOD_OPT_UNUSED = 0x0100, 46 ) << 1
48# endif
49#else
50 INSMOD_OPT_UNUSED = 0x0004,
51#endif
52}; 47};
53 48
54#if ENABLE_FEATURE_INSMOD_TRY_MMAP 49#if ENABLE_FEATURE_INSMOD_TRY_MMAP
diff --git a/networking/Config.src b/networking/Config.src
index eb8dc1ce2..ebad9e598 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Networking Utilities" 6menu "Networking Utilities"
7 7
8INSERT
9
8config FEATURE_IPV6 10config FEATURE_IPV6
9 bool "Enable IPv6 support" 11 bool "Enable IPv6 support"
10 default y 12 default y
@@ -859,6 +861,9 @@ config TFTPD
859 In other words: it should be run from inetd in nowait mode, 861 In other words: it should be run from inetd in nowait mode,
860 or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR" 862 or from udpsvd. Example: "udpsvd -E 0 69 tftpd DIR"
861 863
864comment "Common options for tftp/tftpd"
865 depends on TFTP || TFTPD
866
862config FEATURE_TFTP_GET 867config FEATURE_TFTP_GET
863 bool "Enable 'tftp get' and/or tftpd upload code" 868 bool "Enable 'tftp get' and/or tftpd upload code"
864 default y 869 default y
diff --git a/networking/Kbuild.src b/networking/Kbuild.src
index b0765bcf6..e1a4ebcb3 100644
--- a/networking/Kbuild.src
+++ b/networking/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_ARP) += arp.o interface.o 10lib-$(CONFIG_ARP) += arp.o interface.o
9lib-$(CONFIG_ARPING) += arping.o 11lib-$(CONFIG_ARPING) += arping.o
10lib-$(CONFIG_BRCTL) += brctl.o 12lib-$(CONFIG_BRCTL) += brctl.o
diff --git a/networking/libiproute/Kbuild.src b/networking/libiproute/Kbuild.src
index 5f9dd32b6..b0aa50a97 100644
--- a/networking/libiproute/Kbuild.src
+++ b/networking/libiproute/Kbuild.src
@@ -7,6 +7,8 @@
7 7
8lib-y:= 8lib-y:=
9 9
10INSERT
11
10lib-$(CONFIG_SLATTACH) += \ 12lib-$(CONFIG_SLATTACH) += \
11 utils.o 13 utils.o
12 14
diff --git a/networking/telnet.c b/networking/telnet.c
index ec3db0c5e..57997f6b9 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -418,7 +418,7 @@ static void to_echo(void)
418 put_iac2(DONT, TELOPT_ECHO); 418 put_iac2(DONT, TELOPT_ECHO);
419 419
420 setConMode(); 420 setConMode();
421 write_str(1, "\r\n"); /* sudden modec */ 421 full_write1_str("\r\n"); /* sudden modec */
422} 422}
423 423
424static void to_sga(void) 424static void to_sga(void)
@@ -637,7 +637,7 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
637 { 637 {
638 len = safe_read(netfd, G.buf, DATABUFSIZE); 638 len = safe_read(netfd, G.buf, DATABUFSIZE);
639 if (len <= 0) { 639 if (len <= 0) {
640 write_str(1, "Connection closed by foreign host\r\n"); 640 full_write1_str("Connection closed by foreign host\r\n");
641 doexit(EXIT_FAILURE); 641 doexit(EXIT_FAILURE);
642 } 642 }
643 TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); 643 TRACE(0, ("Read netfd (%d): %d\n", netfd, len));
diff --git a/networking/tftp.c b/networking/tftp.c
index ab4e25967..43ae13647 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -24,7 +24,8 @@
24 24
25#define TFTP_BLKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */ 25#define TFTP_BLKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */
26#define TFTP_BLKSIZE_DEFAULT_STR "512" 26#define TFTP_BLKSIZE_DEFAULT_STR "512"
27#define TFTP_TIMEOUT_MS 50 27/* Was 50 ms but users asked to bump it up a bit */
28#define TFTP_TIMEOUT_MS 100
28#define TFTP_MAXTIMEOUT_MS 2000 29#define TFTP_MAXTIMEOUT_MS 2000
29#define TFTP_NUM_RETRIES 12 /* number of backed-off retries */ 30#define TFTP_NUM_RETRIES 12 /* number of backed-off retries */
30 31
@@ -582,7 +583,8 @@ static int tftp_protocol(
582 * "An option not acknowledged by the server 583 * "An option not acknowledged by the server
583 * must be ignored by the client and server 584 * must be ignored by the client and server
584 * as if it were never requested." */ 585 * as if it were never requested." */
585 bb_error_msg("server only supports blocksize of 512"); 586 if (blksize != TFTP_BLKSIZE_DEFAULT)
587 bb_error_msg("falling back to blocksize "TFTP_BLKSIZE_DEFAULT_STR);
586 blksize = TFTP_BLKSIZE_DEFAULT; 588 blksize = TFTP_BLKSIZE_DEFAULT;
587 io_bufsize = TFTP_BLKSIZE_DEFAULT + 4; 589 io_bufsize = TFTP_BLKSIZE_DEFAULT + 4;
588 } 590 }
diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src
index f5840a945..aac88569b 100644
--- a/networking/udhcp/Config.src
+++ b/networking/udhcp/Config.src
@@ -3,6 +3,8 @@
3# see scripts/kbuild/config-language.txt. 3# see scripts/kbuild/config-language.txt.
4# 4#
5 5
6INSERT
7
6config UDHCPD 8config UDHCPD
7 bool "udhcp server (udhcpd)" 9 bool "udhcp server (udhcpd)"
8 default y 10 default y
diff --git a/networking/udhcp/Kbuild.src b/networking/udhcp/Kbuild.src
index 1803903f0..f845bc1d9 100644
--- a/networking/udhcp/Kbuild.src
+++ b/networking/udhcp/Kbuild.src
@@ -7,6 +7,8 @@
7 7
8lib-y:= 8lib-y:=
9 9
10INSERT
11
10lib-$(CONFIG_UDHCPC) += common.o packet.o signalpipe.o socket.o 12lib-$(CONFIG_UDHCPC) += common.o packet.o signalpipe.o socket.o
11lib-$(CONFIG_UDHCPD) += common.o packet.o signalpipe.o socket.o 13lib-$(CONFIG_UDHCPD) += common.o packet.o signalpipe.o socket.o
12 14
diff --git a/printutils/Config.src b/printutils/Config.src
index 194789660..cc4ab8d28 100644
--- a/printutils/Config.src
+++ b/printutils/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Print Utilities" 6menu "Print Utilities"
7 7
8INSERT
9
8config LPD 10config LPD
9 bool "lpd" 11 bool "lpd"
10 default y 12 default y
diff --git a/procps/Config.src b/procps/Config.src
index 01f6b0cf9..e61de5614 100644
--- a/procps/Config.src
+++ b/procps/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Process Utilities" 6menu "Process Utilities"
7 7
8INSERT
9
8config FREE 10config FREE
9 bool "free" 11 bool "free"
10 default y 12 default y
diff --git a/procps/Kbuild.src b/procps/Kbuild.src
index 8e62fdfa6..c41f12b15 100644
--- a/procps/Kbuild.src
+++ b/procps/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_FREE) += free.o 10lib-$(CONFIG_FREE) += free.o
9lib-$(CONFIG_FUSER) += fuser.o 11lib-$(CONFIG_FUSER) += fuser.o
10lib-$(CONFIG_KILL) += kill.o 12lib-$(CONFIG_KILL) += kill.o
diff --git a/procps/fuser.c b/procps/fuser.c
index 7465d4554..85523c31c 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -40,31 +40,6 @@ struct globals {
40#define INIT_G() do { } while (0) 40#define INIT_G() do { } while (0)
41 41
42 42
43static dev_t find_socket_dev(void)
44{
45 int fd = socket(AF_INET, SOCK_DGRAM, 0);
46 if (fd >= 0) {
47 struct stat buf;
48 int r = fstat(fd, &buf);
49 close(fd);
50 if (r == 0)
51 return buf.st_dev;
52 }
53 return 0;
54}
55
56static char *parse_net_arg(const char *arg, unsigned *port)
57{
58 char path[20], tproto[5];
59
60 if (sscanf(arg, "%u/%4s", port, tproto) != 2)
61 return NULL;
62 sprintf(path, "/proc/net/%s", tproto);
63 if (access(path, R_OK) != 0)
64 return NULL;
65 return xstrdup(path);
66}
67
68static void add_pid(const pid_t pid) 43static void add_pid(const pid_t pid)
69{ 44{
70 pid_list **curr = &G.pid_list_head; 45 pid_list **curr = &G.pid_list_head;
@@ -104,8 +79,15 @@ static void scan_proc_net(const char *path, unsigned port)
104 unsigned tmp_port; 79 unsigned tmp_port;
105 FILE *f; 80 FILE *f;
106 struct stat st; 81 struct stat st;
82 int fd;
107 83
108 st.st_dev = find_socket_dev(); 84 /* find socket dev */
85 st.st_dev = 0;
86 fd = socket(AF_INET, SOCK_DGRAM, 0);
87 if (fd >= 0) {
88 fstat(fd, &st);
89 close(fd);
90 }
109 91
110 f = fopen_for_read(path); 92 f = fopen_for_read(path);
111 if (!f) 93 if (!f)
@@ -284,11 +266,15 @@ Find processes which use FILEs or PORTs
284 266
285 pp = argv; 267 pp = argv;
286 while (*pp) { 268 while (*pp) {
287 char *path = parse_net_arg(*pp, &port); 269 /* parse net arg */
288 if (path) { /* PORT/PROTO */ 270 char path[20], tproto[5];
271 if (sscanf(*pp, "%u/%4s", &port, tproto) != 2)
272 goto file;
273 sprintf(path, "/proc/net/%s", tproto);
274 if (access(path, R_OK) != 0) { /* PORT/PROTO */
289 scan_proc_net(path, port); 275 scan_proc_net(path, port);
290 free(path);
291 } else { /* FILE */ 276 } else { /* FILE */
277 file:
292 xstat(*pp, &st); 278 xstat(*pp, &st);
293 add_inode(&st); 279 add_inode(&st);
294 } 280 }
diff --git a/runit/Config.src b/runit/Config.src
index 53b445101..9db974002 100644
--- a/runit/Config.src
+++ b/runit/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Runit Utilities" 6menu "Runit Utilities"
7 7
8INSERT
9
8config RUNSV 10config RUNSV
9 bool "runsv" 11 bool "runsv"
10 default y 12 default y
diff --git a/runit/Kbuild.src b/runit/Kbuild.src
index ab9eef6ff..4d85372df 100644
--- a/runit/Kbuild.src
+++ b/runit/Kbuild.src
@@ -5,6 +5,9 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
10
8lib-$(CONFIG_RUNSV) += runsv.o runit_lib.o 11lib-$(CONFIG_RUNSV) += runsv.o runit_lib.o
9lib-$(CONFIG_RUNSVDIR) += runsvdir.o runit_lib.o 12lib-$(CONFIG_RUNSVDIR) += runsvdir.o runit_lib.o
10lib-$(CONFIG_SV) += sv.o runit_lib.o 13lib-$(CONFIG_SV) += sv.o runit_lib.o
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index bbb575cec..1a5b10f84 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -243,22 +243,27 @@ void parse_config_file(char *map, size_t len)
243 if (!memcmp(p, "IF_NOT", 6)) goto conf7; 243 if (!memcmp(p, "IF_NOT", 6)) goto conf7;
244 } 244 }
245 /* we have at least 3 chars because of p <= end_3 */ 245 /* we have at least 3 chars because of p <= end_3 */
246 /*if (!memcmp(p, "IF_", 3)) goto conf3;*/ 246 /*if (!memcmp(p, "IF_", 3)) ...*/
247 if (p[0] == 'I' && p[1] == 'F' && p[2] == '_') goto conf3; 247 if (p[0] == 'I' && p[1] == 'F' && p[2] == '_') {
248 off = 3;
249 goto conf;
250 }
248 251
249 /* This identifier is not interesting, skip it */ 252 /* This identifier is not interesting, skip it */
250 while (p <= end_3 && (isalnum(*p) || *p == '_')) 253 while (p <= end_3 && (isalnum(*p) || *p == '_'))
251 p++; 254 p++;
252 continue; 255 continue;
253 256
254 conf3: off = 3;
255 conf7: off = 7; 257 conf7: off = 7;
258 conf:
256 p += off; 259 p += off;
257 for (q = p; q < end_3+3; q++) { 260 for (q = p; q < end_3+3; q++) {
258 if (!(isalnum(*q) || *q == '_')) 261 if (!(isalnum(*q) || *q == '_'))
259 break; 262 break;
260 } 263 }
261 use_config(p, q-p); 264 if (q != p) {
265 use_config(p, q-p);
266 }
262 } 267 }
263} 268}
264 269
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
index 60934b5b1..e328788e2 100644
--- a/scripts/basic/split-include.c
+++ b/scripts/basic/split-include.c
@@ -110,11 +110,12 @@ int main(int argc, const char * argv [])
110 110
111 if (line[0] != '#') 111 if (line[0] != '#')
112 continue; 112 continue;
113 if ((str_config = strstr(line, "CONFIG_")) == NULL) 113 if ((str_config = strstr(line, " CONFIG_")) == NULL)
114 continue; 114 continue;
115 115
116 /* Make the output file name. */ 116 /* We found #define CONFIG_foo or #undef CONFIG_foo.
117 str_config += sizeof("CONFIG_") - 1; 117 * Make the output file name. */
118 str_config += sizeof(" CONFIG_") - 1;
118 for (itarget = 0; !isspace(str_config[itarget]); itarget++) 119 for (itarget = 0; !isspace(str_config[itarget]); itarget++)
119 { 120 {
120 int c = (unsigned char) str_config[itarget]; 121 int c = (unsigned char) str_config[itarget];
diff --git a/scripts/echo.c b/scripts/echo.c
index 85a8aa913..3c45e339c 100644
--- a/scripts/echo.c
+++ b/scripts/echo.c
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
187 putchar('\n'); 187 putchar('\n');
188 } 188 }
189 ret: 189 ret:
190 return fflush_all(); 190 return fflush(NULL);
191} 191}
192 192
193/*- 193/*-
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index acabe385c..d34dfd46d 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -56,7 +56,7 @@ EOF
56} 56}
57 57
58usage() { 58usage() {
59 printf "Usage: $0 [-check compiler options|-header|-library]\n" 59 printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
60} 60}
61 61
62if [ $# -eq 0 ]; then 62if [ $# -eq 0 ]; then
diff --git a/scripts/mkconfigs b/scripts/mkconfigs
index 0d1771a36..ef6ae8aaf 100755
--- a/scripts/mkconfigs
+++ b/scripts/mkconfigs
@@ -42,9 +42,8 @@ echo "\
42 * 42 *
43 * This file is generated automatically by scripts/mkconfigs. 43 * This file is generated automatically by scripts/mkconfigs.
44 * Do not edit. 44 * Do not edit.
45 *
46 */ 45 */
47static const char *const bbconfig_config =" 46static const char bbconfig_config[] ="
48 47
49sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}' 48sed 's/\"/\\\"/g' $config | grep "^#\? \?CONFIG_" | awk '{print "\"" $0 "\\n\"";}'
50 49
diff --git a/selinux/Config.src b/selinux/Config.src
index e46030adf..64a99203e 100644
--- a/selinux/Config.src
+++ b/selinux/Config.src
@@ -6,6 +6,8 @@
6menu "SELinux Utilities" 6menu "SELinux Utilities"
7 depends on SELINUX 7 depends on SELINUX
8 8
9INSERT
10
9config CHCON 11config CHCON
10 bool "chcon" 12 bool "chcon"
11 default n 13 default n
diff --git a/selinux/Kbuild.src b/selinux/Kbuild.src
index d0c190ceb..6567e3c07 100644
--- a/selinux/Kbuild.src
+++ b/selinux/Kbuild.src
@@ -6,6 +6,8 @@
6# Licensed under the GPL v2, see the file LICENSE in this tarball. 6# Licensed under the GPL v2, see the file LICENSE in this tarball.
7 7
8lib-y:= 8lib-y:=
9
10INSERT
9lib-$(CONFIG_CHCON) += chcon.o 11lib-$(CONFIG_CHCON) += chcon.o
10lib-$(CONFIG_GETENFORCE) += getenforce.o 12lib-$(CONFIG_GETENFORCE) += getenforce.o
11lib-$(CONFIG_GETSEBOOL) += getsebool.o 13lib-$(CONFIG_GETSEBOOL) += getsebool.o
diff --git a/shell/Config.src b/shell/Config.src
index 234d05367..800911966 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -5,57 +5,7 @@
5 5
6menu "Shells" 6menu "Shells"
7 7
8choice 8INSERT
9 prompt "Choose which shell is aliased to 'sh' name"
10 default FEATURE_SH_IS_ASH
11 help
12 Choose which shell you want to be executed by 'sh' alias.
13 The ash shell is the most bash compatible and full featured one.
14
15config FEATURE_SH_IS_ASH
16 select ASH
17 bool "ash"
18 depends on !NOMMU
19
20config FEATURE_SH_IS_HUSH
21 select HUSH
22 bool "hush"
23
24config FEATURE_SH_IS_NONE
25 bool "none"
26
27endchoice
28
29choice
30 prompt "Choose which shell is aliased to 'bash' name"
31 default FEATURE_BASH_IS_NONE
32 help
33 Choose which shell you want to be executed by 'bash' alias.
34 The ash shell is the most bash compatible and full featured one.
35
36 Note that selecting this option does not switch on any bash
37 compatibility code. It merely makes it possible to install
38 /bin/bash (sym)link and run scripts which start with
39 #!/bin/bash line.
40
41 Many systems use it in scripts which use bash-specific features,
42 even simple ones like $RANDOM. Without this option, busybox
43 can't be used for running them because it won't recongnize
44 "bash" as a supported applet name.
45
46config FEATURE_BASH_IS_ASH
47 select ASH
48 bool "ash"
49 depends on !NOMMU
50
51config FEATURE_BASH_IS_HUSH
52 select HUSH
53 bool "hush"
54
55config FEATURE_BASH_IS_NONE
56 bool "none"
57
58endchoice
59 9
60config ASH 10config ASH
61 bool "ash" 11 bool "ash"
@@ -266,6 +216,61 @@ config HUSH_RANDOM_SUPPORT
266 Enable pseudorandom generator and dynamic variable "$RANDOM". 216 Enable pseudorandom generator and dynamic variable "$RANDOM".
267 Each read of "$RANDOM" will generate a new pseudorandom value. 217 Each read of "$RANDOM" will generate a new pseudorandom value.
268 218
219
220choice
221 prompt "Choose which shell is aliased to 'sh' name"
222 default FEATURE_SH_IS_ASH
223 help
224 Choose which shell you want to be executed by 'sh' alias.
225 The ash shell is the most bash compatible and full featured one.
226
227# note: cannot use "select ASH" here, it breaks "make allnoconfig"
228config FEATURE_SH_IS_ASH
229 depends on ASH
230 bool "ash"
231 depends on !NOMMU
232
233config FEATURE_SH_IS_HUSH
234 depends on HUSH
235 bool "hush"
236
237config FEATURE_SH_IS_NONE
238 bool "none"
239
240endchoice
241
242choice
243 prompt "Choose which shell is aliased to 'bash' name"
244 default FEATURE_BASH_IS_NONE
245 help
246 Choose which shell you want to be executed by 'bash' alias.
247 The ash shell is the most bash compatible and full featured one.
248
249 Note that selecting this option does not switch on any bash
250 compatibility code. It merely makes it possible to install
251 /bin/bash (sym)link and run scripts which start with
252 #!/bin/bash line.
253
254 Many systems use it in scripts which use bash-specific features,
255 even simple ones like $RANDOM. Without this option, busybox
256 can't be used for running them because it won't recongnize
257 "bash" as a supported applet name.
258
259config FEATURE_BASH_IS_ASH
260 depends on ASH
261 bool "ash"
262 depends on !NOMMU
263
264config FEATURE_BASH_IS_HUSH
265 depends on HUSH
266 bool "hush"
267
268config FEATURE_BASH_IS_NONE
269 bool "none"
270
271endchoice
272
273
269config LASH 274config LASH
270 bool "lash (deprecated: aliased to hush)" 275 bool "lash (deprecated: aliased to hush)"
271 default n 276 default n
diff --git a/shell/Kbuild.src b/shell/Kbuild.src
index 8bdb68b11..d76b35386 100644
--- a/shell/Kbuild.src
+++ b/shell/Kbuild.src
@@ -5,6 +5,9 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
10
8lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o 11lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o
9lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o 12lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o
10lib-$(CONFIG_CTTYHACK) += cttyhack.o 13lib-$(CONFIG_CTTYHACK) += cttyhack.o
diff --git a/shell/hush.c b/shell/hush.c
index 4cccf31a4..4832e2c48 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7103,7 +7103,7 @@ int hush_main(int argc, char **argv)
7103 break; 7103 break;
7104#if !BB_MMU 7104#if !BB_MMU
7105 case '<': /* "big heredoc" support */ 7105 case '<': /* "big heredoc" support */
7106 full_write(STDOUT_FILENO, optarg, strlen(optarg)); 7106 full_write1_str(optarg);
7107 _exit(0); 7107 _exit(0);
7108 case '$': { 7108 case '$': {
7109 unsigned long long empty_trap_mask; 7109 unsigned long long empty_trap_mask;
diff --git a/sysklogd/Config.src b/sysklogd/Config.src
index af00d65bb..6d574abb1 100644
--- a/sysklogd/Config.src
+++ b/sysklogd/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "System Logging Utilities" 6menu "System Logging Utilities"
7 7
8INSERT
9
8config SYSLOGD 10config SYSLOGD
9 bool "syslogd" 11 bool "syslogd"
10 default y 12 default y
diff --git a/sysklogd/Kbuild.src b/sysklogd/Kbuild.src
index d802198e6..faaac110c 100644
--- a/sysklogd/Kbuild.src
+++ b/sysklogd/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_KLOGD) += klogd.o 10lib-$(CONFIG_KLOGD) += klogd.o
9lib-$(CONFIG_LOGGER) += syslogd_and_logger.o 11lib-$(CONFIG_LOGGER) += syslogd_and_logger.o
10lib-$(CONFIG_LOGREAD) += logread.o 12lib-$(CONFIG_LOGREAD) += logread.o
diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests
index 725e70eab..42e3ff8dc 100755
--- a/testsuite/cpio.tests
+++ b/testsuite/cpio.tests
@@ -40,8 +40,7 @@ ls -ln cpio.testdir | $FILTER_LS" \
400 400
41-rw-r--r-- 2 $user $group 0 x 41-rw-r--r-- 2 $user $group 0 x
42-rw-r--r-- 2 $user $group 0 y 42-rw-r--r-- 2 $user $group 0 y
43" \ 43" "" ""
44 "" ""
45SKIP= 44SKIP=
46 45
47 46
@@ -56,8 +55,7 @@ cpio.testdir/x
56cpio.testdir/y 55cpio.testdir/y
571 blocks 561 blocks
580 570
59" \ 58" "" ""
60 "" ""
61} 59}
62 60
63 61
@@ -83,11 +81,9 @@ ls -ln cpio.testdir2/cpio.testdir | $FILTER_LS" \
83-rw-r--r-- 2 $user $group 2 nonempty 81-rw-r--r-- 2 $user $group 2 nonempty
84-rw-r--r-- 2 $user $group 2 nonempty1 82-rw-r--r-- 2 $user $group 2 nonempty1
85-rw-r--r-- 1 $user $group 0 solo 83-rw-r--r-- 1 $user $group 0 solo
86" \ 84" "" ""
87 "" ""
88SKIP= 85SKIP=
89 86
90
91# Was trying to create "/usr/bin", correct is "usr/bin". 87# Was trying to create "/usr/bin", correct is "usr/bin".
92rm -rf cpio.testdir 88rm -rf cpio.testdir
93optional FEATURE_CPIO_P 89optional FEATURE_CPIO_P
@@ -98,8 +94,24 @@ ls cpio.testdir" \
981 blocks 941 blocks
990 950
100usr 96usr
101" \ 97" "" ""
102 "" "" 98SKIP=
99
100# chown on a link was affecting file, dropping its sgid bits
101rm -rf cpio.testdir
102optional FEATURE_CPIO_O
103mkdir cpio.testdir
104touch cpio.testdir/file
105chmod 6755 cpio.testdir/file # set the suid/sgid bit
106ln -sf file cpio.testdir/link
107testing "cpio restores sgid bits" \
108"cd cpio.testdir && { echo file; echo link; } | cpio -ovHnewc >pack.cpio && rm ???? && cpio -idmvu <pack.cpio 2>/dev/null;
109 stat -c '%a %n' file" \
110"\
111file
112link
1136755 file
114" "" ""
103SKIP= 115SKIP=
104 116
105 117
diff --git a/testsuite/xargs.tests b/testsuite/xargs.tests
index 17f4e7a1b..6463252bf 100755
--- a/testsuite/xargs.tests
+++ b/testsuite/xargs.tests
@@ -26,4 +26,19 @@ testing "xargs does not stop on underscore ('new' GNU behavior)" \
26 "a _ b\n" \ 26 "a _ b\n" \
27 "" "a\n_\nb\n" 27 "" "a\n_\nb\n"
28 28
29testing "xargs -s7 can take one-char input" \
30 "xargs -s7 echo" \
31 "a\n" \
32 "" "a\n"
33
34testing "xargs -sNUM test 1" \
35 "xargs -ts25 echo 2>&1 >/dev/null" \
36 "echo 1 2 3 4 5 6 7 8 9 0\n""echo 1 2 3 4 5 6 7 8 9\n""echo 00\n" \
37 "" "1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 00\n"
38
39testing "xargs -sNUM test 2" \
40 "xargs -ts25 echo 1 2>&1 >/dev/null" \
41 "echo 1 2 3 4 5 6 7 8 9 0\n""echo 1 2 3 4 5 6 7 8 9\n""echo 1 00\n" \
42 "" "2 3 4 5 6 7 8 9 0 2 3 4 5 6 7 8 9 00\n"
43
29exit $FAILCOUNT 44exit $FAILCOUNT
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 997cdec83..e97125917 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -5,6 +5,8 @@
5 5
6menu "Linux System Utilities" 6menu "Linux System Utilities"
7 7
8INSERT
9
8config ACPID 10config ACPID
9 bool "acpid" 11 bool "acpid"
10 default y 12 default y
diff --git a/util-linux/Kbuild.src b/util-linux/Kbuild.src
index 4fa392398..afc0db50e 100644
--- a/util-linux/Kbuild.src
+++ b/util-linux/Kbuild.src
@@ -5,6 +5,8 @@
5# Licensed under the GPL v2, see the file LICENSE in this tarball. 5# Licensed under the GPL v2, see the file LICENSE in this tarball.
6 6
7lib-y:= 7lib-y:=
8
9INSERT
8lib-$(CONFIG_ACPID) += acpid.o 10lib-$(CONFIG_ACPID) += acpid.o
9lib-$(CONFIG_BLKID) += blkid.o 11lib-$(CONFIG_BLKID) += blkid.o
10lib-$(CONFIG_DMESG) += dmesg.o 12lib-$(CONFIG_DMESG) += dmesg.o
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index e44773a07..0f5914c88 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -23,7 +23,7 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
23 }; 23 };
24 24
25 /* max 2 args, all opts are mutually exclusive */ 25 /* max 2 args, all opts are mutually exclusive */
26 opt_complementary = "?2:d--of:o--df:f-do"; 26 opt_complementary = "?2:d--of:o--df:f--do";
27 opt = getopt32(argv, "do:f", &opt_o); 27 opt = getopt32(argv, "do:f", &opt_o);
28 argv += optind; 28 argv += optind;
29 29
diff --git a/util-linux/volume_id/Kbuild.src b/util-linux/volume_id/Kbuild.src
index 3520f2480..8af3ccd81 100644
--- a/util-linux/volume_id/Kbuild.src
+++ b/util-linux/volume_id/Kbuild.src
@@ -6,6 +6,8 @@
6 6
7lib-y:= 7lib-y:=
8 8
9INSERT
10
9lib-$(CONFIG_BLKID) += get_devname.o 11lib-$(CONFIG_BLKID) += get_devname.o
10lib-$(CONFIG_FINDFS) += get_devname.o 12lib-$(CONFIG_FINDFS) += get_devname.o
11lib-$(CONFIG_FEATURE_MOUNT_LABEL) += get_devname.o 13lib-$(CONFIG_FEATURE_MOUNT_LABEL) += get_devname.o