aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-09-27 10:08:12 +0100
committerRon Yorston <rmy@pobox.com>2017-09-27 10:11:19 +0100
commitd9383e984da8de72e61e5094a3cf6404c5707ddc (patch)
treedd42825854fc42aea40d4f7a95548d53721d1733
parent166b3e4e82799f87d3b002c7177891111eff079e (diff)
parent0c4dbd481aedb5d22c1048e7f7eb547a3b5e50a5 (diff)
downloadbusybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.gz
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.bz2
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.zip
Merge branch 'busybox' into merge
-rw-r--r--NOFORK_NOEXEC.lst20
-rw-r--r--archival/ar.c2
-rw-r--r--archival/bbunzip.c6
-rw-r--r--archival/bzip2.c2
-rw-r--r--archival/cpio.c9
-rw-r--r--archival/dpkg.c2
-rw-r--r--archival/dpkg_deb.c1
-rw-r--r--archival/gzip.c2
-rw-r--r--archival/lzop.c2
-rw-r--r--archival/tar.c2
-rw-r--r--console-tools/clear.c4
-rw-r--r--console-tools/dumpkmap.c1
-rw-r--r--console-tools/reset.c8
-rw-r--r--coreutils/ls.c10
-rw-r--r--coreutils/printf.c1
-rw-r--r--coreutils/shuf.c4
-rw-r--r--coreutils/stty.c22
-rw-r--r--editors/awk.c1
-rw-r--r--editors/cmp.c11
-rw-r--r--editors/diff.c6
-rw-r--r--editors/patch.c1
-rw-r--r--editors/sed.c21
-rw-r--r--editors/vi.c23
-rw-r--r--findutils/find.c3
-rw-r--r--findutils/grep.c1
-rw-r--r--findutils/xargs.c176
-rw-r--r--include/libbb.h3
-rw-r--r--init/bootchartd.c9
-rw-r--r--init/halt.c1
-rw-r--r--init/init.c1
-rw-r--r--klibc-utils/ipconfig.c.txt316
-rw-r--r--klibc-utils/nuke.c2
-rw-r--r--klibc-utils/resume.c2
-rw-r--r--libbb/getopt32.c2
-rw-r--r--libbb/lineedit.c26
-rw-r--r--libbb/u_signal_names.c1
-rw-r--r--libbb/xfuncs.c55
-rw-r--r--loginutils/addgroup.c1
-rw-r--r--miscutils/beep.c1
-rw-r--r--miscutils/chat.c10
-rw-r--r--miscutils/fbsplash.c6
-rw-r--r--miscutils/hexedit.c465
-rw-r--r--miscutils/i2c_tools.c109
-rw-r--r--miscutils/less.c28
-rw-r--r--miscutils/microcom.c14
-rw-r--r--miscutils/nandwrite.c1
-rw-r--r--miscutils/raidautorun.c1
-rw-r--r--miscutils/rfkill.c13
-rw-r--r--miscutils/setfattr.c68
-rw-r--r--miscutils/setserial.c1
-rw-r--r--miscutils/ubi_tools.c1
-rw-r--r--networking/hostname.c1
-rw-r--r--networking/httpd.c9
-rw-r--r--networking/ifupdown.c1
-rw-r--r--networking/interface.c7
-rw-r--r--networking/ip.c14
-rw-r--r--networking/nameif.c1
-rw-r--r--networking/nbd-client.c16
-rw-r--r--networking/nc.c17
-rw-r--r--networking/ntpd.c2
-rw-r--r--networking/ping.c43
-rw-r--r--networking/udhcp/d6_dhcpc.c1
-rw-r--r--networking/udhcp/dhcpc.c39
-rw-r--r--networking/vconfig.c5
-rw-r--r--networking/wget.c1
-rw-r--r--networking/whois.c1
-rw-r--r--procps/iostat.c1
-rw-r--r--procps/kill.c5
-rw-r--r--procps/lsof.c1
-rw-r--r--procps/mpstat.c11
-rw-r--r--procps/nmeter.c1
-rw-r--r--procps/pmap.c2
-rw-r--r--procps/powertop.c6
-rw-r--r--procps/pwdx.c1
-rw-r--r--procps/smemcap.c9
-rw-r--r--procps/top.c9
-rw-r--r--procps/watch.c11
-rw-r--r--runit/svlogd.c1
-rw-r--r--scripts/kconfig/conf.c56
-rw-r--r--selinux/setfiles.c14
-rw-r--r--shell/ash.c14
-rw-r--r--shell/ash_test/ash-getopts/getopt_nested.right14
-rwxr-xr-xshell/ash_test/ash-getopts/getopt_nested.tests21
-rw-r--r--shell/cttyhack.c12
-rw-r--r--shell/hush.c80
-rw-r--r--shell/hush_test/hush-getopts/getopt_nested.right14
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_nested.tests21
-rwxr-xr-xshell/hush_test/hush-vars/unset.tests6
-rw-r--r--shell/shell_common.c4
-rwxr-xr-xtestsuite/sed.tests6
-rw-r--r--util-linux/fallocate.c1
-rw-r--r--util-linux/fsfreeze.c1
-rw-r--r--util-linux/fstrim.c1
-rw-r--r--util-linux/mdev.c1
-rw-r--r--util-linux/mesg.c1
-rw-r--r--util-linux/nsenter.c1
-rw-r--r--util-linux/rdev.c1
-rw-r--r--util-linux/setpriv.c8
-rw-r--r--util-linux/taskset.c2
-rw-r--r--util-linux/volume_id/bcache.c5
-rw-r--r--util-linux/volume_id/btrfs.c5
-rw-r--r--util-linux/volume_id/cramfs.c5
-rw-r--r--util-linux/volume_id/exfat.c5
-rw-r--r--util-linux/volume_id/ext.c5
-rw-r--r--util-linux/volume_id/f2fs.c5
-rw-r--r--util-linux/volume_id/fat.c5
-rw-r--r--util-linux/volume_id/hfs.c5
-rw-r--r--util-linux/volume_id/iso9660.c5
-rw-r--r--util-linux/volume_id/jfs.c5
-rw-r--r--util-linux/volume_id/linux_raid.c5
-rw-r--r--util-linux/volume_id/linux_swap.c5
-rw-r--r--util-linux/volume_id/luks.c5
-rw-r--r--util-linux/volume_id/nilfs.c5
-rw-r--r--util-linux/volume_id/ntfs.c5
-rw-r--r--util-linux/volume_id/ocfs2.c5
-rw-r--r--util-linux/volume_id/reiserfs.c5
-rw-r--r--util-linux/volume_id/romfs.c5
-rw-r--r--util-linux/volume_id/squashfs.c5
-rw-r--r--util-linux/volume_id/sysv.c5
-rw-r--r--util-linux/volume_id/ubifs.c5
-rw-r--r--util-linux/volume_id/udf.c5
-rw-r--r--util-linux/volume_id/unused_highpoint.c5
-rw-r--r--util-linux/volume_id/unused_hpfs.c5
-rw-r--r--util-linux/volume_id/unused_isw_raid.c5
-rw-r--r--util-linux/volume_id/unused_lsi_raid.c5
-rw-r--r--util-linux/volume_id/unused_lvm.c5
-rw-r--r--util-linux/volume_id/unused_mac.c5
-rw-r--r--util-linux/volume_id/unused_msdos.c5
-rw-r--r--util-linux/volume_id/unused_nvidia_raid.c5
-rw-r--r--util-linux/volume_id/unused_promise_raid.c5
-rw-r--r--util-linux/volume_id/unused_silicon_raid.c5
-rw-r--r--util-linux/volume_id/unused_ufs.c5
-rw-r--r--util-linux/volume_id/unused_via_raid.c5
-rw-r--r--util-linux/volume_id/xfs.c5
-rw-r--r--util-linux/wall.c1
135 files changed, 1628 insertions, 521 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst
index 3070a321b..4e53d7204 100644
--- a/NOFORK_NOEXEC.lst
+++ b/NOFORK_NOEXEC.lst
@@ -166,6 +166,7 @@ hd - noexec. runner
166hdparm - hardware 166hdparm - hardware
167head - noexec. runner 167head - noexec. runner
168hexdump - noexec. runner 168hexdump - noexec. runner
169hexedit - interactive, longterm
169hostid - NOFORK 170hostid - NOFORK
170hostname - noexec. talks to network (hostname -d may query DNS) 171hostname - noexec. talks to network (hostname -d may query DNS)
171httpd - daemon 172httpd - daemon
@@ -186,16 +187,16 @@ insmod - noexec
186install - runner 187install - runner
187ionice - noexec. spawner 188ionice - noexec. spawner
188iostat - longterm: "iostat 1" runs indefinitely 189iostat - longterm: "iostat 1" runs indefinitely
189ip - noexec candidate 190ip - noexec
190ipaddr - noexec candidate 191ipaddr - noexec
191ipcalc - noexec. ipcalc -h talks to network 192ipcalc - noexec. ipcalc -h talks to network
192ipcrm - noexec 193ipcrm - noexec
193ipcs - noexec 194ipcs - noexec
194iplink - noexec candidate 195iplink - noexec
195ipneigh - noexec candidate 196ipneigh - noexec
196iproute - noexec candidate 197iproute - noexec
197iprule - noexec candidate 198iprule - noexec
198iptunnel - noexec candidate 199iptunnel - noexec
199kbd_mode - noexec. leaks: xopen_nonblocking+xioctl 200kbd_mode - noexec. leaks: xopen_nonblocking+xioctl
200kill - NOFORK 201kill - NOFORK
201killall - NOFORK 202killall - NOFORK
@@ -235,6 +236,7 @@ md5sum - noexec. runner
235mdev - daemon 236mdev - daemon
236mesg - NOFORK 237mesg - NOFORK
237microcom - interactive, longterm 238microcom - interactive, longterm
239minips - noexec
238mkdir - NOFORK 240mkdir - NOFORK
239mkdosfs - needs ^C 241mkdosfs - needs ^C
240mke2fs - needs ^C 242mke2fs - needs ^C
@@ -264,6 +266,7 @@ nmeter - longterm
264nohup - noexec. spawner 266nohup - noexec. spawner
265nproc - NOFORK 267nproc - NOFORK
266ntpd - daemon 268ntpd - daemon
269nuke - noexec
267od - runner 270od - runner
268openvt - longterm: spawns a child and waits for it 271openvt - longterm: spawns a child and waits for it
269partprobe - noexec. leaks: open+ioctl_or_perror_and_die(BLKRRPART) 272partprobe - noexec. leaks: open+ioctl_or_perror_and_die(BLKRRPART)
@@ -300,6 +303,7 @@ remove-shell - noexec. leaks: open+xfunc
300renice - noexec. nofork candidate(uses getpwnam, is that ok?) 303renice - noexec. nofork candidate(uses getpwnam, is that ok?)
301reset - noexec. spawner (execs "stty") 304reset - noexec. spawner (execs "stty")
302resize - noexec. changes state (signal handlers) 305resize - noexec. changes state (signal handlers)
306resume - noexec
303rev - runner 307rev - runner
304rm - noexec. rm -i interactive 308rm - noexec. rm -i interactive
305rmdir - NOFORK 309rmdir - NOFORK
@@ -308,6 +312,7 @@ route - talks to network (may query DNS to convert IPs to names)
308rpm - runner 312rpm - runner
309rpm2cpio - runner 313rpm2cpio - runner
310rtcwake - longterm: puts system to sleep, optimizing this for speed is pointless 314rtcwake - longterm: puts system to sleep, optimizing this for speed is pointless
315run-init - spawner, rare, changes state (oh yes), execing may be important to free binary's inode
311run-parts - longterm 316run-parts - longterm
312runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother? 317runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother?
313runsv - daemon 318runsv - daemon
@@ -320,6 +325,7 @@ sendmail - runner
320seq - noexec. runner 325seq - noexec. runner
321setarch - noexec. spawner 326setarch - noexec. spawner
322setconsole - noexec 327setconsole - noexec
328setfattr - noexec
323setfont - noexec. leaks a lot of stuff 329setfont - noexec. leaks a lot of stuff
324setkeycodes - noexec 330setkeycodes - noexec
325setlogcons - noexec 331setlogcons - noexec
diff --git a/archival/ar.c b/archival/ar.c
index d113bc6ca..9dc070390 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -16,7 +16,6 @@
16 * between different systems 16 * between different systems
17 * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html 17 * http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
18 */ 18 */
19
20//config:config AR 19//config:config AR
21//config: bool "ar (9.5 kb)" 20//config: bool "ar (9.5 kb)"
22//config: default n # needs to be improved to be able to replace binutils ar 21//config: default n # needs to be improved to be able to replace binutils ar
@@ -46,6 +45,7 @@
46//config: This enables archive creation (-c and -r) with busybox ar. 45//config: This enables archive creation (-c and -r) with busybox ar.
47 46
48//applet:IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP)) 47//applet:IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
48
49//kbuild:lib-$(CONFIG_AR) += ar.o 49//kbuild:lib-$(CONFIG_AR) += ar.o
50 50
51//usage:#define ar_trivial_usage 51//usage:#define ar_trivial_usage
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 34a2e8e96..301170fd4 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -4,9 +4,6 @@
4 * 4 *
5 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6 */ 6 */
7#include "libbb.h"
8#include "bb_archive.h"
9
10//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o 7//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
11//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o 8//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
12//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o 9//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
@@ -21,6 +18,9 @@
21/* gzip_main() too: */ 18/* gzip_main() too: */
22//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o 19//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
23 20
21#include "libbb.h"
22#include "bb_archive.h"
23
24/* Note: must be kept in sync with archival/lzop.c */ 24/* Note: must be kept in sync with archival/lzop.c */
25enum { 25enum {
26 OPT_STDOUT = 1 << 0, 26 OPT_STDOUT = 1 << 0,
diff --git a/archival/bzip2.c b/archival/bzip2.c
index d578eb7ad..d6fd9296d 100644
--- a/archival/bzip2.c
+++ b/archival/bzip2.c
@@ -6,7 +6,6 @@
6 * See README and LICENSE files in bz/ directory for more information 6 * See README and LICENSE files in bz/ directory for more information
7 * about bzip2 library code. 7 * about bzip2 library code.
8 */ 8 */
9
10//config:config BZIP2 9//config:config BZIP2
11//config: bool "bzip2 (18 kb)" 10//config: bool "bzip2 (18 kb)"
12//config: default y 11//config: default y
@@ -30,6 +29,7 @@
30//config: enabled. 29//config: enabled.
31 30
32//applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) 31//applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
32
33//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o 33//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o
34 34
35//usage:#define bzip2_trivial_usage 35//usage:#define bzip2_trivial_usage
diff --git a/archival/cpio.c b/archival/cpio.c
index f2165be3a..1d6cbd1e2 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -10,10 +10,6 @@
10 * Doesn't check CRC's 10 * Doesn't check CRC's
11 * Only supports new ASCII and CRC formats 11 * Only supports new ASCII and CRC formats
12 */ 12 */
13#include "libbb.h"
14#include "common_bufsiz.h"
15#include "bb_archive.h"
16
17//config:config CPIO 13//config:config CPIO
18//config: bool "cpio (14 kb)" 14//config: bool "cpio (14 kb)"
19//config: default y 15//config: default y
@@ -44,6 +40,7 @@
44//config: Passthrough mode. Rarely used. 40//config: Passthrough mode. Rarely used.
45 41
46//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) 42//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
43
47//kbuild:lib-$(CONFIG_CPIO) += cpio.o 44//kbuild:lib-$(CONFIG_CPIO) += cpio.o
48 45
49//usage:#define cpio_trivial_usage 46//usage:#define cpio_trivial_usage
@@ -142,6 +139,10 @@
142 -u, --unconditional Replace all files unconditionally 139 -u, --unconditional Replace all files unconditionally
143 */ 140 */
144 141
142#include "libbb.h"
143#include "common_bufsiz.h"
144#include "bb_archive.h"
145
145enum { 146enum {
146 OPT_EXTRACT = (1 << 0), 147 OPT_EXTRACT = (1 << 0),
147 OPT_TEST = (1 << 1), 148 OPT_TEST = (1 << 1),
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 852e0cac2..58bc4dba3 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -25,7 +25,6 @@
25 * bugs that need to be fixed 25 * bugs that need to be fixed
26 * - (unknown, please let me know when you find any) 26 * - (unknown, please let me know when you find any)
27 */ 27 */
28
29//config:config DPKG 28//config:config DPKG
30//config: bool "dpkg (44 kb)" 29//config: bool "dpkg (44 kb)"
31//config: default y 30//config: default y
@@ -38,6 +37,7 @@
38//config: you should use the official dpkg if possible. 37//config: you should use the official dpkg if possible.
39 38
40//applet:IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP)) 39//applet:IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP))
40
41//kbuild:lib-$(CONFIG_DPKG) += dpkg.o 41//kbuild:lib-$(CONFIG_DPKG) += dpkg.o
42 42
43//usage:#define dpkg_trivial_usage 43//usage:#define dpkg_trivial_usage
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index f6bf9eb04..dc4738d28 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -4,7 +4,6 @@
4 * 4 *
5 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 5 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
6 */ 6 */
7
8//config:config DPKG_DEB 7//config:config DPKG_DEB
9//config: bool "dpkg_deb" 8//config: bool "dpkg_deb"
10//config: default y 9//config: default y
diff --git a/archival/gzip.c b/archival/gzip.c
index 9c53895e9..ac6633044 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -36,7 +36,6 @@ a: 85.1% -- replaced with a.gz
36gzip: bogus: No such file or directory 36gzip: bogus: No such file or directory
37aa: 85.1% -- replaced with aa.gz 37aa: 85.1% -- replaced with aa.gz
38*/ 38*/
39
40//config:config GZIP 39//config:config GZIP
41//config: bool "gzip (19 kb)" 40//config: bool "gzip (19 kb)"
42//config: default y 41//config: default y
@@ -81,6 +80,7 @@ aa: 85.1% -- replaced with aa.gz
81//config: enabled. 80//config: enabled.
82 81
83//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) 82//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))
83
84//kbuild:lib-$(CONFIG_GZIP) += gzip.o 84//kbuild:lib-$(CONFIG_GZIP) += gzip.o
85 85
86//usage:#define gzip_trivial_usage 86//usage:#define gzip_trivial_usage
diff --git a/archival/lzop.c b/archival/lzop.c
index 1bf954f4f..92411c23f 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -24,7 +24,6 @@
24 24
25 "Minimalized" for busybox by Alain Knaff 25 "Minimalized" for busybox by Alain Knaff
26*/ 26*/
27
28//config:config LZOP 27//config:config LZOP
29//config: bool "lzop (13 kb)" 28//config: bool "lzop (13 kb)"
30//config: default y 29//config: default y
@@ -56,6 +55,7 @@
56// APPLET_ODDNAME:name main location suid_type help 55// APPLET_ODDNAME:name main location suid_type help
57//applet:IF_UNLZOP( APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) 56//applet:IF_UNLZOP( APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))
58//applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) 57//applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))
58
59//kbuild:lib-$(CONFIG_LZOP) += lzop.o 59//kbuild:lib-$(CONFIG_LZOP) += lzop.o
60//kbuild:lib-$(CONFIG_UNLZOP) += lzop.o 60//kbuild:lib-$(CONFIG_UNLZOP) += lzop.o
61//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o 61//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o
diff --git a/archival/tar.c b/archival/tar.c
index 46e2e4fcc..6332bb6ee 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -22,7 +22,6 @@
22 * 22 *
23 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 23 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
24 */ 24 */
25
26//config:config TAR 25//config:config TAR
27//config: bool "tar (40 kb)" 26//config: bool "tar (40 kb)"
28//config: default y 27//config: default y
@@ -113,6 +112,7 @@
113//config: when extracting files from tar archives. 112//config: when extracting files from tar archives.
114 113
115//applet:IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP)) 114//applet:IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP))
115
116//kbuild:lib-$(CONFIG_TAR) += tar.o 116//kbuild:lib-$(CONFIG_TAR) += tar.o
117 117
118#include <fnmatch.h> 118#include <fnmatch.h>
diff --git a/console-tools/clear.c b/console-tools/clear.c
index 3cc16257b..09ef1ea68 100644
--- a/console-tools/clear.c
+++ b/console-tools/clear.c
@@ -23,9 +23,11 @@
23 23
24#include "libbb.h" 24#include "libbb.h"
25 25
26#define ESC "\033"
27
26int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
27int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 29int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
28{ 30{
29 /* home; clear to the end of screen */ 31 /* home; clear to the end of screen */
30 return full_write1_str("\033[H""\033[J") != 6; 32 return full_write1_str(ESC"[H" ESC"[J") != 6;
31} 33}
diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c
index b803e579a..f1c9287b5 100644
--- a/console-tools/dumpkmap.c
+++ b/console-tools/dumpkmap.c
@@ -5,7 +5,6 @@
5 * Copyright (C) Arne Bernin <arne@matrix.loopback.org> 5 * Copyright (C) Arne Bernin <arne@matrix.loopback.org>
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 *
9 */ 8 */
10//config:config DUMPKMAP 9//config:config DUMPKMAP
11//config: bool "dumpkmap (1.3 kb)" 10//config: bool "dumpkmap (1.3 kb)"
diff --git a/console-tools/reset.c b/console-tools/reset.c
index f2b900ddb..614806ba7 100644
--- a/console-tools/reset.c
+++ b/console-tools/reset.c
@@ -7,8 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10/* "Standard" version of this tool is in ncurses package */
11
12//config:config RESET 10//config:config RESET
13//config: bool "reset (275 bytes)" 11//config: bool "reset (275 bytes)"
14//config: default y 12//config: default y
@@ -25,6 +23,8 @@
25//usage:#define reset_full_usage "\n\n" 23//usage:#define reset_full_usage "\n\n"
26//usage: "Reset the screen" 24//usage: "Reset the screen"
27 25
26/* "Standard" version of this tool is in ncurses package */
27
28#include "libbb.h" 28#include "libbb.h"
29 29
30#define ESC "\033" 30#define ESC "\033"
@@ -46,11 +46,11 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
46 /* See 'man 4 console_codes' for details: 46 /* See 'man 4 console_codes' for details:
47 * "ESC c" -- Reset 47 * "ESC c" -- Reset
48 * "ESC ( B" -- Select G0 Character Set (B = US) 48 * "ESC ( B" -- Select G0 Character Set (B = US)
49 * "ESC [ 0 m" -- Reset all display attributes 49 * "ESC [ m" -- Reset all display attributes
50 * "ESC [ J" -- Erase to the end of screen 50 * "ESC [ J" -- Erase to the end of screen
51 * "ESC [ ? 25 h" -- Make cursor visible 51 * "ESC [ ? 25 h" -- Make cursor visible
52 */ 52 */
53 printf(ESC"c" ESC"(B" ESC"[0m" ESC"[J" ESC"[?25h"); 53 printf(ESC"c" ESC"(B" ESC"[m" ESC"[J" ESC"[?25h");
54 /* http://bugs.busybox.net/view.php?id=1414: 54 /* http://bugs.busybox.net/view.php?id=1414:
55 * people want it to reset echo etc: */ 55 * people want it to reset echo etc: */
56#if ENABLE_STTY 56#if ENABLE_STTY
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 9f0462936..22286d713 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -347,6 +347,8 @@ struct globals {
347 IF_FEATURE_LS_TIMESTAMPS(time(&G.current_time_t);) \ 347 IF_FEATURE_LS_TIMESTAMPS(time(&G.current_time_t);) \
348} while (0) 348} while (0)
349 349
350#define ESC "\033"
351
350 352
351/*** Output code ***/ 353/*** Output code ***/
352 354
@@ -586,12 +588,12 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
586 if (!mode) 588 if (!mode)
587 if (lstat(dn->fullname, &statbuf) == 0) 589 if (lstat(dn->fullname, &statbuf) == 0)
588 mode = statbuf.st_mode; 590 mode = statbuf.st_mode;
589 printf("\033[%u;%um", bold(mode), fgcolor(mode)); 591 printf(ESC"[%u;%um", bold(mode), fgcolor(mode));
590 } 592 }
591#endif 593#endif
592 column += print_name(dn->name); 594 column += print_name(dn->name);
593 if (G_show_color) { 595 if (G_show_color) {
594 printf("\033[0m"); 596 printf(ESC"[m");
595 } 597 }
596 598
597 if (lpath) { 599 if (lpath) {
@@ -609,7 +611,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
609# endif 611# endif
610# if ENABLE_FEATURE_LS_COLOR 612# if ENABLE_FEATURE_LS_COLOR
611 if (G_show_color) { 613 if (G_show_color) {
612 printf("\033[%u;%um", bold(mode), fgcolor(mode)); 614 printf(ESC"[%u;%um", bold(mode), fgcolor(mode));
613 } 615 }
614# endif 616# endif
615 } 617 }
@@ -617,7 +619,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
617 column += print_name(lpath) + 4; 619 column += print_name(lpath) + 4;
618 free(lpath); 620 free(lpath);
619 if (G_show_color) { 621 if (G_show_color) {
620 printf("\033[0m"); 622 printf(ESC"[m");
621 } 623 }
622 } 624 }
623#if ENABLE_FEATURE_LS_FILETYPES 625#if ENABLE_FEATURE_LS_FILETYPES
diff --git a/coreutils/printf.c b/coreutils/printf.c
index d1ff183d0..353cfc608 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -48,7 +48,6 @@
48//applet:IF_PRINTF(APPLET_NOFORK(printf, printf, BB_DIR_USR_BIN, BB_SUID_DROP, printf)) 48//applet:IF_PRINTF(APPLET_NOFORK(printf, printf, BB_DIR_USR_BIN, BB_SUID_DROP, printf))
49 49
50//kbuild:lib-$(CONFIG_PRINTF) += printf.o 50//kbuild:lib-$(CONFIG_PRINTF) += printf.o
51
52//kbuild:lib-$(CONFIG_ASH_PRINTF) += printf.o 51//kbuild:lib-$(CONFIG_ASH_PRINTF) += printf.o
53//kbuild:lib-$(CONFIG_HUSH_PRINTF) += printf.o 52//kbuild:lib-$(CONFIG_HUSH_PRINTF) += printf.o
54 53
diff --git a/coreutils/shuf.c b/coreutils/shuf.c
index d0caaa2ce..fdbd3e9b2 100644
--- a/coreutils/shuf.c
+++ b/coreutils/shuf.c
@@ -6,16 +6,16 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config SHUF 9//config:config SHUF
11//config: bool "shuf (5.4 kb)" 10//config: bool "shuf (5.4 kb)"
12//config: default y 11//config: default y
13//config: help 12//config: help
14//config: Generate random permutations 13//config: Generate random permutations
15 14
16//kbuild:lib-$(CONFIG_SHUF) += shuf.o
17//applet:IF_SHUF(APPLET_NOEXEC(shuf, shuf, BB_DIR_USR_BIN, BB_SUID_DROP, shuf)) 15//applet:IF_SHUF(APPLET_NOEXEC(shuf, shuf, BB_DIR_USR_BIN, BB_SUID_DROP, shuf))
18 16
17//kbuild:lib-$(CONFIG_SHUF) += shuf.o
18
19//usage:#define shuf_trivial_usage 19//usage:#define shuf_trivial_usage
20//usage: "[-e|-i L-H] [-n NUM] [-o FILE] [-z] [FILE|ARG...]" 20//usage: "[-e|-i L-H] [-n NUM] [-o FILE] [-z] [FILE|ARG...]"
21//usage:#define shuf_full_usage "\n\n" 21//usage:#define shuf_full_usage "\n\n"
diff --git a/coreutils/stty.c b/coreutils/stty.c
index 57e2cc30d..b6e836364 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -148,6 +148,9 @@
148#ifndef CRDLY 148#ifndef CRDLY
149# define CRDLY 0 149# define CRDLY 0
150#endif 150#endif
151#ifndef CMSPAR
152# define CMSPAR 0
153#endif
151#ifndef CRTSCTS 154#ifndef CRTSCTS
152# define CRTSCTS 0 155# define CRTSCTS 0
153#endif 156#endif
@@ -352,6 +355,9 @@ static const char mode_name[] ALIGN1 =
352#endif 355#endif
353 MI_ENTRY("parenb", control, REV, PARENB, 0 ) 356 MI_ENTRY("parenb", control, REV, PARENB, 0 )
354 MI_ENTRY("parodd", control, REV, PARODD, 0 ) 357 MI_ENTRY("parodd", control, REV, PARODD, 0 )
358#if CMSPAR
359 MI_ENTRY("cmspar", control, REV, CMSPAR, 0 )
360#endif
355 MI_ENTRY("cs5", control, 0, CS5, CSIZE) 361 MI_ENTRY("cs5", control, 0, CS5, CSIZE)
356 MI_ENTRY("cs6", control, 0, CS6, CSIZE) 362 MI_ENTRY("cs6", control, 0, CS6, CSIZE)
357 MI_ENTRY("cs7", control, 0, CS7, CSIZE) 363 MI_ENTRY("cs7", control, 0, CS7, CSIZE)
@@ -477,6 +483,10 @@ static const char mode_name[] ALIGN1 =
477 MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 ) 483 MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
478 MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 ) 484 MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 )
479#endif 485#endif
486 MI_ENTRY("flusho", local, SANE_UNSET | REV, FLUSHO, 0 )
487#ifdef EXTPROC
488 MI_ENTRY("extproc", local, SANE_UNSET | REV, EXTPROC, 0 )
489#endif
480 ; 490 ;
481 491
482#undef MI_ENTRY 492#undef MI_ENTRY
@@ -509,6 +519,9 @@ static const struct mode_info mode_info[] = {
509#endif 519#endif
510 MI_ENTRY("parenb", control, REV, PARENB, 0 ) 520 MI_ENTRY("parenb", control, REV, PARENB, 0 )
511 MI_ENTRY("parodd", control, REV, PARODD, 0 ) 521 MI_ENTRY("parodd", control, REV, PARODD, 0 )
522#if CMSPAR
523 MI_ENTRY("cmspar", control, REV, CMSPAR, 0 )
524#endif
512 MI_ENTRY("cs5", control, 0, CS5, CSIZE) 525 MI_ENTRY("cs5", control, 0, CS5, CSIZE)
513 MI_ENTRY("cs6", control, 0, CS6, CSIZE) 526 MI_ENTRY("cs6", control, 0, CS6, CSIZE)
514 MI_ENTRY("cs7", control, 0, CS7, CSIZE) 527 MI_ENTRY("cs7", control, 0, CS7, CSIZE)
@@ -634,6 +647,10 @@ static const struct mode_info mode_info[] = {
634 MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 ) 647 MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
635 MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 ) 648 MI_ENTRY("crtkill", local, OMIT | REV, ECHOKE, 0 )
636#endif 649#endif
650 MI_ENTRY("flusho", local, SANE_UNSET | REV, FLUSHO, 0 )
651#ifdef EXTPROC
652 MI_ENTRY("extproc", local, SANE_UNSET | REV, EXTPROC, 0 )
653#endif
637}; 654};
638 655
639enum { 656enum {
@@ -836,10 +853,11 @@ static void wrapf(const char *message, ...)
836 G.current_col++; 853 G.current_col++;
837 if (buf[0] != '\n') { 854 if (buf[0] != '\n') {
838 if (G.current_col + buflen >= G.max_col) { 855 if (G.current_col + buflen >= G.max_col) {
839 bb_putchar('\n');
840 G.current_col = 0; 856 G.current_col = 0;
841 } else 857 bb_putchar('\n');
858 } else {
842 bb_putchar(' '); 859 bb_putchar(' ');
860 }
843 } 861 }
844 } 862 }
845 fputs(buf, stdout); 863 fputs(buf, stdout);
diff --git a/editors/awk.c b/editors/awk.c
index 2fc7d6102..1a273ff2e 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config AWK 9//config:config AWK
11//config: bool "awk (22 kb)" 10//config: bool "awk (22 kb)"
12//config: default y 11//config: default y
diff --git a/editors/cmp.c b/editors/cmp.c
index ec86c0ce2..2a410fdec 100644
--- a/editors/cmp.c
+++ b/editors/cmp.c
@@ -6,10 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
12
13//config:config CMP 9//config:config CMP
14//config: bool "cmp (5.4 kb)" 10//config: bool "cmp (5.4 kb)"
15//config: default y 11//config: default y
@@ -17,10 +13,10 @@
17//config: cmp is used to compare two files and returns the result 13//config: cmp is used to compare two files and returns the result
18//config: to standard output. 14//config: to standard output.
19 15
20//kbuild:lib-$(CONFIG_CMP) += cmp.o
21
22//applet:IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP)) 16//applet:IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP))
23 17
18//kbuild:lib-$(CONFIG_CMP) += cmp.o
19
24//usage:#define cmp_trivial_usage 20//usage:#define cmp_trivial_usage
25//usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]" 21//usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]"
26//usage:#define cmp_full_usage "\n\n" 22//usage:#define cmp_full_usage "\n\n"
@@ -29,6 +25,9 @@
29//usage: "\n for all differing bytes" 25//usage: "\n for all differing bytes"
30//usage: "\n -s Quiet" 26//usage: "\n -s Quiet"
31 27
28/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
29/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
30
32#include "libbb.h" 31#include "libbb.h"
33 32
34static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; 33static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n";
diff --git a/editors/diff.c b/editors/diff.c
index 1ff399ffb..beea3e618 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -12,7 +12,6 @@
12 * 12 *
13 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 13 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
14 */ 14 */
15
16/* 15/*
17 * The following code uses an algorithm due to Harold Stone, 16 * The following code uses an algorithm due to Harold Stone,
18 * which finds a pair of longest identical subsequences in 17 * which finds a pair of longest identical subsequences in
@@ -75,7 +74,6 @@
75 * 3*(number of k-candidates installed), typically about 74 * 3*(number of k-candidates installed), typically about
76 * 6n words for files of length n. 75 * 6n words for files of length n.
77 */ 76 */
78
79//config:config DIFF 77//config:config DIFF
80//config: bool "diff (13 kb)" 78//config: bool "diff (13 kb)"
81//config: default y 79//config: default y
@@ -97,10 +95,10 @@
97//config: This option enables support for directory and subdirectory 95//config: This option enables support for directory and subdirectory
98//config: comparison. 96//config: comparison.
99 97
100//kbuild:lib-$(CONFIG_DIFF) += diff.o
101
102//applet:IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP)) 98//applet:IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP))
103 99
100//kbuild:lib-$(CONFIG_DIFF) += diff.o
101
104//usage:#define diff_trivial_usage 102//usage:#define diff_trivial_usage
105//usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2" 103//usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2"
106//usage:#define diff_full_usage "\n\n" 104//usage:#define diff_full_usage "\n\n"
diff --git a/editors/patch.c b/editors/patch.c
index 81316fae3..a51b7a502 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -21,7 +21,6 @@
21 * -F fuzz (number, default 2) 21 * -F fuzz (number, default 2)
22 * [file] which file to patch 22 * [file] which file to patch
23 */ 23 */
24
25//config:config PATCH 24//config:config PATCH
26//config: bool "patch (9.1 kb)" 25//config: bool "patch (9.1 kb)"
27//config: default y 26//config: default y
diff --git a/editors/sed.c b/editors/sed.c
index e2c6690bb..bb2809d3c 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -12,7 +12,6 @@
12 * 12 *
13 * Licensed under GPLv2, see file LICENSE in this source tree. 13 * Licensed under GPLv2, see file LICENSE in this source tree.
14 */ 14 */
15
16/* Code overview. 15/* Code overview.
17 * 16 *
18 * Files are laid out to avoid unnecessary function declarations. So for 17 * Files are laid out to avoid unnecessary function declarations. So for
@@ -29,7 +28,6 @@
29 * 28 *
30 * sed_main() is where external code calls into this, with a command line. 29 * sed_main() is where external code calls into this, with a command line.
31 */ 30 */
32
33/* Supported features and commands in this version of sed: 31/* Supported features and commands in this version of sed:
34 * 32 *
35 * - comments ('#') 33 * - comments ('#')
@@ -55,7 +53,6 @@
55 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html 53 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
56 * http://sed.sourceforge.net/sedfaq3.html 54 * http://sed.sourceforge.net/sedfaq3.html
57 */ 55 */
58
59//config:config SED 56//config:config SED
60//config: bool "sed (12 kb)" 57//config: bool "sed (12 kb)"
61//config: default y 58//config: default y
@@ -63,10 +60,10 @@
63//config: sed is used to perform text transformations on a file 60//config: sed is used to perform text transformations on a file
64//config: or input from a pipeline. 61//config: or input from a pipeline.
65 62
66//kbuild:lib-$(CONFIG_SED) += sed.o
67
68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) 63//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))
69 64
65//kbuild:lib-$(CONFIG_SED) += sed.o
66
70//usage:#define sed_trivial_usage 67//usage:#define sed_trivial_usage
71//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n" 68//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n"
72//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..." 69//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..."
@@ -356,10 +353,16 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex)
356 if (*my_str == '\\') 353 if (*my_str == '\\')
357 delimiter = *++pos; 354 delimiter = *++pos;
358 next = index_of_next_unescaped_regexp_delim(delimiter, ++pos); 355 next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
359 temp = copy_parsing_escapes(pos, next); 356 if (next != 0) {
360 *regex = xzalloc(sizeof(regex_t)); 357 temp = copy_parsing_escapes(pos, next);
361 xregcomp(*regex, temp, G.regex_type); 358 G.previous_regex_ptr = *regex = xzalloc(sizeof(regex_t));
362 free(temp); 359 xregcomp(*regex, temp, G.regex_type);
360 free(temp);
361 } else {
362 *regex = G.previous_regex_ptr;
363 if (!G.previous_regex_ptr)
364 bb_error_msg_and_die("no previous regexp");
365 }
363 /* Move position to next character after last delimiter */ 366 /* Move position to next character after last delimiter */
364 pos += (next+1); 367 pos += (next+1);
365 } 368 }
diff --git a/editors/vi.c b/editors/vi.c
index 91e954a87..8393eb825 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8
9/* 8/*
10 * Things To Do: 9 * Things To Do:
11 * EXINIT 10 * EXINIT
@@ -19,7 +18,6 @@
19 * ":r !cmd" and "!cmd" to filter text through an external command 18 * ":r !cmd" and "!cmd" to filter text through an external command
20 * An "ex" line oriented mode- maybe using "cmdedit" 19 * An "ex" line oriented mode- maybe using "cmdedit"
21 */ 20 */
22
23//config:config VI 21//config:config VI
24//config: bool "vi (22 kb)" 22//config: bool "vi (22 kb)"
25//config: default y 23//config: default y
@@ -224,24 +222,25 @@ enum {
224 * See "Xterm Control Sequences" 222 * See "Xterm Control Sequences"
225 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html 223 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
226 */ 224 */
225#define ESC "\033"
227/* Inverse/Normal text */ 226/* Inverse/Normal text */
228#define ESC_BOLD_TEXT "\033[7m" 227#define ESC_BOLD_TEXT ESC"[7m"
229#define ESC_NORM_TEXT "\033[0m" 228#define ESC_NORM_TEXT ESC"[m"
230/* Bell */ 229/* Bell */
231#define ESC_BELL "\007" 230#define ESC_BELL "\007"
232/* Clear-to-end-of-line */ 231/* Clear-to-end-of-line */
233#define ESC_CLEAR2EOL "\033[K" 232#define ESC_CLEAR2EOL ESC"[K"
234/* Clear-to-end-of-screen. 233/* Clear-to-end-of-screen.
235 * (We use default param here. 234 * (We use default param here.
236 * Full sequence is "ESC [ <num> J", 235 * Full sequence is "ESC [ <num> J",
237 * <num> is 0/1/2 = "erase below/above/all".) 236 * <num> is 0/1/2 = "erase below/above/all".)
238 */ 237 */
239#define ESC_CLEAR2EOS "\033[J" 238#define ESC_CLEAR2EOS ESC"[J"
240/* Cursor to given coordinate (1,1: top left) */ 239/* Cursor to given coordinate (1,1: top left) */
241#define ESC_SET_CURSOR_POS "\033[%u;%uH" 240#define ESC_SET_CURSOR_POS ESC"[%u;%uH"
242//UNUSED 241//UNUSED
243///* Cursor up and down */ 242///* Cursor up and down */
244//#define ESC_CURSOR_UP "\033[A" 243//#define ESC_CURSOR_UP ESC"[A"
245//#define ESC_CURSOR_DOWN "\n" 244//#define ESC_CURSOR_DOWN "\n"
246 245
247#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK 246#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
@@ -696,14 +695,14 @@ int vi_main(int argc, char **argv)
696 save_argc = argc; 695 save_argc = argc;
697 optind = 0; 696 optind = 0;
698 // "Save cursor, use alternate screen buffer, clear screen" 697 // "Save cursor, use alternate screen buffer, clear screen"
699 write1("\033[?1049h"); 698 write1(ESC"[?1049h");
700 while (1) { 699 while (1) {
701 edit_file(argv[optind]); /* param might be NULL */ 700 edit_file(argv[optind]); /* param might be NULL */
702 if (++optind >= argc) 701 if (++optind >= argc)
703 break; 702 break;
704 } 703 }
705 // "Use normal screen buffer, restore cursor" 704 // "Use normal screen buffer, restore cursor"
706 write1("\033[?1049l"); 705 write1(ESC"[?1049l");
707 //----------------------------------------------------------- 706 //-----------------------------------------------------------
708 707
709 return 0; 708 return 0;
@@ -772,7 +771,7 @@ static void edit_file(char *fn)
772#if ENABLE_FEATURE_VI_ASK_TERMINAL 771#if ENABLE_FEATURE_VI_ASK_TERMINAL
773 if (G.get_rowcol_error /* TODO? && no input on stdin */) { 772 if (G.get_rowcol_error /* TODO? && no input on stdin */) {
774 uint64_t k; 773 uint64_t k;
775 write1("\033[999;999H" "\033[6n"); 774 write1(ESC"[999;999H" ESC"[6n");
776 fflush_all(); 775 fflush_all();
777 k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); 776 k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100);
778 if ((int32_t)k == KEYCODE_CURSOR_POS) { 777 if ((int32_t)k == KEYCODE_CURSOR_POS) {
@@ -4501,7 +4500,7 @@ static void crash_dummy()
4501 sleeptime = 0; // how fast to type 4500 sleeptime = 0; // how fast to type
4502 } 4501 }
4503 } 4502 }
4504 strcat(readbuffer, "\033"); 4503 strcat(readbuffer, ESC);
4505 } 4504 }
4506 readbuffer[0] = strlen(readbuffer + 1); 4505 readbuffer[0] = strlen(readbuffer + 1);
4507 cd1: 4506 cd1:
diff --git a/findutils/find.c b/findutils/find.c
index 5857a3f44..d9a42b3c6 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * Licensed under GPLv2, see file LICENSE in this source tree. 10 * Licensed under GPLv2, see file LICENSE in this source tree.
11 */ 11 */
12
13/* findutils-4.1.20: 12/* findutils-4.1.20:
14 * 13 *
15 * # find file.txt -exec 'echo {}' '{} {}' ';' 14 * # find file.txt -exec 'echo {}' '{} {}' ';'
@@ -44,7 +43,6 @@
44 * # find t z t z '(' -name '*t*' -o -name '*z*' ')' -o -print 43 * # find t z t z '(' -name '*t*' -o -name '*z*' ')' -o -print
45 * (no output) 44 * (no output)
46 */ 45 */
47
48/* Testing script 46/* Testing script
49 * ./busybox find "$@" | tee /tmp/bb_find 47 * ./busybox find "$@" | tee /tmp/bb_find
50 * echo ================== 48 * echo ==================
@@ -52,7 +50,6 @@
52 * echo ================== 50 * echo ==================
53 * diff -u /tmp/std_find /tmp/bb_find && echo Identical 51 * diff -u /tmp/std_find /tmp/bb_find && echo Identical
54 */ 52 */
55
56//config:config FIND 53//config:config FIND
57//config: bool "find (14 kb)" 54//config: bool "find (14 kb)"
58//config: default y 55//config: default y
diff --git a/findutils/grep.c b/findutils/grep.c
index 7c5f73d2f..f72175afb 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -17,7 +17,6 @@
17 * 17 *
18 * (C) 2006 Jac Goudsmit added -o option 18 * (C) 2006 Jac Goudsmit added -o option
19 */ 19 */
20
21//config:config GREP 20//config:config GREP
22//config: bool "grep (8.5 kb)" 21//config: bool "grep (8.5 kb)"
23//config: default y 22//config: default y
diff --git a/findutils/xargs.c b/findutils/xargs.c
index 4765085dc..caa89f13e 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -14,7 +14,6 @@
14 * xargs is described in the Single Unix Specification v3 at 14 * xargs is described in the Single Unix Specification v3 at
15 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html 15 * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html
16 */ 16 */
17
18//config:config XARGS 17//config:config XARGS
19//config: bool "xargs (6.7 kb)" 18//config: bool "xargs (6.7 kb)"
20//config: default y 19//config: default y
@@ -60,6 +59,16 @@
60//config: depends on XARGS 59//config: depends on XARGS
61//config: help 60//config: help
62//config: Support -I STR and -i[STR] options. 61//config: Support -I STR and -i[STR] options.
62//config:
63//config:config FEATURE_XARGS_SUPPORT_PARALLEL
64//config: bool "Enable -P N: processes to run in parallel"
65//config: default y
66//config: depends on XARGS
67//config:
68//config:config FEATURE_XARGS_SUPPORT_ARGS_FILE
69//config: bool "Enable -a FILE: use FILE instead of stdin"
70//config: default y
71//config: depends on XARGS
63 72
64//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs)) 73//applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs))
65 74
@@ -103,37 +112,121 @@ struct globals {
103#endif 112#endif
104 const char *eof_str; 113 const char *eof_str;
105 int idx; 114 int idx;
115#if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL
116 int running_procs;
117 int max_procs;
118#endif
119 smalluint xargs_exitcode;
106} FIX_ALIASING; 120} FIX_ALIASING;
107#define G (*(struct globals*)bb_common_bufsiz1) 121#define G (*(struct globals*)bb_common_bufsiz1)
108#define INIT_G() do { \ 122#define INIT_G() do { \
109 setup_common_bufsiz(); \ 123 setup_common_bufsiz(); \
110 G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \ 124 G.eof_str = NULL; /* need to clear by hand because we are NOEXEC applet */ \
125 G.idx = 0; \
126 IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.running_procs = 0;) \
127 IF_FEATURE_XARGS_SUPPORT_PARALLEL(G.max_procs = 1;) \
128 G.xargs_exitcode = 0; \
111 IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \ 129 IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.repl_str = "{}";) \
112 IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \ 130 IF_FEATURE_XARGS_SUPPORT_REPL_STR(G.eol_ch = '\n';) \
113} while (0) 131} while (0)
114 132
115 133
134/*
135 * Returns 0 if xargs should continue (but may set G.xargs_exitcode to 123).
136 * Else sets G.xargs_exitcode to error code and returns nonzero.
137 *
138 * If G.max_procs == 0, performs final waitpid() loop for all children.
139 */
116static int xargs_exec(void) 140static int xargs_exec(void)
117{ 141{
118 int status; 142 int status;
119 143
144#if !ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL
120 status = spawn_and_wait(G.args); 145 status = spawn_and_wait(G.args);
146#else
147 if (G.max_procs == 1) {
148 status = spawn_and_wait(G.args);
149 } else {
150 pid_t pid;
151 int wstat;
152 again:
153 if (G.running_procs >= G.max_procs)
154 pid = safe_waitpid(-1, &wstat, 0);
155 else
156 pid = wait_any_nohang(&wstat);
157 if (pid > 0) {
158 /* We may have children we don't know about:
159 * sh -c 'sleep 1 & exec xargs ...'
160 * Do not make G.running_procs go negative.
161 */
162 if (G.running_procs != 0)
163 G.running_procs--;
164 status = WIFSIGNALED(wstat)
165 ? 0x180 + WTERMSIG(wstat)
166 : WEXITSTATUS(wstat);
167 if (status > 0 && status < 255) {
168 /* See below why 123 does not abort */
169 G.xargs_exitcode = 123;
170 status = 0;
171 }
172 if (status == 0)
173 goto again; /* maybe we have more children? */
174 /* else: "bad" status, will bail out */
175 } else if (G.max_procs != 0) {
176 /* Not in final waitpid() loop,
177 * and G.running_procs < G.max_procs: start more procs
178 */
179 status = spawn(G.args);
180 /* here "status" actually holds pid, or -1 */
181 if (status > 0) {
182 G.running_procs++;
183 status = 0;
184 }
185 /* else: status == -1 (failed to fork or exec) */
186 } else {
187 /* final waitpid() loop: must be ECHILD "no more children" */
188 status = 0;
189 }
190 }
191#endif
192 /* Manpage:
193 * """xargs exits with the following status:
194 * 0 if it succeeds
195 * 123 if any invocation of the command exited with status 1-125
196 * 124 if the command exited with status 255
197 * ("""If any invocation of the command exits with a status of 255,
198 * xargs will stop immediately without reading any further input.
199 * An error message is issued on stderr when this happens.""")
200 * 125 if the command is killed by a signal
201 * 126 if the command cannot be run
202 * 127 if the command is not found
203 * 1 if some other error occurred."""
204 */
121 if (status < 0) { 205 if (status < 0) {
122 bb_simple_perror_msg(G.args[0]); 206 bb_simple_perror_msg(G.args[0]);
123 return errno == ENOENT ? 127 : 126; 207 status = (errno == ENOENT) ? 127 : 126;
124 }
125 if (status == 255) {
126 bb_error_msg("%s: exited with status 255; aborting", G.args[0]);
127 return 124;
128 } 208 }
129 if (status >= 0x180) { 209 else if (status >= 0x180) {
130 bb_error_msg("'%s' terminated by signal %d", 210 bb_error_msg("'%s' terminated by signal %d",
131 G.args[0], status - 0x180); 211 G.args[0], status - 0x180);
132 return 125; 212 status = 125;
213 }
214 else if (status != 0) {
215 if (status == 255) {
216 bb_error_msg("%s: exited with status 255; aborting", G.args[0]);
217 return 124;
218 }
219 /* "123 if any invocation of the command exited with status 1-125"
220 * This implies that nonzero exit code is remembered,
221 * but does not cause xargs to stop: we return 0.
222 */
223 G.xargs_exitcode = 123;
224 status = 0;
133 } 225 }
134 if (status) 226
135 return 123; 227 if (status != 0)
136 return 0; 228 G.xargs_exitcode = status;
229 return status;
137} 230}
138 231
139/* In POSIX/C locale isspace is only these chars: "\t\n\v\f\r" and space. 232/* In POSIX/C locale isspace is only these chars: "\t\n\v\f\r" and space.
@@ -144,7 +237,7 @@ static int xargs_exec(void)
144static void store_param(char *s) 237static void store_param(char *s)
145{ 238{
146 /* Grow by 256 elements at once */ 239 /* Grow by 256 elements at once */
147 if (!(G.idx & 0xff)) { /* G.idx == N*256 */ 240 if (!(G.idx & 0xff)) { /* G.idx == N*256? */
148 /* Enlarge, make G.args[(N+1)*256 - 1] last valid idx */ 241 /* Enlarge, make G.args[(N+1)*256 - 1] last valid idx */
149 G.args = xrealloc(G.args, sizeof(G.args[0]) * (G.idx + 0x100)); 242 G.args = xrealloc(G.args, sizeof(G.args[0]) * (G.idx + 0x100));
150 } 243 }
@@ -444,6 +537,9 @@ static int xargs_ask_confirmation(void)
444//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( 537//usage: IF_FEATURE_XARGS_SUPPORT_ZERO_TERM(
445//usage: "\n -0 Input is separated by NUL characters" 538//usage: "\n -0 Input is separated by NUL characters"
446//usage: ) 539//usage: )
540//usage: IF_FEATURE_XARGS_SUPPORT_ARGS_FILE(
541//usage: "\n -a FILE Read from FILE instead of stdin"
542//usage: )
447//usage: "\n -t Print the command on stderr before execution" 543//usage: "\n -t Print the command on stderr before execution"
448//usage: "\n -e[STR] STR stops input processing" 544//usage: "\n -e[STR] STR stops input processing"
449//usage: "\n -n N Pass no more than N args to PROG" 545//usage: "\n -n N Pass no more than N args to PROG"
@@ -451,6 +547,9 @@ static int xargs_ask_confirmation(void)
451//usage: IF_FEATURE_XARGS_SUPPORT_REPL_STR( 547//usage: IF_FEATURE_XARGS_SUPPORT_REPL_STR(
452//usage: "\n -I STR Replace STR within PROG ARGS with input line" 548//usage: "\n -I STR Replace STR within PROG ARGS with input line"
453//usage: ) 549//usage: )
550//usage: IF_FEATURE_XARGS_SUPPORT_PARALLEL(
551//usage: "\n -P N Run up to N PROGs in parallel"
552//usage: )
454//usage: IF_FEATURE_XARGS_SUPPORT_TERMOPT( 553//usage: IF_FEATURE_XARGS_SUPPORT_TERMOPT(
455//usage: "\n -x Exit if size is exceeded" 554//usage: "\n -x Exit if size is exceeded"
456//usage: ) 555//usage: )
@@ -488,13 +587,15 @@ enum {
488 IF_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \ 587 IF_FEATURE_XARGS_SUPPORT_CONFIRMATION("p") \
489 IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \ 588 IF_FEATURE_XARGS_SUPPORT_TERMOPT( "x") \
490 IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \ 589 IF_FEATURE_XARGS_SUPPORT_ZERO_TERM( "0") \
491 IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") 590 IF_FEATURE_XARGS_SUPPORT_REPL_STR( "I:i::") \
591 IF_FEATURE_XARGS_SUPPORT_PARALLEL( "P:+") \
592 IF_FEATURE_XARGS_SUPPORT_ARGS_FILE( "a:")
492 593
493int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 594int xargs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
494int xargs_main(int argc, char **argv) 595int xargs_main(int argc UNUSED_PARAM, char **argv)
495{ 596{
597 int initial_idx;
496 int i; 598 int i;
497 int child_error = 0;
498 char *max_args; 599 char *max_args;
499 char *max_chars; 600 char *max_chars;
500 char *buf; 601 char *buf;
@@ -507,6 +608,7 @@ int xargs_main(int argc, char **argv)
507#else 608#else
508#define read_args process_stdin 609#define read_args process_stdin
509#endif 610#endif
611 IF_FEATURE_XARGS_SUPPORT_ARGS_FILE(char *opt_a = NULL;)
510 612
511 INIT_G(); 613 INIT_G();
512 614
@@ -514,8 +616,20 @@ int xargs_main(int argc, char **argv)
514 "no-run-if-empty\0" No_argument "r", 616 "no-run-if-empty\0" No_argument "r",
515 &max_args, &max_chars, &G.eof_str, &G.eof_str 617 &max_args, &max_chars, &G.eof_str, &G.eof_str
516 IF_FEATURE_XARGS_SUPPORT_REPL_STR(, &G.repl_str, &G.repl_str) 618 IF_FEATURE_XARGS_SUPPORT_REPL_STR(, &G.repl_str, &G.repl_str)
619 IF_FEATURE_XARGS_SUPPORT_PARALLEL(, &G.max_procs)
620 IF_FEATURE_XARGS_SUPPORT_ARGS_FILE(, &opt_a)
517 ); 621 );
518 622
623#if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL
624 if (G.max_procs <= 0) /* -P0 means "run lots of them" */
625 G.max_procs = 100; /* let's not go crazy high */
626#endif
627
628#if ENABLE_FEATURE_XARGS_SUPPORT_ARGS_FILE
629 if (opt_a)
630 xmove_fd(xopen(opt_a, O_RDONLY), 0);
631#endif
632
519 /* -E ""? You may wonder why not just omit -E? 633 /* -E ""? You may wonder why not just omit -E?
520 * This is used for portability: 634 * This is used for portability:
521 * old xargs was using "_" as default for -E / -e */ 635 * old xargs was using "_" as default for -E / -e */
@@ -528,11 +642,11 @@ int xargs_main(int argc, char **argv)
528 } 642 }
529 643
530 argv += optind; 644 argv += optind;
531 argc -= optind; 645 //argc -= optind;
532 if (!argv[0]) { 646 if (!argv[0]) {
533 /* default behavior is to echo all the filenames */ 647 /* default behavior is to echo all the filenames */
534 *--argv = (char*)"echo"; 648 *--argv = (char*)"echo";
535 argc++; 649 //argc++;
536 } 650 }
537 651
538 /* 652 /*
@@ -587,7 +701,6 @@ int xargs_main(int argc, char **argv)
587 */ 701 */
588 G.args = NULL; 702 G.args = NULL;
589 G.argv = argv; 703 G.argv = argv;
590 argc = 0;
591 read_args = process_stdin_with_replace; 704 read_args = process_stdin_with_replace;
592 /* Make -I imply -r. GNU findutils seems to do the same: */ 705 /* Make -I imply -r. GNU findutils seems to do the same: */
593 /* (otherwise "echo -n | xargs -I% echo %" would SEGV) */ 706 /* (otherwise "echo -n | xargs -I% echo %" would SEGV) */
@@ -595,30 +708,27 @@ int xargs_main(int argc, char **argv)
595 } else 708 } else
596#endif 709#endif
597 { 710 {
598 /* Allocate pointers for execvp. 711 /* Store the command to be executed, part 1.
599 * We can statically allocate (argc + n_max_arg + 1) elements 712 * We can statically allocate (argc + n_max_arg + 1) elements
600 * and do not bother with resizing args[], but on 64-bit machines 713 * and do not bother with resizing args[], but on 64-bit machines
601 * this results in args[] vector which is ~8 times bigger 714 * this results in args[] vector which is ~8 times bigger
602 * than n_max_chars! That is, with n_max_chars == 20k, 715 * than n_max_chars! That is, with n_max_chars == 20k,
603 * args[] will take 160k (!), which will most likely be 716 * args[] will take 160k (!), which will most likely be
604 * almost entirely unused. 717 * almost entirely unused.
605 *
606 * See store_param() for matching 256-step growth logic
607 */ 718 */
608 G.args = xmalloc(sizeof(G.args[0]) * ((argc + 0xff) & ~0xff));
609 /* Store the command to be executed, part 1 */
610 for (i = 0; argv[i]; i++) 719 for (i = 0; argv[i]; i++)
611 G.args[i] = argv[i]; 720 store_param(argv[i]);
612 } 721 }
613 722
723 initial_idx = G.idx;
614 while (1) { 724 while (1) {
615 char *rem; 725 char *rem;
616 726
617 G.idx = argc; 727 G.idx = initial_idx;
618 rem = read_args(n_max_chars, n_max_arg, buf); 728 rem = read_args(n_max_chars, n_max_arg, buf);
619 store_param(NULL); 729 store_param(NULL);
620 730
621 if (!G.args[argc]) { 731 if (!G.args[initial_idx]) { /* not even one ARG was added? */
622 if (*rem != '\0') 732 if (*rem != '\0')
623 bb_error_msg_and_die("argument line too long"); 733 bb_error_msg_and_die("argument line too long");
624 if (opt & OPT_NO_EMPTY) 734 if (opt & OPT_NO_EMPTY)
@@ -638,11 +748,8 @@ int xargs_main(int argc, char **argv)
638 } 748 }
639 749
640 if (!(opt & OPT_INTERACTIVE) || xargs_ask_confirmation()) { 750 if (!(opt & OPT_INTERACTIVE) || xargs_ask_confirmation()) {
641 child_error = xargs_exec(); 751 if (xargs_exec() != 0)
642 } 752 break; /* G.xargs_exitcode is set by xargs_exec() */
643
644 if (child_error > 0 && child_error != 123) {
645 break;
646 } 753 }
647 754
648 overlapping_strcpy(buf, rem); 755 overlapping_strcpy(buf, rem);
@@ -653,7 +760,12 @@ int xargs_main(int argc, char **argv)
653 free(buf); 760 free(buf);
654 } 761 }
655 762
656 return child_error; 763#if ENABLE_FEATURE_XARGS_SUPPORT_PARALLEL
764 G.max_procs = 0;
765 xargs_exec(); /* final waitpid() loop */
766#endif
767
768 return G.xargs_exitcode;
657} 769}
658 770
659 771
diff --git a/include/libbb.h b/include/libbb.h
index 9ce89636a..136bc33f5 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1242,7 +1242,7 @@ uint32_t getopt32long(char **argv, const char *optstring, const char *longopts,
1242 * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0 1242 * By ~2008, OpenBSD 3.4 was changed to survive glibc-like optind = 0
1243 * (to interpret it as if optreset was set). 1243 * (to interpret it as if optreset was set).
1244 */ 1244 */
1245#if defined(__GLIBC__) || ENABLE_PLATFORM_MINGW32 1245#if 1 /*def __GLIBC__*/
1246#define GETOPT_RESET() (optind = 0) 1246#define GETOPT_RESET() (optind = 0)
1247#else /* BSD style */ 1247#else /* BSD style */
1248#define GETOPT_RESET() (optind = 1) 1248#define GETOPT_RESET() (optind = 1)
@@ -1612,6 +1612,7 @@ int tcsetattr_stdin_TCSANOW(const struct termios *tp) FAST_FUNC;
1612#define TERMIOS_CLEAR_ISIG (1 << 0) 1612#define TERMIOS_CLEAR_ISIG (1 << 0)
1613#define TERMIOS_RAW_CRNL (1 << 1) 1613#define TERMIOS_RAW_CRNL (1 << 1)
1614#define TERMIOS_RAW_INPUT (1 << 2) 1614#define TERMIOS_RAW_INPUT (1 << 2)
1615int get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags) FAST_FUNC;
1615int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC; 1616int set_termios_to_raw(int fd, struct termios *oldterm, int flags) FAST_FUNC;
1616 1617
1617/* NB: "unsigned request" is crucial! "int request" will break some arches! */ 1618/* NB: "unsigned request" is crucial! "int request" will break some arches! */
diff --git a/init/bootchartd.c b/init/bootchartd.c
index b5dd17439..373cde2d8 100644
--- a/init/bootchartd.c
+++ b/init/bootchartd.c
@@ -2,11 +2,6 @@
2/* 2/*
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */ 4 */
5
6//applet:IF_BOOTCHARTD(APPLET(bootchartd, BB_DIR_SBIN, BB_SUID_DROP))
7
8//kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o
9
10//config:config BOOTCHARTD 5//config:config BOOTCHARTD
11//config: bool "bootchartd (10 kb)" 6//config: bool "bootchartd (10 kb)"
12//config: default y 7//config: default y
@@ -46,6 +41,10 @@
46//config: Enable reading and parsing of $PWD/bootchartd.conf 41//config: Enable reading and parsing of $PWD/bootchartd.conf
47//config: and /etc/bootchartd.conf files. 42//config: and /etc/bootchartd.conf files.
48 43
44//applet:IF_BOOTCHARTD(APPLET(bootchartd, BB_DIR_SBIN, BB_SUID_DROP))
45
46//kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o
47
49#include "libbb.h" 48#include "libbb.h"
50#include "common_bufsiz.h" 49#include "common_bufsiz.h"
51/* After libbb.h, since it needs sys/types.h on some systems */ 50/* After libbb.h, since it needs sys/types.h on some systems */
diff --git a/init/halt.c b/init/halt.c
index 632c6cc56..c6c857f08 100644
--- a/init/halt.c
+++ b/init/halt.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config HALT 9//config:config HALT
11//config: bool "halt (3.7 kb)" 10//config: bool "halt (3.7 kb)"
12//config: default y 11//config: default y
diff --git a/init/init.c b/init/init.c
index ab137a981..64e5c3e0b 100644
--- a/init/init.c
+++ b/init/init.c
@@ -8,7 +8,6 @@
8 * 8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11
12//config:config INIT 11//config:config INIT
13//config: bool "init (9.3 kb)" 12//config: bool "init (9.3 kb)"
14//config: default y 13//config: default y
diff --git a/klibc-utils/ipconfig.c.txt b/klibc-utils/ipconfig.c.txt
new file mode 100644
index 000000000..5dd95c16b
--- /dev/null
+++ b/klibc-utils/ipconfig.c.txt
@@ -0,0 +1,316 @@
1/*
2 * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com>
3 *
4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */
6//config:config IPCONFIG
7//config: bool "ipconfig"
8//config: default y
9//config: help
10//config: (Auto)configure network.
11
12//applet:IF_IPCONFIG(APPLET(ipconfig, BB_DIR_BIN, BB_SUID_DROP))
13
14//kbuild:lib-$(CONFIG_IPCONFIG) += ipconfig.o
15
16#include <net/if.h>
17#include "libbb.h"
18
19struct globals {
20 int fixed;
21 const char *hostname;
22};
23#define G (*ptr_to_globals)
24#define INIT_G() do { \
25 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
26} while (0)
27
28struct dev {
29 const char *name;
30 uint8_t fixed;
31 uint32_t ip_addr;
32 uint32_t ip_netmask;
33 uint32_t ip_server;
34 uint32_t ip_router;
35};
36
37static int
38parse_method(const char *method)
39{
40 int fixed;
41
42 fixed = (method[0] != '\0');
43 if (fixed) {
44 /* if it's not "" */
45 fixed = index_in_strings(
46 /* 0 */ "on""\0"
47 /* 1 */ "any""\0"
48 /* 2 */ "both""\0"
49 /* 3 */ "dhcp""\0"
50 /* 4 */ "bootp""\0"
51 /* 5 */ "rarp""\0"
52 /* 6 */ "none""\0"
53 /* 7 */ "static""\0"
54 /* 8 */ "off""\0"
55 , method
56 );
57 if (fixed > 0)
58 fixed /= 6;
59 }
60 return fixed;
61}
62
63static uint32_t
64parse_addr(const char *ip)
65{
66 struct in_addr in;
67 if (inet_aton(ip, &in) == 0)
68 bb_error_msg_and_die("bad IP address '%s'", ip);
69 return in.s_addr;
70}
71
72static struct dev*
73find_device(llist_t *iface_list, const char *name)
74{
75 while (iface_list) {
76 struct dev *dev = (void*) iface_list->data;
77 if (strcmp(dev->name, name) == 0)
78 return dev;
79 iface_list = iface_list->link;
80 }
81 return NULL;
82}
83
84static void
85set_from_template(struct dev *dev, struct dev *template)
86{
87 if (template->ip_addr != 0)
88 dev->ip_addr = template->ip_addr;
89 if (template->ip_netmask != 0)
90 dev->ip_netmask = template->ip_netmask;
91 if (template->ip_server != 0)
92 dev->ip_server = template->ip_server;
93 if (template->ip_router != 0)
94 dev->ip_router = template->ip_router;
95 dev->fixed = template->fixed;
96}
97
98// "ip=PROTO" - also implies -o
99// "nfsaddrs=PROTO" - also implies -o
100// "<devname>"
101// "[ip=/nfsaddrs=]IP:SERVER_IP:ROUTER:NETMASK:HOSTNAME:IFACE:METHOD"
102// all optional. trailing empty :: can be skipped, only one : needs to be there
103// (to distinguish from other formats).
104// ":::::eth0" - dhcp on eth0
105// ":" - dhcp on all ifaces
106// "::1.2.3.4" - dhcp on all ifaces, gateway is 1.2.3.4 (fairly nonsensical)
107static void
108add_all_devices(llist_t **iface_list, struct dev *template);
109static struct dev*
110add_device(llist_t **iface_list, char *ip)
111{
112 struct dev *dev;
113
114 dev = xzalloc(sizeof(*dev));
115 dev->fixed = G.fixed;
116
117 if (strncmp("ip=", ip, 3) == 0
118 || strncmp("nfsaddrs=", ip, 9) == 0
119 ) {
120 int fixed;
121
122 ip = strchr(ip, '=') + 1;
123 fixed = parse_method(ip);
124 if (fixed >= 0) {
125 add_all_devices(iface_list, dev);
126 free(dev);
127 return NULL;
128 }
129 }
130
131 if (!strchr(ip, ':')) {
132 dev->name = ip;
133 } else {
134 unsigned opt = 0;
135 while (ip && *ip) {
136 char *next = strchr(ip, ':');
137 if (next)
138 *next++ = '\0';
139 if (opt > 6)
140 bb_error_msg_and_die("too many options for %s", dev->name);
141 if (ip[0]) switch (opt) {
142 case 0:
143 dev->ip_addr = parse_addr(ip);
144 break;
145 case 1:
146 dev->ip_server = parse_addr(ip);
147 break;
148 case 2:
149 dev->ip_router = parse_addr(ip);
150 break;
151 case 3:
152 dev->ip_netmask = parse_addr(ip);
153 break;
154 case 4:
155 if (G.hostname && strcmp(G.hostname, ip) != 0)
156 bb_error_msg_and_die("hostname must be the same");
157 G.hostname = ip;
158 break;
159 case 5:
160 dev->name = ip;
161 break;
162 case 6:
163 dev->fixed = parse_method(ip);
164 break;
165 }
166 ip = next;
167 opt++;
168 }
169 }
170
171 if (dev->name == NULL
172 || strcmp(dev->name, "all") == 0
173 ) {
174 add_all_devices(iface_list, dev);
175 free(dev);
176 return NULL;
177 }
178 llist_add_to_end(iface_list, dev);
179 return dev;
180}
181
182static void
183add_all_devices(llist_t **iface_list, struct dev *template)
184{
185 DIR *d;
186 struct dirent *de;
187#define sys_class_net "/sys/class/net"
188
189 /* All forms of "config all ifaces" imply -o */
190 option_mask32 |= 1;
191
192 d = opendir(sys_class_net);
193 if (!d)
194 return;
195
196 while ((de = readdir(d)) != NULL) {
197 struct dev *dev;
198 char *filename;
199 char p[sizeof(long)*3];
200 unsigned long flags;
201 int r;
202
203 /* Exclude devices beginning with dots as well as . and .. */
204 if (de->d_name[0] == '.')
205 continue;
206 filename = xasprintf("%s/%s/flags", sys_class_net, de->d_name);
207 r = open_read_close(filename, p, sizeof(p) - 1);
208 free(filename);
209 if (r < 0)
210 continue;
211 p[r] = '\0';
212 /* file's format is "0xNNNN\n" */
213 flags = bb_strtoul(p, NULL, 0);
214 /*
215 * Heuristic for if this is a reasonable boot interface.
216 * This is the same logic the in-kernel ipconfig uses.
217 */
218 if (flags & IFF_LOOPBACK)
219 continue;
220 if (!(flags & (IFF_BROADCAST | IFF_POINTOPOINT)))
221 continue;
222 if (find_device(*iface_list, de->d_name))
223 continue;
224 dev = add_device(iface_list, xstrdup(de->d_name));
225 if (dev)
226 set_from_template(dev, template);
227 }
228 closedir(d);
229#undef sys_class_net
230}
231
232//usage:#define ipconfig_trivial_usage
233//usage: "[-c METHOD] [-t TIMEOUT] [-on] [-i VENDOR_ID] [-p PORT] [-d] IFACE..."
234//usage:#define ipconfig_full_usage "\n\n"
235//usage: "(Auto)configure network"
236//usage: "\n"
237//usage: "\n"" -c METHOD off/none/static or on/dhcp (default)"
238//usage: "\n"" -t SECONDS Give up after SECONDS"
239//usage: "\n"" -o Stop after one interface is configured"
240//usage: "\n"" -n Dry run"
241//usage: "\n"" -i VENDOR_ID DHCP vendor id (default '')"
242//usage: "\n"" -p PORT DHCP port to use"
243//usage: "\n"" [-d] IFACE... Interface(s)"
244//usage: "\n"
245//usage: "\n"" IFACE can be:"
246//usage: "\n"" all - configure all interfaces"
247//usage: "\n"" IFACE - configure this interface"
248//usage: "\n"" IP:SERVER_IP:ROUTER:NETMASK:HOSTNAME:IFACE:METHOD (all optional)"
249// TIMEOUT defaults to infinite
250// -d actually is an option with an argument
251// (not a clue why klibc-utils has two ways to specify interfaces)
252int ipconfig_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
253int ipconfig_main(int argc UNUSED_PARAM, char **argv)
254{
255 const char *method = "";
256 const char *vendor_id = "";
257 llist_t *devname_list = NULL;
258 llist_t *iface_list;
259 int timeout = -1;
260 unsigned port;
261 unsigned opt;
262
263 INIT_G();
264
265 opt = getopt32(argv,
266 "onc:t:i:p:+d:*",
267 &method, &timeout, &vendor_id, &port, &devname_list
268 );
269 argv += optind;
270
271 G.fixed = parse_method(method);
272 if (G.fixed < 0)
273 bb_show_usage();
274
275 iface_list = NULL;
276 while (devname_list)
277 add_device(&iface_list, (char*) llist_pop(&devname_list));
278 while (*argv)
279 add_device(&iface_list, *argv++);
280
281 while (iface_list) {
282 struct dev *dev = (void*) iface_list->data;
283 printf("name:'%s'\n", dev->name);
284 printf("fixed:%u\n" , dev->fixed);
285 printf("ip:%s/" , inet_ntoa(*(struct in_addr*)&dev->ip_addr));
286 printf("%s\n" , inet_ntoa(*(struct in_addr*)&dev->ip_netmask));
287 printf("server:%s\n", inet_ntoa(*(struct in_addr*)&dev->ip_server));
288 printf("router:%s\n", inet_ntoa(*(struct in_addr*)&dev->ip_router));
289 iface_list = iface_list->link;
290 }
291 bb_error_msg("hostname:'%s'", G.hostname);
292 bb_error_msg("fixed:%u", G.fixed);
293
294 return EXIT_SUCCESS;
295}
296//After device is configured, write out a "/run/net-IFACE.conf" file:
297// // udchcp env values:
298//write_option("DEVICE", dev->name); interface=eth0
299//write_option("PROTO", method);
300//write_option("IPV4ADDR", dev->ip_addr); ip=10.43.17.38
301//write_option("IPV4BROADCAST", dev->ip_broadcast); subnet=255.255.255.0 mask=24
302//write_option("IPV4NETMASK", dev->ip_netmask); subnet=255.255.255.0 mask=24
303//write_option("IPV4GATEWAY", dev->ip_gateway); router=10.43.17.254
304//write_option("IPV4DNS0", dev->ip_nameserver[0]); dns=10.38.5.26 10.11.5.19
305//write_option("IPV4DNS1", dev->ip_nameserver[1]); dns=10.38.5.26 10.11.5.19
306//write_option("HOSTNAME", dev->hostname); hostname="STR"
307//write_option("DNSDOMAIN", dev->dnsdomainname); domain=domain.com
308//write_option("NISDOMAIN", dev->nisdomainname); nisdomain="STR"
309//write_option("ROOTSERVER", my_inet_ntoa(dev->ip_server)); serverid=10.44.6.2
310//write_option("ROOTPATH", dev->bootpath); rootpath="STR"
311//write_option("filename", dev->filename); boot_file=/pxelinux.0
312//write_option("UPTIME", dev->uptime); sysinfo()->uptime
313//write_option("DHCPLEASETIME", dev->dhcpleasetime); lease=44148
314//write_option("DOMAINSEARCH", dev->domainsearch); search="ABC DEF"
315//
316//(write_option writes out single-quote escaped string, VAR='VAL')
diff --git a/klibc-utils/nuke.c b/klibc-utils/nuke.c
index a5d2f8d70..6b65f705f 100644
--- a/klibc-utils/nuke.c
+++ b/klibc-utils/nuke.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com> 2 * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com>
3 * 3 *
4 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */ 5 */
6//config:config NUKE 6//config:config NUKE
7//config: bool "nuke" 7//config: bool "nuke"
diff --git a/klibc-utils/resume.c b/klibc-utils/resume.c
index de142f350..f85384853 100644
--- a/klibc-utils/resume.c
+++ b/klibc-utils/resume.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com> 2 * Copyright (c) 2017 Denys Vlasenko <vda.linux@googlemail.com>
3 * 3 *
4 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */ 5 */
6//config:config RESUME 6//config:config RESUME
7//config: bool "resume" 7//config: bool "resume"
diff --git a/libbb/getopt32.c b/libbb/getopt32.c
index f778c6e89..378510063 100644
--- a/libbb/getopt32.c
+++ b/libbb/getopt32.c
@@ -517,7 +517,7 @@ vgetopt32(char **argv, const char *applet_opts, const char *applet_long_options,
517 } 517 }
518 518
519 /* In case getopt32 was already called: 519 /* In case getopt32 was already called:
520 * reset the libc getopt() function, which keeps internal state. 520 * reset libc getopt() internal state.
521 * run_nofork_applet() does this, but we might end up here 521 * run_nofork_applet() does this, but we might end up here
522 * also via gunzip_main() -> gzip_main(). Play safe. 522 * also via gunzip_main() -> gzip_main(). Play safe.
523 */ 523 */
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index c2b0a3842..d85057e72 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2321,7 +2321,7 @@ static int32_t reverse_i_search(int timeout)
2321 */ 2321 */
2322int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) 2322int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize)
2323{ 2323{
2324 int len; 2324 int len, n;
2325 int timeout; 2325 int timeout;
2326#if ENABLE_FEATURE_TAB_COMPLETION 2326#if ENABLE_FEATURE_TAB_COMPLETION
2327 smallint lastWasTab = 0; 2327 smallint lastWasTab = 0;
@@ -2336,15 +2336,15 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2336 2336
2337 INIT_S(); 2337 INIT_S();
2338 2338
2339 n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0
2340 | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */
2341 );
2339#if ENABLE_PLATFORM_MINGW32 2342#if ENABLE_PLATFORM_MINGW32
2340 memset(initial_settings.c_cc, 0, sizeof(initial_settings.c_cc));
2341 initial_settings.c_cc[VINTR] = CTRL('C'); 2343 initial_settings.c_cc[VINTR] = CTRL('C');
2342 initial_settings.c_cc[VEOF] = CTRL('D'); 2344 initial_settings.c_cc[VEOF] = CTRL('D');
2343 if (!isatty(0) || !isatty(1)) { 2345 if (n > 0 || !isatty(0) || !isatty(1)) {
2344#else 2346#else
2345 if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 2347 if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) {
2346 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON
2347 ) {
2348#endif 2348#endif
2349 /* Happens when e.g. stty -echo was run before. 2349 /* Happens when e.g. stty -echo was run before.
2350 * But if ICANON is not set, we don't come here. 2350 * But if ICANON is not set, we don't come here.
@@ -2398,18 +2398,6 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2398#endif 2398#endif
2399#define command command_must_not_be_used 2399#define command command_must_not_be_used
2400 2400
2401 new_settings = initial_settings;
2402 /* ~ICANON: unbuffered input (most c_cc[] are disabled, VMIN/VTIME are enabled) */
2403 /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */
2404 /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */
2405 new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG);
2406 /* reads will block only if < 1 char is available */
2407 new_settings.c_cc[VMIN] = 1;
2408 /* no timeout (reads block forever) */
2409 new_settings.c_cc[VTIME] = 0;
2410 /* Should be not needed if ISIG is off: */
2411 /* Turn off CTRL-C */
2412 /* new_settings.c_cc[VINTR] = _POSIX_VDISABLE; */
2413 tcsetattr_stdin_TCSANOW(&new_settings); 2401 tcsetattr_stdin_TCSANOW(&new_settings);
2414 2402
2415#if ENABLE_USERNAME_OR_HOMEDIR 2403#if ENABLE_USERNAME_OR_HOMEDIR
@@ -2942,7 +2930,7 @@ int main(int argc, char **argv)
2942#if ENABLE_FEATURE_EDITING_FANCY_PROMPT 2930#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
2943 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:" 2931 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:"
2944 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] " 2932 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] "
2945 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]"; 2933 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[m\\]";
2946#else 2934#else
2947 "% "; 2935 "% ";
2948#endif 2936#endif
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c
index b82a706d8..b3038e32d 100644
--- a/libbb/u_signal_names.c
+++ b/libbb/u_signal_names.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config FEATURE_RTMINMAX 9//config:config FEATURE_RTMINMAX
11//config: bool "Support RTMIN[+n] and RTMAX[-n] signal names" 10//config: bool "Support RTMIN[+n] and RTMAX[-n] signal names"
12//config: default y 11//config: default y
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index 1b3a1667b..0dfb3e2d9 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -311,40 +311,65 @@ int FAST_FUNC tcsetattr_stdin_TCSANOW(const struct termios *tp)
311 return tcsetattr(STDIN_FILENO, TCSANOW, tp); 311 return tcsetattr(STDIN_FILENO, TCSANOW, tp);
312} 312}
313 313
314int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags) 314int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct termios *oldterm, int flags)
315{ 315{
316//TODO: lineedit, microcom, slattach, less might be adapted to use this too: 316//TODO: slattach, shell read might be adapted to use this too: grep for "tcsetattr", "[VTIME] = 0"
317// grep for "tcsetattr" 317 int r;
318
319 struct termios newterm;
320 318
321 tcgetattr(fd, oldterm); 319 memset(oldterm, 0, sizeof(*oldterm)); /* paranoia */
322 newterm = *oldterm; 320 r = tcgetattr(fd, oldterm);
321 *newterm = *oldterm;
323 322
324 /* Turn off buffered input (ICANON) 323 /* Turn off buffered input (ICANON)
325 * Turn off echoing (ECHO) 324 * Turn off echoing (ECHO)
326 * and separate echoing of newline (ECHONL, normally off anyway) 325 * and separate echoing of newline (ECHONL, normally off anyway)
327 */ 326 */
328 newterm.c_lflag &= ~(ICANON | ECHO | ECHONL); 327 newterm->c_lflag &= ~(ICANON | ECHO | ECHONL);
329 if (flags & TERMIOS_CLEAR_ISIG) { 328 if (flags & TERMIOS_CLEAR_ISIG) {
330 /* dont recognize INT/QUIT/SUSP chars */ 329 /* dont recognize INT/QUIT/SUSP chars */
331 newterm.c_lflag &= ~ISIG; 330 newterm->c_lflag &= ~ISIG;
332 } 331 }
333 /* reads will block only if < 1 char is available */ 332 /* reads will block only if < 1 char is available */
334 newterm.c_cc[VMIN] = 1; 333 newterm->c_cc[VMIN] = 1;
335 /* no timeout (reads block forever) */ 334 /* no timeout (reads block forever) */
336 newterm.c_cc[VTIME] = 0; 335 newterm->c_cc[VTIME] = 0;
337 if (flags & TERMIOS_RAW_CRNL) { 336 if (flags & TERMIOS_RAW_CRNL) {
337/* IXON, IXOFF, and IXANY:
338 * IXOFF=1: sw flow control is enabled on input queue:
339 * tty transmits a STOP char when input queue is close to full
340 * and transmits a START char when input queue is nearly empty.
341 * IXON=1: sw flow control is enabled on output queue:
342 * tty will stop sending if STOP char is received,
343 * and resume sending if START is received, or if any char
344 * is received and IXANY=1.
345 */
346 /* IXON=0: XON/XOFF chars are treated as normal chars (why we do this?) */
338 /* dont convert CR to NL on input */ 347 /* dont convert CR to NL on input */
339 newterm.c_iflag &= ~(IXON | ICRNL); 348 newterm->c_iflag &= ~(IXON | ICRNL);
340 /* dont convert NL to CR on output */ 349 /* dont convert NL to CR+NL on output */
341 newterm.c_oflag &= ~(ONLCR); 350 newterm->c_oflag &= ~(ONLCR);
351 /* Maybe clear more c_oflag bits? Usually, only OPOST and ONLCR are set.
352 * OPOST Enable output processing (reqd for OLCUC and *NL* bits to work)
353 * OLCUC Map lowercase characters to uppercase on output.
354 * OCRNL Map CR to NL on output.
355 * ONOCR Don't output CR at column 0.
356 * ONLRET Don't output CR.
357 */
342 } 358 }
343 if (flags & TERMIOS_RAW_INPUT) { 359 if (flags & TERMIOS_RAW_INPUT) {
360 /* IXOFF=0: disable sending XON/XOFF if input buf is full */
361 /* IXON=0: input XON/XOFF chars are not special */
344 /* dont convert anything on input */ 362 /* dont convert anything on input */
345 newterm.c_iflag &= ~(BRKINT|INLCR|ICRNL|IXON|IXOFF|IUCLC|IXANY|IMAXBEL); 363 newterm->c_iflag &= ~(IXOFF|IXON|IXANY|BRKINT|INLCR|ICRNL|IUCLC|IMAXBEL);
346 } 364 }
365 return r;
366}
367
368int FAST_FUNC set_termios_to_raw(int fd, struct termios *oldterm, int flags)
369{
370 struct termios newterm;
347 371
372 get_termios_and_make_raw(fd, &newterm, oldterm, flags);
348 return tcsetattr(fd, TCSANOW, &newterm); 373 return tcsetattr(fd, TCSANOW, &newterm);
349} 374}
350 375
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index adef2328d..ec11b30ca 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 2007 by Tito Ragusa <farmatito@tiscali.it> 7 * Copyright (C) 2007 by Tito Ragusa <farmatito@tiscali.it>
8 * 8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 *
11 */ 10 */
12//config:config ADDGROUP 11//config:config ADDGROUP
13//config: bool "addgroup (8.2 kb)" 12//config: bool "addgroup (8.2 kb)"
diff --git a/miscutils/beep.c b/miscutils/beep.c
index b9b62f79b..0c8a8225e 100644
--- a/miscutils/beep.c
+++ b/miscutils/beep.c
@@ -5,7 +5,6 @@
5 * Copyright (C) 2009 Bernhard Reutner-Fischer 5 * Copyright (C) 2009 Bernhard Reutner-Fischer
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 *
9 */ 8 */
10//config:config BEEP 9//config:config BEEP
11//config: bool "beep (3 kb)" 10//config: bool "beep (3 kb)"
diff --git a/miscutils/chat.c b/miscutils/chat.c
index 1446a040c..2dfe52c4f 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -238,10 +238,18 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
238 , *argv 238 , *argv
239 ); 239 );
240 if (key >= 0) { 240 if (key >= 0) {
241 bool onoff;
241 // cache directive value 242 // cache directive value
242 char *arg = *++argv; 243 char *arg = *++argv;
244
245 if (!arg) {
246#if ENABLE_FEATURE_CHAT_TTY_HIFI
247 tcsetattr(STDIN_FILENO, TCSAFLUSH, &tio0);
248#endif
249 bb_show_usage();
250 }
243 // OFF -> 0, anything else -> 1 251 // OFF -> 0, anything else -> 1
244 bool onoff = (0 != strcmp("OFF", arg)); 252 onoff = (0 != strcmp("OFF", arg));
245 // process directive 253 // process directive
246 if (DIR_HANGUP == key) { 254 if (DIR_HANGUP == key) {
247 // turn SIGHUP on/off 255 // turn SIGHUP on/off
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 9ac91e01e..5b2e5ac56 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -65,6 +65,8 @@
65/* If you want logging messages on /tmp/fbsplash.log... */ 65/* If you want logging messages on /tmp/fbsplash.log... */
66#define DEBUG 0 66#define DEBUG 0
67 67
68#define ESC "\033"
69
68struct globals { 70struct globals {
69#if DEBUG 71#if DEBUG
70 bool bdebug_messages; // enable/disable logging 72 bool bdebug_messages; // enable/disable logging
@@ -514,7 +516,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
514 516
515 if (fifo_filename && bCursorOff) { 517 if (fifo_filename && bCursorOff) {
516 // hide cursor (BEFORE any fb ops) 518 // hide cursor (BEFORE any fb ops)
517 full_write(STDOUT_FILENO, "\033[?25l", 6); 519 full_write(STDOUT_FILENO, ESC"[?25l", 6);
518 } 520 }
519 521
520 fb_drawimage(); 522 fb_drawimage();
@@ -559,7 +561,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
559 } 561 }
560 562
561 if (bCursorOff) // restore cursor 563 if (bCursorOff) // restore cursor
562 full_write(STDOUT_FILENO, "\033[?25h", 6); 564 full_write(STDOUT_FILENO, ESC"[?25h", 6);
563 565
564 return EXIT_SUCCESS; 566 return EXIT_SUCCESS;
565} 567}
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c
new file mode 100644
index 000000000..bafb834b5
--- /dev/null
+++ b/miscutils/hexedit.c
@@ -0,0 +1,465 @@
1/*
2 * Copyright (C) 2017 Denys Vlasenko <vda.linux@googlemail.com>
3 *
4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */
6//config:config HEXEDIT
7//config: bool "hexedit"
8//config: default y
9//config: help
10//config: Edit file in hexadecimal.
11
12//applet:IF_HEXEDIT(APPLET(hexedit, BB_DIR_USR_BIN, BB_SUID_DROP))
13
14//kbuild:lib-$(CONFIG_HEXEDIT) += hexedit.o
15
16#include "libbb.h"
17
18#define ESC "\033"
19#define HOME ESC"[H"
20#define CLEAR ESC"[J"
21#define CLEAR_TILL_EOL ESC"[K"
22#define SET_ALT_SCR ESC"[?1049h"
23#define POP_ALT_SCR ESC"[?1049l"
24
25#undef CTRL
26#define CTRL(c) ((c) & (uint8_t)~0x60)
27
28struct globals {
29 smallint half;
30 smallint in_read_key;
31 int fd;
32 unsigned height;
33 unsigned row;
34 unsigned pagesize;
35 uint8_t *baseaddr;
36 uint8_t *current_byte;
37 uint8_t *eof_byte;
38 off_t size;
39 off_t offset;
40 /* needs to be zero-inited, thus keeping it in G: */
41 char read_key_buffer[KEYCODE_BUFFER_SIZE];
42 struct termios orig_termios;
43};
44#define G (*ptr_to_globals)
45#define INIT_G() do { \
46 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
47} while (0)
48
49//TODO: move to libbb
50#if defined(__x86_64__) || defined(i386)
51# define G_pagesize 4096
52# define INIT_PAGESIZE() ((void)0)
53#else
54# define G_pagesize (G.pagesize)
55# define INIT_PAGESIZE() ((void)(G.pagesize = getpagesize()))
56#endif
57
58/* hopefully there aren't arches with PAGE_SIZE > 64k */
59#define G_mapsize (64*1024)
60
61/* "12ef5670 (xx )*16 _1_3_5_7_9abcdef\n"NUL */
62#define LINEBUF_SIZE (8 + 1 + 3*16 + 16 + 1 + 1 /*paranoia:*/ + 13)
63
64static void restore_term(void)
65{
66 tcsetattr_stdin_TCSANOW(&G.orig_termios);
67 printf(POP_ALT_SCR);
68 fflush_all();
69}
70
71static void sig_catcher(int sig)
72{
73 if (!G.in_read_key) {
74 /* now it's not safe to do I/O, just inform the main loop */
75 bb_got_signal = sig;
76 return;
77 }
78 restore_term();
79 kill_myself_with_sig(sig);
80}
81
82static int format_line(char *hex, uint8_t *data, off_t offset)
83{
84 int ofs_pos;
85 char *text;
86 uint8_t *end, *end1;
87
88#if 1
89 /* Can be more than 4Gb, thus >8 chars, thus use a variable - don't assume 8! */
90 ofs_pos = sprintf(hex, "%08"OFF_FMT"x ", offset);
91#else
92 if (offset <= 0xffff)
93 ofs_pos = sprintf(hex, "%04"OFF_FMT"x ", offset);
94 else
95 ofs_pos = sprintf(hex, "%08"OFF_FMT"x ", offset);
96#endif
97 hex += ofs_pos;
98
99 text = hex + 16 * 3;
100 end1 = data + 15;
101 if ((G.size - offset) > 0) {
102 end = end1;
103 if ((G.size - offset) <= 15)
104 end = data + (G.size - offset) - 1;
105 while (data <= end) {
106 uint8_t c = *data++;
107 *hex++ = bb_hexdigits_upcase[c >> 4];
108 *hex++ = bb_hexdigits_upcase[c & 0xf];
109 *hex++ = ' ';
110 if (c < ' ' || c > 0x7e)
111 c = '.';
112 *text++ = c;
113 }
114 }
115 while (data <= end1) {
116 *hex++ = ' ';
117 *hex++ = ' ';
118 *hex++ = ' ';
119 *text++ = ' ';
120 data++;
121 }
122 *text = '\0';
123
124 return ofs_pos;
125}
126
127static void redraw(unsigned cursor)
128{
129 uint8_t *data;
130 off_t offset;
131 unsigned i, pos;
132
133 printf(HOME CLEAR);
134
135 /* if cursor is past end of screen, how many lines to move down? */
136 i = (cursor / 16) - G.height + 1;
137 if ((int)i < 0)
138 i = 0;
139
140 data = G.baseaddr + i * 16;
141 offset = G.offset + i * 16;
142 cursor -= i * 16;
143 pos = i = 0;
144 while (i < G.height) {
145 char buf[LINEBUF_SIZE];
146 pos = format_line(buf, data, offset);
147 printf(
148 "\r\n%s" + (!i) * 2, /* print \r\n only on 2nd line and later */
149 buf
150 );
151 data += 16;
152 offset += 16;
153 i++;
154 }
155
156 printf(ESC"[%u;%uH", 1 + cursor / 16, 1 + pos + (cursor & 0xf) * 3);
157}
158
159static void redraw_cur_line(void)
160{
161 char buf[LINEBUF_SIZE];
162 uint8_t *data;
163 off_t offset;
164 int column;
165
166 column = (0xf & (uintptr_t)G.current_byte);
167 data = G.current_byte - column;
168 offset = G.offset + (data - G.baseaddr);
169
170 column = column*3 + G.half;
171 column += format_line(buf, data, offset);
172 printf("%s"
173 "\r"
174 "%.*s",
175 buf + column,
176 column, buf
177 );
178}
179
180/* if remappers return 0, no change was done */
181static int remap(unsigned cur_pos)
182{
183 if (G.baseaddr)
184 munmap(G.baseaddr, G_mapsize);
185
186 G.baseaddr = mmap(NULL,
187 G_mapsize,
188 PROT_READ | PROT_WRITE,
189 MAP_SHARED,
190 G.fd,
191 G.offset
192 );
193 if (G.baseaddr == MAP_FAILED) {
194 restore_term();
195 bb_perror_msg_and_die("mmap");
196 }
197
198 G.current_byte = G.baseaddr + cur_pos;
199
200 G.eof_byte = G.baseaddr + G_mapsize;
201 if ((G.size - G.offset) < G_mapsize) {
202 /* mapping covers tail of the file */
203 /* we do have a mapped byte which is past eof */
204 G.eof_byte = G.baseaddr + (G.size - G.offset);
205 }
206 return 1;
207}
208static int move_mapping_further(void)
209{
210 unsigned pos;
211 unsigned pagesize;
212
213 if ((G.size - G.offset) < G_mapsize)
214 return 0; /* can't move mapping even further, it's at the end already */
215
216 pagesize = G_pagesize; /* constant on most arches */
217 pos = G.current_byte - G.baseaddr;
218 if (pos >= pagesize) {
219 /* move offset up until current position is in 1st page */
220 do {
221 G.offset += pagesize;
222 if (G.offset == 0) { /* whoops */
223 G.offset -= pagesize;
224 break;
225 }
226 pos -= pagesize;
227 } while (pos >= pagesize);
228 return remap(pos);
229 }
230 return 0;
231}
232static int move_mapping_lower(void)
233{
234 unsigned pos;
235 unsigned pagesize;
236
237 if (G.offset == 0)
238 return 0; /* we are at 0 already */
239
240 pagesize = G_pagesize; /* constant on most arches */
241 pos = G.current_byte - G.baseaddr;
242
243 /* move offset down until current position is in last page */
244 pos += pagesize;
245 while (pos < G_mapsize) {
246 pos += pagesize;
247 G.offset -= pagesize;
248 if (G.offset == 0)
249 break;
250 }
251 pos -= pagesize;
252
253 return remap(pos);
254}
255
256//usage:#define hexedit_trivial_usage
257//usage: "FILE"
258//usage:#define hexedit_full_usage "\n\n"
259//usage: "Edit FILE in hexadecimal"
260int hexedit_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
261int hexedit_main(int argc UNUSED_PARAM, char **argv)
262{
263 INIT_G();
264 INIT_PAGESIZE();
265
266 get_terminal_width_height(-1, NULL, &G.height);
267 if (1) {
268 /* reduce number of write() syscalls while PgUp/Down: fully buffered output */
269 unsigned sz = (G.height | 0xf) * LINEBUF_SIZE;
270 setvbuf(stdout, xmalloc(sz), _IOFBF, sz);
271 }
272
273 getopt32(argv, "^" "" "\0" "=1"/*one arg*/);
274 argv += optind;
275
276 G.fd = xopen(*argv, O_RDWR);
277 G.size = xlseek(G.fd, 0, SEEK_END);
278
279 /* TERMIOS_RAW_CRNL suppresses \n -> \r\n translation, helps with down-arrow */
280 printf(SET_ALT_SCR);
281 set_termios_to_raw(STDIN_FILENO, &G.orig_termios, TERMIOS_RAW_CRNL);
282 bb_signals(BB_FATAL_SIGS, sig_catcher);
283
284 remap(0);
285 redraw(0);
286
287//TODO: //Home/End: start/end of line; '<'/'>': start/end of file
288 //Backspace: undo
289 //Ctrl-L: redraw
290 //Ctrl-Z: suspend
291 //'/', Ctrl-S: search
292//TODO: detect window resize
293
294 for (;;) {
295 unsigned cnt;
296 int32_t key = key; /* for compiler */
297 uint8_t byte;
298
299 fflush_all();
300 G.in_read_key = 1;
301 if (!bb_got_signal)
302 key = read_key(STDIN_FILENO, G.read_key_buffer, -1);
303 G.in_read_key = 0;
304 if (bb_got_signal)
305 key = CTRL('X');
306
307 cnt = 1;
308 if ((unsigned)(key - 'A') <= 'Z' - 'A')
309 key |= 0x20; /* convert A-Z to a-z */
310 switch (key) {
311 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
312 /* convert to '0'+10...15 */
313 key = key - ('a' - '0' - 10);
314 /* fall through */
315 case '0': case '1': case '2': case '3': case '4':
316 case '5': case '6': case '7': case '8': case '9':
317 if (G.current_byte == G.eof_byte) {
318 if (!move_mapping_further()) {
319 /* already at EOF; extend the file */
320 if (++G.size <= 0 /* overflow? */
321 || ftruncate(G.fd, G.size) != 0 /* error extending? (e.g. block dev) */
322 ) {
323 G.size--;
324 break;
325 }
326 G.eof_byte++;
327 }
328 }
329 key -= '0';
330 byte = *G.current_byte & 0xf0;
331 if (!G.half) {
332 byte = *G.current_byte & 0x0f;
333 key <<= 4;
334 }
335 *G.current_byte = byte + key;
336 /* can't just print one updated hex char: need to update right-hand ASCII too */
337 redraw_cur_line();
338 /* fall through */
339 case KEYCODE_RIGHT:
340 if (G.current_byte == G.eof_byte)
341 break; /* eof - don't allow going past it */
342 byte = *G.current_byte;
343 if (!G.half) {
344 G.half = 1;
345 putchar(bb_hexdigits_upcase[byte >> 4]);
346 } else {
347 G.half = 0;
348 G.current_byte++;
349 if ((0xf & (uintptr_t)G.current_byte) == 0) {
350 /* rightmost pos, wrap to next line */
351 if (G.current_byte == G.eof_byte)
352 move_mapping_further();
353 printf(ESC"[46D"); /* cursor left 3*15 + 1 chars */
354 goto down;
355 }
356 putchar(bb_hexdigits_upcase[byte & 0xf]);
357 putchar(' ');
358 }
359 break;
360 case KEYCODE_PAGEDOWN:
361 cnt = G.height;
362 case KEYCODE_DOWN:
363 k_down:
364 G.current_byte += 16;
365 if (G.current_byte >= G.eof_byte) {
366 move_mapping_further();
367 if (G.current_byte > G.eof_byte) {
368 /* _after_ eof - don't allow this */
369 G.current_byte -= 16;
370 break;
371 }
372 }
373 down:
374 putchar('\n'); /* down one line, possibly scroll screen */
375 G.row++;
376 if (G.row >= G.height) {
377 G.row--;
378 redraw_cur_line();
379 }
380 if (--cnt)
381 goto k_down;
382 break;
383
384 case KEYCODE_LEFT:
385 if (G.half) {
386 G.half = 0;
387 printf(ESC"[D");
388 break;
389 }
390 if ((0xf & (uintptr_t)G.current_byte) == 0) {
391 /* leftmost pos, wrap to prev line */
392 if (G.current_byte == G.baseaddr) {
393 if (!move_mapping_lower())
394 break; /* first line, don't do anything */
395 }
396 G.half = 1;
397 G.current_byte--;
398 printf(ESC"[46C"); /* cursor right 3*15 + 1 chars */
399 goto up;
400 }
401 G.half = 1;
402 G.current_byte--;
403 printf(ESC"[2D");
404 break;
405 case KEYCODE_PAGEUP:
406 cnt = G.height;
407 case KEYCODE_UP:
408 k_up:
409 if ((G.current_byte - G.baseaddr) < 16) {
410 if (!move_mapping_lower())
411 break; /* already at 0, stop */
412 }
413 G.current_byte -= 16;
414 up:
415 if (G.row != 0) {
416 G.row--;
417 printf(ESC"[A"); /* up (won't scroll) */
418 } else {
419 //printf(ESC"[T"); /* scroll up */ - not implemented on Linux VT!
420 printf(ESC"M"); /* scroll up */
421 redraw_cur_line();
422 }
423 if (--cnt)
424 goto k_up;
425 break;
426
427 case '\n':
428 case '\r':
429 /* [Enter]: goto specified position */
430 {
431 char buf[sizeof(G.offset)*3 + 4];
432 printf(ESC"[999;1H" CLEAR_TILL_EOL); /* go to last line */
433 if (read_line_input(NULL, "Go to (dec,0Xhex,0oct): ", buf, sizeof(buf)) > 0) {
434 off_t t;
435 unsigned cursor;
436
437 t = bb_strtoull(buf, NULL, 0);
438 if (t >= G.size)
439 t = G.size - 1;
440 cursor = t & (G_pagesize - 1);
441 t -= cursor;
442 if (t < 0)
443 cursor = t = 0;
444 if (t != 0 && cursor < 0x1ff) {
445 /* very close to end of page, possibly to EOF */
446 /* move one page lower */
447 t -= G_pagesize;
448 cursor += G_pagesize;
449 }
450 G.offset = t;
451 remap(cursor);
452 redraw(cursor);
453 break;
454 }
455 /* ^C/EOF/error: fall through to exiting */
456 }
457 case CTRL('X'):
458 restore_term();
459 return EXIT_SUCCESS;
460 } /* switch */
461 } /* for (;;) */
462
463 /* not reached */
464 return EXIT_SUCCESS;
465}
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 30f606e8e..fc392d9dc 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -8,7 +8,6 @@
8 * 8 *
9 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 9 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
10 */ 10 */
11
12//config:config I2CGET 11//config:config I2CGET
13//config: bool "i2cget (5.6 kb)" 12//config: bool "i2cget (5.6 kb)"
14//config: default y 13//config: default y
@@ -61,10 +60,8 @@
61 */ 60 */
62 61
63#include "libbb.h" 62#include "libbb.h"
64#include "common_bufsiz.h"
65 63
66#include <linux/i2c.h> 64#include <linux/i2c.h>
67#include <linux/i2c-dev.h>
68 65
69#define I2CDUMP_NUM_REGS 256 66#define I2CDUMP_NUM_REGS 256
70 67
@@ -72,6 +69,25 @@
72#define I2CDETECT_MODE_QUICK 1 69#define I2CDETECT_MODE_QUICK 1
73#define I2CDETECT_MODE_READ 2 70#define I2CDETECT_MODE_READ 2
74 71
72/* linux/i2c-dev.h from i2c-tools overwrites the one from linux uapi
73 * and defines symbols already defined by linux/i2c.h.
74 * Also, it defines a bunch of static inlines which we would rather NOT
75 * inline. What a mess.
76 * We need only these definitions from linux/i2c-dev.h:
77 */
78#define I2C_SLAVE 0x0703
79#define I2C_SLAVE_FORCE 0x0706
80#define I2C_FUNCS 0x0705
81#define I2C_PEC 0x0708
82#define I2C_SMBUS 0x0720
83struct i2c_smbus_ioctl_data {
84 __u8 read_write;
85 __u8 command;
86 __u32 size;
87 union i2c_smbus_data *data;
88};
89/* end linux/i2c-dev.h */
90
75/* 91/*
76 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers. 92 * This is needed for ioctl_or_perror_and_die() since it only accepts pointers.
77 */ 93 */
@@ -438,19 +454,20 @@ static void confirm_action(int bus_addr, int mode, int data_addr, int pec)
438 454
439#if ENABLE_I2CGET 455#if ENABLE_I2CGET
440//usage:#define i2cget_trivial_usage 456//usage:#define i2cget_trivial_usage
441//usage: "[-f] [-y] BUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]" 457//usage: "[-fy] BUS CHIP-ADDRESS [DATA-ADDRESS [MODE]]"
442//usage:#define i2cget_full_usage "\n\n" 458//usage:#define i2cget_full_usage "\n\n"
443//usage: "Read from I2C/SMBus chip registers\n" 459//usage: "Read from I2C/SMBus chip registers"
444//usage: "\n I2CBUS i2c bus number" 460//usage: "\n"
445//usage: "\n ADDRESS 0x03 - 0x77" 461//usage: "\n I2CBUS I2C bus number"
462//usage: "\n ADDRESS 0x03-0x77"
446//usage: "\nMODE is:" 463//usage: "\nMODE is:"
447//usage: "\n b read byte data (default)" 464//usage: "\n b Read byte data (default)"
448//usage: "\n w read word data" 465//usage: "\n w Read word data"
449//usage: "\n c write byte/read byte" 466//usage: "\n c Write byte/read byte"
450//usage: "\n Append p for SMBus PEC" 467//usage: "\n Append p for SMBus PEC"
451//usage: "\n" 468//usage: "\n"
452//usage: "\n -f force access" 469//usage: "\n -f Force access"
453//usage: "\n -y disable interactive mode" 470//usage: "\n -y Disable interactive mode"
454int i2cget_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 471int i2cget_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
455int i2cget_main(int argc UNUSED_PARAM, char **argv) 472int i2cget_main(int argc UNUSED_PARAM, char **argv)
456{ 473{
@@ -520,23 +537,24 @@ int i2cget_main(int argc UNUSED_PARAM, char **argv)
520 537
521#if ENABLE_I2CSET 538#if ENABLE_I2CSET
522//usage:#define i2cset_trivial_usage 539//usage:#define i2cset_trivial_usage
523//usage: "[-f] [-y] [-m MASK] BUS CHIP-ADDR DATA-ADDR [VALUE] ... [MODE]" 540//usage: "[-fy] [-m MASK] BUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]"
524//usage:#define i2cset_full_usage "\n\n" 541//usage:#define i2cset_full_usage "\n\n"
525//usage: "Set I2C registers\n" 542//usage: "Set I2C registers"
526//usage: "\n I2CBUS i2c bus number" 543//usage: "\n"
527//usage: "\n ADDRESS 0x03 - 0x77" 544//usage: "\n I2CBUS I2C bus number"
545//usage: "\n ADDRESS 0x03-0x77"
528//usage: "\nMODE is:" 546//usage: "\nMODE is:"
529//usage: "\n c byte, no value" 547//usage: "\n c Byte, no value"
530//usage: "\n b byte data (default)" 548//usage: "\n b Byte data (default)"
531//usage: "\n w word data" 549//usage: "\n w Word data"
532//usage: "\n i I2C block data" 550//usage: "\n i I2C block data"
533//usage: "\n s SMBus block data" 551//usage: "\n s SMBus block data"
534//usage: "\n Append p for SMBus PEC" 552//usage: "\n Append p for SMBus PEC"
535//usage: "\n" 553//usage: "\n"
536//usage: "\n -f force access" 554//usage: "\n -f Force access"
537//usage: "\n -y disable interactive mode" 555//usage: "\n -y Disable interactive mode"
538//usage: "\n -r read back and compare the result" 556//usage: "\n -r Read back and compare the result"
539//usage: "\n -m MASK mask specifying which bits to write" 557//usage: "\n -m MASK Mask specifying which bits to write"
540int i2cset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 558int i2cset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
541int i2cset_main(int argc, char **argv) 559int i2cset_main(int argc, char **argv)
542{ 560{
@@ -879,23 +897,24 @@ static void dump_word_data(int bus_fd, unsigned first, unsigned last)
879} 897}
880 898
881//usage:#define i2cdump_trivial_usage 899//usage:#define i2cdump_trivial_usage
882//usage: "[-f] [-r FIRST-LAST] [-y] BUS ADDR [MODE]" 900//usage: "[-fy] [-r FIRST-LAST] BUS ADDR [MODE]"
883//usage:#define i2cdump_full_usage "\n\n" 901//usage:#define i2cdump_full_usage "\n\n"
884//usage: "Examine I2C registers\n" 902//usage: "Examine I2C registers"
885//usage: "\n I2CBUS i2c bus number" 903//usage: "\n"
886//usage: "\n ADDRESS 0x03 - 0x77" 904//usage: "\n I2CBUS I2C bus number"
905//usage: "\n ADDRESS 0x03-0x77"
887//usage: "\nMODE is:" 906//usage: "\nMODE is:"
888//usage: "\n b byte (default)" 907//usage: "\n b Byte (default)"
889//usage: "\n w word" 908//usage: "\n w Word"
890//usage: "\n W word on even register addresses" 909//usage: "\n W Word on even register addresses"
891//usage: "\n i I2C block" 910//usage: "\n i I2C block"
892//usage: "\n s SMBus block" 911//usage: "\n s SMBus block"
893//usage: "\n c consecutive byte" 912//usage: "\n c Consecutive byte"
894//usage: "\n Append p for SMBus PEC" 913//usage: "\n Append p for SMBus PEC"
895//usage: "\n" 914//usage: "\n"
896//usage: "\n -f force access" 915//usage: "\n -f Force access"
897//usage: "\n -y disable interactive mode" 916//usage: "\n -y Disable interactive mode"
898//usage: "\n -r limit the number of registers being accessed" 917//usage: "\n -r Limit the number of registers being accessed"
899int i2cdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 918int i2cdump_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
900int i2cdump_main(int argc UNUSED_PARAM, char **argv) 919int i2cdump_main(int argc UNUSED_PARAM, char **argv)
901{ 920{
@@ -1188,18 +1207,17 @@ static void will_skip(const char *cmd)
1188} 1207}
1189 1208
1190//usage:#define i2cdetect_trivial_usage 1209//usage:#define i2cdetect_trivial_usage
1191//usage: "[-F I2CBUS] [-l] [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]" 1210//usage: "-l | -F I2CBUS | [-ya] [-q|-r] I2CBUS [FIRST LAST]"
1192//usage:#define i2cdetect_full_usage "\n\n" 1211//usage:#define i2cdetect_full_usage "\n\n"
1193//usage: "Detect I2C chips.\n" 1212//usage: "Detect I2C chips"
1194//usage: "\n I2CBUS i2c bus number"
1195//usage: "\n FIRST and LAST limit the probing range"
1196//usage: "\n" 1213//usage: "\n"
1197//usage: "\n -l output list of installed busses" 1214//usage: "\n -l List installed buses"
1198//usage: "\n -y disable interactive mode" 1215//usage: "\n -F BUS# List functionalities on this bus"
1199//usage: "\n -a force scanning of non-regular addresses" 1216//usage: "\n -y Disable interactive mode"
1200//usage: "\n -q use smbus quick write commands for probing (default)" 1217//usage: "\n -a Force scanning of non-regular addresses"
1201//usage: "\n -r use smbus read byte commands for probing" 1218//usage: "\n -q Use smbus quick write commands for probing (default)"
1202//usage: "\n -F display list of functionalities" 1219//usage: "\n -r Use smbus read byte commands for probing"
1220//usage: "\n FIRST and LAST limit probing range"
1203int i2cdetect_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1221int i2cdetect_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1204int i2cdetect_main(int argc UNUSED_PARAM, char **argv) 1222int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
1205{ 1223{
@@ -1214,7 +1232,8 @@ int i2cdetect_main(int argc UNUSED_PARAM, char **argv)
1214 opts = getopt32(argv, "^" 1232 opts = getopt32(argv, "^"
1215 "yaqrFl" 1233 "yaqrFl"
1216 "\0" 1234 "\0"
1217 "q--r:r--q:"/*mutually exclusive*/ "?3"/*up to 3 args*/ 1235 "q--r:r--q:"/*mutually exclusive*/
1236 "?3"/*up to 3 args*/
1218 ); 1237 );
1219 argv += optind; 1238 argv += optind;
1220 1239
diff --git a/miscutils/less.c b/miscutils/less.c
index 8a5b9ff0b..4ab0e17da 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10/* 9/*
11 * TODO: 10 * TODO:
12 * - Add more regular expression support - search modifiers, certain matches, etc. 11 * - Add more regular expression support - search modifiers, certain matches, etc.
@@ -20,7 +19,6 @@
20 * - the inp file pointer is used so that keyboard input works after 19 * - the inp file pointer is used so that keyboard input works after
21 * redirected input has been read from stdin 20 * redirected input has been read from stdin
22 */ 21 */
23
24//config:config LESS 22//config:config LESS
25//config: bool "less (15 kb)" 23//config: bool "less (15 kb)"
26//config: default y 24//config: default y
@@ -141,9 +139,9 @@
141#define ESC "\033" 139#define ESC "\033"
142/* The escape codes for highlighted and normal text */ 140/* The escape codes for highlighted and normal text */
143#define HIGHLIGHT ESC"[7m" 141#define HIGHLIGHT ESC"[7m"
144#define NORMAL ESC"[0m" 142#define NORMAL ESC"[m"
145/* The escape code to home and clear to the end of screen */ 143/* The escape code to home and clear to the end of screen */
146#define CLEAR ESC"[H\033[J" 144#define CLEAR ESC"[H"ESC"[J"
147/* The escape code to clear to the end of line */ 145/* The escape code to clear to the end of line */
148#define CLEAR_2_EOL ESC"[K" 146#define CLEAR_2_EOL ESC"[K"
149 147
@@ -285,9 +283,9 @@ static void set_tty_cooked(void)
285 283
286/* Move the cursor to a position (x,y), where (0,0) is the 284/* Move the cursor to a position (x,y), where (0,0) is the
287 top-left corner of the console */ 285 top-left corner of the console */
288static void move_cursor(int line, int row) 286static void move_cursor(int line, int col)
289{ 287{
290 printf(ESC"[%u;%uH", line, row); 288 printf(ESC"[%u;%uH", line, col);
291} 289}
292 290
293static void clear_line(void) 291static void clear_line(void)
@@ -1070,7 +1068,7 @@ static void reinitialize(void)
1070 open_file_and_read_lines(); 1068 open_file_and_read_lines();
1071#if ENABLE_FEATURE_LESS_ASK_TERMINAL 1069#if ENABLE_FEATURE_LESS_ASK_TERMINAL
1072 if (G.winsize_err) 1070 if (G.winsize_err)
1073 printf("\033[999;999H" "\033[6n"); 1071 printf(ESC"[999;999H" ESC"[6n");
1074#endif 1072#endif
1075#if ENABLE_PLATFORM_MINGW32 1073#if ENABLE_PLATFORM_MINGW32
1076 reset_screen(); 1074 reset_screen();
@@ -1135,7 +1133,7 @@ static int64_t getch_nowait(void)
1135 goto again; 1133 goto again;
1136 } 1134 }
1137 /* EOF/error (ssh session got killed etc) */ 1135 /* EOF/error (ssh session got killed etc) */
1138 less_exit(0); 1136 less_exit(EXIT_SUCCESS);
1139 } 1137 }
1140 set_tty_cooked(); 1138 set_tty_cooked();
1141 return key64; 1139 return key64;
@@ -1839,8 +1837,8 @@ int less_main(int argc, char **argv)
1839{ 1837{
1840#if !ENABLE_PLATFORM_MINGW32 1838#if !ENABLE_PLATFORM_MINGW32
1841 char *tty_name; 1839 char *tty_name;
1842 int tty_fd;
1843#endif 1840#endif
1841 int tty_fd;
1844 1842
1845 INIT_G(); 1843 INIT_G();
1846 1844
@@ -1901,18 +1899,12 @@ int less_main(int argc, char **argv)
1901 G.kbd_fd_orig_flags = ndelay_on(tty_fd); 1899 G.kbd_fd_orig_flags = ndelay_on(tty_fd);
1902 kbd_fd = tty_fd; /* save in a global */ 1900 kbd_fd = tty_fd; /* save in a global */
1903#else 1901#else
1904 kbd_fd = 0; 1902 kbd_fd = tty_fd = 0;
1905#endif 1903#endif
1906 1904
1907 tcgetattr(kbd_fd, &term_orig); 1905 get_termios_and_make_raw(tty_fd, &term_less, &term_orig, TERMIOS_RAW_CRNL);
1908 term_less = term_orig;
1909 term_less.c_lflag &= ~(ICANON | ECHO);
1910 term_less.c_iflag &= ~(IXON | ICRNL);
1911 /*term_less.c_oflag &= ~ONLCR;*/
1912 term_less.c_cc[VMIN] = 1;
1913 term_less.c_cc[VTIME] = 0;
1914 1906
1915 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(kbd_fd, &width, &max_displayed_line); 1907 IF_FEATURE_LESS_ASK_TERMINAL(G.winsize_err =) get_terminal_width_height(tty_fd, &width, &max_displayed_line);
1916 /* 20: two tabstops + 4 */ 1908 /* 20: two tabstops + 4 */
1917 if (width < 20 || max_displayed_line < 3) 1909 if (width < 20 || max_displayed_line < 3)
1918 return bb_cat(argv); 1910 return bb_cat(argv);
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index b87f3273f..fa090057e 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -33,15 +33,11 @@
33// set raw tty mode 33// set raw tty mode
34static void xget1(int fd, struct termios *t, struct termios *oldt) 34static void xget1(int fd, struct termios *t, struct termios *oldt)
35{ 35{
36//TODO: use set_termios_to_raw() 36 get_termios_and_make_raw(fd, t, oldt, 0
37 tcgetattr(fd, oldt); 37 | TERMIOS_CLEAR_ISIG /* ^C is ASCII char 3, not "interrupt me!" */
38 *t = *oldt; 38 | TERMIOS_RAW_INPUT /* pass all chars verbatim, no special handling or translating CR->NL */
39 cfmakeraw(t); 39 | TERMIOS_RAW_CRNL /* dont convert NL<->CR on output too */
40// t->c_lflag &= ~(ISIG|ICANON|ECHO|IEXTEN); 40 );
41// t->c_iflag &= ~(BRKINT|IXON|ICRNL);
42// t->c_oflag &= ~(ONLCR);
43// t->c_cc[VMIN] = 1;
44// t->c_cc[VTIME] = 0;
45} 41}
46 42
47static int xset1(int fd, struct termios *tio, const char *device) 43static int xset1(int fd, struct termios *tio, const char *device)
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index 80a005821..72f028ed3 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -7,7 +7,6 @@
7 * 7 *
8 * TODO: add support for large (>4GB) MTD devices 8 * TODO: add support for large (>4GB) MTD devices
9 */ 9 */
10
11//config:config NANDWRITE 10//config:config NANDWRITE
12//config: bool "nandwrite (5.9 kb)" 11//config: bool "nandwrite (5.9 kb)"
13//config: default y 12//config: default y
diff --git a/miscutils/raidautorun.c b/miscutils/raidautorun.c
index caf6e0821..d315c2734 100644
--- a/miscutils/raidautorun.c
+++ b/miscutils/raidautorun.c
@@ -5,7 +5,6 @@
5 * Copyright (C) 2006 Bernhard Reutner-Fischer 5 * Copyright (C) 2006 Bernhard Reutner-Fischer
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 *
9 */ 8 */
10//config:config RAIDAUTORUN 9//config:config RAIDAUTORUN
11//config: bool "raidautorun (1.4 kb)" 10//config: bool "raidautorun (1.4 kb)"
diff --git a/miscutils/rfkill.c b/miscutils/rfkill.c
index 546928402..ae38c182d 100644
--- a/miscutils/rfkill.c
+++ b/miscutils/rfkill.c
@@ -1,12 +1,11 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3* rfkill implementation for busybox 3 * rfkill implementation for busybox
4* 4 *
5* Copyright (C) 2010 Malek Degachi <malek-degachi@laposte.net> 5 * Copyright (C) 2010 Malek Degachi <malek-degachi@laposte.net>
6* 6 *
7* Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8*/ 8 */
9
10//config:config RFKILL 9//config:config RFKILL
11//config: bool "rfkill (5.3 kb)" 10//config: bool "rfkill (5.3 kb)"
12//config: default n # doesn't build on Ubuntu 9.04 11//config: default n # doesn't build on Ubuntu 9.04
diff --git a/miscutils/setfattr.c b/miscutils/setfattr.c
new file mode 100644
index 000000000..f0ef227cb
--- /dev/null
+++ b/miscutils/setfattr.c
@@ -0,0 +1,68 @@
1/*
2 * setfattr - set extended attributes of filesystem objects.
3 *
4 * Copyright (C) 2017 by Denys Vlasenko <vda.linux@googlemail.com>
5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */
8//config:config SETFATTR
9//config: bool "setfattr"
10//config: default y
11//config: help
12//config: Set/delete extended attributes on files
13
14//applet:IF_SETFATTR(APPLET_NOEXEC(setfattr, setfattr, BB_DIR_USR_BIN, BB_SUID_DROP, setfattr))
15
16//kbuild:lib-$(CONFIG_SETFATTR) += setfattr.o
17
18#include <sys/xattr.h>
19#include "libbb.h"
20
21//usage:#define setfattr_trivial_usage
22//usage: "[-h] -n|-x ATTR [-v VALUE] FILE..."
23//usage:#define setfattr_full_usage "\n\n"
24//usage: "Set extended attributes"
25//usage: "\n"
26//usage: "\n -h Do not follow symlinks"
27//usage: "\n -x ATTR Remove attribute ATTR"
28//usage: "\n -n ATTR Set attribute ATTR to VALUE"
29//usage: "\n -v VALUE (default: empty)"
30int setfattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
31int setfattr_main(int argc UNUSED_PARAM, char **argv)
32{
33 const char *name;
34 const char *value = "";
35 int status;
36 int opt;
37 enum {
38 OPT_h = (1 << 0),
39 OPT_x = (1 << 1),
40 };
41
42 opt = getopt32(argv, "^"
43 "hx:n:v:"
44 /* Min one arg, either -x or -n is a must, -x does not allow -v */
45 "\0" "-1:x:n:n--x:x--nv:v--x"
46 , &name, &name, &value
47 );
48 argv += optind;
49
50 status = EXIT_SUCCESS;
51 do {
52 int r;
53 if (opt & OPT_x)
54 r = ((opt & OPT_h) ? lremovexattr : removexattr)(*argv, name);
55 else {
56 r = ((opt & OPT_h) ? lsetxattr : setxattr)(
57 *argv, name,
58 value, strlen(value), /*flags:*/ 0
59 );
60 }
61 if (r) {
62 bb_simple_perror_msg(*argv);
63 status = EXIT_FAILURE;
64 }
65 } while (*++argv);
66
67 return status;
68}
diff --git a/miscutils/setserial.c b/miscutils/setserial.c
index f217c3beb..fd88ed106 100644
--- a/miscutils/setserial.c
+++ b/miscutils/setserial.c
@@ -7,7 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10
11//config:config SETSERIAL 10//config:config SETSERIAL
12//config: bool "setserial (6.6 kb)" 11//config: bool "setserial (6.6 kb)"
13//config: default y 12//config: default y
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c
index d142d1144..1ef8fd90e 100644
--- a/miscutils/ubi_tools.c
+++ b/miscutils/ubi_tools.c
@@ -2,7 +2,6 @@
2 * 2 *
3 * Licensed under GPLv2, see file LICENSE in this source tree. 3 * Licensed under GPLv2, see file LICENSE in this source tree.
4 */ 4 */
5
6//config:config UBIATTACH 5//config:config UBIATTACH
7//config: bool "ubiattach (4.7 kb)" 6//config: bool "ubiattach (4.7 kb)"
8//config: default y 7//config: default y
diff --git a/networking/hostname.c b/networking/hostname.c
index d87f6562f..8e3238d99 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12
13//config:config HOSTNAME 12//config:config HOSTNAME
14//config: bool "hostname (5.6 kb)" 13//config: bool "hostname (5.6 kb)"
15//config: default y 14//config: default y
diff --git a/networking/httpd.c b/networking/httpd.c
index 9369de824..74196a4f1 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1371,12 +1371,13 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
1371 out_cnt += count; 1371 out_cnt += count;
1372 count = 0; 1372 count = 0;
1373 /* "Status" header format is: "Status: 302 Redirected\r\n" */ 1373 /* "Status" header format is: "Status: 302 Redirected\r\n" */
1374 if (out_cnt >= 7 && memcmp(rbuf, "Status:", 7) == 0) { 1374 if (out_cnt >= 8 && memcmp(rbuf, "Status: ", 8) == 0) {
1375 /* send "HTTP/1.0 " */ 1375 /* send "HTTP/1.0 " */
1376 if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9) 1376 if (full_write(STDOUT_FILENO, HTTP_200, 9) != 9)
1377 break; 1377 break;
1378 rbuf += 7; /* skip "Status:" */ 1378 /* skip "Status: " (including space, sending "HTTP/1.0 NNN" is wrong) */
1379 count = out_cnt - 7; 1379 rbuf += 8;
1380 count = out_cnt - 8;
1380 out_cnt = -1; /* buffering off */ 1381 out_cnt = -1; /* buffering off */
1381 } else if (out_cnt >= 4) { 1382 } else if (out_cnt >= 4) {
1382 /* Did CGI add "HTTP"? */ 1383 /* Did CGI add "HTTP"? */
@@ -2337,7 +2338,7 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr)
2337 if (STRNCASECMP(iobuf, "Range:") == 0) { 2338 if (STRNCASECMP(iobuf, "Range:") == 0) {
2338 /* We know only bytes=NNN-[MMM] */ 2339 /* We know only bytes=NNN-[MMM] */
2339 char *s = skip_whitespace(iobuf + sizeof("Range:")-1); 2340 char *s = skip_whitespace(iobuf + sizeof("Range:")-1);
2340 if (is_prefixed_with(s, "bytes=") == 0) { 2341 if (is_prefixed_with(s, "bytes=")) {
2341 s += sizeof("bytes=")-1; 2342 s += sizeof("bytes=")-1;
2342 range_start = BB_STRTOOFF(s, &s, 10); 2343 range_start = BB_STRTOOFF(s, &s, 10);
2343 if (s[0] != '-' || range_start < 0) { 2344 if (s[0] != '-' || range_start < 0) {
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index c2cfe82ec..5521e8a5a 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -16,7 +16,6 @@
16 * 16 *
17 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 17 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
18 */ 18 */
19
20//config:config IFUP 19//config:config IFUP
21//config: bool "ifup (17 kb)" 20//config: bool "ifup (17 kb)"
22//config: default y 21//config: default y
diff --git a/networking/interface.c b/networking/interface.c
index c5c8f2cdd..119185881 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -223,7 +223,7 @@ static char* FAST_FUNC UNSPEC_print(unsigned char *ptr)
223 pos = buff; 223 pos = buff;
224 for (i = 0; i < sizeof(struct sockaddr); i++) { 224 for (i = 0; i < sizeof(struct sockaddr); i++) {
225 /* careful -- not every libc's sprintf returns # bytes written */ 225 /* careful -- not every libc's sprintf returns # bytes written */
226 sprintf(pos, "%02X-", (*ptr++ & 0377)); 226 sprintf(pos, "%02X-", *ptr++);
227 pos += 3; 227 pos += 3;
228 } 228 }
229 /* Erase trailing "-". Works as long as sizeof(struct sockaddr) != 0 */ 229 /* Erase trailing "-". Works as long as sizeof(struct sockaddr) != 0 */
@@ -704,9 +704,8 @@ static char* FAST_FUNC ether_print(unsigned char *ptr)
704{ 704{
705 char *buff; 705 char *buff;
706 buff = xasprintf("%02X:%02X:%02X:%02X:%02X:%02X", 706 buff = xasprintf("%02X:%02X:%02X:%02X:%02X:%02X",
707 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), 707 ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]
708 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377) 708 );
709 );
710 return auto_string(buff); 709 return auto_string(buff);
711} 710}
712 711
diff --git a/networking/ip.c b/networking/ip.c
index 8aaeef0db..0bc0edc57 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -126,13 +126,13 @@
126//config: Ethernet, wireless, infrared, ppp/slip, ip tunnelling 126//config: Ethernet, wireless, infrared, ppp/slip, ip tunnelling
127//config: link types are supported without this option selected. 127//config: link types are supported without this option selected.
128 128
129//applet:IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP)) 129//applet:IF_IP( APPLET_NOEXEC(ip , ip , BB_DIR_SBIN, BB_SUID_DROP, ip ))
130//applet:IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP)) 130//applet:IF_IPADDR( APPLET_NOEXEC(ipaddr , ipaddr , BB_DIR_SBIN, BB_SUID_DROP, ipaddr ))
131//applet:IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP)) 131//applet:IF_IPLINK( APPLET_NOEXEC(iplink , iplink , BB_DIR_SBIN, BB_SUID_DROP, iplink ))
132//applet:IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP)) 132//applet:IF_IPROUTE( APPLET_NOEXEC(iproute , iproute , BB_DIR_SBIN, BB_SUID_DROP, iproute ))
133//applet:IF_IPRULE(APPLET(iprule, BB_DIR_SBIN, BB_SUID_DROP)) 133//applet:IF_IPRULE( APPLET_NOEXEC(iprule , iprule , BB_DIR_SBIN, BB_SUID_DROP, iprule ))
134//applet:IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_SBIN, BB_SUID_DROP)) 134//applet:IF_IPTUNNEL(APPLET_NOEXEC(iptunnel, iptunnel, BB_DIR_SBIN, BB_SUID_DROP, iptunnel))
135//applet:IF_IPNEIGH(APPLET(ipneigh, BB_DIR_SBIN, BB_SUID_DROP)) 135//applet:IF_IPNEIGH( APPLET_NOEXEC(ipneigh , ipneigh , BB_DIR_SBIN, BB_SUID_DROP, ipneigh ))
136 136
137//kbuild:lib-$(CONFIG_IP) += ip.o 137//kbuild:lib-$(CONFIG_IP) += ip.o
138//kbuild:lib-$(CONFIG_IPADDR) += ip.o 138//kbuild:lib-$(CONFIG_IPADDR) += ip.o
diff --git a/networking/nameif.c b/networking/nameif.c
index 1f2695495..91d50536a 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 10 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 */ 11 */
12
13//config:config NAMEIF 12//config:config NAMEIF
14//config: bool "nameif (6.6 kb)" 13//config: bool "nameif (6.6 kb)"
15//config: default y 14//config: default y
diff --git a/networking/nbd-client.c b/networking/nbd-client.c
index cf1857231..bedb01a1c 100644
--- a/networking/nbd-client.c
+++ b/networking/nbd-client.c
@@ -3,20 +3,20 @@
3 * 3 *
4 * Licensed under GPLv2, see file LICENSE in this source tree. 4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */ 5 */
6#include "libbb.h"
7#include <netinet/tcp.h>
8#include <linux/fs.h>
9
10//applet:IF_NBDCLIENT(APPLET_NOEXEC(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient))
11
12//kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o
13
14//config:config NBDCLIENT 6//config:config NBDCLIENT
15//config: bool "nbd-client (4.6 kb)" 7//config: bool "nbd-client (4.6 kb)"
16//config: default y 8//config: default y
17//config: help 9//config: help
18//config: Network block device client 10//config: Network block device client
19 11
12//applet:IF_NBDCLIENT(APPLET_NOEXEC(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient))
13
14//kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o
15
16#include "libbb.h"
17#include <netinet/tcp.h>
18#include <linux/fs.h>
19
20#define NBD_SET_SOCK _IO(0xab, 0) 20#define NBD_SET_SOCK _IO(0xab, 0)
21#define NBD_SET_BLKSIZE _IO(0xab, 1) 21#define NBD_SET_BLKSIZE _IO(0xab, 1)
22#define NBD_SET_SIZE _IO(0xab, 2) 22#define NBD_SET_SIZE _IO(0xab, 2)
diff --git a/networking/nc.c b/networking/nc.c
index 3437c565e..4b8f9c13a 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -13,17 +13,23 @@
13//config: A simple Unix utility which reads and writes data across network 13//config: A simple Unix utility which reads and writes data across network
14//config: connections. 14//config: connections.
15//config: 15//config:
16//config:config NETCAT
17//config: bool "netcat (11 kb)"
18//config: default n
19//config: help
20//config: Alias to nc.
21//config:
16//config:config NC_SERVER 22//config:config NC_SERVER
17//config: bool "Netcat server options (-l)" 23//config: bool "Netcat server options (-l)"
18//config: default y 24//config: default y
19//config: depends on NC 25//config: depends on NC || NETCAT
20//config: help 26//config: help
21//config: Allow netcat to act as a server. 27//config: Allow netcat to act as a server.
22//config: 28//config:
23//config:config NC_EXTRA 29//config:config NC_EXTRA
24//config: bool "Netcat extensions (-eiw and -f FILE)" 30//config: bool "Netcat extensions (-eiw and -f FILE)"
25//config: default y 31//config: default y
26//config: depends on NC 32//config: depends on NC || NETCAT
27//config: help 33//config: help
28//config: Add -e (support for executing the rest of the command line after 34//config: Add -e (support for executing the rest of the command line after
29//config: making or receiving a successful connection), -i (delay interval for 35//config: making or receiving a successful connection), -i (delay interval for
@@ -31,8 +37,8 @@
31//config: 37//config:
32//config:config NC_110_COMPAT 38//config:config NC_110_COMPAT
33//config: bool "Netcat 1.10 compatibility (+2.5k)" 39//config: bool "Netcat 1.10 compatibility (+2.5k)"
34//config: default n # off specially for Rob 40//config: default y
35//config: depends on NC 41//config: depends on NC || NETCAT
36//config: help 42//config: help
37//config: This option makes nc closely follow original nc-1.10. 43//config: This option makes nc closely follow original nc-1.10.
38//config: The code is about 2.5k bigger. It enables 44//config: The code is about 2.5k bigger. It enables
@@ -40,8 +46,11 @@
40//config: busybox-specific extensions: -f FILE. 46//config: busybox-specific extensions: -f FILE.
41 47
42//applet:IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP)) 48//applet:IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP))
49// APPLET_ODDNAME:name main location suid_type help
50//applet:IF_NETCAT(APPLET_ODDNAME(netcat, nc, BB_DIR_USR_BIN, BB_SUID_DROP, nc))
43 51
44//kbuild:lib-$(CONFIG_NC) += nc.o 52//kbuild:lib-$(CONFIG_NC) += nc.o
53//kbuild:lib-$(CONFIG_NETCAT) += nc.o
45 54
46#include "libbb.h" 55#include "libbb.h"
47#include "common_bufsiz.h" 56#include "common_bufsiz.h"
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 25fa44389..4f881eaf9 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2235,7 +2235,7 @@ static NOINLINE void ntp_init(char **argv)
2235 "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ 2235 "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */
2236 IF_FEATURE_NTPD_SERVER("I:") /* compat */ 2236 IF_FEATURE_NTPD_SERVER("I:") /* compat */
2237 "d" /* compat */ 2237 "d" /* compat */
2238 "46aAbgL", /* compat, ignored */ 2238 "46aAbgL" /* compat, ignored */
2239 "\0" 2239 "\0"
2240 "dd:wn" /* -d: counter; -p: list; -w implies -n */ 2240 "dd:wn" /* -d: counter; -p: list; -w implies -n */
2241 IF_FEATURE_NTPD_SERVER(":Il") /* -I implies -l */ 2241 IF_FEATURE_NTPD_SERVER(":Il") /* -I implies -l */
diff --git a/networking/ping.c b/networking/ping.c
index 7460e4414..774f8f3e0 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -24,28 +24,6 @@
24 * This version is an adaptation of ping.c from busybox. 24 * This version is an adaptation of ping.c from busybox.
25 * The code was modified by Bart Visscher <magick@linux-fan.com> 25 * The code was modified by Bart Visscher <magick@linux-fan.com>
26 */ 26 */
27
28#include <net/if.h>
29#include <netinet/ip_icmp.h>
30#include "libbb.h"
31#include "common_bufsiz.h"
32
33#ifdef __BIONIC__
34/* should be in netinet/ip_icmp.h */
35# define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
36# define ICMP_SOURCE_QUENCH 4 /* Source Quench */
37# define ICMP_REDIRECT 5 /* Redirect (change route) */
38# define ICMP_ECHO 8 /* Echo Request */
39# define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
40# define ICMP_PARAMETERPROB 12 /* Parameter Problem */
41# define ICMP_TIMESTAMP 13 /* Timestamp Request */
42# define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
43# define ICMP_INFO_REQUEST 15 /* Information Request */
44# define ICMP_INFO_REPLY 16 /* Information Reply */
45# define ICMP_ADDRESS 17 /* Address Mask Request */
46# define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
47#endif
48
49//config:config PING 27//config:config PING
50//config: bool "ping (9.5 kb)" 28//config: bool "ping (9.5 kb)"
51//config: default y 29//config: default y
@@ -136,6 +114,27 @@
136//usage: "1 packets transmitted, 1 packets received, 0% packet loss\n" 114//usage: "1 packets transmitted, 1 packets received, 0% packet loss\n"
137//usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" 115//usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n"
138 116
117#include <net/if.h>
118#include <netinet/ip_icmp.h>
119#include "libbb.h"
120#include "common_bufsiz.h"
121
122#ifdef __BIONIC__
123/* should be in netinet/ip_icmp.h */
124# define ICMP_DEST_UNREACH 3 /* Destination Unreachable */
125# define ICMP_SOURCE_QUENCH 4 /* Source Quench */
126# define ICMP_REDIRECT 5 /* Redirect (change route) */
127# define ICMP_ECHO 8 /* Echo Request */
128# define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */
129# define ICMP_PARAMETERPROB 12 /* Parameter Problem */
130# define ICMP_TIMESTAMP 13 /* Timestamp Request */
131# define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */
132# define ICMP_INFO_REQUEST 15 /* Information Request */
133# define ICMP_INFO_REPLY 16 /* Information Reply */
134# define ICMP_ADDRESS 17 /* Address Mask Request */
135# define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */
136#endif
137
139#if ENABLE_PING6 138#if ENABLE_PING6
140# include <netinet/icmp6.h> 139# include <netinet/icmp6.h>
141/* I see RENUMBERED constants in bits/in.h - !!? 140/* I see RENUMBERED constants in bits/in.h - !!?
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 849ca1388..714555fa8 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -8,7 +8,6 @@
8 * 8 *
9 * Licensed under GPLv2, see file LICENSE in this source tree. 9 * Licensed under GPLv2, see file LICENSE in this source tree.
10 */ 10 */
11
12//config:config UDHCPC6 11//config:config UDHCPC6
13//config: bool "udhcpc6" 12//config: bool "udhcpc6"
14//config: default n # not yet ready 13//config: default n # not yet ready
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 55e0400b9..99d91bf70 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1183,44 +1183,6 @@ static void client_background(void)
1183//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" 1183//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n"
1184//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." 1184//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..."
1185//usage:#define udhcpc_full_usage "\n" 1185//usage:#define udhcpc_full_usage "\n"
1186//usage: IF_LONG_OPTS(
1187//usage: "\n -i,--interface IFACE Interface to use (default eth0)"
1188//usage: IF_FEATURE_UDHCP_PORT(
1189//usage: "\n -P,--client-port PORT Use PORT (default 68)"
1190//usage: )
1191//usage: "\n -s,--script PROG Run PROG at DHCP events (default "CONFIG_UDHCPC_DEFAULT_SCRIPT")"
1192//usage: "\n -p,--pidfile FILE Create pidfile"
1193//usage: "\n -B,--broadcast Request broadcast replies"
1194//usage: "\n -t,--retries N Send up to N discover packets (default 3)"
1195//usage: "\n -T,--timeout SEC Pause between packets (default 3)"
1196//usage: "\n -A,--tryagain SEC Wait if lease is not obtained (default 20)"
1197//usage: "\n -n,--now Exit if lease is not obtained"
1198//usage: "\n -q,--quit Exit after obtaining lease"
1199//usage: "\n -R,--release Release IP on exit"
1200//usage: "\n -f,--foreground Run in foreground"
1201//usage: USE_FOR_MMU(
1202//usage: "\n -b,--background Background if lease is not obtained"
1203//usage: )
1204//usage: "\n -S,--syslog Log to syslog too"
1205//usage: IF_FEATURE_UDHCPC_ARPING(
1206//usage: "\n -a[MSEC],--arping[=MSEC] Validate offered address with ARP ping"
1207//usage: )
1208//usage: "\n -r,--request IP Request this IP address"
1209//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)"
1210//usage: "\n -O,--request-option OPT Request option OPT from server (cumulative)"
1211//usage: "\n -x OPT:VAL Include option OPT in sent packets (cumulative)"
1212//usage: "\n Examples of string, numeric, and hex byte opts:"
1213//usage: "\n -x hostname:bbox - option 12"
1214//usage: "\n -x lease:3600 - option 51 (lease time)"
1215//usage: "\n -x 0x3d:0100BEEFC0FFEE - option 61 (client id)"
1216//usage: "\n -F,--fqdn NAME Ask server to update DNS mapping for NAME"
1217//usage: "\n -V,--vendorclass VENDOR Vendor identifier (default 'udhcp VERSION')"
1218//usage: "\n -C,--clientid-none Don't send MAC as client identifier"
1219//usage: IF_UDHCP_VERBOSE(
1220//usage: "\n -v Verbose"
1221//usage: )
1222//usage: )
1223//usage: IF_NOT_LONG_OPTS(
1224//usage: "\n -i IFACE Interface to use (default eth0)" 1186//usage: "\n -i IFACE Interface to use (default eth0)"
1225//usage: IF_FEATURE_UDHCP_PORT( 1187//usage: IF_FEATURE_UDHCP_PORT(
1226//usage: "\n -P PORT Use PORT (default 68)" 1188//usage: "\n -P PORT Use PORT (default 68)"
@@ -1256,7 +1218,6 @@ static void client_background(void)
1256//usage: IF_UDHCP_VERBOSE( 1218//usage: IF_UDHCP_VERBOSE(
1257//usage: "\n -v Verbose" 1219//usage: "\n -v Verbose"
1258//usage: ) 1220//usage: )
1259//usage: )
1260//usage: "\nSignals:" 1221//usage: "\nSignals:"
1261//usage: "\n USR1 Renew lease" 1222//usage: "\n USR1 Renew lease"
1262//usage: "\n USR2 Release lease" 1223//usage: "\n USR2 Release lease"
diff --git a/networking/vconfig.c b/networking/vconfig.c
index 62a483865..8548c8c3b 100644
--- a/networking/vconfig.c
+++ b/networking/vconfig.c
@@ -6,9 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10/* BB_AUDIT SUSv3 N/A */
11
12//config:config VCONFIG 9//config:config VCONFIG
13//config: bool "vconfig (2.5 kb)" 10//config: bool "vconfig (2.5 kb)"
14//config: default y 11//config: default y
@@ -34,6 +31,8 @@
34#include "libbb.h" 31#include "libbb.h"
35#include <net/if.h> 32#include <net/if.h>
36 33
34/* BB_AUDIT SUSv3 N/A */
35
37/* Stuff from linux/if_vlan.h, kernel version 2.4.23 */ 36/* Stuff from linux/if_vlan.h, kernel version 2.4.23 */
38enum vlan_ioctl_cmds { 37enum vlan_ioctl_cmds {
39 ADD_VLAN_CMD, 38 ADD_VLAN_CMD,
diff --git a/networking/wget.c b/networking/wget.c
index 0001ddcba..1f5ab8bc2 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -8,7 +8,6 @@
8 * Copyright (C) 2010 Bradley M. Kuhn <bkuhn@ebb.org> 8 * Copyright (C) 2010 Bradley M. Kuhn <bkuhn@ebb.org>
9 * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2. 9 * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2.
10 */ 10 */
11
12//config:config WGET 11//config:config WGET
13//config: bool "wget (35 kb)" 12//config: bool "wget (35 kb)"
14//config: default y 13//config: default y
diff --git a/networking/whois.c b/networking/whois.c
index fd1cdf43e..f0ec86301 100644
--- a/networking/whois.c
+++ b/networking/whois.c
@@ -9,7 +9,6 @@
9 * Add ipv6 support 9 * Add ipv6 support
10 * Add proxy support 10 * Add proxy support
11 */ 11 */
12
13//config:config WHOIS 12//config:config WHOIS
14//config: bool "whois (6.6 kb)" 13//config: bool "whois (6.6 kb)"
15//config: default y 14//config: default y
diff --git a/procps/iostat.c b/procps/iostat.c
index 050625f57..09aae7102 100644
--- a/procps/iostat.c
+++ b/procps/iostat.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config IOSTAT 9//config:config IOSTAT
11//config: bool "iostat (7.4 kb)" 10//config: bool "iostat (7.4 kb)"
12//config: default y 11//config: default y
diff --git a/procps/kill.c b/procps/kill.c
index 0ddae2f70..24cc903fc 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -184,6 +184,10 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
184 if (is_killall5 && arg[0] == 'o') 184 if (is_killall5 && arg[0] == 'o')
185 goto do_it_now; 185 goto do_it_now;
186 186
187 /* "--" separates options from args. Testcase: "kill -- -123" */
188 if (!is_killall5 && arg[0] == '-' && arg[1] == '\0')
189 goto do_it_sooner;
190
187 if (argv[1] && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */ 191 if (argv[1] && arg[0] == 's' && arg[1] == '\0') { /* -s SIG? */
188 arg = *++argv; 192 arg = *++argv;
189 } /* else it must be -SIG */ 193 } /* else it must be -SIG */
@@ -192,6 +196,7 @@ int kill_main(int argc UNUSED_PARAM, char **argv)
192 bb_error_msg("bad signal name '%s'", arg); 196 bb_error_msg("bad signal name '%s'", arg);
193 return EXIT_FAILURE; 197 return EXIT_FAILURE;
194 } 198 }
199 do_it_sooner:
195 arg = *++argv; 200 arg = *++argv;
196 201
197 do_it_now: 202 do_it_now:
diff --git a/procps/lsof.c b/procps/lsof.c
index 8d3a23cc8..4917cf899 100644
--- a/procps/lsof.c
+++ b/procps/lsof.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config LSOF 9//config:config LSOF
11//config: bool "lsof (3.6 kb)" 10//config: bool "lsof (3.6 kb)"
12//config: default y 11//config: default y
diff --git a/procps/mpstat.c b/procps/mpstat.c
index c6279f9d8..b1ac09d75 100644
--- a/procps/mpstat.c
+++ b/procps/mpstat.c
@@ -6,18 +6,17 @@
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9
10//applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP))
11/* shouldn't be noexec: "mpstat INTERVAL" runs indefinitely */
12
13//kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o
14
15//config:config MPSTAT 9//config:config MPSTAT
16//config: bool "mpstat (10 kb)" 10//config: bool "mpstat (10 kb)"
17//config: default y 11//config: default y
18//config: help 12//config: help
19//config: Per-processor statistics 13//config: Per-processor statistics
20 14
15//applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP))
16/* shouldn't be noexec: "mpstat INTERVAL" runs indefinitely */
17
18//kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o
19
21#include "libbb.h" 20#include "libbb.h"
22#include <sys/utsname.h> /* struct utsname */ 21#include <sys/utsname.h> /* struct utsname */
23 22
diff --git a/procps/nmeter.c b/procps/nmeter.c
index 9463f94dc..166c8ab18 100644
--- a/procps/nmeter.c
+++ b/procps/nmeter.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Contact me: vda.linux@googlemail.com 6 * Contact me: vda.linux@googlemail.com
7 */ 7 */
8
9//config:config NMETER 8//config:config NMETER
10//config: bool "nmeter (10 kb)" 9//config: bool "nmeter (10 kb)"
11//config: default y 10//config: default y
diff --git a/procps/pmap.c b/procps/pmap.c
index 5c2d1ad59..c8fa0d280 100644
--- a/procps/pmap.c
+++ b/procps/pmap.c
@@ -7,7 +7,6 @@
7 * Licensed under GPLv2 or later, see the LICENSE file in this source tree 7 * Licensed under GPLv2 or later, see the LICENSE file in this source tree
8 * for details. 8 * for details.
9 */ 9 */
10
11//config:config PMAP 10//config:config PMAP
12//config: bool "pmap (6 kb)" 11//config: bool "pmap (6 kb)"
13//config: default y 12//config: default y
@@ -15,6 +14,7 @@
15//config: Display processes' memory mappings. 14//config: Display processes' memory mappings.
16 15
17//applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP)) 16//applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP))
17
18//kbuild:lib-$(CONFIG_PMAP) += pmap.o 18//kbuild:lib-$(CONFIG_PMAP) += pmap.o
19 19
20//usage:#define pmap_trivial_usage 20//usage:#define pmap_trivial_usage
diff --git a/procps/powertop.c b/procps/powertop.c
index 5d522bf91..2872035cf 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -51,6 +51,8 @@
51/* Max filename length of entry in /sys/devices subsystem */ 51/* Max filename length of entry in /sys/devices subsystem */
52#define BIG_SYSNAME_LEN 16 52#define BIG_SYSNAME_LEN 16
53 53
54#define ESC "\033"
55
54typedef unsigned long long ullong; 56typedef unsigned long long ullong;
55 57
56struct line { 58struct line {
@@ -776,8 +778,8 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
776 } 778 }
777 } 779 }
778 780
779 /* Clear the screen */ 781 /* Home; clear screen */
780 printf("\033[H\033[J"); 782 printf(ESC"[H" ESC"[J");
781 783
782 /* Clear C-state lines */ 784 /* Clear C-state lines */
783 memset(&cstate_lines, 0, sizeof(cstate_lines)); 785 memset(&cstate_lines, 0, sizeof(cstate_lines));
diff --git a/procps/pwdx.c b/procps/pwdx.c
index c72cf804a..6009e2aa3 100644
--- a/procps/pwdx.c
+++ b/procps/pwdx.c
@@ -7,7 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this source tree. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10
11//config:config PWDX 10//config:config PWDX
12//config: bool "pwdx (3.5 kb)" 11//config: bool "pwdx (3.5 kb)"
13//config: default y 12//config: default y
diff --git a/procps/smemcap.c b/procps/smemcap.c
index 17aeccd53..f2e2de29d 100644
--- a/procps/smemcap.c
+++ b/procps/smemcap.c
@@ -7,11 +7,6 @@
7 the GNU General Public License version 2 or later, incorporated 7 the GNU General Public License version 2 or later, incorporated
8 herein by reference. 8 herein by reference.
9*/ 9*/
10
11//applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP))
12
13//kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o
14
15//config:config SMEMCAP 10//config:config SMEMCAP
16//config: bool "smemcap (2.5 kb)" 11//config: bool "smemcap (2.5 kb)"
17//config: default y 12//config: default y
@@ -19,6 +14,10 @@
19//config: smemcap is a tool for capturing process data for smem, 14//config: smemcap is a tool for capturing process data for smem,
20//config: a memory usage statistic tool. 15//config: a memory usage statistic tool.
21 16
17//applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP))
18
19//kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o
20
22#include "libbb.h" 21#include "libbb.h"
23#define BB_ARCHIVE_PUBLIC 22#define BB_ARCHIVE_PUBLIC
24#include "bb_archive.h" 23#include "bb_archive.h"
diff --git a/procps/top.c b/procps/top.c
index f97ded5d6..b777c494e 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -117,6 +117,7 @@
117 117
118#include "libbb.h" 118#include "libbb.h"
119 119
120#define ESC "\033"
120 121
121typedef struct top_status_t { 122typedef struct top_status_t {
122 unsigned long vsz; 123 unsigned long vsz;
@@ -580,7 +581,7 @@ static unsigned long display_header(int scr_width, int *lines_rem_p)
580 meminfo[MI_BUFFERS], 581 meminfo[MI_BUFFERS],
581 meminfo[MI_CACHED]); 582 meminfo[MI_CACHED]);
582 /* Go to top & clear to the end of screen */ 583 /* Go to top & clear to the end of screen */
583 printf(OPT_BATCH_MODE ? "%s\n" : "\033[H\033[J%s\n", scrbuf); 584 printf(OPT_BATCH_MODE ? "%s\n" : ESC"[H" ESC"[J" "%s\n", scrbuf);
584 (*lines_rem_p)--; 585 (*lines_rem_p)--;
585 586
586 /* Display CPU time split as percentage of total time. 587 /* Display CPU time split as percentage of total time.
@@ -618,7 +619,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
618#endif 619#endif
619 620
620 /* what info of the processes is shown */ 621 /* what info of the processes is shown */
621 printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, 622 printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width,
622 " PID PPID USER STAT VSZ %VSZ" 623 " PID PPID USER STAT VSZ %VSZ"
623 IF_FEATURE_TOP_SMP_PROCESS(" CPU") 624 IF_FEATURE_TOP_SMP_PROCESS(" CPU")
624 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") 625 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
@@ -802,7 +803,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p)
802 meminfo[MI_ANONPAGES], 803 meminfo[MI_ANONPAGES],
803 meminfo[MI_MAPPED], 804 meminfo[MI_MAPPED],
804 meminfo[MI_MEMFREE]); 805 meminfo[MI_MEMFREE]);
805 printf(OPT_BATCH_MODE ? "%.*s\n" : "\033[H\033[J%.*s\n", scr_width, line_buf); 806 printf(OPT_BATCH_MODE ? "%.*s\n" : ESC"[H" ESC"[J" "%.*s\n", scr_width, line_buf);
806 807
807 snprintf(line_buf, LINE_BUF_SIZE, 808 snprintf(line_buf, LINE_BUF_SIZE,
808 " slab:%lu buf:%lu cache:%lu dirty:%lu write:%lu", 809 " slab:%lu buf:%lu cache:%lu dirty:%lu write:%lu",
@@ -844,7 +845,7 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width)
844 cp[6] = ch; 845 cp[6] = ch;
845 do *cp++ = ch; while (*cp == ' '); 846 do *cp++ = ch; while (*cp == ' ');
846 847
847 printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); 848 printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, line_buf);
848 lines_rem--; 849 lines_rem--;
849 850
850 if (lines_rem > ntop - G_scroll_ofs) 851 if (lines_rem > ntop - G_scroll_ofs)
diff --git a/procps/watch.c b/procps/watch.c
index 6fc9f7db7..420e6d3d1 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -7,10 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10
11/* BB_AUDIT SUSv3 N/A */
12/* BB_AUDIT GNU defects -- only option -n is supported. */
13
14//config:config WATCH 10//config:config WATCH
15//config: bool "watch (4.1 kb)" 11//config: bool "watch (4.1 kb)"
16//config: default y 12//config: default y
@@ -35,8 +31,13 @@
35//usage: "Mon Dec 17 10:31:42 GMT 2000\n" 31//usage: "Mon Dec 17 10:31:42 GMT 2000\n"
36//usage: "Mon Dec 17 10:31:44 GMT 2000" 32//usage: "Mon Dec 17 10:31:44 GMT 2000"
37 33
34/* BB_AUDIT SUSv3 N/A */
35/* BB_AUDIT GNU defects -- only option -n is supported. */
36
38#include "libbb.h" 37#include "libbb.h"
39 38
39#define ESC "\033"
40
40// procps 2.0.18: 41// procps 2.0.18:
41// watch [-d] [-n seconds] 42// watch [-d] [-n seconds]
42// [--differences[=cumulative]] [--interval=seconds] command 43// [--differences[=cumulative]] [--interval=seconds] command
@@ -77,7 +78,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv)
77 header = NULL; 78 header = NULL;
78 while (1) { 79 while (1) {
79 /* home; clear to the end of screen */ 80 /* home; clear to the end of screen */
80 printf("\033[H""\033[J"); 81 printf(ESC"[H" ESC"[J");
81 if (!(opt & 0x2)) { // no -t 82 if (!(opt & 0x2)) { // no -t
82 const unsigned time_len = sizeof("1234-67-90 23:56:89"); 83 const unsigned time_len = sizeof("1234-67-90 23:56:89");
83 84
diff --git a/runit/svlogd.c b/runit/svlogd.c
index 739483356..dfd7e38a0 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -123,7 +123,6 @@ log message, you can use a pattern like this instead
123 123
124-*: *: pid * 124-*: *: pid *
125*/ 125*/
126
127//config:config SVLOGD 126//config:config SVLOGD
128//config: bool "svlogd (15 kb)" 127//config: bool "svlogd (15 kb)"
129//config: default y 128//config: default y
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 41ac23936..f69591c69 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -76,14 +76,53 @@ static void conf_askvalue(struct symbol *sym, const char *def)
76 76
77 line[0] = '\n'; 77 line[0] = '\n';
78 line[1] = 0; 78 line[1] = 0;
79 line[2] = 0;
79 80
80 if (!sym_is_changable(sym)) { 81 if (!sym_is_changable(sym)) {
81 printf("%s\n", def); 82 printf("%s\n", def);
82 line[0] = '\n';
83 line[1] = 0;
84 return; 83 return;
85 } 84 }
86 85
86 // If autoconf run (allnoconfig and such), reset bool and tristates:
87 // "select ITEM" sets ITEM=y and then parent item might have been
88 // reset to "n" later. Try to set ITEM to "n" on the second run.
89 if (type == S_BOOLEAN || type == S_TRISTATE) {
90 switch (input_mode) {
91 case set_yes:
92 if (sym_tristate_within_range(sym, yes)) {
93 line[0] = 'y';
94 line[1] = '\n';
95 printf("%s", line);
96 return;
97 }
98 case set_mod:
99 if (type == S_TRISTATE) {
100 if (sym_tristate_within_range(sym, mod)) {
101 line[0] = 'm';
102 line[1] = '\n';
103 printf("%s", line);
104 return;
105 }
106 } else {
107 if (sym_tristate_within_range(sym, yes)) {
108 line[0] = 'y';
109 line[1] = '\n';
110 printf("%s", line);
111 return;
112 }
113 }
114 case set_no:
115 if (sym_tristate_within_range(sym, no)) {
116 line[0] = 'n';
117 line[1] = '\n';
118 printf("%s", line);
119 return;
120 }
121 default: // placate compiler
122 break;
123 }
124 }
125
87 switch (input_mode) { 126 switch (input_mode) {
88 case set_no: 127 case set_no:
89 case set_mod: 128 case set_mod:
@@ -605,6 +644,19 @@ int main(int ac, char **av)
605 if (input_mode != ask_silent) { 644 if (input_mode != ask_silent) {
606 rootEntry = &rootmenu; 645 rootEntry = &rootmenu;
607 conf(&rootmenu); 646 conf(&rootmenu);
647 // If autoconf run (allnoconfig and such), run it twice:
648 // "select ITEM" sets ITEM=y and then parent item
649 // is reset to "n" later. Second run sets ITEM to "n".
650 // Example: ADDUSER selects LONG_OPTS.
651 // allnoconfig must set _both_ to "n".
652 // Before, LONG_OPTS remained "y".
653 if (input_mode == set_no
654 || input_mode == set_mod
655 || input_mode == set_yes
656 ) {
657 rootEntry = &rootmenu;
658 conf(&rootmenu);
659 }
608 if (input_mode == ask_all) { 660 if (input_mode == ask_all) {
609 input_mode = ask_silent; 661 input_mode = ask_silent;
610 valid_stdin = 1; 662 valid_stdin = 1;
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index 8da47d274..740eaf8fb 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -613,19 +613,21 @@ int setfiles_main(int argc UNUSED_PARAM, char **argv)
613 /* Option order must match OPT_x definitions! */ 613 /* Option order must match OPT_x definitions! */
614 if (applet_name[0] == 'r') { /* restorecon */ 614 if (applet_name[0] == 'r') { /* restorecon */
615 flags = getopt32(argv, "^" 615 flags = getopt32(argv, "^"
616 "de:*f:ilnpqrsvo:FWR", 616 "de:*f:ilnpqrsvo:FWR"
617 "\0" "vv:v--p:p--v:v--q:q--v"; 617 "\0"
618 "vv:v--p:p--v:v--q:q--v",
618 &exclude_dir, &input_filename, &out_filename, 619 &exclude_dir, &input_filename, &out_filename,
619 &verbose 620 &verbose
620 ); 621 );
621 } else { /* setfiles */ 622 } else { /* setfiles */
622 flags = getopt32(argv, "^" 623 flags = getopt32(argv, "^"
623 "de:*f:ilnpqr:svo:FW" 624 "de:*f:ilnpqr:svo:FW"
624 IF_FEATURE_SETFILES_CHECK_OPTION("c:"), 625 IF_FEATURE_SETFILES_CHECK_OPTION("c:")
625 "\0" "vv:v--p:p--v:v--q:q--v"; 626 "\0"
627 "vv:v--p:p--v:v--q:q--v",
626 &exclude_dir, &input_filename, &rootpath, &out_filename, 628 &exclude_dir, &input_filename, &rootpath, &out_filename,
627 IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,) 629 IF_FEATURE_SETFILES_CHECK_OPTION(&policyfile,)
628 &verbose 630 &verbose
629 ); 631 );
630 } 632 }
631 argv += optind; 633 argv += optind;
diff --git a/shell/ash.c b/shell/ash.c
index 639f5396a..0d65a225b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -2957,7 +2957,7 @@ cdcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
2957 goto docd; 2957 goto docd;
2958 2958
2959 err: 2959 err:
2960 ash_msg_and_raise_error("can't cd to %s", dest); 2960 ash_msg_and_raise_perror("can't cd to %s", dest);
2961 /* NOTREACHED */ 2961 /* NOTREACHED */
2962 out: 2962 out:
2963 if (flags & CD_PRINT) 2963 if (flags & CD_PRINT)
@@ -5313,7 +5313,7 @@ forkchild(struct job *jp, union node *n, int mode)
5313 if (jp->nprocs == 0) { 5313 if (jp->nprocs == 0) {
5314 close(0); 5314 close(0);
5315 if (open(bb_dev_null, O_RDONLY) != 0) 5315 if (open(bb_dev_null, O_RDONLY) != 0)
5316 ash_msg_and_raise_error("can't open '%s'", bb_dev_null); 5316 ash_msg_and_raise_perror("can't open '%s'", bb_dev_null);
5317 } 5317 }
5318 } 5318 }
5319 if (oldlvl == 0) { 5319 if (oldlvl == 0) {
@@ -5414,7 +5414,7 @@ forkshell(struct job *jp, union node *n, int mode)
5414 TRACE(("Fork failed, errno=%d", errno)); 5414 TRACE(("Fork failed, errno=%d", errno));
5415 if (jp) 5415 if (jp)
5416 freejob(jp); 5416 freejob(jp);
5417 ash_msg_and_raise_error("can't fork"); 5417 ash_msg_and_raise_perror("can't fork");
5418 } 5418 }
5419 if (pid == 0) { 5419 if (pid == 0) {
5420 CLEAR_RANDOM_T(&random_gen); /* or else $RANDOM repeats in child */ 5420 CLEAR_RANDOM_T(&random_gen); /* or else $RANDOM repeats in child */
@@ -5559,7 +5559,7 @@ openhere(union node *redir)
5559 IF_PLATFORM_MINGW32(struct forkshell fs); 5559 IF_PLATFORM_MINGW32(struct forkshell fs);
5560 5560
5561 if (pipe(pip) < 0) 5561 if (pipe(pip) < 0)
5562 ash_msg_and_raise_error("pipe call failed"); 5562 ash_msg_and_raise_perror("can't create pipe");
5563 if (redir->type == NHERE) { 5563 if (redir->type == NHERE) {
5564 len = strlen(redir->nhere.doc->narg.text); 5564 len = strlen(redir->nhere.doc->narg.text);
5565 if (len <= PIPE_BUF) { 5565 if (len <= PIPE_BUF) {
@@ -6661,7 +6661,7 @@ evalbackcmd(union node *n, struct backcmd *result)
6661 } 6661 }
6662 6662
6663 if (pipe(pip) < 0) 6663 if (pipe(pip) < 0)
6664 ash_msg_and_raise_error("pipe call failed"); 6664 ash_msg_and_raise_perror("can't create pipe");
6665 jp = makejob(/*n,*/ 1); 6665 jp = makejob(/*n,*/ 1);
6666#if ENABLE_PLATFORM_MINGW32 6666#if ENABLE_PLATFORM_MINGW32
6667 result->fs.fpid = FS_EVALBACKCMD; 6667 result->fs.fpid = FS_EVALBACKCMD;
@@ -9625,7 +9625,7 @@ evalpipe(union node *n, int flags)
9625 if (lp->next) { 9625 if (lp->next) {
9626 if (pipe(pip) < 0) { 9626 if (pipe(pip) < 0) {
9627 close(prevfd); 9627 close(prevfd);
9628 ash_msg_and_raise_error("pipe call failed"); 9628 ash_msg_and_raise_perror("can't create pipe");
9629 } 9629 }
9630 } 9630 }
9631#if ENABLE_PLATFORM_MINGW32 9631#if ENABLE_PLATFORM_MINGW32
@@ -11058,7 +11058,7 @@ setinputfile(const char *fname, int flags)
11058 if (flags & INPUT_NOFILE_OK) 11058 if (flags & INPUT_NOFILE_OK)
11059 goto out; 11059 goto out;
11060 exitstatus = 127; 11060 exitstatus = 127;
11061 ash_msg_and_raise_error("can't open '%s'", fname); 11061 ash_msg_and_raise_perror("can't open '%s'", fname);
11062 } 11062 }
11063 if (fd < 10) 11063 if (fd < 10)
11064 fd = savefd(fd); 11064 fd = savefd(fd);
diff --git a/shell/ash_test/ash-getopts/getopt_nested.right b/shell/ash_test/ash-getopts/getopt_nested.right
new file mode 100644
index 000000000..b0c339db1
--- /dev/null
+++ b/shell/ash_test/ash-getopts/getopt_nested.right
@@ -0,0 +1,14 @@
1var:a
2var:b
3var:c
4var:a
5var:b
6var:c
7Illegal option -d
8var:?
9Illegal option -e
10var:?
11Illegal option -f
12var:?
13var:a
14End: var:? OPTIND:6
diff --git a/shell/ash_test/ash-getopts/getopt_nested.tests b/shell/ash_test/ash-getopts/getopt_nested.tests
new file mode 100755
index 000000000..1b48b4075
--- /dev/null
+++ b/shell/ash_test/ash-getopts/getopt_nested.tests
@@ -0,0 +1,21 @@
1# Test that there is no interference of getopt()
2# in getopts and unset.
3# It's unclear what "correct" OPTIND values should be
4# for "b" and "c" results from "-bc": 2? 3?
5# What we focus on here is that all options are reported
6# correct number of times and in correct sequence.
7
8(
9
10loop=99
11while getopts "abc" var -a -bc -abc -def -a; do
12 echo "var:$var" #OPTIND:$OPTIND
13 # this may use getopt():
14 unset -ff func
15 test $((--loop)) = 0 && break # BUG if this triggers
16done
17echo "End: var:$var OPTIND:$OPTIND"
18
19) 2>&1 \
20| sed -e 's/ unrecognized option: / invalid option -- /' \
21 -e 's/ illegal option -- / invalid option -- /' \
diff --git a/shell/cttyhack.c b/shell/cttyhack.c
index 849fe9e48..ec1b6c429 100644
--- a/shell/cttyhack.c
+++ b/shell/cttyhack.c
@@ -4,12 +4,6 @@
4 * 4 *
5 * Licensed under GPLv2, see file LICENSE in this source tree. 5 * Licensed under GPLv2, see file LICENSE in this source tree.
6 */ 6 */
7#include "libbb.h"
8
9//applet:IF_CTTYHACK(APPLET_NOEXEC(cttyhack, cttyhack, BB_DIR_BIN, BB_SUID_DROP, cttyhack))
10
11//kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o
12
13//config:config CTTYHACK 7//config:config CTTYHACK
14//config: bool "cttyhack (2.5 kb)" 8//config: bool "cttyhack (2.5 kb)"
15//config: default y 9//config: default y
@@ -54,6 +48,10 @@
54//config: 48//config:
55//config: # getty 115200 $(cttyhack) 49//config: # getty 115200 $(cttyhack)
56 50
51//applet:IF_CTTYHACK(APPLET_NOEXEC(cttyhack, cttyhack, BB_DIR_BIN, BB_SUID_DROP, cttyhack))
52
53//kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o
54
57//usage:#define cttyhack_trivial_usage 55//usage:#define cttyhack_trivial_usage
58//usage: "[PROG ARGS]" 56//usage: "[PROG ARGS]"
59//usage:#define cttyhack_full_usage "\n\n" 57//usage:#define cttyhack_full_usage "\n\n"
@@ -65,6 +63,8 @@
65//usage: "\nStarting interactive shell from boot shell script:" 63//usage: "\nStarting interactive shell from boot shell script:"
66//usage: "\n setsid cttyhack sh" 64//usage: "\n setsid cttyhack sh"
67 65
66#include "libbb.h"
67
68#if !defined(__linux__) && !defined(TIOCGSERIAL) && !ENABLE_WERROR 68#if !defined(__linux__) && !defined(TIOCGSERIAL) && !ENABLE_WERROR
69# warning cttyhack will not be able to detect a controlling tty on this system 69# warning cttyhack will not be able to detect a controlling tty on this system
70#endif 70#endif
diff --git a/shell/hush.c b/shell/hush.c
index cdc3a8618..d27550ba0 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -907,6 +907,9 @@ struct globals {
907 unsigned depth_break_continue; 907 unsigned depth_break_continue;
908 unsigned depth_of_loop; 908 unsigned depth_of_loop;
909#endif 909#endif
910#if ENABLE_HUSH_GETOPTS
911 unsigned getopt_count;
912#endif
910 const char *ifs; 913 const char *ifs;
911 const char *cwd; 914 const char *cwd;
912 struct variable *top_var; 915 struct variable *top_var;
@@ -2214,6 +2217,11 @@ static int set_local_var(char *str, unsigned flags)
2214 cur->flg_export = 1; 2217 cur->flg_export = 1;
2215 if (name_len == 4 && cur->varstr[0] == 'P' && cur->varstr[1] == 'S') 2218 if (name_len == 4 && cur->varstr[0] == 'P' && cur->varstr[1] == 'S')
2216 cmdedit_update_prompt(); 2219 cmdedit_update_prompt();
2220#if ENABLE_HUSH_GETOPTS
2221 /* defoptindvar is a "OPTIND=..." constant string */
2222 if (strncmp(cur->varstr, defoptindvar, 7) == 0)
2223 G.getopt_count = 0;
2224#endif
2217 if (cur->flg_export) { 2225 if (cur->flg_export) {
2218 if (flags & SETFLAG_UNEXPORT) { 2226 if (flags & SETFLAG_UNEXPORT) {
2219 cur->flg_export = 0; 2227 cur->flg_export = 0;
@@ -2244,6 +2252,10 @@ static int unset_local_var_len(const char *name, int name_len)
2244 2252
2245 if (!name) 2253 if (!name)
2246 return EXIT_SUCCESS; 2254 return EXIT_SUCCESS;
2255#if ENABLE_HUSH_GETOPTS
2256 if (name_len == 6 && strncmp(name, "OPTIND", 6) == 0)
2257 G.getopt_count = 0;
2258#endif
2247 var_pp = &G.top_var; 2259 var_pp = &G.top_var;
2248 while ((cur = *var_pp) != NULL) { 2260 while ((cur = *var_pp) != NULL) {
2249 if (strncmp(cur->varstr, name, name_len) == 0 && cur->varstr[name_len] == '=') { 2261 if (strncmp(cur->varstr, name, name_len) == 0 && cur->varstr[name_len] == '=') {
@@ -9889,7 +9901,8 @@ Test that VAR is a valid variable name?
9889*/ 9901*/
9890 char cbuf[2]; 9902 char cbuf[2];
9891 const char *cp, *optstring, *var; 9903 const char *cp, *optstring, *var;
9892 int c, exitcode; 9904 int c, n, exitcode, my_opterr;
9905 unsigned count;
9893 9906
9894 optstring = *++argv; 9907 optstring = *++argv;
9895 if (!optstring || !(var = *++argv)) { 9908 if (!optstring || !(var = *++argv)) {
@@ -9897,17 +9910,18 @@ Test that VAR is a valid variable name?
9897 return EXIT_FAILURE; 9910 return EXIT_FAILURE;
9898 } 9911 }
9899 9912
9900 c = 0; 9913 if (argv[1])
9914 argv[0] = G.global_argv[0]; /* for error messages in getopt() */
9915 else
9916 argv = G.global_argv;
9917 cbuf[1] = '\0';
9918
9919 my_opterr = 0;
9901 if (optstring[0] != ':') { 9920 if (optstring[0] != ':') {
9902 cp = get_local_var_value("OPTERR"); 9921 cp = get_local_var_value("OPTERR");
9903 /* 0 if "OPTERR=0", 1 otherwise */ 9922 /* 0 if "OPTERR=0", 1 otherwise */
9904 c = (!cp || NOT_LONE_CHAR(cp, '0')); 9923 my_opterr = (!cp || NOT_LONE_CHAR(cp, '0'));
9905 } 9924 }
9906 opterr = c;
9907 cp = get_local_var_value("OPTIND");
9908 optind = cp ? atoi(cp) : 0;
9909 optarg = NULL;
9910 cbuf[1] = '\0';
9911 9925
9912 /* getopts stops on first non-option. Add "+" to force that */ 9926 /* getopts stops on first non-option. Add "+" to force that */
9913 /*if (optstring[0] != '+')*/ { 9927 /*if (optstring[0] != '+')*/ {
@@ -9916,11 +9930,48 @@ Test that VAR is a valid variable name?
9916 optstring = s; 9930 optstring = s;
9917 } 9931 }
9918 9932
9919 if (argv[1]) 9933 /* Naively, now we should just
9920 argv[0] = G.global_argv[0]; /* for error messages */ 9934 * cp = get_local_var_value("OPTIND");
9921 else 9935 * optind = cp ? atoi(cp) : 0;
9922 argv = G.global_argv; 9936 * optarg = NULL;
9923 c = getopt(string_array_len(argv), argv, optstring); 9937 * opterr = my_opterr;
9938 * c = getopt(string_array_len(argv), argv, optstring);
9939 * and be done? Not so fast...
9940 * Unlike normal getopt() usage in C programs, here
9941 * each successive call will (usually) have the same argv[] CONTENTS,
9942 * but not the ADDRESSES. Worse yet, it's possible that between
9943 * invocations of "getopts", there will be calls to shell builtins
9944 * which use getopt() internally. Example:
9945 * while getopts "abc" RES -a -bc -abc de; do
9946 * unset -ff func
9947 * done
9948 * This would not work correctly: getopt() call inside "unset"
9949 * modifies internal libc state which is tracking position in
9950 * multi-option strings ("-abc"). At best, it can skip options
9951 * or return the same option infinitely. With glibc implementation
9952 * of getopt(), it would use outright invalid pointers and return
9953 * garbage even _without_ "unset" mangling internal state.
9954 *
9955 * We resort to resetting getopt() state and calling it N times,
9956 * until we get Nth result (or failure).
9957 * (N == G.getopt_count is reset to 0 whenever OPTIND is [un]set).
9958 */
9959 GETOPT_RESET();
9960 count = 0;
9961 n = string_array_len(argv);
9962 do {
9963 optarg = NULL;
9964 opterr = (count < G.getopt_count) ? 0 : my_opterr;
9965 c = getopt(n, argv, optstring);
9966 if (c < 0)
9967 break;
9968 count++;
9969 } while (count <= G.getopt_count);
9970
9971 /* Set OPTIND. Prevent resetting of the magic counter! */
9972 set_local_var_from_halves("OPTIND", utoa(optind));
9973 G.getopt_count = count; /* "next time, give me N+1'th result" */
9974 GETOPT_RESET(); /* just in case */
9924 9975
9925 /* Set OPTARG */ 9976 /* Set OPTARG */
9926 /* Always set or unset, never left as-is, even on exit/error: 9977 /* Always set or unset, never left as-is, even on exit/error:
@@ -9949,10 +10000,9 @@ Test that VAR is a valid variable name?
9949 c = '?'; 10000 c = '?';
9950 } 10001 }
9951 10002
9952 /* Set VAR and OPTIND */ 10003 /* Set VAR */
9953 cbuf[0] = c; 10004 cbuf[0] = c;
9954 set_local_var_from_halves(var, cbuf); 10005 set_local_var_from_halves(var, cbuf);
9955 set_local_var_from_halves("OPTIND", utoa(optind));
9956 10006
9957 return exitcode; 10007 return exitcode;
9958} 10008}
diff --git a/shell/hush_test/hush-getopts/getopt_nested.right b/shell/hush_test/hush-getopts/getopt_nested.right
new file mode 100644
index 000000000..0218dba56
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_nested.right
@@ -0,0 +1,14 @@
1var:a
2var:b
3var:c
4var:a
5var:b
6var:c
7./getopt_nested.tests: invalid option -- d
8var:?
9./getopt_nested.tests: invalid option -- e
10var:?
11./getopt_nested.tests: invalid option -- f
12var:?
13var:a
14End: var:? OPTIND:6
diff --git a/shell/hush_test/hush-getopts/getopt_nested.tests b/shell/hush_test/hush-getopts/getopt_nested.tests
new file mode 100755
index 000000000..1b48b4075
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_nested.tests
@@ -0,0 +1,21 @@
1# Test that there is no interference of getopt()
2# in getopts and unset.
3# It's unclear what "correct" OPTIND values should be
4# for "b" and "c" results from "-bc": 2? 3?
5# What we focus on here is that all options are reported
6# correct number of times and in correct sequence.
7
8(
9
10loop=99
11while getopts "abc" var -a -bc -abc -def -a; do
12 echo "var:$var" #OPTIND:$OPTIND
13 # this may use getopt():
14 unset -ff func
15 test $((--loop)) = 0 && break # BUG if this triggers
16done
17echo "End: var:$var OPTIND:$OPTIND"
18
19) 2>&1 \
20| sed -e 's/ unrecognized option: / invalid option -- /' \
21 -e 's/ illegal option -- / invalid option -- /' \
diff --git a/shell/hush_test/hush-vars/unset.tests b/shell/hush_test/hush-vars/unset.tests
index 81243fbf9..268323a6d 100755
--- a/shell/hush_test/hush-vars/unset.tests
+++ b/shell/hush_test/hush-vars/unset.tests
@@ -1,3 +1,5 @@
1(
2
1# check invalid options are rejected 3# check invalid options are rejected
2# bash: in posix mode, aborts if non-interactive 4# bash: in posix mode, aborts if non-interactive
3unset - 5unset -
@@ -37,3 +39,7 @@ unset VAR_RO
37echo $? $f $g 39echo $? $f $g
38unset f VAR_RO g 40unset f VAR_RO g
39echo $? $f $g 41echo $? $f $g
42
43) 2>&1 \
44| sed -e 's/ unrecognized option: / invalid option -- /' \
45 -e 's/ illegal option -- / invalid option -- /' \
diff --git a/shell/shell_common.c b/shell/shell_common.c
index bc34de404..ad9048d89 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -432,8 +432,8 @@ shell_builtin_ulimit(char **argv)
432 * ulimit 123 -c2 -l 456 432 * ulimit 123 -c2 -l 456
433 */ 433 */
434 434
435 /* In case getopt was already called: 435 /* In case getopt() was already called:
436 * reset the libc getopt() function, which keeps internal state. 436 * reset libc getopt() internal state.
437 */ 437 */
438 GETOPT_RESET(); 438 GETOPT_RESET();
439 439
diff --git a/testsuite/sed.tests b/testsuite/sed.tests
index 05c00a99b..675cb4f10 100755
--- a/testsuite/sed.tests
+++ b/testsuite/sed.tests
@@ -387,6 +387,12 @@ testing "sed 's///w FILE'" \
387 "" \ 387 "" \
388 "123\nqwe\nasd\n" 388 "123\nqwe\nasd\n"
389 389
390testing "sed uses previous regexp" \
391 "sed '/w/p;//q'" \
392 "q\nw\nw\n" \
393 "" \
394 "q\nw\ne\nr\n"
395
390# testing "description" "commands" "result" "infile" "stdin" 396# testing "description" "commands" "result" "infile" "stdin"
391 397
392exit $FAILCOUNT 398exit $FAILCOUNT
diff --git a/util-linux/fallocate.c b/util-linux/fallocate.c
index 1a02a322f..8542586dc 100644
--- a/util-linux/fallocate.c
+++ b/util-linux/fallocate.c
@@ -4,7 +4,6 @@
4 * 4 *
5 * Licensed under GPLv2, see file LICENSE in this source tree. 5 * Licensed under GPLv2, see file LICENSE in this source tree.
6 */ 6 */
7
8//config:config FALLOCATE 7//config:config FALLOCATE
9//config: bool "fallocate (5 kb)" 8//config: bool "fallocate (5 kb)"
10//config: default y 9//config: default y
diff --git a/util-linux/fsfreeze.c b/util-linux/fsfreeze.c
index 2e2257337..c485810aa 100644
--- a/util-linux/fsfreeze.c
+++ b/util-linux/fsfreeze.c
@@ -4,7 +4,6 @@
4 * 4 *
5 * Licensed under GPLv2, see file LICENSE in this source tree. 5 * Licensed under GPLv2, see file LICENSE in this source tree.
6 */ 6 */
7
8//config:config FSFREEZE 7//config:config FSFREEZE
9//config: bool "fsfreeze (3.6 kb)" 8//config: bool "fsfreeze (3.6 kb)"
10//config: default y 9//config: default y
diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c
index 4acfa567a..205d1e42b 100644
--- a/util-linux/fstrim.c
+++ b/util-linux/fstrim.c
@@ -7,7 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */ 9 */
10
11//config:config FSTRIM 10//config:config FSTRIM
12//config: bool "fstrim (5.5 kb)" 11//config: bool "fstrim (5.5 kb)"
13//config: default y 12//config: default y
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 8acc4d21d..4b4eeafba 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -7,7 +7,6 @@
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this source tree. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 */ 9 */
10
11//config:config MDEV 10//config:config MDEV
12//config: bool "mdev (16 kb)" 11//config: bool "mdev (16 kb)"
13//config: default y 12//config: default y
diff --git a/util-linux/mesg.c b/util-linux/mesg.c
index 91c05317e..35c4ec13d 100644
--- a/util-linux/mesg.c
+++ b/util-linux/mesg.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config MESG 9//config:config MESG
11//config: bool "mesg (1.2 kb)" 10//config: bool "mesg (1.2 kb)"
12//config: default y 11//config: default y
diff --git a/util-linux/nsenter.c b/util-linux/nsenter.c
index d91b0b509..c6933c8d5 100644
--- a/util-linux/nsenter.c
+++ b/util-linux/nsenter.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config NSENTER 9//config:config NSENTER
11//config: bool "nsenter (8.6 kb)" 10//config: bool "nsenter (8.6 kb)"
12//config: default y 11//config: default y
diff --git a/util-linux/rdev.c b/util-linux/rdev.c
index 7eb7413a8..97279ce61 100644
--- a/util-linux/rdev.c
+++ b/util-linux/rdev.c
@@ -6,7 +6,6 @@
6 * Grant Erickson <gerickson@nuovations.com> 6 * Grant Erickson <gerickson@nuovations.com>
7 * 7 *
8 * Licensed under GPLv2, see file LICENSE in this source tree. 8 * Licensed under GPLv2, see file LICENSE in this source tree.
9 *
10 */ 9 */
11//config:config RDEV 10//config:config RDEV
12//config: bool "rdev (1.4 kb)" 11//config: bool "rdev (1.4 kb)"
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index 12ab1bd66..af079fae8 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -173,14 +173,14 @@ static void set_ambient_caps(char *string)
173 173
174 cap = strtok(string, ","); 174 cap = strtok(string, ",");
175 while (cap) { 175 while (cap) {
176 unsigned index; 176 unsigned idx;
177 177
178 index = parse_cap(cap); 178 idx = parse_cap(cap);
179 if (cap[0] == '+') { 179 if (cap[0] == '+') {
180 if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, index, 0, 0) < 0) 180 if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, idx, 0, 0) < 0)
181 bb_perror_msg("cap_ambient_raise"); 181 bb_perror_msg("cap_ambient_raise");
182 } else { 182 } else {
183 if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, index, 0, 0) < 0) 183 if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_LOWER, idx, 0, 0) < 0)
184 bb_perror_msg("cap_ambient_lower"); 184 bb_perror_msg("cap_ambient_lower");
185 } 185 }
186 cap = strtok(NULL, ","); 186 cap = strtok(NULL, ",");
diff --git a/util-linux/taskset.c b/util-linux/taskset.c
index 401a1bcb7..67df1cb73 100644
--- a/util-linux/taskset.c
+++ b/util-linux/taskset.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8
9//config:config TASKSET 8//config:config TASKSET
10//config: bool "taskset (4.1 kb)" 9//config: bool "taskset (4.1 kb)"
11//config: default y 10//config: default y
@@ -23,6 +22,7 @@
23//config: in this case. Otherwise, it is limited to sizeof(long). 22//config: in this case. Otherwise, it is limited to sizeof(long).
24 23
25//applet:IF_TASKSET(APPLET_NOEXEC(taskset, taskset, BB_DIR_USR_BIN, BB_SUID_DROP, taskset)) 24//applet:IF_TASKSET(APPLET_NOEXEC(taskset, taskset, BB_DIR_USR_BIN, BB_SUID_DROP, taskset))
25
26//kbuild:lib-$(CONFIG_TASKSET) += taskset.o 26//kbuild:lib-$(CONFIG_TASKSET) += taskset.o
27 27
28//usage:#define taskset_trivial_usage 28//usage:#define taskset_trivial_usage
diff --git a/util-linux/volume_id/bcache.c b/util-linux/volume_id/bcache.c
index 334a341c3..085c158db 100644
--- a/util-linux/volume_id/bcache.c
+++ b/util-linux/volume_id/bcache.c
@@ -7,14 +7,13 @@
7 * Based on code fragments from bcache-tools by Kent Overstreet: 7 * Based on code fragments from bcache-tools by Kent Overstreet:
8 * http://evilpiepirate.org/git/bcache-tools.git 8 * http://evilpiepirate.org/git/bcache-tools.git
9 */ 9 */
10
11//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BCACHE) += bcache.o
12
13//config:config FEATURE_VOLUMEID_BCACHE 10//config:config FEATURE_VOLUMEID_BCACHE
14//config: bool "bcache filesystem" 11//config: bool "bcache filesystem"
15//config: default y 12//config: default y
16//config: depends on VOLUMEID 13//config: depends on VOLUMEID
17 14
15//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BCACHE) += bcache.o
16
18#include "volume_id_internal.h" 17#include "volume_id_internal.h"
19 18
20#define SB_LABEL_SIZE 32 19#define SB_LABEL_SIZE 32
diff --git a/util-linux/volume_id/btrfs.c b/util-linux/volume_id/btrfs.c
index 338a48762..a3ddf9782 100644
--- a/util-linux/volume_id/btrfs.c
+++ b/util-linux/volume_id/btrfs.c
@@ -18,14 +18,13 @@
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21
22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o
23
24//config:config FEATURE_VOLUMEID_BTRFS 21//config:config FEATURE_VOLUMEID_BTRFS
25//config: bool "btrfs filesystem" 22//config: bool "btrfs filesystem"
26//config: default y 23//config: default y
27//config: depends on VOLUMEID 24//config: depends on VOLUMEID
28 25
26//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_BTRFS) += btrfs.o
27
29#include "volume_id_internal.h" 28#include "volume_id_internal.h"
30 29
31#define BTRFS_UUID_SIZE 16 30#define BTRFS_UUID_SIZE 16
diff --git a/util-linux/volume_id/cramfs.c b/util-linux/volume_id/cramfs.c
index c63223e2b..3468a5005 100644
--- a/util-linux/volume_id/cramfs.c
+++ b/util-linux/volume_id/cramfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o
22
23//config:config FEATURE_VOLUMEID_CRAMFS 20//config:config FEATURE_VOLUMEID_CRAMFS
24//config: bool "cramfs filesystem" 21//config: bool "cramfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_CRAMFS) += cramfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct cramfs_super { 29struct cramfs_super {
diff --git a/util-linux/volume_id/exfat.c b/util-linux/volume_id/exfat.c
index 14bf9d691..952b027d9 100644
--- a/util-linux/volume_id/exfat.c
+++ b/util-linux/volume_id/exfat.c
@@ -17,9 +17,6 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
22
23//config:config FEATURE_VOLUMEID_EXFAT 20//config:config FEATURE_VOLUMEID_EXFAT
24//config: bool "exFAT filesystem" 21//config: bool "exFAT filesystem"
25//config: default y 22//config: default y
@@ -29,6 +26,8 @@
29//config: for flash drives. It has many features from NTFS, but with less 26//config: for flash drives. It has many features from NTFS, but with less
30//config: overhead. exFAT is used on most SDXC cards for consumer electronics. 27//config: overhead. exFAT is used on most SDXC cards for consumer electronics.
31 28
29//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXFAT) += exfat.o
30
32#include "volume_id_internal.h" 31#include "volume_id_internal.h"
33 32
34#define EXFAT_SB_OFFSET 0 33#define EXFAT_SB_OFFSET 0
diff --git a/util-linux/volume_id/ext.c b/util-linux/volume_id/ext.c
index 473b3229a..f17faddb6 100644
--- a/util-linux/volume_id/ext.c
+++ b/util-linux/volume_id/ext.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o
22
23//config:config FEATURE_VOLUMEID_EXT 20//config:config FEATURE_VOLUMEID_EXT
24//config: bool "Ext filesystem" 21//config: bool "Ext filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_EXT) += ext.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29#include "bb_e2fs_defs.h" 28#include "bb_e2fs_defs.h"
30 29
diff --git a/util-linux/volume_id/f2fs.c b/util-linux/volume_id/f2fs.c
index 3027f178e..e6100aec2 100644
--- a/util-linux/volume_id/f2fs.c
+++ b/util-linux/volume_id/f2fs.c
@@ -5,9 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree. 6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */ 7 */
8
9//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_F2FS) += f2fs.o
10
11//config:config FEATURE_VOLUMEID_F2FS 8//config:config FEATURE_VOLUMEID_F2FS
12//config: bool "f2fs filesystem" 9//config: bool "f2fs filesystem"
13//config: default y 10//config: default y
@@ -18,6 +15,8 @@
18//config: known issues of the older log structured file systems, such as high 15//config: known issues of the older log structured file systems, such as high
19//config: cleaning overhead. 16//config: cleaning overhead.
20 17
18//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_F2FS) += f2fs.o
19
21#include "volume_id_internal.h" 20#include "volume_id_internal.h"
22 21
23#define F2FS_MAGIC 0xF2F52010 // F2FS Magic Number 22#define F2FS_MAGIC 0xF2F52010 // F2FS Magic Number
diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
index bc3433daf..b24ed098e 100644
--- a/util-linux/volume_id/fat.c
+++ b/util-linux/volume_id/fat.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o
22
23//config:config FEATURE_VOLUMEID_FAT 20//config:config FEATURE_VOLUMEID_FAT
24//config: bool "fat filesystem" 21//config: bool "fat filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_FAT) += fat.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30/* linux/msdos_fs.h says: */ 29/* linux/msdos_fs.h says: */
diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
index 78dae0790..05d16db34 100644
--- a/util-linux/volume_id/hfs.c
+++ b/util-linux/volume_id/hfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o
22
23//config:config FEATURE_VOLUMEID_HFS 20//config:config FEATURE_VOLUMEID_HFS
24//config: bool "hfs filesystem" 21//config: bool "hfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_HFS) += hfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct hfs_finder_info{ 29struct hfs_finder_info{
diff --git a/util-linux/volume_id/iso9660.c b/util-linux/volume_id/iso9660.c
index 23072f87c..c771b01f5 100644
--- a/util-linux/volume_id/iso9660.c
+++ b/util-linux/volume_id/iso9660.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
22
23//config:config FEATURE_VOLUMEID_ISO9660 20//config:config FEATURE_VOLUMEID_ISO9660
24//config: bool "iso9660 filesystem" 21//config: bool "iso9660 filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ISO9660) += iso9660.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30#define ISO_SUPERBLOCK_OFFSET 0x8000 29#define ISO_SUPERBLOCK_OFFSET 0x8000
diff --git a/util-linux/volume_id/jfs.c b/util-linux/volume_id/jfs.c
index 543d90fe5..5e523e236 100644
--- a/util-linux/volume_id/jfs.c
+++ b/util-linux/volume_id/jfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
22
23//config:config FEATURE_VOLUMEID_JFS 20//config:config FEATURE_VOLUMEID_JFS
24//config: bool "jfs filesystem" 21//config: bool "jfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_JFS) += jfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct jfs_super_block { 29struct jfs_super_block {
diff --git a/util-linux/volume_id/linux_raid.c b/util-linux/volume_id/linux_raid.c
index 0db6e8662..db6209a4d 100644
--- a/util-linux/volume_id/linux_raid.c
+++ b/util-linux/volume_id/linux_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
22
23//config:config FEATURE_VOLUMEID_LINUXRAID 20//config:config FEATURE_VOLUMEID_LINUXRAID
24//config: bool "linuxraid" 21//config: bool "linuxraid"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXRAID) += linux_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct mdp_super_block { 29struct mdp_super_block {
diff --git a/util-linux/volume_id/linux_swap.c b/util-linux/volume_id/linux_swap.c
index a35769dfc..78b339cf0 100644
--- a/util-linux/volume_id/linux_swap.c
+++ b/util-linux/volume_id/linux_swap.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
22
23//config:config FEATURE_VOLUMEID_LINUXSWAP 20//config:config FEATURE_VOLUMEID_LINUXSWAP
24//config: bool "linux swap filesystem" 21//config: bool "linux swap filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct swap_header_v1_2 { 29struct swap_header_v1_2 {
diff --git a/util-linux/volume_id/luks.c b/util-linux/volume_id/luks.c
index 4b80b7a6d..8e634d4ee 100644
--- a/util-linux/volume_id/luks.c
+++ b/util-linux/volume_id/luks.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o
22
23//config:config FEATURE_VOLUMEID_LUKS 20//config:config FEATURE_VOLUMEID_LUKS
24//config: bool "luks filesystem" 21//config: bool "luks filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LUKS) += luks.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30#define LUKS_MAGIC_L 6 29#define LUKS_MAGIC_L 6
diff --git a/util-linux/volume_id/nilfs.c b/util-linux/volume_id/nilfs.c
index 9d6c57fba..7a8b798df 100644
--- a/util-linux/volume_id/nilfs.c
+++ b/util-linux/volume_id/nilfs.c
@@ -18,9 +18,6 @@
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21
22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
23
24//config:config FEATURE_VOLUMEID_NILFS 21//config:config FEATURE_VOLUMEID_NILFS
25//config: bool "nilfs filesystem" 22//config: bool "nilfs filesystem"
26//config: default y 23//config: default y
@@ -37,6 +34,8 @@
37//config: filesystem for Linux desktop environment, or as a basis of advanced 34//config: filesystem for Linux desktop environment, or as a basis of advanced
38//config: storage appliances. 35//config: storage appliances.
39 36
37//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
38
40#include "volume_id_internal.h" 39#include "volume_id_internal.h"
41 40
42#define NILFS_UUID_SIZE 16 41#define NILFS_UUID_SIZE 16
diff --git a/util-linux/volume_id/ntfs.c b/util-linux/volume_id/ntfs.c
index bf85f7ed3..22dd77fc7 100644
--- a/util-linux/volume_id/ntfs.c
+++ b/util-linux/volume_id/ntfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
22
23//config:config FEATURE_VOLUMEID_NTFS 20//config:config FEATURE_VOLUMEID_NTFS
24//config: bool "ntfs filesystem" 21//config: bool "ntfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct ntfs_super_block { 29struct ntfs_super_block {
diff --git a/util-linux/volume_id/ocfs2.c b/util-linux/volume_id/ocfs2.c
index 2dedac98b..235968b88 100644
--- a/util-linux/volume_id/ocfs2.c
+++ b/util-linux/volume_id/ocfs2.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o
22
23//config:config FEATURE_VOLUMEID_OCFS2 20//config:config FEATURE_VOLUMEID_OCFS2
24//config: bool "ocfs2 filesystem" 21//config: bool "ocfs2 filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_OCFS2) += ocfs2.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30/* All these values are taken from ocfs2-tools's ocfs2_fs.h */ 29/* All these values are taken from ocfs2-tools's ocfs2_fs.h */
diff --git a/util-linux/volume_id/reiserfs.c b/util-linux/volume_id/reiserfs.c
index 369d4d9bb..d9fd8944d 100644
--- a/util-linux/volume_id/reiserfs.c
+++ b/util-linux/volume_id/reiserfs.c
@@ -18,14 +18,13 @@
18 * License along with this library; if not, write to the Free Software 18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21
22//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
23
24//config:config FEATURE_VOLUMEID_REISERFS 21//config:config FEATURE_VOLUMEID_REISERFS
25//config: bool "Reiser filesystem" 22//config: bool "Reiser filesystem"
26//config: default y 23//config: default y
27//config: depends on VOLUMEID 24//config: depends on VOLUMEID
28 25
26//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
27
29#include "volume_id_internal.h" 28#include "volume_id_internal.h"
30 29
31struct reiserfs_super_block { 30struct reiserfs_super_block {
diff --git a/util-linux/volume_id/romfs.c b/util-linux/volume_id/romfs.c
index 95a65f9ef..bd74fda8d 100644
--- a/util-linux/volume_id/romfs.c
+++ b/util-linux/volume_id/romfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o
22
23//config:config FEATURE_VOLUMEID_ROMFS 20//config:config FEATURE_VOLUMEID_ROMFS
24//config: bool "romfs filesystem" 21//config: bool "romfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_ROMFS) += romfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct romfs_super { 29struct romfs_super {
diff --git a/util-linux/volume_id/squashfs.c b/util-linux/volume_id/squashfs.c
index e3ffce35e..4b65afd8b 100644
--- a/util-linux/volume_id/squashfs.c
+++ b/util-linux/volume_id/squashfs.c
@@ -5,9 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree. 6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */ 7 */
8
9//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o
10
11//config:config FEATURE_VOLUMEID_SQUASHFS 8//config:config FEATURE_VOLUMEID_SQUASHFS
12//config: bool "SquashFS filesystem" 9//config: bool "SquashFS filesystem"
13//config: default y 10//config: default y
@@ -18,6 +15,8 @@
18//config: device/memory systems (e.g. embedded systems) where low overhead is 15//config: device/memory systems (e.g. embedded systems) where low overhead is
19//config: needed. 16//config: needed.
20 17
18//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SQUASHFS) += squashfs.o
19
21#include "volume_id_internal.h" 20#include "volume_id_internal.h"
22 21
23struct squashfs_superblock { 22struct squashfs_superblock {
diff --git a/util-linux/volume_id/sysv.c b/util-linux/volume_id/sysv.c
index cd4cd906b..be41f8048 100644
--- a/util-linux/volume_id/sysv.c
+++ b/util-linux/volume_id/sysv.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o
22
23//config:config FEATURE_VOLUMEID_SYSV 20//config:config FEATURE_VOLUMEID_SYSV
24//config: bool "sysv filesystem" 21//config: bool "sysv filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_SYSV) += sysv.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30#define SYSV_NICINOD 100 29#define SYSV_NICINOD 100
diff --git a/util-linux/volume_id/ubifs.c b/util-linux/volume_id/ubifs.c
index 7512b84b0..aee53f9dd 100644
--- a/util-linux/volume_id/ubifs.c
+++ b/util-linux/volume_id/ubifs.c
@@ -5,9 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2, see file LICENSE in this source tree. 6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */ 7 */
8
9//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UBIFS) += ubifs.o
10
11//config:config FEATURE_VOLUMEID_UBIFS 8//config:config FEATURE_VOLUMEID_UBIFS
12//config: bool "UBIFS filesystem" 9//config: bool "UBIFS filesystem"
13//config: default y 10//config: default y
@@ -16,6 +13,8 @@
16//config: UBIFS (Unsorted Block Image File System) is a file 13//config: UBIFS (Unsorted Block Image File System) is a file
17//config: system for use with raw flash memory media. 14//config: system for use with raw flash memory media.
18 15
16//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UBIFS) += ubifs.o
17
19#include "volume_id_internal.h" 18#include "volume_id_internal.h"
20 19
21#define UBIFS_NODE_MAGIC 0x06101831 20#define UBIFS_NODE_MAGIC 0x06101831
diff --git a/util-linux/volume_id/udf.c b/util-linux/volume_id/udf.c
index fa5dccee7..0df4a86df 100644
--- a/util-linux/volume_id/udf.c
+++ b/util-linux/volume_id/udf.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
22
23//config:config FEATURE_VOLUMEID_UDF 20//config:config FEATURE_VOLUMEID_UDF
24//config: bool "udf filesystem" 21//config: bool "udf filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct volume_descriptor { 29struct volume_descriptor {
diff --git a/util-linux/volume_id/unused_highpoint.c b/util-linux/volume_id/unused_highpoint.c
index 4afa6d927..1d5ceb787 100644
--- a/util-linux/volume_id/unused_highpoint.c
+++ b/util-linux/volume_id/unused_highpoint.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o
22
23//config:### config FEATURE_VOLUMEID_HIGHPOINTRAID 20//config:### config FEATURE_VOLUMEID_HIGHPOINTRAID
24//config:### bool "highpoint raid" 21//config:### bool "highpoint raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HIGHPOINTRAID) += highpoint.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct hpt37x_meta { 29struct hpt37x_meta {
diff --git a/util-linux/volume_id/unused_hpfs.c b/util-linux/volume_id/unused_hpfs.c
index 3e16dedbd..26fefd415 100644
--- a/util-linux/volume_id/unused_hpfs.c
+++ b/util-linux/volume_id/unused_hpfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o
22
23//config:### config FEATURE_VOLUMEID_HPFS 20//config:### config FEATURE_VOLUMEID_HPFS
24//config:### bool "hpfs filesystem" 21//config:### bool "hpfs filesystem"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_HPFS) += hpfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct hpfs_super { 29struct hpfs_super {
diff --git a/util-linux/volume_id/unused_isw_raid.c b/util-linux/volume_id/unused_isw_raid.c
index fba99be58..f7b3eec74 100644
--- a/util-linux/volume_id/unused_isw_raid.c
+++ b/util-linux/volume_id/unused_isw_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o
22
23//config:### config FEATURE_VOLUMEID_ISWRAID 20//config:### config FEATURE_VOLUMEID_ISWRAID
24//config:### bool "intel raid" 21//config:### bool "intel raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_ISWRAID) += isw_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct isw_meta { 29struct isw_meta {
diff --git a/util-linux/volume_id/unused_lsi_raid.c b/util-linux/volume_id/unused_lsi_raid.c
index 9dd2b409c..12dabea87 100644
--- a/util-linux/volume_id/unused_lsi_raid.c
+++ b/util-linux/volume_id/unused_lsi_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o
22
23//config:### config FEATURE_VOLUMEID_LSIRAID 20//config:### config FEATURE_VOLUMEID_LSIRAID
24//config:### bool "lsi raid" 21//config:### bool "lsi raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LSIRAID) += lsi_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct lsi_meta { 29struct lsi_meta {
diff --git a/util-linux/volume_id/unused_lvm.c b/util-linux/volume_id/unused_lvm.c
index 5ad6d585c..649306c85 100644
--- a/util-linux/volume_id/unused_lvm.c
+++ b/util-linux/volume_id/unused_lvm.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
22
23//config:### config FEATURE_VOLUMEID_LVM 20//config:### config FEATURE_VOLUMEID_LVM
24//config:### bool "lvm" 21//config:### bool "lvm"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct lvm1_super_block { 29struct lvm1_super_block {
diff --git a/util-linux/volume_id/unused_mac.c b/util-linux/volume_id/unused_mac.c
index 997d330a4..a0d253e92 100644
--- a/util-linux/volume_id/unused_mac.c
+++ b/util-linux/volume_id/unused_mac.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
22
23//config:### config FEATURE_VOLUMEID_MAC 20//config:### config FEATURE_VOLUMEID_MAC
24//config:### bool "mac filesystem" 21//config:### bool "mac filesystem"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct mac_driver_desc { 29struct mac_driver_desc {
diff --git a/util-linux/volume_id/unused_msdos.c b/util-linux/volume_id/unused_msdos.c
index f84c0f06f..baa14c552 100644
--- a/util-linux/volume_id/unused_msdos.c
+++ b/util-linux/volume_id/unused_msdos.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
22
23//config:### config FEATURE_VOLUMEID_MSDOS 20//config:### config FEATURE_VOLUMEID_MSDOS
24//config:### bool "msdos filesystem" 21//config:### bool "msdos filesystem"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct msdos_partition_entry { 29struct msdos_partition_entry {
diff --git a/util-linux/volume_id/unused_nvidia_raid.c b/util-linux/volume_id/unused_nvidia_raid.c
index dfb54fa9d..e8217b402 100644
--- a/util-linux/volume_id/unused_nvidia_raid.c
+++ b/util-linux/volume_id/unused_nvidia_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o
22
23//config:### config FEATURE_VOLUMEID_NVIDIARAID 20//config:### config FEATURE_VOLUMEID_NVIDIARAID
24//config:### bool "nvidia raid" 21//config:### bool "nvidia raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_NVIDIARAID) += nvidia_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct nvidia_meta { 29struct nvidia_meta {
diff --git a/util-linux/volume_id/unused_promise_raid.c b/util-linux/volume_id/unused_promise_raid.c
index d594de39c..c4a6f502a 100644
--- a/util-linux/volume_id/unused_promise_raid.c
+++ b/util-linux/volume_id/unused_promise_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o
22
23//config:### config FEATURE_VOLUMEID_PROMISERAID 20//config:### config FEATURE_VOLUMEID_PROMISERAID
24//config:### bool "promise raid" 21//config:### bool "promise raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_PROMISERAID) += promise_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct promise_meta { 29struct promise_meta {
diff --git a/util-linux/volume_id/unused_silicon_raid.c b/util-linux/volume_id/unused_silicon_raid.c
index 886721b61..ea96dc98a 100644
--- a/util-linux/volume_id/unused_silicon_raid.c
+++ b/util-linux/volume_id/unused_silicon_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o
22
23//config:### config FEATURE_VOLUMEID_SILICONRAID 20//config:### config FEATURE_VOLUMEID_SILICONRAID
24//config:### bool "silicon raid" 21//config:### bool "silicon raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_SILICONRAID) += silicon_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct silicon_meta { 29struct silicon_meta {
diff --git a/util-linux/volume_id/unused_ufs.c b/util-linux/volume_id/unused_ufs.c
index 78ef26ad4..c36793a68 100644
--- a/util-linux/volume_id/unused_ufs.c
+++ b/util-linux/volume_id/unused_ufs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
22
23//config:### config FEATURE_VOLUMEID_UFS 20//config:### config FEATURE_VOLUMEID_UFS
24//config:### bool "ufs filesystem" 21//config:### bool "ufs filesystem"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_UFS) += ufs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct ufs_super_block { 29struct ufs_super_block {
diff --git a/util-linux/volume_id/unused_via_raid.c b/util-linux/volume_id/unused_via_raid.c
index f82626655..c77c8393c 100644
--- a/util-linux/volume_id/unused_via_raid.c
+++ b/util-linux/volume_id/unused_via_raid.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o
22
23//config:### config FEATURE_VOLUMEID_VIARAID 20//config:### config FEATURE_VOLUMEID_VIARAID
24//config:### bool "via raid" 21//config:### bool "via raid"
25//config:### default y 22//config:### default y
26//config:### depends on VOLUMEID 23//config:### depends on VOLUMEID
27 24
25//kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_VIARAID) += via_raid.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct via_meta { 29struct via_meta {
diff --git a/util-linux/volume_id/xfs.c b/util-linux/volume_id/xfs.c
index 656d5bfcf..f98b66a53 100644
--- a/util-linux/volume_id/xfs.c
+++ b/util-linux/volume_id/xfs.c
@@ -17,14 +17,13 @@
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20
21//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o
22
23//config:config FEATURE_VOLUMEID_XFS 20//config:config FEATURE_VOLUMEID_XFS
24//config: bool "xfs filesystem" 21//config: bool "xfs filesystem"
25//config: default y 22//config: default y
26//config: depends on VOLUMEID 23//config: depends on VOLUMEID
27 24
25//kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_XFS) += xfs.o
26
28#include "volume_id_internal.h" 27#include "volume_id_internal.h"
29 28
30struct xfs_super_block { 29struct xfs_super_block {
diff --git a/util-linux/wall.c b/util-linux/wall.c
index e214d8c3f..939736592 100644
--- a/util-linux/wall.c
+++ b/util-linux/wall.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8
9//config:config WALL 8//config:config WALL
10//config: bool "wall (2.5 kb)" 9//config: bool "wall (2.5 kb)"
11//config: default y 10//config: default y