aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2012-03-22 14:11:12 +0000
committerRon Yorston <rmy@pobox.com>2012-03-22 14:11:12 +0000
commit67758035a4fe040c6ac69b39d61bcd6bddd7b827 (patch)
treea4a1db7f54c16d12fabe2626b8f1e235cd694e9e
parent811c449748d5bd0505f8510e5582892f94ac0cda (diff)
parentb83c9704128dd106071184e4b00335a3b8486857 (diff)
downloadbusybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.gz
busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.bz2
busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.zip
Merge commit 'b83c9704128dd106071184e4b00335a3b8486857' into merge
-rw-r--r--Config.in1
-rw-r--r--applets/applet_tables.c10
-rwxr-xr-xapplets/install.sh71
-rw-r--r--archival/ar.c13
-rw-r--r--archival/bbunzip.c76
-rw-r--r--archival/bzip2.c10
-rw-r--r--archival/dpkg.c28
-rw-r--r--archival/dpkg_deb.c15
-rw-r--r--archival/gzip.c20
-rw-r--r--archival/lzop.c27
-rw-r--r--archival/rpm.c13
-rw-r--r--archival/rpm2cpio.c6
-rw-r--r--archival/unzip.c13
-rw-r--r--console-tools/chvt.c6
-rw-r--r--console-tools/clear.c6
-rw-r--r--console-tools/deallocvt.c5
-rw-r--r--console-tools/dumpkmap.c8
-rw-r--r--console-tools/fgconsole.c5
-rw-r--r--console-tools/kbd_mode.c12
-rw-r--r--console-tools/loadfont.c21
-rw-r--r--console-tools/loadkmap.c10
-rw-r--r--console-tools/openvt.c13
-rw-r--r--console-tools/reset.c5
-rw-r--r--console-tools/resize.c6
-rw-r--r--console-tools/setconsole.c7
-rw-r--r--console-tools/setkeycodes.c12
-rw-r--r--console-tools/setlogcons.c5
-rw-r--r--console-tools/showkey.c9
-rw-r--r--coreutils/basename.c18
-rw-r--r--coreutils/cal.c9
-rw-r--r--coreutils/cat.c9
-rw-r--r--coreutils/catv.c9
-rw-r--r--coreutils/chgrp.c23
-rw-r--r--coreutils/chmod.c23
-rw-r--r--coreutils/chown.c26
-rw-r--r--coreutils/chroot.c13
-rw-r--r--coreutils/cksum.c6
-rw-r--r--coreutils/comm.c9
-rw-r--r--coreutils/cp.c18
-rw-r--r--coreutils/cut.c18
-rw-r--r--coreutils/dd.c33
-rw-r--r--coreutils/df.c35
-rw-r--r--coreutils/dirname.c11
-rw-r--r--coreutils/dos2unix.c18
-rw-r--r--coreutils/du.c37
-rw-r--r--coreutils/echo.c21
-rw-r--r--coreutils/env.c9
-rw-r--r--coreutils/expand.c31
-rw-r--r--coreutils/expr.c35
-rw-r--r--coreutils/false.c10
-rw-r--r--coreutils/fold.c10
-rw-r--r--coreutils/fsync.c8
-rw-r--r--coreutils/head.c20
-rw-r--r--coreutils/hostid.c5
-rw-r--r--coreutils/id.c18
-rw-r--r--coreutils/install.c18
-rw-r--r--coreutils/length.c.disabled9
-rw-r--r--coreutils/ln.c16
-rw-r--r--coreutils/logname.c9
-rw-r--r--coreutils/ls.c14
-rw-r--r--coreutils/md5_sha1_sum.c80
-rw-r--r--coreutils/mkdir.c19
-rw-r--r--coreutils/mkfifo.c10
-rw-r--r--coreutils/mknod.c18
-rw-r--r--coreutils/nice.c7
-rw-r--r--coreutils/nohup.c8
-rw-r--r--coreutils/od.c5
-rw-r--r--coreutils/printenv.c6
-rw-r--r--coreutils/printf.c10
-rw-r--r--coreutils/pwd.c9
-rw-r--r--coreutils/readlink.c12
-rw-r--r--coreutils/realpath.c5
-rw-r--r--coreutils/rm.c12
-rw-r--r--coreutils/rmdir.c16
-rw-r--r--coreutils/seq.c10
-rw-r--r--coreutils/sleep.c15
-rw-r--r--coreutils/sort.c48
-rw-r--r--coreutils/split.c13
-rw-r--r--coreutils/stat.c61
-rw-r--r--coreutils/stty.c11
-rw-r--r--coreutils/sum.c8
-rw-r--r--coreutils/sync.c5
-rw-r--r--coreutils/tac.c5
-rw-r--r--coreutils/tail.c25
-rw-r--r--coreutils/tee.c13
-rw-r--r--coreutils/test.c23
-rw-r--r--coreutils/tr.c13
-rw-r--r--coreutils/true.c10
-rw-r--r--coreutils/tty.c13
-rw-r--r--coreutils/uname.c17
-rw-r--r--coreutils/uniq.c18
-rw-r--r--coreutils/usleep.c9
-rw-r--r--coreutils/uudecode.c12
-rw-r--r--coreutils/uuencode.c14
-rw-r--r--coreutils/who.c7
-rw-r--r--coreutils/whoami.c5
-rw-r--r--debianutils/pipe_progress.c4
-rw-r--r--debianutils/run_parts.c26
-rw-r--r--debianutils/start_stop_daemon.c73
-rw-r--r--debianutils/which.c9
-rw-r--r--docs/syslog.conf.txt28
-rw-r--r--e2fsprogs/chattr.c24
-rw-r--r--e2fsprogs/fsck.c14
-rw-r--r--e2fsprogs/lsattr.c11
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.c24
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.h2
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c2
-rw-r--r--editors/awk.c8
-rw-r--r--editors/cmp.c9
-rw-r--r--editors/diff.c47
-rw-r--r--editors/ed.c5
-rw-r--r--editors/sed.c17
-rw-r--r--editors/vi.c13
-rw-r--r--include/applet_metadata.h30
-rw-r--r--include/busybox.h25
-rw-r--r--include/libbb.h6
-rw-r--r--include/platform.h21
-rw-r--r--include/usage.src.h4087
-rw-r--r--init/mesg.c6
-rw-r--r--libbb/Config.src5
-rw-r--r--libbb/appletlib.c2
-rw-r--r--libbb/get_line_from_file.c6
-rw-r--r--libbb/lineedit.c152
-rw-r--r--libbb/parse_config.c6
-rw-r--r--libbb/platform.c6
-rw-r--r--libbb/single_argv.c2
-rw-r--r--libbb/unicode.c7
-rw-r--r--libbb/xconnect.c16
-rw-r--r--loginutils/addgroup.c9
-rw-r--r--loginutils/adduser.c15
-rw-r--r--loginutils/chpasswd.c19
-rw-r--r--loginutils/cryptpw.c39
-rw-r--r--loginutils/deluser.c12
-rw-r--r--loginutils/login.c10
-rw-r--r--loginutils/passwd.c21
-rw-r--r--loginutils/sulogin.c7
-rw-r--r--loginutils/vlock.c7
-rw-r--r--mailutils/mime.c27
-rw-r--r--mailutils/popmaildir.c34
-rw-r--r--miscutils/adjtimex.c12
-rw-r--r--miscutils/bbconfig.c6
-rw-r--r--miscutils/beep.c11
-rw-r--r--miscutils/chat.c9
-rw-r--r--miscutils/chrt.c17
-rw-r--r--miscutils/conspy.c5
-rw-r--r--miscutils/crond.c13
-rw-r--r--miscutils/crontab.c10
-rw-r--r--miscutils/devfsd.c16
-rw-r--r--miscutils/devmem.c8
-rw-r--r--miscutils/eject.c11
-rw-r--r--miscutils/fbsplash.c130
-rw-r--r--miscutils/flash_eraseall.c8
-rw-r--r--miscutils/flash_lock_unlock.c12
-rw-r--r--miscutils/flashcp.c7
-rw-r--r--miscutils/hdparm.c52
-rw-r--r--miscutils/inotifyd.c27
-rw-r--r--miscutils/ionice.c8
-rw-r--r--miscutils/last.c11
-rw-r--r--miscutils/less.c12
-rw-r--r--miscutils/makedevs.c60
-rw-r--r--miscutils/man.c8
-rw-r--r--miscutils/microcom.c12
-rw-r--r--miscutils/mountpoint.c16
-rw-r--r--miscutils/mt.c12
-rw-r--r--miscutils/raidautorun.c8
-rw-r--r--miscutils/readahead.c5
-rw-r--r--miscutils/rfkill.c13
-rw-r--r--miscutils/runlevel.c13
-rw-r--r--miscutils/rx.c8
-rw-r--r--miscutils/setsid.c7
-rw-r--r--miscutils/strings.c10
-rw-r--r--miscutils/taskset.c18
-rw-r--r--miscutils/time.c7
-rw-r--r--miscutils/timeout.c6
-rw-r--r--miscutils/ttysize.c6
-rw-r--r--miscutils/volname.c6
-rw-r--r--miscutils/wall.c9
-rw-r--r--miscutils/watchdog.c11
-rw-r--r--networking/arp.c19
-rw-r--r--networking/arping.c17
-rw-r--r--networking/brctl.c24
-rw-r--r--networking/dnsd.c16
-rw-r--r--networking/ether-wake.c10
-rw-r--r--networking/ftpd.c4
-rw-r--r--networking/ftpgetput.c40
-rw-r--r--networking/hostname.c19
-rw-r--r--networking/httpd.c33
-rw-r--r--networking/ifconfig.c21
-rw-r--r--networking/ifenslave.c27
-rw-r--r--networking/ifplugd.c26
-rw-r--r--networking/ifupdown.c28
-rw-r--r--networking/inetd.c15
-rw-r--r--networking/interface.c2
-rw-r--r--networking/ip.c73
-rw-r--r--networking/ipcalc.c27
-rw-r--r--networking/isrv_identd.c11
-rw-r--r--networking/libiproute/ll_types.c1
-rw-r--r--networking/nc_bloaty.c8
-rw-r--r--networking/nslookup.c14
-rw-r--r--networking/ntpd.c37
-rw-r--r--networking/pscan.c14
-rw-r--r--networking/route.c9
-rw-r--r--networking/slattach.c14
-rw-r--r--networking/tc.c21
-rw-r--r--networking/tcpudp.c39
-rw-r--r--networking/telnet.c16
-rw-r--r--networking/telnetd.c22
-rw-r--r--networking/tftp.c46
-rw-r--r--networking/traceroute.c53
-rw-r--r--networking/tunctl.c19
-rw-r--r--networking/udhcp/dhcpd.c11
-rw-r--r--networking/udhcp/dhcprelay.c6
-rw-r--r--networking/udhcp/dumpleases.c17
-rw-r--r--networking/vconfig.c12
-rw-r--r--networking/wget.c50
-rw-r--r--networking/zcip.c13
-rw-r--r--printutils/lpd.c11
-rw-r--r--printutils/lpr.c21
-rw-r--r--procps/free.c12
-rw-r--r--procps/fuser.c11
-rw-r--r--procps/kill.c39
-rw-r--r--procps/pgrep.c29
-rw-r--r--procps/pidof.c28
-rw-r--r--procps/ps.c47
-rw-r--r--procps/pstree.c2
-rw-r--r--procps/renice.c10
-rw-r--r--procps/sysctl.c19
-rw-r--r--procps/uptime.c9
-rw-r--r--procps/watch.c14
-rw-r--r--runit/chpst.c64
-rw-r--r--runit/runsv.c5
-rw-r--r--runit/runsvdir.c7
-rw-r--r--runit/sv.c16
-rw-r--r--scripts/basic/docproc.c2
-rw-r--r--scripts/defconfig.tig4
-rwxr-xr-xscripts/gen_build_files.sh12
-rw-r--r--scripts/kconfig/conf.c2
-rw-r--r--scripts/kconfig/mconf.c3
-rwxr-xr-xscripts/mkconfigs2
-rw-r--r--selinux/chcon.c33
-rw-r--r--selinux/getenforce.c3
-rw-r--r--selinux/getsebool.c5
-rw-r--r--selinux/load_policy.c4
-rw-r--r--selinux/matchpathcon.c10
-rw-r--r--selinux/runcon.c22
-rw-r--r--selinux/selinuxenabled.c4
-rw-r--r--selinux/sestatus.c6
-rw-r--r--selinux/setenforce.c4
-rw-r--r--selinux/setfiles.c40
-rw-r--r--selinux/setsebool.c5
-rw-r--r--shell/Config.src10
-rw-r--r--shell/ash.c18
-rw-r--r--shell/hush.c72
-rw-r--r--shell/shell_common.c12
-rw-r--r--sysklogd/Config.src7
-rw-r--r--sysklogd/klogd.c8
-rw-r--r--sysklogd/logger.c12
-rw-r--r--sysklogd/logread.c7
-rw-r--r--sysklogd/syslogd.c364
-rw-r--r--util-linux/Config.src1
-rw-r--r--util-linux/acpid.c24
-rw-r--r--util-linux/blkid.c5
-rw-r--r--util-linux/dmesg.c10
-rw-r--r--util-linux/fbset.c15
-rw-r--r--util-linux/fdformat.c7
-rw-r--r--util-linux/fdisk.c22
-rw-r--r--util-linux/findfs.c8
-rw-r--r--util-linux/flock.c11
-rw-r--r--util-linux/freeramdisk.c14
-rw-r--r--util-linux/fsck_minix.c13
-rw-r--r--util-linux/getopt.c48
-rw-r--r--util-linux/hexdump.c24
-rw-r--r--util-linux/ipcrm.c10
-rw-r--r--util-linux/ipcs.c16
-rw-r--r--util-linux/losetup.c18
-rw-r--r--util-linux/lspci.c9
-rw-r--r--util-linux/lsusb.c4
-rw-r--r--util-linux/mdev.c35
-rw-r--r--util-linux/mkfs_ext2.c39
-rw-r--r--util-linux/mkfs_minix.c11
-rw-r--r--util-linux/mkfs_reiser.c9
-rw-r--r--util-linux/mkfs_vfat.c17
-rw-r--r--util-linux/mkswap.c8
-rw-r--r--util-linux/more.c8
-rw-r--r--util-linux/mount.c60
-rw-r--r--util-linux/pivot_root.c7
-rw-r--r--util-linux/rdate.c8
-rw-r--r--util-linux/rdev.c9
-rw-r--r--util-linux/readprofile.c15
-rw-r--r--util-linux/rtcwake.c23
-rw-r--r--util-linux/script.c13
-rw-r--r--util-linux/scriptreplay.c6
-rw-r--r--util-linux/setarch.c15
-rw-r--r--util-linux/swaponoff.c17
-rw-r--r--util-linux/switch_root.c10
-rw-r--r--util-linux/umount.c22
296 files changed, 5012 insertions, 4494 deletions
diff --git a/Config.in b/Config.in
index 89e506a6a..63d9f5ad7 100644
--- a/Config.in
+++ b/Config.in
@@ -589,7 +589,6 @@ config FEATURE_SHARED_BUSYBOX
589config LFS 589config LFS
590 bool "Build with Large File Support (for accessing files > 2 GB)" 590 bool "Build with Large File Support (for accessing files > 2 GB)"
591 default y 591 default y
592 select FDISK_SUPPORT_LARGE_DISKS
593 help 592 help
594 If you want to build BusyBox with large file support, then enable 593 If you want to build BusyBox with large file support, then enable
595 this option. This will have no effect if your kernel or your C 594 this option. This will have no effect if your kernel or your C
diff --git a/applets/applet_tables.c b/applets/applet_tables.c
index 32dcdb73d..3859d7326 100644
--- a/applets/applet_tables.c
+++ b/applets/applet_tables.c
@@ -7,13 +7,19 @@
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 10#include <sys/types.h>
11#include <sys/stat.h>
12#include <fcntl.h>
11#include <stdlib.h> 13#include <stdlib.h>
12#include <string.h> 14#include <string.h>
13#include <stdio.h> 15#include <stdio.h>
16#include <unistd.h>
17
18#undef ARRAY_SIZE
19#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
14 20
15#include "../include/autoconf.h" 21#include "../include/autoconf.h"
16#include "../include/busybox.h" 22#include "../include/applet_metadata.h"
17 23
18struct bb_applet { 24struct bb_applet {
19 const char *name; 25 const char *name;
diff --git a/applets/install.sh b/applets/install.sh
index 32049b157..95b4719d4 100755
--- a/applets/install.sh
+++ b/applets/install.sh
@@ -3,12 +3,15 @@
3export LC_ALL=POSIX 3export LC_ALL=POSIX
4export LC_CTYPE=POSIX 4export LC_CTYPE=POSIX
5 5
6prefix=${1} 6prefix=$1
7if [ -z "$prefix" ]; then 7if [ -z "$prefix" ]; then
8 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]" 8 echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
9 exit 1; 9 exit 1
10fi 10fi
11
11h=`sort busybox.links | uniq` 12h=`sort busybox.links | uniq`
13
14linkopts=""
12scriptwrapper="n" 15scriptwrapper="n"
13cleanup="0" 16cleanup="0"
14noclobber="0" 17noclobber="0"
@@ -33,12 +36,12 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
33 libdir=/lib 36 libdir=/lib
34 fi 37 fi
35 38
36 mkdir -p $prefix/$libdir || exit 1 39 mkdir -p "$prefix/$libdir" || exit 1
37 for i in $DO_INSTALL_LIBS; do 40 for i in $DO_INSTALL_LIBS; do
38 rm -f $prefix/$libdir/$i || exit 1 41 rm -f "$prefix/$libdir/$i" || exit 1
39 if [ -f $i ]; then 42 if [ -f "$i" ]; then
40 cp -pPR $i $prefix/$libdir/ || exit 1 43 cp -pPR "$i" "$prefix/$libdir/" || exit 1
41 chmod 0644 $prefix/$libdir/$i || exit 1 44 chmod 0644 "$prefix/$libdir/$i" || exit 1
42 fi 45 fi
43 done 46 done
44fi 47fi
@@ -46,35 +49,35 @@ fi
46if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then 49if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
47 inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'` 50 inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
48 sub_shell_it=` 51 sub_shell_it=`
49 cd "$prefix" 52 cd "$prefix"
50 for d in usr/sbin usr/bin sbin bin; do 53 for d in usr/sbin usr/bin sbin bin; do
51 pd=$PWD 54 pd=$PWD
52 if [ -d "$d" ]; then 55 if [ -d "$d" ]; then
53 cd $d 56 cd "$d"
54 ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f 57 ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
55 fi 58 fi
56 cd "$pd" 59 cd "$pd"
57 done 60 done
58 ` 61 `
59 exit 0 62 exit 0
60fi 63fi
61 64
62rm -f $prefix/bin/busybox || exit 1 65rm -f "$prefix/bin/busybox" || exit 1
63mkdir -p $prefix/bin || exit 1 66mkdir -p "$prefix/bin" || exit 1
64install -m 755 busybox $prefix/bin/busybox || exit 1 67install -m 755 busybox "$prefix/bin/busybox" || exit 1
65 68
66for i in $h; do 69for i in $h; do
67 appdir=`dirname $i` 70 appdir=`dirname "$i"`
68 mkdir -p $prefix/$appdir || exit 1 71 mkdir -p "$prefix/$appdir" || exit 1
69 if [ "$scriptwrapper" = "y" ]; then 72 if [ "$scriptwrapper" = "y" ]; then
70 if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then 73 if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
71 ln $linkopts busybox $prefix$i || exit 1 74 ln $linkopts busybox "$prefix/$i" || exit 1
72 else 75 else
73 rm -f $prefix$i 76 rm -f "$prefix/$i"
74 echo "#!/bin/busybox" > $prefix$i 77 echo "#!/bin/busybox" >"$prefix/$i"
75 chmod +x $prefix/$i 78 chmod +x "$prefix/$i"
76 fi 79 fi
77 echo " $prefix$i" 80 echo " $prefix/$i"
78 else 81 else
79 if [ "$2" = "--hardlinks" ]; then 82 if [ "$2" = "--hardlinks" ]; then
80 bb_path="$prefix/bin/busybox" 83 bb_path="$prefix/bin/busybox"
@@ -89,20 +92,20 @@ for i in $h; do
89 /sbin) 92 /sbin)
90 bb_path="../bin/busybox" 93 bb_path="../bin/busybox"
91 ;; 94 ;;
92 /usr/bin|/usr/sbin) 95 /usr/bin | /usr/sbin)
93 bb_path="../../bin/busybox" 96 bb_path="../../bin/busybox"
94 ;; 97 ;;
95 *) 98 *)
96 echo "Unknown installation directory: $appdir" 99 echo "Unknown installation directory: $appdir"
97 exit 1 100 exit 1
98 ;; 101 ;;
99 esac 102 esac
100 fi 103 fi
101 if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then 104 if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
102 echo " $prefix$i -> $bb_path" 105 echo " $prefix/$i -> $bb_path"
103 ln $linkopts $bb_path $prefix$i || exit 1 106 ln $linkopts "$bb_path" "$prefix/$i" || exit 1
104 else 107 else
105 echo " $prefix$i already exists" 108 echo " $prefix/$i already exists"
106 fi 109 fi
107 fi 110 fi
108done 111done
diff --git a/archival/ar.c b/archival/ar.c
index a2e3306ac..e7973af94 100644
--- a/archival/ar.c
+++ b/archival/ar.c
@@ -17,6 +17,17 @@
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 19
20//usage:#define ar_trivial_usage
21//usage: "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES"
22//usage:#define ar_full_usage "\n\n"
23//usage: "Extract or list FILES from an ar archive\n"
24//usage: "\nOptions:"
25//usage: "\n -o Preserve original dates"
26//usage: "\n -p Extract to stdout"
27//usage: "\n -t List"
28//usage: "\n -x Extract"
29//usage: "\n -v Verbose"
30
20#include "libbb.h" 31#include "libbb.h"
21#include "archive.h" 32#include "archive.h"
22#include "ar.h" 33#include "ar.h"
@@ -71,7 +82,7 @@ static void output_ar_header(archive_handle_t *handle)
71} 82}
72 83
73/* 84/*
74 * when replacing files in an existing archive, copy from the the 85 * when replacing files in an existing archive, copy from the
75 * original archive those files that are to be left intact 86 * original archive those files that are to be left intact
76 */ 87 */
77static void FAST_FUNC copy_data(archive_handle_t *handle) 88static void FAST_FUNC copy_data(archive_handle_t *handle)
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 85447cbfe..f1829db05 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -169,6 +169,15 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
169 * 169 *
170 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 170 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
171 */ 171 */
172
173//usage:#define uncompress_trivial_usage
174//usage: "[-cf] [FILE]..."
175//usage:#define uncompress_full_usage "\n\n"
176//usage: "Decompress .Z file[s]\n"
177//usage: "\nOptions:"
178//usage: "\n -c Write to stdout"
179//usage: "\n -f Overwrite"
180
172#if ENABLE_UNCOMPRESS 181#if ENABLE_UNCOMPRESS
173static 182static
174IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(unpack_info_t *info UNUSED_PARAM) 183IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
@@ -220,6 +229,28 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
220 * See the license_msg below and the file COPYING for the software license. 229 * See the license_msg below and the file COPYING for the software license.
221 * See the file algorithm.doc for the compression algorithms and file formats. 230 * See the file algorithm.doc for the compression algorithms and file formats.
222 */ 231 */
232
233//usage:#define gunzip_trivial_usage
234//usage: "[-cft] [FILE]..."
235//usage:#define gunzip_full_usage "\n\n"
236//usage: "Decompress FILEs (or stdin)\n"
237//usage: "\nOptions:"
238//usage: "\n -c Write to stdout"
239//usage: "\n -f Force"
240//usage: "\n -t Test file integrity"
241//usage:
242//usage:#define gunzip_example_usage
243//usage: "$ ls -la /tmp/BusyBox*\n"
244//usage: "-rw-rw-r-- 1 andersen andersen 557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz\n"
245//usage: "$ gunzip /tmp/BusyBox-0.43.tar.gz\n"
246//usage: "$ ls -la /tmp/BusyBox*\n"
247//usage: "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
248//usage:
249//usage:#define zcat_trivial_usage
250//usage: "FILE"
251//usage:#define zcat_full_usage "\n\n"
252//usage: "Decompress to stdout"
253
223#if ENABLE_GUNZIP 254#if ENABLE_GUNZIP
224static 255static
225char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM) 256char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
@@ -346,6 +377,51 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
346 * 377 *
347 * Licensed under GPLv2, see file LICENSE in this source tree. 378 * Licensed under GPLv2, see file LICENSE in this source tree.
348 */ 379 */
380
381//usage:#define unlzma_trivial_usage
382//usage: "[-cf] [FILE]..."
383//usage:#define unlzma_full_usage "\n\n"
384//usage: "Decompress FILE (or stdin)\n"
385//usage: "\nOptions:"
386//usage: "\n -c Write to stdout"
387//usage: "\n -f Force"
388//usage:
389//usage:#define lzma_trivial_usage
390//usage: "-d [-cf] [FILE]..."
391//usage:#define lzma_full_usage "\n\n"
392//usage: "Decompress FILE (or stdin)\n"
393//usage: "\nOptions:"
394//usage: "\n -d Decompress"
395//usage: "\n -c Write to stdout"
396//usage: "\n -f Force"
397//usage:
398//usage:#define lzcat_trivial_usage
399//usage: "FILE"
400//usage:#define lzcat_full_usage "\n\n"
401//usage: "Decompress to stdout"
402//usage:
403//usage:#define unxz_trivial_usage
404//usage: "[-cf] [FILE]..."
405//usage:#define unxz_full_usage "\n\n"
406//usage: "Decompress FILE (or stdin)\n"
407//usage: "\nOptions:"
408//usage: "\n -c Write to stdout"
409//usage: "\n -f Force"
410//usage:
411//usage:#define xz_trivial_usage
412//usage: "-d [-cf] [FILE]..."
413//usage:#define xz_full_usage "\n\n"
414//usage: "Decompress FILE (or stdin)\n"
415//usage: "\nOptions:"
416//usage: "\n -d Decompress"
417//usage: "\n -c Write to stdout"
418//usage: "\n -f Force"
419//usage:
420//usage:#define xzcat_trivial_usage
421//usage: "FILE"
422//usage:#define xzcat_full_usage "\n\n"
423//usage: "Decompress to stdout"
424
349#if ENABLE_UNLZMA 425#if ENABLE_UNLZMA
350static 426static
351IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(unpack_info_t *info UNUSED_PARAM) 427IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
diff --git a/archival/bzip2.c b/archival/bzip2.c
index ab08ffc1a..cfaf5fe20 100644
--- a/archival/bzip2.c
+++ b/archival/bzip2.c
@@ -7,6 +7,16 @@
7 * about bzip2 library code. 7 * about bzip2 library code.
8 */ 8 */
9 9
10//usage:#define bzip2_trivial_usage
11//usage: "[OPTIONS] [FILE]..."
12//usage:#define bzip2_full_usage "\n\n"
13//usage: "Compress FILEs (or stdin) with bzip2 algorithm\n"
14//usage: "\nOptions:"
15//usage: "\n -1..9 Compression level"
16//usage: "\n -d Decompress"
17//usage: "\n -c Write to stdout"
18//usage: "\n -f Force"
19
10#include "libbb.h" 20#include "libbb.h"
11#include "archive.h" 21#include "archive.h"
12 22
diff --git a/archival/dpkg.c b/archival/dpkg.c
index c37ae3349..f8e349d09 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -28,6 +28,34 @@
28 * 28 *
29 */ 29 */
30 30
31//usage:#define dpkg_trivial_usage
32//usage: "[-ilCPru] [-F OPT] PACKAGE"
33//usage:#define dpkg_full_usage "\n\n"
34//usage: "Install, remove and manage Debian packages\n"
35//usage: "\nOptions:"
36//usage: IF_LONG_OPTS(
37//usage: "\n -i,--install Install the package"
38//usage: "\n -l,--list List of installed packages"
39//usage: "\n --configure Configure an unpackaged package"
40//usage: "\n -P,--purge Purge all files of a package"
41//usage: "\n -r,--remove Remove all but the configuration files for a package"
42//usage: "\n --unpack Unpack a package, but don't configure it"
43//usage: "\n --force-depends Ignore dependency problems"
44//usage: "\n --force-confnew Overwrite existing config files when installing"
45//usage: "\n --force-confold Keep old config files when installing"
46//usage: )
47//usage: IF_NOT_LONG_OPTS(
48//usage: "\n -i Install the package"
49//usage: "\n -l List of installed packages"
50//usage: "\n -C Configure an unpackaged package"
51//usage: "\n -P Purge all files of a package"
52//usage: "\n -r Remove all but the configuration files for a package"
53//usage: "\n -u Unpack a package, but don't configure it"
54//usage: "\n -F depends Ignore dependency problems"
55//usage: "\n -F confnew Overwrite existing config files when installing"
56//usage: "\n -F confold Keep old config files when installing"
57//usage: )
58
31#include "libbb.h" 59#include "libbb.h"
32#include <fnmatch.h> 60#include <fnmatch.h>
33#include "archive.h" 61#include "archive.h"
diff --git a/archival/dpkg_deb.c b/archival/dpkg_deb.c
index aee7b4cf5..9e1e811ee 100644
--- a/archival/dpkg_deb.c
+++ b/archival/dpkg_deb.c
@@ -4,6 +4,21 @@
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//usage:#define dpkg_deb_trivial_usage
9//usage: "[-cefxX] FILE [argument"
10//usage:#define dpkg_deb_full_usage "\n\n"
11//usage: "Perform actions on Debian packages (.debs)\n"
12//usage: "\nOptions:"
13//usage: "\n -c List contents of filesystem tree"
14//usage: "\n -e Extract control files to [argument] directory"
15//usage: "\n -f Display control field name starting with [argument]"
16//usage: "\n -x Extract packages filesystem tree to directory"
17//usage: "\n -X Verbose extract"
18//usage:
19//usage:#define dpkg_deb_example_usage
20//usage: "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
21
7#include "libbb.h" 22#include "libbb.h"
8#include "archive.h" 23#include "archive.h"
9 24
diff --git a/archival/gzip.c b/archival/gzip.c
index feeddf58f..b2f9b2dc2 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -39,6 +39,22 @@ gzip: bogus: No such file or directory
39aa: 85.1% -- replaced with aa.gz 39aa: 85.1% -- replaced with aa.gz
40*/ 40*/
41 41
42//usage:#define gzip_trivial_usage
43//usage: "[-cfd] [FILE]..."
44//usage:#define gzip_full_usage "\n\n"
45//usage: "Compress FILEs (or stdin)\n"
46//usage: "\nOptions:"
47//usage: "\n -d Decompress"
48//usage: "\n -c Write to stdout"
49//usage: "\n -f Force"
50//usage:
51//usage:#define gzip_example_usage
52//usage: "$ ls -la /tmp/busybox*\n"
53//usage: "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/busybox.tar\n"
54//usage: "$ gzip /tmp/busybox.tar\n"
55//usage: "$ ls -la /tmp/busybox*\n"
56//usage: "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n"
57
42#include "libbb.h" 58#include "libbb.h"
43#include "archive.h" 59#include "archive.h"
44 60
@@ -1658,7 +1674,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof_)
1658 1674
1659/* =========================================================================== 1675/* ===========================================================================
1660 * Update a hash value with the given input byte 1676 * Update a hash value with the given input byte
1661 * IN assertion: all calls to to UPDATE_HASH are made with consecutive 1677 * IN assertion: all calls to UPDATE_HASH are made with consecutive
1662 * input characters, so that a running hash key can be computed from the 1678 * input characters, so that a running hash key can be computed from the
1663 * previous key instead of complete recalculation each time. 1679 * previous key instead of complete recalculation each time.
1664 */ 1680 */
@@ -1689,7 +1705,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof_)
1689/* Insert string s in the dictionary and set match_head to the previous head 1705/* Insert string s in the dictionary and set match_head to the previous head
1690 * of the hash chain (the most recent string with same hash key). Return 1706 * of the hash chain (the most recent string with same hash key). Return
1691 * the previous length of the hash chain. 1707 * the previous length of the hash chain.
1692 * IN assertion: all calls to to INSERT_STRING are made with consecutive 1708 * IN assertion: all calls to INSERT_STRING are made with consecutive
1693 * input characters and the first MIN_MATCH bytes of s are valid 1709 * input characters and the first MIN_MATCH bytes of s are valid
1694 * (except for the last MIN_MATCH-1 bytes of the input file). */ 1710 * (except for the last MIN_MATCH-1 bytes of the input file). */
1695#define INSERT_STRING(s, match_head) \ 1711#define INSERT_STRING(s, match_head) \
diff --git a/archival/lzop.c b/archival/lzop.c
index 62455c313..f4419910f 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -25,6 +25,33 @@
25 "Minimalized" for busybox by Alain Knaff 25 "Minimalized" for busybox by Alain Knaff
26*/ 26*/
27 27
28//usage:#define lzop_trivial_usage
29//usage: "[-cfvd123456789CF] [FILE]..."
30//usage:#define lzop_full_usage "\n\n"
31//usage: "Options:"
32//usage: "\n -1..9 Compression level"
33//usage: "\n -d Decompress"
34//usage: "\n -c Write to stdout"
35//usage: "\n -f Force"
36//usage: "\n -v Verbose"
37//usage: "\n -F Don't store or verify checksum"
38//usage: "\n -C Also write checksum of compressed block"
39//usage:
40//usage:#define lzopcat_trivial_usage
41//usage: "[-vCF] [FILE]..."
42//usage:#define lzopcat_full_usage "\n\n"
43//usage: " -v Verbose"
44//usage: "\n -F Don't store or verify checksum"
45//usage:
46//usage:#define unlzop_trivial_usage
47//usage: "[-cfvCF] [FILE]..."
48//usage:#define unlzop_full_usage "\n\n"
49//usage: "Options:"
50//usage: "\n -c Write to stdout"
51//usage: "\n -f Force"
52//usage: "\n -v Verbose"
53//usage: "\n -F Don't store or verify checksum"
54
28#include "libbb.h" 55#include "libbb.h"
29#include "archive.h" 56#include "archive.h"
30#include "liblzo_interface.h" 57#include "liblzo_interface.h"
diff --git a/archival/rpm.c b/archival/rpm.c
index 380226f9b..98a45d9cc 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -7,6 +7,19 @@
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 9
10//usage:#define rpm_trivial_usage
11//usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm"
12//usage:#define rpm_full_usage "\n\n"
13//usage: "Manipulate RPM packages\n"
14//usage: "\nCommands:"
15//usage: "\n -i Install package"
16//usage: "\n -qp Query package"
17//usage: "\nOptions:"
18//usage: "\n -i Show information"
19//usage: "\n -l List contents"
20//usage: "\n -d List documents"
21//usage: "\n -c List config files"
22
10#include "libbb.h" 23#include "libbb.h"
11#include "archive.h" 24#include "archive.h"
12#include "rpm.h" 25#include "rpm.h"
diff --git a/archival/rpm2cpio.c b/archival/rpm2cpio.c
index ce8cd2c2c..ff4a0d1b0 100644
--- a/archival/rpm2cpio.c
+++ b/archival/rpm2cpio.c
@@ -6,6 +6,12 @@
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//usage:#define rpm2cpio_trivial_usage
11//usage: "package.rpm"
12//usage:#define rpm2cpio_full_usage "\n\n"
13//usage: "Output a cpio archive of the rpm file"
14
9#include "libbb.h" 15#include "libbb.h"
10#include "archive.h" 16#include "archive.h"
11#include "rpm.h" 17#include "rpm.h"
diff --git a/archival/unzip.c b/archival/unzip.c
index 5d62c08cb..52b0a6414 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -19,6 +19,19 @@
19 * Zip64 + other methods 19 * Zip64 + other methods
20 */ 20 */
21 21
22//usage:#define unzip_trivial_usage
23//usage: "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
24//usage:#define unzip_full_usage "\n\n"
25//usage: "Extract files from ZIP archives\n"
26//usage: "\nOptions:"
27//usage: "\n -l List archive contents (with -q for short form)"
28//usage: "\n -n Never overwrite files (default)"
29//usage: "\n -o Overwrite"
30//usage: "\n -p Send output to stdout"
31//usage: "\n -q Quiet"
32//usage: "\n -x XLST Exclude these files"
33//usage: "\n -d DIR Extract files into DIR"
34
22#include "libbb.h" 35#include "libbb.h"
23#include "archive.h" 36#include "archive.h"
24 37
diff --git a/console-tools/chvt.c b/console-tools/chvt.c
index 07e58c3b8..b9c974f4a 100644
--- a/console-tools/chvt.c
+++ b/console-tools/chvt.c
@@ -6,6 +6,12 @@
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//usage:#define chvt_trivial_usage
11//usage: "N"
12//usage:#define chvt_full_usage "\n\n"
13//usage: "Change the foreground virtual terminal to /dev/ttyN"
14
9#include "libbb.h" 15#include "libbb.h"
10 16
11int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 17int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/console-tools/clear.c b/console-tools/clear.c
index da5e381b8..232d500b5 100644
--- a/console-tools/clear.c
+++ b/console-tools/clear.c
@@ -6,6 +6,12 @@
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//usage:#define clear_trivial_usage
11//usage: ""
12//usage:#define clear_full_usage "\n\n"
13//usage: "Clear screen"
14
9#include "libbb.h" 15#include "libbb.h"
10 16
11int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 17int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/console-tools/deallocvt.c b/console-tools/deallocvt.c
index 6a1d13d14..b131c0a64 100644
--- a/console-tools/deallocvt.c
+++ b/console-tools/deallocvt.c
@@ -10,6 +10,11 @@
10 10
11/* no options, no getopt */ 11/* no options, no getopt */
12 12
13//usage:#define deallocvt_trivial_usage
14//usage: "[N]"
15//usage:#define deallocvt_full_usage "\n\n"
16//usage: "Deallocate unused virtual terminal /dev/ttyN"
17
13#include "libbb.h" 18#include "libbb.h"
14 19
15/* From <linux/vt.h> */ 20/* From <linux/vt.h> */
diff --git a/console-tools/dumpkmap.c b/console-tools/dumpkmap.c
index 301a90674..6b923d2d4 100644
--- a/console-tools/dumpkmap.c
+++ b/console-tools/dumpkmap.c
@@ -9,6 +9,14 @@
9 */ 9 */
10/* no options, no getopt */ 10/* no options, no getopt */
11 11
12//usage:#define dumpkmap_trivial_usage
13//usage: "> keymap"
14//usage:#define dumpkmap_full_usage "\n\n"
15//usage: "Print a binary keyboard translation table to stdout"
16//usage:
17//usage:#define dumpkmap_example_usage
18//usage: "$ dumpkmap > keymap\n"
19
12#include "libbb.h" 20#include "libbb.h"
13 21
14/* From <linux/kd.h> */ 22/* From <linux/kd.h> */
diff --git a/console-tools/fgconsole.c b/console-tools/fgconsole.c
index e2dba4860..54355bee6 100644
--- a/console-tools/fgconsole.c
+++ b/console-tools/fgconsole.c
@@ -7,6 +7,11 @@
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 9
10//usage:#define fgconsole_trivial_usage
11//usage: ""
12//usage:#define fgconsole_full_usage "\n\n"
13//usage: "Get active console"
14
10#include "libbb.h" 15#include "libbb.h"
11 16
12/* From <linux/vt.h> */ 17/* From <linux/vt.h> */
diff --git a/console-tools/kbd_mode.c b/console-tools/kbd_mode.c
index 1481d0dbb..221a9f782 100644
--- a/console-tools/kbd_mode.c
+++ b/console-tools/kbd_mode.c
@@ -8,6 +8,18 @@
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//usage:#define kbd_mode_trivial_usage
13//usage: "[-a|k|s|u] [-C TTY]"
14//usage:#define kbd_mode_full_usage "\n\n"
15//usage: "Report or set the keyboard mode\n"
16//usage: "\nOptions:"
17//usage: "\n -a Default (ASCII)"
18//usage: "\n -k Medium-raw (keyboard)"
19//usage: "\n -s Raw (scancode)"
20//usage: "\n -u Unicode (utf-8)"
21//usage: "\n -C TTY Affect TTY instead of /dev/tty"
22
11#include "libbb.h" 23#include "libbb.h"
12#include <linux/kd.h> 24#include <linux/kd.h>
13 25
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 079626c20..597519f91 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -9,6 +9,27 @@
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//usage:#define loadfont_trivial_usage
14//usage: "< font"
15//usage:#define loadfont_full_usage "\n\n"
16//usage: "Load a console font from stdin"
17/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
18//usage:
19//usage:#define loadfont_example_usage
20//usage: "$ loadfont < /etc/i18n/fontname\n"
21//usage:
22//usage:#define setfont_trivial_usage
23//usage: "FONT [-m MAPFILE] [-C TTY]"
24//usage:#define setfont_full_usage "\n\n"
25//usage: "Load a console font\n"
26//usage: "\nOptions:"
27//usage: "\n -m MAPFILE Load console screen map"
28//usage: "\n -C TTY Affect TTY instead of /dev/tty"
29//usage:
30//usage:#define setfont_example_usage
31//usage: "$ setfont -m koi8-r /etc/i18n/fontname\n"
32
12#include "libbb.h" 33#include "libbb.h"
13#include <sys/kd.h> 34#include <sys/kd.h>
14 35
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index 2d1c9e284..bcffe16b1 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -6,6 +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//usage:#define loadkmap_trivial_usage
11//usage: "< keymap"
12//usage:#define loadkmap_full_usage "\n\n"
13//usage: "Load a binary keyboard translation table from stdin\n"
14/* //usage: "\n -C TTY Affect TTY instead of /dev/tty" */
15//usage:
16//usage:#define loadkmap_example_usage
17//usage: "$ loadkmap < /etc/i18n/lang-keymap\n"
18
9#include "libbb.h" 19#include "libbb.h"
10 20
11#define BINARY_KEYMAP_MAGIC "bkeymap" 21#define BINARY_KEYMAP_MAGIC "bkeymap"
diff --git a/console-tools/openvt.c b/console-tools/openvt.c
index 56f50c6cd..de5cf93fe 100644
--- a/console-tools/openvt.c
+++ b/console-tools/openvt.c
@@ -8,6 +8,19 @@
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 10
11//usage:#define openvt_trivial_usage
12//usage: "[-c N] [-sw] [PROG ARGS]"
13//usage:#define openvt_full_usage "\n\n"
14//usage: "Start PROG on a new virtual terminal\n"
15//usage: "\nOptions:"
16//usage: "\n -c N Use specified VT"
17//usage: "\n -s Switch to the VT"
18/* //usage: "\n -l Run PROG as login shell (by prepending '-')" */
19//usage: "\n -w Wait for PROG to exit"
20//usage:
21//usage:#define openvt_example_usage
22//usage: "openvt 2 /bin/ash\n"
23
11#include <linux/vt.h> 24#include <linux/vt.h>
12#include "libbb.h" 25#include "libbb.h"
13 26
diff --git a/console-tools/reset.c b/console-tools/reset.c
index a23e4f408..65940bdec 100644
--- a/console-tools/reset.c
+++ b/console-tools/reset.c
@@ -11,6 +11,11 @@
11/* BTW, which "standard" package has this utility? It doesn't seem 11/* BTW, which "standard" package has this utility? It doesn't seem
12 * to be ncurses, coreutils, console-tools... then what? */ 12 * to be ncurses, coreutils, console-tools... then what? */
13 13
14//usage:#define reset_trivial_usage
15//usage: ""
16//usage:#define reset_full_usage "\n\n"
17//usage: "Reset the screen"
18
14#include "libbb.h" 19#include "libbb.h"
15 20
16#define ESC "\033" 21#define ESC "\033"
diff --git a/console-tools/resize.c b/console-tools/resize.c
index ee0728b71..4b0d63a03 100644
--- a/console-tools/resize.c
+++ b/console-tools/resize.c
@@ -7,6 +7,12 @@
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/* no options, no getopt */ 9/* no options, no getopt */
10
11//usage:#define resize_trivial_usage
12//usage: ""
13//usage:#define resize_full_usage "\n\n"
14//usage: "Resize the screen"
15
10#include "libbb.h" 16#include "libbb.h"
11 17
12#define ESC "\033" 18#define ESC "\033"
diff --git a/console-tools/setconsole.c b/console-tools/setconsole.c
index 87265baf8..59c83361c 100644
--- a/console-tools/setconsole.c
+++ b/console-tools/setconsole.c
@@ -8,6 +8,13 @@
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 10
11//usage:#define setconsole_trivial_usage
12//usage: "[-r" IF_FEATURE_SETCONSOLE_LONG_OPTIONS("|--reset") "] [DEVICE]"
13//usage:#define setconsole_full_usage "\n\n"
14//usage: "Redirect system console output to DEVICE (default: /dev/tty)\n"
15//usage: "\nOptions:"
16//usage: "\n -r Reset output to /dev/console"
17
11#include "libbb.h" 18#include "libbb.h"
12 19
13int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/console-tools/setkeycodes.c b/console-tools/setkeycodes.c
index ca8cd21c2..a6a7c2374 100644
--- a/console-tools/setkeycodes.c
+++ b/console-tools/setkeycodes.c
@@ -8,6 +8,18 @@
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//usage:#define setkeycodes_trivial_usage
13//usage: "SCANCODE KEYCODE..."
14//usage:#define setkeycodes_full_usage "\n\n"
15//usage: "Set entries into the kernel's scancode-to-keycode map,\n"
16//usage: "allowing unusual keyboards to generate usable keycodes.\n\n"
17//usage: "SCANCODE may be either xx or e0xx (hexadecimal),\n"
18//usage: "and KEYCODE is given in decimal."
19//usage:
20//usage:#define setkeycodes_example_usage
21//usage: "$ setkeycodes e030 127\n"
22
11#include "libbb.h" 23#include "libbb.h"
12 24
13/* From <linux/kd.h> */ 25/* From <linux/kd.h> */
diff --git a/console-tools/setlogcons.c b/console-tools/setlogcons.c
index 52d2608aa..83a895407 100644
--- a/console-tools/setlogcons.c
+++ b/console-tools/setlogcons.c
@@ -9,6 +9,11 @@
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 11
12//usage:#define setlogcons_trivial_usage
13//usage: "N"
14//usage:#define setlogcons_full_usage "\n\n"
15//usage: "Redirect the kernel output to console N (0 for current)"
16
12#include "libbb.h" 17#include "libbb.h"
13 18
14int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 19int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/console-tools/showkey.c b/console-tools/showkey.c
index 06df68bfd..2c832c92c 100644
--- a/console-tools/showkey.c
+++ b/console-tools/showkey.c
@@ -7,6 +7,15 @@
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 9
10//usage:#define showkey_trivial_usage
11//usage: "[-a | -k | -s]"
12//usage:#define showkey_full_usage "\n\n"
13//usage: "Show keys pressed\n"
14//usage: "\nOptions:"
15//usage: "\n -a Display decimal/octal/hex values of the keys"
16//usage: "\n -k Display interpreted keycodes (default)"
17//usage: "\n -s Display raw scan-codes"
18
10#include "libbb.h" 19#include "libbb.h"
11#include <linux/kd.h> 20#include <linux/kd.h>
12 21
diff --git a/coreutils/basename.c b/coreutils/basename.c
index d44124741..1f7a13713 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -28,6 +28,19 @@
28//config: leaving just the filename itself. Enable this option if you wish 28//config: leaving just the filename itself. Enable this option if you wish
29//config: to enable the 'basename' utility. 29//config: to enable the 'basename' utility.
30 30
31//usage:#define basename_trivial_usage
32//usage: "FILE [SUFFIX]"
33//usage:#define basename_full_usage "\n\n"
34//usage: "Strip directory path and .SUFFIX from FILE\n"
35//usage:
36//usage:#define basename_example_usage
37//usage: "$ basename /usr/local/bin/foo\n"
38//usage: "foo\n"
39//usage: "$ basename /usr/local/bin/\n"
40//usage: "bin\n"
41//usage: "$ basename /foo/bar.txt .txt\n"
42//usage: "bar"
43
31#include "libbb.h" 44#include "libbb.h"
32 45
33/* This is a NOFORK applet. Be very careful! */ 46/* This is a NOFORK applet. Be very careful! */
@@ -38,6 +51,11 @@ int basename_main(int argc, char **argv)
38 size_t m, n; 51 size_t m, n;
39 char *s; 52 char *s;
40 53
54 if (argv[1] && strcmp(argv[1], "--") == 0) {
55 argv++;
56 argc--;
57 }
58
41 if ((unsigned)(argc-2) >= 2) { 59 if ((unsigned)(argc-2) >= 2) {
42 bb_show_usage(); 60 bb_show_usage();
43 } 61 }
diff --git a/coreutils/cal.c b/coreutils/cal.c
index f18c16120..ef1c29bb9 100644
--- a/coreutils/cal.c
+++ b/coreutils/cal.c
@@ -16,6 +16,15 @@
16 * 16 *
17 * Major size reduction... over 50% (>1.5k) on i386. 17 * Major size reduction... over 50% (>1.5k) on i386.
18 */ 18 */
19
20//usage:#define cal_trivial_usage
21//usage: "[-jy] [[MONTH] YEAR]"
22//usage:#define cal_full_usage "\n\n"
23//usage: "Display a calendar\n"
24//usage: "\nOptions:"
25//usage: "\n -j Use julian dates"
26//usage: "\n -y Display the entire year"
27
19#include "libbb.h" 28#include "libbb.h"
20#include "unicode.h" 29#include "unicode.h"
21 30
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 922549828..00c38d486 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -22,6 +22,15 @@
22//config: cat is used to concatenate files and print them to the standard 22//config: cat is used to concatenate files and print them to the standard
23//config: output. Enable this option if you wish to enable the 'cat' utility. 23//config: output. Enable this option if you wish to enable the 'cat' utility.
24 24
25//usage:#define cat_trivial_usage
26//usage: "[FILE]..."
27//usage:#define cat_full_usage "\n\n"
28//usage: "Concatenate FILEs and print them to stdout"
29//usage:
30//usage:#define cat_example_usage
31//usage: "$ cat /proc/uptime\n"
32//usage: "110716.72 17.67"
33
25#include "libbb.h" 34#include "libbb.h"
26 35
27/* This is a NOFORK applet. Be very careful! */ 36/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/catv.c b/coreutils/catv.c
index f92d93d24..37c7ed2d1 100644
--- a/coreutils/catv.c
+++ b/coreutils/catv.c
@@ -10,6 +10,15 @@
10/* See "Cat -v considered harmful" at 10/* See "Cat -v considered harmful" at
11 * http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */ 11 * http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
12 12
13//usage:#define catv_trivial_usage
14//usage: "[-etv] [FILE]..."
15//usage:#define catv_full_usage "\n\n"
16//usage: "Display nonprinting characters as ^x or M-x\n"
17//usage: "\nOptions:"
18//usage: "\n -e End each line with $"
19//usage: "\n -t Show tabs as ^I"
20//usage: "\n -v Don't use ^x or M-x escapes"
21
13#include "libbb.h" 22#include "libbb.h"
14 23
15int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 24int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c
index 58f78e736..bc9608362 100644
--- a/coreutils/chgrp.c
+++ b/coreutils/chgrp.c
@@ -11,6 +11,29 @@
11/* BB_AUDIT GNU defects - unsupported long options. */ 11/* BB_AUDIT GNU defects - unsupported long options. */
12/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */ 12/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
13 13
14//usage:#define chgrp_trivial_usage
15//usage: "[-RhLHP"IF_DESKTOP("cvf")"]... GROUP FILE..."
16//usage:#define chgrp_full_usage "\n\n"
17//usage: "Change the group membership of each FILE to GROUP\n"
18//usage: "\nOptions:"
19//usage: "\n -R Recurse"
20//usage: "\n -h Affect symlinks instead of symlink targets"
21//usage: "\n -L Traverse all symlinks to directories"
22//usage: "\n -H Traverse symlinks on command line only"
23//usage: "\n -P Don't traverse symlinks (default)"
24//usage: IF_DESKTOP(
25//usage: "\n -c List changed files"
26//usage: "\n -v Verbose"
27//usage: "\n -f Hide errors"
28//usage: )
29//usage:
30//usage:#define chgrp_example_usage
31//usage: "$ ls -l /tmp/foo\n"
32//usage: "-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n"
33//usage: "$ chgrp root /tmp/foo\n"
34//usage: "$ ls -l /tmp/foo\n"
35//usage: "-r--r--r-- 1 andersen root 0 Apr 12 18:25 /tmp/foo\n"
36
14#include "libbb.h" 37#include "libbb.h"
15 38
16/* This is a NOEXEC applet. Be very careful! */ 39/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index f07a49bd3..0bcd6bb66 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -14,6 +14,29 @@
14/* BB_AUDIT GNU defects - unsupported long options. */ 14/* BB_AUDIT GNU defects - unsupported long options. */
15/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */ 15/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
16 16
17//usage:#define chmod_trivial_usage
18//usage: "[-R"IF_DESKTOP("cvf")"] MODE[,MODE]... FILE..."
19//usage:#define chmod_full_usage "\n\n"
20//usage: "Each MODE is one or more of the letters ugoa, one of the\n"
21//usage: "symbols +-= and one or more of the letters rwxst\n"
22//usage: "\nOptions:"
23//usage: "\n -R Recurse"
24//usage: IF_DESKTOP(
25//usage: "\n -c List changed files"
26//usage: "\n -v List all files"
27//usage: "\n -f Hide errors"
28//usage: )
29//usage:
30//usage:#define chmod_example_usage
31//usage: "$ ls -l /tmp/foo\n"
32//usage: "-rw-rw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
33//usage: "$ chmod u+x /tmp/foo\n"
34//usage: "$ ls -l /tmp/foo\n"
35//usage: "-rwxrw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo*\n"
36//usage: "$ chmod 444 /tmp/foo\n"
37//usage: "$ ls -l /tmp/foo\n"
38//usage: "-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
39
17#include "libbb.h" 40#include "libbb.h"
18 41
19/* This is a NOEXEC applet. Be very careful! */ 42/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/chown.c b/coreutils/chown.c
index 282deccfb..c4c182d3c 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -10,6 +10,32 @@
10/* BB_AUDIT SUSv3 defects - none? */ 10/* BB_AUDIT SUSv3 defects - none? */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
12 12
13//usage:#define chown_trivial_usage
14//usage: "[-RhLHP"IF_DESKTOP("cvf")"]... OWNER[<.|:>[GROUP]] FILE..."
15//usage:#define chown_full_usage "\n\n"
16//usage: "Change the owner and/or group of each FILE to OWNER and/or GROUP\n"
17//usage: "\nOptions:"
18//usage: "\n -R Recurse"
19//usage: "\n -h Affect symlinks instead of symlink targets"
20//usage: "\n -L Traverse all symlinks to directories"
21//usage: "\n -H Traverse symlinks on command line only"
22//usage: "\n -P Don't traverse symlinks (default)"
23//usage: IF_DESKTOP(
24//usage: "\n -c List changed files"
25//usage: "\n -v List all files"
26//usage: "\n -f Hide errors"
27//usage: )
28//usage:
29//usage:#define chown_example_usage
30//usage: "$ ls -l /tmp/foo\n"
31//usage: "-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n"
32//usage: "$ chown root /tmp/foo\n"
33//usage: "$ ls -l /tmp/foo\n"
34//usage: "-r--r--r-- 1 root andersen 0 Apr 12 18:25 /tmp/foo\n"
35//usage: "$ chown root.root /tmp/foo\n"
36//usage: "ls -l /tmp/foo\n"
37//usage: "-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
38
13#include "libbb.h" 39#include "libbb.h"
14 40
15/* This is a NOEXEC applet. Be very careful! */ 41/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index 5ac2e890e..ab8beb023 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -9,6 +9,19 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12//usage:#define chroot_trivial_usage
13//usage: "NEWROOT [PROG ARGS]"
14//usage:#define chroot_full_usage "\n\n"
15//usage: "Run PROG with root directory set to NEWROOT"
16//usage:
17//usage:#define chroot_example_usage
18//usage: "$ ls -l /bin/ls\n"
19//usage: "lrwxrwxrwx 1 root root 12 Apr 13 00:46 /bin/ls -> /BusyBox\n"
20//usage: "# mount /dev/hdc1 /mnt -t minix\n"
21//usage: "# chroot /mnt\n"
22//usage: "# ls -l /bin/ls\n"
23//usage: "-rwxr-xr-x 1 root root 40816 Feb 5 07:45 /bin/ls*\n"
24
12#include "libbb.h" 25#include "libbb.h"
13 26
14int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 27int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index 53fb87a78..ac0b0c319 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -6,6 +6,12 @@
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//usage:#define cksum_trivial_usage
11//usage: "FILES..."
12//usage:#define cksum_full_usage "\n\n"
13//usage: "Calculate the CRC32 checksums of FILES"
14
9#include "libbb.h" 15#include "libbb.h"
10 16
11/* This is a NOEXEC applet. Be very careful! */ 17/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/comm.c b/coreutils/comm.c
index c04da1896..7da6b25f9 100644
--- a/coreutils/comm.c
+++ b/coreutils/comm.c
@@ -7,6 +7,15 @@
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 9
10//usage:#define comm_trivial_usage
11//usage: "[-123] FILE1 FILE2"
12//usage:#define comm_full_usage "\n\n"
13//usage: "Compare FILE1 with FILE2\n"
14//usage: "\nOptions:"
15//usage: "\n -1 Suppress lines unique to FILE1"
16//usage: "\n -2 Suppress lines unique to FILE2"
17//usage: "\n -3 Suppress lines common to both files"
18
10#include "libbb.h" 19#include "libbb.h"
11 20
12#define COMM_OPT_1 (1 << 0) 21#define COMM_OPT_1 (1 << 0)
diff --git a/coreutils/cp.c b/coreutils/cp.c
index bbdb10e95..c35dc2872 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -15,6 +15,24 @@
15 * Size reduction. 15 * Size reduction.
16 */ 16 */
17 17
18//usage:#define cp_trivial_usage
19//usage: "[OPTIONS] SOURCE DEST"
20//usage:#define cp_full_usage "\n\n"
21//usage: "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY\n"
22//usage: "\nOptions:"
23//usage: "\n -a Same as -dpR"
24//usage: IF_SELINUX(
25//usage: "\n -c Preserve security context"
26//usage: )
27//usage: "\n -R,-r Recurse"
28//usage: "\n -d,-P Preserve symlinks (default if -R)"
29//usage: "\n -L Follow all symlinks"
30//usage: "\n -H Follow symlinks on command line"
31//usage: "\n -p Preserve file attributes if possible"
32//usage: "\n -f Overwrite"
33//usage: "\n -i Prompt before overwrite"
34//usage: "\n -l,-s Create (sym)links"
35
18#include "libbb.h" 36#include "libbb.h"
19#include "libcoreutils/coreutils.h" 37#include "libcoreutils/coreutils.h"
20 38
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 38cd32c77..dfa1833b4 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -9,6 +9,24 @@
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 11
12//usage:#define cut_trivial_usage
13//usage: "[OPTIONS] [FILE]..."
14//usage:#define cut_full_usage "\n\n"
15//usage: "Print selected fields from each input FILE to stdout\n"
16//usage: "\nOptions:"
17//usage: "\n -b LIST Output only bytes from LIST"
18//usage: "\n -c LIST Output only characters from LIST"
19//usage: "\n -d CHAR Use CHAR instead of tab as the field delimiter"
20//usage: "\n -s Output only the lines containing delimiter"
21//usage: "\n -f N Print only these fields"
22//usage: "\n -n Ignored"
23//usage:
24//usage:#define cut_example_usage
25//usage: "$ echo \"Hello world\" | cut -f 1 -d ' '\n"
26//usage: "Hello\n"
27//usage: "$ echo \"Hello world\" | cut -f 2 -d ' '\n"
28//usage: "world\n"
29
12#include "libbb.h" 30#include "libbb.h"
13 31
14/* This is a NOEXEC applet. Be very careful! */ 32/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 544ece051..e4b53c0af 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -8,6 +8,39 @@
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 10
11//usage:#define dd_trivial_usage
12//usage: "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n"
13//usage: " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]")
14//usage:#define dd_full_usage "\n\n"
15//usage: "Copy a file with converting and formatting\n"
16//usage: "\nOptions:"
17//usage: "\n if=FILE Read from FILE instead of stdin"
18//usage: "\n of=FILE Write to FILE instead of stdout"
19//usage: "\n bs=N Read and write N bytes at a time"
20//usage: IF_FEATURE_DD_IBS_OBS(
21//usage: "\n ibs=N Read N bytes at a time"
22//usage: )
23//usage: IF_FEATURE_DD_IBS_OBS(
24//usage: "\n obs=N Write N bytes at a time"
25//usage: )
26//usage: "\n count=N Copy only N input blocks"
27//usage: "\n skip=N Skip N input blocks"
28//usage: "\n seek=N Skip N output blocks"
29//usage: IF_FEATURE_DD_IBS_OBS(
30//usage: "\n conv=notrunc Don't truncate output file"
31//usage: "\n conv=noerror Continue after read errors"
32//usage: "\n conv=sync Pad blocks with zeros"
33//usage: "\n conv=fsync Physically write data out before finishing"
34//usage: )
35//usage: "\n"
36//usage: "\nNumbers may be suffixed by c (x1), w (x2), b (x512), kD (x1000), k (x1024),"
37//usage: "\nMD (x1000000), M (x1048576), GD (x1000000000) or G (x1073741824)"
38//usage:
39//usage:#define dd_example_usage
40//usage: "$ dd if=/dev/zero of=/dev/ram1 bs=1M count=4\n"
41//usage: "4+0 records in\n"
42//usage: "4+0 records out\n"
43
11#include "libbb.h" 44#include "libbb.h"
12 45
13/* This is a NOEXEC applet. Be very careful! */ 46/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/df.c b/coreutils/df.c
index 70fd1f4fd..518e856a2 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -22,6 +22,41 @@
22 * Implement -P and -B; better coreutils compat; cleanup 22 * Implement -P and -B; better coreutils compat; cleanup
23 */ 23 */
24 24
25//usage:#define df_trivial_usage
26//usage: "[-Pk"
27//usage: IF_FEATURE_HUMAN_READABLE("mh")
28//usage: IF_FEATURE_DF_FANCY("ai] [-B SIZE")
29//usage: "] [FILESYSTEM]..."
30//usage:#define df_full_usage "\n\n"
31//usage: "Print filesystem usage statistics\n"
32//usage: "\nOptions:"
33//usage: "\n -P POSIX output format"
34//usage: "\n -k 1024-byte blocks (default)"
35//usage: IF_FEATURE_HUMAN_READABLE(
36//usage: "\n -m 1M-byte blocks"
37//usage: "\n -h Human readable (e.g. 1K 243M 2G)"
38//usage: )
39//usage: IF_FEATURE_DF_FANCY(
40//usage: "\n -a Show all filesystems"
41//usage: "\n -i Inodes"
42//usage: "\n -B SIZE Blocksize"
43//usage: )
44//usage:
45//usage:#define df_example_usage
46//usage: "$ df\n"
47//usage: "Filesystem 1K-blocks Used Available Use% Mounted on\n"
48//usage: "/dev/sda3 8690864 8553540 137324 98% /\n"
49//usage: "/dev/sda1 64216 36364 27852 57% /boot\n"
50//usage: "$ df /dev/sda3\n"
51//usage: "Filesystem 1K-blocks Used Available Use% Mounted on\n"
52//usage: "/dev/sda3 8690864 8553540 137324 98% /\n"
53//usage: "$ POSIXLY_CORRECT=sure df /dev/sda3\n"
54//usage: "Filesystem 512B-blocks Used Available Use% Mounted on\n"
55//usage: "/dev/sda3 17381728 17107080 274648 98% /\n"
56//usage: "$ POSIXLY_CORRECT=yep df -P /dev/sda3\n"
57//usage: "Filesystem 512-blocks Used Available Capacity Mounted on\n"
58//usage: "/dev/sda3 17381728 17107080 274648 98% /\n"
59
25#include <mntent.h> 60#include <mntent.h>
26#include <sys/vfs.h> 61#include <sys/vfs.h>
27#include "libbb.h" 62#include "libbb.h"
diff --git a/coreutils/dirname.c b/coreutils/dirname.c
index 246946ed0..101067c90 100644
--- a/coreutils/dirname.c
+++ b/coreutils/dirname.c
@@ -10,6 +10,17 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
12 12
13//usage:#define dirname_trivial_usage
14//usage: "FILENAME"
15//usage:#define dirname_full_usage "\n\n"
16//usage: "Strip non-directory suffix from FILENAME"
17//usage:
18//usage:#define dirname_example_usage
19//usage: "$ dirname /tmp/foo\n"
20//usage: "/tmp\n"
21//usage: "$ dirname /tmp/foo/\n"
22//usage: "/tmp\n"
23
13#include "libbb.h" 24#include "libbb.h"
14 25
15/* This is a NOFORK applet. Be very careful! */ 26/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/dos2unix.c b/coreutils/dos2unix.c
index 35fa11247..add1da666 100644
--- a/coreutils/dos2unix.c
+++ b/coreutils/dos2unix.c
@@ -12,6 +12,24 @@
12 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 12 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
13*/ 13*/
14 14
15//usage:#define dos2unix_trivial_usage
16//usage: "[-ud] [FILE]"
17//usage:#define dos2unix_full_usage "\n\n"
18//usage: "Convert FILE in-place from DOS to Unix format.\n"
19//usage: "When no file is given, use stdin/stdout.\n"
20//usage: "\nOptions:"
21//usage: "\n -u dos2unix"
22//usage: "\n -d unix2dos"
23//usage:
24//usage:#define unix2dos_trivial_usage
25//usage: "[-ud] [FILE]"
26//usage:#define unix2dos_full_usage "\n\n"
27//usage: "Convert FILE in-place from Unix to DOS format.\n"
28//usage: "When no file is given, use stdin/stdout.\n"
29//usage: "\nOptions:"
30//usage: "\n -u dos2unix"
31//usage: "\n -d unix2dos"
32
15#include "libbb.h" 33#include "libbb.h"
16 34
17/* This is a NOEXEC applet. Be very careful! */ 35/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/du.c b/coreutils/du.c
index cc3c78433..7a6662d1e 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -23,6 +23,43 @@
23 * 4) Fixed busybox bug #1284 involving long overflow with human_readable. 23 * 4) Fixed busybox bug #1284 involving long overflow with human_readable.
24 */ 24 */
25 25
26//usage:#define du_trivial_usage
27//usage: "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..."
28//usage:#define du_full_usage "\n\n"
29//usage: "Summarize disk space used for each FILE and/or directory.\n"
30//usage: "Disk space is printed in units of "
31//usage: IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("1024")
32//usage: IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("512")
33//usage: " bytes.\n"
34//usage: "\nOptions:"
35//usage: "\n -a Show file sizes too"
36//usage: "\n -L Follow all symlinks"
37//usage: "\n -H Follow symlinks on command line"
38//usage: "\n -d N Limit output to directories (and files with -a) of depth < N"
39//usage: "\n -c Show grand total"
40//usage: "\n -l Count sizes many times if hard linked"
41//usage: "\n -s Display only a total for each argument"
42//usage: "\n -x Skip directories on different filesystems"
43//usage: IF_FEATURE_HUMAN_READABLE(
44//usage: "\n -h Sizes in human readable format (e.g., 1K 243M 2G )"
45//usage: "\n -m Sizes in megabytes"
46//usage: )
47//usage: "\n -k Sizes in kilobytes"
48//usage: IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)")
49//usage:
50//usage:#define du_example_usage
51//usage: "$ du\n"
52//usage: "16 ./CVS\n"
53//usage: "12 ./kernel-patches/CVS\n"
54//usage: "80 ./kernel-patches\n"
55//usage: "12 ./tests/CVS\n"
56//usage: "36 ./tests\n"
57//usage: "12 ./scripts/CVS\n"
58//usage: "16 ./scripts\n"
59//usage: "12 ./docs/CVS\n"
60//usage: "104 ./docs\n"
61//usage: "2417 .\n"
62
26#include "libbb.h" 63#include "libbb.h"
27 64
28enum { 65enum {
diff --git a/coreutils/echo.c b/coreutils/echo.c
index 72e18c161..0895e2940 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -23,6 +23,27 @@
23 * The previous version did not allow 4-digit octals. 23 * The previous version did not allow 4-digit octals.
24 */ 24 */
25 25
26//usage:#define echo_trivial_usage
27//usage: IF_FEATURE_FANCY_ECHO("[-neE] ") "[ARG]..."
28//usage:#define echo_full_usage "\n\n"
29//usage: "Print the specified ARGs to stdout"
30//usage: IF_FEATURE_FANCY_ECHO( "\n"
31//usage: "\nOptions:"
32//usage: "\n -n Suppress trailing newline"
33//usage: "\n -e Interpret backslash escapes (i.e., \\t=tab)"
34//usage: "\n -E Don't interpret backslash escapes (default)"
35//usage: )
36//usage:
37//usage:#define echo_example_usage
38//usage: "$ echo \"Erik is cool\"\n"
39//usage: "Erik is cool\n"
40//usage: IF_FEATURE_FANCY_ECHO("$ echo -e \"Erik\\nis\\ncool\"\n"
41//usage: "Erik\n"
42//usage: "is\n"
43//usage: "cool\n"
44//usage: "$ echo \"Erik\\nis\\ncool\"\n"
45//usage: "Erik\\nis\\ncool\n")
46
26#include "libbb.h" 47#include "libbb.h"
27 48
28/* This is a NOFORK applet. Be very careful! */ 49/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/env.c b/coreutils/env.c
index d64a71439..747c668da 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -31,6 +31,15 @@
31 31
32/* This is a NOEXEC applet. Be very careful! */ 32/* This is a NOEXEC applet. Be very careful! */
33 33
34//usage:#define env_trivial_usage
35//usage: "[-iu] [-] [name=value]... [PROG ARGS]"
36//usage:#define env_full_usage "\n\n"
37//usage: "Print the current environment or run PROG after setting up\n"
38//usage: "the specified environment\n"
39//usage: "\nOptions:"
40//usage: "\n -, -i Start with an empty environment"
41//usage: "\n -u Remove variable from the environment"
42
34#include "libbb.h" 43#include "libbb.h"
35 44
36#if ENABLE_FEATURE_ENV_LONG_OPTIONS 45#if ENABLE_FEATURE_ENV_LONG_OPTIONS
diff --git a/coreutils/expand.c b/coreutils/expand.c
index 7491b717a..73ab0ece3 100644
--- a/coreutils/expand.c
+++ b/coreutils/expand.c
@@ -20,6 +20,37 @@
20 * 20 *
21 * Caveat: this versions of expand and unexpand don't accept tab lists. 21 * Caveat: this versions of expand and unexpand don't accept tab lists.
22 */ 22 */
23
24//usage:#define expand_trivial_usage
25//usage: "[-i] [-t N] [FILE]..."
26//usage:#define expand_full_usage "\n\n"
27//usage: "Convert tabs to spaces, writing to stdout\n"
28//usage: "\nOptions:"
29//usage: IF_FEATURE_EXPAND_LONG_OPTIONS(
30//usage: "\n -i,--initial Don't convert tabs after non blanks"
31//usage: "\n -t,--tabs=N Tabstops every N chars"
32//usage: )
33//usage: IF_NOT_FEATURE_EXPAND_LONG_OPTIONS(
34//usage: "\n -i Don't convert tabs after non blanks"
35//usage: "\n -t Tabstops every N chars"
36//usage: )
37
38//usage:#define unexpand_trivial_usage
39//usage: "[-fa][-t N] [FILE]..."
40//usage:#define unexpand_full_usage "\n\n"
41//usage: "Convert spaces to tabs, writing to stdout\n"
42//usage: "\nOptions:"
43//usage: IF_FEATURE_UNEXPAND_LONG_OPTIONS(
44//usage: "\n -a,--all Convert all blanks"
45//usage: "\n -f,--first-only Convert only leading blanks"
46//usage: "\n -t,--tabs=N Tabstops every N chars"
47//usage: )
48//usage: IF_NOT_FEATURE_UNEXPAND_LONG_OPTIONS(
49//usage: "\n -a Convert all blanks"
50//usage: "\n -f Convert only leading blanks"
51//usage: "\n -t N Tabstops every N chars"
52//usage: )
53
23#include "libbb.h" 54#include "libbb.h"
24#include "unicode.h" 55#include "unicode.h"
25 56
diff --git a/coreutils/expr.c b/coreutils/expr.c
index 04d783f2b..24e75b556 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -25,6 +25,41 @@
25 25
26/* no getopt needed */ 26/* no getopt needed */
27 27
28//usage:#define expr_trivial_usage
29//usage: "EXPRESSION"
30//usage:#define expr_full_usage "\n\n"
31//usage: "Print the value of EXPRESSION to stdout\n"
32//usage: "\n"
33//usage: "EXPRESSION may be:\n"
34//usage: " ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2\n"
35//usage: " ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0\n"
36//usage: " ARG1 < ARG2 1 if ARG1 is less than ARG2, else 0. Similarly:\n"
37//usage: " ARG1 <= ARG2\n"
38//usage: " ARG1 = ARG2\n"
39//usage: " ARG1 != ARG2\n"
40//usage: " ARG1 >= ARG2\n"
41//usage: " ARG1 > ARG2\n"
42//usage: " ARG1 + ARG2 Sum of ARG1 and ARG2. Similarly:\n"
43//usage: " ARG1 - ARG2\n"
44//usage: " ARG1 * ARG2\n"
45//usage: " ARG1 / ARG2\n"
46//usage: " ARG1 % ARG2\n"
47//usage: " STRING : REGEXP Anchored pattern match of REGEXP in STRING\n"
48//usage: " match STRING REGEXP Same as STRING : REGEXP\n"
49//usage: " substr STRING POS LENGTH Substring of STRING, POS counted from 1\n"
50//usage: " index STRING CHARS Index in STRING where any CHARS is found, or 0\n"
51//usage: " length STRING Length of STRING\n"
52//usage: " quote TOKEN Interpret TOKEN as a string, even if\n"
53//usage: " it is a keyword like 'match' or an\n"
54//usage: " operator like '/'\n"
55//usage: " (EXPRESSION) Value of EXPRESSION\n"
56//usage: "\n"
57//usage: "Beware that many operators need to be escaped or quoted for shells.\n"
58//usage: "Comparisons are arithmetic if both ARGs are numbers, else\n"
59//usage: "lexicographical. Pattern matches return the string matched between\n"
60//usage: "\\( and \\) or null; if \\( and \\) are not used, they return the number\n"
61//usage: "of characters matched or 0."
62
28#include "libbb.h" 63#include "libbb.h"
29#include "xregex.h" 64#include "xregex.h"
30 65
diff --git a/coreutils/false.c b/coreutils/false.c
index 033d2bff4..59c2f321a 100644
--- a/coreutils/false.c
+++ b/coreutils/false.c
@@ -10,6 +10,16 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */ 11/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
12 12
13//usage:#define false_trivial_usage
14//usage: ""
15//usage:#define false_full_usage "\n\n"
16//usage: "Return an exit code of FALSE (1)"
17//usage:
18//usage:#define false_example_usage
19//usage: "$ false\n"
20//usage: "$ echo $?\n"
21//usage: "1\n"
22
13#include "libbb.h" 23#include "libbb.h"
14 24
15/* This is a NOFORK applet. Be very careful! */ 25/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 4a6429ad7..3fe668512 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -9,6 +9,16 @@
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//usage:#define fold_trivial_usage
14//usage: "[-bs] [-w WIDTH] [FILE]..."
15//usage:#define fold_full_usage "\n\n"
16//usage: "Wrap input lines in each FILE (or stdin), writing to stdout\n"
17//usage: "\nOptions:"
18//usage: "\n -b Count bytes rather than columns"
19//usage: "\n -s Break at spaces"
20//usage: "\n -w Use WIDTH columns instead of 80"
21
12#include "libbb.h" 22#include "libbb.h"
13#include "unicode.h" 23#include "unicode.h"
14 24
diff --git a/coreutils/fsync.c b/coreutils/fsync.c
index b8b463cd1..518c5642b 100644
--- a/coreutils/fsync.c
+++ b/coreutils/fsync.c
@@ -6,6 +6,14 @@
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//usage:#define fsync_trivial_usage
11//usage: "[-d] FILE..."
12//usage:#define fsync_full_usage "\n\n"
13//usage: "Write files' buffered blocks to disk\n"
14//usage: "\nOptions:"
15//usage: "\n -d Avoid syncing metadata"
16
9#include "libbb.h" 17#include "libbb.h"
10#ifndef O_NOATIME 18#ifndef O_NOATIME
11# define O_NOATIME 0 19# define O_NOATIME 0
diff --git a/coreutils/head.c b/coreutils/head.c
index 669aae819..f49320ef4 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -11,6 +11,26 @@
11/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */ 11/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
12/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */ 12/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
13 13
14//usage:#define head_trivial_usage
15//usage: "[OPTIONS] [FILE]..."
16//usage:#define head_full_usage "\n\n"
17//usage: "Print first 10 lines of each FILE (or stdin) to stdout.\n"
18//usage: "With more than one FILE, precede each with a filename header.\n"
19//usage: "\nOptions:"
20//usage: "\n -n N[kbm] Print first N lines"
21//usage: IF_FEATURE_FANCY_HEAD(
22//usage: "\n -c N[kbm] Print first N bytes"
23//usage: "\n -q Never print headers"
24//usage: "\n -v Always print headers"
25//usage: )
26//usage: "\n"
27//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)."
28//usage:
29//usage:#define head_example_usage
30//usage: "$ head -n 2 /etc/passwd\n"
31//usage: "root:x:0:0:root:/root:/bin/bash\n"
32//usage: "daemon:x:1:1:daemon:/usr/sbin:/bin/sh\n"
33
14#include "libbb.h" 34#include "libbb.h"
15 35
16/* This is a NOEXEC applet. Be very careful! */ 36/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/hostid.c b/coreutils/hostid.c
index 635e48e12..49409b9de 100644
--- a/coreutils/hostid.c
+++ b/coreutils/hostid.c
@@ -9,6 +9,11 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12//usage:#define hostid_trivial_usage
13//usage: ""
14//usage:#define hostid_full_usage "\n\n"
15//usage: "Print out a unique 32-bit identifier for the machine"
16
12#include "libbb.h" 17#include "libbb.h"
13 18
14/* This is a NOFORK applet. Be very careful! */ 19/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/id.c b/coreutils/id.c
index 0639325c3..42ed4c749 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -15,6 +15,24 @@
15 * Added -G option Tito Ragusa (C) 2008 for SUSv3. 15 * Added -G option Tito Ragusa (C) 2008 for SUSv3.
16 */ 16 */
17 17
18//usage:#define id_trivial_usage
19//usage: "[OPTIONS] [USER]"
20//usage:#define id_full_usage "\n\n"
21//usage: "Print information about USER or the current user\n"
22//usage: "\nOptions:"
23//usage: IF_SELINUX(
24//usage: "\n -Z Security context"
25//usage: )
26//usage: "\n -u User ID"
27//usage: "\n -g Group ID"
28//usage: "\n -G Supplementary group IDs"
29//usage: "\n -n Print names instead of numbers"
30//usage: "\n -r Print real ID instead of effective ID"
31//usage:
32//usage:#define id_example_usage
33//usage: "$ id\n"
34//usage: "uid=1000(andersen) gid=1000(andersen)\n"
35
18#include "libbb.h" 36#include "libbb.h"
19 37
20/* This is a NOEXEC applet. Be very careful! */ 38/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/install.c b/coreutils/install.c
index 9dc90d641..fe5f26e79 100644
--- a/coreutils/install.c
+++ b/coreutils/install.c
@@ -6,6 +6,24 @@
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 8
9/* -v, -b, -c are ignored */
10//usage:#define install_trivial_usage
11//usage: "[-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST"
12//usage:#define install_full_usage "\n\n"
13//usage: "Copy files and set attributes\n"
14//usage: "\nOptions:"
15//usage: "\n -c Just copy (default)"
16//usage: "\n -d Create directories"
17//usage: "\n -D Create leading target directories"
18//usage: "\n -s Strip symbol table"
19//usage: "\n -p Preserve date"
20//usage: "\n -o USER Set ownership"
21//usage: "\n -g GRP Set group ownership"
22//usage: "\n -m MODE Set permissions"
23//usage: IF_SELINUX(
24//usage: "\n -Z Set security context"
25//usage: )
26
9#include "libbb.h" 27#include "libbb.h"
10#include "libcoreutils/coreutils.h" 28#include "libcoreutils/coreutils.h"
11 29
diff --git a/coreutils/length.c.disabled b/coreutils/length.c.disabled
index 7f0b48ccd..aee898d22 100644
--- a/coreutils/length.c.disabled
+++ b/coreutils/length.c.disabled
@@ -5,6 +5,15 @@
5 5
6/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */ 6/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
7 7
8//usage:#define length_trivial_usage
9//usage: "STRING"
10//usage:#define length_full_usage "\n\n"
11//usage: "Print STRING's length"
12//usage:
13//usage:#define length_example_usage
14//usage: "$ length Hello\n"
15//usage: "5\n"
16
8#include "libbb.h" 17#include "libbb.h"
9 18
10/* This is a NOFORK applet. Be very careful! */ 19/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 6da290c11..2da915a68 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -11,6 +11,22 @@
11/* BB_AUDIT GNU options missing: -d, -F, -i, and -v. */ 11/* BB_AUDIT GNU options missing: -d, -F, -i, and -v. */
12/* http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html */ 12/* http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html */
13 13
14//usage:#define ln_trivial_usage
15//usage: "[OPTIONS] TARGET... LINK|DIR"
16//usage:#define ln_full_usage "\n\n"
17//usage: "Create a link LINK or DIR/TARGET to the specified TARGET(s)\n"
18//usage: "\nOptions:"
19//usage: "\n -s Make symlinks instead of hardlinks"
20//usage: "\n -f Remove existing destinations"
21//usage: "\n -n Don't dereference symlinks - treat like normal file"
22//usage: "\n -b Make a backup of the target (if exists) before link operation"
23//usage: "\n -S suf Use suffix instead of ~ when making backup files"
24//usage:
25//usage:#define ln_example_usage
26//usage: "$ ln -s BusyBox /tmp/ls\n"
27//usage: "$ ls -l /tmp/ls\n"
28//usage: "lrwxrwxrwx 1 root root 7 Apr 12 18:39 ls -> BusyBox*\n"
29
14#include "libbb.h" 30#include "libbb.h"
15 31
16/* This is a NOEXEC applet. Be very careful! */ 32/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/logname.c b/coreutils/logname.c
index 62f453f2f..10b9615a1 100644
--- a/coreutils/logname.c
+++ b/coreutils/logname.c
@@ -20,6 +20,15 @@
20 * a diagnostic message and an error return. 20 * a diagnostic message and an error return.
21 */ 21 */
22 22
23//usage:#define logname_trivial_usage
24//usage: ""
25//usage:#define logname_full_usage "\n\n"
26//usage: "Print the name of the current user"
27//usage:
28//usage:#define logname_example_usage
29//usage: "$ logname\n"
30//usage: "root\n"
31
23#include "libbb.h" 32#include "libbb.h"
24 33
25/* This is a NOFORK applet. Be very careful! */ 34/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 4a41db76a..09b9f101a 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -43,9 +43,9 @@
43//usage:#define ls_full_usage "\n\n" 43//usage:#define ls_full_usage "\n\n"
44//usage: "List directory contents\n" 44//usage: "List directory contents\n"
45//usage: "\nOptions:" 45//usage: "\nOptions:"
46//usage: "\n -1 List in a single column" 46//usage: "\n -1 One column output"
47//usage: "\n -A Don't list . and .." 47//usage: "\n -a Include entries which start with ."
48//usage: "\n -a Don't hide entries starting with ." 48//usage: "\n -A Like -a, but exclude . and .."
49//usage: "\n -C List by columns" 49//usage: "\n -C List by columns"
50//usage: "\n -x List by lines" 50//usage: "\n -x List by lines"
51//usage: "\n -d List directory entries instead of contents" 51//usage: "\n -d List directory entries instead of contents"
@@ -63,7 +63,7 @@
63//usage: "\n -l Long listing format" 63//usage: "\n -l Long listing format"
64//usage: "\n -i List inode numbers" 64//usage: "\n -i List inode numbers"
65//usage: "\n -n List numeric UIDs and GIDs instead of names" 65//usage: "\n -n List numeric UIDs and GIDs instead of names"
66//usage: "\n -s List the size of each file, in blocks" 66//usage: "\n -s List allocated blocks"
67//usage: IF_FEATURE_LS_TIMESTAMPS( 67//usage: IF_FEATURE_LS_TIMESTAMPS(
68//usage: "\n -e List full date and time" 68//usage: "\n -e List full date and time"
69//usage: ) 69//usage: )
@@ -72,14 +72,14 @@
72//usage: ) 72//usage: )
73//usage: IF_FEATURE_LS_SORTFILES( 73//usage: IF_FEATURE_LS_SORTFILES(
74//usage: "\n -r Sort in reverse order" 74//usage: "\n -r Sort in reverse order"
75//usage: "\n -S Sort by file size" 75//usage: "\n -S Sort by size"
76//usage: "\n -X Sort by extension" 76//usage: "\n -X Sort by extension"
77//usage: "\n -v Sort by version" 77//usage: "\n -v Sort by version"
78//usage: ) 78//usage: )
79//usage: IF_FEATURE_LS_TIMESTAMPS( 79//usage: IF_FEATURE_LS_TIMESTAMPS(
80//usage: "\n -c With -l: sort by ctime" 80//usage: "\n -c With -l: sort by ctime"
81//usage: "\n -t With -l: sort by modification time" 81//usage: "\n -t With -l: sort by mtime"
82//usage: "\n -u With -l: sort by access time" 82//usage: "\n -u With -l: sort by atime"
83//usage: ) 83//usage: )
84//usage: IF_SELINUX( 84//usage: IF_SELINUX(
85//usage: "\n -k List security context" 85//usage: "\n -k List security context"
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c
index 3b897c18f..050d46701 100644
--- a/coreutils/md5_sha1_sum.c
+++ b/coreutils/md5_sha1_sum.c
@@ -6,6 +6,64 @@
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 8
9//usage:#define md5sum_trivial_usage
10//usage: "[FILE]..."
11//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: md5sum -c [-sw] [FILE]")
12//usage:#define md5sum_full_usage "\n\n"
13//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " MD5 checksums"
14//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
15//usage: "\nOptions:"
16//usage: "\n -c Check sums against given list"
17//usage: "\n -s Don't output anything, status code shows success"
18//usage: "\n -w Warn about improperly formatted checksum lines"
19//usage: )
20//usage:
21//usage:#define md5sum_example_usage
22//usage: "$ md5sum < busybox\n"
23//usage: "6fd11e98b98a58f64ff3398d7b324003\n"
24//usage: "$ md5sum busybox\n"
25//usage: "6fd11e98b98a58f64ff3398d7b324003 busybox\n"
26//usage: "$ md5sum -c -\n"
27//usage: "6fd11e98b98a58f64ff3398d7b324003 busybox\n"
28//usage: "busybox: OK\n"
29//usage: "^D\n"
30//usage:
31//usage:#define sha1sum_trivial_usage
32//usage: "[FILE]..."
33//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha1sum -c [-sw] [FILE]")
34//usage:#define sha1sum_full_usage "\n\n"
35//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA1 checksums"
36//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
37//usage: "\nOptions:"
38//usage: "\n -c Check sums against given list"
39//usage: "\n -s Don't output anything, status code shows success"
40//usage: "\n -w Warn about improperly formatted checksum lines"
41//usage: )
42//usage:
43//usage:#define sha256sum_trivial_usage
44//usage: "[FILE]..."
45//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha256sum -c [-sw] [FILE]")
46//usage:#define sha256sum_full_usage "\n\n"
47//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA256 checksums"
48//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
49//usage: "\nOptions:"
50//usage: "\n -c Check sums against given list"
51//usage: "\n -s Don't output anything, status code shows success"
52//usage: "\n -w Warn about improperly formatted checksum lines"
53//usage: )
54//usage:
55//usage:#define sha512sum_trivial_usage
56//usage: "[FILE]..."
57//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha512sum -c [-sw] [FILE]")
58//usage:#define sha512sum_full_usage "\n\n"
59//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA512 checksums"
60//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
61//usage: "\nOptions:"
62//usage: "\n -c Check sums against given list"
63//usage: "\n -s Don't output anything, status code shows success"
64//usage: "\n -w Warn about improperly formatted checksum lines"
65//usage: )
66
9#include "libbb.h" 67#include "libbb.h"
10 68
11/* This is a NOEXEC applet. Be very careful! */ 69/* This is a NOEXEC applet. Be very careful! */
@@ -42,7 +100,6 @@ static uint8_t *hash_file(const char *filename)
42 md5_ctx_t md5; 100 md5_ctx_t md5;
43 } context; 101 } context;
44 uint8_t *hash_value = NULL; 102 uint8_t *hash_value = NULL;
45 RESERVE_CONFIG_UBUFFER(in_buf, 4096);
46 void FAST_FUNC (*update)(void*, const void*, size_t); 103 void FAST_FUNC (*update)(void*, const void*, size_t);
47 void FAST_FUNC (*final)(void*, void*); 104 void FAST_FUNC (*final)(void*, void*);
48 char hash_algo; 105 char hash_algo;
@@ -54,7 +111,7 @@ static uint8_t *hash_file(const char *filename)
54 111
55 hash_algo = applet_name[3]; 112 hash_algo = applet_name[3];
56 113
57 /* figure specific hash algorithims */ 114 /* figure specific hash algorithms */
58 if (ENABLE_MD5SUM && hash_algo == HASH_MD5) { 115 if (ENABLE_MD5SUM && hash_algo == HASH_MD5) {
59 md5_begin(&context.md5); 116 md5_begin(&context.md5);
60 update = (void*)md5_hash; 117 update = (void*)md5_hash;
@@ -79,17 +136,18 @@ static uint8_t *hash_file(const char *filename)
79 xfunc_die(); /* can't reach this */ 136 xfunc_die(); /* can't reach this */
80 } 137 }
81 138
82 while ((count = safe_read(src_fd, in_buf, 4096)) > 0) { 139 {
83 update(&context, in_buf, count); 140 RESERVE_CONFIG_UBUFFER(in_buf, 4096);
84 } 141 while ((count = safe_read(src_fd, in_buf, 4096)) > 0) {
85 142 update(&context, in_buf, count);
86 if (count == 0) { 143 }
87 final(&context, in_buf); 144 if (count == 0) {
88 hash_value = hash_bin_to_hex(in_buf, hash_len); 145 final(&context, in_buf);
146 hash_value = hash_bin_to_hex(in_buf, hash_len);
147 }
148 RELEASE_CONFIG_BUFFER(in_buf);
89 } 149 }
90 150
91 RELEASE_CONFIG_BUFFER(in_buf);
92
93 if (src_fd != STDIN_FILENO) { 151 if (src_fd != STDIN_FILENO) {
94 close(src_fd); 152 close(src_fd);
95 } 153 }
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 0de0d5c3b..e425bbe5e 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -19,6 +19,25 @@
19/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support. 19/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
20 */ 20 */
21 21
22//usage:#define mkdir_trivial_usage
23//usage: "[OPTIONS] DIRECTORY..."
24//usage:#define mkdir_full_usage "\n\n"
25//usage: "Create DIRECTORY\n"
26//usage: "\nOptions:"
27//usage: "\n -m MODE Mode"
28//usage: "\n -p No error if exists; make parent directories as needed"
29//usage: IF_SELINUX(
30//usage: "\n -Z Set security context"
31//usage: )
32//usage:
33//usage:#define mkdir_example_usage
34//usage: "$ mkdir /tmp/foo\n"
35//usage: "$ mkdir /tmp/foo\n"
36//usage: "/tmp/foo: File exists\n"
37//usage: "$ mkdir /tmp/foo/bar/baz\n"
38//usage: "/tmp/foo/bar/baz: No such file or directory\n"
39//usage: "$ mkdir -p /tmp/foo/bar/baz\n"
40
22#include "libbb.h" 41#include "libbb.h"
23 42
24/* This is a NOFORK applet. Be very careful! */ 43/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c
index d908ce45e..84d8d99dd 100644
--- a/coreutils/mkfifo.c
+++ b/coreutils/mkfifo.c
@@ -10,6 +10,16 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
12 12
13//usage:#define mkfifo_trivial_usage
14//usage: "[-m MODE] " IF_SELINUX("[-Z] ") "NAME"
15//usage:#define mkfifo_full_usage "\n\n"
16//usage: "Create named pipe\n"
17//usage: "\nOptions:"
18//usage: "\n -m MODE Mode (default a=rw)"
19//usage: IF_SELINUX(
20//usage: "\n -Z Set security context"
21//usage: )
22
13#include "libbb.h" 23#include "libbb.h"
14#include "libcoreutils/coreutils.h" 24#include "libcoreutils/coreutils.h"
15 25
diff --git a/coreutils/mknod.c b/coreutils/mknod.c
index 14d91b5df..50dbd62e3 100644
--- a/coreutils/mknod.c
+++ b/coreutils/mknod.c
@@ -9,6 +9,24 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12//usage:#define mknod_trivial_usage
13//usage: "[-m MODE] " IF_SELINUX("[-Z] ") "NAME TYPE MAJOR MINOR"
14//usage:#define mknod_full_usage "\n\n"
15//usage: "Create a special file (block, character, or pipe)\n"
16//usage: "\nOptions:"
17//usage: "\n -m MODE Creation mode (default a=rw)"
18//usage: IF_SELINUX(
19//usage: "\n -Z Set security context"
20//usage: )
21//usage: "\nTYPE:"
22//usage: "\n b Block device"
23//usage: "\n c or u Character device"
24//usage: "\n p Named pipe (MAJOR and MINOR are ignored)"
25//usage:
26//usage:#define mknod_example_usage
27//usage: "$ mknod /dev/fd0 b 2 0\n"
28//usage: "$ mknod -m 644 /tmp/pipe p\n"
29
12#include <sys/sysmacros.h> // For makedev 30#include <sys/sysmacros.h> // For makedev
13 31
14#include "libbb.h" 32#include "libbb.h"
diff --git a/coreutils/nice.c b/coreutils/nice.c
index 35d6bf3d9..2763986e7 100644
--- a/coreutils/nice.c
+++ b/coreutils/nice.c
@@ -7,6 +7,13 @@
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 9
10//usage:#define nice_trivial_usage
11//usage: "[-n ADJUST] [PROG ARGS]"
12//usage:#define nice_full_usage "\n\n"
13//usage: "Change scheduling priority, run PROG\n"
14//usage: "\nOptions:"
15//usage: "\n -n ADJUST Adjust priority by ADJUST"
16
10#include <sys/resource.h> 17#include <sys/resource.h>
11#include "libbb.h" 18#include "libbb.h"
12 19
diff --git a/coreutils/nohup.c b/coreutils/nohup.c
index c21aae9f5..63853fd55 100644
--- a/coreutils/nohup.c
+++ b/coreutils/nohup.c
@@ -10,6 +10,14 @@
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 12
13//usage:#define nohup_trivial_usage
14//usage: "PROG ARGS"
15//usage:#define nohup_full_usage "\n\n"
16//usage: "Run PROG immune to hangups, with output to a non-tty"
17//usage:
18//usage:#define nohup_example_usage
19//usage: "$ nohup make &"
20
13#include "libbb.h" 21#include "libbb.h"
14 22
15/* Compat info: nohup (GNU coreutils 6.8) does this: 23/* Compat info: nohup (GNU coreutils 6.8) does this:
diff --git a/coreutils/od.c b/coreutils/od.c
index e62711671..31ebde210 100644
--- a/coreutils/od.c
+++ b/coreutils/od.c
@@ -11,6 +11,11 @@
11 * Original copyright notice is retained at the end of this file. 11 * Original copyright notice is retained at the end of this file.
12 */ 12 */
13 13
14//usage:#define od_trivial_usage
15//usage: "[-aBbcDdeFfHhIiLlOovXx] " IF_DESKTOP("[-t TYPE] ") "[FILE]"
16//usage:#define od_full_usage "\n\n"
17//usage: "Write an unambiguous representation, octal bytes by default, of FILE\n"
18//usage: "(or stdin) to stdout"
14 19
15#include "libbb.h" 20#include "libbb.h"
16#if ENABLE_DESKTOP 21#if ENABLE_DESKTOP
diff --git a/coreutils/printenv.c b/coreutils/printenv.c
index d0fb71636..bd5db7073 100644
--- a/coreutils/printenv.c
+++ b/coreutils/printenv.c
@@ -8,6 +8,12 @@
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 10
11//usage:#define printenv_trivial_usage
12//usage: "[VARIABLE]..."
13//usage:#define printenv_full_usage "\n\n"
14//usage: "Print environment VARIABLEs.\n"
15//usage: "If no VARIABLE specified, print all."
16
11#include "libbb.h" 17#include "libbb.h"
12 18
13/* This is a NOFORK applet. Be very careful! */ 19/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/printf.c b/coreutils/printf.c
index c8395fa89..f53aa4787 100644
--- a/coreutils/printf.c
+++ b/coreutils/printf.c
@@ -38,6 +38,16 @@
38 38
39// 19990508 Busy Boxed! Dave Cinege 39// 19990508 Busy Boxed! Dave Cinege
40 40
41//usage:#define printf_trivial_usage
42//usage: "FORMAT [ARGUMENT]..."
43//usage:#define printf_full_usage "\n\n"
44//usage: "Format and print ARGUMENT(s) according to FORMAT,\n"
45//usage: "where FORMAT controls the output exactly as in C printf"
46//usage:
47//usage:#define printf_example_usage
48//usage: "$ printf \"Val=%d\\n\" 5\n"
49//usage: "Val=5\n"
50
41#include "libbb.h" 51#include "libbb.h"
42 52
43/* A note on bad input: neither bash 3.2 nor coreutils 6.10 stop on it. 53/* A note on bad input: neither bash 3.2 nor coreutils 6.10 stop on it.
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index 2949c55c2..739b835b5 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -7,6 +7,15 @@
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 9
10//usage:#define pwd_trivial_usage
11//usage: ""
12//usage:#define pwd_full_usage "\n\n"
13//usage: "Print the full filename of the current working directory"
14//usage:
15//usage:#define pwd_example_usage
16//usage: "$ pwd\n"
17//usage: "/root\n"
18
10#include "libbb.h" 19#include "libbb.h"
11 20
12/* This is a NOFORK applet. Be very careful! */ 21/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/readlink.c b/coreutils/readlink.c
index 87602fbc6..1a0eca646 100644
--- a/coreutils/readlink.c
+++ b/coreutils/readlink.c
@@ -6,6 +6,18 @@
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//usage:#define readlink_trivial_usage
11//usage: IF_FEATURE_READLINK_FOLLOW("[-fnv] ") "FILE"
12//usage:#define readlink_full_usage "\n\n"
13//usage: "Display the value of a symlink"
14//usage: IF_FEATURE_READLINK_FOLLOW( "\n"
15//usage: "\nOptions:"
16//usage: "\n -f Canonicalize by following all symlinks"
17//usage: "\n -n Don't add newline"
18//usage: "\n -v Verbose"
19//usage: )
20
9#include "libbb.h" 21#include "libbb.h"
10 22
11/* 23/*
diff --git a/coreutils/realpath.c b/coreutils/realpath.c
index 5933062b8..c513b5549 100644
--- a/coreutils/realpath.c
+++ b/coreutils/realpath.c
@@ -10,6 +10,11 @@
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 12
13//usage:#define realpath_trivial_usage
14//usage: "FILE..."
15//usage:#define realpath_full_usage "\n\n"
16//usage: "Return the absolute pathnames of given FILE"
17
13#include "libbb.h" 18#include "libbb.h"
14 19
15int realpath_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20int realpath_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 69c473ddb..8efd895cc 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -15,6 +15,18 @@
15 * Size reduction. 15 * Size reduction.
16 */ 16 */
17 17
18//usage:#define rm_trivial_usage
19//usage: "[-irf] FILE..."
20//usage:#define rm_full_usage "\n\n"
21//usage: "Remove (unlink) FILEs\n"
22//usage: "\nOptions:"
23//usage: "\n -i Always prompt before removing"
24//usage: "\n -f Never prompt"
25//usage: "\n -R,-r Recurse"
26//usage:
27//usage:#define rm_example_usage
28//usage: "$ rm -rf /tmp/foo\n"
29
18#include "libbb.h" 30#include "libbb.h"
19 31
20/* This is a NOFORK applet. Be very careful! */ 32/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index 231793ce0..0dbd940a1 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -10,6 +10,22 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
12 12
13//usage:#define rmdir_trivial_usage
14//usage: "[OPTIONS] DIRECTORY..."
15//usage:#define rmdir_full_usage "\n\n"
16//usage: "Remove DIRECTORY if it is empty\n"
17//usage: "\nOptions:"
18//usage: IF_FEATURE_RMDIR_LONG_OPTIONS(
19//usage: "\n -p|--parents Include parents"
20//usage: "\n --ignore-fail-on-non-empty"
21//usage: )
22//usage: IF_NOT_FEATURE_RMDIR_LONG_OPTIONS(
23//usage: "\n -p Include parents"
24//usage: )
25//usage:
26//usage:#define rmdir_example_usage
27//usage: "# rmdir /tmp/foo\n"
28
13#include "libbb.h" 29#include "libbb.h"
14 30
15/* This is a NOFORK applet. Be very careful! */ 31/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/seq.c b/coreutils/seq.c
index 22bf3ec9d..b600266fd 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -6,6 +6,16 @@
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//usage:#define seq_trivial_usage
11//usage: "[-w] [-s SEP] [FIRST [INC]] LAST"
12//usage:#define seq_full_usage "\n\n"
13//usage: "Print numbers from FIRST to LAST, in steps of INC.\n"
14//usage: "FIRST, INC default to 1.\n"
15//usage: "\nOptions:"
16//usage: "\n -w Pad to last with leading zeros"
17//usage: "\n -s SEP String separator"
18
9#include "libbb.h" 19#include "libbb.h"
10 20
11/* This is a NOFORK applet. Be very careful! */ 21/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 433f9d6ee..0ffbd16eb 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -18,6 +18,21 @@
18 * time suffixes for seconds, minutes, hours, and days. 18 * time suffixes for seconds, minutes, hours, and days.
19 */ 19 */
20 20
21//usage:#define sleep_trivial_usage
22//usage: IF_FEATURE_FANCY_SLEEP("[") "N" IF_FEATURE_FANCY_SLEEP("]...")
23//usage:#define sleep_full_usage "\n\n"
24//usage: IF_NOT_FEATURE_FANCY_SLEEP("Pause for N seconds")
25//usage: IF_FEATURE_FANCY_SLEEP(
26//usage: "Pause for a time equal to the total of the args given, where each arg can\n"
27//usage: "have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays")
28//usage:
29//usage:#define sleep_example_usage
30//usage: "$ sleep 2\n"
31//usage: "[2 second delay results]\n"
32//usage: IF_FEATURE_FANCY_SLEEP(
33//usage: "$ sleep 1d 3h 22m 8s\n"
34//usage: "[98528 second delay results]\n")
35
21#include "libbb.h" 36#include "libbb.h"
22 37
23/* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells */ 38/* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells */
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 3562464d1..f709ea1b3 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -12,6 +12,54 @@
12 * http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html 12 * http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
13 */ 13 */
14 14
15//usage:#define sort_trivial_usage
16//usage: "[-nru"
17//usage: IF_FEATURE_SORT_BIG("gMcszbdfimSTokt] [-o FILE] [-k start[.offset][opts][,end[.offset][opts]] [-t CHAR")
18//usage: "] [FILE]..."
19//usage:#define sort_full_usage "\n\n"
20//usage: "Sort lines of text\n"
21//usage: "\nOptions:"
22//usage: IF_FEATURE_SORT_BIG(
23//usage: "\n -b Ignore leading blanks"
24//usage: "\n -c Check whether input is sorted"
25//usage: "\n -d Dictionary order (blank or alphanumeric only)"
26//usage: "\n -f Ignore case"
27//usage: "\n -g General numerical sort"
28//usage: "\n -i Ignore unprintable characters"
29//usage: "\n -k Sort key"
30//usage: "\n -M Sort month"
31//usage: )
32//usage: "\n -n Sort numbers"
33//usage: IF_FEATURE_SORT_BIG(
34//usage: "\n -o Output to file"
35//usage: "\n -k Sort by key"
36//usage: "\n -t CHAR Key separator"
37//usage: )
38//usage: "\n -r Reverse sort order"
39//usage: IF_FEATURE_SORT_BIG(
40//usage: "\n -s Stable (don't sort ties alphabetically)"
41//usage: )
42//usage: "\n -u Suppress duplicate lines"
43//usage: IF_FEATURE_SORT_BIG(
44//usage: "\n -z Lines are terminated by NUL, not newline"
45//usage: "\n -mST Ignored for GNU compatibility")
46//usage:
47//usage:#define sort_example_usage
48//usage: "$ echo -e \"e\\nf\\nb\\nd\\nc\\na\" | sort\n"
49//usage: "a\n"
50//usage: "b\n"
51//usage: "c\n"
52//usage: "d\n"
53//usage: "e\n"
54//usage: "f\n"
55//usage: IF_FEATURE_SORT_BIG(
56//usage: "$ echo -e \"c 3\\nb 2\\nd 2\" | $SORT -k 2,2n -k 1,1r\n"
57//usage: "d 2\n"
58//usage: "b 2\n"
59//usage: "c 3\n"
60//usage: )
61//usage: ""
62
15#include "libbb.h" 63#include "libbb.h"
16 64
17/* This is a NOEXEC applet. Be very careful! */ 65/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/split.c b/coreutils/split.c
index 79316ed74..f0077077e 100644
--- a/coreutils/split.c
+++ b/coreutils/split.c
@@ -9,6 +9,19 @@
9 * SUSv3 requirements: 9 * SUSv3 requirements:
10 * http://www.opengroup.org/onlinepubs/009695399/utilities/split.html 10 * http://www.opengroup.org/onlinepubs/009695399/utilities/split.html
11 */ 11 */
12
13//usage:#define split_trivial_usage
14//usage: "[OPTIONS] [INPUT [PREFIX]]"
15//usage:#define split_full_usage "\n\n"
16//usage: "Options:"
17//usage: "\n -b N[k|m] Split by N (kilo|mega)bytes"
18//usage: "\n -l N Split by N lines"
19//usage: "\n -a N Use N letters as suffix"
20//usage:
21//usage:#define split_example_usage
22//usage: "$ split TODO foo\n"
23//usage: "$ cat TODO | split -a 2 -l 2 TODO_\n"
24
12#include "libbb.h" 25#include "libbb.h"
13 26
14static const struct suffix_mult split_suffices[] = { 27static const struct suffix_mult split_suffices[] = {
diff --git a/coreutils/stat.c b/coreutils/stat.c
index 7351f5956..e85e51033 100644
--- a/coreutils/stat.c
+++ b/coreutils/stat.c
@@ -12,6 +12,67 @@
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//usage:#define stat_trivial_usage
17//usage: "[OPTIONS] FILE..."
18//usage:#define stat_full_usage "\n\n"
19//usage: "Display file (default) or filesystem status\n"
20//usage: "\nOptions:"
21//usage: IF_FEATURE_STAT_FORMAT(
22//usage: "\n -c fmt Use the specified format"
23//usage: )
24//usage: "\n -f Display filesystem status"
25//usage: "\n -L Follow links"
26//usage: "\n -t Display info in terse form"
27//usage: IF_SELINUX(
28//usage: "\n -Z Print security context"
29//usage: )
30//usage: IF_FEATURE_STAT_FORMAT(
31//usage: "\n\nValid format sequences for files:\n"
32//usage: " %a Access rights in octal\n"
33//usage: " %A Access rights in human readable form\n"
34//usage: " %b Number of blocks allocated (see %B)\n"
35//usage: " %B The size in bytes of each block reported by %b\n"
36//usage: " %d Device number in decimal\n"
37//usage: " %D Device number in hex\n"
38//usage: " %f Raw mode in hex\n"
39//usage: " %F File type\n"
40//usage: " %g Group ID of owner\n"
41//usage: " %G Group name of owner\n"
42//usage: " %h Number of hard links\n"
43//usage: " %i Inode number\n"
44//usage: " %n File name\n"
45//usage: " %N File name, with -> TARGET if symlink\n"
46//usage: " %o I/O block size\n"
47//usage: " %s Total size, in bytes\n"
48//usage: " %t Major device type in hex\n"
49//usage: " %T Minor device type in hex\n"
50//usage: " %u User ID of owner\n"
51//usage: " %U User name of owner\n"
52//usage: " %x Time of last access\n"
53//usage: " %X Time of last access as seconds since Epoch\n"
54//usage: " %y Time of last modification\n"
55//usage: " %Y Time of last modification as seconds since Epoch\n"
56//usage: " %z Time of last change\n"
57//usage: " %Z Time of last change as seconds since Epoch\n"
58//usage: "\nValid format sequences for file systems:\n"
59//usage: " %a Free blocks available to non-superuser\n"
60//usage: " %b Total data blocks in file system\n"
61//usage: " %c Total file nodes in file system\n"
62//usage: " %d Free file nodes in file system\n"
63//usage: " %f Free blocks in file system\n"
64//usage: IF_SELINUX(
65//usage: " %C Security context in selinux\n"
66//usage: )
67//usage: " %i File System ID in hex\n"
68//usage: " %l Maximum length of filenames\n"
69//usage: " %n File name\n"
70//usage: " %s Block size (for faster transfer)\n"
71//usage: " %S Fundamental block size (for block counts)\n"
72//usage: " %t Type in hex\n"
73//usage: " %T Type in human readable form"
74//usage: )
75
15#include "libbb.h" 76#include "libbb.h"
16 77
17#define OPT_FILESYS (1 << 0) 78#define OPT_FILESYS (1 << 0)
diff --git a/coreutils/stty.c b/coreutils/stty.c
index d8184a34f..af2347161 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -21,6 +21,17 @@
21 21
22 */ 22 */
23 23
24//usage:#define stty_trivial_usage
25//usage: "[-a|g] [-F DEVICE] [SETTING]..."
26//usage:#define stty_full_usage "\n\n"
27//usage: "Without arguments, prints baud rate, line discipline,\n"
28//usage: "and deviations from stty sane\n"
29//usage: "\nOptions:"
30//usage: "\n -F DEVICE Open device instead of stdin"
31//usage: "\n -a Print all current settings in human-readable form"
32//usage: "\n -g Print in stty-readable form"
33//usage: "\n [SETTING] See manpage"
34
24#include "libbb.h" 35#include "libbb.h"
25 36
26#ifndef _POSIX_VDISABLE 37#ifndef _POSIX_VDISABLE
diff --git a/coreutils/sum.c b/coreutils/sum.c
index e087fb85b..9e6b0c5b1 100644
--- a/coreutils/sum.c
+++ b/coreutils/sum.c
@@ -13,6 +13,14 @@
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 15
16//usage:#define sum_trivial_usage
17//usage: "[-rs] [FILE]..."
18//usage:#define sum_full_usage "\n\n"
19//usage: "Checksum and count the blocks in a file\n"
20//usage: "\nOptions:"
21//usage: "\n -r Use BSD sum algorithm (1K blocks)"
22//usage: "\n -s Use System V sum algorithm (512byte blocks)"
23
16#include "libbb.h" 24#include "libbb.h"
17 25
18enum { SUM_BSD, PRINT_NAME, SUM_SYSV }; 26enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
diff --git a/coreutils/sync.c b/coreutils/sync.c
index bb112ea38..7d98a1e30 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -9,6 +9,11 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12//usage:#define sync_trivial_usage
13//usage: ""
14//usage:#define sync_full_usage "\n\n"
15//usage: "Write all buffered blocks to disk"
16
12#include "libbb.h" 17#include "libbb.h"
13 18
14/* This is a NOFORK applet. Be very careful! */ 19/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/tac.c b/coreutils/tac.c
index ab3e66ac2..94d669de1 100644
--- a/coreutils/tac.c
+++ b/coreutils/tac.c
@@ -16,6 +16,11 @@
16 * http://www.uclibc.org/lists/busybox/2003-July/008813.html 16 * http://www.uclibc.org/lists/busybox/2003-July/008813.html
17 */ 17 */
18 18
19//usage:#define tac_trivial_usage
20//usage: "[FILE]..."
21//usage:#define tac_full_usage "\n\n"
22//usage: "Concatenate FILEs and print them in reverse"
23
19#include "libbb.h" 24#include "libbb.h"
20 25
21/* This is a NOEXEC applet. Be very careful! */ 26/* This is a NOEXEC applet. Be very careful! */
diff --git a/coreutils/tail.c b/coreutils/tail.c
index df881a37a..eac982735 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -24,6 +24,31 @@
24 * 7) lseek attempted when count==0 even if arg was +0 (from top) 24 * 7) lseek attempted when count==0 even if arg was +0 (from top)
25 */ 25 */
26 26
27//usage:#define tail_trivial_usage
28//usage: "[OPTIONS] [FILE]..."
29//usage:#define tail_full_usage "\n\n"
30//usage: "Print last 10 lines of each FILE (or stdin) to stdout.\n"
31//usage: "With more than one FILE, precede each with a filename header.\n"
32//usage: "\nOptions:"
33//usage: "\n -f Print data as file grows"
34//usage: IF_FEATURE_FANCY_TAIL(
35//usage: "\n -s SECONDS Wait SECONDS between reads with -f"
36//usage: )
37//usage: "\n -n N[kbm] Print last N lines"
38//usage: IF_FEATURE_FANCY_TAIL(
39//usage: "\n -c N[kbm] Print last N bytes"
40//usage: "\n -q Never print headers"
41//usage: "\n -v Always print headers"
42//usage: "\n"
43//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)."
44//usage: "\nIf N starts with a '+', output begins with the Nth item from the start"
45//usage: "\nof each file, not from the end."
46//usage: )
47//usage:
48//usage:#define tail_example_usage
49//usage: "$ tail -n 1 /etc/resolv.conf\n"
50//usage: "nameserver 10.0.0.1\n"
51
27#include "libbb.h" 52#include "libbb.h"
28 53
29static const struct suffix_mult tail_suffixes[] = { 54static const struct suffix_mult tail_suffixes[] = {
diff --git a/coreutils/tee.c b/coreutils/tee.c
index e66e885ec..3e3164e70 100644
--- a/coreutils/tee.c
+++ b/coreutils/tee.c
@@ -10,6 +10,19 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/tee.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/tee.html */
12 12
13//usage:#define tee_trivial_usage
14//usage: "[-ai] [FILE]..."
15//usage:#define tee_full_usage "\n\n"
16//usage: "Copy stdin to each FILE, and also to stdout\n"
17//usage: "\nOptions:"
18//usage: "\n -a Append to the given FILEs, don't overwrite"
19//usage: "\n -i Ignore interrupt signals (SIGINT)"
20//usage:
21//usage:#define tee_example_usage
22//usage: "$ echo \"Hello\" | tee /tmp/foo\n"
23//usage: "$ cat /tmp/foo\n"
24//usage: "Hello\n"
25
13#include "libbb.h" 26#include "libbb.h"
14 27
15int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/test.c b/coreutils/test.c
index cb15ed725..2e896f4c7 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -39,6 +39,29 @@
39//config: help 39//config: help
40//config: Enable 64-bit support in test. 40//config: Enable 64-bit support in test.
41 41
42/* "test --help" does not print help (POSIX compat), only "[ --help" does.
43 * We display "<applet> EXPRESSION ]" here (not "<applet> EXPRESSION")
44 * Unfortunately, it screws up generated BusyBox.html. TODO. */
45//usage:#define test_trivial_usage
46//usage: "EXPRESSION ]"
47//usage:#define test_full_usage "\n\n"
48//usage: "Check file types, compare values etc. Return a 0/1 exit code\n"
49//usage: "depending on logical value of EXPRESSION"
50//usage:
51//usage:#define test_example_usage
52//usage: "$ test 1 -eq 2\n"
53//usage: "$ echo $?\n"
54//usage: "1\n"
55//usage: "$ test 1 -eq 1\n"
56//usage: "$ echo $?\n"
57//usage: "0\n"
58//usage: "$ [ -d /etc ]\n"
59//usage: "$ echo $?\n"
60//usage: "0\n"
61//usage: "$ [ -d /junk ]\n"
62//usage: "$ echo $?\n"
63//usage: "1\n"
64
42#include "libbb.h" 65#include "libbb.h"
43#include <setjmp.h> 66#include <setjmp.h>
44 67
diff --git a/coreutils/tr.c b/coreutils/tr.c
index 5b2b9a9a4..2f14a414f 100644
--- a/coreutils/tr.c
+++ b/coreutils/tr.c
@@ -47,6 +47,19 @@
47//config: useful for cases when no other way of expressing a character 47//config: useful for cases when no other way of expressing a character
48//config: is possible. 48//config: is possible.
49 49
50//usage:#define tr_trivial_usage
51//usage: "[-cds] STRING1 [STRING2]"
52//usage:#define tr_full_usage "\n\n"
53//usage: "Translate, squeeze, or delete characters from stdin, writing to stdout\n"
54//usage: "\nOptions:"
55//usage: "\n -c Take complement of STRING1"
56//usage: "\n -d Delete input characters coded STRING1"
57//usage: "\n -s Squeeze multiple output characters of STRING2 into one character"
58//usage:
59//usage:#define tr_example_usage
60//usage: "$ echo \"gdkkn vnqkc\" | tr [a-y] [b-z]\n"
61//usage: "hello world\n"
62
50#include "libbb.h" 63#include "libbb.h"
51 64
52enum { 65enum {
diff --git a/coreutils/true.c b/coreutils/true.c
index 0a862ef18..382e476a8 100644
--- a/coreutils/true.c
+++ b/coreutils/true.c
@@ -10,6 +10,16 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */
12 12
13//usage:#define true_trivial_usage
14//usage: ""
15//usage:#define true_full_usage "\n\n"
16//usage: "Return an exit code of TRUE (0)"
17//usage:
18//usage:#define true_example_usage
19//usage: "$ true\n"
20//usage: "$ echo $?\n"
21//usage: "0\n"
22
13#include "libbb.h" 23#include "libbb.h"
14 24
15/* This is a NOFORK applet. Be very careful! */ 25/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/tty.c b/coreutils/tty.c
index 282d9680f..67399cbf3 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -10,6 +10,19 @@
10/* BB_AUDIT SUSv4 compliant */ 10/* BB_AUDIT SUSv4 compliant */
11/* http://www.opengroup.org/onlinepubs/9699919799/utilities/tty.html */ 11/* http://www.opengroup.org/onlinepubs/9699919799/utilities/tty.html */
12 12
13//usage:#define tty_trivial_usage
14//usage: ""
15//usage:#define tty_full_usage "\n\n"
16//usage: "Print file name of stdin's terminal"
17//usage: IF_INCLUDE_SUSv2( "\n"
18//usage: "\nOptions:"
19//usage: "\n -s Print nothing, only return exit status"
20//usage: )
21//usage:
22//usage:#define tty_example_usage
23//usage: "$ tty\n"
24//usage: "/dev/tty2\n"
25
13#include "libbb.h" 26#include "libbb.h"
14 27
15int tty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int tty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/uname.c b/coreutils/uname.c
index c259b1771..775c450df 100644
--- a/coreutils/uname.c
+++ b/coreutils/uname.c
@@ -48,6 +48,23 @@
48 * Fix handling of -a to not print "unknown", add -o and -i support. 48 * Fix handling of -a to not print "unknown", add -o and -i support.
49 */ 49 */
50 50
51//usage:#define uname_trivial_usage
52//usage: "[-amnrspv]"
53//usage:#define uname_full_usage "\n\n"
54//usage: "Print system information\n"
55//usage: "\nOptions:"
56//usage: "\n -a Print all"
57//usage: "\n -m The machine (hardware) type"
58//usage: "\n -n Hostname"
59//usage: "\n -r OS release"
60//usage: "\n -s OS name (default)"
61//usage: "\n -p Processor type"
62//usage: "\n -v OS version"
63//usage:
64//usage:#define uname_example_usage
65//usage: "$ uname -a\n"
66//usage: "Linux debian 2.4.23 #2 Tue Dec 23 17:09:10 MST 2003 i686 GNU/Linux\n"
67
51#include "libbb.h" 68#include "libbb.h"
52/* After libbb.h, since it needs sys/types.h on some systems */ 69/* After libbb.h, since it needs sys/types.h on some systems */
53#include <sys/utsname.h> 70#include <sys/utsname.h>
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index decf7e4f8..6e764d8a4 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -10,6 +10,24 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/uniq.html */
12 12
13//usage:#define uniq_trivial_usage
14//usage: "[-cdu][-f,s,w N] [INPUT [OUTPUT]]"
15//usage:#define uniq_full_usage "\n\n"
16//usage: "Discard duplicate lines\n"
17//usage: "\nOptions:"
18//usage: "\n -c Prefix lines by the number of occurrences"
19//usage: "\n -d Only print duplicate lines"
20//usage: "\n -u Only print unique lines"
21//usage: "\n -f N Skip first N fields"
22//usage: "\n -s N Skip first N chars (after any skipped fields)"
23//usage: "\n -w N Compare N characters in line"
24//usage:
25//usage:#define uniq_example_usage
26//usage: "$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n"
27//usage: "a\n"
28//usage: "b\n"
29//usage: "c\n"
30
13#include "libbb.h" 31#include "libbb.h"
14 32
15int uniq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 33int uniq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/coreutils/usleep.c b/coreutils/usleep.c
index cb4ec5898..67f94f798 100644
--- a/coreutils/usleep.c
+++ b/coreutils/usleep.c
@@ -9,6 +9,15 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */ 10/* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
11 11
12//usage:#define usleep_trivial_usage
13//usage: "N"
14//usage:#define usleep_full_usage "\n\n"
15//usage: "Pause for N microseconds"
16//usage:
17//usage:#define usleep_example_usage
18//usage: "$ usleep 1000000\n"
19//usage: "[pauses for 1 second]\n"
20
12#include "libbb.h" 21#include "libbb.h"
13 22
14/* This is a NOFORK applet. Be very careful! */ 23/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 56ed254e5..47a155ecb 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -10,6 +10,18 @@
10 * Bugs: the spec doesn't mention anything about "`\n`\n" prior to the 10 * Bugs: the spec doesn't mention anything about "`\n`\n" prior to the
11 * "end" line 11 * "end" line
12 */ 12 */
13
14//usage:#define uudecode_trivial_usage
15//usage: "[-o OUTFILE] [INFILE]"
16//usage:#define uudecode_full_usage "\n\n"
17//usage: "Uudecode a file\n"
18//usage: "Finds outfile name in uuencoded source unless -o is given"
19//usage:
20//usage:#define uudecode_example_usage
21//usage: "$ uudecode -o busybox busybox.uu\n"
22//usage: "$ ls -l busybox\n"
23//usage: "-rwxr-xr-x 1 ams ams 245264 Jun 7 21:35 busybox\n"
24
13#include "libbb.h" 25#include "libbb.h"
14 26
15#if ENABLE_UUDECODE 27#if ENABLE_UUDECODE
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c
index fe9e8c664..b4cd0a9e6 100644
--- a/coreutils/uuencode.c
+++ b/coreutils/uuencode.c
@@ -8,6 +8,20 @@
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 10
11//usage:#define uuencode_trivial_usage
12//usage: "[-m] [INFILE] STORED_FILENAME"
13//usage:#define uuencode_full_usage "\n\n"
14//usage: "Uuencode a file to stdout\n"
15//usage: "\nOptions:"
16//usage: "\n -m Use base64 encoding per RFC1521"
17//usage:
18//usage:#define uuencode_example_usage
19//usage: "$ uuencode busybox busybox\n"
20//usage: "begin 755 busybox\n"
21//usage: "<encoded file snipped>\n"
22//usage: "$ uudecode busybox busybox > busybox.uu\n"
23//usage: "$\n"
24
11#include "libbb.h" 25#include "libbb.h"
12 26
13enum { 27enum {
diff --git a/coreutils/who.c b/coreutils/who.c
index ab1e30fc8..ec385bf95 100644
--- a/coreutils/who.c
+++ b/coreutils/who.c
@@ -18,6 +18,13 @@
18 */ 18 */
19/* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ 19/* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */
20 20
21//usage:#define who_trivial_usage
22//usage: "[-a]"
23//usage:#define who_full_usage "\n\n"
24//usage: "Show who is logged on\n"
25//usage: "\nOptions:"
26//usage: "\n -a Show all"
27
21#include "libbb.h" 28#include "libbb.h"
22 29
23static void idle_string(char *str6, time_t t) 30static void idle_string(char *str6, time_t t)
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index f7ac7aa6d..500e07166 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -9,6 +9,11 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12//usage:#define whoami_trivial_usage
13//usage: ""
14//usage:#define whoami_full_usage "\n\n"
15//usage: "Print the user name associated with the current effective user id"
16
12#include "libbb.h" 17#include "libbb.h"
13 18
14/* This is a NOFORK applet. Be very careful! */ 19/* This is a NOFORK applet. Be very careful! */
diff --git a/debianutils/pipe_progress.c b/debianutils/pipe_progress.c
index 1e57dc241..2c7444f31 100644
--- a/debianutils/pipe_progress.c
+++ b/debianutils/pipe_progress.c
@@ -6,6 +6,10 @@
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//usage:#define pipe_progress_trivial_usage NOUSAGE_STR
11//usage:#define pipe_progress_full_usage ""
12
9#include "libbb.h" 13#include "libbb.h"
10 14
11#define PIPE_PROGRESS_SIZE 4096 15#define PIPE_PROGRESS_SIZE 4096
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c
index b93a5a917..0c2302696 100644
--- a/debianutils/run_parts.c
+++ b/debianutils/run_parts.c
@@ -30,6 +30,32 @@
30 * -u MASK umask. Set the umask of the program executed to MASK. 30 * -u MASK umask. Set the umask of the program executed to MASK.
31 */ 31 */
32 32
33//usage:#define run_parts_trivial_usage
34//usage: "[-t] "IF_FEATURE_RUN_PARTS_FANCY("[-l] ")"[-a ARG] [-u MASK] DIRECTORY"
35//usage:#define run_parts_full_usage "\n\n"
36//usage: "Run a bunch of scripts in DIRECTORY\n"
37//usage: "\nOptions:"
38//usage: "\n -t Print what would be run, but don't actually run anything"
39//usage: "\n -a ARG Pass ARG as argument for every program"
40//usage: "\n -u MASK Set the umask to MASK before running every program"
41//usage: IF_FEATURE_RUN_PARTS_FANCY(
42//usage: "\n -l Print names of all matching files even if they are not executable"
43//usage: )
44//usage:
45//usage:#define run_parts_example_usage
46//usage: "$ run-parts -a start /etc/init.d\n"
47//usage: "$ run-parts -a stop=now /etc/init.d\n\n"
48//usage: "Let's assume you have a script foo/dosomething:\n"
49//usage: "#!/bin/sh\n"
50//usage: "for i in $*; do eval $i; done; unset i\n"
51//usage: "case \"$1\" in\n"
52//usage: "start*) echo starting something;;\n"
53//usage: "stop*) set -x; shutdown -h $stop;;\n"
54//usage: "esac\n\n"
55//usage: "Running this yields:\n"
56//usage: "$run-parts -a stop=+4m foo/\n"
57//usage: "+ shutdown -h +4m"
58
33#include "libbb.h" 59#include "libbb.h"
34 60
35struct globals { 61struct globals {
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c
index d2ee95068..bc61959d2 100644
--- a/debianutils/start_stop_daemon.c
+++ b/debianutils/start_stop_daemon.c
@@ -56,6 +56,69 @@ Misc options:
56 -v,--verbose Verbose 56 -v,--verbose Verbose
57*/ 57*/
58 58
59//usage:#define start_stop_daemon_trivial_usage
60//usage: "[OPTIONS] [-S|-K] ... [-- ARGS...]"
61//usage:#define start_stop_daemon_full_usage "\n\n"
62//usage: "Search for matching processes, and then\n"
63//usage: "-K: stop all matching processes.\n"
64//usage: "-S: start a process unless a matching process is found.\n"
65//usage: IF_FEATURE_START_STOP_DAEMON_LONG_OPTIONS(
66//usage: "\nProcess matching:"
67//usage: "\n -u,--user USERNAME|UID Match only this user's processes"
68//usage: "\n -n,--name NAME Match processes with NAME"
69//usage: "\n in comm field in /proc/PID/stat"
70//usage: "\n -x,--exec EXECUTABLE Match processes with this command"
71//usage: "\n in /proc/PID/cmdline"
72//usage: "\n -p,--pidfile FILE Match a process with PID from the file"
73//usage: "\n All specified conditions must match"
74//usage: "\n-S only:"
75//usage: "\n -x,--exec EXECUTABLE Program to run"
76//usage: "\n -a,--startas NAME Zeroth argument"
77//usage: "\n -b,--background Background"
78//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
79//usage: "\n -N,--nicelevel N Change nice level"
80//usage: )
81//usage: "\n -c,--chuid USER[:[GRP]] Change to user/group"
82//usage: "\n -m,--make-pidfile Write PID to the pidfile specified by -p"
83//usage: "\n-K only:"
84//usage: "\n -s,--signal SIG Signal to send"
85//usage: "\n -t,--test Match only, exit with 0 if a process is found"
86//usage: "\nOther:"
87//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
88//usage: "\n -o,--oknodo Exit with status 0 if nothing is done"
89//usage: "\n -v,--verbose Verbose"
90//usage: )
91//usage: "\n -q,--quiet Quiet"
92//usage: )
93//usage: IF_NOT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS(
94//usage: "\nProcess matching:"
95//usage: "\n -u USERNAME|UID Match only this user's processes"
96//usage: "\n -n NAME Match processes with NAME"
97//usage: "\n in comm field in /proc/PID/stat"
98//usage: "\n -x EXECUTABLE Match processes with this command"
99//usage: "\n command in /proc/PID/cmdline"
100//usage: "\n -p FILE Match a process with PID from the file"
101//usage: "\n All specified conditions must match"
102//usage: "\n-S only:"
103//usage: "\n -x EXECUTABLE Program to run"
104//usage: "\n -a NAME Zeroth argument"
105//usage: "\n -b Background"
106//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
107//usage: "\n -N N Change nice level"
108//usage: )
109//usage: "\n -c USER[:[GRP]] Change to user/group"
110//usage: "\n -m Write PID to the pidfile specified by -p"
111//usage: "\n-K only:"
112//usage: "\n -s SIG Signal to send"
113//usage: "\n -t Match only, exit with 0 if a process is found"
114//usage: "\nOther:"
115//usage: IF_FEATURE_START_STOP_DAEMON_FANCY(
116//usage: "\n -o Exit with status 0 if nothing is done"
117//usage: "\n -v Verbose"
118//usage: )
119//usage: "\n -q Quiet"
120//usage: )
121
59#include <sys/resource.h> 122#include <sys/resource.h>
60 123
61/* Override ENABLE_FEATURE_PIDFILE */ 124/* Override ENABLE_FEATURE_PIDFILE */
@@ -274,11 +337,17 @@ static int do_stop(void)
274 goto ret; 337 goto ret;
275 } 338 }
276 for (p = G.found_procs; p; p = p->next) { 339 for (p = G.found_procs; p; p = p->next) {
277 if (TEST || kill(p->pid, signal_nr) == 0) { 340 if (kill(p->pid, TEST ? 0 : signal_nr) == 0) {
278 killed++; 341 killed++;
279 } else { 342 } else {
280 p->pid = 0;
281 bb_perror_msg("warning: killing process %u", (unsigned)p->pid); 343 bb_perror_msg("warning: killing process %u", (unsigned)p->pid);
344 p->pid = 0;
345 if (TEST) {
346 /* Example: -K --test --pidfile PIDFILE detected
347 * that PIDFILE's pid doesn't exist */
348 killed = -1;
349 goto ret;
350 }
282 } 351 }
283 } 352 }
284 if (!QUIET && killed) { 353 if (!QUIET && killed) {
diff --git a/debianutils/which.c b/debianutils/which.c
index 0cf786803..6e92901bc 100644
--- a/debianutils/which.c
+++ b/debianutils/which.c
@@ -10,6 +10,15 @@
10 * Based on which from debianutils 10 * Based on which from debianutils
11 */ 11 */
12 12
13//usage:#define which_trivial_usage
14//usage: "[COMMAND]..."
15//usage:#define which_full_usage "\n\n"
16//usage: "Locate a COMMAND"
17//usage:
18//usage:#define which_example_usage
19//usage: "$ which login\n"
20//usage: "/bin/login\n"
21
13#include "libbb.h" 22#include "libbb.h"
14 23
15int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 24int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/docs/syslog.conf.txt b/docs/syslog.conf.txt
new file mode 100644
index 000000000..6d9c4a173
--- /dev/null
+++ b/docs/syslog.conf.txt
@@ -0,0 +1,28 @@
1If syslogd applet compiled with FEATURE_SYSLOGD_CFG=y, then it supports restricted syslog.conf.
2The config resembles rsyslog.conf in RULES part:
3
4LINE = DELIM [RULE | COMMENT]
5COMMENT = #.*
6DELIM = SPACE TAB
7RULE = SELECTOR [;SELECTOR]* DELIM* ACTION DELIM*
8SELECTOR = FACILITY [,FACILITY]* .[[!]=] PRIORITY
9FACILITY = * | kern | user ... (see syslog.h)
10PRIORITY = * | emerg | alert ... (see syslog.h)
11ACTION = FILE
12
13"mark" facility is NOT supported.
14"none" priority is supported.
15In FACILITY and PRIORITY "*" stands for "any".
16FILE is a regular file or tty device.
17
18Here is an example:
19
20#syslog.conf
21kern,user.* /var/log/messages #all messages of kern and user facilities
22kern.!err /var/log/critical #all messages of kern facility with priorities lower than err (warn, notice ...)
23*.*;auth,authpriv.none /var/log/noauth #all messages except ones with auth and authpriv facilities
24kern,user.*;kern.!=notice;*.err;syslog.none /var/log/OMG #some whicked rule just as an example =)
25*.* /dev/null #this prevents from logging to default log file (-O FILE or /var/log/messages)
26
27Even in the case of match with some rule another rules will be tried too.
28If there was no match with any of the rules, logging to default log file or shared memory will be performed.
diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c
index ab52cb009..b1c77faad 100644
--- a/e2fsprogs/chattr.c
+++ b/e2fsprogs/chattr.c
@@ -19,6 +19,30 @@
19 * 98/12/29 - Display version info only when -V specified (G M Sipe) 19 * 98/12/29 - Display version info only when -V specified (G M Sipe)
20 */ 20 */
21 21
22//usage:#define chattr_trivial_usage
23//usage: "[-R] [-+=AacDdijsStTu] [-v VERSION] [FILE]..."
24//usage:#define chattr_full_usage "\n\n"
25//usage: "Change file attributes on an ext2 fs\n"
26//usage: "\nModifiers:"
27//usage: "\n - Remove attributes"
28//usage: "\n + Add attributes"
29//usage: "\n = Set attributes"
30//usage: "\nAttributes:"
31//usage: "\n A Don't track atime"
32//usage: "\n a Append mode only"
33//usage: "\n c Enable compress"
34//usage: "\n D Write dir contents synchronously"
35//usage: "\n d Don't backup with dump"
36//usage: "\n i Cannot be modified (immutable)"
37//usage: "\n j Write all data to journal first"
38//usage: "\n s Zero disk storage when deleted"
39//usage: "\n S Write file contents synchronously"
40//usage: "\n t Disable tail-merging of partial blocks with other files"
41//usage: "\n u Allow file to be undeleted"
42//usage: "\nOptions:"
43//usage: "\n -R Recurse"
44//usage: "\n -v Set the file's version/generation number"
45
22#include "libbb.h" 46#include "libbb.h"
23#include "e2fs_lib.h" 47#include "e2fs_lib.h"
24 48
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c
index a86a9d96f..b4257a2ad 100644
--- a/e2fsprogs/fsck.c
+++ b/e2fsprogs/fsck.c
@@ -34,6 +34,20 @@
34 * It doesn't guess filesystem types from on-disk format. 34 * It doesn't guess filesystem types from on-disk format.
35 */ 35 */
36 36
37//usage:#define fsck_trivial_usage
38//usage: "[-ANPRTV] [-C FD] [-t FSTYPE] [FS_OPTS] [BLOCKDEV]..."
39//usage:#define fsck_full_usage "\n\n"
40//usage: "Check and repair filesystems\n"
41//usage: "\nOptions:"
42//usage: "\n -A Walk /etc/fstab and check all filesystems"
43//usage: "\n -N Don't execute, just show what would be done"
44//usage: "\n -P With -A, check filesystems in parallel"
45//usage: "\n -R With -A, skip the root filesystem"
46//usage: "\n -T Don't show title on startup"
47//usage: "\n -V Verbose"
48//usage: "\n -C n Write status information to specified filedescriptor"
49//usage: "\n -t TYPE List of filesystem types to check"
50
37#include "libbb.h" 51#include "libbb.h"
38 52
39/* "progress indicator" code is somewhat buggy and ext[23] specific. 53/* "progress indicator" code is somewhat buggy and ext[23] specific.
diff --git a/e2fsprogs/lsattr.c b/e2fsprogs/lsattr.c
index 7d475a969..964e8d026 100644
--- a/e2fsprogs/lsattr.c
+++ b/e2fsprogs/lsattr.c
@@ -18,6 +18,17 @@
18 * 98/12/29 - Display version info only when -V specified (G M Sipe) 18 * 98/12/29 - Display version info only when -V specified (G M Sipe)
19 */ 19 */
20 20
21//usage:#define lsattr_trivial_usage
22//usage: "[-Radlv] [FILE]..."
23//usage:#define lsattr_full_usage "\n\n"
24//usage: "List file attributes on an ext2 fs\n"
25//usage: "\nOptions:"
26//usage: "\n -R Recurse"
27//usage: "\n -a Don't hide entries starting with ."
28//usage: "\n -d List directory entries instead of contents"
29//usage: "\n -l List long flag names"
30//usage: "\n -v List the file's version/generation number"
31
21#include "libbb.h" 32#include "libbb.h"
22#include "e2fs_lib.h" 33#include "e2fs_lib.h"
23 34
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.c b/e2fsprogs/old_e2fsprogs/e2fsck.c
index d73665988..ad4ff348b 100644
--- a/e2fsprogs/old_e2fsprogs/e2fsck.c
+++ b/e2fsprogs/old_e2fsprogs/e2fsck.c
@@ -29,6 +29,28 @@
29 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 29 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
30 */ 30 */
31 31
32/*
33//usage:#define e2fsck_trivial_usage
34//usage: "[-panyrcdfvstDFSV] [-b superblock] [-B blocksize] "
35//usage: "[-I inode_buffer_blocks] [-P process_inode_size] "
36//usage: "[-l|-L bad_blocks_file] [-C fd] [-j external_journal] "
37//usage: "[-E extended-options] device"
38//usage:#define e2fsck_full_usage "\n\n"
39//usage: "Check ext2/ext3 file system\n"
40//usage: "\nOptions:"
41//usage: "\n -p Automatic repair (no questions)"
42//usage: "\n -n Make no changes to the filesystem"
43//usage: "\n -y Assume 'yes' to all questions"
44//usage: "\n -c Check for bad blocks and add them to the badblock list"
45//usage: "\n -f Force checking even if filesystem is marked clean"
46//usage: "\n -v Verbose"
47//usage: "\n -b superblock Use alternative superblock"
48//usage: "\n -B blocksize Force blocksize when looking for superblock"
49//usage: "\n -j journal Set location of the external journal"
50//usage: "\n -l file Add to badblocks list"
51//usage: "\n -L file Set badblocks list"
52*/
53
32#include "e2fsck.h" /*Put all of our defines here to clean things up*/ 54#include "e2fsck.h" /*Put all of our defines here to clean things up*/
33 55
34#define _(x) x 56#define _(x) x
@@ -560,7 +582,7 @@ static dnode_t *dict_first(dict_t *dict)
560 582
561/* 583/*
562 * Return the given node's successor node---the node which has the 584 * Return the given node's successor node---the node which has the
563 * next key in the the left to right ordering. If the node has 585 * next key in the left to right ordering. If the node has
564 * no successor, a null pointer is returned rather than a pointer to 586 * no successor, a null pointer is returned rather than a pointer to
565 * the nil node. 587 * the nil node.
566 */ 588 */
diff --git a/e2fsprogs/old_e2fsprogs/e2fsck.h b/e2fsprogs/old_e2fsprogs/e2fsck.h
index 330209d69..c159fabab 100644
--- a/e2fsprogs/old_e2fsprogs/e2fsck.h
+++ b/e2fsprogs/old_e2fsprogs/e2fsck.h
@@ -258,7 +258,7 @@ The following defines are used in the 'flags' field of a dx_dirblock_info
258#define PR_1_SET_IMAGIC 0x01002F /* Imagic flag set on an inode when filesystem doesn't support it */ 258#define PR_1_SET_IMAGIC 0x01002F /* Imagic flag set on an inode when filesystem doesn't support it */
259#define PR_1_SET_IMMUTABLE 0x010030 /* Immutable flag set on a device or socket inode */ 259#define PR_1_SET_IMMUTABLE 0x010030 /* Immutable flag set on a device or socket inode */
260#define PR_1_COMPR_SET 0x010031 /* Compression flag set on a non-compressed filesystem */ 260#define PR_1_COMPR_SET 0x010031 /* Compression flag set on a non-compressed filesystem */
261#define PR_1_SET_NONZSIZE 0x010032 /* Non-zero size on on device, fifo or socket inode */ 261#define PR_1_SET_NONZSIZE 0x010032 /* Non-zero size on device, fifo or socket inode */
262#define PR_1_FS_REV_LEVEL 0x010033 /* Filesystem revision is 0, but feature flags are set */ 262#define PR_1_FS_REV_LEVEL 0x010033 /* Filesystem revision is 0, but feature flags are set */
263#define PR_1_JOURNAL_INODE_NOT_CLEAR 0x010034 /* Journal inode not in use, needs clearing */ 263#define PR_1_JOURNAL_INODE_NOT_CLEAR 0x010034 /* Journal inode not in use, needs clearing */
264#define PR_1_JOURNAL_BAD_MODE 0x010035 /* Journal inode has wrong mode */ 264#define PR_1_JOURNAL_BAD_MODE 0x010035 /* Journal inode has wrong mode */
diff --git a/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c b/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
index a3bbad851..2bb1cc25e 100644
--- a/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
+++ b/e2fsprogs/old_e2fsprogs/ext2fs/get_pathname.c
@@ -15,7 +15,7 @@
15 * string, placing the result in <name>. <dir> is the containing 15 * string, placing the result in <name>. <dir> is the containing
16 * directory inode, and <ino> is the inode number itself. If 16 * directory inode, and <ino> is the inode number itself. If
17 * <ino> is zero, then ext2fs_get_pathname will return pathname 17 * <ino> is zero, then ext2fs_get_pathname will return pathname
18 * of the the directory <dir>. 18 * of the directory <dir>.
19 * 19 *
20 */ 20 */
21 21
diff --git a/editors/awk.c b/editors/awk.c
index 2eeb9d77a..9d38b1f88 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -7,6 +7,14 @@
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 9
10//usage:#define awk_trivial_usage
11//usage: "[OPTIONS] [AWK_PROGRAM] [FILE]..."
12//usage:#define awk_full_usage "\n\n"
13//usage: "Options:"
14//usage: "\n -v VAR=VAL Set variable"
15//usage: "\n -F SEP Use SEP as field separator"
16//usage: "\n -f FILE Read program from FILE"
17
10#include "libbb.h" 18#include "libbb.h"
11#include "xregex.h" 19#include "xregex.h"
12#include <math.h> 20#include <math.h>
diff --git a/editors/cmp.c b/editors/cmp.c
index f84a56e3e..3a0f5aa4f 100644
--- a/editors/cmp.c
+++ b/editors/cmp.c
@@ -10,6 +10,15 @@
10/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */ 10/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
12 12
13//usage:#define cmp_trivial_usage
14//usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]"
15//usage:#define cmp_full_usage "\n\n"
16//usage: "Compare FILE1 with FILE2 (or stdin)\n"
17//usage: "\nOptions:"
18//usage: "\n -l Write the byte numbers (decimal) and values (octal)"
19//usage: "\n for all differing bytes"
20//usage: "\n -s Quiet"
21
13#include "libbb.h" 22#include "libbb.h"
14 23
15static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; 24static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n";
diff --git a/editors/diff.c b/editors/diff.c
index ca4a4eae7..daa58af9b 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -76,6 +76,28 @@
76 * 6n words for files of length n. 76 * 6n words for files of length n.
77 */ 77 */
78 78
79//usage:#define diff_trivial_usage
80//usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2"
81//usage:#define diff_full_usage "\n\n"
82//usage: "Compare files line by line and output the differences between them.\n"
83//usage: "This implementation supports unified diffs only.\n"
84//usage: "\nOptions:"
85//usage: "\n -a Treat all files as text"
86//usage: "\n -b Ignore changes in the amount of whitespace"
87//usage: "\n -B Ignore changes whose lines are all blank"
88//usage: "\n -d Try hard to find a smaller set of changes"
89//usage: "\n -i Ignore case differences"
90//usage: "\n -L Use LABEL instead of the filename in the unified header"
91//usage: "\n -N Treat absent files as empty"
92//usage: "\n -q Output only whether files differ"
93//usage: "\n -r Recurse"
94//usage: "\n -S Start with FILE when comparing directories"
95//usage: "\n -T Make tabs line up by prefixing a tab when necessary"
96//usage: "\n -s Report when two files are the same"
97//usage: "\n -t Expand tabs to spaces in output"
98//usage: "\n -U Output LINES lines of context"
99//usage: "\n -w Ignore all whitespace"
100
79#include "libbb.h" 101#include "libbb.h"
80 102
81#if 0 103#if 0
@@ -952,6 +974,31 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
952 if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode))) 974 if (gotstdin && (S_ISDIR(stb[0].st_mode) || S_ISDIR(stb[1].st_mode)))
953 bb_error_msg_and_die("can't compare stdin to a directory"); 975 bb_error_msg_and_die("can't compare stdin to a directory");
954 976
977 /* Compare metadata to check if the files are the same physical file.
978 *
979 * Comment from diffutils source says:
980 * POSIX says that two files are identical if st_ino and st_dev are
981 * the same, but many file systems incorrectly assign the same (device,
982 * inode) pair to two distinct files, including:
983 * GNU/Linux NFS servers that export all local file systems as a
984 * single NFS file system, if a local device number (st_dev) exceeds
985 * 255, or if a local inode number (st_ino) exceeds 16777215.
986 */
987 if (ENABLE_DESKTOP
988 && stb[0].st_ino == stb[1].st_ino
989 && stb[0].st_dev == stb[1].st_dev
990 && stb[0].st_size == stb[1].st_size
991 && stb[0].st_mtime == stb[1].st_mtime
992 && stb[0].st_ctime == stb[1].st_ctime
993 && stb[0].st_mode == stb[1].st_mode
994 && stb[0].st_nlink == stb[1].st_nlink
995 && stb[0].st_uid == stb[1].st_uid
996 && stb[0].st_gid == stb[1].st_gid
997 ) {
998 /* files are physically the same; no need to compare them */
999 return STATUS_SAME;
1000 }
1001
955 if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode)) { 1002 if (S_ISDIR(stb[0].st_mode) && S_ISDIR(stb[1].st_mode)) {
956#if ENABLE_FEATURE_DIFF_DIR 1003#if ENABLE_FEATURE_DIFF_DIR
957 diffdir(file, s_start); 1004 diffdir(file, s_start);
diff --git a/editors/ed.c b/editors/ed.c
index b1b6a8d27..dbb51306c 100644
--- a/editors/ed.c
+++ b/editors/ed.c
@@ -7,6 +7,9 @@
7 * The "ed" built-in command (much simplified) 7 * The "ed" built-in command (much simplified)
8 */ 8 */
9 9
10//usage:#define ed_trivial_usage ""
11//usage:#define ed_full_usage ""
12
10#include "libbb.h" 13#include "libbb.h"
11 14
12typedef struct LINE { 15typedef struct LINE {
@@ -451,7 +454,7 @@ static void subCommand(const char *cmd, int num1, int num2)
451 454
452 /* 455 /*
453 * The new string is larger, so allocate a new line 456 * The new string is larger, so allocate a new line
454 * structure and use that. Link it in in place of 457 * structure and use that. Link it in place of
455 * the old line structure. 458 * the old line structure.
456 */ 459 */
457 nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen); 460 nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen);
diff --git a/editors/sed.c b/editors/sed.c
index d3555243f..9ab758bd7 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -58,6 +58,23 @@
58 Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html 58 Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
59*/ 59*/
60 60
61//usage:#define sed_trivial_usage
62//usage: "[-efinr] SED_CMD [FILE]..."
63//usage:#define sed_full_usage "\n\n"
64//usage: "Options:"
65//usage: "\n -e CMD Add CMD to sed commands to be executed"
66//usage: "\n -f FILE Add FILE contents to sed commands to be executed"
67//usage: "\n -i Edit files in-place (else sends result to stdout)"
68//usage: "\n -n Suppress automatic printing of pattern space"
69//usage: "\n -r Use extended regex syntax"
70//usage: "\n"
71//usage: "\nIf no -e or -f, the first non-option argument is the sed command string."
72//usage: "\nRemaining arguments are input files (stdin if none)."
73//usage:
74//usage:#define sed_example_usage
75//usage: "$ echo \"foo\" | sed -e 's/f[a-zA-Z]o/bar/g'\n"
76//usage: "bar\n"
77
61#include "libbb.h" 78#include "libbb.h"
62#include "xregex.h" 79#include "xregex.h"
63 80
diff --git a/editors/vi.c b/editors/vi.c
index f59d5a706..712af0326 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -21,6 +21,19 @@
21 * An "ex" line oriented mode- maybe using "cmdedit" 21 * An "ex" line oriented mode- maybe using "cmdedit"
22 */ 22 */
23 23
24//usage:#define vi_trivial_usage
25//usage: "[OPTIONS] [FILE]..."
26//usage:#define vi_full_usage "\n\n"
27//usage: "Edit FILE\n"
28//usage: "\nOptions:"
29//usage: IF_FEATURE_VI_COLON(
30//usage: "\n -c Initial command to run ($EXINIT also available)"
31//usage: )
32//usage: IF_FEATURE_VI_READONLY(
33//usage: "\n -R Read-only"
34//usage: )
35//usage: "\n -H Short help regarding available features"
36
24#include "libbb.h" 37#include "libbb.h"
25 38
26/* the CRASHME code is unmaintained, and doesn't currently build */ 39/* the CRASHME code is unmaintained, and doesn't currently build */
diff --git a/include/applet_metadata.h b/include/applet_metadata.h
new file mode 100644
index 000000000..566ef3517
--- /dev/null
+++ b/include/applet_metadata.h
@@ -0,0 +1,30 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
4 */
5#ifndef APPLET_METADATA_H
6#define APPLET_METADATA_H 1
7
8/* Note: can be included by both host and target builds! */
9
10/* order matters: used as index into "install_dir[]" in appletlib.c */
11typedef enum bb_install_loc_t {
12 BB_DIR_ROOT = 0,
13 BB_DIR_BIN,
14 BB_DIR_SBIN,
15#if ENABLE_INSTALL_NO_USR
16 BB_DIR_USR_BIN = BB_DIR_BIN,
17 BB_DIR_USR_SBIN = BB_DIR_SBIN,
18#else
19 BB_DIR_USR_BIN,
20 BB_DIR_USR_SBIN,
21#endif
22} bb_install_loc_t;
23
24typedef enum bb_suid_t {
25 BB_SUID_DROP = 0,
26 BB_SUID_MAYBE,
27 BB_SUID_REQUIRE
28} bb_suid_t;
29
30#endif
diff --git a/include/busybox.h b/include/busybox.h
index be06817e3..315ef8f26 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -1,37 +1,16 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * Busybox main internal header file
4 *
5 * 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.
6 */ 4 */
7#ifndef BUSYBOX_H 5#ifndef BUSYBOX_H
8#define BUSYBOX_H 1 6#define BUSYBOX_H 1
9 7
10#include "libbb.h" 8#include "libbb.h"
9/* BB_DIR_foo and BB_SUID_bar constants: */
10#include "applet_metadata.h"
11 11
12PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN 12PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
13 13
14/* order matters: used as index into "install_dir[]" in appletlib.c */
15typedef enum bb_install_loc_t {
16 BB_DIR_ROOT = 0,
17 BB_DIR_BIN,
18 BB_DIR_SBIN,
19#if ENABLE_INSTALL_NO_USR
20 BB_DIR_USR_BIN = BB_DIR_BIN,
21 BB_DIR_USR_SBIN = BB_DIR_SBIN,
22#else
23 BB_DIR_USR_BIN,
24 BB_DIR_USR_SBIN,
25#endif
26} bb_install_loc_t;
27
28typedef enum bb_suid_t {
29 BB_SUID_DROP = 0,
30 BB_SUID_MAYBE,
31 BB_SUID_REQUIRE
32} bb_suid_t;
33
34
35/* Defined in appletlib.c (by including generated applet_tables.h) */ 14/* Defined in appletlib.c (by including generated applet_tables.h) */
36/* Keep in sync with applets/applet_tables.c! */ 15/* Keep in sync with applets/applet_tables.c! */
37extern const char applet_names[]; 16extern const char applet_names[];
diff --git a/include/libbb.h b/include/libbb.h
index 0006e7e55..4f46cf8c5 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -602,7 +602,7 @@ len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t
602/* Assign sin[6]_port member if the socket is an AF_INET[6] one, 602/* Assign sin[6]_port member if the socket is an AF_INET[6] one,
603 * otherwise no-op. Useful for ftp. 603 * otherwise no-op. Useful for ftp.
604 * NB: does NOT do htons() internally, just direct assignment. */ 604 * NB: does NOT do htons() internally, just direct assignment. */
605void set_nport(len_and_sockaddr *lsa, unsigned port) FAST_FUNC; 605void set_nport(struct sockaddr *sa, unsigned port) FAST_FUNC;
606/* Retrieve sin[6]_port or return -1 for non-INET[6] lsa's */ 606/* Retrieve sin[6]_port or return -1 for non-INET[6] lsa's */
607int get_nport(const struct sockaddr *sa) FAST_FUNC; 607int get_nport(const struct sockaddr *sa) FAST_FUNC;
608/* Reverse DNS. Returns NULL on failure. */ 608/* Reverse DNS. Returns NULL on failure. */
@@ -1389,8 +1389,9 @@ void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
1389 1389
1390#if ENABLE_FEATURE_EDITING 1390#if ENABLE_FEATURE_EDITING
1391/* It's NOT just ENABLEd or disabled. It's a number: */ 1391/* It's NOT just ENABLEd or disabled. It's a number: */
1392# ifdef CONFIG_FEATURE_EDITING_HISTORY 1392# if defined CONFIG_FEATURE_EDITING_HISTORY && CONFIG_FEATURE_EDITING_HISTORY > 0
1393# define MAX_HISTORY (CONFIG_FEATURE_EDITING_HISTORY + 0) 1393# define MAX_HISTORY (CONFIG_FEATURE_EDITING_HISTORY + 0)
1394unsigned size_from_HISTFILESIZE(const char *hp);
1394# else 1395# else
1395# define MAX_HISTORY 0 1396# define MAX_HISTORY 0
1396# endif 1397# endif
@@ -1400,6 +1401,7 @@ typedef struct line_input_t {
1400# if MAX_HISTORY 1401# if MAX_HISTORY
1401 int cnt_history; 1402 int cnt_history;
1402 int cur_history; 1403 int cur_history;
1404 int max_history; /* must never be <= 0 */
1403# if ENABLE_FEATURE_EDITING_SAVEHISTORY 1405# if ENABLE_FEATURE_EDITING_SAVEHISTORY
1404 unsigned cnt_history_in_file; 1406 unsigned cnt_history_in_file;
1405 const char *hist_file; 1407 const char *hist_file;
diff --git a/include/platform.h b/include/platform.h
index 395ec5d45..eb9f8032b 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -22,7 +22,7 @@
22 */ 22 */
23#define HAVE_CLEARENV 1 23#define HAVE_CLEARENV 1
24#define HAVE_FDATASYNC 1 24#define HAVE_FDATASYNC 1
25#define HAVE_FDPRINTF 1 25#define HAVE_DPRINTF 1
26#define HAVE_MEMRCHR 1 26#define HAVE_MEMRCHR 1
27#define HAVE_MKDTEMP 1 27#define HAVE_MKDTEMP 1
28#define HAVE_PTSNAME_R 1 28#define HAVE_PTSNAME_R 1
@@ -282,7 +282,7 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
282# undef HAVE_SYS_STATFS_H 282# undef HAVE_SYS_STATFS_H
283# undef HAVE_SIGHANDLER_T 283# undef HAVE_SIGHANDLER_T
284# undef HAVE_XTABS 284# undef HAVE_XTABS
285# undef HAVE_FDPRINTF 285# undef HAVE_DPRINTF
286#else 286#else
287# define HAVE_MNTENT_H 1 287# define HAVE_MNTENT_H 1
288# define HAVE_SYS_STATFS_H 1 288# define HAVE_SYS_STATFS_H 1
@@ -350,11 +350,6 @@ typedef unsigned smalluint;
350# define USE_FOR_MMU(...) __VA_ARGS__ 350# define USE_FOR_MMU(...) __VA_ARGS__
351#endif 351#endif
352 352
353/* Don't use lchown with glibc older than 2.1.x */
354#if defined(__GLIBC__) && __GLIBC__ <= 2 && __GLIBC_MINOR__ < 1
355# define lchown chown
356#endif
357
358#if defined(__digital__) && defined(__unix__) 353#if defined(__digital__) && defined(__unix__)
359 354
360# include <standards.h> 355# include <standards.h>
@@ -384,16 +379,14 @@ typedef unsigned smalluint;
384#endif 379#endif
385 380
386#include <unistd.h> 381#include <unistd.h>
387#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L) || defined(__GLIBC__) 382#define fdprintf dprintf
388# define fdprintf dprintf
389#endif
390 383
391#if defined(__dietlibc__) 384#if defined(__dietlibc__)
392# undef HAVE_STRCHRNUL 385# undef HAVE_STRCHRNUL
393#endif 386#endif
394 387
395#if ENABLE_PLATFORM_MINGW32 388#if ENABLE_PLATFORM_MINGW32
396# undef HAVE_FDPRINTF 389# undef HAVE_DPRINTF
397# undef HAVE_MEMRCHR 390# undef HAVE_MEMRCHR
398# undef HAVE_MKDTEMP 391# undef HAVE_MKDTEMP
399# undef HAVE_SETBIT 392# undef HAVE_SETBIT
@@ -407,7 +400,7 @@ typedef unsigned smalluint;
407#endif 400#endif
408 401
409#if defined(__WATCOMC__) 402#if defined(__WATCOMC__)
410# undef HAVE_FDPRINTF 403# undef HAVE_DPRINTF
411# undef HAVE_MEMRCHR 404# undef HAVE_MEMRCHR
412# undef HAVE_MKDTEMP 405# undef HAVE_MKDTEMP
413# undef HAVE_SETBIT 406# undef HAVE_SETBIT
@@ -428,8 +421,8 @@ typedef unsigned smalluint;
428 * These must come after all the HAVE_* macros are defined (or not) 421 * These must come after all the HAVE_* macros are defined (or not)
429 */ 422 */
430 423
431#ifndef HAVE_FDPRINTF 424#ifndef HAVE_DPRINTF
432extern int fdprintf(int fd, const char *format, ...); 425extern int dprintf(int fd, const char *format, ...);
433#endif 426#endif
434 427
435#ifndef HAVE_MEMRCHR 428#ifndef HAVE_MEMRCHR
diff --git a/include/usage.src.h b/include/usage.src.h
index d07b408a6..78beccf4d 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -12,4098 +12,11 @@
12#ifndef BB_USAGE_H 12#ifndef BB_USAGE_H
13#define BB_USAGE_H 1 13#define BB_USAGE_H 1
14 14
15
16#define NOUSAGE_STR "\b" 15#define NOUSAGE_STR "\b"
17 16
18INSERT 17INSERT
19 18
20#define acpid_trivial_usage \
21 "[-d] [-c CONFDIR] [-l LOGFILE] [-a ACTIONFILE] [-M MAPFILE] [-e PROC_EVENT_FILE] [-p PIDFILE]"
22#define acpid_full_usage "\n\n" \
23 "Listen to ACPI events and spawn specific helpers on event arrival\n" \
24 "\nOptions:" \
25 "\n -c DIR Config directory [/etc/acpi]" \
26 "\n -d Don't daemonize, (implies -f)" \
27 "\n -e FILE /proc event file [/proc/acpi/event]" \
28 "\n -f Run in foreground" \
29 "\n -l FILE Log file [/var/log/acpid.log]" \
30 "\n -p FILE Pid file [/var/run/acpid.pid]" \
31 "\n -a FILE Action file [/etc/acpid.conf]" \
32 "\n -M FILE Map file [/etc/acpi.map]" \
33 IF_FEATURE_ACPID_COMPAT( \
34 "\n\nAccept and ignore compatibility options -g -m -s -S -v" \
35 )
36
37#define acpid_example_usage \
38 "Without -e option, acpid uses all /dev/input/event* files\n" \
39 "# acpid\n" \
40 "# acpid -l /var/log/my-acpi-log\n" \
41 "# acpid -e /proc/acpi/event\n"
42
43#define addgroup_trivial_usage \
44 "[-g GID] " IF_FEATURE_ADDUSER_TO_GROUP("[USER] ") "GROUP"
45#define addgroup_full_usage "\n\n" \
46 "Add a group " IF_FEATURE_ADDUSER_TO_GROUP("or add a user to a group") "\n" \
47 "\nOptions:" \
48 "\n -g GID Group id" \
49 "\n -S Create a system group" \
50
51#define adduser_trivial_usage \
52 "[OPTIONS] USER"
53#define adduser_full_usage "\n\n" \
54 "Add a user\n" \
55 "\nOptions:" \
56 "\n -h DIR Home directory" \
57 "\n -g GECOS GECOS field" \
58 "\n -s SHELL Login shell" \
59 "\n -G GRP Add user to existing group" \
60 "\n -S Create a system user" \
61 "\n -D Don't assign a password" \
62 "\n -H Don't create home directory" \
63 "\n -u UID User id" \
64
65#define adjtimex_trivial_usage \
66 "[-q] [-o OFF] [-f FREQ] [-p TCONST] [-t TICK]"
67#define adjtimex_full_usage "\n\n" \
68 "Read and optionally set system timebase parameters. See adjtimex(2)\n" \
69 "\nOptions:" \
70 "\n -q Quiet" \
71 "\n -o OFF Time offset, microseconds" \
72 "\n -f FREQ Frequency adjust, integer kernel units (65536 is 1ppm)" \
73 "\n (positive values make clock run faster)" \
74 "\n -t TICK Microseconds per tick, usually 10000" \
75 "\n -p TCONST" \
76
77#define ar_trivial_usage \
78 "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES"
79#define ar_full_usage "\n\n" \
80 "Extract or list FILES from an ar archive\n" \
81 "\nOptions:" \
82 "\n -o Preserve original dates" \
83 "\n -p Extract to stdout" \
84 "\n -t List" \
85 "\n -x Extract" \
86 "\n -v Verbose" \
87
88#define arp_trivial_usage \
89 "\n[-vn] [-H HWTYPE] [-i IF] -a [HOSTNAME]" \
90 "\n[-v] [-i IF] -d HOSTNAME [pub]" \
91 "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [temp]" \
92 "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [netmask MASK] pub" \
93 "\n[-v] [-H HWTYPE] [-i IF] -Ds HOSTNAME IFACE [netmask MASK] pub"
94#define arp_full_usage "\n\n" \
95 "Manipulate ARP cache\n" \
96 "\nOptions:" \
97 "\n -a Display (all) hosts" \
98 "\n -s Set new ARP entry" \
99 "\n -d Delete a specified entry" \
100 "\n -v Verbose" \
101 "\n -n Don't resolve names" \
102 "\n -i IF Network interface" \
103 "\n -D Read <hwaddr> from given device" \
104 "\n -A,-p AF Protocol family" \
105 "\n -H HWTYPE Hardware address type" \
106
107#define arping_trivial_usage \
108 "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP"
109#define arping_full_usage "\n\n" \
110 "Send ARP requests/replies\n" \
111 "\nOptions:" \
112 "\n -f Quit on first ARP reply" \
113 "\n -q Quiet" \
114 "\n -b Keep broadcasting, don't go unicast" \
115 "\n -D Duplicated address detection mode" \
116 "\n -U Unsolicited ARP mode, update your neighbors" \
117 "\n -A ARP answer mode, update your neighbors" \
118 "\n -c N Stop after sending N ARP requests" \
119 "\n -w TIMEOUT Time to wait for ARP reply, seconds" \
120 "\n -I IFACE Interface to use (default eth0)" \
121 "\n -s SRC_IP Sender IP address" \
122 "\n DST_IP Target IP address" \
123
124#define awk_trivial_usage \
125 "[OPTIONS] [AWK_PROGRAM] [FILE]..."
126#define awk_full_usage "\n\n" \
127 "Options:" \
128 "\n -v VAR=VAL Set variable" \
129 "\n -F SEP Use SEP as field separator" \
130 "\n -f FILE Read program from FILE" \
131
132#define basename_trivial_usage \
133 "FILE [SUFFIX]"
134#define basename_full_usage "\n\n" \
135 "Strip directory path and .SUFFIX from FILE\n"
136#define basename_example_usage \
137 "$ basename /usr/local/bin/foo\n" \
138 "foo\n" \
139 "$ basename /usr/local/bin/\n" \
140 "bin\n" \
141 "$ basename /foo/bar.txt .txt\n" \
142 "bar"
143
144#define beep_trivial_usage \
145 "-f FREQ -l LEN -d DELAY -r COUNT -n"
146#define beep_full_usage "\n\n" \
147 "Options:" \
148 "\n -f Frequency in Hz" \
149 "\n -l Length in ms" \
150 "\n -d Delay in ms" \
151 "\n -r Repetitions" \
152 "\n -n Start new tone" \
153
154#define blkid_trivial_usage \
155 ""
156#define blkid_full_usage "\n\n" \
157 "Print UUIDs of all filesystems"
158
159#define brctl_trivial_usage \
160 "COMMAND [BRIDGE [INTERFACE]]"
161#define brctl_full_usage "\n\n" \
162 "Manage ethernet bridges\n" \
163 "\nCommands:" \
164 IF_FEATURE_BRCTL_SHOW( \
165 "\n show Show a list of bridges" \
166 ) \
167 "\n addbr BRIDGE Create BRIDGE" \
168 "\n delbr BRIDGE Delete BRIDGE" \
169 "\n addif BRIDGE IFACE Add IFACE to BRIDGE" \
170 "\n delif BRIDGE IFACE Delete IFACE from BRIDGE" \
171 IF_FEATURE_BRCTL_FANCY( \
172 "\n setageing BRIDGE TIME Set ageing time" \
173 "\n setfd BRIDGE TIME Set bridge forward delay" \
174 "\n sethello BRIDGE TIME Set hello time" \
175 "\n setmaxage BRIDGE TIME Set max message age" \
176 "\n setpathcost BRIDGE COST Set path cost" \
177 "\n setportprio BRIDGE PRIO Set port priority" \
178 "\n setbridgeprio BRIDGE PRIO Set bridge priority" \
179 "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off" \
180 ) \
181
182#define bzip2_trivial_usage \
183 "[OPTIONS] [FILE]..."
184#define bzip2_full_usage "\n\n" \
185 "Compress FILEs (or stdin) with bzip2 algorithm\n" \
186 "\nOptions:" \
187 "\n -1..9 Compression level" \
188 "\n -d Decompress" \
189 "\n -c Write to stdout" \
190 "\n -f Force" \
191
192#define busybox_notes_usage \ 19#define busybox_notes_usage \
193 "Hello world!\n" 20 "Hello world!\n"
194 21
195#define lzop_trivial_usage \
196 "[-cfvd123456789CF] [FILE]..."
197#define lzop_full_usage "\n\n" \
198 "Options:" \
199 "\n -1..9 Compression level" \
200 "\n -d Decompress" \
201 "\n -c Write to stdout" \
202 "\n -f Force" \
203 "\n -v Verbose" \
204 "\n -F Don't store or verify checksum" \
205 "\n -C Also write checksum of compressed block" \
206
207#define lzopcat_trivial_usage \
208 "[-vCF] [FILE]..."
209#define lzopcat_full_usage "\n\n" \
210 " -v Verbose" \
211 "\n -F Don't store or verify checksum" \
212
213#define unlzop_trivial_usage \
214 "[-cfvCF] [FILE]..."
215#define unlzop_full_usage "\n\n" \
216 "Options:" \
217 "\n -c Write to stdout" \
218 "\n -f Force" \
219 "\n -v Verbose" \
220 "\n -F Don't store or verify checksum" \
221
222#define unlzma_trivial_usage \
223 "[-cf] [FILE]..."
224#define unlzma_full_usage "\n\n" \
225 "Decompress FILE (or stdin)\n" \
226 "\nOptions:" \
227 "\n -c Write to stdout" \
228 "\n -f Force" \
229
230#define lzma_trivial_usage \
231 "-d [-cf] [FILE]..."
232#define lzma_full_usage "\n\n" \
233 "Decompress FILE (or stdin)\n" \
234 "\nOptions:" \
235 "\n -d Decompress" \
236 "\n -c Write to stdout" \
237 "\n -f Force" \
238
239#define lzcat_trivial_usage \
240 "FILE"
241#define lzcat_full_usage "\n\n" \
242 "Decompress to stdout"
243
244#define unxz_trivial_usage \
245 "[-cf] [FILE]..."
246#define unxz_full_usage "\n\n" \
247 "Decompress FILE (or stdin)\n" \
248 "\nOptions:" \
249 "\n -c Write to stdout" \
250 "\n -f Force" \
251
252#define xz_trivial_usage \
253 "-d [-cf] [FILE]..."
254#define xz_full_usage "\n\n" \
255 "Decompress FILE (or stdin)\n" \
256 "\nOptions:" \
257 "\n -d Decompress" \
258 "\n -c Write to stdout" \
259 "\n -f Force" \
260
261#define xzcat_trivial_usage \
262 "FILE"
263#define xzcat_full_usage "\n\n" \
264 "Decompress to stdout"
265
266#define cal_trivial_usage \
267 "[-jy] [[MONTH] YEAR]"
268#define cal_full_usage "\n\n" \
269 "Display a calendar\n" \
270 "\nOptions:" \
271 "\n -j Use julian dates" \
272 "\n -y Display the entire year" \
273
274#define cat_trivial_usage \
275 "[FILE]..."
276#define cat_full_usage "\n\n" \
277 "Concatenate FILEs and print them to stdout" \
278
279#define cat_example_usage \
280 "$ cat /proc/uptime\n" \
281 "110716.72 17.67"
282
283#define catv_trivial_usage \
284 "[-etv] [FILE]..."
285#define catv_full_usage "\n\n" \
286 "Display nonprinting characters as ^x or M-x\n" \
287 "\nOptions:" \
288 "\n -e End each line with $" \
289 "\n -t Show tabs as ^I" \
290 "\n -v Don't use ^x or M-x escapes" \
291
292#define chat_trivial_usage \
293 "EXPECT [SEND [EXPECT [SEND...]]]"
294#define chat_full_usage "\n\n" \
295 "Useful for interacting with a modem connected to stdin/stdout.\n" \
296 "A script consists of one or more \"expect-send\" pairs of strings,\n" \
297 "each pair is a pair of arguments. Example:\n" \
298 "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'" \
299
300#define chattr_trivial_usage \
301 "[-R] [-+=AacDdijsStTu] [-v VERSION] [FILE]..."
302#define chattr_full_usage "\n\n" \
303 "Change file attributes on an ext2 fs\n" \
304 "\nModifiers:" \
305 "\n - Remove attributes" \
306 "\n + Add attributes" \
307 "\n = Set attributes" \
308 "\nAttributes:" \
309 "\n A Don't track atime" \
310 "\n a Append mode only" \
311 "\n c Enable compress" \
312 "\n D Write dir contents synchronously" \
313 "\n d Don't backup with dump" \
314 "\n i Cannot be modified (immutable)" \
315 "\n j Write all data to journal first" \
316 "\n s Zero disk storage when deleted" \
317 "\n S Write file contents synchronously" \
318 "\n t Disable tail-merging of partial blocks with other files" \
319 "\n u Allow file to be undeleted" \
320 "\nOptions:" \
321 "\n -R Recurse" \
322 "\n -v Set the file's version/generation number" \
323
324#define chcon_trivial_usage \
325 "[OPTIONS] CONTEXT FILE..." \
326 "\n chcon [OPTIONS] [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE..." \
327 IF_FEATURE_CHCON_LONG_OPTIONS( \
328 "\n chcon [OPTIONS] --reference=RFILE FILE..." \
329 )
330#define chcon_full_usage "\n\n" \
331 "Change the security context of each FILE to CONTEXT\n" \
332 IF_FEATURE_CHCON_LONG_OPTIONS( \
333 "\n -v,--verbose Verbose" \
334 "\n -c,--changes Report changes made" \
335 "\n -h,--no-dereference Affect symlinks instead of their targets" \
336 "\n -f,--silent,--quiet Suppress most error messages" \
337 "\n --reference=RFILE Use RFILE's group instead of using a CONTEXT value" \
338 "\n -u,--user=USER Set user/role/type/range in the target" \
339 "\n -r,--role=ROLE security context" \
340 "\n -t,--type=TYPE" \
341 "\n -l,--range=RANGE" \
342 "\n -R,--recursive Recurse" \
343 ) \
344 IF_NOT_FEATURE_CHCON_LONG_OPTIONS( \
345 "\n -v Verbose" \
346 "\n -c Report changes made" \
347 "\n -h Affect symlinks instead of their targets" \
348 "\n -f Suppress most error messages" \
349 "\n -u USER Set user/role/type/range in the target security context" \
350 "\n -r ROLE" \
351 "\n -t TYPE" \
352 "\n -l RNG" \
353 "\n -R Recurse" \
354 )
355
356#define chmod_trivial_usage \
357 "[-R"IF_DESKTOP("cvf")"] MODE[,MODE]... FILE..."
358#define chmod_full_usage "\n\n" \
359 "Each MODE is one or more of the letters ugoa, one of the\n" \
360 "symbols +-= and one or more of the letters rwxst\n" \
361 "\nOptions:" \
362 "\n -R Recurse" \
363 IF_DESKTOP( \
364 "\n -c List changed files" \
365 "\n -v List all files" \
366 "\n -f Hide errors" \
367 )
368#define chmod_example_usage \
369 "$ ls -l /tmp/foo\n" \
370 "-rw-rw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n" \
371 "$ chmod u+x /tmp/foo\n" \
372 "$ ls -l /tmp/foo\n" \
373 "-rwxrw-r-- 1 root root 0 Apr 12 18:25 /tmp/foo*\n" \
374 "$ chmod 444 /tmp/foo\n" \
375 "$ ls -l /tmp/foo\n" \
376 "-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
377
378#define chgrp_trivial_usage \
379 "[-RhLHP"IF_DESKTOP("cvf")"]... GROUP FILE..."
380#define chgrp_full_usage "\n\n" \
381 "Change the group membership of each FILE to GROUP\n" \
382 "\nOptions:" \
383 "\n -R Recurse" \
384 "\n -h Affect symlinks instead of symlink targets" \
385 "\n -L Traverse all symlinks to directories" \
386 "\n -H Traverse symlinks on command line only" \
387 "\n -P Don't traverse symlinks (default)" \
388 IF_DESKTOP( \
389 "\n -c List changed files" \
390 "\n -v Verbose" \
391 "\n -f Hide errors" \
392 )
393#define chgrp_example_usage \
394 "$ ls -l /tmp/foo\n" \
395 "-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n" \
396 "$ chgrp root /tmp/foo\n" \
397 "$ ls -l /tmp/foo\n" \
398 "-r--r--r-- 1 andersen root 0 Apr 12 18:25 /tmp/foo\n"
399
400#define chown_trivial_usage \
401 "[-RhLHP"IF_DESKTOP("cvf")"]... OWNER[<.|:>[GROUP]] FILE..."
402#define chown_full_usage "\n\n" \
403 "Change the owner and/or group of each FILE to OWNER and/or GROUP\n" \
404 "\nOptions:" \
405 "\n -R Recurse" \
406 "\n -h Affect symlinks instead of symlink targets" \
407 "\n -L Traverse all symlinks to directories" \
408 "\n -H Traverse symlinks on command line only" \
409 "\n -P Don't traverse symlinks (default)" \
410 IF_DESKTOP( \
411 "\n -c List changed files" \
412 "\n -v List all files" \
413 "\n -f Hide errors" \
414 )
415#define chown_example_usage \
416 "$ ls -l /tmp/foo\n" \
417 "-r--r--r-- 1 andersen andersen 0 Apr 12 18:25 /tmp/foo\n" \
418 "$ chown root /tmp/foo\n" \
419 "$ ls -l /tmp/foo\n" \
420 "-r--r--r-- 1 root andersen 0 Apr 12 18:25 /tmp/foo\n" \
421 "$ chown root.root /tmp/foo\n" \
422 "ls -l /tmp/foo\n" \
423 "-r--r--r-- 1 root root 0 Apr 12 18:25 /tmp/foo\n"
424
425#define chpst_trivial_usage \
426 "[-vP012] [-u USER[:GRP]] [-U USER[:GRP]] [-e DIR]\n" \
427 " [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n" \
428 " [-p N] [-f BYTES] [-c BYTES] PROG ARGS"
429#define chpst_full_usage "\n\n" \
430 "Change the process state, run PROG\n" \
431 "\nOptions:" \
432 "\n -u USER[:GRP] Set uid and gid" \
433 "\n -U USER[:GRP] Set $UID and $GID in environment" \
434 "\n -e DIR Set environment variables as specified by files" \
435 "\n in DIR: file=1st_line_of_file" \
436 "\n -/ DIR Chroot to DIR" \
437 "\n -n NICE Add NICE to nice value" \
438 "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES" \
439 "\n -d BYTES Limit data segment" \
440 "\n -o N Limit number of open files per process" \
441 "\n -p N Limit number of processes per uid" \
442 "\n -f BYTES Limit output file sizes" \
443 "\n -c BYTES Limit core file size" \
444 "\n -v Verbose" \
445 "\n -P Create new process group" \
446 "\n -0 Close stdin" \
447 "\n -1 Close stdout" \
448 "\n -2 Close stderr" \
449
450#define setuidgid_trivial_usage \
451 "USER PROG ARGS"
452#define setuidgid_full_usage "\n\n" \
453 "Set uid and gid to USER's uid and gid, drop supplementary group ids,\n" \
454 "run PROG"
455#define envuidgid_trivial_usage \
456 "USER PROG ARGS"
457#define envuidgid_full_usage "\n\n" \
458 "Set $UID to USER's uid and $GID to USER's gid, run PROG"
459#define envdir_trivial_usage \
460 "DIR PROG ARGS"
461#define envdir_full_usage "\n\n" \
462 "Set various environment variables as specified by files\n" \
463 "in the directory DIR, run PROG"
464#define softlimit_trivial_usage \
465 "[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n" \
466 " [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n" \
467 " PROG ARGS"
468#define softlimit_full_usage "\n\n" \
469 "Set soft resource limits, then run PROG\n" \
470 "\nOptions:" \
471 "\n -a BYTES Limit total size of all segments" \
472 "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES -a BYTES" \
473 "\n -d BYTES Limit data segment" \
474 "\n -s BYTES Limit stack segment" \
475 "\n -l BYTES Limit locked memory size" \
476 "\n -o N Limit number of open files per process" \
477 "\n -p N Limit number of processes per uid" \
478 "\nOptions controlling file sizes:" \
479 "\n -f BYTES Limit output file sizes" \
480 "\n -c BYTES Limit core file size" \
481 "\nEfficiency opts:" \
482 "\n -r BYTES Limit resident set size" \
483 "\n -t N Limit CPU time, process receives" \
484 "\n a SIGXCPU after N seconds" \
485
486#define chroot_trivial_usage \
487 "NEWROOT [PROG ARGS]"
488#define chroot_full_usage "\n\n" \
489 "Run PROG with root directory set to NEWROOT"
490#define chroot_example_usage \
491 "$ ls -l /bin/ls\n" \
492 "lrwxrwxrwx 1 root root 12 Apr 13 00:46 /bin/ls -> /BusyBox\n" \
493 "# mount /dev/hdc1 /mnt -t minix\n" \
494 "# chroot /mnt\n" \
495 "# ls -l /bin/ls\n" \
496 "-rwxr-xr-x 1 root root 40816 Feb 5 07:45 /bin/ls*\n"
497
498#define chvt_trivial_usage \
499 "N"
500#define chvt_full_usage "\n\n" \
501 "Change the foreground virtual terminal to /dev/ttyN"
502
503#define cksum_trivial_usage \
504 "FILES..."
505#define cksum_full_usage "\n\n" \
506 "Calculate the CRC32 checksums of FILES"
507
508#define clear_trivial_usage \
509 ""
510#define clear_full_usage "\n\n" \
511 "Clear screen"
512
513#define cmp_trivial_usage \
514 "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]"
515#define cmp_full_usage "\n\n" \
516 "Compare FILE1 with FILE2 (or stdin)\n" \
517 "\nOptions:" \
518 "\n -l Write the byte numbers (decimal) and values (octal)" \
519 "\n for all differing bytes" \
520 "\n -s Quiet" \
521
522#define comm_trivial_usage \
523 "[-123] FILE1 FILE2"
524#define comm_full_usage "\n\n" \
525 "Compare FILE1 with FILE2\n" \
526 "\nOptions:" \
527 "\n -1 Suppress lines unique to FILE1" \
528 "\n -2 Suppress lines unique to FILE2" \
529 "\n -3 Suppress lines common to both files" \
530
531#define bbconfig_trivial_usage \
532 ""
533#define bbconfig_full_usage "\n\n" \
534 "Print the config file used by busybox build"
535
536#define chrt_trivial_usage \
537 "[-prfom] [PRIO] [PID | PROG ARGS]"
538#define chrt_full_usage "\n\n" \
539 "Change scheduling priority and class for a process\n" \
540 "\nOptions:" \
541 "\n -p Operate on PID" \
542 "\n -r Set SCHED_RR class" \
543 "\n -f Set SCHED_FIFO class" \
544 "\n -o Set SCHED_OTHER class" \
545 "\n -m Show min/max priorities" \
546
547#define chrt_example_usage \
548 "$ chrt -r 4 sleep 900; x=$!\n" \
549 "$ chrt -f -p 3 $x\n" \
550 "You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
551
552#define nice_trivial_usage \
553 "[-n ADJUST] [PROG ARGS]"
554#define nice_full_usage "\n\n" \
555 "Change scheduling priority, run PROG\n" \
556 "\nOptions:" \
557 "\n -n ADJUST Adjust priority by ADJUST" \
558
559#define renice_trivial_usage \
560 "{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID...]"
561#define renice_full_usage "\n\n" \
562 "Change scheduling priority for a running process\n" \
563 "\nOptions:" \
564 "\n -n Adjust current nice value (smaller is faster)" \
565 "\n -p Process id(s) (default)" \
566 "\n -g Process group id(s)" \
567 "\n -u Process user name(s) and/or id(s)" \
568
569#define ionice_trivial_usage \
570 "[-c 1-3] [-n 0-7] [-p PID] [PROG]"
571#define ionice_full_usage "\n\n" \
572 "Change I/O priority and class\n" \
573 "\nOptions:" \
574 "\n -c Class. 1:realtime 2:best-effort 3:idle" \
575 "\n -n Priority" \
576
577#define cp_trivial_usage \
578 "[OPTIONS] SOURCE DEST"
579#define cp_full_usage "\n\n" \
580 "Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY\n" \
581 "\nOptions:" \
582 "\n -a Same as -dpR" \
583 IF_SELINUX( \
584 "\n -c Preserve security context" \
585 ) \
586 "\n -R,-r Recurse" \
587 "\n -d,-P Preserve symlinks (default if -R)" \
588 "\n -L Follow all symlinks" \
589 "\n -H Follow symlinks on command line" \
590 "\n -p Preserve file attributes if possible" \
591 "\n -f Overwrite" \
592 "\n -i Prompt before overwrite" \
593 "\n -l,-s Create (sym)links" \
594
595#define crond_trivial_usage \
596 "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR"
597#define crond_full_usage "\n\n" \
598 " -f Foreground" \
599 "\n -b Background (default)" \
600 "\n -S Log to syslog (default)" \
601 "\n -l Set log level. 0 is the most verbose, default 8" \
602 IF_FEATURE_CROND_D( \
603 "\n -d Set log level, log to stderr" \
604 ) \
605 "\n -L Log to file" \
606 "\n -c Working dir" \
607
608#define crontab_trivial_usage \
609 "[-c DIR] [-u USER] [-ler]|[FILE]"
610#define crontab_full_usage "\n\n" \
611 " -c Crontab directory" \
612 "\n -u User" \
613 "\n -l List crontab" \
614 "\n -e Edit crontab" \
615 "\n -r Delete crontab" \
616 "\n FILE Replace crontab by FILE ('-': stdin)" \
617
618#define cryptpw_trivial_usage \
619 "[OPTIONS] [PASSWORD] [SALT]"
620/* We do support -s, we just don't mention it */
621#define cryptpw_full_usage "\n\n" \
622 "Crypt the PASSWORD using crypt(3)\n" \
623 "\nOptions:" \
624 IF_LONG_OPTS( \
625 "\n -P,--password-fd=N Read password from fd N" \
626/* "\n -s,--stdin Use stdin; like -P0" */ \
627 "\n -m,--method=TYPE Encryption method TYPE" \
628 "\n -S,--salt=SALT" \
629 ) \
630 IF_NOT_LONG_OPTS( \
631 "\n -P N Read password from fd N" \
632/* "\n -s Use stdin; like -P0" */ \
633 "\n -m TYPE Encryption method TYPE" \
634 "\n -S SALT" \
635 ) \
636
637/* mkpasswd is an alias to cryptpw */
638
639#define mkpasswd_trivial_usage \
640 "[OPTIONS] [PASSWORD] [SALT]"
641/* We do support -s, we just don't mention it */
642#define mkpasswd_full_usage "\n\n" \
643 "Crypt the PASSWORD using crypt(3)\n" \
644 "\nOptions:" \
645 IF_LONG_OPTS( \
646 "\n -P,--password-fd=N Read password from fd N" \
647/* "\n -s,--stdin Use stdin; like -P0" */ \
648 "\n -m,--method=TYPE Encryption method TYPE" \
649 "\n -S,--salt=SALT" \
650 ) \
651 IF_NOT_LONG_OPTS( \
652 "\n -P N Read password from fd N" \
653/* "\n -s Use stdin; like -P0" */ \
654 "\n -m TYPE Encryption method TYPE" \
655 "\n -S SALT" \
656 ) \
657
658#define cut_trivial_usage \
659 "[OPTIONS] [FILE]..."
660#define cut_full_usage "\n\n" \
661 "Print selected fields from each input FILE to stdout\n" \
662 "\nOptions:" \
663 "\n -b LIST Output only bytes from LIST" \
664 "\n -c LIST Output only characters from LIST" \
665 "\n -d CHAR Use CHAR instead of tab as the field delimiter" \
666 "\n -s Output only the lines containing delimiter" \
667 "\n -f N Print only these fields" \
668 "\n -n Ignored" \
669
670#define cut_example_usage \
671 "$ echo \"Hello world\" | cut -f 1 -d ' '\n" \
672 "Hello\n" \
673 "$ echo \"Hello world\" | cut -f 2 -d ' '\n" \
674 "world\n"
675
676#define dd_trivial_usage \
677 "[if=FILE] [of=FILE] " IF_FEATURE_DD_IBS_OBS("[ibs=N] [obs=N] ") "[bs=N] [count=N] [skip=N]\n" \
678 " [seek=N]" IF_FEATURE_DD_IBS_OBS(" [conv=notrunc|noerror|sync|fsync]")
679#define dd_full_usage "\n\n" \
680 "Copy a file with converting and formatting\n" \
681 "\nOptions:" \
682 "\n if=FILE Read from FILE instead of stdin" \
683 "\n of=FILE Write to FILE instead of stdout" \
684 "\n bs=N Read and write N bytes at a time" \
685 IF_FEATURE_DD_IBS_OBS( \
686 "\n ibs=N Read N bytes at a time" \
687 ) \
688 IF_FEATURE_DD_IBS_OBS( \
689 "\n obs=N Write N bytes at a time" \
690 ) \
691 "\n count=N Copy only N input blocks" \
692 "\n skip=N Skip N input blocks" \
693 "\n seek=N Skip N output blocks" \
694 IF_FEATURE_DD_IBS_OBS( \
695 "\n conv=notrunc Don't truncate output file" \
696 "\n conv=noerror Continue after read errors" \
697 "\n conv=sync Pad blocks with zeros" \
698 "\n conv=fsync Physically write data out before finishing" \
699 ) \
700 "\n" \
701 "\nNumbers may be suffixed by c (x1), w (x2), b (x512), kD (x1000), k (x1024)," \
702 "\nMD (x1000000), M (x1048576), GD (x1000000000) or G (x1073741824)" \
703
704#define dd_example_usage \
705 "$ dd if=/dev/zero of=/dev/ram1 bs=1M count=4\n" \
706 "4+0 records in\n" \
707 "4+0 records out\n"
708
709#define deallocvt_trivial_usage \
710 "[N]"
711#define deallocvt_full_usage "\n\n" \
712 "Deallocate unused virtual terminal /dev/ttyN"
713
714#define delgroup_trivial_usage \
715 IF_FEATURE_DEL_USER_FROM_GROUP("[USER] ")"GROUP"
716#define delgroup_full_usage "\n\n" \
717 "Delete group GROUP from the system" \
718 IF_FEATURE_DEL_USER_FROM_GROUP(" or user USER from group GROUP")
719
720#define deluser_trivial_usage \
721 "USER"
722#define deluser_full_usage "\n\n" \
723 "Delete USER from the system"
724
725#define devmem_trivial_usage \
726 "ADDRESS [WIDTH [VALUE]]"
727
728#define devmem_full_usage "\n\n" \
729 "Read/write from physical address\n" \
730 "\n ADDRESS Address to act upon" \
731 "\n WIDTH Width (8/16/...)" \
732 "\n VALUE Data to be written" \
733
734#define devfsd_trivial_usage \
735 "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]")
736#define devfsd_full_usage "\n\n" \
737 "Manage devfs permissions and old device name symlinks\n" \
738 "\nOptions:" \
739 "\n mntpnt The mount point where devfs is mounted" \
740 "\n -v Print the protocol version numbers for devfsd" \
741 "\n and the kernel-side protocol version and exit" \
742 IF_DEVFSD_FG_NP( \
743 "\n -fg Run in foreground" \
744 "\n -np Exit after parsing the configuration file" \
745 "\n and processing synthetic REGISTER events," \
746 "\n don't poll for events" \
747 )
748
749#define df_trivial_usage \
750 "[-Pk" \
751 IF_FEATURE_HUMAN_READABLE("mh") \
752 IF_FEATURE_DF_FANCY("ai] [-B SIZE") \
753 "] [FILESYSTEM]..."
754#define df_full_usage "\n\n" \
755 "Print filesystem usage statistics\n" \
756 "\nOptions:" \
757 "\n -P POSIX output format" \
758 "\n -k 1024-byte blocks (default)" \
759 IF_FEATURE_HUMAN_READABLE( \
760 "\n -m 1M-byte blocks" \
761 "\n -h Human readable (e.g. 1K 243M 2G)" \
762 ) \
763 IF_FEATURE_DF_FANCY( \
764 "\n -a Show all filesystems" \
765 "\n -i Inodes" \
766 "\n -B SIZE Blocksize" \
767 ) \
768
769#define df_example_usage \
770 "$ df\n" \
771 "Filesystem 1K-blocks Used Available Use% Mounted on\n" \
772 "/dev/sda3 8690864 8553540 137324 98% /\n" \
773 "/dev/sda1 64216 36364 27852 57% /boot\n" \
774 "$ df /dev/sda3\n" \
775 "Filesystem 1K-blocks Used Available Use% Mounted on\n" \
776 "/dev/sda3 8690864 8553540 137324 98% /\n" \
777 "$ POSIXLY_CORRECT=sure df /dev/sda3\n" \
778 "Filesystem 512B-blocks Used Available Use% Mounted on\n" \
779 "/dev/sda3 17381728 17107080 274648 98% /\n" \
780 "$ POSIXLY_CORRECT=yep df -P /dev/sda3\n" \
781 "Filesystem 512-blocks Used Available Capacity Mounted on\n" \
782 "/dev/sda3 17381728 17107080 274648 98% /\n"
783
784#define dhcprelay_trivial_usage \
785 "CLIENT_IFACE[,CLIENT_IFACE2]... SERVER_IFACE [SERVER_IP]"
786#define dhcprelay_full_usage "\n\n" \
787 "Relay DHCP requests between clients and server" \
788
789#define diff_trivial_usage \
790 "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2"
791#define diff_full_usage "\n\n" \
792 "Compare files line by line and output the differences between them.\n" \
793 "This implementation supports unified diffs only.\n" \
794 "\nOptions:" \
795 "\n -a Treat all files as text" \
796 "\n -b Ignore changes in the amount of whitespace" \
797 "\n -B Ignore changes whose lines are all blank" \
798 "\n -d Try hard to find a smaller set of changes" \
799 "\n -i Ignore case differences" \
800 "\n -L Use LABEL instead of the filename in the unified header" \
801 "\n -N Treat absent files as empty" \
802 "\n -q Output only whether files differ" \
803 "\n -r Recurse" \
804 "\n -S Start with FILE when comparing directories" \
805 "\n -T Make tabs line up by prefixing a tab when necessary" \
806 "\n -s Report when two files are the same" \
807 "\n -t Expand tabs to spaces in output" \
808 "\n -U Output LINES lines of context" \
809 "\n -w Ignore all whitespace" \
810
811#define dirname_trivial_usage \
812 "FILENAME"
813#define dirname_full_usage "\n\n" \
814 "Strip non-directory suffix from FILENAME"
815#define dirname_example_usage \
816 "$ dirname /tmp/foo\n" \
817 "/tmp\n" \
818 "$ dirname /tmp/foo/\n" \
819 "/tmp\n"
820
821#define dmesg_trivial_usage \
822 "[-c] [-n LEVEL] [-s SIZE]"
823#define dmesg_full_usage "\n\n" \
824 "Print or control the kernel ring buffer\n" \
825 "\nOptions:" \
826 "\n -c Clear ring buffer after printing" \
827 "\n -n LEVEL Set console logging level" \
828 "\n -s SIZE Buffer size" \
829
830#define dnsd_trivial_usage \
831 "[-dvs] [-c CONFFILE] [-t TTL_SEC] [-p PORT] [-i ADDR]"
832#define dnsd_full_usage "\n\n" \
833 "Small static DNS server daemon\n" \
834 "\nOptions:" \
835 "\n -c FILE Config file" \
836 "\n -t SEC TTL" \
837 "\n -p PORT Listen on PORT" \
838 "\n -i ADDR Listen on ADDR" \
839 "\n -d Daemonize" \
840 "\n -v Verbose" \
841 "\n -s Send successful replies only. Use this if you want" \
842 "\n to use /etc/resolv.conf with two nameserver lines:" \
843 "\n nameserver DNSD_SERVER" \
844 "\n nameserver NORNAL_DNS_SERVER" \
845
846#define dos2unix_trivial_usage \
847 "[-ud] [FILE]"
848#define dos2unix_full_usage "\n\n" \
849 "Convert FILE in-place from DOS to Unix format.\n" \
850 "When no file is given, use stdin/stdout.\n" \
851 "\nOptions:" \
852 "\n -u dos2unix" \
853 "\n -d unix2dos" \
854
855#define unix2dos_trivial_usage \
856 "[-ud] [FILE]"
857#define unix2dos_full_usage "\n\n" \
858 "Convert FILE in-place from Unix to DOS format.\n" \
859 "When no file is given, use stdin/stdout.\n" \
860 "\nOptions:" \
861 "\n -u dos2unix" \
862 "\n -d unix2dos" \
863
864#define dpkg_trivial_usage \
865 "[-ilCPru] [-F OPT] PACKAGE"
866#define dpkg_full_usage "\n\n" \
867 "Install, remove and manage Debian packages\n" \
868 "\nOptions:" \
869 IF_LONG_OPTS( \
870 "\n -i,--install Install the package" \
871 "\n -l,--list List of installed packages" \
872 "\n --configure Configure an unpackaged package" \
873 "\n -P,--purge Purge all files of a package" \
874 "\n -r,--remove Remove all but the configuration files for a package" \
875 "\n --unpack Unpack a package, but don't configure it" \
876 "\n --force-depends Ignore dependency problems" \
877 "\n --force-confnew Overwrite existing config files when installing" \
878 "\n --force-confold Keep old config files when installing" \
879 ) \
880 IF_NOT_LONG_OPTS( \
881 "\n -i Install the package" \
882 "\n -l List of installed packages" \
883 "\n -C Configure an unpackaged package" \
884 "\n -P Purge all files of a package" \
885 "\n -r Remove all but the configuration files for a package" \
886 "\n -u Unpack a package, but don't configure it" \
887 "\n -F depends Ignore dependency problems" \
888 "\n -F confnew Overwrite existing config files when installing" \
889 "\n -F confold Keep old config files when installing" \
890 )
891
892#define dpkg_deb_trivial_usage \
893 "[-cefxX] FILE [argument]"
894#define dpkg_deb_full_usage "\n\n" \
895 "Perform actions on Debian packages (.debs)\n" \
896 "\nOptions:" \
897 "\n -c List contents of filesystem tree" \
898 "\n -e Extract control files to [argument] directory" \
899 "\n -f Display control field name starting with [argument]" \
900 "\n -x Extract packages filesystem tree to directory" \
901 "\n -X Verbose extract" \
902
903#define dpkg_deb_example_usage \
904 "$ dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp\n"
905
906#define du_trivial_usage \
907 "[-aHLdclsx" IF_FEATURE_HUMAN_READABLE("hm") "k] [FILE]..."
908#define du_full_usage "\n\n" \
909 "Summarize disk space used for each FILE and/or directory.\n" \
910 "Disk space is printed in units of " \
911 IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("1024") \
912 IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K("512") \
913 " bytes.\n" \
914 "\nOptions:" \
915 "\n -a Show file sizes too" \
916 "\n -L Follow all symlinks" \
917 "\n -H Follow symlinks on command line" \
918 "\n -d N Limit output to directories (and files with -a) of depth < N" \
919 "\n -c Show grand total" \
920 "\n -l Count sizes many times if hard linked" \
921 "\n -s Display only a total for each argument" \
922 "\n -x Skip directories on different filesystems" \
923 IF_FEATURE_HUMAN_READABLE( \
924 "\n -h Sizes in human readable format (e.g., 1K 243M 2G )" \
925 "\n -m Sizes in megabytes" \
926 ) \
927 "\n -k Sizes in kilobytes" \
928 IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(" (default)") \
929
930#define du_example_usage \
931 "$ du\n" \
932 "16 ./CVS\n" \
933 "12 ./kernel-patches/CVS\n" \
934 "80 ./kernel-patches\n" \
935 "12 ./tests/CVS\n" \
936 "36 ./tests\n" \
937 "12 ./scripts/CVS\n" \
938 "16 ./scripts\n" \
939 "12 ./docs/CVS\n" \
940 "104 ./docs\n" \
941 "2417 .\n"
942
943#define dumpkmap_trivial_usage \
944 "> keymap"
945#define dumpkmap_full_usage "\n\n" \
946 "Print a binary keyboard translation table to stdout"
947#define dumpkmap_example_usage \
948 "$ dumpkmap > keymap\n"
949
950#define dumpleases_trivial_usage \
951 "[-r|-a] [-f LEASEFILE]"
952#define dumpleases_full_usage "\n\n" \
953 "Display DHCP leases granted by udhcpd\n" \
954 "\nOptions:" \
955 IF_LONG_OPTS( \
956 "\n -f,--file=FILE Lease file" \
957 "\n -r,--remaining Show remaining time" \
958 "\n -a,--absolute Show expiration time" \
959 ) \
960 IF_NOT_LONG_OPTS( \
961 "\n -f FILE Lease file" \
962 "\n -r Show remaining time" \
963 "\n -a Show expiration time" \
964 )
965
966/*
967#define e2fsck_trivial_usage \
968 "[-panyrcdfvstDFSV] [-b superblock] [-B blocksize] " \
969 "[-I inode_buffer_blocks] [-P process_inode_size] " \
970 "[-l|-L bad_blocks_file] [-C fd] [-j external_journal] " \
971 "[-E extended-options] device"
972#define e2fsck_full_usage "\n\n" \
973 "Check ext2/ext3 file system\n" \
974 "\nOptions:" \
975 "\n -p Automatic repair (no questions)" \
976 "\n -n Make no changes to the filesystem" \
977 "\n -y Assume 'yes' to all questions" \
978 "\n -c Check for bad blocks and add them to the badblock list" \
979 "\n -f Force checking even if filesystem is marked clean" \
980 "\n -v Verbose" \
981 "\n -b superblock Use alternative superblock" \
982 "\n -B blocksize Force blocksize when looking for superblock" \
983 "\n -j journal Set location of the external journal" \
984 "\n -l file Add to badblocks list" \
985 "\n -L file Set badblocks list" \
986*/
987
988#define echo_trivial_usage \
989 IF_FEATURE_FANCY_ECHO("[-neE] ") "[ARG]..."
990#define echo_full_usage "\n\n" \
991 "Print the specified ARGs to stdout" \
992 IF_FEATURE_FANCY_ECHO( "\n" \
993 "\nOptions:" \
994 "\n -n Suppress trailing newline" \
995 "\n -e Interpret backslash escapes (i.e., \\t=tab)" \
996 "\n -E Don't interpret backslash escapes (default)" \
997 )
998#define echo_example_usage \
999 "$ echo \"Erik is cool\"\n" \
1000 "Erik is cool\n" \
1001 IF_FEATURE_FANCY_ECHO("$ echo -e \"Erik\\nis\\ncool\"\n" \
1002 "Erik\n" \
1003 "is\n" \
1004 "cool\n" \
1005 "$ echo \"Erik\\nis\\ncool\"\n" \
1006 "Erik\\nis\\ncool\n")
1007
1008#define eject_trivial_usage \
1009 "[-t] [-T] [DEVICE]"
1010#define eject_full_usage "\n\n" \
1011 "Eject DEVICE or default /dev/cdrom\n" \
1012 "\nOptions:" \
1013 IF_FEATURE_EJECT_SCSI( \
1014 "\n -s SCSI device" \
1015 ) \
1016 "\n -t Close tray" \
1017 "\n -T Open/close tray (toggle)" \
1018
1019#define ed_trivial_usage ""
1020#define ed_full_usage ""
1021
1022#define env_trivial_usage \
1023 "[-iu] [-] [name=value]... [PROG ARGS]"
1024#define env_full_usage "\n\n" \
1025 "Print the current environment or run PROG after setting up\n" \
1026 "the specified environment\n" \
1027 "\nOptions:" \
1028 "\n -, -i Start with an empty environment" \
1029 "\n -u Remove variable from the environment" \
1030
1031#define ether_wake_trivial_usage \
1032 "[-b] [-i iface] [-p aa:bb:cc:dd[:ee:ff]] MAC"
1033#define ether_wake_full_usage "\n\n" \
1034 "Send a magic packet to wake up sleeping machines.\n" \
1035 "MAC must be a station address (00:11:22:33:44:55) or\n" \
1036 "a hostname with a known 'ethers' entry.\n" \
1037 "\nOptions:" \
1038 "\n -b Send wake-up packet to the broadcast address" \
1039 "\n -i iface Interface to use (default eth0)" \
1040 "\n -p pass Append four or six byte password PW to the packet" \
1041
1042#define expand_trivial_usage \
1043 "[-i] [-t N] [FILE]..."
1044#define expand_full_usage "\n\n" \
1045 "Convert tabs to spaces, writing to stdout\n" \
1046 "\nOptions:" \
1047 IF_FEATURE_EXPAND_LONG_OPTIONS( \
1048 "\n -i,--initial Don't convert tabs after non blanks" \
1049 "\n -t,--tabs=N Tabstops every N chars" \
1050 ) \
1051 IF_NOT_FEATURE_EXPAND_LONG_OPTIONS( \
1052 "\n -i Don't convert tabs after non blanks" \
1053 "\n -t Tabstops every N chars" \
1054 )
1055
1056#define expr_trivial_usage \
1057 "EXPRESSION"
1058#define expr_full_usage "\n\n" \
1059 "Print the value of EXPRESSION to stdout\n" \
1060 "\n" \
1061 "EXPRESSION may be:\n" \
1062 " ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2\n" \
1063 " ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0\n" \
1064 " ARG1 < ARG2 1 if ARG1 is less than ARG2, else 0. Similarly:\n" \
1065 " ARG1 <= ARG2\n" \
1066 " ARG1 = ARG2\n" \
1067 " ARG1 != ARG2\n" \
1068 " ARG1 >= ARG2\n" \
1069 " ARG1 > ARG2\n" \
1070 " ARG1 + ARG2 Sum of ARG1 and ARG2. Similarly:\n" \
1071 " ARG1 - ARG2\n" \
1072 " ARG1 * ARG2\n" \
1073 " ARG1 / ARG2\n" \
1074 " ARG1 % ARG2\n" \
1075 " STRING : REGEXP Anchored pattern match of REGEXP in STRING\n" \
1076 " match STRING REGEXP Same as STRING : REGEXP\n" \
1077 " substr STRING POS LENGTH Substring of STRING, POS counted from 1\n" \
1078 " index STRING CHARS Index in STRING where any CHARS is found, or 0\n" \
1079 " length STRING Length of STRING\n" \
1080 " quote TOKEN Interpret TOKEN as a string, even if\n" \
1081 " it is a keyword like 'match' or an\n" \
1082 " operator like '/'\n" \
1083 " (EXPRESSION) Value of EXPRESSION\n" \
1084 "\n" \
1085 "Beware that many operators need to be escaped or quoted for shells.\n" \
1086 "Comparisons are arithmetic if both ARGs are numbers, else\n" \
1087 "lexicographical. Pattern matches return the string matched between\n" \
1088 "\\( and \\) or null; if \\( and \\) are not used, they return the number\n" \
1089 "of characters matched or 0."
1090
1091#define fakeidentd_trivial_usage \
1092 "[-fiw] [-b ADDR] [STRING]"
1093#define fakeidentd_full_usage "\n\n" \
1094 "Provide fake ident (auth) service\n" \
1095 "\nOptions:" \
1096 "\n -f Run in foreground" \
1097 "\n -i Inetd mode" \
1098 "\n -w Inetd 'wait' mode" \
1099 "\n -b ADDR Bind to specified address" \
1100 "\n STRING Ident answer string (default: nobody)" \
1101
1102#define false_trivial_usage \
1103 ""
1104#define false_full_usage "\n\n" \
1105 "Return an exit code of FALSE (1)"
1106
1107#define false_example_usage \
1108 "$ false\n" \
1109 "$ echo $?\n" \
1110 "1\n"
1111
1112#define fbsplash_trivial_usage \
1113 "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
1114#define fbsplash_full_usage "\n\n" \
1115 "Options:" \
1116 "\n -s Image" \
1117 "\n -c Hide cursor" \
1118 "\n -d Framebuffer device (default /dev/fb0)" \
1119 "\n -i Config file (var=value):" \
1120 "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT" \
1121 "\n BAR_R,BAR_G,BAR_B" \
1122 "\n -f Control pipe (else exit after drawing image)" \
1123 "\n commands: 'NN' (% for progress bar) or 'exit'" \
1124
1125#define fbset_trivial_usage \
1126 "[OPTIONS] [MODE]"
1127#define fbset_full_usage "\n\n" \
1128 "Show and modify frame buffer settings"
1129
1130#define fbset_example_usage \
1131 "$ fbset\n" \
1132 "mode \"1024x768-76\"\n" \
1133 " # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz\n" \
1134 " geometry 1024 768 1024 768 16\n" \
1135 " timings 12714 128 32 16 4 128 4\n" \
1136 " accel false\n" \
1137 " rgba 5/11,6/5,5/0,0/0\n" \
1138 "endmode\n"
1139
1140#define fdflush_trivial_usage \
1141 "DEVICE"
1142#define fdflush_full_usage "\n\n" \
1143 "Force floppy disk drive to detect disk change"
1144
1145#define fdformat_trivial_usage \
1146 "[-n] DEVICE"
1147#define fdformat_full_usage "\n\n" \
1148 "Format floppy disk\n" \
1149 "\nOptions:" \
1150 "\n -n Don't verify after format" \
1151
1152/* Looks like someone forgot to add this to config system */
1153#ifndef ENABLE_FEATURE_FDISK_BLKSIZE
1154# define ENABLE_FEATURE_FDISK_BLKSIZE 0
1155# define IF_FEATURE_FDISK_BLKSIZE(a)
1156#endif
1157
1158#define fdisk_trivial_usage \
1159 "[-ul" IF_FEATURE_FDISK_BLKSIZE("s") "] " \
1160 "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK"
1161#define fdisk_full_usage "\n\n" \
1162 "Change partition table\n" \
1163 "\nOptions:" \
1164 "\n -u Start and End are in sectors (instead of cylinders)" \
1165 "\n -l Show partition table for each DISK, then exit" \
1166 IF_FEATURE_FDISK_BLKSIZE( \
1167 "\n -s Show partition sizes in kb for each DISK, then exit" \
1168 ) \
1169 "\n -b 2048 (for certain MO disks) use 2048-byte sectors" \
1170 "\n -C CYLINDERS Set number of cylinders/heads/sectors" \
1171 "\n -H HEADS" \
1172 "\n -S SECTORS" \
1173
1174#define fgconsole_trivial_usage \
1175 ""
1176#define fgconsole_full_usage "\n\n" \
1177 "Get active console"
1178
1179#define findfs_trivial_usage \
1180 "LABEL=label or UUID=uuid"
1181#define findfs_full_usage "\n\n" \
1182 "Find a filesystem device based on a label or UUID"
1183#define findfs_example_usage \
1184 "$ findfs LABEL=MyDevice"
1185
1186#define flash_lock_trivial_usage \
1187 "MTD_DEVICE OFFSET SECTORS"
1188#define flash_lock_full_usage "\n\n" \
1189 "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n" \
1190 "will be locked, regardless of the value of OFFSET"
1191
1192#define flash_unlock_trivial_usage \
1193 "MTD_DEVICE"
1194#define flash_unlock_full_usage "\n\n" \
1195 "Unlock an MTD device"
1196
1197#define flash_eraseall_trivial_usage \
1198 "[-jq] MTD_DEVICE"
1199#define flash_eraseall_full_usage "\n\n" \
1200 "Erase an MTD device\n" \
1201 "\nOptions:" \
1202 "\n -j Format the device for jffs2" \
1203 "\n -q Don't display progress messages" \
1204
1205#define flashcp_trivial_usage \
1206 "-v FILE MTD_DEVICE"
1207#define flashcp_full_usage "\n\n" \
1208 "Copy an image to MTD device\n" \
1209 "\nOptions:" \
1210 "\n -v Verbose" \
1211
1212#define flock_trivial_usage \
1213 "[-sxun] FD|{FILE [-c] PROG ARGS}"
1214#define flock_full_usage "\n\n" \
1215 "[Un]lock file descriptor, or lock FILE, run PROG\n" \
1216 "\nOptions:" \
1217 "\n -s Shared lock" \
1218 "\n -x Exclusive lock (default)" \
1219 "\n -u Unlock FD" \
1220 "\n -n Fail rather than wait" \
1221
1222#define fold_trivial_usage \
1223 "[-bs] [-w WIDTH] [FILE]..."
1224#define fold_full_usage "\n\n" \
1225 "Wrap input lines in each FILE (or stdin), writing to stdout\n" \
1226 "\nOptions:" \
1227 "\n -b Count bytes rather than columns" \
1228 "\n -s Break at spaces" \
1229 "\n -w Use WIDTH columns instead of 80" \
1230
1231#define free_trivial_usage \
1232 "" IF_DESKTOP("[-b/k/m/g]")
1233#define free_full_usage "\n\n" \
1234 "Display the amount of free and used system memory"
1235#define free_example_usage \
1236 "$ free\n" \
1237 " total used free shared buffers\n" \
1238 " Mem: 257628 248724 8904 59644 93124\n" \
1239 " Swap: 128516 8404 120112\n" \
1240 "Total: 386144 257128 129016\n" \
1241
1242#define freeramdisk_trivial_usage \
1243 "DEVICE"
1244#define freeramdisk_full_usage "\n\n" \
1245 "Free all memory used by the specified ramdisk"
1246#define freeramdisk_example_usage \
1247 "$ freeramdisk /dev/ram2\n"
1248
1249#define fsck_trivial_usage \
1250 "[-ANPRTV] [-C FD] [-t FSTYPE] [FS_OPTS] [BLOCKDEV]..."
1251#define fsck_full_usage "\n\n" \
1252 "Check and repair filesystems\n" \
1253 "\nOptions:" \
1254 "\n -A Walk /etc/fstab and check all filesystems" \
1255 "\n -N Don't execute, just show what would be done" \
1256 "\n -P With -A, check filesystems in parallel" \
1257 "\n -R With -A, skip the root filesystem" \
1258 "\n -T Don't show title on startup" \
1259 "\n -V Verbose" \
1260 "\n -C n Write status information to specified filedescriptor" \
1261 "\n -t TYPE List of filesystem types to check" \
1262
1263#define fsck_minix_trivial_usage \
1264 "[-larvsmf] BLOCKDEV"
1265#define fsck_minix_full_usage "\n\n" \
1266 "Check MINIX filesystem\n" \
1267 "\nOptions:" \
1268 "\n -l List all filenames" \
1269 "\n -r Perform interactive repairs" \
1270 "\n -a Perform automatic repairs" \
1271 "\n -v Verbose" \
1272 "\n -s Output superblock information" \
1273 "\n -m Show \"mode not cleared\" warnings" \
1274 "\n -f Force file system check" \
1275
1276#define ftpget_trivial_usage \
1277 "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE"
1278#define ftpget_full_usage "\n\n" \
1279 "Retrieve a remote file via FTP\n" \
1280 "\nOptions:" \
1281 IF_FEATURE_FTPGETPUT_LONG_OPTIONS( \
1282 "\n -c,--continue Continue previous transfer" \
1283 "\n -v,--verbose Verbose" \
1284 "\n -u,--username Username" \
1285 "\n -p,--password Password" \
1286 "\n -P,--port Port number" \
1287 ) \
1288 IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( \
1289 "\n -c Continue previous transfer" \
1290 "\n -v Verbose" \
1291 "\n -u Username" \
1292 "\n -p Password" \
1293 "\n -P Port number" \
1294 )
1295
1296#define ftpput_trivial_usage \
1297 "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE"
1298#define ftpput_full_usage "\n\n" \
1299 "Store a local file on a remote machine via FTP\n" \
1300 "\nOptions:" \
1301 IF_FEATURE_FTPGETPUT_LONG_OPTIONS( \
1302 "\n -v,--verbose Verbose" \
1303 "\n -u,--username Username" \
1304 "\n -p,--password Password" \
1305 "\n -P,--port Port number" \
1306 ) \
1307 IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( \
1308 "\n -v Verbose" \
1309 "\n -u Username" \
1310 "\n -p Password" \
1311 "\n -P Port number" \
1312 )
1313
1314#define fuser_trivial_usage \
1315 "[OPTIONS] FILE or PORT/PROTO"
1316#define fuser_full_usage "\n\n" \
1317 "Find processes which use FILEs or PORTs\n" \
1318 "\nOptions:" \
1319 "\n -m Find processes which use same fs as FILEs" \
1320 "\n -4,-6 Search only IPv4/IPv6 space" \
1321 "\n -s Don't display PIDs" \
1322 "\n -k Kill found processes" \
1323 "\n -SIGNAL Signal to send (default: KILL)" \
1324
1325#define getenforce_trivial_usage NOUSAGE_STR
1326#define getenforce_full_usage ""
1327
1328#define getopt_trivial_usage \
1329 "[OPTIONS]"
1330#define getopt_full_usage "\n\n" \
1331 "Options:" \
1332 IF_LONG_OPTS( \
1333 "\n -a,--alternative Allow long options starting with single -" \
1334 "\n -l,--longoptions=longopts Long options to be recognized" \
1335 "\n -n,--name=progname The name under which errors are reported" \
1336 "\n -o,--options=optstring Short options to be recognized" \
1337 "\n -q,--quiet Disable error reporting by getopt(3)" \
1338 "\n -Q,--quiet-output No normal output" \
1339 "\n -s,--shell=shell Set shell quoting conventions" \
1340 "\n -T,--test Test for getopt(1) version" \
1341 "\n -u,--unquoted Don't quote the output" \
1342 ) \
1343 IF_NOT_LONG_OPTS( \
1344 "\n -a Allow long options starting with single -" \
1345 "\n -l longopts Long options to be recognized" \
1346 "\n -n progname The name under which errors are reported" \
1347 "\n -o optstring Short options to be recognized" \
1348 "\n -q Disable error reporting by getopt(3)" \
1349 "\n -Q No normal output" \
1350 "\n -s shell Set shell quoting conventions" \
1351 "\n -T Test for getopt(1) version" \
1352 "\n -u Don't quote the output" \
1353 )
1354#define getopt_example_usage \
1355 "$ cat getopt.test\n" \
1356 "#!/bin/sh\n" \
1357 "GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \\\n" \
1358 " -n 'example.busybox' -- \"$@\"`\n" \
1359 "if [ $? != 0 ]; then exit 1; fi\n" \
1360 "eval set -- \"$GETOPT\"\n" \
1361 "while true; do\n" \
1362 " case $1 in\n" \
1363 " -a|--a-long) echo \"Option a\"; shift;;\n" \
1364 " -b|--b-long) echo \"Option b, argument '$2'\"; shift 2;;\n" \
1365 " -c|--c-long)\n" \
1366 " case \"$2\" in\n" \
1367 " \"\") echo \"Option c, no argument\"; shift 2;;\n" \
1368 " *) echo \"Option c, argument '$2'\"; shift 2;;\n" \
1369 " esac;;\n" \
1370 " --) shift; break;;\n" \
1371 " *) echo \"Internal error!\"; exit 1;;\n" \
1372 " esac\n" \
1373 "done\n"
1374
1375#define getsebool_trivial_usage \
1376 "-a or getsebool boolean..."
1377#define getsebool_full_usage "\n\n" \
1378 " -a Show all selinux booleans"
1379
1380#define gunzip_trivial_usage \
1381 "[-cft] [FILE]..."
1382#define gunzip_full_usage "\n\n" \
1383 "Decompress FILEs (or stdin)\n" \
1384 "\nOptions:" \
1385 "\n -c Write to stdout" \
1386 "\n -f Force" \
1387 "\n -t Test file integrity" \
1388
1389#define gunzip_example_usage \
1390 "$ ls -la /tmp/BusyBox*\n" \
1391 "-rw-rw-r-- 1 andersen andersen 557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz\n" \
1392 "$ gunzip /tmp/BusyBox-0.43.tar.gz\n" \
1393 "$ ls -la /tmp/BusyBox*\n" \
1394 "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
1395
1396#define gzip_trivial_usage \
1397 "[-cfd] [FILE]..."
1398#define gzip_full_usage "\n\n" \
1399 "Compress FILEs (or stdin)\n" \
1400 "\nOptions:" \
1401 "\n -d Decompress" \
1402 "\n -c Write to stdout" \
1403 "\n -f Force" \
1404
1405#define gzip_example_usage \
1406 "$ ls -la /tmp/busybox*\n" \
1407 "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/busybox.tar\n" \
1408 "$ gzip /tmp/busybox.tar\n" \
1409 "$ ls -la /tmp/busybox*\n" \
1410 "-rw-rw-r-- 1 andersen andersen 554058 Apr 14 17:49 /tmp/busybox.tar.gz\n"
1411
1412#define hdparm_trivial_usage \
1413 "[OPTIONS] [DEVICE]"
1414#define hdparm_full_usage "\n\n" \
1415 "Options:" \
1416 "\n -a Get/set fs readahead" \
1417 "\n -A Set drive read-lookahead flag (0/1)" \
1418 "\n -b Get/set bus state (0 == off, 1 == on, 2 == tristate)" \
1419 "\n -B Set Advanced Power Management setting (1-255)" \
1420 "\n -c Get/set IDE 32-bit IO setting" \
1421 "\n -C Check IDE power mode status" \
1422 IF_FEATURE_HDPARM_HDIO_GETSET_DMA( \
1423 "\n -d Get/set using_dma flag") \
1424 "\n -D Enable/disable drive defect-mgmt" \
1425 "\n -f Flush buffer cache for device on exit" \
1426 "\n -g Display drive geometry" \
1427 "\n -h Display terse usage information" \
1428 IF_FEATURE_HDPARM_GET_IDENTITY( \
1429 "\n -i Display drive identification") \
1430 IF_FEATURE_HDPARM_GET_IDENTITY( \
1431 "\n -I Detailed/current information directly from drive") \
1432 "\n -k Get/set keep_settings_over_reset flag (0/1)" \
1433 "\n -K Set drive keep_features_over_reset flag (0/1)" \
1434 "\n -L Set drive doorlock (0/1) (removable harddisks only)" \
1435 "\n -m Get/set multiple sector count" \
1436 "\n -n Get/set ignore-write-errors flag (0/1)" \
1437 "\n -p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)" \
1438 "\n -P Set drive prefetch count" \
1439/* "\n -q Change next setting quietly" - not supported ib bbox */ \
1440 "\n -Q Get/set DMA tagged-queuing depth (if supported)" \
1441 "\n -r Get/set readonly flag (DANGEROUS to set)" \
1442 IF_FEATURE_HDPARM_HDIO_SCAN_HWIF( \
1443 "\n -R Register an IDE interface (DANGEROUS)") \
1444 "\n -S Set standby (spindown) timeout" \
1445 "\n -t Perform device read timings" \
1446 "\n -T Perform cache read timings" \
1447 "\n -u Get/set unmaskirq flag (0/1)" \
1448 IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF( \
1449 "\n -U Unregister an IDE interface (DANGEROUS)") \
1450 "\n -v Defaults; same as -mcudkrag for IDE drives" \
1451 "\n -V Display program version and exit immediately" \
1452 IF_FEATURE_HDPARM_HDIO_DRIVE_RESET( \
1453 "\n -w Perform device reset (DANGEROUS)") \
1454 "\n -W Set drive write-caching flag (0/1) (DANGEROUS)" \
1455 IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( \
1456 "\n -x Tristate device for hotswap (0/1) (DANGEROUS)") \
1457 "\n -X Set IDE xfer mode (DANGEROUS)" \
1458 "\n -y Put IDE drive in standby mode" \
1459 "\n -Y Put IDE drive to sleep" \
1460 "\n -Z Disable Seagate auto-powersaving mode" \
1461 "\n -z Reread partition table" \
1462
1463#define head_trivial_usage \
1464 "[OPTIONS] [FILE]..."
1465#define head_full_usage "\n\n" \
1466 "Print first 10 lines of each FILE (or stdin) to stdout.\n" \
1467 "With more than one FILE, precede each with a filename header.\n" \
1468 "\nOptions:" \
1469 "\n -n N[kbm] Print first N lines" \
1470 IF_FEATURE_FANCY_HEAD( \
1471 "\n -c N[kbm] Print first N bytes" \
1472 "\n -q Never print headers" \
1473 "\n -v Always print headers" \
1474 ) \
1475 "\n" \
1476 "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)." \
1477
1478#define head_example_usage \
1479 "$ head -n 2 /etc/passwd\n" \
1480 "root:x:0:0:root:/root:/bin/bash\n" \
1481 "daemon:x:1:1:daemon:/usr/sbin:/bin/sh\n"
1482
1483#define tail_trivial_usage \
1484 "[OPTIONS] [FILE]..."
1485#define tail_full_usage "\n\n" \
1486 "Print last 10 lines of each FILE (or stdin) to stdout.\n" \
1487 "With more than one FILE, precede each with a filename header.\n" \
1488 "\nOptions:" \
1489 "\n -f Print data as file grows" \
1490 IF_FEATURE_FANCY_TAIL( \
1491 "\n -s SECONDS Wait SECONDS between reads with -f" \
1492 ) \
1493 "\n -n N[kbm] Print last N lines" \
1494 IF_FEATURE_FANCY_TAIL( \
1495 "\n -c N[kbm] Print last N bytes" \
1496 "\n -q Never print headers" \
1497 "\n -v Always print headers" \
1498 "\n" \
1499 "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)." \
1500 "\nIf N starts with a '+', output begins with the Nth item from the start" \
1501 "\nof each file, not from the end." \
1502 ) \
1503
1504#define tail_example_usage \
1505 "$ tail -n 1 /etc/resolv.conf\n" \
1506 "nameserver 10.0.0.1\n"
1507
1508#define hexdump_trivial_usage \
1509 "[-bcCdefnosvx" IF_FEATURE_HEXDUMP_REVERSE("R") "] [FILE]..."
1510#define hexdump_full_usage "\n\n" \
1511 "Display FILEs (or stdin) in a user specified format\n" \
1512 "\nOptions:" \
1513 "\n -b One-byte octal display" \
1514 "\n -c One-byte character display" \
1515 "\n -C Canonical hex+ASCII, 16 bytes per line" \
1516 "\n -d Two-byte decimal display" \
1517 "\n -e FORMAT_STRING" \
1518 "\n -f FORMAT_FILE" \
1519 "\n -n LENGTH Interpret only LENGTH bytes of input" \
1520 "\n -o Two-byte octal display" \
1521 "\n -s OFFSET Skip OFFSET bytes" \
1522 "\n -v Display all input data" \
1523 "\n -x Two-byte hexadecimal display" \
1524 IF_FEATURE_HEXDUMP_REVERSE( \
1525 "\n -R Reverse of 'hexdump -Cv'") \
1526
1527#define hd_trivial_usage \
1528 "FILE..."
1529#define hd_full_usage "\n\n" \
1530 "hd is an alias for hexdump -C"
1531
1532#define hostid_trivial_usage \
1533 ""
1534#define hostid_full_usage "\n\n" \
1535 "Print out a unique 32-bit identifier for the machine"
1536
1537#define hostname_trivial_usage \
1538 "[OPTIONS] [HOSTNAME | -F FILE]"
1539#define hostname_full_usage "\n\n" \
1540 "Get or set hostname or DNS domain name\n" \
1541 "\nOptions:" \
1542 "\n -s Short" \
1543 "\n -i Addresses for the hostname" \
1544 "\n -d DNS domain name" \
1545 "\n -f Fully qualified domain name" \
1546 "\n -F FILE Use FILE's content as hostname" \
1547
1548#define hostname_example_usage \
1549 "$ hostname\n" \
1550 "sage\n"
1551
1552#define dnsdomainname_trivial_usage NOUSAGE_STR
1553#define dnsdomainname_full_usage ""
1554
1555#define httpd_trivial_usage \
1556 "[-ifv[v]]" \
1557 " [-c CONFFILE]" \
1558 " [-p [IP:]PORT]" \
1559 IF_FEATURE_HTTPD_SETUID(" [-u USER[:GRP]]") \
1560 IF_FEATURE_HTTPD_BASIC_AUTH(" [-r REALM]") \
1561 " [-h HOME]\n" \
1562 "or httpd -d/-e" IF_FEATURE_HTTPD_AUTH_MD5("/-m") " STRING"
1563#define httpd_full_usage "\n\n" \
1564 "Listen for incoming HTTP requests\n" \
1565 "\nOptions:" \
1566 "\n -i Inetd mode" \
1567 "\n -f Don't daemonize" \
1568 "\n -v[v] Verbose" \
1569 "\n -p [IP:]PORT Bind to IP:PORT (default *:80)" \
1570 IF_FEATURE_HTTPD_SETUID( \
1571 "\n -u USER[:GRP] Set uid/gid after binding to port") \
1572 IF_FEATURE_HTTPD_BASIC_AUTH( \
1573 "\n -r REALM Authentication Realm for Basic Authentication") \
1574 "\n -h HOME Home directory (default .)" \
1575 "\n -c FILE Configuration file (default {/etc,HOME}/httpd.conf)" \
1576 IF_FEATURE_HTTPD_AUTH_MD5( \
1577 "\n -m STRING MD5 crypt STRING") \
1578 "\n -e STRING HTML encode STRING" \
1579 "\n -d STRING URL decode STRING" \
1580
1581#define id_trivial_usage \
1582 "[OPTIONS] [USER]"
1583#define id_full_usage "\n\n" \
1584 "Print information about USER or the current user\n" \
1585 "\nOptions:" \
1586 IF_SELINUX( \
1587 "\n -Z Security context" \
1588 ) \
1589 "\n -u User ID" \
1590 "\n -g Group ID" \
1591 "\n -G Supplementary group IDs" \
1592 "\n -n Print names instead of numbers" \
1593 "\n -r Print real ID instead of effective ID" \
1594
1595#define id_example_usage \
1596 "$ id\n" \
1597 "uid=1000(andersen) gid=1000(andersen)\n"
1598
1599#define ifconfig_trivial_usage \
1600 IF_FEATURE_IFCONFIG_STATUS("[-a]") " interface [address]"
1601#define ifconfig_full_usage "\n\n" \
1602 "Configure a network interface\n" \
1603 "\nOptions:" \
1604 "\n" \
1605 IF_FEATURE_IPV6( \
1606 " [add ADDRESS[/PREFIXLEN]]\n") \
1607 IF_FEATURE_IPV6( \
1608 " [del ADDRESS[/PREFIXLEN]]\n") \
1609 " [[-]broadcast [ADDRESS]] [[-]pointopoint [ADDRESS]]\n" \
1610 " [netmask ADDRESS] [dstaddr ADDRESS]\n" \
1611 IF_FEATURE_IFCONFIG_SLIP( \
1612 " [outfill NN] [keepalive NN]\n") \
1613 " " IF_FEATURE_IFCONFIG_HW("[hw ether" IF_FEATURE_HWIB("|infiniband")" ADDRESS] ") "[metric NN] [mtu NN]\n" \
1614 " [[-]trailers] [[-]arp] [[-]allmulti]\n" \
1615 " [multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]\n" \
1616 IF_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ( \
1617 " [mem_start NN] [io_addr NN] [irq NN]\n") \
1618 " [up|down] ..."
1619
1620#define ifenslave_trivial_usage \
1621 "[-cdf] MASTER_IFACE SLAVE_IFACE..."
1622#define ifenslave_full_usage "\n\n" \
1623 "Configure network interfaces for parallel routing\n" \
1624 "\nOptions:" \
1625 "\n -c,--change-active Change active slave" \
1626 "\n -d,--detach Remove slave interface from bonding device" \
1627 "\n -f,--force Force, even if interface is not Ethernet" \
1628/* "\n -r,--receive-slave Create a receive-only slave" */
1629
1630#define ifenslave_example_usage \
1631 "To create a bond device, simply follow these three steps:\n" \
1632 "- ensure that the required drivers are properly loaded:\n" \
1633 " # modprobe bonding ; modprobe <3c59x|eepro100|pcnet32|tulip|...>\n" \
1634 "- assign an IP address to the bond device:\n" \
1635 " # ifconfig bond0 <addr> netmask <mask> broadcast <bcast>\n" \
1636 "- attach all the interfaces you need to the bond device:\n" \
1637 " # ifenslave bond0 eth0 eth1 eth2\n" \
1638 " If bond0 didn't have a MAC address, it will take eth0's. Then, all\n" \
1639 " interfaces attached AFTER this assignment will get the same MAC addr.\n\n" \
1640 " To detach a dead interface without setting the bond device down:\n" \
1641 " # ifenslave -d bond0 eth1\n\n" \
1642 " To set the bond device down and automatically release all the slaves:\n" \
1643 " # ifconfig bond0 down\n\n" \
1644 " To change active slave:\n" \
1645 " # ifenslave -c bond0 eth0\n" \
1646
1647#define ifplugd_trivial_usage \
1648 "[OPTIONS]"
1649#define ifplugd_full_usage "\n\n" \
1650 "Network interface plug detection daemon\n" \
1651 "\nOptions:" \
1652 "\n -n Don't daemonize" \
1653 "\n -s Don't log to syslog" \
1654 "\n -i IFACE Interface" \
1655 "\n -f/-F Treat link detection error as link down/link up" \
1656 "\n (otherwise exit on error)" \
1657 "\n -a Don't up interface at each link probe" \
1658 "\n -M Monitor creation/destruction of interface" \
1659 "\n (otherwise it must exist)" \
1660 "\n -r PROG Script to run" \
1661 "\n -x ARG Extra argument for script" \
1662 "\n -I Don't exit on nonzero exit code from script" \
1663 "\n -p Don't run script on daemon startup" \
1664 "\n -q Don't run script on daemon quit" \
1665 "\n -l Run script on startup even if no cable is detected" \
1666 "\n -t SECS Poll time in seconds" \
1667 "\n -u SECS Delay before running script after link up" \
1668 "\n -d SECS Delay after link down" \
1669 "\n -m MODE API mode (mii, priv, ethtool, wlan, iff, auto)" \
1670 "\n -k Kill running daemon" \
1671
1672#define ifup_trivial_usage \
1673 "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
1674#define ifup_full_usage "\n\n" \
1675 "Options:" \
1676 "\n -a De/configure all interfaces automatically" \
1677 "\n -i FILE Use FILE for interface definitions" \
1678 "\n -n Print out what would happen, but don't do it" \
1679 IF_FEATURE_IFUPDOWN_MAPPING( \
1680 "\n (note: doesn't disable mappings)" \
1681 "\n -m Don't run any mappings" \
1682 ) \
1683 "\n -v Print out what would happen before doing it" \
1684 "\n -f Force de/configuration" \
1685
1686#define ifdown_trivial_usage \
1687 "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
1688#define ifdown_full_usage "\n\n" \
1689 "Options:" \
1690 "\n -a De/configure all interfaces automatically" \
1691 "\n -i FILE Use FILE for interface definitions" \
1692 "\n -n Print out what would happen, but don't do it" \
1693 IF_FEATURE_IFUPDOWN_MAPPING( \
1694 "\n (note: doesn't disable mappings)" \
1695 "\n -m Don't run any mappings" \
1696 ) \
1697 "\n -v Print out what would happen before doing it" \
1698 "\n -f Force de/configuration" \
1699
1700#define inetd_trivial_usage \
1701 "[-fe] [-q N] [-R N] [CONFFILE]"
1702#define inetd_full_usage "\n\n" \
1703 "Listen for network connections and launch programs\n" \
1704 "\nOptions:" \
1705 "\n -f Run in foreground" \
1706 "\n -e Log to stderr" \
1707 "\n -q N Socket listen queue (default: 128)" \
1708 "\n -R N Pause services after N connects/min" \
1709 "\n (default: 0 - disabled)" \
1710
1711#define inotifyd_trivial_usage \
1712 "PROG FILE1[:MASK]..."
1713#define inotifyd_full_usage "\n\n" \
1714 "Run PROG on filesystem changes." \
1715 "\nWhen a filesystem event matching MASK occurs on FILEn," \
1716 "\nPROG ACTUAL_EVENTS FILEn [SUBFILE] is run." \
1717 "\nEvents:" \
1718 "\n a File is accessed" \
1719 "\n c File is modified" \
1720 "\n e Metadata changed" \
1721 "\n w Writable file is closed" \
1722 "\n 0 Unwritable file is closed" \
1723 "\n r File is opened" \
1724 "\n D File is deleted" \
1725 "\n M File is moved" \
1726 "\n u Backing fs is unmounted" \
1727 "\n o Event queue overflowed" \
1728 "\n x File can't be watched anymore" \
1729 "\nIf watching a directory:" \
1730 "\n m Subfile is moved into dir" \
1731 "\n y Subfile is moved out of dir" \
1732 "\n n Subfile is created" \
1733 "\n d Subfile is deleted" \
1734 "\n" \
1735 "\ninotifyd waits for PROG to exit." \
1736 "\nWhen x event happens for all FILEs, inotifyd exits." \
1737
1738/* -v, -b, -c are ignored */
1739#define install_trivial_usage \
1740 "[-cdDsp] [-o USER] [-g GRP] [-m MODE] [SOURCE]... DEST"
1741#define install_full_usage "\n\n" \
1742 "Copy files and set attributes\n" \
1743 "\nOptions:" \
1744 "\n -c Just copy (default)" \
1745 "\n -d Create directories" \
1746 "\n -D Create leading target directories" \
1747 "\n -s Strip symbol table" \
1748 "\n -p Preserve date" \
1749 "\n -o USER Set ownership" \
1750 "\n -g GRP Set group ownership" \
1751 "\n -m MODE Set permissions" \
1752 IF_SELINUX( \
1753 "\n -Z Set security context" \
1754 )
1755
1756/* would need to make the " | " optional depending on more than one selected: */
1757#define ip_trivial_usage \
1758 "[OPTIONS] {" \
1759 IF_FEATURE_IP_ADDRESS("address | ") \
1760 IF_FEATURE_IP_ROUTE("route | ") \
1761 IF_FEATURE_IP_LINK("link | ") \
1762 IF_FEATURE_IP_TUNNEL("tunnel | ") \
1763 IF_FEATURE_IP_RULE("rule") \
1764 "} {COMMAND}"
1765#define ip_full_usage "\n\n" \
1766 "ip [OPTIONS] OBJECT {COMMAND}\n" \
1767 "where OBJECT := {" \
1768 IF_FEATURE_IP_ADDRESS("address | ") \
1769 IF_FEATURE_IP_ROUTE("route | ") \
1770 IF_FEATURE_IP_LINK("link | ") \
1771 IF_FEATURE_IP_TUNNEL("tunnel | ") \
1772 IF_FEATURE_IP_RULE("rule") \
1773 "}\n" \
1774 "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }" \
1775
1776#define ipaddr_trivial_usage \
1777 "{ {add|del} IFADDR dev STRING | {show|flush}\n" \
1778 " [dev STRING] [to PREFIX] }"
1779#define ipaddr_full_usage "\n\n" \
1780 "ipaddr {add|delete} IFADDR dev STRING\n" \
1781 "ipaddr {show|flush} [dev STRING] [scope SCOPE-ID]\n" \
1782 " [to PREFIX] [label PATTERN]\n" \
1783 " IFADDR := PREFIX | ADDR peer PREFIX\n" \
1784 " [broadcast ADDR] [anycast ADDR]\n" \
1785 " [label STRING] [scope SCOPE-ID]\n" \
1786 " SCOPE-ID := [host | link | global | NUMBER]" \
1787
1788#define ipcalc_trivial_usage \
1789 "[OPTIONS] ADDRESS[[/]NETMASK] [NETMASK]"
1790#define ipcalc_full_usage "\n\n" \
1791 "Calculate IP network settings from a IP address\n" \
1792 "\nOptions:" \
1793 IF_FEATURE_IPCALC_LONG_OPTIONS( \
1794 "\n -b,--broadcast Display calculated broadcast address" \
1795 "\n -n,--network Display calculated network address" \
1796 "\n -m,--netmask Display default netmask for IP" \
1797 IF_FEATURE_IPCALC_FANCY( \
1798 "\n -p,--prefix Display the prefix for IP/NETMASK" \
1799 "\n -h,--hostname Display first resolved host name" \
1800 "\n -s,--silent Don't ever display error messages" \
1801 ) \
1802 ) \
1803 IF_NOT_FEATURE_IPCALC_LONG_OPTIONS( \
1804 "\n -b Display calculated broadcast address" \
1805 "\n -n Display calculated network address" \
1806 "\n -m Display default netmask for IP" \
1807 IF_FEATURE_IPCALC_FANCY( \
1808 "\n -p Display the prefix for IP/NETMASK" \
1809 "\n -h Display first resolved host name" \
1810 "\n -s Don't ever display error messages" \
1811 ) \
1812 )
1813
1814#define ipcrm_trivial_usage \
1815 "[-MQS key] [-mqs id]"
1816#define ipcrm_full_usage "\n\n" \
1817 "Upper-case options MQS remove an object by shmkey value.\n" \
1818 "Lower-case options remove an object by shmid value.\n" \
1819 "\nOptions:" \
1820 "\n -mM Remove memory segment after last detach" \
1821 "\n -qQ Remove message queue" \
1822 "\n -sS Remove semaphore" \
1823
1824#define ipcs_trivial_usage \
1825 "[[-smq] -i shmid] | [[-asmq] [-tcplu]]"
1826#define ipcs_full_usage "\n\n" \
1827 " -i Show specific resource" \
1828 "\nResource specification:" \
1829 "\n -m Shared memory segments" \
1830 "\n -q Message queues" \
1831 "\n -s Semaphore arrays" \
1832 "\n -a All (default)" \
1833 "\nOutput format:" \
1834 "\n -t Time" \
1835 "\n -c Creator" \
1836 "\n -p Pid" \
1837 "\n -l Limits" \
1838 "\n -u Summary" \
1839
1840#define iplink_trivial_usage \
1841 "{ set DEVICE { up | down | arp { on | off } | show [DEVICE] }"
1842#define iplink_full_usage "\n\n" \
1843 "iplink set DEVICE { up | down | arp | multicast { on | off } |\n" \
1844 " dynamic { on | off } |\n" \
1845 " mtu MTU }\n" \
1846 "iplink show [DEVICE]" \
1847
1848#define iproute_trivial_usage \
1849 "{ list | flush | { add | del | change | append |\n" \
1850 " replace | monitor } ROUTE }"
1851#define iproute_full_usage "\n\n" \
1852 "iproute { list | flush } SELECTOR\n" \
1853 "iproute get ADDRESS [from ADDRESS iif STRING]\n" \
1854 " [oif STRING] [tos TOS]\n" \
1855 "iproute { add | del | change | append | replace | monitor } ROUTE\n" \
1856 " SELECTOR := [root PREFIX] [match PREFIX] [proto RTPROTO]\n" \
1857 " ROUTE := [TYPE] PREFIX [tos TOS] [proto RTPROTO]\n" \
1858 " [metric METRIC]" \
1859
1860#define iprule_trivial_usage \
1861 "{[list | add | del] RULE}"
1862#define iprule_full_usage "\n\n" \
1863 "iprule [list | add | del] SELECTOR ACTION\n" \
1864 " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n" \
1865 " [dev STRING] [pref NUMBER]\n" \
1866 " ACTION := [table TABLE_ID] [nat ADDRESS]\n" \
1867 " [prohibit | reject | unreachable]\n" \
1868 " [realms [SRCREALM/]DSTREALM]\n" \
1869 " TABLE_ID := [local | main | default | NUMBER]" \
1870
1871#define iptunnel_trivial_usage \
1872 "{ add | change | del | show } [NAME]\n" \
1873 " [mode { ipip | gre | sit }]\n" \
1874 " [remote ADDR] [local ADDR] [ttl TTL]"
1875#define iptunnel_full_usage "\n\n" \
1876 "iptunnel { add | change | del | show } [NAME]\n" \
1877 " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n" \
1878 " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n" \
1879 " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" \
1880
1881#define kbd_mode_trivial_usage \
1882 "[-a|k|s|u] [-C TTY]"
1883#define kbd_mode_full_usage "\n\n" \
1884 "Report or set the keyboard mode\n" \
1885 "\nOptions:" \
1886 "\n -a Default (ASCII)" \
1887 "\n -k Medium-raw (keyboard)" \
1888 "\n -s Raw (scancode)" \
1889 "\n -u Unicode (utf-8)" \
1890 "\n -C TTY Affect TTY instead of /dev/tty" \
1891
1892#define kill_trivial_usage \
1893 "[-l] [-SIG] PID..."
1894#define kill_full_usage "\n\n" \
1895 "Send a signal (default: TERM) to given PIDs\n" \
1896 "\nOptions:" \
1897 "\n -l List all signal names and numbers" \
1898/* "\n -s SIG Yet another way of specifying SIG" */ \
1899
1900#define kill_example_usage \
1901 "$ ps | grep apache\n" \
1902 "252 root root S [apache]\n" \
1903 "263 www-data www-data S [apache]\n" \
1904 "264 www-data www-data S [apache]\n" \
1905 "265 www-data www-data S [apache]\n" \
1906 "266 www-data www-data S [apache]\n" \
1907 "267 www-data www-data S [apache]\n" \
1908 "$ kill 252\n"
1909
1910#define killall_trivial_usage \
1911 "[-l] [-q] [-SIG] PROCESS_NAME..."
1912#define killall_full_usage "\n\n" \
1913 "Send a signal (default: TERM) to given processes\n" \
1914 "\nOptions:" \
1915 "\n -l List all signal names and numbers" \
1916/* "\n -s SIG Yet another way of specifying SIG" */ \
1917 "\n -q Don't complain if no processes were killed" \
1918
1919#define killall_example_usage \
1920 "$ killall apache\n"
1921
1922#define killall5_trivial_usage \
1923 "[-l] [-SIG] [-o PID]..."
1924#define killall5_full_usage "\n\n" \
1925 "Send a signal (default: TERM) to all processes outside current session\n" \
1926 "\nOptions:" \
1927 "\n -l List all signal names and numbers" \
1928 "\n -o PID Don't signal this PID" \
1929/* "\n -s SIG Yet another way of specifying SIG" */ \
1930
1931#define klogd_trivial_usage \
1932 "[-c N] [-n]"
1933#define klogd_full_usage "\n\n" \
1934 "Kernel logger\n" \
1935 "\nOptions:" \
1936 "\n -c N Only messages with level < N are printed to console" \
1937 "\n -n Run in foreground" \
1938
1939#define length_trivial_usage \
1940 "STRING"
1941#define length_full_usage "\n\n" \
1942 "Print STRING's length"
1943
1944#define length_example_usage \
1945 "$ length Hello\n" \
1946 "5\n"
1947
1948#define less_trivial_usage \
1949 "[-EMNmh~I?] [FILE]..."
1950#define less_full_usage "\n\n" \
1951 "View FILE (or stdin) one screenful at a time\n" \
1952 "\nOptions:" \
1953 "\n -E Quit once the end of a file is reached" \
1954 "\n -M,-m Display status line with line numbers" \
1955 "\n and percentage through the file" \
1956 "\n -N Prefix line number to each line" \
1957 "\n -I Ignore case in all searches" \
1958 "\n -~ Suppress ~s displayed past the end of the file" \
1959
1960#define linux32_trivial_usage NOUSAGE_STR
1961#define linux32_full_usage ""
1962#define linux64_trivial_usage NOUSAGE_STR
1963#define linux64_full_usage ""
1964
1965#define setarch_trivial_usage \
1966 "personality PROG ARGS"
1967#define setarch_full_usage "\n\n" \
1968 "Personality may be:\n" \
1969 " linux32 Set 32bit uname emulation\n" \
1970 " linux64 Set 64bit uname emulation" \
1971
1972#define ln_trivial_usage \
1973 "[OPTIONS] TARGET... LINK|DIR"
1974#define ln_full_usage "\n\n" \
1975 "Create a link LINK or DIR/TARGET to the specified TARGET(s)\n" \
1976 "\nOptions:" \
1977 "\n -s Make symlinks instead of hardlinks" \
1978 "\n -f Remove existing destinations" \
1979 "\n -n Don't dereference symlinks - treat like normal file" \
1980 "\n -b Make a backup of the target (if exists) before link operation" \
1981 "\n -S suf Use suffix instead of ~ when making backup files" \
1982
1983#define ln_example_usage \
1984 "$ ln -s BusyBox /tmp/ls\n" \
1985 "$ ls -l /tmp/ls\n" \
1986 "lrwxrwxrwx 1 root root 7 Apr 12 18:39 ls -> BusyBox*\n"
1987
1988#define load_policy_trivial_usage NOUSAGE_STR
1989#define load_policy_full_usage ""
1990
1991#define loadfont_trivial_usage \
1992 "< font"
1993#define loadfont_full_usage "\n\n" \
1994 "Load a console font from stdin" \
1995/* "\n -C TTY Affect TTY instead of /dev/tty" */ \
1996
1997#define loadfont_example_usage \
1998 "$ loadfont < /etc/i18n/fontname\n"
1999
2000#define loadkmap_trivial_usage \
2001 "< keymap"
2002#define loadkmap_full_usage "\n\n" \
2003 "Load a binary keyboard translation table from stdin\n" \
2004/* "\n -C TTY Affect TTY instead of /dev/tty" */ \
2005
2006#define loadkmap_example_usage \
2007 "$ loadkmap < /etc/i18n/lang-keymap\n"
2008
2009#define logger_trivial_usage \
2010 "[OPTIONS] [MESSAGE]"
2011#define logger_full_usage "\n\n" \
2012 "Write MESSAGE (or stdin) to syslog\n" \
2013 "\nOptions:" \
2014 "\n -s Log to stderr as well as the system log" \
2015 "\n -t TAG Log using the specified tag (defaults to user name)" \
2016 "\n -p PRIO Priority (numeric or facility.level pair)" \
2017
2018#define logger_example_usage \
2019 "$ logger \"hello\"\n"
2020
2021#define login_trivial_usage \
2022 "[-p] [-h HOST] [[-f] USER]"
2023#define login_full_usage "\n\n" \
2024 "Begin a new session on the system\n" \
2025 "\nOptions:" \
2026 "\n -f Don't authenticate (user already authenticated)" \
2027 "\n -h Name of the remote host" \
2028 "\n -p Preserve environment" \
2029
2030#define logname_trivial_usage \
2031 ""
2032#define logname_full_usage "\n\n" \
2033 "Print the name of the current user"
2034#define logname_example_usage \
2035 "$ logname\n" \
2036 "root\n"
2037
2038#define logread_trivial_usage \
2039 "[-f]"
2040#define logread_full_usage "\n\n" \
2041 "Show messages in syslogd's circular buffer\n" \
2042 "\nOptions:" \
2043 "\n -f Output data as log grows" \
2044
2045#define losetup_trivial_usage \
2046 "[-o OFS] LOOPDEV FILE - associate loop devices\n" \
2047 " losetup -d LOOPDEV - disassociate\n" \
2048 " losetup [-f] - show"
2049#define losetup_full_usage "\n\n" \
2050 "Options:" \
2051 "\n -o OFS Start OFS bytes into FILE" \
2052 "\n -f Show first free loop device" \
2053
2054#define losetup_notes_usage \
2055 "No arguments will display all current associations.\n" \
2056 "One argument (losetup /dev/loop1) will display the current association\n" \
2057 "(if any), or disassociate it (with -d). The display shows the offset\n" \
2058 "and filename of the file the loop device is currently bound to.\n\n" \
2059 "Two arguments (losetup /dev/loop1 file.img) create a new association,\n" \
2060 "with an optional offset (-o 12345). Encryption is not yet supported.\n" \
2061 "losetup -f will show the first loop free loop device\n\n"
2062
2063#define lpd_trivial_usage \
2064 "SPOOLDIR [HELPER [ARGS]]"
2065#define lpd_full_usage "\n\n" \
2066 "SPOOLDIR must contain (symlinks to) device nodes or directories" \
2067 "\nwith names matching print queue names. In the first case, jobs are" \
2068 "\nsent directly to the device. Otherwise each job is stored in queue" \
2069 "\ndirectory and HELPER program is called. Name of file to print" \
2070 "\nis passed in $DATAFILE variable." \
2071 "\nExample:" \
2072 "\n tcpsvd -E 0 515 softlimit -m 999999 lpd /var/spool ./print" \
2073
2074#define lpq_trivial_usage \
2075 "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID]... [-fs]"
2076#define lpq_full_usage "\n\n" \
2077 "Options:" \
2078 "\n -P lp service to connect to (else uses $PRINTER)" \
2079 "\n -d Delete jobs" \
2080 "\n -f Force any waiting job to be printed" \
2081 "\n -s Short display" \
2082
2083#define lpr_trivial_usage \
2084 "-P queue[@host[:port]] -U USERNAME -J TITLE -Vmh [FILE]..."
2085/* -C CLASS exists too, not shown.
2086 * CLASS is supposed to be printed on banner page, if one is requested */
2087#define lpr_full_usage "\n\n" \
2088 "Options:" \
2089 "\n -P lp service to connect to (else uses $PRINTER)"\
2090 "\n -m Send mail on completion" \
2091 "\n -h Print banner page too" \
2092 "\n -V Verbose" \
2093
2094#define lsattr_trivial_usage \
2095 "[-Radlv] [FILE]..."
2096#define lsattr_full_usage "\n\n" \
2097 "List file attributes on an ext2 fs\n" \
2098 "\nOptions:" \
2099 "\n -R Recurse" \
2100 "\n -a Don't hide entries starting with ." \
2101 "\n -d List directory entries instead of contents" \
2102 "\n -l List long flag names" \
2103 "\n -v List the file's version/generation number" \
2104
2105#define lspci_trivial_usage \
2106 "[-mk]"
2107#define lspci_full_usage "\n\n" \
2108 "List all PCI devices" \
2109 "\n" \
2110 "\n -m Parseable output" \
2111 "\n -k Show driver" \
2112
2113#define lsusb_trivial_usage NOUSAGE_STR
2114#define lsusb_full_usage ""
2115
2116#if ENABLE_FEATURE_MAKEDEVS_LEAF
2117#define makedevs_trivial_usage \
2118 "NAME TYPE MAJOR MINOR FIRST LAST [s]"
2119#define makedevs_full_usage "\n\n" \
2120 "Create a range of block or character special files" \
2121 "\n" \
2122 "\nTYPE is:" \
2123 "\n b Block device" \
2124 "\n c Character device" \
2125 "\n f FIFO, MAJOR and MINOR are ignored" \
2126 "\n" \
2127 "\nFIRST..LAST specify numbers appended to NAME." \
2128 "\nIf 's' is the last argument, the base device is created as well." \
2129 "\n" \
2130 "\nExamples:" \
2131 "\n makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63" \
2132 "\n makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8"
2133#define makedevs_example_usage \
2134 "# makedevs /dev/ttyS c 4 66 2 63\n" \
2135 "[creates ttyS2-ttyS63]\n" \
2136 "# makedevs /dev/hda b 3 0 0 8 s\n" \
2137 "[creates hda,hda1-hda8]\n"
2138#endif
2139
2140#if ENABLE_FEATURE_MAKEDEVS_TABLE
2141#define makedevs_trivial_usage \
2142 "[-d device_table] rootdir"
2143#define makedevs_full_usage "\n\n" \
2144 "Create a range of special files as specified in a device table.\n" \
2145 "Device table entries take the form of:\n" \
2146 "<type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n" \
2147 "Where name is the file name, type can be one of:\n" \
2148 " f Regular file\n" \
2149 " d Directory\n" \
2150 " c Character device\n" \
2151 " b Block device\n" \
2152 " p Fifo (named pipe)\n" \
2153 "uid is the user id for the target file, gid is the group id for the\n" \
2154 "target file. The rest of the entries (major, minor, etc) apply to\n" \
2155 "to device special files. A '-' may be used for blank entries."
2156#define makedevs_example_usage \
2157 "For example:\n" \
2158 "<name> <type> <mode><uid><gid><major><minor><start><inc><count>\n" \
2159 "/dev d 755 0 0 - - - - -\n" \
2160 "/dev/console c 666 0 0 5 1 - - -\n" \
2161 "/dev/null c 666 0 0 1 3 0 0 -\n" \
2162 "/dev/zero c 666 0 0 1 5 0 0 -\n" \
2163 "/dev/hda b 640 0 0 3 0 0 0 -\n" \
2164 "/dev/hda b 640 0 0 3 1 1 1 15\n\n" \
2165 "Will Produce:\n" \
2166 "/dev\n" \
2167 "/dev/console\n" \
2168 "/dev/null\n" \
2169 "/dev/zero\n" \
2170 "/dev/hda\n" \
2171 "/dev/hda[0-15]\n"
2172#endif
2173
2174#define makemime_trivial_usage \
2175 "[OPTIONS] [FILE]..."
2176#define makemime_full_usage "\n\n" \
2177 "Create multipart MIME-encoded message from FILEs\n" \
2178/* "Transfer encoding is base64, disposition is inline (not attachment)\n" */ \
2179 "\nOptions:" \
2180 "\n -o FILE Output. Default: stdout" \
2181 "\n -a HDR Add header. Examples:" \
2182 "\n \"From: user@host.org\", \"Date: `date -R`\"" \
2183 "\n -c CT Content type. Default: text/plain" \
2184 "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET \
2185/* "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */ \
2186 "\n" \
2187 "\nOther options are silently ignored" \
2188
2189#define man_trivial_usage \
2190 "[-aw] [MANPAGE]..."
2191#define man_full_usage "\n\n" \
2192 "Format and display manual page\n" \
2193 "\nOptions:" \
2194 "\n -a Display all pages" \
2195 "\n -w Show page locations" \
2196
2197#define matchpathcon_trivial_usage \
2198 "[-n] [-N] [-f file_contexts_file] [-p prefix] [-V]"
2199#define matchpathcon_full_usage "\n\n" \
2200 " -n Don't display path" \
2201 "\n -N Don't use translations" \
2202 "\n -f Use alternate file_context file" \
2203 "\n -p Use prefix to speed translations" \
2204 "\n -V Verify file context on disk matches defaults" \
2205
2206#define md5sum_trivial_usage \
2207 "[FILE]..." \
2208 IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: md5sum -c [-sw] [FILE]")
2209#define md5sum_full_usage "\n\n" \
2210 "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " MD5 checksums" \
2211 IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n" \
2212 "\nOptions:" \
2213 "\n -c Check sums against given list" \
2214 "\n -s Don't output anything, status code shows success" \
2215 "\n -w Warn about improperly formatted checksum lines" \
2216 )
2217
2218#define md5sum_example_usage \
2219 "$ md5sum < busybox\n" \
2220 "6fd11e98b98a58f64ff3398d7b324003\n" \
2221 "$ md5sum busybox\n" \
2222 "6fd11e98b98a58f64ff3398d7b324003 busybox\n" \
2223 "$ md5sum -c -\n" \
2224 "6fd11e98b98a58f64ff3398d7b324003 busybox\n" \
2225 "busybox: OK\n" \
2226 "^D\n"
2227
2228#define sha1sum_trivial_usage \
2229 "[FILE]..." \
2230 IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha1sum -c [-sw] [FILE]")
2231#define sha1sum_full_usage "\n\n" \
2232 "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA1 checksums" \
2233 IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n" \
2234 "\nOptions:" \
2235 "\n -c Check sums against given list" \
2236 "\n -s Don't output anything, status code shows success" \
2237 "\n -w Warn about improperly formatted checksum lines" \
2238 )
2239
2240#define sha256sum_trivial_usage \
2241 "[FILE]..." \
2242 IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha256sum -c [-sw] [FILE]")
2243#define sha256sum_full_usage "\n\n" \
2244 "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA256 checksums" \
2245 IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n" \
2246 "\nOptions:" \
2247 "\n -c Check sums against given list" \
2248 "\n -s Don't output anything, status code shows success" \
2249 "\n -w Warn about improperly formatted checksum lines" \
2250 )
2251
2252#define sha512sum_trivial_usage \
2253 "[FILE]..." \
2254 IF_FEATURE_MD5_SHA1_SUM_CHECK("\n or: sha512sum -c [-sw] [FILE]")
2255#define sha512sum_full_usage "\n\n" \
2256 "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA512 checksums" \
2257 IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n" \
2258 "\nOptions:" \
2259 "\n -c Check sums against given list" \
2260 "\n -s Don't output anything, status code shows success" \
2261 "\n -w Warn about improperly formatted checksum lines" \
2262 )
2263
2264#define mdev_trivial_usage \
2265 "[-s]"
2266#define mdev_full_usage "\n\n" \
2267 " -s Scan /sys and populate /dev during system boot\n" \
2268 "\n" \
2269 "It can be run by kernel as a hotplug helper. To activate it:\n" \
2270 " echo /sbin/mdev > /proc/sys/kernel/hotplug\n" \
2271 IF_FEATURE_MDEV_CONF( \
2272 "It uses /etc/mdev.conf with lines\n" \
2273 "[-]DEVNAME UID:GID PERM" \
2274 IF_FEATURE_MDEV_RENAME(" [>|=PATH]") \
2275 IF_FEATURE_MDEV_EXEC(" [@|$|*PROG]") \
2276 ) \
2277
2278#define mdev_notes_usage "" \
2279 IF_FEATURE_MDEV_CONFIG( \
2280 "The mdev config file contains lines that look like:\n" \
2281 " hd[a-z][0-9]* 0:3 660\n\n" \
2282 "That's device name (with regex match), uid:gid, and permissions.\n\n" \
2283 IF_FEATURE_MDEV_EXEC( \
2284 "Optionally, that can be followed (on the same line) by a special character\n" \
2285 "and a command line to run after creating/before deleting the corresponding\n" \
2286 "device(s). The environment variable $MDEV indicates the active device node\n" \
2287 "(which is useful if it's a regex match). For example:\n\n" \
2288 " hdc root:cdrom 660 *ln -s $MDEV cdrom\n\n" \
2289 "The special characters are @ (run after creating), $ (run before deleting),\n" \
2290 "and * (run both after creating and before deleting). The commands run in\n" \
2291 "the /dev directory, and use system() which calls /bin/sh.\n\n" \
2292 ) \
2293 "Config file parsing stops on the first matching line. If no config\n" \
2294 "entry is matched, devices are created with default 0:0 660. (Make\n" \
2295 "the last line match .* to override this.)\n\n" \
2296 )
2297
2298#define microcom_trivial_usage \
2299 "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY"
2300#define microcom_full_usage "\n\n" \
2301 "Copy bytes for stdin to TTY and from TTY to stdout\n" \
2302 "\nOptions:" \
2303 "\n -d Wait up to DELAY ms for TTY output before sending every" \
2304 "\n next byte to it" \
2305 "\n -t Exit if both stdin and TTY are silent for TIMEOUT ms" \
2306 "\n -s Set serial line to SPEED" \
2307 "\n -X Disable special meaning of NUL and Ctrl-X from stdin" \
2308
2309#define mkdir_trivial_usage \
2310 "[OPTIONS] DIRECTORY..."
2311#define mkdir_full_usage "\n\n" \
2312 "Create DIRECTORY\n" \
2313 "\nOptions:" \
2314 "\n -m MODE Mode" \
2315 "\n -p No error if exists; make parent directories as needed" \
2316 IF_SELINUX( \
2317 "\n -Z Set security context" \
2318 )
2319
2320#define mkdir_example_usage \
2321 "$ mkdir /tmp/foo\n" \
2322 "$ mkdir /tmp/foo\n" \
2323 "/tmp/foo: File exists\n" \
2324 "$ mkdir /tmp/foo/bar/baz\n" \
2325 "/tmp/foo/bar/baz: No such file or directory\n" \
2326 "$ mkdir -p /tmp/foo/bar/baz\n"
2327
2328#define mkfifo_trivial_usage \
2329 "[-m MODE] " IF_SELINUX("[-Z] ") "NAME"
2330#define mkfifo_full_usage "\n\n" \
2331 "Create named pipe\n" \
2332 "\nOptions:" \
2333 "\n -m MODE Mode (default a=rw)" \
2334 IF_SELINUX( \
2335 "\n -Z Set security context" \
2336 )
2337
2338#define mkfs_ext2_trivial_usage \
2339 "[-Fn] " \
2340 /* "[-c|-l filename] " */ \
2341 "[-b BLK_SIZE] " \
2342 /* "[-f fragment-size] [-g blocks-per-group] " */ \
2343 "[-i INODE_RATIO] [-I INODE_SIZE] " \
2344 /* "[-j] [-J journal-options] [-N number-of-inodes] " */ \
2345 "[-m RESERVED_PERCENT] " \
2346 /* "[-o creator-os] [-O feature[,...]] [-q] " */ \
2347 /* "[r fs-revision-level] [-E extended-options] [-v] [-F] " */ \
2348 "[-L LABEL] " \
2349 /* "[-M last-mounted-directory] [-S] [-T filesystem-type] " */ \
2350 "BLOCKDEV [KBYTES]"
2351#define mkfs_ext2_full_usage "\n\n" \
2352 " -b BLK_SIZE Block size, bytes" \
2353/* "\n -c Check device for bad blocks" */ \
2354/* "\n -E opts Set extended options" */ \
2355/* "\n -f size Fragment size in bytes" */ \
2356 "\n -F Force" \
2357/* "\n -g N Number of blocks in a block group" */ \
2358 "\n -i RATIO Max number of files is filesystem_size / RATIO" \
2359 "\n -I BYTES Inode size (min 128)" \
2360/* "\n -j Create a journal (ext3)" */ \
2361/* "\n -J opts Set journal options (size/device)" */ \
2362/* "\n -l file Read bad blocks list from file" */ \
2363 "\n -L LBL Volume label" \
2364 "\n -m PERCENT Percent of blocks to reserve for admin" \
2365/* "\n -M dir Set last mounted directory" */ \
2366 "\n -n Dry run" \
2367/* "\n -N N Number of inodes to create" */ \
2368/* "\n -o os Set the 'creator os' field" */ \
2369/* "\n -O features Dir_index/filetype/has_journal/journal_dev/sparse_super" */ \
2370/* "\n -q Quiet" */ \
2371/* "\n -r rev Set filesystem revision" */ \
2372/* "\n -S Write superblock and group descriptors only" */ \
2373/* "\n -T fs-type Set usage type (news/largefile/largefile4)" */ \
2374/* "\n -v Verbose" */ \
2375
2376#define mkfs_minix_trivial_usage \
2377 "[-c | -l FILE] [-nXX] [-iXX] BLOCKDEV [KBYTES]"
2378#define mkfs_minix_full_usage "\n\n" \
2379 "Make a MINIX filesystem\n" \
2380 "\nOptions:" \
2381 "\n -c Check device for bad blocks" \
2382 "\n -n [14|30] Maximum length of filenames" \
2383 "\n -i INODES Number of inodes for the filesystem" \
2384 "\n -l FILE Read bad blocks list from FILE" \
2385 "\n -v Make version 2 filesystem" \
2386
2387#define mkfs_reiser_trivial_usage \
2388 "[-f] [-l LABEL] BLOCKDEV [4K-BLOCKS]"
2389
2390#define mkfs_reiser_full_usage "\n\n" \
2391 "Make a ReiserFS V3 filesystem\n" \
2392 "\nOptions:" \
2393 "\n -f Force" \
2394 "\n -l LBL Volume label" \
2395
2396#define mkfs_vfat_trivial_usage \
2397 "[-v] [-n LABEL] BLOCKDEV [KBYTES]"
2398/* Accepted but ignored:
2399 "[-c] [-C] [-I] [-l bad-block-file] [-b backup-boot-sector] "
2400 "[-m boot-msg-file] [-i volume-id] "
2401 "[-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs] "
2402 "[-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors] "
2403*/
2404#define mkfs_vfat_full_usage "\n\n" \
2405 "Make a FAT32 filesystem\n" \
2406 "\nOptions:" \
2407/* "\n -c Check device for bad blocks" */ \
2408 "\n -v Verbose" \
2409/* "\n -I Allow to use entire disk device (e.g. /dev/hda)" */ \
2410 "\n -n LBL Volume label" \
2411
2412#define mknod_trivial_usage \
2413 "[-m MODE] " IF_SELINUX("[-Z] ") "NAME TYPE MAJOR MINOR"
2414#define mknod_full_usage "\n\n" \
2415 "Create a special file (block, character, or pipe)\n" \
2416 "\nOptions:" \
2417 "\n -m MODE Creation mode (default a=rw)" \
2418 IF_SELINUX( \
2419 "\n -Z Set security context" \
2420 ) \
2421 "\nTYPE:" \
2422 "\n b Block device" \
2423 "\n c or u Character device" \
2424 "\n p Named pipe (MAJOR and MINOR are ignored)" \
2425
2426#define mknod_example_usage \
2427 "$ mknod /dev/fd0 b 2 0\n" \
2428 "$ mknod -m 644 /tmp/pipe p\n"
2429
2430#define mkswap_trivial_usage \
2431 "[-L LBL] BLOCKDEV [KBYTES]"
2432#define mkswap_full_usage "\n\n" \
2433 "Prepare BLOCKDEV to be used as swap partition\n" \
2434 "\nOptions:" \
2435 "\n -L LBL Label" \
2436
2437#define more_trivial_usage \
2438 "[FILE]..."
2439#define more_full_usage "\n\n" \
2440 "View FILE (or stdin) one screenful at a time"
2441
2442#define more_example_usage \
2443 "$ dmesg | more\n"
2444
2445#define mount_trivial_usage \
2446 "[OPTIONS] [-o OPTS] DEVICE NODE"
2447#define mount_full_usage "\n\n" \
2448 "Mount a filesystem. Filesystem autodetection requires /proc.\n" \
2449 "\nOptions:" \
2450 "\n -a Mount all filesystems in fstab" \
2451 IF_FEATURE_MOUNT_FAKE( \
2452 IF_FEATURE_MTAB_SUPPORT( \
2453 "\n -f Update /etc/mtab, but don't mount" \
2454 ) \
2455 IF_NOT_FEATURE_MTAB_SUPPORT( \
2456 "\n -f Dry run" \
2457 ) \
2458 ) \
2459 IF_FEATURE_MOUNT_HELPERS( \
2460 "\n -i Don't run mount helper" \
2461 ) \
2462 IF_FEATURE_MTAB_SUPPORT( \
2463 "\n -n Don't update /etc/mtab" \
2464 ) \
2465 "\n -r Read-only mount" \
2466 "\n -w Read-write mount (default)" \
2467 "\n -t FSTYPE Filesystem type" \
2468 "\n -O OPT Mount only filesystems with option OPT (-a only)" \
2469 "\n-o OPT:" \
2470 IF_FEATURE_MOUNT_LOOP( \
2471 "\n loop Ignored (loop devices are autodetected)" \
2472 ) \
2473 IF_FEATURE_MOUNT_FLAGS( \
2474 "\n [a]sync Writes are [a]synchronous" \
2475 "\n [no]atime Disable/enable updates to inode access times" \
2476 "\n [no]diratime Disable/enable atime updates to directories" \
2477 "\n [no]relatime Disable/enable atime updates relative to modification time" \
2478 "\n [no]dev (Dis)allow use of special device files" \
2479 "\n [no]exec (Dis)allow use of executable files" \
2480 "\n [no]suid (Dis)allow set-user-id-root programs" \
2481 "\n [r]shared Convert [recursively] to a shared subtree" \
2482 "\n [r]slave Convert [recursively] to a slave subtree" \
2483 "\n [r]private Convert [recursively] to a private subtree" \
2484 "\n [un]bindable Make mount point [un]able to be bind mounted" \
2485 "\n [r]bind Bind a file or directory [recursively] to another location" \
2486 "\n move Relocate an existing mount point" \
2487 ) \
2488 "\n remount Remount a mounted filesystem, changing flags" \
2489 "\n ro/rw Same as -r/-w" \
2490 "\n" \
2491 "\nThere are filesystem-specific -o flags." \
2492
2493#define mount_example_usage \
2494 "$ mount\n" \
2495 "/dev/hda3 on / type minix (rw)\n" \
2496 "proc on /proc type proc (rw)\n" \
2497 "devpts on /dev/pts type devpts (rw)\n" \
2498 "$ mount /dev/fd0 /mnt -t msdos -o ro\n" \
2499 "$ mount /tmp/diskimage /opt -t ext2 -o loop\n" \
2500 "$ mount cd_image.iso mydir\n"
2501#define mount_notes_usage \
2502 "Returns 0 for success, number of failed mounts for -a, or errno for one mount."
2503
2504#define mountpoint_trivial_usage \
2505 "[-q] <[-dn] DIR | -x DEVICE>"
2506#define mountpoint_full_usage "\n\n" \
2507 "Check if the directory is a mountpoint\n" \
2508 "\nOptions:" \
2509 "\n -q Quiet" \
2510 "\n -d Print major/minor device number of the filesystem" \
2511 "\n -n Print device name of the filesystem" \
2512 "\n -x Print major/minor device number of the blockdevice" \
2513
2514#define mountpoint_example_usage \
2515 "$ mountpoint /proc\n" \
2516 "/proc is not a mountpoint\n" \
2517 "$ mountpoint /sys\n" \
2518 "/sys is a mountpoint\n"
2519
2520#define mt_trivial_usage \
2521 "[-f device] opcode value"
2522#define mt_full_usage "\n\n" \
2523 "Control magnetic tape drive operation\n" \
2524 "\n" \
2525 "Available Opcodes:\n" \
2526 "\n" \
2527 "bsf bsfm bsr bss datacompression drvbuffer eof eom erase\n" \
2528 "fsf fsfm fsr fss load lock mkpart nop offline ras1 ras2\n" \
2529 "ras3 reset retension rewind rewoffline seek setblk setdensity\n" \
2530 "setpart tell unload unlock weof wset" \
2531
2532#define nohup_trivial_usage \
2533 "PROG ARGS"
2534#define nohup_full_usage "\n\n" \
2535 "Run PROG immune to hangups, with output to a non-tty"
2536#define nohup_example_usage \
2537 "$ nohup make &"
2538
2539#define nslookup_trivial_usage \
2540 "[HOST] [SERVER]"
2541#define nslookup_full_usage "\n\n" \
2542 "Query the nameserver for the IP address of the given HOST\n" \
2543 "optionally using a specified DNS server"
2544#define nslookup_example_usage \
2545 "$ nslookup localhost\n" \
2546 "Server: default\n" \
2547 "Address: default\n" \
2548 "\n" \
2549 "Name: debian\n" \
2550 "Address: 127.0.0.1\n"
2551
2552#define ntpd_trivial_usage \
2553 "[-dnqNw"IF_FEATURE_NTPD_SERVER("l")"] [-S PROG] [-p PEER]..."
2554#define ntpd_full_usage "\n\n" \
2555 "NTP client/server\n" \
2556 "\nOptions:" \
2557 "\n -d Verbose" \
2558 "\n -n Do not daemonize" \
2559 "\n -q Quit after clock is set" \
2560 "\n -N Run at high priority" \
2561 "\n -w Do not set time (only query peers), implies -n" \
2562 IF_FEATURE_NTPD_SERVER( \
2563 "\n -l Run as server on port 123" \
2564 ) \
2565 "\n -S PROG Run PROG after stepping time, stratum change, and every 11 mins" \
2566 "\n -p PEER Obtain time from PEER (may be repeated)" \
2567
2568#define od_trivial_usage \
2569 "[-aBbcDdeFfHhIiLlOovXx] " IF_DESKTOP("[-t TYPE] ") "[FILE]"
2570#define od_full_usage "\n\n" \
2571 "Write an unambiguous representation, octal bytes by default, of FILE\n" \
2572 "(or stdin) to stdout"
2573
2574#define openvt_trivial_usage \
2575 "[-c N] [-sw] [PROG ARGS]"
2576#define openvt_full_usage "\n\n" \
2577 "Start PROG on a new virtual terminal\n" \
2578 "\nOptions:" \
2579 "\n -c N Use specified VT" \
2580 "\n -s Switch to the VT" \
2581/* "\n -l Run PROG as login shell (by prepending '-')" */ \
2582 "\n -w Wait for PROG to exit" \
2583
2584#define openvt_example_usage \
2585 "openvt 2 /bin/ash\n"
2586
2587/*
2588#define parse_trivial_usage \
2589 "[-n MAXTOKENS] [-m MINTOKENS] [-d DELIMS] [-f FLAGS] FILE..."
2590#define parse_full_usage ""
2591*/
2592
2593#define passwd_trivial_usage \
2594 "[OPTIONS] [USER]"
2595#define passwd_full_usage "\n\n" \
2596 "Change USER's password. If no USER is specified,\n" \
2597 "changes the password for the current user.\n" \
2598 "\nOptions:" \
2599 "\n -a ALG Algorithm to use for password (des, md5)" /* ", sha1)" */ \
2600 "\n -d Delete password for the account" \
2601 "\n -l Lock (disable) account" \
2602 "\n -u Unlock (re-enable) account" \
2603
2604#define chpasswd_trivial_usage \
2605 IF_LONG_OPTS("[--md5|--encrypted]") IF_NOT_LONG_OPTS("[-m|-e]")
2606#define chpasswd_full_usage "\n\n" \
2607 "Read user:password from stdin and update /etc/passwd\n" \
2608 "\nOptions:" \
2609 IF_LONG_OPTS( \
2610 "\n -e,--encrypted Supplied passwords are in encrypted form" \
2611 "\n -m,--md5 Use MD5 encryption instead of DES" \
2612 ) \
2613 IF_NOT_LONG_OPTS( \
2614 "\n -e Supplied passwords are in encrypted form" \
2615 "\n -m Use MD5 encryption instead of DES" \
2616 )
2617
2618#define pgrep_trivial_usage \
2619 "[-flnovx] [-s SID|-P PPID|PATTERN]"
2620#define pgrep_full_usage "\n\n" \
2621 "Display process(es) selected by regex PATTERN\n" \
2622 "\nOptions:" \
2623 "\n -l Show command name too" \
2624 "\n -f Match against entire command line" \
2625 "\n -n Show the newest process only" \
2626 "\n -o Show the oldest process only" \
2627 "\n -v Negate the match" \
2628 "\n -x Match whole name (not substring)" \
2629 "\n -s Match session ID (0 for current)" \
2630 "\n -P Match parent process ID" \
2631
2632#if (ENABLE_FEATURE_PIDOF_SINGLE || ENABLE_FEATURE_PIDOF_OMIT)
2633#define pidof_trivial_usage \
2634 "[OPTIONS] [NAME]..."
2635#define USAGE_PIDOF "\n\nOptions:"
2636#else
2637#define pidof_trivial_usage \
2638 "[NAME]..."
2639#define USAGE_PIDOF /* none */
2640#endif
2641#define pidof_full_usage "\n\n" \
2642 "List PIDs of all processes with names that match NAMEs" \
2643 USAGE_PIDOF \
2644 IF_FEATURE_PIDOF_SINGLE( \
2645 "\n -s Show only one PID" \
2646 ) \
2647 IF_FEATURE_PIDOF_OMIT( \
2648 "\n -o PID Omit given pid" \
2649 "\n Use %PPID to omit pid of pidof's parent" \
2650 ) \
2651
2652#define pidof_example_usage \
2653 "$ pidof init\n" \
2654 "1\n" \
2655 IF_FEATURE_PIDOF_OMIT( \
2656 "$ pidof /bin/sh\n20351 5973 5950\n") \
2657 IF_FEATURE_PIDOF_OMIT( \
2658 "$ pidof /bin/sh -o %PPID\n20351 5950")
2659
2660#define pipe_progress_trivial_usage NOUSAGE_STR
2661#define pipe_progress_full_usage ""
2662
2663#define pivot_root_trivial_usage \
2664 "NEW_ROOT PUT_OLD"
2665#define pivot_root_full_usage "\n\n" \
2666 "Move the current root file system to PUT_OLD and make NEW_ROOT\n" \
2667 "the new root file system"
2668
2669#define pkill_trivial_usage \
2670 "[-l|-SIGNAL] [-fnovx] [-s SID|-P PPID|PATTERN]"
2671#define pkill_full_usage "\n\n" \
2672 "Send a signal to process(es) selected by regex PATTERN\n" \
2673 "\nOptions:" \
2674 "\n -l List all signals" \
2675 "\n -f Match against entire command line" \
2676 "\n -n Signal the newest process only" \
2677 "\n -o Signal the oldest process only" \
2678 "\n -v Negate the match" \
2679 "\n -x Match whole name (not substring)" \
2680 "\n -s Match session ID (0 for current)" \
2681 "\n -P Match parent process ID" \
2682
2683#define popmaildir_trivial_usage \
2684 "[OPTIONS] MAILDIR [CONN_HELPER ARGS]"
2685#define popmaildir_full_usage "\n\n" \
2686 "Fetch content of remote mailbox to local maildir\n" \
2687 "\nOptions:" \
2688/* "\n -b Binary mode. Ignored" */ \
2689/* "\n -d Debug. Ignored" */ \
2690/* "\n -m Show used memory. Ignored" */ \
2691/* "\n -V Show version. Ignored" */ \
2692/* "\n -c Use tcpclient. Ignored" */ \
2693/* "\n -a Use APOP protocol. Implied. If server supports APOP -> use it" */ \
2694 "\n -s Skip authorization" \
2695 "\n -T Get messages with TOP instead of RETR" \
2696 "\n -k Keep retrieved messages on the server" \
2697 "\n -t SEC Network timeout" \
2698 IF_FEATURE_POPMAILDIR_DELIVERY( \
2699 "\n -F \"PROG ARGS\" Filter program (may be repeated)" \
2700 "\n -M \"PROG ARGS\" Delivery program" \
2701 ) \
2702 "\n" \
2703 "\nFetch from plain POP3 server:" \
2704 "\npopmaildir -k DIR nc pop3.server.com 110 <user_and_pass.txt" \
2705 "\nFetch from SSLed POP3 server and delete fetched emails:" \
2706 "\npopmaildir DIR -- openssl s_client -quiet -connect pop3.server.com:995 <user_and_pass.txt"
2707/* "\n -R BYTES Remove old messages on the server >= BYTES. Ignored" */
2708/* "\n -Z N1-N2 Remove messages from N1 to N2 (dangerous). Ignored" */
2709/* "\n -L BYTES Don't retrieve new messages >= BYTES. Ignored" */
2710/* "\n -H LINES Type first LINES of a message. Ignored" */
2711#define popmaildir_example_usage \
2712 "$ popmaildir -k ~/Maildir -- nc pop.drvv.ru 110 [<password_file]\n" \
2713 "$ popmaildir ~/Maildir -- openssl s_client -quiet -connect pop.gmail.com:995 [<password_file]\n"
2714
2715#define printenv_trivial_usage \
2716 "[VARIABLE]..."
2717#define printenv_full_usage "\n\n" \
2718 "Print environment VARIABLEs.\n" \
2719 "If no VARIABLE specified, print all."
2720
2721#define printf_trivial_usage \
2722 "FORMAT [ARGUMENT]..."
2723#define printf_full_usage "\n\n" \
2724 "Format and print ARGUMENT(s) according to FORMAT,\n" \
2725 "where FORMAT controls the output exactly as in C printf"
2726#define printf_example_usage \
2727 "$ printf \"Val=%d\\n\" 5\n" \
2728 "Val=5\n"
2729
2730
2731#if ENABLE_DESKTOP
2732
2733#define ps_trivial_usage \
2734 "[-o COL1,COL2=HEADER]" IF_FEATURE_SHOW_THREADS(" [-T]")
2735#define ps_full_usage "\n\n" \
2736 "Show list of processes\n" \
2737 "\nOptions:" \
2738 "\n -o COL1,COL2=HEADER Select columns for display" \
2739 IF_FEATURE_SHOW_THREADS( \
2740 "\n -T Show threads" \
2741 )
2742
2743#else /* !ENABLE_DESKTOP */
2744
2745#if !ENABLE_SELINUX && !ENABLE_FEATURE_PS_WIDE
2746#define USAGE_PS "\nThis version of ps accepts no options"
2747#else
2748#define USAGE_PS "\nOptions:"
2749#endif
2750
2751#define ps_trivial_usage \
2752 ""
2753#define ps_full_usage "\n\n" \
2754 "Show list of processes\n" \
2755 USAGE_PS \
2756 IF_SELINUX( \
2757 "\n -Z Show selinux context" \
2758 ) \
2759 IF_FEATURE_PS_WIDE( \
2760 "\n w Wide output" \
2761 )
2762
2763#endif /* ENABLE_DESKTOP */
2764
2765#define ps_example_usage \
2766 "$ ps\n" \
2767 " PID Uid Gid State Command\n" \
2768 " 1 root root S init\n" \
2769 " 2 root root S [kflushd]\n" \
2770 " 3 root root S [kupdate]\n" \
2771 " 4 root root S [kpiod]\n" \
2772 " 5 root root S [kswapd]\n" \
2773 " 742 andersen andersen S [bash]\n" \
2774 " 743 andersen andersen S -bash\n" \
2775 " 745 root root S [getty]\n" \
2776 " 2990 andersen andersen R ps\n" \
2777
2778#define pscan_trivial_usage \
2779 "[-cb] [-p MIN_PORT] [-P MAX_PORT] [-t TIMEOUT] [-T MIN_RTT] HOST"
2780#define pscan_full_usage "\n\n" \
2781 "Scan a host, print all open ports\n" \
2782 "\nOptions:" \
2783 "\n -c Show closed ports too" \
2784 "\n -b Show blocked ports too" \
2785 "\n -p Scan from this port (default 1)" \
2786 "\n -P Scan up to this port (default 1024)" \
2787 "\n -t Timeout (default 5000 ms)" \
2788 "\n -T Minimum rtt (default 5 ms, increase for congested hosts)" \
2789
2790#define pwd_trivial_usage \
2791 ""
2792#define pwd_full_usage "\n\n" \
2793 "Print the full filename of the current working directory"
2794#define pwd_example_usage \
2795 "$ pwd\n" \
2796 "/root\n"
2797
2798#define raidautorun_trivial_usage \
2799 "DEVICE"
2800#define raidautorun_full_usage "\n\n" \
2801 "Tell the kernel to automatically search and start RAID arrays"
2802#define raidautorun_example_usage \
2803 "$ raidautorun /dev/md0"
2804
2805#define rdate_trivial_usage \
2806 "[-sp] HOST"
2807#define rdate_full_usage "\n\n" \
2808 "Get and possibly set the system date and time from a remote HOST\n" \
2809 "\nOptions:" \
2810 "\n -s Set the system date and time (default)" \
2811 "\n -p Print the date and time" \
2812
2813#define rdev_trivial_usage \
2814 ""
2815#define rdev_full_usage "\n\n" \
2816 "Print the device node associated with the filesystem mounted at '/'"
2817#define rdev_example_usage \
2818 "$ rdev\n" \
2819 "/dev/mtdblock9 /\n"
2820
2821#define readahead_trivial_usage \
2822 "[FILE]..."
2823#define readahead_full_usage "\n\n" \
2824 "Preload FILEs to RAM"
2825
2826#define readlink_trivial_usage \
2827 IF_FEATURE_READLINK_FOLLOW("[-fnv] ") "FILE"
2828#define readlink_full_usage "\n\n" \
2829 "Display the value of a symlink" \
2830 IF_FEATURE_READLINK_FOLLOW( "\n" \
2831 "\nOptions:" \
2832 "\n -f Canonicalize by following all symlinks" \
2833 "\n -n Don't add newline" \
2834 "\n -v Verbose" \
2835 ) \
2836
2837#define readprofile_trivial_usage \
2838 "[OPTIONS]"
2839#define readprofile_full_usage "\n\n" \
2840 "Options:" \
2841 "\n -m mapfile (Default: /boot/System.map)" \
2842 "\n -p profile (Default: /proc/profile)" \
2843 "\n -M NUM Set the profiling multiplier to NUM" \
2844 "\n -i Print only info about the sampling step" \
2845 "\n -v Verbose" \
2846 "\n -a Print all symbols, even if count is 0" \
2847 "\n -b Print individual histogram-bin counts" \
2848 "\n -s Print individual counters within functions" \
2849 "\n -r Reset all the counters (root only)" \
2850 "\n -n Disable byte order auto-detection" \
2851
2852#define realpath_trivial_usage \
2853 "FILE..."
2854#define realpath_full_usage "\n\n" \
2855 "Return the absolute pathnames of given FILE"
2856
2857#define reformime_trivial_usage \
2858 "[OPTIONS] [FILE]..."
2859#define reformime_full_usage "\n\n" \
2860 "Parse MIME-encoded message\n" \
2861 "\nOptions:" \
2862 "\n -x PREFIX Extract content of MIME sections to files" \
2863 "\n -X PROG ARGS Filter content of MIME sections through PROG" \
2864 "\n Must be the last option" \
2865 "\n" \
2866 "\nOther options are silently ignored" \
2867
2868#define scriptreplay_trivial_usage \
2869 "timingfile [typescript [divisor]]"
2870#define scriptreplay_full_usage "\n\n" \
2871 "Play back typescripts, using timing information"
2872
2873#define reset_trivial_usage \
2874 ""
2875#define reset_full_usage "\n\n" \
2876 "Reset the screen"
2877
2878#define resize_trivial_usage \
2879 ""
2880#define resize_full_usage "\n\n" \
2881 "Resize the screen"
2882
2883#define restorecon_trivial_usage \
2884 "[-iFnRv] [-e EXCLUDEDIR]... [-o FILE] [-f FILE]"
2885#define restorecon_full_usage "\n\n" \
2886 "Reset security contexts of files in pathname\n" \
2887 "\n -i Ignore files that don't exist" \
2888 "\n -f FILE File with list of files to process" \
2889 "\n -e DIR Directory to exclude" \
2890 "\n -R,-r Recurse" \
2891 "\n -n Don't change any file labels" \
2892 "\n -o FILE Save list of files with incorrect context" \
2893 "\n -v Verbose" \
2894 "\n -vv Show changed labels" \
2895 "\n -F Force reset of context to match file_context" \
2896 "\n for customizable files, or the user section," \
2897 "\n if it has changed" \
2898
2899#define rfkill_trivial_usage \
2900 "COMMAND [INDEX|TYPE]"
2901#define rfkill_full_usage "\n\n" \
2902 "Enable/disable wireless devices\n" \
2903 "\nCommands:" \
2904 "\n list [INDEX|TYPE] List current state" \
2905 "\n block INDEX|TYPE Disable device" \
2906 "\n unblock INDEX|TYPE Enable device" \
2907 "\n" \
2908 "\n TYPE: all, wlan(wifi), bluetooth, uwb(ultrawideband)," \
2909 "\n wimax, wwan, gps, fm" \
2910
2911#define rm_trivial_usage \
2912 "[-irf] FILE..."
2913#define rm_full_usage "\n\n" \
2914 "Remove (unlink) FILEs\n" \
2915 "\nOptions:" \
2916 "\n -i Always prompt before removing" \
2917 "\n -f Never prompt" \
2918 "\n -R,-r Recurse" \
2919
2920#define rm_example_usage \
2921 "$ rm -rf /tmp/foo\n"
2922
2923#define rmdir_trivial_usage \
2924 "[OPTIONS] DIRECTORY..."
2925#define rmdir_full_usage "\n\n" \
2926 "Remove DIRECTORY if it is empty\n" \
2927 "\nOptions:" \
2928 IF_FEATURE_RMDIR_LONG_OPTIONS( \
2929 "\n -p|--parents Include parents" \
2930 "\n --ignore-fail-on-non-empty" \
2931 ) \
2932 IF_NOT_FEATURE_RMDIR_LONG_OPTIONS( \
2933 "\n -p Include parents" \
2934 )
2935
2936#define rmdir_example_usage \
2937 "# rmdir /tmp/foo\n"
2938
2939#define route_trivial_usage \
2940 "[{add|del|delete}]"
2941#define route_full_usage "\n\n" \
2942 "Edit kernel routing tables\n" \
2943 "\nOptions:" \
2944 "\n -n Don't resolve names" \
2945 "\n -e Display other/more information" \
2946 "\n -A inet" IF_FEATURE_IPV6("{6}") " Select address family" \
2947
2948#define rpm_trivial_usage \
2949 "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm"
2950#define rpm_full_usage "\n\n" \
2951 "Manipulate RPM packages\n" \
2952 "\nCommands:" \
2953 "\n -i Install package" \
2954 "\n -qp Query package" \
2955 "\nOptions:" \
2956 "\n -i Show information" \
2957 "\n -l List contents" \
2958 "\n -d List documents" \
2959 "\n -c List config files" \
2960
2961#define rpm2cpio_trivial_usage \
2962 "package.rpm"
2963#define rpm2cpio_full_usage "\n\n" \
2964 "Output a cpio archive of the rpm file"
2965
2966#define rtcwake_trivial_usage \
2967 "[-a | -l | -u] [-d DEV] [-m MODE] [-s SEC | -t TIME]"
2968#define rtcwake_full_usage "\n\n" \
2969 "Enter a system sleep state until specified wakeup time\n" \
2970 IF_LONG_OPTS( \
2971 "\n -a,--auto Read clock mode from adjtime" \
2972 "\n -l,--local Clock is set to local time" \
2973 "\n -u,--utc Clock is set to UTC time" \
2974 "\n -d,--device=DEV Specify the RTC device" \
2975 "\n -m,--mode=MODE Set the sleep state (default: standby)" \
2976 "\n -s,--seconds=SEC Set the timeout in SEC seconds from now" \
2977 "\n -t,--time=TIME Set the timeout to TIME seconds from epoch" \
2978 ) \
2979 IF_NOT_LONG_OPTS( \
2980 "\n -a Read clock mode from adjtime" \
2981 "\n -l Clock is set to local time" \
2982 "\n -u Clock is set to UTC time" \
2983 "\n -d DEV Specify the RTC device" \
2984 "\n -m MODE Set the sleep state (default: standby)" \
2985 "\n -s SEC Set the timeout in SEC seconds from now" \
2986 "\n -t TIME Set the timeout to TIME seconds from epoch" \
2987 )
2988
2989#define runcon_trivial_usage \
2990 "[-c] [-u USER] [-r ROLE] [-t TYPE] [-l RANGE] PROG ARGS\n" \
2991 "runcon CONTEXT PROG ARGS"
2992#define runcon_full_usage "\n\n" \
2993 "Run PROG in a different security context\n" \
2994 "\n CONTEXT Complete security context\n" \
2995 IF_FEATURE_RUNCON_LONG_OPTIONS( \
2996 "\n -c,--compute Compute process transition context before modifying" \
2997 "\n -t,--type=TYPE Type (for same role as parent)" \
2998 "\n -u,--user=USER User identity" \
2999 "\n -r,--role=ROLE Role" \
3000 "\n -l,--range=RNG Levelrange" \
3001 ) \
3002 IF_NOT_FEATURE_RUNCON_LONG_OPTIONS( \
3003 "\n -c Compute process transition context before modifying" \
3004 "\n -t TYPE Type (for same role as parent)" \
3005 "\n -u USER User identity" \
3006 "\n -r ROLE Role" \
3007 "\n -l RNG Levelrange" \
3008 )
3009
3010#define run_parts_trivial_usage \
3011 "[-t] "IF_FEATURE_RUN_PARTS_FANCY("[-l] ")"[-a ARG] [-u MASK] DIRECTORY"
3012#define run_parts_full_usage "\n\n" \
3013 "Run a bunch of scripts in DIRECTORY\n" \
3014 "\nOptions:" \
3015 "\n -t Print what would be run, but don't actually run anything" \
3016 "\n -a ARG Pass ARG as argument for every program" \
3017 "\n -u MASK Set the umask to MASK before running every program" \
3018 IF_FEATURE_RUN_PARTS_FANCY( \
3019 "\n -l Print names of all matching files even if they are not executable" \
3020 )
3021
3022#define run_parts_example_usage \
3023 "$ run-parts -a start /etc/init.d\n" \
3024 "$ run-parts -a stop=now /etc/init.d\n\n" \
3025 "Let's assume you have a script foo/dosomething:\n" \
3026 "#!/bin/sh\n" \
3027 "for i in $*; do eval $i; done; unset i\n" \
3028 "case \"$1\" in\n" \
3029 "start*) echo starting something;;\n" \
3030 "stop*) set -x; shutdown -h $stop;;\n" \
3031 "esac\n\n" \
3032 "Running this yields:\n" \
3033 "$run-parts -a stop=+4m foo/\n" \
3034 "+ shutdown -h +4m"
3035
3036#define runlevel_trivial_usage \
3037 "[FILE]"
3038#define runlevel_full_usage "\n\n" \
3039 "Find the current and previous system runlevel\n" \
3040 "\n" \
3041 "If no utmp FILE exists or if no runlevel record can be found,\n" \
3042 "print \"unknown\""
3043#define runlevel_example_usage \
3044 "$ runlevel /var/run/utmp\n" \
3045 "N 2"
3046
3047#define runsv_trivial_usage \
3048 "DIR"
3049#define runsv_full_usage "\n\n" \
3050 "Start and monitor a service and optionally an appendant log service"
3051
3052#define runsvdir_trivial_usage \
3053 "[-P] [-s SCRIPT] DIR"
3054#define runsvdir_full_usage "\n\n" \
3055 "Start a runsv process for each subdirectory. If it exits, restart it.\n" \
3056 "\n -P Put each runsv in a new session" \
3057 "\n -s SCRIPT Run SCRIPT <signo> after signal is processed" \
3058
3059#define rx_trivial_usage \
3060 "FILE"
3061#define rx_full_usage "\n\n" \
3062 "Receive a file using the xmodem protocol"
3063#define rx_example_usage \
3064 "$ rx /tmp/foo\n"
3065
3066#define script_trivial_usage \
3067 "[-afq" IF_SCRIPTREPLAY("t") "] [-c PROG] [OUTFILE]"
3068#define script_full_usage "\n\n" \
3069 "Options:" \
3070 "\n -a Append output" \
3071 "\n -c PROG Run PROG, not shell" \
3072 "\n -f Flush output after each write" \
3073 "\n -q Quiet" \
3074 IF_SCRIPTREPLAY( \
3075 "\n -t Send timing to stderr" \
3076 )
3077
3078#define sed_trivial_usage \
3079 "[-efinr] SED_CMD [FILE]..."
3080#define sed_full_usage "\n\n" \
3081 "Options:" \
3082 "\n -e CMD Add CMD to sed commands to be executed" \
3083 "\n -f FILE Add FILE contents to sed commands to be executed" \
3084 "\n -i Edit files in-place (else sends result to stdout)" \
3085 "\n -n Suppress automatic printing of pattern space" \
3086 "\n -r Use extended regex syntax" \
3087 "\n" \
3088 "\nIf no -e or -f, the first non-option argument is the sed command string." \
3089 "\nRemaining arguments are input files (stdin if none)."
3090
3091#define sed_example_usage \
3092 "$ echo \"foo\" | sed -e 's/f[a-zA-Z]o/bar/g'\n" \
3093 "bar\n"
3094
3095#define selinuxenabled_trivial_usage NOUSAGE_STR
3096#define selinuxenabled_full_usage ""
3097
3098#define seq_trivial_usage \
3099 "[-w] [-s SEP] [FIRST [INC]] LAST"
3100#define seq_full_usage "\n\n" \
3101 "Print numbers from FIRST to LAST, in steps of INC.\n" \
3102 "FIRST, INC default to 1.\n" \
3103 "\nOptions:" \
3104 "\n -w Pad to last with leading zeros" \
3105 "\n -s SEP String separator" \
3106
3107#define sestatus_trivial_usage \
3108 "[-vb]"
3109#define sestatus_full_usage "\n\n" \
3110 " -v Verbose" \
3111 "\n -b Display current state of booleans" \
3112
3113#define setconsole_trivial_usage \
3114 "[-r" IF_FEATURE_SETCONSOLE_LONG_OPTIONS("|--reset") "] [DEVICE]"
3115#define setconsole_full_usage "\n\n" \
3116 "Redirect system console output to DEVICE (default: /dev/tty)\n" \
3117 "\nOptions:" \
3118 "\n -r Reset output to /dev/console" \
3119
3120#define setenforce_trivial_usage \
3121 "[Enforcing | Permissive | 1 | 0]"
3122#define setenforce_full_usage ""
3123
3124#define setfiles_trivial_usage \
3125 "[-dnpqsvW] [-e DIR]... [-o FILE] [-r alt_root_path]" \
3126 IF_FEATURE_SETFILES_CHECK_OPTION( \
3127 " [-c policyfile] spec_file" \
3128 ) \
3129 " pathname"
3130#define setfiles_full_usage "\n\n" \
3131 "Reset file contexts under pathname according to spec_file\n" \
3132 IF_FEATURE_SETFILES_CHECK_OPTION( \
3133 "\n -c FILE Check the validity of the contexts against the specified binary policy" \
3134 ) \
3135 "\n -d Show which specification matched each file" \
3136 "\n -l Log changes in file labels to syslog" \
3137 "\n -n Don't change any file labels" \
3138 "\n -q Suppress warnings" \
3139 "\n -r DIR Use an alternate root path" \
3140 "\n -e DIR Exclude DIR" \
3141 "\n -F Force reset of context to match file_context for customizable files" \
3142 "\n -o FILE Save list of files with incorrect context" \
3143 "\n -s Take a list of files from stdin (instead of command line)" \
3144 "\n -v Show changes in file labels, if type or role are changing" \
3145 "\n -vv Show changes in file labels, if type, role, or user are changing" \
3146 "\n -W Display warnings about entries that had no matching files" \
3147
3148#define setfont_trivial_usage \
3149 "FONT [-m MAPFILE] [-C TTY]"
3150#define setfont_full_usage "\n\n" \
3151 "Load a console font\n" \
3152 "\nOptions:" \
3153 "\n -m MAPFILE Load console screen map" \
3154 "\n -C TTY Affect TTY instead of /dev/tty" \
3155
3156#define setfont_example_usage \
3157 "$ setfont -m koi8-r /etc/i18n/fontname\n"
3158
3159#define setkeycodes_trivial_usage \
3160 "SCANCODE KEYCODE..."
3161#define setkeycodes_full_usage "\n\n" \
3162 "Set entries into the kernel's scancode-to-keycode map,\n" \
3163 "allowing unusual keyboards to generate usable keycodes.\n\n" \
3164 "SCANCODE may be either xx or e0xx (hexadecimal),\n" \
3165 "and KEYCODE is given in decimal." \
3166
3167#define setkeycodes_example_usage \
3168 "$ setkeycodes e030 127\n"
3169
3170#define setlogcons_trivial_usage \
3171 "N"
3172#define setlogcons_full_usage "\n\n" \
3173 "Redirect the kernel output to console N (0 for current)"
3174
3175#define setsebool_trivial_usage \
3176 "boolean value"
3177
3178#define setsebool_full_usage "\n\n" \
3179 "Change boolean setting"
3180
3181#define setsid_trivial_usage \
3182 "PROG ARGS"
3183#define setsid_full_usage "\n\n" \
3184 "Run PROG in a new session. PROG will have no controlling terminal\n" \
3185 "and will not be affected by keyboard signals (Ctrl-C etc).\n" \
3186 "See setsid(2) for details." \
3187
3188#define last_trivial_usage \
3189 ""IF_FEATURE_LAST_FANCY("[-HW] [-f FILE]")
3190#define last_full_usage "\n\n" \
3191 "Show listing of the last users that logged into the system" \
3192 IF_FEATURE_LAST_FANCY( "\n" \
3193 "\nOptions:" \
3194/* "\n -H Show header line" */ \
3195 "\n -W Display with no host column truncation" \
3196 "\n -f FILE Read from FILE instead of /var/log/wtmp" \
3197 )
3198
3199#define showkey_trivial_usage \
3200 "[-a | -k | -s]"
3201#define showkey_full_usage "\n\n" \
3202 "Show keys pressed\n" \
3203 "\nOptions:" \
3204 "\n -a Display decimal/octal/hex values of the keys" \
3205 "\n -k Display interpreted keycodes (default)" \
3206 "\n -s Display raw scan-codes" \
3207
3208#define slattach_trivial_usage \
3209 "[-cehmLF] [-s SPEED] [-p PROTOCOL] DEVICE"
3210#define slattach_full_usage "\n\n" \
3211 "Attach network interface(s) to serial line(s)\n" \
3212 "\nOptions:" \
3213 "\n -p PROT Set protocol (slip, cslip, slip6, clisp6 or adaptive)" \
3214 "\n -s SPD Set line speed" \
3215 "\n -e Exit after initializing device" \
3216 "\n -h Exit when the carrier is lost" \
3217 "\n -c PROG Run PROG when the line is hung up" \
3218 "\n -m Do NOT initialize the line in raw 8 bits mode" \
3219 "\n -L Enable 3-wire operation" \
3220 "\n -F Disable RTS/CTS flow control" \
3221
3222#define sleep_trivial_usage \
3223 IF_FEATURE_FANCY_SLEEP("[") "N" IF_FEATURE_FANCY_SLEEP("]...")
3224#define sleep_full_usage "\n\n" \
3225 IF_NOT_FEATURE_FANCY_SLEEP("Pause for N seconds") \
3226 IF_FEATURE_FANCY_SLEEP( \
3227 "Pause for a time equal to the total of the args given, where each arg can\n" \
3228 "have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays")
3229#define sleep_example_usage \
3230 "$ sleep 2\n" \
3231 "[2 second delay results]\n" \
3232 IF_FEATURE_FANCY_SLEEP( \
3233 "$ sleep 1d 3h 22m 8s\n" \
3234 "[98528 second delay results]\n")
3235
3236#define sort_trivial_usage \
3237 "[-nru" \
3238 IF_FEATURE_SORT_BIG("gMcszbdfimSTokt] [-o FILE] [-k start[.offset][opts][,end[.offset][opts]] [-t CHAR") \
3239 "] [FILE]..."
3240#define sort_full_usage "\n\n" \
3241 "Sort lines of text\n" \
3242 "\nOptions:" \
3243 IF_FEATURE_SORT_BIG( \
3244 "\n -b Ignore leading blanks" \
3245 "\n -c Check whether input is sorted" \
3246 "\n -d Dictionary order (blank or alphanumeric only)" \
3247 "\n -f Ignore case" \
3248 "\n -g General numerical sort" \
3249 "\n -i Ignore unprintable characters" \
3250 "\n -k Sort key" \
3251 "\n -M Sort month" \
3252 ) \
3253 "\n -n Sort numbers" \
3254 IF_FEATURE_SORT_BIG( \
3255 "\n -o Output to file" \
3256 "\n -k Sort by key" \
3257 "\n -t CHAR Key separator" \
3258 ) \
3259 "\n -r Reverse sort order" \
3260 IF_FEATURE_SORT_BIG( \
3261 "\n -s Stable (don't sort ties alphabetically)" \
3262 ) \
3263 "\n -u Suppress duplicate lines" \
3264 IF_FEATURE_SORT_BIG( \
3265 "\n -z Lines are terminated by NUL, not newline" \
3266 "\n -mST Ignored for GNU compatibility") \
3267
3268#define sort_example_usage \
3269 "$ echo -e \"e\\nf\\nb\\nd\\nc\\na\" | sort\n" \
3270 "a\n" \
3271 "b\n" \
3272 "c\n" \
3273 "d\n" \
3274 "e\n" \
3275 "f\n" \
3276 IF_FEATURE_SORT_BIG( \
3277 "$ echo -e \"c 3\\nb 2\\nd 2\" | $SORT -k 2,2n -k 1,1r\n" \
3278 "d 2\n" \
3279 "b 2\n" \
3280 "c 3\n" \
3281 ) \
3282 ""
3283
3284#define split_trivial_usage \
3285 "[OPTIONS] [INPUT [PREFIX]]"
3286#define split_full_usage "\n\n" \
3287 "Options:" \
3288 "\n -b N[k|m] Split by N (kilo|mega)bytes" \
3289 "\n -l N Split by N lines" \
3290 "\n -a N Use N letters as suffix" \
3291
3292#define split_example_usage \
3293 "$ split TODO foo\n" \
3294 "$ cat TODO | split -a 2 -l 2 TODO_\n"
3295
3296#define start_stop_daemon_trivial_usage \
3297 "[OPTIONS] [-S|-K] ... [-- ARGS...]"
3298#define start_stop_daemon_full_usage "\n\n" \
3299 "Search for matching processes, and then\n" \
3300 "-K: stop all matching processes.\n" \
3301 "-S: start a process unless a matching process is found.\n" \
3302 IF_FEATURE_START_STOP_DAEMON_LONG_OPTIONS( \
3303 "\nProcess matching:" \
3304 "\n -u,--user USERNAME|UID Match only this user's processes" \
3305 "\n -n,--name NAME Match processes with NAME" \
3306 "\n in comm field in /proc/PID/stat" \
3307 "\n -x,--exec EXECUTABLE Match processes with this command" \
3308 "\n in /proc/PID/cmdline" \
3309 "\n -p,--pidfile FILE Match a process with PID from the file" \
3310 "\n All specified conditions must match" \
3311 "\n-S only:" \
3312 "\n -x,--exec EXECUTABLE Program to run" \
3313 "\n -a,--startas NAME Zeroth argument" \
3314 "\n -b,--background Background" \
3315 IF_FEATURE_START_STOP_DAEMON_FANCY( \
3316 "\n -N,--nicelevel N Change nice level" \
3317 ) \
3318 "\n -c,--chuid USER[:[GRP]] Change to user/group" \
3319 "\n -m,--make-pidfile Write PID to the pidfile specified by -p" \
3320 "\n-K only:" \
3321 "\n -s,--signal SIG Signal to send" \
3322 "\n -t,--test Match only, exit with 0 if a process is found" \
3323 "\nOther:" \
3324 IF_FEATURE_START_STOP_DAEMON_FANCY( \
3325 "\n -o,--oknodo Exit with status 0 if nothing is done" \
3326 "\n -v,--verbose Verbose" \
3327 ) \
3328 "\n -q,--quiet Quiet" \
3329 ) \
3330 IF_NOT_FEATURE_START_STOP_DAEMON_LONG_OPTIONS( \
3331 "\nProcess matching:" \
3332 "\n -u USERNAME|UID Match only this user's processes" \
3333 "\n -n NAME Match processes with NAME" \
3334 "\n in comm field in /proc/PID/stat" \
3335 "\n -x EXECUTABLE Match processes with this command" \
3336 "\n command in /proc/PID/cmdline" \
3337 "\n -p FILE Match a process with PID from the file" \
3338 "\n All specified conditions must match" \
3339 "\n-S only:" \
3340 "\n -x EXECUTABLE Program to run" \
3341 "\n -a NAME Zeroth argument" \
3342 "\n -b Background" \
3343 IF_FEATURE_START_STOP_DAEMON_FANCY( \
3344 "\n -N N Change nice level" \
3345 ) \
3346 "\n -c USER[:[GRP]] Change to user/group" \
3347 "\n -m Write PID to the pidfile specified by -p" \
3348 "\n-K only:" \
3349 "\n -s SIG Signal to send" \
3350 "\n -t Match only, exit with 0 if a process is found" \
3351 "\nOther:" \
3352 IF_FEATURE_START_STOP_DAEMON_FANCY( \
3353 "\n -o Exit with status 0 if nothing is done" \
3354 "\n -v Verbose" \
3355 ) \
3356 "\n -q Quiet" \
3357 ) \
3358
3359#define stat_trivial_usage \
3360 "[OPTIONS] FILE..."
3361#define stat_full_usage "\n\n" \
3362 "Display file (default) or filesystem status\n" \
3363 "\nOptions:" \
3364 IF_FEATURE_STAT_FORMAT( \
3365 "\n -c fmt Use the specified format" \
3366 ) \
3367 "\n -f Display filesystem status" \
3368 "\n -L Follow links" \
3369 "\n -t Display info in terse form" \
3370 IF_SELINUX( \
3371 "\n -Z Print security context" \
3372 ) \
3373 IF_FEATURE_STAT_FORMAT( \
3374 "\n\nValid format sequences for files:\n" \
3375 " %a Access rights in octal\n" \
3376 " %A Access rights in human readable form\n" \
3377 " %b Number of blocks allocated (see %B)\n" \
3378 " %B The size in bytes of each block reported by %b\n" \
3379 " %d Device number in decimal\n" \
3380 " %D Device number in hex\n" \
3381 " %f Raw mode in hex\n" \
3382 " %F File type\n" \
3383 " %g Group ID of owner\n" \
3384 " %G Group name of owner\n" \
3385 " %h Number of hard links\n" \
3386 " %i Inode number\n" \
3387 " %n File name\n" \
3388 " %N File name, with -> TARGET if symlink\n" \
3389 " %o I/O block size\n" \
3390 " %s Total size, in bytes\n" \
3391 " %t Major device type in hex\n" \
3392 " %T Minor device type in hex\n" \
3393 " %u User ID of owner\n" \
3394 " %U User name of owner\n" \
3395 " %x Time of last access\n" \
3396 " %X Time of last access as seconds since Epoch\n" \
3397 " %y Time of last modification\n" \
3398 " %Y Time of last modification as seconds since Epoch\n" \
3399 " %z Time of last change\n" \
3400 " %Z Time of last change as seconds since Epoch\n" \
3401 "\nValid format sequences for file systems:\n" \
3402 " %a Free blocks available to non-superuser\n" \
3403 " %b Total data blocks in file system\n" \
3404 " %c Total file nodes in file system\n" \
3405 " %d Free file nodes in file system\n" \
3406 " %f Free blocks in file system\n" \
3407 IF_SELINUX( \
3408 " %C Security context in selinux\n" \
3409 ) \
3410 " %i File System ID in hex\n" \
3411 " %l Maximum length of filenames\n" \
3412 " %n File name\n" \
3413 " %s Block size (for faster transfer)\n" \
3414 " %S Fundamental block size (for block counts)\n" \
3415 " %t Type in hex\n" \
3416 " %T Type in human readable form" \
3417 ) \
3418
3419#define strings_trivial_usage \
3420 "[-afo] [-n LEN] [FILE]..."
3421#define strings_full_usage "\n\n" \
3422 "Display printable strings in a binary file\n" \
3423 "\nOptions:" \
3424 "\n -a Scan whole file (default)" \
3425 "\n -f Precede strings with filenames" \
3426 "\n -n LEN At least LEN characters form a string (default 4)" \
3427 "\n -o Precede strings with decimal offsets" \
3428
3429#define stty_trivial_usage \
3430 "[-a|g] [-F DEVICE] [SETTING]..."
3431#define stty_full_usage "\n\n" \
3432 "Without arguments, prints baud rate, line discipline,\n" \
3433 "and deviations from stty sane\n" \
3434 "\nOptions:" \
3435 "\n -F DEVICE Open device instead of stdin" \
3436 "\n -a Print all current settings in human-readable form" \
3437 "\n -g Print in stty-readable form" \
3438 "\n [SETTING] See manpage" \
3439
3440#define sulogin_trivial_usage \
3441 "[-t N] [TTY]"
3442#define sulogin_full_usage "\n\n" \
3443 "Single user login\n" \
3444 "\nOptions:" \
3445 "\n -t N Timeout" \
3446
3447#define sum_trivial_usage \
3448 "[-rs] [FILE]..."
3449#define sum_full_usage "\n\n" \
3450 "Checksum and count the blocks in a file\n" \
3451 "\nOptions:" \
3452 "\n -r Use BSD sum algorithm (1K blocks)" \
3453 "\n -s Use System V sum algorithm (512byte blocks)" \
3454
3455#define sv_trivial_usage \
3456 "[-v] [-w SEC] CMD SERVICE_DIR..."
3457#define sv_full_usage "\n\n" \
3458 "Control services monitored by runsv supervisor.\n" \
3459 "Commands (only first character is enough):\n" \
3460 "\n" \
3461 "status: query service status\n" \
3462 "up: if service isn't running, start it. If service stops, restart it\n" \
3463 "once: like 'up', but if service stops, don't restart it\n" \
3464 "down: send TERM and CONT signals. If ./run exits, start ./finish\n" \
3465 " if it exists. After it stops, don't restart service\n" \
3466 "exit: send TERM and CONT signals to service and log service. If they exit,\n" \
3467 " runsv exits too\n" \
3468 "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" \
3469 "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" \
3470
3471#define swapoff_trivial_usage \
3472 "[-a] [DEVICE]"
3473#define swapoff_full_usage "\n\n" \
3474 "Stop swapping on DEVICE\n" \
3475 "\nOptions:" \
3476 "\n -a Stop swapping on all swap devices" \
3477
3478#define swapon_trivial_usage \
3479 "[-a]" IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]"
3480#define swapon_full_usage "\n\n" \
3481 "Start swapping on DEVICE\n" \
3482 "\nOptions:" \
3483 "\n -a Start swapping on all swap devices" \
3484 IF_FEATURE_SWAPON_PRI( \
3485 "\n -p PRI Set swap device priority" \
3486 ) \
3487
3488#define switch_root_trivial_usage \
3489 "[-c /dev/console] NEW_ROOT NEW_INIT [ARGS]"
3490#define switch_root_full_usage "\n\n" \
3491 "Free initramfs and switch to another root fs:\n" \
3492 "chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,\n" \
3493 "execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.\n" \
3494 "\nOptions:" \
3495 "\n -c DEV Reopen stdio to DEV after switch" \
3496
3497#define sync_trivial_usage \
3498 ""
3499#define sync_full_usage "\n\n" \
3500 "Write all buffered blocks to disk"
3501
3502#define fsync_trivial_usage \
3503 "[-d] FILE..."
3504#define fsync_full_usage "\n\n" \
3505 "Write files' buffered blocks to disk\n" \
3506 "\nOptions:" \
3507 "\n -d Avoid syncing metadata"
3508
3509#define sysctl_trivial_usage \
3510 "[OPTIONS] [VALUE]..."
3511#define sysctl_full_usage "\n\n" \
3512 "Configure kernel parameters at runtime\n" \
3513 "\nOptions:" \
3514 "\n -n Don't print key names" \
3515 "\n -e Don't warn about unknown keys" \
3516 "\n -w Change sysctl setting" \
3517 "\n -p FILE Load sysctl settings from FILE (default /etc/sysctl.conf)" \
3518 "\n -a Display all values" \
3519 "\n -A Display all values in table form" \
3520
3521#define sysctl_example_usage \
3522 "sysctl [-n] [-e] variable...\n" \
3523 "sysctl [-n] [-e] -w variable=value...\n" \
3524 "sysctl [-n] [-e] -a\n" \
3525 "sysctl [-n] [-e] -p file (default /etc/sysctl.conf)\n" \
3526 "sysctl [-n] [-e] -A\n"
3527
3528#define syslogd_trivial_usage \
3529 "[OPTIONS]"
3530#define syslogd_full_usage "\n\n" \
3531 "System logging utility.\n" \
3532 "This version of syslogd ignores /etc/syslog.conf\n" \
3533 "\nOptions:" \
3534 "\n -n Run in foreground" \
3535 "\n -O FILE Log to given file (default:/var/log/messages)" \
3536 "\n -l N Set local log level" \
3537 "\n -S Smaller logging output" \
3538 IF_FEATURE_ROTATE_LOGFILE( \
3539 "\n -s SIZE Max size (KB) before rotate (default:200KB, 0=off)" \
3540 "\n -b N N rotated logs to keep (default:1, max=99, 0=purge)") \
3541 IF_FEATURE_REMOTE_LOG( \
3542 "\n -R HOST[:PORT] Log to IP or hostname on PORT (default PORT=514/UDP)" \
3543 "\n -L Log locally and via network (default is network only if -R)") \
3544 IF_FEATURE_SYSLOGD_DUP( \
3545 "\n -D Drop duplicates") \
3546 IF_FEATURE_IPC_SYSLOG( \
3547 "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)") \
3548 /* NB: -Csize shouldn't have space (because size is optional) */
3549/* "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */
3550
3551#define syslogd_example_usage \
3552 "$ syslogd -R masterlog:514\n" \
3553 "$ syslogd -R 192.168.1.1:601\n"
3554
3555#define tac_trivial_usage \
3556 "[FILE]..."
3557#define tac_full_usage "\n\n" \
3558 "Concatenate FILEs and print them in reverse"
3559
3560#define taskset_trivial_usage \
3561 "[-p] [MASK] [PID | PROG ARGS]"
3562#define taskset_full_usage "\n\n" \
3563 "Set or get CPU affinity\n" \
3564 "\nOptions:" \
3565 "\n -p Operate on an existing PID" \
3566
3567#define taskset_example_usage \
3568 "$ taskset 0x7 ./dgemm_test&\n" \
3569 "$ taskset -p 0x1 $!\n" \
3570 "pid 4790's current affinity mask: 7\n" \
3571 "pid 4790's new affinity mask: 1\n" \
3572 "$ taskset 0x7 /bin/sh -c './taskset -p 0x1 $$'\n" \
3573 "pid 6671's current affinity mask: 1\n" \
3574 "pid 6671's new affinity mask: 1\n" \
3575 "$ taskset -p 1\n" \
3576 "pid 1's current affinity mask: 3\n"
3577
3578#define tee_trivial_usage \
3579 "[-ai] [FILE]..."
3580#define tee_full_usage "\n\n" \
3581 "Copy stdin to each FILE, and also to stdout\n" \
3582 "\nOptions:" \
3583 "\n -a Append to the given FILEs, don't overwrite" \
3584 "\n -i Ignore interrupt signals (SIGINT)" \
3585
3586#define tee_example_usage \
3587 "$ echo \"Hello\" | tee /tmp/foo\n" \
3588 "$ cat /tmp/foo\n" \
3589 "Hello\n"
3590
3591#if ENABLE_FEATURE_TELNET_AUTOLOGIN
3592#define telnet_trivial_usage \
3593 "[-a] [-l USER] HOST [PORT]"
3594#define telnet_full_usage "\n\n" \
3595 "Connect to telnet server\n" \
3596 "\nOptions:" \
3597 "\n -a Automatic login with $USER variable" \
3598 "\n -l USER Automatic login as USER" \
3599
3600#else
3601#define telnet_trivial_usage \
3602 "HOST [PORT]"
3603#define telnet_full_usage "\n\n" \
3604 "Connect to telnet server"
3605#endif
3606
3607#define telnetd_trivial_usage \
3608 "[OPTIONS]"
3609#define telnetd_full_usage "\n\n" \
3610 "Handle incoming telnet connections" \
3611 IF_NOT_FEATURE_TELNETD_STANDALONE(" via inetd") "\n" \
3612 "\nOptions:" \
3613 "\n -l LOGIN Exec LOGIN on connect" \
3614 "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" \
3615 "\n -K Close connection as soon as login exits" \
3616 "\n (normally wait until all programs close slave pty)" \
3617 IF_FEATURE_TELNETD_STANDALONE( \
3618 "\n -p PORT Port to listen on" \
3619 "\n -b ADDR[:PORT] Address to bind to" \
3620 "\n -F Run in foreground" \
3621 "\n -i Inetd mode" \
3622 IF_FEATURE_TELNETD_INETD_WAIT( \
3623 "\n -w SEC Inetd 'wait' mode, linger time SEC" \
3624 "\n -S Log to syslog (implied by -i or without -F and -w)" \
3625 ) \
3626 )
3627
3628/* "test --help" does not print help (POSIX compat), only "[ --help" does.
3629 * We display "<applet> EXPRESSION ]" here (not "<applet> EXPRESSION")
3630 * Unfortunately, it screws up generated BusyBox.html. TODO. */
3631#define test_trivial_usage \
3632 "EXPRESSION ]"
3633#define test_full_usage "\n\n" \
3634 "Check file types, compare values etc. Return a 0/1 exit code\n" \
3635 "depending on logical value of EXPRESSION"
3636#define test_example_usage \
3637 "$ test 1 -eq 2\n" \
3638 "$ echo $?\n" \
3639 "1\n" \
3640 "$ test 1 -eq 1\n" \
3641 "$ echo $?\n" \
3642 "0\n" \
3643 "$ [ -d /etc ]\n" \
3644 "$ echo $?\n" \
3645 "0\n" \
3646 "$ [ -d /junk ]\n" \
3647 "$ echo $?\n" \
3648 "1\n"
3649
3650#define tc_trivial_usage \
3651 /*"[OPTIONS] "*/"OBJECT CMD [dev STRING]"
3652#define tc_full_usage "\n\n" \
3653 "OBJECT: {qdisc|class|filter}\n" \
3654 "CMD: {add|del|change|replace|show}\n" \
3655 "\n" \
3656 "qdisc [ handle QHANDLE ] [ root |"IF_FEATURE_TC_INGRESS(" ingress |")" parent CLASSID ]\n" \
3657 /* "[ estimator INTERVAL TIME_CONSTANT ]\n" */ \
3658 " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n" \
3659 " QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n" \
3660 "qdisc show [ dev STRING ]"IF_FEATURE_TC_INGRESS(" [ingress]")"\n" \
3661 "class [ classid CLASSID ] [ root | parent CLASSID ]\n" \
3662 " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n" \
3663 "class show [ dev STRING ] [ root | parent CLASSID ]\n" \
3664 "filter [ pref PRIO ] [ protocol PROTO ]\n" \
3665 /* "\t[ estimator INTERVAL TIME_CONSTANT ]\n" */ \
3666 " [ root | classid CLASSID ] [ handle FILTERID ]\n" \
3667 " [ [ FILTER_TYPE ] [ help | OPTIONS ] ]\n" \
3668 "filter show [ dev STRING ] [ root | parent CLASSID ]"
3669
3670#define tcpsvd_trivial_usage \
3671 "[-hEv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] IP PORT PROG"
3672/* with not-implemented options: */
3673/* "[-hpEvv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] [-i DIR|-x CDB] [-t SEC] IP PORT PROG" */
3674#define tcpsvd_full_usage "\n\n" \
3675 "Create TCP socket, bind to IP:PORT and listen\n" \
3676 "for incoming connection. Run PROG for each connection.\n" \
3677 "\n IP IP to listen on. '0' = all" \
3678 "\n PORT Port to listen on" \
3679 "\n PROG ARGS Program to run" \
3680 "\n -l NAME Local hostname (else looks up local hostname in DNS)" \
3681 "\n -u USER[:GRP] Change to user/group after bind" \
3682 "\n -c N Handle up to N connections simultaneously" \
3683 "\n -b N Allow a backlog of approximately N TCP SYNs" \
3684 "\n -C N[:MSG] Allow only up to N connections from the same IP." \
3685 "\n New connections from this IP address are closed" \
3686 "\n immediately. MSG is written to the peer before close" \
3687 "\n -h Look up peer's hostname" \
3688 "\n -E Don't set up environment variables" \
3689 "\n -v Verbose" \
3690
3691#define udpsvd_trivial_usage \
3692 "[-hEv] [-c N] [-u USER] [-l NAME] IP PORT PROG"
3693#define udpsvd_full_usage "\n\n" \
3694 "Create UDP socket, bind to IP:PORT and wait\n" \
3695 "for incoming packets. Run PROG for each packet,\n" \
3696 "redirecting all further packets with same peer ip:port to it.\n" \
3697 "\n IP IP to listen on. '0' = all" \
3698 "\n PORT Port to listen on" \
3699 "\n PROG ARGS Program to run" \
3700 "\n -l NAME Local hostname (else looks up local hostname in DNS)" \
3701 "\n -u USER[:GRP] Change to user/group after bind" \
3702 "\n -c N Handle up to N connections simultaneously" \
3703 "\n -h Look up peer's hostname" \
3704 "\n -E Don't set up environment variables" \
3705 "\n -v Verbose" \
3706
3707#define tftp_trivial_usage \
3708 "[OPTIONS] HOST [PORT]"
3709#define tftp_full_usage "\n\n" \
3710 "Transfer a file from/to tftp server\n" \
3711 "\nOptions:" \
3712 "\n -l FILE Local FILE" \
3713 "\n -r FILE Remote FILE" \
3714 IF_FEATURE_TFTP_GET( \
3715 "\n -g Get file" \
3716 ) \
3717 IF_FEATURE_TFTP_PUT( \
3718 "\n -p Put file" \
3719 ) \
3720 IF_FEATURE_TFTP_BLOCKSIZE( \
3721 "\n -b SIZE Transfer blocks of SIZE octets" \
3722 )
3723
3724#define tftpd_trivial_usage \
3725 "[-cr] [-u USER] [DIR]"
3726#define tftpd_full_usage "\n\n" \
3727 "Transfer a file on tftp client's request\n" \
3728 "\n" \
3729 "tftpd should be used as an inetd service.\n" \
3730 "tftpd's line for inetd.conf:\n" \
3731 " 69 dgram udp nowait root tftpd tftpd /files/to/serve\n" \
3732 "It also can be ran from udpsvd:\n" \
3733 " udpsvd -vE 0.0.0.0 69 tftpd /files/to/serve\n" \
3734 "\nOptions:" \
3735 "\n -r Prohibit upload" \
3736 "\n -c Allow file creation via upload" \
3737 "\n -u Access files as USER" \
3738
3739#define time_trivial_usage \
3740 "[-v] PROG ARGS"
3741#define time_full_usage "\n\n" \
3742 "Run PROG, display resource usage when it exits\n" \
3743 "\nOptions:" \
3744 "\n -v Verbose" \
3745
3746#define timeout_trivial_usage \
3747 "[-t SECS] [-s SIG] PROG ARGS"
3748#define timeout_full_usage "\n\n" \
3749 "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" \
3750 "Defaults: SECS: 10, SIG: TERM." \
3751
3752#define tr_trivial_usage \
3753 "[-cds] STRING1 [STRING2]"
3754#define tr_full_usage "\n\n" \
3755 "Translate, squeeze, or delete characters from stdin, writing to stdout\n" \
3756 "\nOptions:" \
3757 "\n -c Take complement of STRING1" \
3758 "\n -d Delete input characters coded STRING1" \
3759 "\n -s Squeeze multiple output characters of STRING2 into one character" \
3760
3761#define tr_example_usage \
3762 "$ echo \"gdkkn vnqkc\" | tr [a-y] [b-z]\n" \
3763 "hello world\n"
3764
3765#define traceroute_trivial_usage \
3766 "[-"IF_TRACEROUTE6("46")"FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]\n" \
3767 " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]\n" \
3768 " [-z PAUSE_MSEC] HOST [BYTES]"
3769#define traceroute_full_usage "\n\n" \
3770 "Trace the route to HOST\n" \
3771 "\nOptions:" \
3772 IF_TRACEROUTE6( \
3773 "\n -4,-6 Force IP or IPv6 name resolution" \
3774 ) \
3775 "\n -F Set the don't fragment bit" \
3776 "\n -I Use ICMP ECHO instead of UDP datagrams" \
3777 "\n -l Display the TTL value of the returned packet" \
3778 "\n -d Set SO_DEBUG options to socket" \
3779 "\n -n Print numeric addresses" \
3780 "\n -r Bypass routing tables, send directly to HOST" \
3781 "\n -v Verbose" \
3782 "\n -m Max time-to-live (max number of hops)" \
3783 "\n -p Base UDP port number used in probes" \
3784 "\n (default 33434)" \
3785 "\n -q Number of probes per TTL (default 3)" \
3786 "\n -s IP address to use as the source address" \
3787 "\n -t Type-of-service in probe packets (default 0)" \
3788 "\n -w Time in seconds to wait for a response (default 3)" \
3789 "\n -g Loose source route gateway (8 max)" \
3790
3791#define traceroute6_trivial_usage \
3792 "[-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES]\n" \
3793 " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE]\n" \
3794 " HOST [BYTES]"
3795#define traceroute6_full_usage "\n\n" \
3796 "Trace the route to HOST\n" \
3797 "\nOptions:" \
3798 "\n -d Set SO_DEBUG options to socket" \
3799 "\n -n Print numeric addresses" \
3800 "\n -r Bypass routing tables, send directly to HOST" \
3801 "\n -v Verbose" \
3802 "\n -m Max time-to-live (max number of hops)" \
3803 "\n -p Base UDP port number used in probes" \
3804 "\n (default is 33434)" \
3805 "\n -q Number of probes per TTL (default 3)" \
3806 "\n -s IP address to use as the source address" \
3807 "\n -t Type-of-service in probe packets (default 0)" \
3808 "\n -w Time in seconds to wait for a response (default 3)" \
3809
3810#define true_trivial_usage \
3811 ""
3812#define true_full_usage "\n\n" \
3813 "Return an exit code of TRUE (0)"
3814#define true_example_usage \
3815 "$ true\n" \
3816 "$ echo $?\n" \
3817 "0\n"
3818
3819#define tty_trivial_usage \
3820 ""
3821#define tty_full_usage "\n\n" \
3822 "Print file name of stdin's terminal" \
3823 IF_INCLUDE_SUSv2( "\n" \
3824 "\nOptions:" \
3825 "\n -s Print nothing, only return exit status" \
3826 )
3827#define tty_example_usage \
3828 "$ tty\n" \
3829 "/dev/tty2\n"
3830
3831#define ttysize_trivial_usage \
3832 "[w] [h]"
3833#define ttysize_full_usage "\n\n" \
3834 "Print dimension(s) of stdin's terminal, on error return 80x25"
3835
3836#define tunctl_trivial_usage \
3837 "[-f device] ([-t name] | -d name)" IF_FEATURE_TUNCTL_UG(" [-u owner] [-g group] [-b]")
3838#define tunctl_full_usage "\n\n" \
3839 "Create or delete tun interfaces\n" \
3840 "\nOptions:" \
3841 "\n -f name tun device (/dev/net/tun)" \
3842 "\n -t name Create iface 'name'" \
3843 "\n -d name Delete iface 'name'" \
3844 IF_FEATURE_TUNCTL_UG( \
3845 "\n -u owner Set iface owner" \
3846 "\n -g group Set iface group" \
3847 "\n -b Brief output" \
3848 )
3849#define tunctl_example_usage \
3850 "# tunctl\n" \
3851 "# tunctl -d tun0\n"
3852
3853#define udhcpd_trivial_usage \
3854 "[-fS]" IF_FEATURE_UDHCP_PORT(" [-P N]") " [CONFFILE]" \
3855
3856#define udhcpd_full_usage "\n\n" \
3857 "DHCP server\n" \
3858 "\n -f Run in foreground" \
3859 "\n -S Log to syslog too" \
3860 IF_FEATURE_UDHCP_PORT( \
3861 "\n -P N Use port N (default 67)" \
3862 )
3863
3864#define umount_trivial_usage \
3865 "[OPTIONS] FILESYSTEM|DIRECTORY"
3866#define umount_full_usage "\n\n" \
3867 "Unmount file systems\n" \
3868 "\nOptions:" \
3869 IF_FEATURE_UMOUNT_ALL( \
3870 "\n -a Unmount all file systems" IF_FEATURE_MTAB_SUPPORT(" in /etc/mtab") \
3871 ) \
3872 IF_FEATURE_MTAB_SUPPORT( \
3873 "\n -n Don't erase /etc/mtab entries" \
3874 ) \
3875 "\n -r Try to remount devices as read-only if mount is busy" \
3876 "\n -l Lazy umount (detach filesystem)" \
3877 "\n -f Force umount (i.e., unreachable NFS server)" \
3878 IF_FEATURE_MOUNT_LOOP( \
3879 "\n -d Free loop device if it has been used" \
3880 )
3881
3882#define umount_example_usage \
3883 "$ umount /dev/hdc1\n"
3884
3885#define uname_trivial_usage \
3886 "[-amnrspv]"
3887#define uname_full_usage "\n\n" \
3888 "Print system information\n" \
3889 "\nOptions:" \
3890 "\n -a Print all" \
3891 "\n -m The machine (hardware) type" \
3892 "\n -n Hostname" \
3893 "\n -r OS release" \
3894 "\n -s OS name (default)" \
3895 "\n -p Processor type" \
3896 "\n -v OS version" \
3897
3898#define uname_example_usage \
3899 "$ uname -a\n" \
3900 "Linux debian 2.4.23 #2 Tue Dec 23 17:09:10 MST 2003 i686 GNU/Linux\n"
3901
3902#define uncompress_trivial_usage \
3903 "[-cf] [FILE]..."
3904#define uncompress_full_usage "\n\n" \
3905 "Decompress .Z file[s]\n" \
3906 "\nOptions:" \
3907 "\n -c Write to stdout" \
3908 "\n -f Overwrite" \
3909
3910#define unexpand_trivial_usage \
3911 "[-fa][-t N] [FILE]..."
3912#define unexpand_full_usage "\n\n" \
3913 "Convert spaces to tabs, writing to stdout\n" \
3914 "\nOptions:" \
3915 IF_FEATURE_UNEXPAND_LONG_OPTIONS( \
3916 "\n -a,--all Convert all blanks" \
3917 "\n -f,--first-only Convert only leading blanks" \
3918 "\n -t,--tabs=N Tabstops every N chars" \
3919 ) \
3920 IF_NOT_FEATURE_UNEXPAND_LONG_OPTIONS( \
3921 "\n -a Convert all blanks" \
3922 "\n -f Convert only leading blanks" \
3923 "\n -t N Tabstops every N chars" \
3924 )
3925
3926#define uniq_trivial_usage \
3927 "[-cdu][-f,s,w N] [INPUT [OUTPUT]]"
3928#define uniq_full_usage "\n\n" \
3929 "Discard duplicate lines\n" \
3930 "\nOptions:" \
3931 "\n -c Prefix lines by the number of occurrences" \
3932 "\n -d Only print duplicate lines" \
3933 "\n -u Only print unique lines" \
3934 "\n -f N Skip first N fields" \
3935 "\n -s N Skip first N chars (after any skipped fields)" \
3936 "\n -w N Compare N characters in line" \
3937
3938#define uniq_example_usage \
3939 "$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n" \
3940 "a\n" \
3941 "b\n" \
3942 "c\n"
3943
3944#define unzip_trivial_usage \
3945 "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
3946#define unzip_full_usage "\n\n" \
3947 "Extract files from ZIP archives\n" \
3948 "\nOptions:" \
3949 "\n -l List archive contents (with -q for short form)" \
3950 "\n -n Never overwrite files (default)" \
3951 "\n -o Overwrite" \
3952 "\n -p Send output to stdout" \
3953 "\n -q Quiet" \
3954 "\n -x XLST Exclude these files" \
3955 "\n -d DIR Extract files into DIR" \
3956
3957#define uptime_trivial_usage \
3958 ""
3959#define uptime_full_usage "\n\n" \
3960 "Display the time since the last boot"
3961
3962#define uptime_example_usage \
3963 "$ uptime\n" \
3964 " 1:55pm up 2:30, load average: 0.09, 0.04, 0.00\n"
3965
3966#define usleep_trivial_usage \
3967 "N"
3968#define usleep_full_usage "\n\n" \
3969 "Pause for N microseconds"
3970
3971#define usleep_example_usage \
3972 "$ usleep 1000000\n" \
3973 "[pauses for 1 second]\n"
3974
3975#define uudecode_trivial_usage \
3976 "[-o OUTFILE] [INFILE]"
3977#define uudecode_full_usage "\n\n" \
3978 "Uudecode a file\n" \
3979 "Finds outfile name in uuencoded source unless -o is given"
3980
3981#define uudecode_example_usage \
3982 "$ uudecode -o busybox busybox.uu\n" \
3983 "$ ls -l busybox\n" \
3984 "-rwxr-xr-x 1 ams ams 245264 Jun 7 21:35 busybox\n"
3985
3986#define uuencode_trivial_usage \
3987 "[-m] [INFILE] STORED_FILENAME"
3988#define uuencode_full_usage "\n\n" \
3989 "Uuencode a file to stdout\n" \
3990 "\nOptions:" \
3991 "\n -m Use base64 encoding per RFC1521" \
3992
3993#define uuencode_example_usage \
3994 "$ uuencode busybox busybox\n" \
3995 "begin 755 busybox\n" \
3996 "<encoded file snipped>\n" \
3997 "$ uudecode busybox busybox > busybox.uu\n" \
3998 "$\n"
3999
4000#define vconfig_trivial_usage \
4001 "COMMAND [OPTIONS]"
4002#define vconfig_full_usage "\n\n" \
4003 "Create and remove virtual ethernet devices\n" \
4004 "\nOptions:" \
4005 "\n add [interface-name] [vlan_id]" \
4006 "\n rem [vlan-name]" \
4007 "\n set_flag [interface-name] [flag-num] [0 | 1]" \
4008 "\n set_egress_map [vlan-name] [skb_priority] [vlan_qos]" \
4009 "\n set_ingress_map [vlan-name] [skb_priority] [vlan_qos]" \
4010 "\n set_name_type [name-type]" \
4011
4012#define vi_trivial_usage \
4013 "[OPTIONS] [FILE]..."
4014#define vi_full_usage "\n\n" \
4015 "Edit FILE\n" \
4016 "\nOptions:" \
4017 IF_FEATURE_VI_COLON( \
4018 "\n -c Initial command to run ($EXINIT also available)" \
4019 ) \
4020 IF_FEATURE_VI_READONLY( \
4021 "\n -R Read-only" \
4022 ) \
4023 "\n -H Short help regarding available features" \
4024
4025#define vlock_trivial_usage \
4026 "[-a]"
4027#define vlock_full_usage "\n\n" \
4028 "Lock a virtual terminal. A password is required to unlock.\n" \
4029 "\nOptions:" \
4030 "\n -a Lock all VTs" \
4031
4032#define volname_trivial_usage \
4033 "[DEVICE]"
4034#define volname_full_usage "\n\n" \
4035 "Show CD volume name of the DEVICE (default /dev/cdrom)"
4036
4037#define wall_trivial_usage \
4038 "[FILE]"
4039#define wall_full_usage "\n\n" \
4040 "Write content of FILE or stdin to all logged-in users"
4041#define wall_sample_usage \
4042 "echo foo | wall\n" \
4043 "wall ./mymessage"
4044
4045#define watch_trivial_usage \
4046 "[-n SEC] [-t] PROG ARGS"
4047#define watch_full_usage "\n\n" \
4048 "Run PROG periodically\n" \
4049 "\nOptions:" \
4050 "\n -n Loop period in seconds (default 2)" \
4051 "\n -t Don't print header" \
4052
4053#define watch_example_usage \
4054 "$ watch date\n" \
4055 "Mon Dec 17 10:31:40 GMT 2000\n" \
4056 "Mon Dec 17 10:31:42 GMT 2000\n" \
4057 "Mon Dec 17 10:31:44 GMT 2000"
4058
4059#define watchdog_trivial_usage \
4060 "[-t N[ms]] [-T N[ms]] [-F] DEV"
4061#define watchdog_full_usage "\n\n" \
4062 "Periodically write to watchdog device DEV\n" \
4063 "\nOptions:" \
4064 "\n -T N Reboot after N seconds if not reset (default 60)" \
4065 "\n -t N Reset every N seconds (default 30)" \
4066 "\n -F Run in foreground" \
4067 "\n" \
4068 "\nUse 500ms to specify period in milliseconds" \
4069
4070#define which_trivial_usage \
4071 "[COMMAND]..."
4072#define which_full_usage "\n\n" \
4073 "Locate a COMMAND"
4074#define which_example_usage \
4075 "$ which login\n" \
4076 "/bin/login\n"
4077
4078#define who_trivial_usage \
4079 "[-a]"
4080#define who_full_usage "\n\n" \
4081 "Show who is logged on\n" \
4082 "\nOptions:" \
4083 "\n -a Show all" \
4084
4085#define whoami_trivial_usage \
4086 ""
4087#define whoami_full_usage "\n\n" \
4088 "Print the user name associated with the current effective user id"
4089
4090#define zcat_trivial_usage \
4091 "FILE"
4092#define zcat_full_usage "\n\n" \
4093 "Decompress to stdout"
4094
4095#define zcip_trivial_usage \
4096 "[OPTIONS] IFACE SCRIPT"
4097#define zcip_full_usage "\n\n" \
4098 "Manage a ZeroConf IPv4 link-local address\n" \
4099 "\nOptions:" \
4100 "\n -f Run in foreground" \
4101 "\n -q Quit after obtaining address" \
4102 "\n -r 169.254.x.x Request this address first" \
4103 "\n -v Verbose" \
4104 "\n" \
4105 "\nWith no -q, runs continuously monitoring for ARP conflicts," \
4106 "\nexits only on I/O errors (link down etc)" \
4107
4108
4109#endif 22#endif
diff --git a/init/mesg.c b/init/mesg.c
index 8489e621c..45c13b8e0 100644
--- a/init/mesg.c
+++ b/init/mesg.c
@@ -60,17 +60,17 @@ int mesg_main(int argc UNUSED_PARAM, char **argv)
60 bb_show_usage(); 60 bb_show_usage();
61 } 61 }
62 62
63 if (!isatty(STDERR_FILENO)) 63 if (!isatty(STDIN_FILENO))
64 bb_error_msg_and_die("not a tty"); 64 bb_error_msg_and_die("not a tty");
65 65
66 xfstat(STDERR_FILENO, &sb, "stderr"); 66 xfstat(STDIN_FILENO, &sb, "stderr");
67 if (c == 0) { 67 if (c == 0) {
68 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); 68 puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n");
69 return EXIT_SUCCESS; 69 return EXIT_SUCCESS;
70 } 70 }
71 m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH 71 m = (c == 'y') ? sb.st_mode | S_IWGRP_OR_S_IWOTH
72 : sb.st_mode & ~(S_IWGRP|S_IWOTH); 72 : sb.st_mode & ~(S_IWGRP|S_IWOTH);
73 if (fchmod(STDERR_FILENO, m) != 0) 73 if (fchmod(STDIN_FILENO, m) != 0)
74 bb_perror_nomsg_and_die(); 74 bb_perror_nomsg_and_die();
75 return EXIT_SUCCESS; 75 return EXIT_SUCCESS;
76} 76}
diff --git a/libbb/Config.src b/libbb/Config.src
index a25af23b4..0ea8f43ab 100644
--- a/libbb/Config.src
+++ b/libbb/Config.src
@@ -80,11 +80,12 @@ config FEATURE_EDITING_VI
80 80
81config FEATURE_EDITING_HISTORY 81config FEATURE_EDITING_HISTORY
82 int "History size" 82 int "History size"
83 range 0 99999 83 # Don't allow way too big values here, code uses fixed "char *history[N]" struct member
84 range 0 9999
84 default 255 85 default 255
85 depends on FEATURE_EDITING 86 depends on FEATURE_EDITING
86 help 87 help
87 Specify command history size. 88 Specify command history size (0 - disable).
88 89
89config FEATURE_EDITING_SAVEHISTORY 90config FEATURE_EDITING_SAVEHISTORY
90 bool "History saving" 91 bool "History saving"
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 50e53aa25..a934f11bb 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -442,7 +442,7 @@ static void parse_config_file(void)
442 sct->m_mode |= mode_mask[(q - mode_chars) - i]; 442 sct->m_mode |= mode_mask[(q - mode_chars) - i];
443 } 443 }
444 444
445 /* Now get the the user/group info. */ 445 /* Now get the user/group info. */
446 446
447 s = skip_whitespace(e); 447 s = skip_whitespace(e);
448 448
diff --git a/libbb/get_line_from_file.c b/libbb/get_line_from_file.c
index a0ed9193f..9be10687b 100644
--- a/libbb/get_line_from_file.c
+++ b/libbb/get_line_from_file.c
@@ -44,8 +44,12 @@ char* FAST_FUNC bb_get_chunk_with_continuation(FILE *file, int *end, int *lineno
44 idx -= 2; 44 idx -= 2;
45 } 45 }
46 } 46 }
47 if (end) 47 if (end) {
48 *end = idx; 48 *end = idx;
49 /* handle corner case when the file is not ended with '\n' */
50 if (ch == EOF && lineno != NULL)
51 (*lineno)++;
52 }
49 if (linebuf) { 53 if (linebuf) {
50 // huh, does fgets discard prior data on error like this? 54 // huh, does fgets discard prior data on error like this?
51 // I don't think so.... 55 // I don't think so....
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 92ecc330a..67c5e0baa 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -204,65 +204,82 @@ static void deinit_S(void)
204#if ENABLE_UNICODE_SUPPORT 204#if ENABLE_UNICODE_SUPPORT
205static size_t load_string(const char *src, int maxsize) 205static size_t load_string(const char *src, int maxsize)
206{ 206{
207 ssize_t len = mbstowcs(command_ps, src, maxsize - 1); 207 if (unicode_status == UNICODE_ON) {
208 if (len < 0) 208 ssize_t len = mbstowcs(command_ps, src, maxsize - 1);
209 len = 0; 209 if (len < 0)
210 command_ps[len] = BB_NUL; 210 len = 0;
211 return len; 211 command_ps[len] = BB_NUL;
212 return len;
213 } else {
214 unsigned i = 0;
215 while ((command_ps[i] = src[i]) != 0)
216 i++;
217 return i;
218 }
212} 219}
213static unsigned save_string(char *dst, unsigned maxsize) 220static unsigned save_string(char *dst, unsigned maxsize)
214{ 221{
222 if (unicode_status == UNICODE_ON) {
215# if !ENABLE_UNICODE_PRESERVE_BROKEN 223# if !ENABLE_UNICODE_PRESERVE_BROKEN
216 ssize_t len = wcstombs(dst, command_ps, maxsize - 1); 224 ssize_t len = wcstombs(dst, command_ps, maxsize - 1);
217 if (len < 0) 225 if (len < 0)
218 len = 0; 226 len = 0;
219 dst[len] = '\0'; 227 dst[len] = '\0';
220 return len; 228 return len;
221# else 229# else
222 unsigned dstpos = 0; 230 unsigned dstpos = 0;
223 unsigned srcpos = 0; 231 unsigned srcpos = 0;
224 232
225 maxsize--; 233 maxsize--;
226 while (dstpos < maxsize) { 234 while (dstpos < maxsize) {
227 wchar_t wc; 235 wchar_t wc;
228 int n = srcpos; 236 int n = srcpos;
229 237
230 /* Convert up to 1st invalid byte (or up to end) */ 238 /* Convert up to 1st invalid byte (or up to end) */
231 while ((wc = command_ps[srcpos]) != BB_NUL 239 while ((wc = command_ps[srcpos]) != BB_NUL
232 && !unicode_is_raw_byte(wc) 240 && !unicode_is_raw_byte(wc)
233 ) { 241 ) {
242 srcpos++;
243 }
244 command_ps[srcpos] = BB_NUL;
245 n = wcstombs(dst + dstpos, command_ps + n, maxsize - dstpos);
246 if (n < 0) /* should not happen */
247 break;
248 dstpos += n;
249 if (wc == BB_NUL) /* usually is */
250 break;
251
252 /* We do have invalid byte here! */
253 command_ps[srcpos] = wc; /* restore it */
234 srcpos++; 254 srcpos++;
255 if (dstpos == maxsize)
256 break;
257 dst[dstpos++] = (char) wc;
235 } 258 }
236 command_ps[srcpos] = BB_NUL; 259 dst[dstpos] = '\0';
237 n = wcstombs(dst + dstpos, command_ps + n, maxsize - dstpos); 260 return dstpos;
238 if (n < 0) /* should not happen */
239 break;
240 dstpos += n;
241 if (wc == BB_NUL) /* usually is */
242 break;
243
244 /* We do have invalid byte here! */
245 command_ps[srcpos] = wc; /* restore it */
246 srcpos++;
247 if (dstpos == maxsize)
248 break;
249 dst[dstpos++] = (char) wc;
250 }
251 dst[dstpos] = '\0';
252 return dstpos;
253# endif 261# endif
262 } else {
263 unsigned i = 0;
264 while ((dst[i] = command_ps[i]) != 0)
265 i++;
266 return i;
267 }
254} 268}
255/* I thought just fputwc(c, stdout) would work. But no... */ 269/* I thought just fputwc(c, stdout) would work. But no... */
256static void BB_PUTCHAR(wchar_t c) 270static void BB_PUTCHAR(wchar_t c)
257{ 271{
258 char buf[MB_CUR_MAX + 1]; 272 if (unicode_status == UNICODE_ON) {
259 mbstate_t mbst = { 0 }; 273 char buf[MB_CUR_MAX + 1];
260 ssize_t len; 274 mbstate_t mbst = { 0 };
261 275 ssize_t len = wcrtomb(buf, c, &mbst);
262 len = wcrtomb(buf, c, &mbst); 276 if (len > 0) {
263 if (len > 0) { 277 buf[len] = '\0';
264 buf[len] = '\0'; 278 fputs(buf, stdout);
265 fputs(buf, stdout); 279 }
280 } else {
281 /* In this case, c is always one byte */
282 putchar(c);
266 } 283 }
267} 284}
268# if ENABLE_UNICODE_COMBINING_WCHARS || ENABLE_UNICODE_WIDE_WCHARS 285# if ENABLE_UNICODE_COMBINING_WCHARS || ENABLE_UNICODE_WIDE_WCHARS
@@ -1234,12 +1251,26 @@ line_input_t* FAST_FUNC new_line_input_t(int flags)
1234{ 1251{
1235 line_input_t *n = xzalloc(sizeof(*n)); 1252 line_input_t *n = xzalloc(sizeof(*n));
1236 n->flags = flags; 1253 n->flags = flags;
1254 n->max_history = MAX_HISTORY;
1237 return n; 1255 return n;
1238} 1256}
1239 1257
1240 1258
1241#if MAX_HISTORY > 0 1259#if MAX_HISTORY > 0
1242 1260
1261unsigned size_from_HISTFILESIZE(const char *hp)
1262{
1263 int size = MAX_HISTORY;
1264 if (hp) {
1265 size = atoi(hp);
1266 if (size <= 0)
1267 return 1;
1268 if (size > MAX_HISTORY)
1269 return MAX_HISTORY;
1270 }
1271 return size;
1272}
1273
1243static void save_command_ps_at_cur_history(void) 1274static void save_command_ps_at_cur_history(void)
1244{ 1275{
1245 if (command_ps[0] != BB_NUL) { 1276 if (command_ps[0] != BB_NUL) {
@@ -1330,7 +1361,7 @@ static void load_history(line_input_t *st_parm)
1330 temp_h[idx] = line; 1361 temp_h[idx] = line;
1331 st_parm->cnt_history_in_file++; 1362 st_parm->cnt_history_in_file++;
1332 idx++; 1363 idx++;
1333 if (idx == MAX_HISTORY) 1364 if (idx == st_parm->max_history)
1334 idx = 0; 1365 idx = 0;
1335 } 1366 }
1336 fclose(fp); 1367 fclose(fp);
@@ -1339,18 +1370,18 @@ static void load_history(line_input_t *st_parm)
1339 if (st_parm->cnt_history_in_file) { 1370 if (st_parm->cnt_history_in_file) {
1340 while (temp_h[idx] == NULL) { 1371 while (temp_h[idx] == NULL) {
1341 idx++; 1372 idx++;
1342 if (idx == MAX_HISTORY) 1373 if (idx == st_parm->max_history)
1343 idx = 0; 1374 idx = 0;
1344 } 1375 }
1345 } 1376 }
1346 1377
1347 /* copy temp_h[] to st_parm->history[] */ 1378 /* copy temp_h[] to st_parm->history[] */
1348 for (i = 0; i < MAX_HISTORY;) { 1379 for (i = 0; i < st_parm->max_history;) {
1349 line = temp_h[idx]; 1380 line = temp_h[idx];
1350 if (!line) 1381 if (!line)
1351 break; 1382 break;
1352 idx++; 1383 idx++;
1353 if (idx == MAX_HISTORY) 1384 if (idx == st_parm->max_history)
1354 idx = 0; 1385 idx = 0;
1355 line_len = strlen(line); 1386 line_len = strlen(line);
1356 if (line_len >= MAX_LINELEN) 1387 if (line_len >= MAX_LINELEN)
@@ -1381,7 +1412,7 @@ static void save_history(char *str)
1381 1412
1382 /* did we write so much that history file needs trimming? */ 1413 /* did we write so much that history file needs trimming? */
1383 state->cnt_history_in_file++; 1414 state->cnt_history_in_file++;
1384 if (state->cnt_history_in_file > MAX_HISTORY * 4) { 1415 if (state->cnt_history_in_file > state->max_history * 4) {
1385 char *new_name; 1416 char *new_name;
1386 line_input_t *st_temp; 1417 line_input_t *st_temp;
1387 1418
@@ -1389,6 +1420,7 @@ static void save_history(char *str)
1389 * load them */ 1420 * load them */
1390 st_temp = new_line_input_t(state->flags); 1421 st_temp = new_line_input_t(state->flags);
1391 st_temp->hist_file = state->hist_file; 1422 st_temp->hist_file = state->hist_file;
1423 st_temp->max_history = state->max_history;
1392 load_history(st_temp); 1424 load_history(st_temp);
1393 1425
1394 /* write out temp file and replace hist_file atomically */ 1426 /* write out temp file and replace hist_file atomically */
@@ -1427,20 +1459,20 @@ static void remember_in_history(char *str)
1427 if (i && strcmp(state->history[i-1], str) == 0) 1459 if (i && strcmp(state->history[i-1], str) == 0)
1428 return; 1460 return;
1429 1461
1430 free(state->history[MAX_HISTORY]); /* redundant, paranoia */ 1462 free(state->history[state->max_history]); /* redundant, paranoia */
1431 state->history[MAX_HISTORY] = NULL; /* redundant, paranoia */ 1463 state->history[state->max_history] = NULL; /* redundant, paranoia */
1432 1464
1433 /* If history[] is full, remove the oldest command */ 1465 /* If history[] is full, remove the oldest command */
1434 /* we need to keep history[MAX_HISTORY] empty, hence >=, not > */ 1466 /* we need to keep history[state->max_history] empty, hence >=, not > */
1435 if (i >= MAX_HISTORY) { 1467 if (i >= state->max_history) {
1436 free(state->history[0]); 1468 free(state->history[0]);
1437 for (i = 0; i < MAX_HISTORY-1; i++) 1469 for (i = 0; i < state->max_history-1; i++)
1438 state->history[i] = state->history[i+1]; 1470 state->history[i] = state->history[i+1];
1439 /* i == MAX_HISTORY-1 */ 1471 /* i == state->max_history-1 */
1440 } 1472 }
1441 /* i <= MAX_HISTORY-1 */ 1473 /* i <= state->max_history-1 */
1442 state->history[i++] = xstrdup(str); 1474 state->history[i++] = xstrdup(str);
1443 /* i <= MAX_HISTORY */ 1475 /* i <= state->max_history */
1444 state->cur_history = i; 1476 state->cur_history = i;
1445 state->cnt_history = i; 1477 state->cnt_history = i;
1446# if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY 1478# if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY
@@ -1968,7 +2000,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
1968 maxsize = MAX_LINELEN; 2000 maxsize = MAX_LINELEN;
1969 S.maxsize = maxsize; 2001 S.maxsize = maxsize;
1970 2002
1971 /* With null flags, no other fields are ever used */ 2003 /* With zero flags, no other fields are ever used */
1972 state = st ? st : (line_input_t*) &const_int_0; 2004 state = st ? st : (line_input_t*) &const_int_0;
1973#if MAX_HISTORY > 0 2005#if MAX_HISTORY > 0
1974# if ENABLE_FEATURE_EDITING_SAVEHISTORY 2006# if ENABLE_FEATURE_EDITING_SAVEHISTORY
@@ -2020,7 +2052,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2020#endif 2052#endif
2021 2053
2022#if 0 2054#if 0
2023 for (i = 0; i <= MAX_HISTORY; i++) 2055 for (i = 0; i <= state->max_history; i++)
2024 bb_error_msg("history[%d]:'%s'", i, state->history[i]); 2056 bb_error_msg("history[%d]:'%s'", i, state->history[i]);
2025 bb_error_msg("cur_history:%d cnt_history:%d", state->cur_history, state->cnt_history); 2057 bb_error_msg("cur_history:%d cnt_history:%d", state->cur_history, state->cnt_history);
2026#endif 2058#endif
diff --git a/libbb/parse_config.c b/libbb/parse_config.c
index d471edbee..4b0236028 100644
--- a/libbb/parse_config.c
+++ b/libbb/parse_config.c
@@ -8,6 +8,12 @@
8 * Also for use in uClibc (http://uclibc.org/) licensed under LGPLv2.1 or later. 8 * Also for use in uClibc (http://uclibc.org/) licensed under LGPLv2.1 or later.
9 */ 9 */
10 10
11/*
12//usage:#define parse_trivial_usage
13//usage: "[-n MAXTOKENS] [-m MINTOKENS] [-d DELIMS] [-f FLAGS] FILE..."
14//usage:#define parse_full_usage ""
15*/
16
11#include "libbb.h" 17#include "libbb.h"
12 18
13#if defined ENABLE_PARSE && ENABLE_PARSE 19#if defined ENABLE_PARSE && ENABLE_PARSE
diff --git a/libbb/platform.c b/libbb/platform.c
index 1441a84ac..c594dcb4a 100644
--- a/libbb/platform.c
+++ b/libbb/platform.c
@@ -42,9 +42,9 @@ int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p)
42} 42}
43#endif 43#endif
44 44
45#ifndef HAVE_FDPRINTF 45#ifndef HAVE_DPRINTF
46/* dprintf is now actually part of POSIX.1, but was only added in 2008 */ 46/* dprintf is now part of POSIX.1, but was only added in 2008 */
47int fdprintf(int fd, const char *format, ...) 47int dprintf(int fd, const char *format, ...)
48{ 48{
49 va_list p; 49 va_list p;
50 int r; 50 int r;
diff --git a/libbb/single_argv.c b/libbb/single_argv.c
index 85137b40f..64844ddf8 100644
--- a/libbb/single_argv.c
+++ b/libbb/single_argv.c
@@ -10,6 +10,8 @@
10 10
11char* FAST_FUNC single_argv(char **argv) 11char* FAST_FUNC single_argv(char **argv)
12{ 12{
13 if (argv[1] && strcmp(argv[1], "--") == 0)
14 argv++;
13 if (!argv[1] || argv[2]) 15 if (!argv[1] || argv[2])
14 bb_show_usage(); 16 bb_show_usage();
15 return argv[1]; 17 return argv[1];
diff --git a/libbb/unicode.c b/libbb/unicode.c
index d01efd9a2..99dc1dfa6 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -23,12 +23,13 @@ uint8_t unicode_status;
23 23
24/* Unicode support using libc locale support. */ 24/* Unicode support using libc locale support. */
25 25
26void FAST_FUNC reinit_unicode(const char *LANG UNUSED_PARAM) 26void FAST_FUNC reinit_unicode(const char *LANG)
27{ 27{
28 static const char unicode_0x394[] = { 0xce, 0x94, 0 }; 28 static const char unicode_0x394[] = { 0xce, 0x94, 0 };
29 size_t width; 29 size_t width;
30 30
31//TODO: call setlocale(LC_ALL, LANG) here? 31//TODO: avoid repeated calls by caching last string?
32 setlocale(LC_ALL, (LANG && LANG[0]) ? LANG : "C");
32 33
33 /* In unicode, this is a one character string */ 34 /* In unicode, this is a one character string */
34// can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused 35// can use unicode_strlen(string) too, but otherwise unicode_strlen() is unused
@@ -39,7 +40,7 @@ void FAST_FUNC reinit_unicode(const char *LANG UNUSED_PARAM)
39void FAST_FUNC init_unicode(void) 40void FAST_FUNC init_unicode(void)
40{ 41{
41 if (unicode_status == UNICODE_UNKNOWN) 42 if (unicode_status == UNICODE_UNKNOWN)
42 reinit_unicode(NULL /*getenv("LANG")*/); 43 reinit_unicode(getenv("LANG"));
43} 44}
44 45
45#else 46#else
diff --git a/libbb/xconnect.c b/libbb/xconnect.c
index 127e2a5fc..4b7c110d3 100644
--- a/libbb/xconnect.c
+++ b/libbb/xconnect.c
@@ -134,16 +134,18 @@ int FAST_FUNC get_nport(const struct sockaddr *sa)
134 return -1; 134 return -1;
135} 135}
136 136
137void FAST_FUNC set_nport(len_and_sockaddr *lsa, unsigned port) 137void FAST_FUNC set_nport(struct sockaddr *sa, unsigned port)
138{ 138{
139#if ENABLE_FEATURE_IPV6 139#if ENABLE_FEATURE_IPV6
140 if (lsa->u.sa.sa_family == AF_INET6) { 140 if (sa->sa_family == AF_INET6) {
141 lsa->u.sin6.sin6_port = port; 141 struct sockaddr_in6 *sin6 = (void*) sa;
142 sin6->sin6_port = port;
142 return; 143 return;
143 } 144 }
144#endif 145#endif
145 if (lsa->u.sa.sa_family == AF_INET) { 146 if (sa->sa_family == AF_INET) {
146 lsa->u.sin.sin_port = port; 147 struct sockaddr_in *sin = (void*) sa;
148 sin->sin_port = port;
147 return; 149 return;
148 } 150 }
149 /* What? UNIX socket? IPX?? :) */ 151 /* What? UNIX socket? IPX?? :) */
@@ -283,7 +285,7 @@ IF_NOT_FEATURE_IPV6(sa_family_t af = AF_INET;)
283 memcpy(&r->u.sa, used_res->ai_addr, used_res->ai_addrlen); 285 memcpy(&r->u.sa, used_res->ai_addr, used_res->ai_addrlen);
284 286
285 set_port: 287 set_port:
286 set_nport(r, htons(port)); 288 set_nport(&r->u.sa, htons(port));
287 ret: 289 ret:
288 if (result) 290 if (result)
289 freeaddrinfo(result); 291 freeaddrinfo(result);
@@ -369,7 +371,7 @@ static int create_and_bind_or_die(const char *bindaddr, int port, int sock_type)
369 fd = xsocket(lsa->u.sa.sa_family, sock_type, 0); 371 fd = xsocket(lsa->u.sa.sa_family, sock_type, 0);
370 } else { 372 } else {
371 fd = xsocket_type(&lsa, IF_FEATURE_IPV6(AF_UNSPEC,) sock_type); 373 fd = xsocket_type(&lsa, IF_FEATURE_IPV6(AF_UNSPEC,) sock_type);
372 set_nport(lsa, htons(port)); 374 set_nport(&lsa->u.sa, htons(port));
373 } 375 }
374 setsockopt_reuseaddr(fd); 376 setsockopt_reuseaddr(fd);
375 xbind(fd, &lsa->u.sa, lsa->len); 377 xbind(fd, &lsa->u.sa, lsa->len);
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 5a0714501..2d6736f1a 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -9,6 +9,15 @@
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 */ 11 */
12
13//usage:#define addgroup_trivial_usage
14//usage: "[-g GID] " IF_FEATURE_ADDUSER_TO_GROUP("[USER] ") "GROUP"
15//usage:#define addgroup_full_usage "\n\n"
16//usage: "Add a group " IF_FEATURE_ADDUSER_TO_GROUP("or add a user to a group") "\n"
17//usage: "\nOptions:"
18//usage: "\n -g GID Group id"
19//usage: "\n -S Create a system group"
20
12#include "libbb.h" 21#include "libbb.h"
13 22
14#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID 23#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 0c675caf9..1944d9d56 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -7,6 +7,21 @@
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//usage:#define adduser_trivial_usage
12//usage: "[OPTIONS] USER"
13//usage:#define adduser_full_usage "\n\n"
14//usage: "Add a user\n"
15//usage: "\nOptions:"
16//usage: "\n -h DIR Home directory"
17//usage: "\n -g GECOS GECOS field"
18//usage: "\n -s SHELL Login shell"
19//usage: "\n -G GRP Add user to existing group"
20//usage: "\n -S Create a system user"
21//usage: "\n -D Don't assign a password"
22//usage: "\n -H Don't create home directory"
23//usage: "\n -u UID User id"
24
10#include "libbb.h" 25#include "libbb.h"
11 26
12#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID 27#if CONFIG_LAST_SYSTEM_ID < CONFIG_FIRST_SYSTEM_ID
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index 48cf9b130..6c4296faa 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -7,6 +7,20 @@
7 */ 7 */
8#include "libbb.h" 8#include "libbb.h"
9 9
10//usage:#define chpasswd_trivial_usage
11//usage: IF_LONG_OPTS("[--md5|--encrypted]") IF_NOT_LONG_OPTS("[-m|-e]")
12//usage:#define chpasswd_full_usage "\n\n"
13//usage: "Read user:password from stdin and update /etc/passwd\n"
14//usage: "\nOptions:"
15//usage: IF_LONG_OPTS(
16//usage: "\n -e,--encrypted Supplied passwords are in encrypted form"
17//usage: "\n -m,--md5 Use MD5 encryption instead of DES"
18//usage: )
19//usage: IF_NOT_LONG_OPTS(
20//usage: "\n -e Supplied passwords are in encrypted form"
21//usage: "\n -m Use MD5 encryption instead of DES"
22//usage: )
23
10#if ENABLE_LONG_OPTS 24#if ENABLE_LONG_OPTS
11static const char chpasswd_longopts[] ALIGN1 = 25static const char chpasswd_longopts[] ALIGN1 =
12 "encrypted\0" No_argument "e" 26 "encrypted\0" No_argument "e"
@@ -53,7 +67,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
53 * we try to find & change his passwd in /etc/passwd */ 67 * we try to find & change his passwd in /etc/passwd */
54#if ENABLE_FEATURE_SHADOWPASSWDS 68#if ENABLE_FEATURE_SHADOWPASSWDS
55 rc = update_passwd(bb_path_shadow_file, name, pass, NULL); 69 rc = update_passwd(bb_path_shadow_file, name, pass, NULL);
56 if (rc == 0) /* no lines updated, no errors detected */ 70 if (rc > 0) /* password in /etc/shadow was updated */
71 pass = (char*)"x";
72 if (rc >= 0)
73 /* 0 = /etc/shadow missing (not an error), >0 = passwd changed in /etc/shadow */
57#endif 74#endif
58 rc = update_passwd(bb_path_passwd_file, name, pass, NULL); 75 rc = update_passwd(bb_path_passwd_file, name, pass, NULL);
59 /* LOGMODE_BOTH logs to syslog also */ 76 /* LOGMODE_BOTH logs to syslog also */
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index 6c801f9fa..72388c492 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -10,6 +10,45 @@
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 12
13//usage:#define cryptpw_trivial_usage
14//usage: "[OPTIONS] [PASSWORD] [SALT]"
15/* We do support -s, we just don't mention it */
16//usage:#define cryptpw_full_usage "\n\n"
17//usage: "Crypt the PASSWORD using crypt(3)\n"
18//usage: "\nOptions:"
19//usage: IF_LONG_OPTS(
20//usage: "\n -P,--password-fd=N Read password from fd N"
21/* //usage: "\n -s,--stdin Use stdin; like -P0" */
22//usage: "\n -m,--method=TYPE Encryption method TYPE"
23//usage: "\n -S,--salt=SALT"
24//usage: )
25//usage: IF_NOT_LONG_OPTS(
26//usage: "\n -P N Read password from fd N"
27/* //usage: "\n -s Use stdin; like -P0" */
28//usage: "\n -m TYPE Encryption method TYPE"
29//usage: "\n -S SALT"
30//usage: )
31
32/* mkpasswd is an alias to cryptpw */
33//usage:#define mkpasswd_trivial_usage
34//usage: "[OPTIONS] [PASSWORD] [SALT]"
35/* We do support -s, we just don't mention it */
36//usage:#define mkpasswd_full_usage "\n\n"
37//usage: "Crypt the PASSWORD using crypt(3)\n"
38//usage: "\nOptions:"
39//usage: IF_LONG_OPTS(
40//usage: "\n -P,--password-fd=N Read password from fd N"
41/* //usage: "\n -s,--stdin Use stdin; like -P0" */
42//usage: "\n -m,--method=TYPE Encryption method TYPE"
43//usage: "\n -S,--salt=SALT"
44//usage: )
45//usage: IF_NOT_LONG_OPTS(
46//usage: "\n -P N Read password from fd N"
47/* //usage: "\n -s Use stdin; like -P0" */
48//usage: "\n -m TYPE Encryption method TYPE"
49//usage: "\n -S SALT"
50//usage: )
51
13#include "libbb.h" 52#include "libbb.h"
14 53
15/* Debian has 'mkpasswd' utility, manpage says: 54/* Debian has 'mkpasswd' utility, manpage says:
diff --git a/loginutils/deluser.c b/loginutils/deluser.c
index 47a10fe14..e39ac5506 100644
--- a/loginutils/deluser.c
+++ b/loginutils/deluser.c
@@ -9,6 +9,18 @@
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 */ 11 */
12
13//usage:#define deluser_trivial_usage
14//usage: "USER"
15//usage:#define deluser_full_usage "\n\n"
16//usage: "Delete USER from the system"
17
18//usage:#define delgroup_trivial_usage
19//usage: IF_FEATURE_DEL_USER_FROM_GROUP("[USER] ")"GROUP"
20//usage:#define delgroup_full_usage "\n\n"
21//usage: "Delete group GROUP from the system"
22//usage: IF_FEATURE_DEL_USER_FROM_GROUP(" or user USER from group GROUP")
23
12#include "libbb.h" 24#include "libbb.h"
13 25
14int deluser_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 26int deluser_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/loginutils/login.c b/loginutils/login.c
index ce0d1741f..f2563dc09 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -2,6 +2,16 @@
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//usage:#define login_trivial_usage
7//usage: "[-p] [-h HOST] [[-f] USER]"
8//usage:#define login_full_usage "\n\n"
9//usage: "Begin a new session on the system\n"
10//usage: "\nOptions:"
11//usage: "\n -f Don't authenticate (user already authenticated)"
12//usage: "\n -h Name of the remote host"
13//usage: "\n -p Preserve environment"
14
5#include "libbb.h" 15#include "libbb.h"
6#include <syslog.h> 16#include <syslog.h>
7#include <sys/resource.h> 17#include <sys/resource.h>
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index f3928cecc..810644e61 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -2,6 +2,18 @@
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//usage:#define passwd_trivial_usage
7//usage: "[OPTIONS] [USER]"
8//usage:#define passwd_full_usage "\n\n"
9//usage: "Change USER's password. If no USER is specified,\n"
10//usage: "changes the password for the current user.\n"
11//usage: "\nOptions:"
12//usage: "\n -a ALG Algorithm to use for password (des, md5)" /* ", sha1)" */
13//usage: "\n -d Delete password for the account"
14//usage: "\n -l Lock (disable) account"
15//usage: "\n -u Unlock (re-enable) account"
16
5#include "libbb.h" 17#include "libbb.h"
6#include <syslog.h> 18#include <syslog.h>
7 19
@@ -172,8 +184,7 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
172 * strdup'ing to avoid nasty surprizes */ 184 * strdup'ing to avoid nasty surprizes */
173 newp = xstrdup(&pw->pw_passwd[1]); 185 newp = xstrdup(&pw->pw_passwd[1]);
174 } else if (opt & OPT_delete) { 186 } else if (opt & OPT_delete) {
175 //newp = xstrdup(""); 187 newp = (char*)""; //xstrdup("");
176 newp = (char*)"";
177 } 188 }
178 189
179 rlimit_fsize.rlim_cur = rlimit_fsize.rlim_max = 512L * 30000; 190 rlimit_fsize.rlim_cur = rlimit_fsize.rlim_max = 512L * 30000;
@@ -189,7 +200,11 @@ int passwd_main(int argc UNUSED_PARAM, char **argv)
189#if ENABLE_FEATURE_SHADOWPASSWDS 200#if ENABLE_FEATURE_SHADOWPASSWDS
190 filename = bb_path_shadow_file; 201 filename = bb_path_shadow_file;
191 rc = update_passwd(bb_path_shadow_file, name, newp, NULL); 202 rc = update_passwd(bb_path_shadow_file, name, newp, NULL);
192 if (rc == 0) /* no lines updated, no errors detected */ 203 if (rc > 0)
204 /* password in /etc/shadow was updated */
205 newp = (char*) "x"; //xstrdup("x");
206 if (rc >= 0)
207 /* 0 = /etc/shadow missing (not an error), >0 = passwd changed in /etc/shadow */
193#endif 208#endif
194 { 209 {
195 filename = bb_path_passwd_file; 210 filename = bb_path_passwd_file;
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 0e5b59433..28edf067c 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -5,6 +5,13 @@
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 7
8//usage:#define sulogin_trivial_usage
9//usage: "[-t N] [TTY]"
10//usage:#define sulogin_full_usage "\n\n"
11//usage: "Single user login\n"
12//usage: "\nOptions:"
13//usage: "\n -t N Timeout"
14
8#include "libbb.h" 15#include "libbb.h"
9#include <syslog.h> 16#include <syslog.h>
10 17
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index 3299afa50..efad63ff3 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -15,6 +15,13 @@
15/* Fixed by Erik Andersen to do passwords the tinylogin way... 15/* Fixed by Erik Andersen to do passwords the tinylogin way...
16 * It now works with md5, sha1, etc passwords. */ 16 * It now works with md5, sha1, etc passwords. */
17 17
18//usage:#define vlock_trivial_usage
19//usage: "[-a]"
20//usage:#define vlock_full_usage "\n\n"
21//usage: "Lock a virtual terminal. A password is required to unlock.\n"
22//usage: "\nOptions:"
23//usage: "\n -a Lock all VTs"
24
18#include "libbb.h" 25#include "libbb.h"
19 26
20#ifdef __linux__ 27#ifdef __linux__
diff --git a/mailutils/mime.c b/mailutils/mime.c
index 1e393ed31..0aff8b1d7 100644
--- a/mailutils/mime.c
+++ b/mailutils/mime.c
@@ -7,6 +7,33 @@
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//usage:#define makemime_trivial_usage
12//usage: "[OPTIONS] [FILE]..."
13//usage:#define makemime_full_usage "\n\n"
14//usage: "Create multipart MIME-encoded message from FILEs\n"
15/* //usage: "Transfer encoding is base64, disposition is inline (not attachment)\n" */
16//usage: "\nOptions:"
17//usage: "\n -o FILE Output. Default: stdout"
18//usage: "\n -a HDR Add header. Examples:"
19//usage: "\n \"From: user@host.org\", \"Date: `date -R`\""
20//usage: "\n -c CT Content type. Default: text/plain"
21//usage: "\n -C CS Charset. Default: " CONFIG_FEATURE_MIME_CHARSET
22/* //usage: "\n -e ENC Transfer encoding. Ignored. base64 is assumed" */
23//usage: "\n"
24//usage: "\nOther options are silently ignored"
25
26//usage:#define reformime_trivial_usage
27//usage: "[OPTIONS] [FILE]..."
28//usage:#define reformime_full_usage "\n\n"
29//usage: "Parse MIME-encoded message\n"
30//usage: "\nOptions:"
31//usage: "\n -x PREFIX Extract content of MIME sections to files"
32//usage: "\n -X PROG ARGS Filter content of MIME sections through PROG"
33//usage: "\n Must be the last option"
34//usage: "\n"
35//usage: "\nOther options are silently ignored"
36
10#include "libbb.h" 37#include "libbb.h"
11#include "mail.h" 38#include "mail.h"
12 39
diff --git a/mailutils/popmaildir.c b/mailutils/popmaildir.c
index 6b733441f..642657919 100644
--- a/mailutils/popmaildir.c
+++ b/mailutils/popmaildir.c
@@ -9,6 +9,40 @@
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//usage:#define popmaildir_trivial_usage
14//usage: "[OPTIONS] MAILDIR [CONN_HELPER ARGS]"
15//usage:#define popmaildir_full_usage "\n\n"
16//usage: "Fetch content of remote mailbox to local maildir\n"
17//usage: "\nOptions:"
18/* //usage: "\n -b Binary mode. Ignored" */
19/* //usage: "\n -d Debug. Ignored" */
20/* //usage: "\n -m Show used memory. Ignored" */
21/* //usage: "\n -V Show version. Ignored" */
22/* //usage: "\n -c Use tcpclient. Ignored" */
23/* //usage: "\n -a Use APOP protocol. Implied. If server supports APOP -> use it" */
24//usage: "\n -s Skip authorization"
25//usage: "\n -T Get messages with TOP instead of RETR"
26//usage: "\n -k Keep retrieved messages on the server"
27//usage: "\n -t SEC Network timeout"
28//usage: IF_FEATURE_POPMAILDIR_DELIVERY(
29//usage: "\n -F \"PROG ARGS\" Filter program (may be repeated)"
30//usage: "\n -M \"PROG ARGS\" Delivery program"
31//usage: )
32//usage: "\n"
33//usage: "\nFetch from plain POP3 server:"
34//usage: "\npopmaildir -k DIR nc pop3.server.com 110 <user_and_pass.txt"
35//usage: "\nFetch from SSLed POP3 server and delete fetched emails:"
36//usage: "\npopmaildir DIR -- openssl s_client -quiet -connect pop3.server.com:995 <user_and_pass.txt"
37/* //usage: "\n -R BYTES Remove old messages on the server >= BYTES. Ignored" */
38/* //usage: "\n -Z N1-N2 Remove messages from N1 to N2 (dangerous). Ignored" */
39/* //usage: "\n -L BYTES Don't retrieve new messages >= BYTES. Ignored" */
40/* //usage: "\n -H LINES Type first LINES of a message. Ignored" */
41//usage:
42//usage:#define popmaildir_example_usage
43//usage: "$ popmaildir -k ~/Maildir -- nc pop.drvv.ru 110 [<password_file]\n"
44//usage: "$ popmaildir ~/Maildir -- openssl s_client -quiet -connect pop.gmail.com:995 [<password_file]\n"
45
12#include "libbb.h" 46#include "libbb.h"
13#include "mail.h" 47#include "mail.h"
14 48
diff --git a/miscutils/adjtimex.c b/miscutils/adjtimex.c
index 8e8ff8c0a..e1edbbebc 100644
--- a/miscutils/adjtimex.c
+++ b/miscutils/adjtimex.c
@@ -11,6 +11,18 @@
11 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13 13
14//usage:#define adjtimex_trivial_usage
15//usage: "[-q] [-o OFF] [-f FREQ] [-p TCONST] [-t TICK]"
16//usage:#define adjtimex_full_usage "\n\n"
17//usage: "Read and optionally set system timebase parameters. See adjtimex(2)\n"
18//usage: "\nOptions:"
19//usage: "\n -q Quiet"
20//usage: "\n -o OFF Time offset, microseconds"
21//usage: "\n -f FREQ Frequency adjust, integer kernel units (65536 is 1ppm)"
22//usage: "\n (positive values make clock run faster)"
23//usage: "\n -t TICK Microseconds per tick, usually 10000"
24//usage: "\n -p TCONST"
25
14#include "libbb.h" 26#include "libbb.h"
15#include <sys/timex.h> 27#include <sys/timex.h>
16 28
diff --git a/miscutils/bbconfig.c b/miscutils/bbconfig.c
index 7c30669a3..e8be81352 100644
--- a/miscutils/bbconfig.c
+++ b/miscutils/bbconfig.c
@@ -1,6 +1,12 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* This file was released into the public domain by Paul Fox. 2/* This file was released into the public domain by Paul Fox.
3 */ 3 */
4
5//usage:#define bbconfig_trivial_usage
6//usage: ""
7//usage:#define bbconfig_full_usage "\n\n"
8//usage: "Print the config file used by busybox build"
9
4#include "libbb.h" 10#include "libbb.h"
5#include "bbconfigopts.h" 11#include "bbconfigopts.h"
6#if ENABLE_FEATURE_COMPRESS_BBCONFIG 12#if ENABLE_FEATURE_COMPRESS_BBCONFIG
diff --git a/miscutils/beep.c b/miscutils/beep.c
index 013a72543..c7699ffe1 100644
--- a/miscutils/beep.c
+++ b/miscutils/beep.c
@@ -7,6 +7,17 @@
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 */ 9 */
10
11//usage:#define beep_trivial_usage
12//usage: "-f FREQ -l LEN -d DELAY -r COUNT -n"
13//usage:#define beep_full_usage "\n\n"
14//usage: "Options:"
15//usage: "\n -f Frequency in Hz"
16//usage: "\n -l Length in ms"
17//usage: "\n -d Delay in ms"
18//usage: "\n -r Repetitions"
19//usage: "\n -n Start new tone"
20
10#include "libbb.h" 21#include "libbb.h"
11 22
12#include <linux/kd.h> 23#include <linux/kd.h>
diff --git a/miscutils/chat.c b/miscutils/chat.c
index d8370a963..ce994f870 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -7,6 +7,15 @@
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//usage:#define chat_trivial_usage
12//usage: "EXPECT [SEND [EXPECT [SEND...]]]"
13//usage:#define chat_full_usage "\n\n"
14//usage: "Useful for interacting with a modem connected to stdin/stdout.\n"
15//usage: "A script consists of one or more \"expect-send\" pairs of strings,\n"
16//usage: "each pair is a pair of arguments. Example:\n"
17//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'"
18
10#include "libbb.h" 19#include "libbb.h"
11 20
12// default timeout: 45 sec 21// default timeout: 45 sec
diff --git a/miscutils/chrt.c b/miscutils/chrt.c
index 1c6737a3c..7e40b9f13 100644
--- a/miscutils/chrt.c
+++ b/miscutils/chrt.c
@@ -5,6 +5,23 @@
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//usage:#define chrt_trivial_usage
10//usage: "[-prfom] [PRIO] [PID | PROG ARGS]"
11//usage:#define chrt_full_usage "\n\n"
12//usage: "Change scheduling priority and class for a process\n"
13//usage: "\nOptions:"
14//usage: "\n -p Operate on PID"
15//usage: "\n -r Set SCHED_RR class"
16//usage: "\n -f Set SCHED_FIFO class"
17//usage: "\n -o Set SCHED_OTHER class"
18//usage: "\n -m Show min/max priorities"
19//usage:
20//usage:#define chrt_example_usage
21//usage: "$ chrt -r 4 sleep 900; x=$!\n"
22//usage: "$ chrt -f -p 3 $x\n"
23//usage: "You need CAP_SYS_NICE privileges to set scheduling attributes of a process"
24
8#include <sched.h> 25#include <sched.h>
9#include "libbb.h" 26#include "libbb.h"
10#ifndef _POSIX_PRIORITY_SCHEDULING 27#ifndef _POSIX_PRIORITY_SCHEDULING
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 9c5405332..90ef91c5c 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -504,16 +504,17 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
504 } 504 }
505 } 505 }
506 poll_timeout_ms = 250; 506 poll_timeout_ms = 250;
507 if (option_mask32 & FLAG(v)) continue;
507 508
508 // Insert all keys pressed into the virtual console's input 509 // Insert all keys pressed into the virtual console's input
509 // buffer. Don't do this if the virtual console is in scan 510 // buffer. Don't do this if the virtual console is in scan
510 // code mode - giving ASCII characters to a program expecting 511 // code mode - giving ASCII characters to a program expecting
511 // scan codes will confuse it. 512 // scan codes will confuse it.
512 if (!(option_mask32 & FLAG(v)) && G.escape_count == 0) { 513 G.key_count += bytes_read;
514 if (G.escape_count == 0) {
513 int handle, result; 515 int handle, result;
514 long kbd_mode; 516 long kbd_mode;
515 517
516 G.key_count += bytes_read;
517 handle = xopen(tty_name, O_WRONLY); 518 handle = xopen(tty_name, O_WRONLY);
518 result = ioctl(handle, KDGKBMODE, &kbd_mode); 519 result = ioctl(handle, KDGKBMODE, &kbd_mode);
519 if (result >= 0) { 520 if (result >= 0) {
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 5bf053609..014016fb6 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -11,6 +11,19 @@
11 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13 13
14//usage:#define crond_trivial_usage
15//usage: "-fbS -l N " IF_FEATURE_CROND_D("-d N ") "-L LOGFILE -c DIR"
16//usage:#define crond_full_usage "\n\n"
17//usage: " -f Foreground"
18//usage: "\n -b Background (default)"
19//usage: "\n -S Log to syslog (default)"
20//usage: "\n -l Set log level. 0 is the most verbose, default 8"
21//usage: IF_FEATURE_CROND_D(
22//usage: "\n -d Set log level, log to stderr"
23//usage: )
24//usage: "\n -L Log to file"
25//usage: "\n -c Working dir"
26
14#include "libbb.h" 27#include "libbb.h"
15#include <syslog.h> 28#include <syslog.h>
16 29
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index 16d7fdf69..4731d8da6 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -10,6 +10,16 @@
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 12
13//usage:#define crontab_trivial_usage
14//usage: "[-c DIR] [-u USER] [-ler]|[FILE]"
15//usage:#define crontab_full_usage "\n\n"
16//usage: " -c Crontab directory"
17//usage: "\n -u User"
18//usage: "\n -l List crontab"
19//usage: "\n -e Edit crontab"
20//usage: "\n -r Delete crontab"
21//usage: "\n FILE Replace crontab by FILE ('-': stdin)"
22
13#include "libbb.h" 23#include "libbb.h"
14 24
15#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs" 25#define CRONTABS CONFIG_FEATURE_CROND_DIR "/crontabs"
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 35e431951..706276015 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -53,6 +53,22 @@
53 The postal address is: 53 The postal address is:
54 Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia. 54 Richard Gooch, c/o ATNF, P. O. Box 76, Epping, N.S.W., 2121, Australia.
55*/ 55*/
56
57//usage:#define devfsd_trivial_usage
58//usage: "mntpnt [-v]" IF_DEVFSD_FG_NP("[-fg][-np]")
59//usage:#define devfsd_full_usage "\n\n"
60//usage: "Manage devfs permissions and old device name symlinks\n"
61//usage: "\nOptions:"
62//usage: "\n mntpnt The mount point where devfs is mounted"
63//usage: "\n -v Print the protocol version numbers for devfsd"
64//usage: "\n and the kernel-side protocol version and exit"
65//usage: IF_DEVFSD_FG_NP(
66//usage: "\n -fg Run in foreground"
67//usage: "\n -np Exit after parsing the configuration file"
68//usage: "\n and processing synthetic REGISTER events,"
69//usage: "\n don't poll for events"
70//usage: )
71
56#include "libbb.h" 72#include "libbb.h"
57#include "xregex.h" 73#include "xregex.h"
58#include <syslog.h> 74#include <syslog.h>
diff --git a/miscutils/devmem.c b/miscutils/devmem.c
index 7a9f533af..786a21bee 100644
--- a/miscutils/devmem.c
+++ b/miscutils/devmem.c
@@ -4,6 +4,14 @@
4 * Copyright (C) 2008, BusyBox Team. -solar 4/26/08 4 * Copyright (C) 2008, BusyBox Team. -solar 4/26/08
5 */ 5 */
6 6
7//usage:#define devmem_trivial_usage
8//usage: "ADDRESS [WIDTH [VALUE]]"
9//usage:#define devmem_full_usage "\n\n"
10//usage: "Read/write from physical address\n"
11//usage: "\n ADDRESS Address to act upon"
12//usage: "\n WIDTH Width (8/16/...)"
13//usage: "\n VALUE Data to be written"
14
7#include "libbb.h" 15#include "libbb.h"
8 16
9int devmem_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 17int devmem_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/eject.c b/miscutils/eject.c
index 63d20d3ad..184ccc5d7 100644
--- a/miscutils/eject.c
+++ b/miscutils/eject.c
@@ -13,6 +13,17 @@
13 * Most of the dirty work blatantly ripped off from cat.c =) 13 * Most of the dirty work blatantly ripped off from cat.c =)
14 */ 14 */
15 15
16//usage:#define eject_trivial_usage
17//usage: "[-t] [-T] [DEVICE]"
18//usage:#define eject_full_usage "\n\n"
19//usage: "Eject DEVICE or default /dev/cdrom\n"
20//usage: "\nOptions:"
21//usage: IF_FEATURE_EJECT_SCSI(
22//usage: "\n -s SCSI device"
23//usage: )
24//usage: "\n -t Close tray"
25//usage: "\n -T Open/close tray (toggle)"
26
16#include <sys/mount.h> 27#include <sys/mount.h>
17#include "libbb.h" 28#include "libbb.h"
18/* Must be after libbb.h: they need size_t */ 29/* Must be after libbb.h: they need size_t */
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 150992343..c761a88ca 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -21,16 +21,25 @@
21 * "exit" (or just close fifo) - well you guessed it. 21 * "exit" (or just close fifo) - well you guessed it.
22 */ 22 */
23 23
24//usage:#define fbsplash_trivial_usage
25//usage: "-s IMGFILE [-c] [-d DEV] [-i INIFILE] [-f CMD]"
26//usage:#define fbsplash_full_usage "\n\n"
27//usage: "Options:"
28//usage: "\n -s Image"
29//usage: "\n -c Hide cursor"
30//usage: "\n -d Framebuffer device (default /dev/fb0)"
31//usage: "\n -i Config file (var=value):"
32//usage: "\n BAR_LEFT,BAR_TOP,BAR_WIDTH,BAR_HEIGHT"
33//usage: "\n BAR_R,BAR_G,BAR_B"
34//usage: "\n -f Control pipe (else exit after drawing image)"
35//usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
36
24#include "libbb.h" 37#include "libbb.h"
25#include <linux/fb.h> 38#include <linux/fb.h>
26 39
27/* If you want logging messages on /tmp/fbsplash.log... */ 40/* If you want logging messages on /tmp/fbsplash.log... */
28#define DEBUG 0 41#define DEBUG 0
29 42
30#define BYTES_PER_PIXEL 2
31
32typedef unsigned short DATA;
33
34struct globals { 43struct globals {
35#if DEBUG 44#if DEBUG
36 bool bdebug_messages; // enable/disable logging 45 bool bdebug_messages; // enable/disable logging
@@ -41,6 +50,7 @@ struct globals {
41 const char *image_filename; 50 const char *image_filename;
42 struct fb_var_screeninfo scr_var; 51 struct fb_var_screeninfo scr_var;
43 struct fb_fix_screeninfo scr_fix; 52 struct fb_fix_screeninfo scr_fix;
53 unsigned bytes_per_pixel;
44}; 54};
45#define G (*ptr_to_globals) 55#define G (*ptr_to_globals)
46#define INIT_G() do { \ 56#define INIT_G() do { \
@@ -67,7 +77,7 @@ struct globals {
67 77
68 78
69/** 79/**
70 * Open and initialize the framebuffer device 80 * Open and initialize the framebuffer device
71 * \param *strfb_device pointer to framebuffer device 81 * \param *strfb_device pointer to framebuffer device
72 */ 82 */
73static void fb_open(const char *strfb_device) 83static void fb_open(const char *strfb_device)
@@ -78,62 +88,98 @@ static void fb_open(const char *strfb_device)
78 xioctl(fbfd, FBIOGET_VSCREENINFO, &G.scr_var); 88 xioctl(fbfd, FBIOGET_VSCREENINFO, &G.scr_var);
79 xioctl(fbfd, FBIOGET_FSCREENINFO, &G.scr_fix); 89 xioctl(fbfd, FBIOGET_FSCREENINFO, &G.scr_fix);
80 90
81 if (G.scr_var.bits_per_pixel != 16) 91 if (G.scr_var.bits_per_pixel < 16 || G.scr_var.bits_per_pixel > 32)
82 bb_error_msg_and_die("only 16 bpp is supported"); 92 bb_error_msg_and_die("unsupported %u bpp", (int)G.scr_var.bits_per_pixel);
93 G.bytes_per_pixel = (G.scr_var.bits_per_pixel + 7) >> 3;
83 94
84 // map the device in memory 95 // map the device in memory
85 G.addr = mmap(NULL, 96 G.addr = mmap(NULL,
86 G.scr_var.xres * G.scr_var.yres_virtual 97 G.scr_var.xres * G.scr_var.yres * G.bytes_per_pixel,
87 * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/,
88 PROT_WRITE, MAP_SHARED, fbfd, 0); 98 PROT_WRITE, MAP_SHARED, fbfd, 0);
89 if (G.addr == MAP_FAILED) 99 if (G.addr == MAP_FAILED)
90 bb_perror_msg_and_die("mmap"); 100 bb_perror_msg_and_die("mmap");
91 101
92 // point to the start of the visible screen 102 // point to the start of the visible screen
93 G.addr += G.scr_var.yoffset * G.scr_fix.line_length + G.scr_var.xoffset * BYTES_PER_PIXEL; 103 G.addr += G.scr_var.yoffset * G.scr_fix.line_length + G.scr_var.xoffset * G.bytes_per_pixel;
94 close(fbfd); 104 close(fbfd);
95} 105}
96 106
97 107
98/** 108/**
99 * Draw hollow rectangle on framebuffer 109 * Return pixel value of the passed RGB color
110 */
111static unsigned fb_pixel_value(unsigned r, unsigned g, unsigned b)
112{
113 if (G.bytes_per_pixel == 2) {
114 r >>= 3; // 5-bit red
115 g >>= 2; // 6-bit green
116 b >>= 3; // 5-bit blue
117 return b + (g << 5) + (r << (5+6));
118 }
119 // RGB 888
120 return b + (g << 8) + (r << 16);
121}
122
123/**
124 * Draw pixel on framebuffer
125 */
126static void fb_write_pixel(unsigned char *addr, unsigned pixel)
127{
128 switch (G.bytes_per_pixel) {
129 case 2:
130 *(uint16_t *)addr = pixel;
131 break;
132 case 4:
133 *(uint32_t *)addr = pixel;
134 break;
135 default: // 24 bits per pixel
136 addr[0] = pixel;
137 addr[1] = pixel >> 8;
138 addr[2] = pixel >> 16;
139 }
140}
141
142
143/**
144 * Draw hollow rectangle on framebuffer
100 */ 145 */
101static void fb_drawrectangle(void) 146static void fb_drawrectangle(void)
102{ 147{
103 int cnt; 148 int cnt;
104 DATA thispix; 149 unsigned thispix;
105 DATA *ptr1, *ptr2; 150 unsigned char *ptr1, *ptr2;
106 unsigned char nred = G.nbar_colr/2; 151 unsigned char nred = G.nbar_colr/2;
107 unsigned char ngreen = G.nbar_colg/2; 152 unsigned char ngreen = G.nbar_colg/2;
108 unsigned char nblue = G.nbar_colb/2; 153 unsigned char nblue = G.nbar_colb/2;
109 154
110 nred >>= 3; // 5-bit red 155 thispix = fb_pixel_value(nred, ngreen, nblue);
111 ngreen >>= 2; // 6-bit green
112 nblue >>= 3; // 5-bit blue
113 thispix = nblue + (ngreen << 5) + (nred << (5+6));
114 156
115 // horizontal lines 157 // horizontal lines
116 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL); 158 ptr1 = G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * G.bytes_per_pixel;
117 ptr2 = (DATA*)(G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL); 159 ptr2 = G.addr + ((G.nbar_posy + G.nbar_height - 1) * G.scr_var.xres + G.nbar_posx) * G.bytes_per_pixel;
118 cnt = G.nbar_width - 1; 160 cnt = G.nbar_width - 1;
119 do { 161 do {
120 *ptr1++ = thispix; 162 fb_write_pixel(ptr1, thispix);
121 *ptr2++ = thispix; 163 fb_write_pixel(ptr2, thispix);
164 ptr1 += G.bytes_per_pixel;
165 ptr2 += G.bytes_per_pixel;
122 } while (--cnt >= 0); 166 } while (--cnt >= 0);
123 167
124 // vertical lines 168 // vertical lines
125 ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL); 169 ptr1 = G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * G.bytes_per_pixel;
126 ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL); 170 ptr2 = G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * G.bytes_per_pixel;
127 cnt = G.nbar_height - 1; 171 cnt = G.nbar_height - 1;
128 do { 172 do {
129 *ptr1 = thispix; ptr1 += G.scr_var.xres; 173 fb_write_pixel(ptr1, thispix);
130 *ptr2 = thispix; ptr2 += G.scr_var.xres; 174 fb_write_pixel(ptr2, thispix);
175 ptr1 += G.scr_var.xres * G.bytes_per_pixel;
176 ptr2 += G.scr_var.xres * G.bytes_per_pixel;
131 } while (--cnt >= 0); 177 } while (--cnt >= 0);
132} 178}
133 179
134 180
135/** 181/**
136 * Draw filled rectangle on framebuffer 182 * Draw filled rectangle on framebuffer
137 * \param nx1pos,ny1pos upper left position 183 * \param nx1pos,ny1pos upper left position
138 * \param nx2pos,ny2pos down right position 184 * \param nx2pos,ny2pos down right position
139 * \param nred,ngreen,nblue rgb color 185 * \param nred,ngreen,nblue rgb color
@@ -142,21 +188,19 @@ static void fb_drawfullrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
142 unsigned char nred, unsigned char ngreen, unsigned char nblue) 188 unsigned char nred, unsigned char ngreen, unsigned char nblue)
143{ 189{
144 int cnt1, cnt2, nypos; 190 int cnt1, cnt2, nypos;
145 DATA thispix; 191 unsigned thispix;
146 DATA *ptr; 192 unsigned char *ptr;
147 193
148 nred >>= 3; // 5-bit red 194 thispix = fb_pixel_value(nred, ngreen, nblue);
149 ngreen >>= 2; // 6-bit green
150 nblue >>= 3; // 5-bit blue
151 thispix = nblue + (ngreen << 5) + (nred << (5+6));
152 195
153 cnt1 = ny2pos - ny1pos; 196 cnt1 = ny2pos - ny1pos;
154 nypos = ny1pos; 197 nypos = ny1pos;
155 do { 198 do {
156 ptr = (DATA*)(G.addr + (nypos * G.scr_var.xres + nx1pos) * BYTES_PER_PIXEL); 199 ptr = G.addr + (nypos * G.scr_var.xres + nx1pos) * G.bytes_per_pixel;
157 cnt2 = nx2pos - nx1pos; 200 cnt2 = nx2pos - nx1pos;
158 do { 201 do {
159 *ptr++ = thispix; 202 fb_write_pixel(ptr, thispix);
203 ptr += G.bytes_per_pixel;
160 } while (--cnt2 >= 0); 204 } while (--cnt2 >= 0);
161 205
162 nypos++; 206 nypos++;
@@ -165,7 +209,7 @@ static void fb_drawfullrectangle(int nx1pos, int ny1pos, int nx2pos, int ny2pos,
165 209
166 210
167/** 211/**
168 * Draw a progress bar on framebuffer 212 * Draw a progress bar on framebuffer
169 * \param percent percentage of loading 213 * \param percent percentage of loading
170 */ 214 */
171static void fb_drawprogressbar(unsigned percent) 215static void fb_drawprogressbar(unsigned percent)
@@ -215,7 +259,7 @@ static void fb_drawprogressbar(unsigned percent)
215 259
216 260
217/** 261/**
218 * Draw image from PPM file 262 * Draw image from PPM file
219 */ 263 */
220static void fb_drawimage(void) 264static void fb_drawimage(void)
221{ 265{
@@ -276,18 +320,16 @@ static void fb_drawimage(void)
276 height = G.scr_var.yres; 320 height = G.scr_var.yres;
277 for (j = 0; j < height; j++) { 321 for (j = 0; j < height; j++) {
278 unsigned char *pixel; 322 unsigned char *pixel;
279 DATA *src; 323 unsigned char *src;
280 324
281 if (fread(pixline, 1, line_size, theme_file) != line_size) 325 if (fread(pixline, 1, line_size, theme_file) != line_size)
282 bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); 326 bb_error_msg_and_die("bad PPM file '%s'", G.image_filename);
283 pixel = pixline; 327 pixel = pixline;
284 src = (DATA *)(G.addr + j * G.scr_fix.line_length); 328 src = G.addr + j * G.scr_fix.line_length;
285 for (i = 0; i < width; i++) { 329 for (i = 0; i < width; i++) {
286 unsigned thispix; 330 unsigned thispix = fb_pixel_value(pixel[0], pixel[1], pixel[2]);
287 thispix = (((unsigned)pixel[0] << 8) & 0xf800) 331 fb_write_pixel(src, thispix);
288 | (((unsigned)pixel[1] << 3) & 0x07e0) 332 src += G.bytes_per_pixel;
289 | (((unsigned)pixel[2] >> 3));
290 *src++ = thispix;
291 pixel += 3; 333 pixel += 3;
292 } 334 }
293 } 335 }
@@ -297,7 +339,7 @@ static void fb_drawimage(void)
297 339
298 340
299/** 341/**
300 * Parse configuration file 342 * Parse configuration file
301 * \param *cfg_filename name of the configuration file 343 * \param *cfg_filename name of the configuration file
302 */ 344 */
303static void init(const char *cfg_filename) 345static void init(const char *cfg_filename)
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c
index 68596e11b..33803f87d 100644
--- a/miscutils/flash_eraseall.c
+++ b/miscutils/flash_eraseall.c
@@ -10,6 +10,14 @@
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 12
13//usage:#define flash_eraseall_trivial_usage
14//usage: "[-jq] MTD_DEVICE"
15//usage:#define flash_eraseall_full_usage "\n\n"
16//usage: "Erase an MTD device\n"
17//usage: "\nOptions:"
18//usage: "\n -j Format the device for jffs2"
19//usage: "\n -q Don't display progress messages"
20
13#include "libbb.h" 21#include "libbb.h"
14#include <mtd/mtd-user.h> 22#include <mtd/mtd-user.h>
15#include <linux/jffs2.h> 23#include <linux/jffs2.h>
diff --git a/miscutils/flash_lock_unlock.c b/miscutils/flash_lock_unlock.c
index fcb836b07..1fefd95f9 100644
--- a/miscutils/flash_lock_unlock.c
+++ b/miscutils/flash_lock_unlock.c
@@ -3,6 +3,18 @@
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
7//usage:#define flash_lock_trivial_usage
8//usage: "MTD_DEVICE OFFSET SECTORS"
9//usage:#define flash_lock_full_usage "\n\n"
10//usage: "Lock part or all of an MTD device. If SECTORS is -1, then all sectors\n"
11//usage: "will be locked, regardless of the value of OFFSET"
12//usage:
13//usage:#define flash_unlock_trivial_usage
14//usage: "MTD_DEVICE"
15//usage:#define flash_unlock_full_usage "\n\n"
16//usage: "Unlock an MTD device"
17
6#include "libbb.h" 18#include "libbb.h"
7#include <mtd/mtd-user.h> 19#include <mtd/mtd-user.h>
8 20
diff --git a/miscutils/flashcp.c b/miscutils/flashcp.c
index fe37c3913..e4bb3a902 100644
--- a/miscutils/flashcp.c
+++ b/miscutils/flashcp.c
@@ -7,6 +7,13 @@
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 9
10//usage:#define flashcp_trivial_usage
11//usage: "-v FILE MTD_DEVICE"
12//usage:#define flashcp_full_usage "\n\n"
13//usage: "Copy an image to MTD device\n"
14//usage: "\nOptions:"
15//usage: "\n -v Verbose"
16
10#include "libbb.h" 17#include "libbb.h"
11#include <mtd/mtd-user.h> 18#include <mtd/mtd-user.h>
12 19
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 38b265d60..7608408dd 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -11,6 +11,58 @@
11 * hdparm.c - Command line interface to get/set hard disk parameters 11 * hdparm.c - Command line interface to get/set hard disk parameters
12 * - by Mark Lord (C) 1994-2002 -- freely distributable 12 * - by Mark Lord (C) 1994-2002 -- freely distributable
13 */ 13 */
14
15//usage:#define hdparm_trivial_usage
16//usage: "[OPTIONS] [DEVICE]"
17//usage:#define hdparm_full_usage "\n\n"
18//usage: "Options:"
19//usage: "\n -a Get/set fs readahead"
20//usage: "\n -A Set drive read-lookahead flag (0/1)"
21//usage: "\n -b Get/set bus state (0 == off, 1 == on, 2 == tristate)"
22//usage: "\n -B Set Advanced Power Management setting (1-255)"
23//usage: "\n -c Get/set IDE 32-bit IO setting"
24//usage: "\n -C Check IDE power mode status"
25//usage: IF_FEATURE_HDPARM_HDIO_GETSET_DMA(
26//usage: "\n -d Get/set using_dma flag")
27//usage: "\n -D Enable/disable drive defect-mgmt"
28//usage: "\n -f Flush buffer cache for device on exit"
29//usage: "\n -g Display drive geometry"
30//usage: "\n -h Display terse usage information"
31//usage: IF_FEATURE_HDPARM_GET_IDENTITY(
32//usage: "\n -i Display drive identification")
33//usage: IF_FEATURE_HDPARM_GET_IDENTITY(
34//usage: "\n -I Detailed/current information directly from drive")
35//usage: "\n -k Get/set keep_settings_over_reset flag (0/1)"
36//usage: "\n -K Set drive keep_features_over_reset flag (0/1)"
37//usage: "\n -L Set drive doorlock (0/1) (removable harddisks only)"
38//usage: "\n -m Get/set multiple sector count"
39//usage: "\n -n Get/set ignore-write-errors flag (0/1)"
40//usage: "\n -p Set PIO mode on IDE interface chipset (0,1,2,3,4,...)"
41//usage: "\n -P Set drive prefetch count"
42/* //usage: "\n -q Change next setting quietly" - not supported ib bbox */
43//usage: "\n -Q Get/set DMA tagged-queuing depth (if supported)"
44//usage: "\n -r Get/set readonly flag (DANGEROUS to set)"
45//usage: IF_FEATURE_HDPARM_HDIO_SCAN_HWIF(
46//usage: "\n -R Register an IDE interface (DANGEROUS)")
47//usage: "\n -S Set standby (spindown) timeout"
48//usage: "\n -t Perform device read timings"
49//usage: "\n -T Perform cache read timings"
50//usage: "\n -u Get/set unmaskirq flag (0/1)"
51//usage: IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(
52//usage: "\n -U Unregister an IDE interface (DANGEROUS)")
53//usage: "\n -v Defaults; same as -mcudkrag for IDE drives"
54//usage: "\n -V Display program version and exit immediately"
55//usage: IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(
56//usage: "\n -w Perform device reset (DANGEROUS)")
57//usage: "\n -W Set drive write-caching flag (0/1) (DANGEROUS)"
58//usage: IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(
59//usage: "\n -x Tristate device for hotswap (0/1) (DANGEROUS)")
60//usage: "\n -X Set IDE xfer mode (DANGEROUS)"
61//usage: "\n -y Put IDE drive in standby mode"
62//usage: "\n -Y Put IDE drive to sleep"
63//usage: "\n -Z Disable Seagate auto-powersaving mode"
64//usage: "\n -z Reread partition table"
65
14#include "libbb.h" 66#include "libbb.h"
15/* must be _after_ libbb.h: */ 67/* must be _after_ libbb.h: */
16#include <linux/hdreg.h> 68#include <linux/hdreg.h>
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index fe429b636..b64e0abb9 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -27,6 +27,33 @@
27 * See below for mask names explanation. 27 * See below for mask names explanation.
28 */ 28 */
29 29
30//usage:#define inotifyd_trivial_usage
31//usage: "PROG FILE1[:MASK]..."
32//usage:#define inotifyd_full_usage "\n\n"
33//usage: "Run PROG on filesystem changes."
34//usage: "\nWhen a filesystem event matching MASK occurs on FILEn,"
35//usage: "\nPROG ACTUAL_EVENTS FILEn [SUBFILE] is run."
36//usage: "\nEvents:"
37//usage: "\n a File is accessed"
38//usage: "\n c File is modified"
39//usage: "\n e Metadata changed"
40//usage: "\n w Writable file is closed"
41//usage: "\n 0 Unwritable file is closed"
42//usage: "\n r File is opened"
43//usage: "\n D File is deleted"
44//usage: "\n M File is moved"
45//usage: "\n u Backing fs is unmounted"
46//usage: "\n o Event queue overflowed"
47//usage: "\n x File can't be watched anymore"
48//usage: "\nIf watching a directory:"
49//usage: "\n m Subfile is moved into dir"
50//usage: "\n y Subfile is moved out of dir"
51//usage: "\n n Subfile is created"
52//usage: "\n d Subfile is deleted"
53//usage: "\n"
54//usage: "\ninotifyd waits for PROG to exit."
55//usage: "\nWhen x event happens for all FILEs, inotifyd exits."
56
30#include "libbb.h" 57#include "libbb.h"
31#include <sys/inotify.h> 58#include <sys/inotify.h>
32 59
diff --git a/miscutils/ionice.c b/miscutils/ionice.c
index 481a738ee..2bc83c5eb 100644
--- a/miscutils/ionice.c
+++ b/miscutils/ionice.c
@@ -7,6 +7,14 @@
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 9
10//usage:#define ionice_trivial_usage
11//usage: "[-c 1-3] [-n 0-7] [-p PID] [PROG]"
12//usage:#define ionice_full_usage "\n\n"
13//usage: "Change I/O priority and class\n"
14//usage: "\nOptions:"
15//usage: "\n -c Class. 1:realtime 2:best-effort 3:idle"
16//usage: "\n -n Priority"
17
10#include <sys/syscall.h> 18#include <sys/syscall.h>
11#include <asm/unistd.h> 19#include <asm/unistd.h>
12#include "libbb.h" 20#include "libbb.h"
diff --git a/miscutils/last.c b/miscutils/last.c
index 12457b157..27f5a35ce 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -7,6 +7,17 @@
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 9
10//usage:#define last_trivial_usage
11//usage: ""IF_FEATURE_LAST_FANCY("[-HW] [-f FILE]")
12//usage:#define last_full_usage "\n\n"
13//usage: "Show listing of the last users that logged into the system"
14//usage: IF_FEATURE_LAST_FANCY( "\n"
15//usage: "\nOptions:"
16/* //usage: "\n -H Show header line" */
17//usage: "\n -W Display with no host column truncation"
18//usage: "\n -f FILE Read from FILE instead of /var/log/wtmp"
19//usage: )
20
10#include "libbb.h" 21#include "libbb.h"
11 22
12/* NB: ut_name and ut_user are the same field, use only one name (ut_user) 23/* NB: ut_name and ut_user are the same field, use only one name (ut_user)
diff --git a/miscutils/less.c b/miscutils/less.c
index 9e12c11a7..77fd5a8de 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -21,6 +21,18 @@
21 * redirected input has been read from stdin 21 * redirected input has been read from stdin
22 */ 22 */
23 23
24//usage:#define less_trivial_usage
25//usage: "[-EMNmh~I?] [FILE]..."
26//usage:#define less_full_usage "\n\n"
27//usage: "View FILE (or stdin) one screenful at a time\n"
28//usage: "\nOptions:"
29//usage: "\n -E Quit once the end of a file is reached"
30//usage: "\n -M,-m Display status line with line numbers"
31//usage: "\n and percentage through the file"
32//usage: "\n -N Prefix line number to each line"
33//usage: "\n -I Ignore case in all searches"
34//usage: "\n -~ Suppress ~s displayed past the end of the file"
35
24#include <sched.h> /* sched_yield() */ 36#include <sched.h> /* sched_yield() */
25 37
26#include "libbb.h" 38#include "libbb.h"
diff --git a/miscutils/makedevs.c b/miscutils/makedevs.c
index e74c47c35..8cca83882 100644
--- a/miscutils/makedevs.c
+++ b/miscutils/makedevs.c
@@ -7,6 +7,66 @@
7 * known bugs: can't deal with alpha ranges 7 * known bugs: can't deal with alpha ranges
8 */ 8 */
9 9
10//usage:#if ENABLE_FEATURE_MAKEDEVS_LEAF
11//usage:#define makedevs_trivial_usage
12//usage: "NAME TYPE MAJOR MINOR FIRST LAST [s]"
13//usage:#define makedevs_full_usage "\n\n"
14//usage: "Create a range of block or character special files"
15//usage: "\n"
16//usage: "\nTYPE is:"
17//usage: "\n b Block device"
18//usage: "\n c Character device"
19//usage: "\n f FIFO, MAJOR and MINOR are ignored"
20//usage: "\n"
21//usage: "\nFIRST..LAST specify numbers appended to NAME."
22//usage: "\nIf 's' is the last argument, the base device is created as well."
23//usage: "\n"
24//usage: "\nExamples:"
25//usage: "\n makedevs /dev/ttyS c 4 66 2 63 -> ttyS2-ttyS63"
26//usage: "\n makedevs /dev/hda b 3 0 0 8 s -> hda,hda1-hda8"
27//usage:
28//usage:#define makedevs_example_usage
29//usage: "# makedevs /dev/ttyS c 4 66 2 63\n"
30//usage: "[creates ttyS2-ttyS63]\n"
31//usage: "# makedevs /dev/hda b 3 0 0 8 s\n"
32//usage: "[creates hda,hda1-hda8]\n"
33//usage:#endif
34//usage:
35//usage:#if ENABLE_FEATURE_MAKEDEVS_TABLE
36//usage:#define makedevs_trivial_usage
37//usage: "[-d device_table] rootdir"
38//usage:#define makedevs_full_usage "\n\n"
39//usage: "Create a range of special files as specified in a device table.\n"
40//usage: "Device table entries take the form of:\n"
41//usage: "<type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>\n"
42//usage: "Where name is the file name, type can be one of:\n"
43//usage: " f Regular file\n"
44//usage: " d Directory\n"
45//usage: " c Character device\n"
46//usage: " b Block device\n"
47//usage: " p Fifo (named pipe)\n"
48//usage: "uid is the user id for the target file, gid is the group id for the\n"
49//usage: "target file. The rest of the entries (major, minor, etc) apply to\n"
50//usage: "to device special files. A '-' may be used for blank entries."
51//usage:
52//usage:#define makedevs_example_usage
53//usage: "For example:\n"
54//usage: "<name> <type> <mode><uid><gid><major><minor><start><inc><count>\n"
55//usage: "/dev d 755 0 0 - - - - -\n"
56//usage: "/dev/console c 666 0 0 5 1 - - -\n"
57//usage: "/dev/null c 666 0 0 1 3 0 0 -\n"
58//usage: "/dev/zero c 666 0 0 1 5 0 0 -\n"
59//usage: "/dev/hda b 640 0 0 3 0 0 0 -\n"
60//usage: "/dev/hda b 640 0 0 3 1 1 1 15\n\n"
61//usage: "Will Produce:\n"
62//usage: "/dev\n"
63//usage: "/dev/console\n"
64//usage: "/dev/null\n"
65//usage: "/dev/zero\n"
66//usage: "/dev/hda\n"
67//usage: "/dev/hda[0-15]\n"
68//usage:#endif
69
10#include "libbb.h" 70#include "libbb.h"
11 71
12#if ENABLE_FEATURE_MAKEDEVS_LEAF 72#if ENABLE_FEATURE_MAKEDEVS_LEAF
diff --git a/miscutils/man.c b/miscutils/man.c
index b356e726f..2c6b25ceb 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -3,6 +3,14 @@
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 5
6//usage:#define man_trivial_usage
7//usage: "[-aw] [MANPAGE]..."
8//usage:#define man_full_usage "\n\n"
9//usage: "Format and display manual page\n"
10//usage: "\nOptions:"
11//usage: "\n -a Display all pages"
12//usage: "\n -w Show page locations"
13
6#include "libbb.h" 14#include "libbb.h"
7 15
8enum { 16enum {
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index 3acbe3023..edaeb6fa5 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -7,6 +7,18 @@
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//usage:#define microcom_trivial_usage
12//usage: "[-d DELAY] [-t TIMEOUT] [-s SPEED] [-X] TTY"
13//usage:#define microcom_full_usage "\n\n"
14//usage: "Copy bytes for stdin to TTY and from TTY to stdout\n"
15//usage: "\nOptions:"
16//usage: "\n -d Wait up to DELAY ms for TTY output before sending every"
17//usage: "\n next byte to it"
18//usage: "\n -t Exit if both stdin and TTY are silent for TIMEOUT ms"
19//usage: "\n -s Set serial line to SPEED"
20//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin"
21
10#include "libbb.h" 22#include "libbb.h"
11 23
12// set raw tty mode 24// set raw tty mode
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index 784c3cbfc..a1a5b396a 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -9,6 +9,22 @@
9 * Based on sysvinit's mountpoint 9 * Based on sysvinit's mountpoint
10 */ 10 */
11 11
12//usage:#define mountpoint_trivial_usage
13//usage: "[-q] <[-dn] DIR | -x DEVICE>"
14//usage:#define mountpoint_full_usage "\n\n"
15//usage: "Check if the directory is a mountpoint\n"
16//usage: "\nOptions:"
17//usage: "\n -q Quiet"
18//usage: "\n -d Print major/minor device number of the filesystem"
19//usage: "\n -n Print device name of the filesystem"
20//usage: "\n -x Print major/minor device number of the blockdevice"
21//usage:
22//usage:#define mountpoint_example_usage
23//usage: "$ mountpoint /proc\n"
24//usage: "/proc is not a mountpoint\n"
25//usage: "$ mountpoint /sys\n"
26//usage: "/sys is a mountpoint\n"
27
12#include "libbb.h" 28#include "libbb.h"
13 29
14int mountpoint_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 30int mountpoint_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/mt.c b/miscutils/mt.c
index 142901bb0..20afd3a50 100644
--- a/miscutils/mt.c
+++ b/miscutils/mt.c
@@ -3,6 +3,18 @@
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 5
6//usage:#define mt_trivial_usage
7//usage: "[-f device] opcode value"
8//usage:#define mt_full_usage "\n\n"
9//usage: "Control magnetic tape drive operation\n"
10//usage: "\n"
11//usage: "Available Opcodes:\n"
12//usage: "\n"
13//usage: "bsf bsfm bsr bss datacompression drvbuffer eof eom erase\n"
14//usage: "fsf fsfm fsr fss load lock mkpart nop offline ras1 ras2\n"
15//usage: "ras3 reset retension rewind rewoffline seek setblk setdensity\n"
16//usage: "setpart tell unload unlock weof wset"
17
6#include "libbb.h" 18#include "libbb.h"
7#include <sys/mtio.h> 19#include <sys/mtio.h>
8 20
diff --git a/miscutils/raidautorun.c b/miscutils/raidautorun.c
index bbfa8577c..b72d89058 100644
--- a/miscutils/raidautorun.c
+++ b/miscutils/raidautorun.c
@@ -8,6 +8,14 @@
8 * 8 *
9 */ 9 */
10 10
11//usage:#define raidautorun_trivial_usage
12//usage: "DEVICE"
13//usage:#define raidautorun_full_usage "\n\n"
14//usage: "Tell the kernel to automatically search and start RAID arrays"
15//usage:
16//usage:#define raidautorun_example_usage
17//usage: "$ raidautorun /dev/md0"
18
11#include "libbb.h" 19#include "libbb.h"
12 20
13#include <linux/major.h> 21#include <linux/major.h>
diff --git a/miscutils/readahead.c b/miscutils/readahead.c
index dd6de7c45..e22aaa468 100644
--- a/miscutils/readahead.c
+++ b/miscutils/readahead.c
@@ -10,6 +10,11 @@
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 12
13//usage:#define readahead_trivial_usage
14//usage: "[FILE]..."
15//usage:#define readahead_full_usage "\n\n"
16//usage: "Preload FILEs to RAM"
17
13#include "libbb.h" 18#include "libbb.h"
14 19
15int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/rfkill.c b/miscutils/rfkill.c
index b150b2cae..467197371 100644
--- a/miscutils/rfkill.c
+++ b/miscutils/rfkill.c
@@ -6,6 +6,19 @@
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//usage:#define rfkill_trivial_usage
11//usage: "COMMAND [INDEX|TYPE]"
12//usage:#define rfkill_full_usage "\n\n"
13//usage: "Enable/disable wireless devices\n"
14//usage: "\nCommands:"
15//usage: "\n list [INDEX|TYPE] List current state"
16//usage: "\n block INDEX|TYPE Disable device"
17//usage: "\n unblock INDEX|TYPE Enable device"
18//usage: "\n"
19//usage: "\n TYPE: all, wlan(wifi), bluetooth, uwb(ultrawideband),"
20//usage: "\n wimax, wwan, gps, fm"
21
9#include "libbb.h" 22#include "libbb.h"
10#include <linux/rfkill.h> 23#include <linux/rfkill.h>
11 24
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c
index 7024361e7..9d38b791f 100644
--- a/miscutils/runlevel.c
+++ b/miscutils/runlevel.c
@@ -11,6 +11,19 @@
11 * 11 *
12 * initially busyboxified by Bernhard Reutner-Fischer 12 * initially busyboxified by Bernhard Reutner-Fischer
13 */ 13 */
14
15//usage:#define runlevel_trivial_usage
16//usage: "[FILE]"
17//usage:#define runlevel_full_usage "\n\n"
18//usage: "Find the current and previous system runlevel\n"
19//usage: "\n"
20//usage: "If no utmp FILE exists or if no runlevel record can be found,\n"
21//usage: "print \"unknown\""
22//usage:
23//usage:#define runlevel_example_usage
24//usage: "$ runlevel /var/run/utmp\n"
25//usage: "N 2"
26
14#include "libbb.h" 27#include "libbb.h"
15 28
16int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 29int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/rx.c b/miscutils/rx.c
index de785d53c..e1225779e 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -15,6 +15,14 @@
15 * This was originally written for blob and then adapted for busybox. 15 * This was originally written for blob and then adapted for busybox.
16 */ 16 */
17 17
18//usage:#define rx_trivial_usage
19//usage: "FILE"
20//usage:#define rx_full_usage "\n\n"
21//usage: "Receive a file using the xmodem protocol"
22//usage:
23//usage:#define rx_example_usage
24//usage: "$ rx /tmp/foo\n"
25
18#include "libbb.h" 26#include "libbb.h"
19 27
20#define SOH 0x01 28#define SOH 0x01
diff --git a/miscutils/setsid.c b/miscutils/setsid.c
index c573fae34..ad2c8a4de 100644
--- a/miscutils/setsid.c
+++ b/miscutils/setsid.c
@@ -14,6 +14,13 @@
14 * - busyboxed 14 * - busyboxed
15 */ 15 */
16 16
17//usage:#define setsid_trivial_usage
18//usage: "PROG ARGS"
19//usage:#define setsid_full_usage "\n\n"
20//usage: "Run PROG in a new session. PROG will have no controlling terminal\n"
21//usage: "and will not be affected by keyboard signals (Ctrl-C etc).\n"
22//usage: "See setsid(2) for details."
23
17#include "libbb.h" 24#include "libbb.h"
18 25
19int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 26int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 7ab0e227c..6e8b9aefc 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -7,6 +7,16 @@
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 9
10//usage:#define strings_trivial_usage
11//usage: "[-afo] [-n LEN] [FILE]..."
12//usage:#define strings_full_usage "\n\n"
13//usage: "Display printable strings in a binary file\n"
14//usage: "\nOptions:"
15//usage: "\n -a Scan whole file (default)"
16//usage: "\n -f Precede strings with filenames"
17//usage: "\n -n LEN At least LEN characters form a string (default 4)"
18//usage: "\n -o Precede strings with decimal offsets"
19
10#include "libbb.h" 20#include "libbb.h"
11 21
12#define WHOLE_FILE 1 22#define WHOLE_FILE 1
diff --git a/miscutils/taskset.c b/miscutils/taskset.c
index 389ef43e4..77fc8643d 100644
--- a/miscutils/taskset.c
+++ b/miscutils/taskset.c
@@ -6,6 +6,24 @@
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 8
9//usage:#define taskset_trivial_usage
10//usage: "[-p] [MASK] [PID | PROG ARGS]"
11//usage:#define taskset_full_usage "\n\n"
12//usage: "Set or get CPU affinity\n"
13//usage: "\nOptions:"
14//usage: "\n -p Operate on an existing PID"
15//usage:
16//usage:#define taskset_example_usage
17//usage: "$ taskset 0x7 ./dgemm_test&\n"
18//usage: "$ taskset -p 0x1 $!\n"
19//usage: "pid 4790's current affinity mask: 7\n"
20//usage: "pid 4790's new affinity mask: 1\n"
21//usage: "$ taskset 0x7 /bin/sh -c './taskset -p 0x1 $$'\n"
22//usage: "pid 6671's current affinity mask: 1\n"
23//usage: "pid 6671's new affinity mask: 1\n"
24//usage: "$ taskset -p 1\n"
25//usage: "pid 1's current affinity mask: 3\n"
26
9#include <sched.h> 27#include <sched.h>
10#include "libbb.h" 28#include "libbb.h"
11 29
diff --git a/miscutils/time.c b/miscutils/time.c
index 6b1c3c42c..dcd89f8fc 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -9,6 +9,13 @@
9 Heavily modified for busybox by Erik Andersen <andersen@codepoet.org> 9 Heavily modified for busybox by Erik Andersen <andersen@codepoet.org>
10*/ 10*/
11 11
12//usage:#define time_trivial_usage
13//usage: "[-v] PROG ARGS"
14//usage:#define time_full_usage "\n\n"
15//usage: "Run PROG, display resource usage when it exits\n"
16//usage: "\nOptions:"
17//usage: "\n -v Verbose"
18
12#include "libbb.h" 19#include "libbb.h"
13 20
14/* Information on the resources used by a child process. */ 21/* Information on the resources used by a child process. */
diff --git a/miscutils/timeout.c b/miscutils/timeout.c
index 841669416..9d56593ba 100644
--- a/miscutils/timeout.c
+++ b/miscutils/timeout.c
@@ -28,6 +28,12 @@
28 * rewrite 14-11-2008 vda 28 * rewrite 14-11-2008 vda
29 */ 29 */
30 30
31//usage:#define timeout_trivial_usage
32//usage: "[-t SECS] [-s SIG] PROG ARGS"
33//usage:#define timeout_full_usage "\n\n"
34//usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n"
35//usage: "Defaults: SECS: 10, SIG: TERM."
36
31#include "libbb.h" 37#include "libbb.h"
32 38
33int timeout_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 39int timeout_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c
index f93a506a2..d2d48d0a9 100644
--- a/miscutils/ttysize.c
+++ b/miscutils/ttysize.c
@@ -9,6 +9,12 @@
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//usage:#define ttysize_trivial_usage
14//usage: "[w] [h]"
15//usage:#define ttysize_full_usage "\n\n"
16//usage: "Print dimension(s) of stdin's terminal, on error return 80x25"
17
12#include "libbb.h" 18#include "libbb.h"
13 19
14int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20int ttysize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/volname.c b/miscutils/volname.c
index 6e8615617..b50e79573 100644
--- a/miscutils/volname.c
+++ b/miscutils/volname.c
@@ -27,6 +27,12 @@
27 * mods from distributed source (eject-2.0.13) are by 27 * mods from distributed source (eject-2.0.13) are by
28 * Matthew Stoltenberg <d3matt@gmail.com> 28 * Matthew Stoltenberg <d3matt@gmail.com>
29 */ 29 */
30
31//usage:#define volname_trivial_usage
32//usage: "[DEVICE]"
33//usage:#define volname_full_usage "\n\n"
34//usage: "Show CD volume name of the DEVICE (default /dev/cdrom)"
35
30#include "libbb.h" 36#include "libbb.h"
31 37
32int volname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 38int volname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/wall.c b/miscutils/wall.c
index 0a2b89e5e..762f53b72 100644
--- a/miscutils/wall.c
+++ b/miscutils/wall.c
@@ -6,6 +6,15 @@
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 8
9//usage:#define wall_trivial_usage
10//usage: "[FILE]"
11//usage:#define wall_full_usage "\n\n"
12//usage: "Write content of FILE or stdin to all logged-in users"
13//usage:
14//usage:#define wall_sample_usage
15//usage: "echo foo | wall\n"
16//usage: "wall ./mymessage"
17
9#include "libbb.h" 18#include "libbb.h"
10 19
11int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 20int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index 630782660..b24dd4b82 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -9,6 +9,17 @@
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 11
12//usage:#define watchdog_trivial_usage
13//usage: "[-t N[ms]] [-T N[ms]] [-F] DEV"
14//usage:#define watchdog_full_usage "\n\n"
15//usage: "Periodically write to watchdog device DEV\n"
16//usage: "\nOptions:"
17//usage: "\n -T N Reboot after N seconds if not reset (default 60)"
18//usage: "\n -t N Reset every N seconds (default 30)"
19//usage: "\n -F Run in foreground"
20//usage: "\n"
21//usage: "\nUse 500ms to specify period in milliseconds"
22
12#include "libbb.h" 23#include "libbb.h"
13#include "linux/types.h" /* for __u32 */ 24#include "linux/types.h" /* for __u32 */
14#include "linux/watchdog.h" 25#include "linux/watchdog.h"
diff --git a/networking/arp.c b/networking/arp.c
index 0ef267a35..3f68f5cf7 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -13,6 +13,25 @@
13 * modified for getopt32 by Arne Bernin <arne [at] alamut.de> 13 * modified for getopt32 by Arne Bernin <arne [at] alamut.de>
14 */ 14 */
15 15
16//usage:#define arp_trivial_usage
17//usage: "\n[-vn] [-H HWTYPE] [-i IF] -a [HOSTNAME]"
18//usage: "\n[-v] [-i IF] -d HOSTNAME [pub]"
19//usage: "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [temp]"
20//usage: "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [netmask MASK] pub"
21//usage: "\n[-v] [-H HWTYPE] [-i IF] -Ds HOSTNAME IFACE [netmask MASK] pub"
22//usage:#define arp_full_usage "\n\n"
23//usage: "Manipulate ARP cache\n"
24//usage: "\nOptions:"
25//usage: "\n -a Display (all) hosts"
26//usage: "\n -s Set new ARP entry"
27//usage: "\n -d Delete a specified entry"
28//usage: "\n -v Verbose"
29//usage: "\n -n Don't resolve names"
30//usage: "\n -i IF Network interface"
31//usage: "\n -D Read <hwaddr> from given device"
32//usage: "\n -A,-p AF Protocol family"
33//usage: "\n -H HWTYPE Hardware address type"
34
16#include "libbb.h" 35#include "libbb.h"
17#include "inet_common.h" 36#include "inet_common.h"
18 37
diff --git a/networking/arping.c b/networking/arping.c
index 6f6b59cfb..357dcaaf0 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -6,6 +6,23 @@
6 * Busybox port: Nick Fedchik <nick@fedchik.org.ua> 6 * Busybox port: Nick Fedchik <nick@fedchik.org.ua>
7 */ 7 */
8 8
9//usage:#define arping_trivial_usage
10//usage: "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP"
11//usage:#define arping_full_usage "\n\n"
12//usage: "Send ARP requests/replies\n"
13//usage: "\nOptions:"
14//usage: "\n -f Quit on first ARP reply"
15//usage: "\n -q Quiet"
16//usage: "\n -b Keep broadcasting, don't go unicast"
17//usage: "\n -D Duplicated address detection mode"
18//usage: "\n -U Unsolicited ARP mode, update your neighbors"
19//usage: "\n -A ARP answer mode, update your neighbors"
20//usage: "\n -c N Stop after sending N ARP requests"
21//usage: "\n -w TIMEOUT Time to wait for ARP reply, seconds"
22//usage: "\n -I IFACE Interface to use (default eth0)"
23//usage: "\n -s SRC_IP Sender IP address"
24//usage: "\n DST_IP Target IP address"
25
9#include <arpa/inet.h> 26#include <arpa/inet.h>
10#include <net/if.h> 27#include <net/if.h>
11#include <netinet/ether.h> 28#include <netinet/ether.h>
diff --git a/networking/brctl.c b/networking/brctl.c
index c0b094eba..19f474fce 100644
--- a/networking/brctl.c
+++ b/networking/brctl.c
@@ -12,6 +12,30 @@
12/* This applet currently uses only the ioctl interface and no sysfs at all. 12/* This applet currently uses only the ioctl interface and no sysfs at all.
13 * At the time of this writing this was considered a feature. 13 * At the time of this writing this was considered a feature.
14 */ 14 */
15
16//usage:#define brctl_trivial_usage
17//usage: "COMMAND [BRIDGE [INTERFACE]]"
18//usage:#define brctl_full_usage "\n\n"
19//usage: "Manage ethernet bridges\n"
20//usage: "\nCommands:"
21//usage: IF_FEATURE_BRCTL_SHOW(
22//usage: "\n show Show a list of bridges"
23//usage: )
24//usage: "\n addbr BRIDGE Create BRIDGE"
25//usage: "\n delbr BRIDGE Delete BRIDGE"
26//usage: "\n addif BRIDGE IFACE Add IFACE to BRIDGE"
27//usage: "\n delif BRIDGE IFACE Delete IFACE from BRIDGE"
28//usage: IF_FEATURE_BRCTL_FANCY(
29//usage: "\n setageing BRIDGE TIME Set ageing time"
30//usage: "\n setfd BRIDGE TIME Set bridge forward delay"
31//usage: "\n sethello BRIDGE TIME Set hello time"
32//usage: "\n setmaxage BRIDGE TIME Set max message age"
33//usage: "\n setpathcost BRIDGE COST Set path cost"
34//usage: "\n setportprio BRIDGE PRIO Set port priority"
35//usage: "\n setbridgeprio BRIDGE PRIO Set bridge priority"
36//usage: "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off"
37//usage: )
38
15#include "libbb.h" 39#include "libbb.h"
16#include <linux/sockios.h> 40#include <linux/sockios.h>
17#include <net/if.h> 41#include <net/if.h>
diff --git a/networking/dnsd.c b/networking/dnsd.c
index 8ed31cea2..65eae9670 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -17,6 +17,22 @@
17 * the first porting of oao' scdns to busybox also. 17 * the first porting of oao' scdns to busybox also.
18 */ 18 */
19 19
20//usage:#define dnsd_trivial_usage
21//usage: "[-dvs] [-c CONFFILE] [-t TTL_SEC] [-p PORT] [-i ADDR]"
22//usage:#define dnsd_full_usage "\n\n"
23//usage: "Small static DNS server daemon\n"
24//usage: "\nOptions:"
25//usage: "\n -c FILE Config file"
26//usage: "\n -t SEC TTL"
27//usage: "\n -p PORT Listen on PORT"
28//usage: "\n -i ADDR Listen on ADDR"
29//usage: "\n -d Daemonize"
30//usage: "\n -v Verbose"
31//usage: "\n -s Send successful replies only. Use this if you want"
32//usage: "\n to use /etc/resolv.conf with two nameserver lines:"
33//usage: "\n nameserver DNSD_SERVER"
34//usage: "\n nameserver NORNAL_DNS_SERVER"
35
20#include "libbb.h" 36#include "libbb.h"
21#include <syslog.h> 37#include <syslog.h>
22 38
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
index 8f1479c02..7bb9aa5a7 100644
--- a/networking/ether-wake.c
+++ b/networking/ether-wake.c
@@ -64,6 +64,16 @@
64 * filter. That configuration consumes more power. 64 * filter. That configuration consumes more power.
65*/ 65*/
66 66
67//usage:#define ether_wake_trivial_usage
68//usage: "[-b] [-i iface] [-p aa:bb:cc:dd[:ee:ff]] MAC"
69//usage:#define ether_wake_full_usage "\n\n"
70//usage: "Send a magic packet to wake up sleeping machines.\n"
71//usage: "MAC must be a station address (00:11:22:33:44:55) or\n"
72//usage: "a hostname with a known 'ethers' entry.\n"
73//usage: "\nOptions:"
74//usage: "\n -b Send wake-up packet to the broadcast address"
75//usage: "\n -i iface Interface to use (default eth0)"
76//usage: "\n -p pass Append four or six byte password PW to the packet"
67 77
68#include <netpacket/packet.h> 78#include <netpacket/packet.h>
69#include <net/ethernet.h> 79#include <net/ethernet.h>
diff --git a/networking/ftpd.c b/networking/ftpd.c
index b59135667..fae634ec4 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -433,7 +433,7 @@ bind_for_passive_mode(void)
433 G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0); 433 G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0);
434 setsockopt_reuseaddr(fd); 434 setsockopt_reuseaddr(fd);
435 435
436 set_nport(G.local_addr, 0); 436 set_nport(&G.local_addr->u.sa, 0);
437 xbind(fd, &G.local_addr->u.sa, G.local_addr->len); 437 xbind(fd, &G.local_addr->u.sa, G.local_addr->len);
438 xlisten(fd, 1); 438 xlisten(fd, 1);
439 getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len); 439 getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len);
@@ -542,7 +542,7 @@ handle_port(void)
542 G.port_addr = xdotted2sockaddr(raw, port); 542 G.port_addr = xdotted2sockaddr(raw, port);
543#else 543#else
544 G.port_addr = get_peer_lsa(STDIN_FILENO); 544 G.port_addr = get_peer_lsa(STDIN_FILENO);
545 set_nport(G.port_addr, htons(port)); 545 set_nport(&G.port_addr->u.sa, htons(port));
546#endif 546#endif
547 WRITE_OK(FTP_PORTOK); 547 WRITE_OK(FTP_PORTOK);
548} 548}
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index c68d0ace2..66316e21f 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -13,6 +13,44 @@
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 15
16//usage:#define ftpget_trivial_usage
17//usage: "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE"
18//usage:#define ftpget_full_usage "\n\n"
19//usage: "Retrieve a remote file via FTP\n"
20//usage: "\nOptions:"
21//usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS(
22//usage: "\n -c,--continue Continue previous transfer"
23//usage: "\n -v,--verbose Verbose"
24//usage: "\n -u,--username Username"
25//usage: "\n -p,--password Password"
26//usage: "\n -P,--port Port number"
27//usage: )
28//usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS(
29//usage: "\n -c Continue previous transfer"
30//usage: "\n -v Verbose"
31//usage: "\n -u Username"
32//usage: "\n -p Password"
33//usage: "\n -P Port number"
34//usage: )
35//usage:
36//usage:#define ftpput_trivial_usage
37//usage: "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE"
38//usage:#define ftpput_full_usage "\n\n"
39//usage: "Store a local file on a remote machine via FTP\n"
40//usage: "\nOptions:"
41//usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS(
42//usage: "\n -v,--verbose Verbose"
43//usage: "\n -u,--username Username"
44//usage: "\n -p,--password Password"
45//usage: "\n -P,--port Port number"
46//usage: )
47//usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS(
48//usage: "\n -v Verbose"
49//usage: "\n -u Username"
50//usage: "\n -p Password"
51//usage: "\n -P Port number"
52//usage: )
53
16#include "libbb.h" 54#include "libbb.h"
17 55
18struct globals { 56struct globals {
@@ -151,7 +189,7 @@ TODO2: need to stop ignoring IP address in PASV response.
151 *buf_ptr = '\0'; 189 *buf_ptr = '\0';
152 port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; 190 port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256;
153 191
154 set_nport(lsa, htons(port_num)); 192 set_nport(&lsa->u.sa, htons(port_num));
155 return xconnect_stream(lsa); 193 return xconnect_stream(lsa);
156} 194}
157 195
diff --git a/networking/hostname.c b/networking/hostname.c
index 66b52dd90..49a3e89bb 100644
--- a/networking/hostname.c
+++ b/networking/hostname.c
@@ -9,6 +9,25 @@
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//usage:#define hostname_trivial_usage
14//usage: "[OPTIONS] [HOSTNAME | -F FILE]"
15//usage:#define hostname_full_usage "\n\n"
16//usage: "Get or set hostname or DNS domain name\n"
17//usage: "\nOptions:"
18//usage: "\n -s Short"
19//usage: "\n -i Addresses for the hostname"
20//usage: "\n -d DNS domain name"
21//usage: "\n -f Fully qualified domain name"
22//usage: "\n -F FILE Use FILE's content as hostname"
23//usage:
24//usage:#define hostname_example_usage
25//usage: "$ hostname\n"
26//usage: "sage\n"
27//usage:
28//usage:#define dnsdomainname_trivial_usage NOUSAGE_STR
29//usage:#define dnsdomainname_full_usage ""
30
12#include "libbb.h" 31#include "libbb.h"
13 32
14static void do_sethostname(char *s, int isfile) 33static void do_sethostname(char *s, int isfile)
diff --git a/networking/httpd.c b/networking/httpd.c
index b8113a843..d6157aca2 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -21,6 +21,10 @@
21 * The server changes directory to the location of the script and executes it 21 * The server changes directory to the location of the script and executes it
22 * after setting QUERY_STRING and other environment variables. 22 * after setting QUERY_STRING and other environment variables.
23 * 23 *
24 * If directory URL is given, no index.html is found and CGI support is enabled,
25 * cgi-bin/index.cgi will be run. Directory to list is ../$QUERY_STRING.
26 * See httpd_indexcgi.c for an example GCI code.
27 *
24 * Doc: 28 * Doc:
25 * "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html 29 * "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html
26 * 30 *
@@ -71,7 +75,7 @@
71 * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255 75 * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255
72 * A:* # (optional line added for clarity) 76 * A:* # (optional line added for clarity)
73 * 77 *
74 * If a sub directory contains a config file it is parsed and merged with 78 * If a sub directory contains config file, it is parsed and merged with
75 * any existing settings as if it was appended to the original configuration. 79 * any existing settings as if it was appended to the original configuration.
76 * 80 *
77 * subdir paths are relative to the containing subdir and thus cannot 81 * subdir paths are relative to the containing subdir and thus cannot
@@ -93,6 +97,32 @@
93 */ 97 */
94 /* TODO: use TCP_CORK, parse_config() */ 98 /* TODO: use TCP_CORK, parse_config() */
95 99
100//usage:#define httpd_trivial_usage
101//usage: "[-ifv[v]]"
102//usage: " [-c CONFFILE]"
103//usage: " [-p [IP:]PORT]"
104//usage: IF_FEATURE_HTTPD_SETUID(" [-u USER[:GRP]]")
105//usage: IF_FEATURE_HTTPD_BASIC_AUTH(" [-r REALM]")
106//usage: " [-h HOME]\n"
107//usage: "or httpd -d/-e" IF_FEATURE_HTTPD_AUTH_MD5("/-m") " STRING"
108//usage:#define httpd_full_usage "\n\n"
109//usage: "Listen for incoming HTTP requests\n"
110//usage: "\nOptions:"
111//usage: "\n -i Inetd mode"
112//usage: "\n -f Don't daemonize"
113//usage: "\n -v[v] Verbose"
114//usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:80)"
115//usage: IF_FEATURE_HTTPD_SETUID(
116//usage: "\n -u USER[:GRP] Set uid/gid after binding to port")
117//usage: IF_FEATURE_HTTPD_BASIC_AUTH(
118//usage: "\n -r REALM Authentication Realm for Basic Authentication")
119//usage: "\n -h HOME Home directory (default .)"
120//usage: "\n -c FILE Configuration file (default {/etc,HOME}/httpd.conf)"
121//usage: IF_FEATURE_HTTPD_AUTH_MD5(
122//usage: "\n -m STRING MD5 crypt STRING")
123//usage: "\n -e STRING HTML encode STRING"
124//usage: "\n -d STRING URL decode STRING"
125
96#include "libbb.h" 126#include "libbb.h"
97#if ENABLE_FEATURE_HTTPD_USE_SENDFILE 127#if ENABLE_FEATURE_HTTPD_USE_SENDFILE
98# include <sys/sendfile.h> 128# include <sys/sendfile.h>
@@ -1065,6 +1095,7 @@ static void send_headers(int responseNum)
1065static void send_headers_and_exit(int responseNum) NORETURN; 1095static void send_headers_and_exit(int responseNum) NORETURN;
1066static void send_headers_and_exit(int responseNum) 1096static void send_headers_and_exit(int responseNum)
1067{ 1097{
1098 IF_FEATURE_HTTPD_GZIP(content_gzip = 0;)
1068 send_headers(responseNum); 1099 send_headers(responseNum);
1069 log_and_exit(); 1100 log_and_exit();
1070} 1101}
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index da2635ce0..220b02126 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -26,6 +26,27 @@
26 * IPV6 support added by Bart Visscher <magick@linux-fan.com> 26 * IPV6 support added by Bart Visscher <magick@linux-fan.com>
27 */ 27 */
28 28
29//usage:#define ifconfig_trivial_usage
30//usage: IF_FEATURE_IFCONFIG_STATUS("[-a]") " interface [address]"
31//usage:#define ifconfig_full_usage "\n\n"
32//usage: "Configure a network interface\n"
33//usage: "\nOptions:"
34//usage: "\n"
35//usage: IF_FEATURE_IPV6(
36//usage: " [add ADDRESS[/PREFIXLEN]]\n")
37//usage: IF_FEATURE_IPV6(
38//usage: " [del ADDRESS[/PREFIXLEN]]\n")
39//usage: " [[-]broadcast [ADDRESS]] [[-]pointopoint [ADDRESS]]\n"
40//usage: " [netmask ADDRESS] [dstaddr ADDRESS]\n"
41//usage: IF_FEATURE_IFCONFIG_SLIP(
42//usage: " [outfill NN] [keepalive NN]\n")
43//usage: " " IF_FEATURE_IFCONFIG_HW("[hw ether" IF_FEATURE_HWIB("|infiniband")" ADDRESS] ") "[metric NN] [mtu NN]\n"
44//usage: " [[-]trailers] [[-]arp] [[-]allmulti]\n"
45//usage: " [multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]\n"
46//usage: IF_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ(
47//usage: " [mem_start NN] [io_addr NN] [irq NN]\n")
48//usage: " [up|down] ..."
49
29#include <net/if.h> 50#include <net/if.h>
30#include <net/if_arp.h> 51#include <net/if_arp.h>
31#include <netinet/in.h> 52#include <netinet/in.h>
diff --git a/networking/ifenslave.c b/networking/ifenslave.c
index 0b3ebf72a..208623e7d 100644
--- a/networking/ifenslave.c
+++ b/networking/ifenslave.c
@@ -98,6 +98,33 @@
98 * set version to 1.1.0 98 * set version to 1.1.0
99 */ 99 */
100 100
101//usage:#define ifenslave_trivial_usage
102//usage: "[-cdf] MASTER_IFACE SLAVE_IFACE..."
103//usage:#define ifenslave_full_usage "\n\n"
104//usage: "Configure network interfaces for parallel routing\n"
105//usage: "\nOptions:"
106//usage: "\n -c,--change-active Change active slave"
107//usage: "\n -d,--detach Remove slave interface from bonding device"
108//usage: "\n -f,--force Force, even if interface is not Ethernet"
109/* //usage: "\n -r,--receive-slave Create a receive-only slave" */
110//usage:
111//usage:#define ifenslave_example_usage
112//usage: "To create a bond device, simply follow these three steps:\n"
113//usage: "- ensure that the required drivers are properly loaded:\n"
114//usage: " # modprobe bonding ; modprobe <3c59x|eepro100|pcnet32|tulip|...>\n"
115//usage: "- assign an IP address to the bond device:\n"
116//usage: " # ifconfig bond0 <addr> netmask <mask> broadcast <bcast>\n"
117//usage: "- attach all the interfaces you need to the bond device:\n"
118//usage: " # ifenslave bond0 eth0 eth1 eth2\n"
119//usage: " If bond0 didn't have a MAC address, it will take eth0's. Then, all\n"
120//usage: " interfaces attached AFTER this assignment will get the same MAC addr.\n\n"
121//usage: " To detach a dead interface without setting the bond device down:\n"
122//usage: " # ifenslave -d bond0 eth1\n\n"
123//usage: " To set the bond device down and automatically release all the slaves:\n"
124//usage: " # ifconfig bond0 down\n\n"
125//usage: " To change active slave:\n"
126//usage: " # ifenslave -c bond0 eth0\n"
127
101#include "libbb.h" 128#include "libbb.h"
102 129
103/* #include <net/if.h> - no. linux/if_bonding.h pulls in linux/if.h */ 130/* #include <net/if.h> - no. linux/if_bonding.h pulls in linux/if.h */
diff --git a/networking/ifplugd.c b/networking/ifplugd.c
index 8dd0a5bd8..421611aae 100644
--- a/networking/ifplugd.c
+++ b/networking/ifplugd.c
@@ -6,6 +6,32 @@
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//usage:#define ifplugd_trivial_usage
11//usage: "[OPTIONS]"
12//usage:#define ifplugd_full_usage "\n\n"
13//usage: "Network interface plug detection daemon\n"
14//usage: "\nOptions:"
15//usage: "\n -n Don't daemonize"
16//usage: "\n -s Don't log to syslog"
17//usage: "\n -i IFACE Interface"
18//usage: "\n -f/-F Treat link detection error as link down/link up"
19//usage: "\n (otherwise exit on error)"
20//usage: "\n -a Don't up interface at each link probe"
21//usage: "\n -M Monitor creation/destruction of interface"
22//usage: "\n (otherwise it must exist)"
23//usage: "\n -r PROG Script to run"
24//usage: "\n -x ARG Extra argument for script"
25//usage: "\n -I Don't exit on nonzero exit code from script"
26//usage: "\n -p Don't run script on daemon startup"
27//usage: "\n -q Don't run script on daemon quit"
28//usage: "\n -l Run script on startup even if no cable is detected"
29//usage: "\n -t SECS Poll time in seconds"
30//usage: "\n -u SECS Delay before running script after link up"
31//usage: "\n -d SECS Delay after link down"
32//usage: "\n -m MODE API mode (mii, priv, ethtool, wlan, iff, auto)"
33//usage: "\n -k Kill running daemon"
34
9#include "libbb.h" 35#include "libbb.h"
10 36
11#include "fix_u32.h" 37#include "fix_u32.h"
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 7706a84b7..b48abb7dc 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -17,6 +17,34 @@
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 19
20//usage:#define ifup_trivial_usage
21//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
22//usage:#define ifup_full_usage "\n\n"
23//usage: "Options:"
24//usage: "\n -a De/configure all interfaces automatically"
25//usage: "\n -i FILE Use FILE for interface definitions"
26//usage: "\n -n Print out what would happen, but don't do it"
27//usage: IF_FEATURE_IFUPDOWN_MAPPING(
28//usage: "\n (note: doesn't disable mappings)"
29//usage: "\n -m Don't run any mappings"
30//usage: )
31//usage: "\n -v Print out what would happen before doing it"
32//usage: "\n -f Force de/configuration"
33//usage:
34//usage:#define ifdown_trivial_usage
35//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
36//usage:#define ifdown_full_usage "\n\n"
37//usage: "Options:"
38//usage: "\n -a De/configure all interfaces automatically"
39//usage: "\n -i FILE Use FILE for interface definitions"
40//usage: "\n -n Print out what would happen, but don't do it"
41//usage: IF_FEATURE_IFUPDOWN_MAPPING(
42//usage: "\n (note: doesn't disable mappings)"
43//usage: "\n -m Don't run any mappings"
44//usage: )
45//usage: "\n -v Print out what would happen before doing it"
46//usage: "\n -f Force de/configuration"
47
20#include "libbb.h" 48#include "libbb.h"
21/* After libbb.h, since it needs sys/types.h on some systems */ 49/* After libbb.h, since it needs sys/types.h on some systems */
22#include <sys/utsname.h> 50#include <sys/utsname.h>
diff --git a/networking/inetd.c b/networking/inetd.c
index fb00c6cd7..226a6491c 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -154,6 +154,17 @@
154 * setuid() 154 * setuid()
155 */ 155 */
156 156
157//usage:#define inetd_trivial_usage
158//usage: "[-fe] [-q N] [-R N] [CONFFILE]"
159//usage:#define inetd_full_usage "\n\n"
160//usage: "Listen for network connections and launch programs\n"
161//usage: "\nOptions:"
162//usage: "\n -f Run in foreground"
163//usage: "\n -e Log to stderr"
164//usage: "\n -q N Socket listen queue (default: 128)"
165//usage: "\n -R N Pause services after N connects/min"
166//usage: "\n (default: 0 - disabled)"
167
157#include <syslog.h> 168#include <syslog.h>
158#include <sys/un.h> 169#include <sys/un.h>
159 170
@@ -501,7 +512,7 @@ static void prepare_socket_fd(servtab_t *sep)
501 512
502 /* zero out the port for all RPC services; let bind() 513 /* zero out the port for all RPC services; let bind()
503 * find one. */ 514 * find one. */
504 set_nport(sep->se_lsa, 0); 515 set_nport(&sep->se_lsa->u.sa, 0);
505 516
506 /* for RPC services, attempt to use a reserved port 517 /* for RPC services, attempt to use a reserved port
507 * if they are going to be running as root. */ 518 * if they are going to be running as root. */
@@ -959,7 +970,7 @@ static void reread_config_file(int sig UNUSED_PARAM)
959 } 970 }
960 if (LONE_CHAR(sep->se_local_hostname, '*')) { 971 if (LONE_CHAR(sep->se_local_hostname, '*')) {
961 lsa = xzalloc_lsa(sep->se_family); 972 lsa = xzalloc_lsa(sep->se_family);
962 set_nport(lsa, port); 973 set_nport(&lsa->u.sa, port);
963 } else { 974 } else {
964 lsa = host_and_af2sockaddr(sep->se_local_hostname, 975 lsa = host_and_af2sockaddr(sep->se_local_hostname,
965 ntohs(port), sep->se_family); 976 ntohs(port), sep->se_family);
diff --git a/networking/interface.c b/networking/interface.c
index 83af62b7c..bea54c180 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -32,7 +32,7 @@
32 */ 32 */
33#include <net/if.h> 33#include <net/if.h>
34#include <net/if_arp.h> 34#include <net/if_arp.h>
35#if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION) 35#ifndef __UCLIBC__
36# include <net/ethernet.h> 36# include <net/ethernet.h>
37#else 37#else
38# include <linux/if_ether.h> 38# include <linux/if_ether.h>
diff --git a/networking/ip.c b/networking/ip.c
index 350656cef..98d583325 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -9,6 +9,79 @@
9 * Bernhard Reutner-Fischer rewrote to use index_in_substr_array 9 * Bernhard Reutner-Fischer rewrote to use index_in_substr_array
10 */ 10 */
11 11
12/* would need to make the " | " optional depending on more than one selected: */
13//usage:#define ip_trivial_usage
14//usage: "[OPTIONS] {"
15//usage: IF_FEATURE_IP_ADDRESS("address | ")
16//usage: IF_FEATURE_IP_ROUTE("route | ")
17//usage: IF_FEATURE_IP_LINK("link | ")
18//usage: IF_FEATURE_IP_TUNNEL("tunnel | ")
19//usage: IF_FEATURE_IP_RULE("rule")
20//usage: "} {COMMAND}"
21//usage:#define ip_full_usage "\n\n"
22//usage: "ip [OPTIONS] OBJECT {COMMAND}\n"
23//usage: "where OBJECT := {"
24//usage: IF_FEATURE_IP_ADDRESS("address | ")
25//usage: IF_FEATURE_IP_ROUTE("route | ")
26//usage: IF_FEATURE_IP_LINK("link | ")
27//usage: IF_FEATURE_IP_TUNNEL("tunnel | ")
28//usage: IF_FEATURE_IP_RULE("rule")
29//usage: "}\n"
30//usage: "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }"
31//usage:
32//usage:#define ipaddr_trivial_usage
33//usage: "{ {add|del} IFADDR dev STRING | {show|flush}\n"
34//usage: " [dev STRING] [to PREFIX] }"
35//usage:#define ipaddr_full_usage "\n\n"
36//usage: "ipaddr {add|delete} IFADDR dev STRING\n"
37//usage: "ipaddr {show|flush} [dev STRING] [scope SCOPE-ID]\n"
38//usage: " [to PREFIX] [label PATTERN]\n"
39//usage: " IFADDR := PREFIX | ADDR peer PREFIX\n"
40//usage: " [broadcast ADDR] [anycast ADDR]\n"
41//usage: " [label STRING] [scope SCOPE-ID]\n"
42//usage: " SCOPE-ID := [host | link | global | NUMBER]"
43//usage:
44//usage:#define iplink_trivial_usage
45//usage: "{ set DEVICE { up | down | arp { on | off } | show [DEVICE] }"
46//usage:#define iplink_full_usage "\n\n"
47//usage: "iplink set DEVICE { up | down | arp | multicast { on | off } |\n"
48//usage: " dynamic { on | off } |\n"
49//usage: " mtu MTU }\n"
50//usage: "iplink show [DEVICE]"
51//usage:
52//usage:#define iproute_trivial_usage
53//usage: "{ list | flush | { add | del | change | append |\n"
54//usage: " replace | monitor } ROUTE }"
55//usage:#define iproute_full_usage "\n\n"
56//usage: "iproute { list | flush } SELECTOR\n"
57//usage: "iproute get ADDRESS [from ADDRESS iif STRING]\n"
58//usage: " [oif STRING] [tos TOS]\n"
59//usage: "iproute { add | del | change | append | replace | monitor } ROUTE\n"
60//usage: " SELECTOR := [root PREFIX] [match PREFIX] [proto RTPROTO]\n"
61//usage: " ROUTE := [TYPE] PREFIX [tos TOS] [proto RTPROTO]\n"
62//usage: " [metric METRIC]"
63//usage:
64//usage:#define iprule_trivial_usage
65//usage: "{[list | add | del] RULE}"
66//usage:#define iprule_full_usage "\n\n"
67//usage: "iprule [list | add | del] SELECTOR ACTION\n"
68//usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n"
69//usage: " [dev STRING] [pref NUMBER]\n"
70//usage: " ACTION := [table TABLE_ID] [nat ADDRESS]\n"
71//usage: " [prohibit | reject | unreachable]\n"
72//usage: " [realms [SRCREALM/]DSTREALM]\n"
73//usage: " TABLE_ID := [local | main | default | NUMBER]"
74//usage:
75//usage:#define iptunnel_trivial_usage
76//usage: "{ add | change | del | show } [NAME]\n"
77//usage: " [mode { ipip | gre | sit }]\n"
78//usage: " [remote ADDR] [local ADDR] [ttl TTL]"
79//usage:#define iptunnel_full_usage "\n\n"
80//usage: "iptunnel { add | change | del | show } [NAME]\n"
81//usage: " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n"
82//usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n"
83//usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]"
84
12#include "libbb.h" 85#include "libbb.h"
13 86
14#include "libiproute/utils.h" 87#include "libiproute/utils.h"
diff --git a/networking/ipcalc.c b/networking/ipcalc.c
index acbaa4ac5..f96c73912 100644
--- a/networking/ipcalc.c
+++ b/networking/ipcalc.c
@@ -11,6 +11,33 @@
11 * 11 *
12 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 12 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
13 */ 13 */
14
15//usage:#define ipcalc_trivial_usage
16//usage: "[OPTIONS] ADDRESS[[/]NETMASK] [NETMASK]"
17//usage:#define ipcalc_full_usage "\n\n"
18//usage: "Calculate IP network settings from a IP address\n"
19//usage: "\nOptions:"
20//usage: IF_FEATURE_IPCALC_LONG_OPTIONS(
21//usage: "\n -b,--broadcast Display calculated broadcast address"
22//usage: "\n -n,--network Display calculated network address"
23//usage: "\n -m,--netmask Display default netmask for IP"
24//usage: IF_FEATURE_IPCALC_FANCY(
25//usage: "\n -p,--prefix Display the prefix for IP/NETMASK"
26//usage: "\n -h,--hostname Display first resolved host name"
27//usage: "\n -s,--silent Don't ever display error messages"
28//usage: )
29//usage: )
30//usage: IF_NOT_FEATURE_IPCALC_LONG_OPTIONS(
31//usage: "\n -b Display calculated broadcast address"
32//usage: "\n -n Display calculated network address"
33//usage: "\n -m Display default netmask for IP"
34//usage: IF_FEATURE_IPCALC_FANCY(
35//usage: "\n -p Display the prefix for IP/NETMASK"
36//usage: "\n -h Display first resolved host name"
37//usage: "\n -s Don't ever display error messages"
38//usage: )
39//usage: )
40
14#include "libbb.h" 41#include "libbb.h"
15/* After libbb.h, because on some systems it needs other includes */ 42/* After libbb.h, because on some systems it needs other includes */
16#include <arpa/inet.h> 43#include <arpa/inet.h>
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index 18ce59aaf..199e11225 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -7,6 +7,17 @@
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 9
10//usage:#define fakeidentd_trivial_usage
11//usage: "[-fiw] [-b ADDR] [STRING]"
12//usage:#define fakeidentd_full_usage "\n\n"
13//usage: "Provide fake ident (auth) service\n"
14//usage: "\nOptions:"
15//usage: "\n -f Run in foreground"
16//usage: "\n -i Inetd mode"
17//usage: "\n -w Inetd 'wait' mode"
18//usage: "\n -b ADDR Bind to specified address"
19//usage: "\n STRING Ident answer string (default: nobody)"
20
10#include "libbb.h" 21#include "libbb.h"
11#include <syslog.h> 22#include <syslog.h>
12#include "isrv.h" 23#include "isrv.h"
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c
index 38b6c0516..bb42e269e 100644
--- a/networking/libiproute/ll_types.c
+++ b/networking/libiproute/ll_types.c
@@ -7,6 +7,7 @@
7 * 7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
9 */ 9 */
10#include <sys/socket.h> /* linux/if_arp.h needs it on some systems */
10#include <arpa/inet.h> 11#include <arpa/inet.h>
11#include <linux/if_arp.h> 12#include <linux/if_arp.h>
12 13
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c
index e98a5dd5b..29f99e76b 100644
--- a/networking/nc_bloaty.c
+++ b/networking/nc_bloaty.c
@@ -386,10 +386,10 @@ create new one, and bind() it. TODO */
386 if (port == 0) { 386 if (port == 0) {
387 /* "nc -nl -p LPORT RHOST" (w/o RPORT!): 387 /* "nc -nl -p LPORT RHOST" (w/o RPORT!):
388 * we should accept any remote port */ 388 * we should accept any remote port */
389 set_nport(&remend, 0); /* blot out remote port# */ 389 set_nport(&remend.u.sa, 0); /* blot out remote port# */
390 } 390 }
391 r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len); 391 r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len);
392 set_nport(&remend, sv_port); /* restore */ 392 set_nport(&remend.u.sa, sv_port); /* restore */
393 if (r != 0) { 393 if (r != 0) {
394 /* nc 1.10 bails out instead, and its error message 394 /* nc 1.10 bails out instead, and its error message
395 * is not suppressed by o_verbose */ 395 * is not suppressed by o_verbose */
@@ -486,7 +486,7 @@ static int udptest(void)
486 us to hang forever, and hit it */ 486 us to hang forever, and hit it */
487 o_wait = 5; /* enough that we'll notice?? */ 487 o_wait = 5; /* enough that we'll notice?? */
488 rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); 488 rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0);
489 set_nport(themaddr, htons(SLEAZE_PORT)); 489 set_nport(&themaddr->u.sa, htons(SLEAZE_PORT));
490 connect_w_timeout(rr); 490 connect_w_timeout(rr);
491 /* don't need to restore themaddr's port, it's not used anymore */ 491 /* don't need to restore themaddr's port, it's not used anymore */
492 close(rr); 492 close(rr);
@@ -813,7 +813,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv)
813 (themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC), 813 (themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC),
814 x); 814 x);
815 if (o_lport) 815 if (o_lport)
816 set_nport(ouraddr, htons(o_lport)); 816 set_nport(&ouraddr->u.sa, htons(o_lport));
817 } 817 }
818 xmove_fd(x, netfd); 818 xmove_fd(x, netfd);
819 setsockopt_reuseaddr(netfd); 819 setsockopt_reuseaddr(netfd);
diff --git a/networking/nslookup.c b/networking/nslookup.c
index 67fc01547..f4fd407dd 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -11,6 +11,20 @@
11 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13 13
14//usage:#define nslookup_trivial_usage
15//usage: "[HOST] [SERVER]"
16//usage:#define nslookup_full_usage "\n\n"
17//usage: "Query the nameserver for the IP address of the given HOST\n"
18//usage: "optionally using a specified DNS server"
19//usage:
20//usage:#define nslookup_example_usage
21//usage: "$ nslookup localhost\n"
22//usage: "Server: default\n"
23//usage: "Address: default\n"
24//usage: "\n"
25//usage: "Name: debian\n"
26//usage: "Address: 127.0.0.1\n"
27
14#include <resolv.h> 28#include <resolv.h>
15#include "libbb.h" 29#include "libbb.h"
16 30
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 3ed05ba29..e27dbaa6b 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -27,6 +27,23 @@
27 * * 27 * *
28 *********************************************************************** 28 ***********************************************************************
29 */ 29 */
30
31//usage:#define ntpd_trivial_usage
32//usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l")"] [-S PROG] [-p PEER]..."
33//usage:#define ntpd_full_usage "\n\n"
34//usage: "NTP client/server\n"
35//usage: "\nOptions:"
36//usage: "\n -d Verbose"
37//usage: "\n -n Do not daemonize"
38//usage: "\n -q Quit after clock is set"
39//usage: "\n -N Run at high priority"
40//usage: "\n -w Do not set time (only query peers), implies -n"
41//usage: IF_FEATURE_NTPD_SERVER(
42//usage: "\n -l Run as server on port 123"
43//usage: )
44//usage: "\n -S PROG Run PROG after stepping time, stratum change, and every 11 mins"
45//usage: "\n -p PEER Obtain time from PEER (may be repeated)"
46
30#include "libbb.h" 47#include "libbb.h"
31#include <math.h> 48#include <math.h>
32#include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */ 49#include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */
@@ -238,6 +255,8 @@ enum {
238 OPT_p = (1 << 5), 255 OPT_p = (1 << 5),
239 OPT_S = (1 << 6), 256 OPT_S = (1 << 6),
240 OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER, 257 OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER,
258 /* We hijack some bits for other purposes */
259 OPT_qq = (1 << 8),
241}; 260};
242 261
243struct globals { 262struct globals {
@@ -1930,15 +1949,18 @@ static NOINLINE void ntp_init(char **argv)
1930 setpriority(PRIO_PROCESS, 0, -15); 1949 setpriority(PRIO_PROCESS, 0, -15);
1931 1950
1932 /* If network is up, syncronization occurs in ~10 seconds. 1951 /* If network is up, syncronization occurs in ~10 seconds.
1933 * We give "ntpd -q" a full minute to finish, then we exit. 1952 * We give "ntpd -q" 10 seconds to get first reply,
1953 * then another 50 seconds to finish syncing.
1934 * 1954 *
1935 * I tested ntpd 4.2.6p1 and apparently it never exits 1955 * I tested ntpd 4.2.6p1 and apparently it never exits
1936 * (will try forever), but it does not feel right. 1956 * (will try forever), but it does not feel right.
1937 * The goal of -q is to act like ntpdate: set time 1957 * The goal of -q is to act like ntpdate: set time
1938 * after a reasonably small period of polling, or fail. 1958 * after a reasonably small period of polling, or fail.
1939 */ 1959 */
1940 if (opts & OPT_q) 1960 if (opts & OPT_q) {
1941 alarm(60); 1961 option_mask32 |= OPT_qq;
1962 alarm(10);
1963 }
1942 1964
1943 bb_signals(0 1965 bb_signals(0
1944 | (1 << SIGTERM) 1966 | (1 << SIGTERM)
@@ -2065,6 +2087,15 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
2065#endif 2087#endif
2066 for (; nfds != 0 && j < i; j++) { 2088 for (; nfds != 0 && j < i; j++) {
2067 if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { 2089 if (pfd[j].revents /* & (POLLIN|POLLERR)*/) {
2090 /*
2091 * At init, alarm was set to 10 sec.
2092 * Now we did get a reply.
2093 * Increase timeout to 50 seconds to finish syncing.
2094 */
2095 if (option_mask32 & OPT_qq) {
2096 option_mask32 &= ~OPT_qq;
2097 alarm(50);
2098 }
2068 nfds--; 2099 nfds--;
2069 recv_and_process_peer_pkt(idx2peer[j]); 2100 recv_and_process_peer_pkt(idx2peer[j]);
2070 gettime1900d(); /* sets G.cur_time */ 2101 gettime1900d(); /* sets G.cur_time */
diff --git a/networking/pscan.c b/networking/pscan.c
index a8194d1a8..5595148fc 100644
--- a/networking/pscan.c
+++ b/networking/pscan.c
@@ -6,6 +6,18 @@
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 8
9//usage:#define pscan_trivial_usage
10//usage: "[-cb] [-p MIN_PORT] [-P MAX_PORT] [-t TIMEOUT] [-T MIN_RTT] HOST"
11//usage:#define pscan_full_usage "\n\n"
12//usage: "Scan a host, print all open ports\n"
13//usage: "\nOptions:"
14//usage: "\n -c Show closed ports too"
15//usage: "\n -b Show blocked ports too"
16//usage: "\n -p Scan from this port (default 1)"
17//usage: "\n -P Scan up to this port (default 1024)"
18//usage: "\n -t Timeout (default 5000 ms)"
19//usage: "\n -T Minimum rtt (default 5 ms, increase for congested hosts)"
20
9#include "libbb.h" 21#include "libbb.h"
10 22
11/* debugging */ 23/* debugging */
@@ -76,7 +88,7 @@ int pscan_main(int argc UNUSED_PARAM, char **argv)
76 DMSG("rtt %u", rtt_4); 88 DMSG("rtt %u", rtt_4);
77 89
78 /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */ 90 /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */
79 set_nport(lsap, htons(port)); 91 set_nport(&lsap->u.sa, htons(port));
80 s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0); 92 s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0);
81 /* We need unblocking socket so we don't need to wait for ETIMEOUT. */ 93 /* We need unblocking socket so we don't need to wait for ETIMEOUT. */
82 /* Nonblocking connect typically "fails" with errno == EINPROGRESS */ 94 /* Nonblocking connect typically "fails" with errno == EINPROGRESS */
diff --git a/networking/route.c b/networking/route.c
index 98a03ded7..6699a1c32 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -25,6 +25,15 @@
25 * remove ridiculous amounts of bloat. 25 * remove ridiculous amounts of bloat.
26 */ 26 */
27 27
28//usage:#define route_trivial_usage
29//usage: "[{add|del|delete}]"
30//usage:#define route_full_usage "\n\n"
31//usage: "Edit kernel routing tables\n"
32//usage: "\nOptions:"
33//usage: "\n -n Don't resolve names"
34//usage: "\n -e Display other/more information"
35//usage: "\n -A inet" IF_FEATURE_IPV6("{6}") " Select address family"
36
28#include <net/route.h> 37#include <net/route.h>
29#include <net/if.h> 38#include <net/if.h>
30 39
diff --git a/networking/slattach.c b/networking/slattach.c
index 71edd2f27..d1221b11a 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -13,6 +13,20 @@
13 * - The -F options allows disabling of RTS/CTS flow control. 13 * - The -F options allows disabling of RTS/CTS flow control.
14 */ 14 */
15 15
16//usage:#define slattach_trivial_usage
17//usage: "[-cehmLF] [-s SPEED] [-p PROTOCOL] DEVICE"
18//usage:#define slattach_full_usage "\n\n"
19//usage: "Attach network interface(s) to serial line(s)\n"
20//usage: "\nOptions:"
21//usage: "\n -p PROT Set protocol (slip, cslip, slip6, clisp6 or adaptive)"
22//usage: "\n -s SPD Set line speed"
23//usage: "\n -e Exit after initializing device"
24//usage: "\n -h Exit when the carrier is lost"
25//usage: "\n -c PROG Run PROG when the line is hung up"
26//usage: "\n -m Do NOT initialize the line in raw 8 bits mode"
27//usage: "\n -L Enable 3-wire operation"
28//usage: "\n -F Disable RTS/CTS flow control"
29
16#include "libbb.h" 30#include "libbb.h"
17#include "libiproute/utils.h" /* invarg() */ 31#include "libiproute/utils.h" /* invarg() */
18 32
diff --git a/networking/tc.c b/networking/tc.c
index 9b3245546..e9848a86b 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -7,6 +7,27 @@
7 * Bernhard Reutner-Fischer adjusted for busybox 7 * Bernhard Reutner-Fischer adjusted for busybox
8 */ 8 */
9 9
10//usage:#define tc_trivial_usage
11/* //usage: "[OPTIONS] OBJECT CMD [dev STRING]" */
12//usage: "OBJECT CMD [dev STRING]"
13//usage:#define tc_full_usage "\n\n"
14//usage: "OBJECT: {qdisc|class|filter}\n"
15//usage: "CMD: {add|del|change|replace|show}\n"
16//usage: "\n"
17//usage: "qdisc [ handle QHANDLE ] [ root |"IF_FEATURE_TC_INGRESS(" ingress |")" parent CLASSID ]\n"
18/* //usage: "[ estimator INTERVAL TIME_CONSTANT ]\n" */
19//usage: " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n"
20//usage: " QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n"
21//usage: "qdisc show [ dev STRING ]"IF_FEATURE_TC_INGRESS(" [ingress]")"\n"
22//usage: "class [ classid CLASSID ] [ root | parent CLASSID ]\n"
23//usage: " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n"
24//usage: "class show [ dev STRING ] [ root | parent CLASSID ]\n"
25//usage: "filter [ pref PRIO ] [ protocol PROTO ]\n"
26/* //usage: "\t[ estimator INTERVAL TIME_CONSTANT ]\n" */
27//usage: " [ root | classid CLASSID ] [ handle FILTERID ]\n"
28//usage: " [ [ FILTER_TYPE ] [ help | OPTIONS ] ]\n"
29//usage: "filter show [ dev STRING ] [ root | parent CLASSID ]"
30
10#include "libbb.h" 31#include "libbb.h"
11 32
12#include "libiproute/utils.h" 33#include "libiproute/utils.h"
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index b532e43cd..a2b8c958c 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -29,6 +29,43 @@
29 * - don't know how to retrieve ORIGDST for udp. 29 * - don't know how to retrieve ORIGDST for udp.
30 */ 30 */
31 31
32//usage:#define tcpsvd_trivial_usage
33//usage: "[-hEv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] IP PORT PROG"
34/* with not-implemented options: */
35/* //usage: "[-hpEvv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] [-i DIR|-x CDB] [-t SEC] IP PORT PROG" */
36//usage:#define tcpsvd_full_usage "\n\n"
37//usage: "Create TCP socket, bind to IP:PORT and listen\n"
38//usage: "for incoming connection. Run PROG for each connection.\n"
39//usage: "\n IP IP to listen on. '0' = all"
40//usage: "\n PORT Port to listen on"
41//usage: "\n PROG ARGS Program to run"
42//usage: "\n -l NAME Local hostname (else looks up local hostname in DNS)"
43//usage: "\n -u USER[:GRP] Change to user/group after bind"
44//usage: "\n -c N Handle up to N connections simultaneously"
45//usage: "\n -b N Allow a backlog of approximately N TCP SYNs"
46//usage: "\n -C N[:MSG] Allow only up to N connections from the same IP."
47//usage: "\n New connections from this IP address are closed"
48//usage: "\n immediately. MSG is written to the peer before close"
49//usage: "\n -h Look up peer's hostname"
50//usage: "\n -E Don't set up environment variables"
51//usage: "\n -v Verbose"
52//usage:
53//usage:#define udpsvd_trivial_usage
54//usage: "[-hEv] [-c N] [-u USER] [-l NAME] IP PORT PROG"
55//usage:#define udpsvd_full_usage "\n\n"
56//usage: "Create UDP socket, bind to IP:PORT and wait\n"
57//usage: "for incoming packets. Run PROG for each packet,\n"
58//usage: "redirecting all further packets with same peer ip:port to it.\n"
59//usage: "\n IP IP to listen on. '0' = all"
60//usage: "\n PORT Port to listen on"
61//usage: "\n PROG ARGS Program to run"
62//usage: "\n -l NAME Local hostname (else looks up local hostname in DNS)"
63//usage: "\n -u USER[:GRP] Change to user/group after bind"
64//usage: "\n -c N Handle up to N connections simultaneously"
65//usage: "\n -h Look up peer's hostname"
66//usage: "\n -E Don't set up environment variables"
67//usage: "\n -v Verbose"
68
32#include "libbb.h" 69#include "libbb.h"
33 70
34/* Wants <limits.h> etc, thus included after libbb.h: */ 71/* Wants <limits.h> etc, thus included after libbb.h: */
@@ -387,7 +424,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
387 * already bound in parent! This seems to work in Linux. 424 * already bound in parent! This seems to work in Linux.
388 * (otherwise we can move socket to fd #0 only if bind succeeds) */ 425 * (otherwise we can move socket to fd #0 only if bind succeeds) */
389 close(0); 426 close(0);
390 set_nport(localp, htons(local_port)); 427 set_nport(&localp->u.sa, htons(local_port));
391 xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0); 428 xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0);
392 setsockopt_reuseaddr(0); /* crucial */ 429 setsockopt_reuseaddr(0); /* crucial */
393 xbind(0, &localp->u.sa, localp->len); 430 xbind(0, &localp->u.sa, localp->len);
diff --git a/networking/telnet.c b/networking/telnet.c
index f6fad684c..1f0d85107 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -21,6 +21,22 @@
21 * 21 *
22 */ 22 */
23 23
24//usage:#if ENABLE_FEATURE_TELNET_AUTOLOGIN
25//usage:#define telnet_trivial_usage
26//usage: "[-a] [-l USER] HOST [PORT]"
27//usage:#define telnet_full_usage "\n\n"
28//usage: "Connect to telnet server\n"
29//usage: "\nOptions:"
30//usage: "\n -a Automatic login with $USER variable"
31//usage: "\n -l USER Automatic login as USER"
32//usage:
33//usage:#else
34//usage:#define telnet_trivial_usage
35//usage: "HOST [PORT]"
36//usage:#define telnet_full_usage "\n\n"
37//usage: "Connect to telnet server"
38//usage:#endif
39
24#include <arpa/telnet.h> 40#include <arpa/telnet.h>
25#include <netinet/in.h> 41#include <netinet/in.h>
26#include "libbb.h" 42#include "libbb.h"
diff --git a/networking/telnetd.c b/networking/telnetd.c
index eec4417ca..4404064fc 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -20,6 +20,28 @@
20 * Vladimir Oleynik <dzo@simtreas.ru> 2001 20 * Vladimir Oleynik <dzo@simtreas.ru> 2001
21 * Set process group corrections, initial busybox port 21 * Set process group corrections, initial busybox port
22 */ 22 */
23
24//usage:#define telnetd_trivial_usage
25//usage: "[OPTIONS]"
26//usage:#define telnetd_full_usage "\n\n"
27//usage: "Handle incoming telnet connections"
28//usage: IF_NOT_FEATURE_TELNETD_STANDALONE(" via inetd") "\n"
29//usage: "\nOptions:"
30//usage: "\n -l LOGIN Exec LOGIN on connect"
31//usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue"
32//usage: "\n -K Close connection as soon as login exits"
33//usage: "\n (normally wait until all programs close slave pty)"
34//usage: IF_FEATURE_TELNETD_STANDALONE(
35//usage: "\n -p PORT Port to listen on"
36//usage: "\n -b ADDR[:PORT] Address to bind to"
37//usage: "\n -F Run in foreground"
38//usage: "\n -i Inetd mode"
39//usage: IF_FEATURE_TELNETD_INETD_WAIT(
40//usage: "\n -w SEC Inetd 'wait' mode, linger time SEC"
41//usage: "\n -S Log to syslog (implied by -i or without -F and -w)"
42//usage: )
43//usage: )
44
23#define DEBUG 0 45#define DEBUG 0
24 46
25#include "libbb.h" 47#include "libbb.h"
diff --git a/networking/tftp.c b/networking/tftp.c
index 35cf0dbd9..648441016 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -18,7 +18,42 @@
18 * 18 *
19 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 19 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
20 */ 20 */
21
22//usage:#define tftp_trivial_usage
23//usage: "[OPTIONS] HOST [PORT]"
24//usage:#define tftp_full_usage "\n\n"
25//usage: "Transfer a file from/to tftp server\n"
26//usage: "\nOptions:"
27//usage: "\n -l FILE Local FILE"
28//usage: "\n -r FILE Remote FILE"
29//usage: IF_FEATURE_TFTP_GET(
30//usage: "\n -g Get file"
31//usage: )
32//usage: IF_FEATURE_TFTP_PUT(
33//usage: "\n -p Put file"
34//usage: )
35//usage: IF_FEATURE_TFTP_BLOCKSIZE(
36//usage: "\n -b SIZE Transfer blocks of SIZE octets"
37//usage: )
38//usage:
39//usage:#define tftpd_trivial_usage
40//usage: "[-cr] [-u USER] [DIR]"
41//usage:#define tftpd_full_usage "\n\n"
42//usage: "Transfer a file on tftp client's request\n"
43//usage: "\n"
44//usage: "tftpd should be used as an inetd service.\n"
45//usage: "tftpd's line for inetd.conf:\n"
46//usage: " 69 dgram udp nowait root tftpd tftpd -l /files/to/serve\n"
47//usage: "It also can be ran from udpsvd:\n"
48//usage: " udpsvd -vE 0.0.0.0 69 tftpd /files/to/serve\n"
49//usage: "\nOptions:"
50//usage: "\n -r Prohibit upload"
51//usage: "\n -c Allow file creation via upload"
52//usage: "\n -u Access files as USER"
53//usage: "\n -l Log to syslog (inetd mode requires this)"
54
21#include "libbb.h" 55#include "libbb.h"
56#include <syslog.h>
22 57
23#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT 58#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
24 59
@@ -59,6 +94,7 @@ enum {
59 TFTPD_OPT_r = (1 << 8) * ENABLE_TFTPD, 94 TFTPD_OPT_r = (1 << 8) * ENABLE_TFTPD,
60 TFTPD_OPT_c = (1 << 9) * ENABLE_TFTPD, 95 TFTPD_OPT_c = (1 << 9) * ENABLE_TFTPD,
61 TFTPD_OPT_u = (1 << 10) * ENABLE_TFTPD, 96 TFTPD_OPT_u = (1 << 10) * ENABLE_TFTPD,
97 TFTPD_OPT_l = (1 << 11) * ENABLE_TFTPD,
62}; 98};
63 99
64#if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT 100#if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT
@@ -422,6 +458,7 @@ static int tftp_protocol(
422 finished = 1; 458 finished = 1;
423 } 459 }
424 cp += len; 460 cp += len;
461 IF_FEATURE_TFTP_PROGRESS_BAR(G.pos += len;)
425 } 462 }
426 send_pkt: 463 send_pkt:
427 /* Send packet */ 464 /* Send packet */
@@ -443,8 +480,6 @@ static int tftp_protocol(
443 xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); 480 xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len);
444 481
445#if ENABLE_FEATURE_TFTP_PROGRESS_BAR 482#if ENABLE_FEATURE_TFTP_PROGRESS_BAR
446 if (ENABLE_TFTP && remote_file) /* tftp */
447 G.pos = (block_nr - 1) * (uoff_t)blksize;
448 if (is_bb_progress_inited(&G.pmt)) 483 if (is_bb_progress_inited(&G.pmt))
449 tftp_progress_update(); 484 tftp_progress_update();
450#endif 485#endif
@@ -588,6 +623,7 @@ static int tftp_protocol(
588 if (sz != blksize) { 623 if (sz != blksize) {
589 finished = 1; 624 finished = 1;
590 } 625 }
626 IF_FEATURE_TFTP_PROGRESS_BAR(G.pos += sz;)
591 continue; /* send ACK */ 627 continue; /* send ACK */
592 } 628 }
593/* Disabled to cope with servers with Sorcerer's Apprentice Syndrome */ 629/* Disabled to cope with servers with Sorcerer's Apprentice Syndrome */
@@ -749,8 +785,12 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
749 peer_lsa->len = our_lsa->len; 785 peer_lsa->len = our_lsa->len;
750 786
751 /* Shifting to not collide with TFTP_OPTs */ 787 /* Shifting to not collide with TFTP_OPTs */
752 opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:", &user_opt) << 8); 788 opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:l", &user_opt) << 8);
753 argv += optind; 789 argv += optind;
790 if (opt & TFTPD_OPT_l) {
791 openlog(applet_name, LOG_PID, LOG_DAEMON);
792 logmode = LOGMODE_SYSLOG;
793 }
754 if (argv[0]) 794 if (argv[0])
755 xchdir(argv[0]); 795 xchdir(argv[0]);
756 796
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 82bb0118c..96f9d3472 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -210,6 +210,51 @@
210 * Tue Dec 20 03:50:13 PST 1988 210 * Tue Dec 20 03:50:13 PST 1988
211 */ 211 */
212 212
213//usage:#define traceroute_trivial_usage
214//usage: "[-"IF_TRACEROUTE6("46")"FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
215//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]\n"
216//usage: " [-z PAUSE_MSEC] HOST [BYTES]"
217//usage:#define traceroute_full_usage "\n\n"
218//usage: "Trace the route to HOST\n"
219//usage: "\nOptions:"
220//usage: IF_TRACEROUTE6(
221//usage: "\n -4,-6 Force IP or IPv6 name resolution"
222//usage: )
223//usage: "\n -F Set the don't fragment bit"
224//usage: "\n -I Use ICMP ECHO instead of UDP datagrams"
225//usage: "\n -l Display the TTL value of the returned packet"
226//usage: "\n -d Set SO_DEBUG options to socket"
227//usage: "\n -n Print numeric addresses"
228//usage: "\n -r Bypass routing tables, send directly to HOST"
229//usage: "\n -v Verbose"
230//usage: "\n -m Max time-to-live (max number of hops)"
231//usage: "\n -p Base UDP port number used in probes"
232//usage: "\n (default 33434)"
233//usage: "\n -q Number of probes per TTL (default 3)"
234//usage: "\n -s IP address to use as the source address"
235//usage: "\n -t Type-of-service in probe packets (default 0)"
236//usage: "\n -w Time in seconds to wait for a response (default 3)"
237//usage: "\n -g Loose source route gateway (8 max)"
238//usage:
239//usage:#define traceroute6_trivial_usage
240//usage: "[-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES]\n"
241//usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE]\n"
242//usage: " HOST [BYTES]"
243//usage:#define traceroute6_full_usage "\n\n"
244//usage: "Trace the route to HOST\n"
245//usage: "\nOptions:"
246//usage: "\n -d Set SO_DEBUG options to socket"
247//usage: "\n -n Print numeric addresses"
248//usage: "\n -r Bypass routing tables, send directly to HOST"
249//usage: "\n -v Verbose"
250//usage: "\n -m Max time-to-live (max number of hops)"
251//usage: "\n -p Base UDP port number used in probes"
252//usage: "\n (default is 33434)"
253//usage: "\n -q Number of probes per TTL (default 3)"
254//usage: "\n -s IP address to use as the source address"
255//usage: "\n -t Type-of-service in probe packets (default 0)"
256//usage: "\n -w Time in seconds to wait for a response (default 3)"
257
213#define TRACEROUTE_SO_DEBUG 0 258#define TRACEROUTE_SO_DEBUG 0
214 259
215/* TODO: undefs were uncommented - ??! we have config system for that! */ 260/* TODO: undefs were uncommented - ??! we have config system for that! */
@@ -482,7 +527,7 @@ send_probe(int seq, int ttl)
482 if (!(option_mask32 & OPT_USE_ICMP)) { 527 if (!(option_mask32 & OPT_USE_ICMP)) {
483 out = outdata; 528 out = outdata;
484 len -= sizeof(*outudp); 529 len -= sizeof(*outudp);
485 set_nport(dest_lsa, htons(port + seq)); 530 set_nport(&dest_lsa->u.sa, htons(port + seq));
486 } 531 }
487 } 532 }
488 533
@@ -1018,10 +1063,10 @@ common_traceroute_main(int op, char **argv)
1018 int probe_fd = xsocket(af, SOCK_DGRAM, 0); 1063 int probe_fd = xsocket(af, SOCK_DGRAM, 0);
1019 if (op & OPT_DEVICE) 1064 if (op & OPT_DEVICE)
1020 setsockopt_bindtodevice(probe_fd, device); 1065 setsockopt_bindtodevice(probe_fd, device);
1021 set_nport(dest_lsa, htons(1025)); 1066 set_nport(&dest_lsa->u.sa, htons(1025));
1022 /* dummy connect. makes kernel pick source IP (and port) */ 1067 /* dummy connect. makes kernel pick source IP (and port) */
1023 xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len); 1068 xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len);
1024 set_nport(dest_lsa, htons(port)); 1069 set_nport(&dest_lsa->u.sa, htons(port));
1025 1070
1026 /* read IP and port */ 1071 /* read IP and port */
1027 source_lsa = get_sock_lsa(probe_fd); 1072 source_lsa = get_sock_lsa(probe_fd);
@@ -1031,7 +1076,7 @@ common_traceroute_main(int op, char **argv)
1031 close(probe_fd); 1076 close(probe_fd);
1032 1077
1033 /* bind our sockets to this IP (but not port) */ 1078 /* bind our sockets to this IP (but not port) */
1034 set_nport(source_lsa, 0); 1079 set_nport(&source_lsa->u.sa, 0);
1035 xbind(sndsock, &source_lsa->u.sa, source_lsa->len); 1080 xbind(sndsock, &source_lsa->u.sa, source_lsa->len);
1036 xbind(rcvsock, &source_lsa->u.sa, source_lsa->len); 1081 xbind(rcvsock, &source_lsa->u.sa, source_lsa->len);
1037 1082
diff --git a/networking/tunctl.c b/networking/tunctl.c
index e17a9db64..8cb733b68 100644
--- a/networking/tunctl.c
+++ b/networking/tunctl.c
@@ -9,6 +9,25 @@
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//usage:#define tunctl_trivial_usage
14//usage: "[-f device] ([-t name] | -d name)" IF_FEATURE_TUNCTL_UG(" [-u owner] [-g group] [-b]")
15//usage:#define tunctl_full_usage "\n\n"
16//usage: "Create or delete tun interfaces\n"
17//usage: "\nOptions:"
18//usage: "\n -f name tun device (/dev/net/tun)"
19//usage: "\n -t name Create iface 'name'"
20//usage: "\n -d name Delete iface 'name'"
21//usage: IF_FEATURE_TUNCTL_UG(
22//usage: "\n -u owner Set iface owner"
23//usage: "\n -g group Set iface group"
24//usage: "\n -b Brief output"
25//usage: )
26//usage:
27//usage:#define tunctl_example_usage
28//usage: "# tunctl\n"
29//usage: "# tunctl -d tun0\n"
30
12#include <netinet/in.h> 31#include <netinet/in.h>
13#include <net/if.h> 32#include <net/if.h>
14#include <linux/if_tun.h> 33#include <linux/if_tun.h>
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 6fb48a19a..747472d0c 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -20,6 +20,17 @@
20 * along with this program; if not, write to the Free Software 20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23
24//usage:#define udhcpd_trivial_usage
25//usage: "[-fS]" IF_FEATURE_UDHCP_PORT(" [-P N]") " [CONFFILE]"
26//usage:#define udhcpd_full_usage "\n\n"
27//usage: "DHCP server\n"
28//usage: "\n -f Run in foreground"
29//usage: "\n -S Log to syslog too"
30//usage: IF_FEATURE_UDHCP_PORT(
31//usage: "\n -P N Use port N (default 67)"
32//usage: )
33
23#include <syslog.h> 34#include <syslog.h>
24#include "common.h" 35#include "common.h"
25#include "dhcpc.h" 36#include "dhcpc.h"
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c
index 86ef04a62..f82ac05b4 100644
--- a/networking/udhcp/dhcprelay.c
+++ b/networking/udhcp/dhcprelay.c
@@ -9,6 +9,12 @@
9 * Netbeat AG 9 * Netbeat AG
10 * Upstream has GPL v2 or later 10 * Upstream has GPL v2 or later
11 */ 11 */
12
13//usage:#define dhcprelay_trivial_usage
14//usage: "CLIENT_IFACE[,CLIENT_IFACE2]... SERVER_IFACE [SERVER_IP]"
15//usage:#define dhcprelay_full_usage "\n\n"
16//usage: "Relay DHCP requests between clients and server"
17
12#include "common.h" 18#include "common.h"
13 19
14#define SERVER_PORT 67 20#define SERVER_PORT 67
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index 21d62a2d2..ec07192c1 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -2,6 +2,23 @@
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//usage:#define dumpleases_trivial_usage
7//usage: "[-r|-a] [-f LEASEFILE]"
8//usage:#define dumpleases_full_usage "\n\n"
9//usage: "Display DHCP leases granted by udhcpd\n"
10//usage: "\nOptions:"
11//usage: IF_LONG_OPTS(
12//usage: "\n -f,--file=FILE Lease file"
13//usage: "\n -r,--remaining Show remaining time"
14//usage: "\n -a,--absolute Show expiration time"
15//usage: )
16//usage: IF_NOT_LONG_OPTS(
17//usage: "\n -f FILE Lease file"
18//usage: "\n -r Show remaining time"
19//usage: "\n -a Show expiration time"
20//usage: )
21
5#include "common.h" 22#include "common.h"
6#include "dhcpd.h" 23#include "dhcpd.h"
7#include "unicode.h" 24#include "unicode.h"
diff --git a/networking/vconfig.c b/networking/vconfig.c
index 13c65ad78..4fa341ac3 100644
--- a/networking/vconfig.c
+++ b/networking/vconfig.c
@@ -9,6 +9,18 @@
9 9
10/* BB_AUDIT SUSv3 N/A */ 10/* BB_AUDIT SUSv3 N/A */
11 11
12//usage:#define vconfig_trivial_usage
13//usage: "COMMAND [OPTIONS]"
14//usage:#define vconfig_full_usage "\n\n"
15//usage: "Create and remove virtual ethernet devices\n"
16//usage: "\nOptions:"
17//usage: "\n add [interface-name] [vlan_id]"
18//usage: "\n rem [vlan-name]"
19//usage: "\n set_flag [interface-name] [flag-num] [0 | 1]"
20//usage: "\n set_egress_map [vlan-name] [skb_priority] [vlan_qos]"
21//usage: "\n set_ingress_map [vlan-name] [skb_priority] [vlan_qos]"
22//usage: "\n set_name_type [name-type]"
23
12#include "libbb.h" 24#include "libbb.h"
13#include <net/if.h> 25#include <net/if.h>
14 26
diff --git a/networking/wget.c b/networking/wget.c
index 41ec7f6dc..5f6e8155f 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -344,44 +344,6 @@ static char *gethdr(FILE *fp)
344 return hdrval; 344 return hdrval;
345} 345}
346 346
347#if ENABLE_FEATURE_WGET_LONG_OPTIONS
348static char *URL_escape(const char *str)
349{
350 /* URL encode, see RFC 2396 */
351 char *dst;
352 char *res = dst = xmalloc(strlen(str) * 3 + 1);
353 unsigned char c;
354
355 while (1) {
356 c = *str++;
357 if (c == '\0'
358 /* || strchr("!&'()*-.=_~", c) - more code */
359 || c == '!'
360 || c == '&'
361 || c == '\''
362 || c == '('
363 || c == ')'
364 || c == '*'
365 || c == '-'
366 || c == '.'
367 || c == '='
368 || c == '_'
369 || c == '~'
370 || (c >= '0' && c <= '9')
371 || ((c|0x20) >= 'a' && (c|0x20) <= 'z')
372 ) {
373 *dst++ = c;
374 if (c == '\0')
375 return res;
376 } else {
377 *dst++ = '%';
378 *dst++ = bb_hexdigits_upcase[c >> 4];
379 *dst++ = bb_hexdigits_upcase[c & 0xf];
380 }
381 }
382}
383#endif
384
385static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) 347static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa)
386{ 348{
387 FILE *sfp; 349 FILE *sfp;
@@ -445,7 +407,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_
445 str = strrchr(G.wget_buf, ','); 407 str = strrchr(G.wget_buf, ',');
446 if (!str) goto pasv_error; 408 if (!str) goto pasv_error;
447 port += xatou_range(str+1, 0, 255) * 256; 409 port += xatou_range(str+1, 0, 255) * 256;
448 set_nport(lsa, htons(port)); 410 set_nport(&lsa->u.sa, htons(port));
449 411
450 *dfpp = open_socket(lsa); 412 *dfpp = open_socket(lsa);
451 413
@@ -699,6 +661,12 @@ static void download_one_url(const char *url)
699 661
700#if ENABLE_FEATURE_WGET_AUTHENTICATION 662#if ENABLE_FEATURE_WGET_AUTHENTICATION
701 if (target.user) { 663 if (target.user) {
664//TODO: URL-decode "user:password" string before base64-encoding:
665//wget http://test:my%20pass@example.com should send
666// Authorization: Basic dGVzdDpteSBwYXNz
667//which decodes to "test:my pass", instead of what we send now:
668// Authorization: Basic dGVzdDpteSUyMHBhc3M=
669//Can reuse decodeString() from httpd.c
702 fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, 670 fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6,
703 base64enc(target.user)); 671 base64enc(target.user));
704 } 672 }
@@ -716,15 +684,13 @@ static void download_one_url(const char *url)
716 fputs(G.extra_headers, sfp); 684 fputs(G.extra_headers, sfp);
717 685
718 if (option_mask32 & WGET_OPT_POST_DATA) { 686 if (option_mask32 & WGET_OPT_POST_DATA) {
719 char *estr = URL_escape(G.post_data);
720 fprintf(sfp, 687 fprintf(sfp,
721 "Content-Type: application/x-www-form-urlencoded\r\n" 688 "Content-Type: application/x-www-form-urlencoded\r\n"
722 "Content-Length: %u\r\n" 689 "Content-Length: %u\r\n"
723 "\r\n" 690 "\r\n"
724 "%s", 691 "%s",
725 (int) strlen(estr), estr 692 (int) strlen(G.post_data), G.post_data
726 ); 693 );
727 free(estr);
728 } else 694 } else
729#endif 695#endif
730 { 696 {
diff --git a/networking/zcip.c b/networking/zcip.c
index 6fa265ad4..7250fb2fd 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -23,6 +23,19 @@
23// - avoid silent script failures, especially under load... 23// - avoid silent script failures, especially under load...
24// - link status monitoring (restart on link-up; stop on link-down) 24// - link status monitoring (restart on link-up; stop on link-down)
25 25
26//usage:#define zcip_trivial_usage
27//usage: "[OPTIONS] IFACE SCRIPT"
28//usage:#define zcip_full_usage "\n\n"
29//usage: "Manage a ZeroConf IPv4 link-local address\n"
30//usage: "\nOptions:"
31//usage: "\n -f Run in foreground"
32//usage: "\n -q Quit after obtaining address"
33//usage: "\n -r 169.254.x.x Request this address first"
34//usage: "\n -v Verbose"
35//usage: "\n"
36//usage: "\nWith no -q, runs continuously monitoring for ARP conflicts,"
37//usage: "\nexits only on I/O errors (link down etc)"
38
26#include <netinet/ether.h> 39#include <netinet/ether.h>
27#include <net/ethernet.h> 40#include <net/ethernet.h>
28#include <net/if.h> 41#include <net/if.h>
diff --git a/printutils/lpd.c b/printutils/lpd.c
index 157cbe8ae..115552e0b 100644
--- a/printutils/lpd.c
+++ b/printutils/lpd.c
@@ -70,6 +70,17 @@
70 * mv -f ./"$DATAFILE" save/ 70 * mv -f ./"$DATAFILE" save/
71 */ 71 */
72 72
73//usage:#define lpd_trivial_usage
74//usage: "SPOOLDIR [HELPER [ARGS]]"
75//usage:#define lpd_full_usage "\n\n"
76//usage: "SPOOLDIR must contain (symlinks to) device nodes or directories"
77//usage: "\nwith names matching print queue names. In the first case, jobs are"
78//usage: "\nsent directly to the device. Otherwise each job is stored in queue"
79//usage: "\ndirectory and HELPER program is called. Name of file to print"
80//usage: "\nis passed in $DATAFILE variable."
81//usage: "\nExample:"
82//usage: "\n tcpsvd -E 0 515 softlimit -m 999999 lpd /var/spool ./print"
83
73#include "libbb.h" 84#include "libbb.h"
74 85
75// strip argument of bad chars 86// strip argument of bad chars
diff --git a/printutils/lpr.c b/printutils/lpr.c
index 284917926..f8ee9a11b 100644
--- a/printutils/lpr.c
+++ b/printutils/lpr.c
@@ -11,6 +11,27 @@
11 * 11 *
12 * See RFC 1179 for protocol description. 12 * See RFC 1179 for protocol description.
13 */ 13 */
14
15//usage:#define lpr_trivial_usage
16//usage: "-P queue[@host[:port]] -U USERNAME -J TITLE -Vmh [FILE]..."
17/* -C CLASS exists too, not shown.
18 * CLASS is supposed to be printed on banner page, if one is requested */
19//usage:#define lpr_full_usage "\n\n"
20//usage: "Options:"
21//usage: "\n -P lp service to connect to (else uses $PRINTER)"
22//usage: "\n -m Send mail on completion"
23//usage: "\n -h Print banner page too"
24//usage: "\n -V Verbose"
25//usage:
26//usage:#define lpq_trivial_usage
27//usage: "[-P queue[@host[:port]]] [-U USERNAME] [-d JOBID]... [-fs]"
28//usage:#define lpq_full_usage "\n\n"
29//usage: "Options:"
30//usage: "\n -P lp service to connect to (else uses $PRINTER)"
31//usage: "\n -d Delete jobs"
32//usage: "\n -f Force any waiting job to be printed"
33//usage: "\n -s Short display"
34
14#include "libbb.h" 35#include "libbb.h"
15 36
16/* 37/*
diff --git a/procps/free.c b/procps/free.c
index ad8711f8a..ca753134c 100644
--- a/procps/free.c
+++ b/procps/free.c
@@ -9,6 +9,18 @@
9 9
10/* getopt not needed */ 10/* getopt not needed */
11 11
12//usage:#define free_trivial_usage
13//usage: "" IF_DESKTOP("[-b/k/m/g]")
14//usage:#define free_full_usage "\n\n"
15//usage: "Display the amount of free and used system memory"
16//usage:
17//usage:#define free_example_usage
18//usage: "$ free\n"
19//usage: " total used free shared buffers\n"
20//usage: " Mem: 257628 248724 8904 59644 93124\n"
21//usage: " Swap: 128516 8404 120112\n"
22//usage: "Total: 386144 257128 129016\n"
23
12#include "libbb.h" 24#include "libbb.h"
13 25
14struct globals { 26struct globals {
diff --git a/procps/fuser.c b/procps/fuser.c
index a1b93d77f..7837ff883 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -7,6 +7,17 @@
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 9
10//usage:#define fuser_trivial_usage
11//usage: "[OPTIONS] FILE or PORT/PROTO"
12//usage:#define fuser_full_usage "\n\n"
13//usage: "Find processes which use FILEs or PORTs\n"
14//usage: "\nOptions:"
15//usage: "\n -m Find processes which use same fs as FILEs"
16//usage: "\n -4,-6 Search only IPv4/IPv6 space"
17//usage: "\n -s Don't display PIDs"
18//usage: "\n -k Kill found processes"
19//usage: "\n -SIGNAL Signal to send (default: KILL)"
20
10#include "libbb.h" 21#include "libbb.h"
11 22
12#define MAX_LINE 255 23#define MAX_LINE 255
diff --git a/procps/kill.c b/procps/kill.c
index 599152250..fa79ce2e7 100644
--- a/procps/kill.c
+++ b/procps/kill.c
@@ -8,6 +8,45 @@
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 10
11//usage:#define kill_trivial_usage
12//usage: "[-l] [-SIG] PID..."
13//usage:#define kill_full_usage "\n\n"
14//usage: "Send a signal (default: TERM) to given PIDs\n"
15//usage: "\nOptions:"
16//usage: "\n -l List all signal names and numbers"
17/* //usage: "\n -s SIG Yet another way of specifying SIG" */
18//usage:
19//usage:#define kill_example_usage
20//usage: "$ ps | grep apache\n"
21//usage: "252 root root S [apache]\n"
22//usage: "263 www-data www-data S [apache]\n"
23//usage: "264 www-data www-data S [apache]\n"
24//usage: "265 www-data www-data S [apache]\n"
25//usage: "266 www-data www-data S [apache]\n"
26//usage: "267 www-data www-data S [apache]\n"
27//usage: "$ kill 252\n"
28//usage:
29//usage:#define killall_trivial_usage
30//usage: "[-l] [-q] [-SIG] PROCESS_NAME..."
31//usage:#define killall_full_usage "\n\n"
32//usage: "Send a signal (default: TERM) to given processes\n"
33//usage: "\nOptions:"
34//usage: "\n -l List all signal names and numbers"
35/* //usage: "\n -s SIG Yet another way of specifying SIG" */
36//usage: "\n -q Don't complain if no processes were killed"
37//usage:
38//usage:#define killall_example_usage
39//usage: "$ killall apache\n"
40//usage:
41//usage:#define killall5_trivial_usage
42//usage: "[-l] [-SIG] [-o PID]..."
43//usage:#define killall5_full_usage "\n\n"
44//usage: "Send a signal (default: TERM) to all processes outside current session\n"
45//usage: "\nOptions:"
46//usage: "\n -l List all signal names and numbers"
47//usage: "\n -o PID Don't signal this PID"
48/* //usage: "\n -s SIG Yet another way of specifying SIG" */
49
11#include "libbb.h" 50#include "libbb.h"
12 51
13/* Note: kill_main is directly called from shell in order to implement 52/* Note: kill_main is directly called from shell in order to implement
diff --git a/procps/pgrep.c b/procps/pgrep.c
index 5d388a87d..902a3a75e 100644
--- a/procps/pgrep.c
+++ b/procps/pgrep.c
@@ -6,6 +6,35 @@
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//usage:#define pgrep_trivial_usage
11//usage: "[-flnovx] [-s SID|-P PPID|PATTERN]"
12//usage:#define pgrep_full_usage "\n\n"
13//usage: "Display process(es) selected by regex PATTERN\n"
14//usage: "\nOptions:"
15//usage: "\n -l Show command name too"
16//usage: "\n -f Match against entire command line"
17//usage: "\n -n Show the newest process only"
18//usage: "\n -o Show the oldest process only"
19//usage: "\n -v Negate the match"
20//usage: "\n -x Match whole name (not substring)"
21//usage: "\n -s Match session ID (0 for current)"
22//usage: "\n -P Match parent process ID"
23//usage:
24//usage:#define pkill_trivial_usage
25//usage: "[-l|-SIGNAL] [-fnovx] [-s SID|-P PPID|PATTERN]"
26//usage:#define pkill_full_usage "\n\n"
27//usage: "Send a signal to process(es) selected by regex PATTERN\n"
28//usage: "\nOptions:"
29//usage: "\n -l List all signals"
30//usage: "\n -f Match against entire command line"
31//usage: "\n -n Signal the newest process only"
32//usage: "\n -o Signal the oldest process only"
33//usage: "\n -v Negate the match"
34//usage: "\n -x Match whole name (not substring)"
35//usage: "\n -s Match session ID (0 for current)"
36//usage: "\n -P Match parent process ID"
37
9#include "libbb.h" 38#include "libbb.h"
10#include "xregex.h" 39#include "xregex.h"
11 40
diff --git a/procps/pidof.c b/procps/pidof.c
index 49e469ca5..e102a31c6 100644
--- a/procps/pidof.c
+++ b/procps/pidof.c
@@ -7,6 +7,34 @@
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 9
10//usage:#if (ENABLE_FEATURE_PIDOF_SINGLE || ENABLE_FEATURE_PIDOF_OMIT)
11//usage:#define pidof_trivial_usage
12//usage: "[OPTIONS] [NAME]..."
13//usage:#define USAGE_PIDOF "\n\nOptions:"
14//usage:#else
15//usage:#define pidof_trivial_usage
16//usage: "[NAME]..."
17//usage:#define USAGE_PIDOF /* none */
18//usage:#endif
19//usage:#define pidof_full_usage "\n\n"
20//usage: "List PIDs of all processes with names that match NAMEs"
21//usage: USAGE_PIDOF
22//usage: IF_FEATURE_PIDOF_SINGLE(
23//usage: "\n -s Show only one PID"
24//usage: )
25//usage: IF_FEATURE_PIDOF_OMIT(
26//usage: "\n -o PID Omit given pid"
27//usage: "\n Use %PPID to omit pid of pidof's parent"
28//usage: )
29//usage:
30//usage:#define pidof_example_usage
31//usage: "$ pidof init\n"
32//usage: "1\n"
33//usage: IF_FEATURE_PIDOF_OMIT(
34//usage: "$ pidof /bin/sh\n20351 5973 5950\n")
35//usage: IF_FEATURE_PIDOF_OMIT(
36//usage: "$ pidof /bin/sh -o %PPID\n20351 5950")
37
10#include "libbb.h" 38#include "libbb.h"
11 39
12enum { 40enum {
diff --git a/procps/ps.c b/procps/ps.c
index c54618248..41e1b1e87 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -9,6 +9,53 @@
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 11
12//usage:#if ENABLE_DESKTOP
13//usage:
14//usage:#define ps_trivial_usage
15//usage: "[-o COL1,COL2=HEADER]" IF_FEATURE_SHOW_THREADS(" [-T]")
16//usage:#define ps_full_usage "\n\n"
17//usage: "Show list of processes\n"
18//usage: "\nOptions:"
19//usage: "\n -o COL1,COL2=HEADER Select columns for display"
20//usage: IF_FEATURE_SHOW_THREADS(
21//usage: "\n -T Show threads"
22//usage: )
23//usage:
24//usage:#else /* !ENABLE_DESKTOP */
25//usage:
26//usage:#if !ENABLE_SELINUX && !ENABLE_FEATURE_PS_WIDE
27//usage:#define USAGE_PS "\nThis version of ps accepts no options"
28//usage:#else
29//usage:#define USAGE_PS "\nOptions:"
30//usage:#endif
31//usage:
32//usage:#define ps_trivial_usage
33//usage: ""
34//usage:#define ps_full_usage "\n\n"
35//usage: "Show list of processes\n"
36//usage: USAGE_PS
37//usage: IF_SELINUX(
38//usage: "\n -Z Show selinux context"
39//usage: )
40//usage: IF_FEATURE_PS_WIDE(
41//usage: "\n w Wide output"
42//usage: )
43//usage:
44//usage:#endif /* ENABLE_DESKTOP */
45//usage:
46//usage:#define ps_example_usage
47//usage: "$ ps\n"
48//usage: " PID Uid Gid State Command\n"
49//usage: " 1 root root S init\n"
50//usage: " 2 root root S [kflushd]\n"
51//usage: " 3 root root S [kupdate]\n"
52//usage: " 4 root root S [kpiod]\n"
53//usage: " 5 root root S [kswapd]\n"
54//usage: " 742 andersen andersen S [bash]\n"
55//usage: " 743 andersen andersen S -bash\n"
56//usage: " 745 root root S [getty]\n"
57//usage: " 2990 andersen andersen R ps\n"
58
12#include "libbb.h" 59#include "libbb.h"
13 60
14/* Absolute maximum on output line length */ 61/* Absolute maximum on output line length */
diff --git a/procps/pstree.c b/procps/pstree.c
index 4cd8cb458..16649cfaa 100644
--- a/procps/pstree.c
+++ b/procps/pstree.c
@@ -339,12 +339,14 @@ static void dump_by_user(PROC *current, uid_t uid)
339 dump_by_user(walk->child, uid); 339 dump_by_user(walk->child, uid);
340} 340}
341 341
342#if ENABLE_FEATURE_SHOW_THREADS
342static void handle_thread(const char *comm, pid_t pid, pid_t ppid, uid_t uid) 343static void handle_thread(const char *comm, pid_t pid, pid_t ppid, uid_t uid)
343{ 344{
344 char threadname[COMM_LEN + 2]; 345 char threadname[COMM_LEN + 2];
345 sprintf(threadname, "{%.*s}", COMM_LEN - 2, comm); 346 sprintf(threadname, "{%.*s}", COMM_LEN - 2, comm);
346 add_proc(threadname, pid, ppid, uid/*, 1*/); 347 add_proc(threadname, pid, ppid, uid/*, 1*/);
347} 348}
349#endif
348 350
349static void mread_proc(void) 351static void mread_proc(void)
350{ 352{
diff --git a/procps/renice.c b/procps/renice.c
index 59194b5f4..067c8f75a 100644
--- a/procps/renice.c
+++ b/procps/renice.c
@@ -19,6 +19,16 @@
19 * following IDs (if any). Multiple switches are allowed. 19 * following IDs (if any). Multiple switches are allowed.
20 */ 20 */
21 21
22//usage:#define renice_trivial_usage
23//usage: "{{-n INCREMENT} | PRIORITY} [[-p | -g | -u] ID...]"
24//usage:#define renice_full_usage "\n\n"
25//usage: "Change scheduling priority for a running process\n"
26//usage: "\nOptions:"
27//usage: "\n -n Adjust current nice value (smaller is faster)"
28//usage: "\n -p Process id(s) (default)"
29//usage: "\n -g Process group id(s)"
30//usage: "\n -u Process user name(s) and/or id(s)"
31
22#include "libbb.h" 32#include "libbb.h"
23#include <sys/resource.h> 33#include <sys/resource.h>
24 34
diff --git a/procps/sysctl.c b/procps/sysctl.c
index aba966e7f..f36548f87 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -11,6 +11,25 @@
11 * v1.01.1 - busybox applet aware by <solar@gentoo.org> 11 * v1.01.1 - busybox applet aware by <solar@gentoo.org>
12 */ 12 */
13 13
14//usage:#define sysctl_trivial_usage
15//usage: "[OPTIONS] [VALUE]..."
16//usage:#define sysctl_full_usage "\n\n"
17//usage: "Configure kernel parameters at runtime\n"
18//usage: "\nOptions:"
19//usage: "\n -n Don't print key names"
20//usage: "\n -e Don't warn about unknown keys"
21//usage: "\n -w Change sysctl setting"
22//usage: "\n -p FILE Load sysctl settings from FILE (default /etc/sysctl.conf)"
23//usage: "\n -a Display all values"
24//usage: "\n -A Display all values in table form"
25//usage:
26//usage:#define sysctl_example_usage
27//usage: "sysctl [-n] [-e] variable...\n"
28//usage: "sysctl [-n] [-e] -w variable=value...\n"
29//usage: "sysctl [-n] [-e] -a\n"
30//usage: "sysctl [-n] [-e] -p file (default /etc/sysctl.conf)\n"
31//usage: "sysctl [-n] [-e] -A\n"
32
14#include "libbb.h" 33#include "libbb.h"
15 34
16enum { 35enum {
diff --git a/procps/uptime.c b/procps/uptime.c
index 5c48795bf..1a7da46a3 100644
--- a/procps/uptime.c
+++ b/procps/uptime.c
@@ -15,6 +15,15 @@
15 15
16/* getopt not needed */ 16/* getopt not needed */
17 17
18//usage:#define uptime_trivial_usage
19//usage: ""
20//usage:#define uptime_full_usage "\n\n"
21//usage: "Display the time since the last boot"
22//usage:
23//usage:#define uptime_example_usage
24//usage: "$ uptime\n"
25//usage: " 1:55pm up 2:30, load average: 0.09, 0.04, 0.00\n"
26
18#include "libbb.h" 27#include "libbb.h"
19 28
20#ifndef FSHIFT 29#ifndef FSHIFT
diff --git a/procps/watch.c b/procps/watch.c
index 36f71c469..e289bf8cb 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -11,6 +11,20 @@
11/* BB_AUDIT SUSv3 N/A */ 11/* BB_AUDIT SUSv3 N/A */
12/* BB_AUDIT GNU defects -- only option -n is supported. */ 12/* BB_AUDIT GNU defects -- only option -n is supported. */
13 13
14//usage:#define watch_trivial_usage
15//usage: "[-n SEC] [-t] PROG ARGS"
16//usage:#define watch_full_usage "\n\n"
17//usage: "Run PROG periodically\n"
18//usage: "\nOptions:"
19//usage: "\n -n Loop period in seconds (default 2)"
20//usage: "\n -t Don't print header"
21//usage:
22//usage:#define watch_example_usage
23//usage: "$ watch date\n"
24//usage: "Mon Dec 17 10:31:40 GMT 2000\n"
25//usage: "Mon Dec 17 10:31:42 GMT 2000\n"
26//usage: "Mon Dec 17 10:31:44 GMT 2000"
27
14#include "libbb.h" 28#include "libbb.h"
15 29
16// procps 2.0.18: 30// procps 2.0.18:
diff --git a/runit/chpst.c b/runit/chpst.c
index dc8a26aeb..63da4797f 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -28,6 +28,70 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */ 28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
29/* Dependencies on runit_lib.c removed */ 29/* Dependencies on runit_lib.c removed */
30 30
31//usage:#define chpst_trivial_usage
32//usage: "[-vP012] [-u USER[:GRP]] [-U USER[:GRP]] [-e DIR]\n"
33//usage: " [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n"
34//usage: " [-p N] [-f BYTES] [-c BYTES] PROG ARGS"
35//usage:#define chpst_full_usage "\n\n"
36//usage: "Change the process state, run PROG\n"
37//usage: "\nOptions:"
38//usage: "\n -u USER[:GRP] Set uid and gid"
39//usage: "\n -U USER[:GRP] Set $UID and $GID in environment"
40//usage: "\n -e DIR Set environment variables as specified by files"
41//usage: "\n in DIR: file=1st_line_of_file"
42//usage: "\n -/ DIR Chroot to DIR"
43//usage: "\n -n NICE Add NICE to nice value"
44//usage: "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES"
45//usage: "\n -d BYTES Limit data segment"
46//usage: "\n -o N Limit number of open files per process"
47//usage: "\n -p N Limit number of processes per uid"
48//usage: "\n -f BYTES Limit output file sizes"
49//usage: "\n -c BYTES Limit core file size"
50//usage: "\n -v Verbose"
51//usage: "\n -P Create new process group"
52//usage: "\n -0 Close stdin"
53//usage: "\n -1 Close stdout"
54//usage: "\n -2 Close stderr"
55//usage:
56//usage:#define envdir_trivial_usage
57//usage: "DIR PROG ARGS"
58//usage:#define envdir_full_usage "\n\n"
59//usage: "Set various environment variables as specified by files\n"
60//usage: "in the directory DIR, run PROG"
61//usage:
62//usage:#define envuidgid_trivial_usage
63//usage: "USER PROG ARGS"
64//usage:#define envuidgid_full_usage "\n\n"
65//usage: "Set $UID to USER's uid and $GID to USER's gid, run PROG"
66//usage:
67//usage:#define setuidgid_trivial_usage
68//usage: "USER PROG ARGS"
69//usage:#define setuidgid_full_usage "\n\n"
70//usage: "Set uid and gid to USER's uid and gid, drop supplementary group ids,\n"
71//usage: "run PROG"
72//usage:
73//usage:#define softlimit_trivial_usage
74//usage: "[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n"
75//usage: " [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n"
76//usage: " PROG ARGS"
77//usage:#define softlimit_full_usage "\n\n"
78//usage: "Set soft resource limits, then run PROG\n"
79//usage: "\nOptions:"
80//usage: "\n -a BYTES Limit total size of all segments"
81//usage: "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES -a BYTES"
82//usage: "\n -d BYTES Limit data segment"
83//usage: "\n -s BYTES Limit stack segment"
84//usage: "\n -l BYTES Limit locked memory size"
85//usage: "\n -o N Limit number of open files per process"
86//usage: "\n -p N Limit number of processes per uid"
87//usage: "\nOptions controlling file sizes:"
88//usage: "\n -f BYTES Limit output file sizes"
89//usage: "\n -c BYTES Limit core file size"
90//usage: "\nEfficiency opts:"
91//usage: "\n -r BYTES Limit resident set size"
92//usage: "\n -t N Limit CPU time, process receives"
93//usage: "\n a SIGXCPU after N seconds"
94
31#include "libbb.h" 95#include "libbb.h"
32 96
33/* 97/*
diff --git a/runit/runsv.c b/runit/runsv.c
index e76572daa..ad8d84f74 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -28,6 +28,11 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */ 28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
29/* TODO: depends on runit_lib.c - review and reduce/eliminate */ 29/* TODO: depends on runit_lib.c - review and reduce/eliminate */
30 30
31//usage:#define runsv_trivial_usage
32//usage: "DIR"
33//usage:#define runsv_full_usage "\n\n"
34//usage: "Start and monitor a service and optionally an appendant log service"
35
31#include <sys/poll.h> 36#include <sys/poll.h>
32#include <sys/file.h> 37#include <sys/file.h>
33#include "libbb.h" 38#include "libbb.h"
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index 166664237..9495a2a4f 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -28,6 +28,13 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */ 28/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
29/* TODO: depends on runit_lib.c - review and reduce/eliminate */ 29/* TODO: depends on runit_lib.c - review and reduce/eliminate */
30 30
31//usage:#define runsvdir_trivial_usage
32//usage: "[-P] [-s SCRIPT] DIR"
33//usage:#define runsvdir_full_usage "\n\n"
34//usage: "Start a runsv process for each subdirectory. If it exits, restart it.\n"
35//usage: "\n -P Put each runsv in a new session"
36//usage: "\n -s SCRIPT Run SCRIPT <signo> after signal is processed"
37
31#include <sys/poll.h> 38#include <sys/poll.h>
32#include <sys/file.h> 39#include <sys/file.h>
33#include "libbb.h" 40#include "libbb.h"
diff --git a/runit/sv.c b/runit/sv.c
index c420a91a6..322688a36 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -153,6 +153,22 @@ Exit Codes
153/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */ 153/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
154/* TODO: depends on runit_lib.c - review and reduce/eliminate */ 154/* TODO: depends on runit_lib.c - review and reduce/eliminate */
155 155
156//usage:#define sv_trivial_usage
157//usage: "[-v] [-w SEC] CMD SERVICE_DIR..."
158//usage:#define sv_full_usage "\n\n"
159//usage: "Control services monitored by runsv supervisor.\n"
160//usage: "Commands (only first character is enough):\n"
161//usage: "\n"
162//usage: "status: query service status\n"
163//usage: "up: if service isn't running, start it. If service stops, restart it\n"
164//usage: "once: like 'up', but if service stops, don't restart it\n"
165//usage: "down: send TERM and CONT signals. If ./run exits, start ./finish\n"
166//usage: " if it exists. After it stops, don't restart service\n"
167//usage: "exit: send TERM and CONT signals to service and log service. If they exit,\n"
168//usage: " runsv exits too\n"
169//usage: "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n"
170//usage: "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service"
171
156#include <sys/poll.h> 172#include <sys/poll.h>
157#include <sys/file.h> 173#include <sys/file.h>
158#include "libbb.h" 174#include "libbb.h"
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index db30019d8..0984e7d4b 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -212,7 +212,7 @@ void find_export_symbols(char * filename)
212 * Document all external or internal functions in a file. 212 * Document all external or internal functions in a file.
213 * Call kernel-doc with following parameters: 213 * Call kernel-doc with following parameters:
214 * kernel-doc -docbook -nofunction function_name1 filename 214 * kernel-doc -docbook -nofunction function_name1 filename
215 * function names are obtained from all the the src files 215 * function names are obtained from all the src files
216 * by find_export_symbols. 216 * by find_export_symbols.
217 * intfunc uses -nofunction 217 * intfunc uses -nofunction
218 * extfunc uses -function 218 * extfunc uses -function
diff --git a/scripts/defconfig.tig b/scripts/defconfig.tig
index 3dd02983f..ab9dc4728 100644
--- a/scripts/defconfig.tig
+++ b/scripts/defconfig.tig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Busybox version: 1.19.0.git 3# Busybox version: 1.19.0.git
4# Thu Mar 22 13:52:53 2012 4# Thu Mar 22 14:00:24 2012
5# 5#
6CONFIG_HAVE_DOT_CONFIG=y 6CONFIG_HAVE_DOT_CONFIG=y
7# CONFIG_PLATFORM_POSIX is not set 7# CONFIG_PLATFORM_POSIX is not set
@@ -971,6 +971,7 @@ CONFIG_SH_MATH_SUPPORT_64=y
971CONFIG_FEATURE_SH_EXTRA_QUIET=y 971CONFIG_FEATURE_SH_EXTRA_QUIET=y
972CONFIG_FEATURE_SH_STANDALONE=y 972CONFIG_FEATURE_SH_STANDALONE=y
973CONFIG_FEATURE_SH_NOFORK=y 973CONFIG_FEATURE_SH_NOFORK=y
974# CONFIG_FEATURE_SH_HISTFILESIZE is not set
974 975
975# 976#
976# System Logging Utilities 977# System Logging Utilities
@@ -979,6 +980,7 @@ CONFIG_FEATURE_SH_NOFORK=y
979# CONFIG_FEATURE_ROTATE_LOGFILE is not set 980# CONFIG_FEATURE_ROTATE_LOGFILE is not set
980# CONFIG_FEATURE_REMOTE_LOG is not set 981# CONFIG_FEATURE_REMOTE_LOG is not set
981# CONFIG_FEATURE_SYSLOGD_DUP is not set 982# CONFIG_FEATURE_SYSLOGD_DUP is not set
983# CONFIG_FEATURE_SYSLOGD_CFG is not set
982CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0 984CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
983# CONFIG_FEATURE_IPC_SYSLOG is not set 985# CONFIG_FEATURE_IPC_SYSLOG is not set
984CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0 986CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 03831f501..e518a9008 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -1,5 +1,9 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# Note: was using sed OPTS CMD -- FILES
4# but users complain that many sed implementations
5# are misinterpreting --.
6
3test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; } 7test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
4 8
5# cd to objtree 9# cd to objtree
@@ -43,7 +47,7 @@ generate()
43} 47}
44 48
45# (Re)generate include/applets.h 49# (Re)generate include/applets.h
46s=`sed -n 's@^//applet:@@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` 50s=`sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c`
47generate \ 51generate \
48 "$srctree/include/applets.src.h" \ 52 "$srctree/include/applets.src.h" \
49 "include/applets.h" \ 53 "include/applets.h" \
@@ -55,7 +59,7 @@ generate \
55# and insert empty line before each line which doesn't start 59# and insert empty line before each line which doesn't start
56# with space or tab 60# with space or tab
57# (note: we need to use \\\\ because of ``) 61# (note: we need to use \\\\ because of ``)
58s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' -- "$srctree"/*/*.c "$srctree"/*/*/*.c` 62s=`sed -n -e 's@^//usage:\([ \t].*\)$@\1 \\\\@p' -e 's@^//usage:\([^ \t].*\)$@\n\1 \\\\@p' "$srctree"/*/*.c "$srctree"/*/*/*.c`
59generate \ 63generate \
60 "$srctree/include/usage.src.h" \ 64 "$srctree/include/usage.src.h" \
61 "include/usage.h" \ 65 "include/usage.h" \
@@ -71,7 +75,7 @@ generate \
71 if test -f "$src"; then 75 if test -f "$src"; then
72 mkdir -p -- "$d" 2>/dev/null 76 mkdir -p -- "$d" 2>/dev/null
73 77
74 s=`sed -n 's@^//kbuild:@@p' -- "$srctree/$d"/*.c` 78 s=`sed -n 's@^//kbuild:@@p' "$srctree/$d"/*.c`
75 generate \ 79 generate \
76 "${src}" "${dst}" \ 80 "${src}" "${dst}" \
77 "# DO NOT EDIT. This file is generated from Kbuild.src" \ 81 "# DO NOT EDIT. This file is generated from Kbuild.src" \
@@ -83,7 +87,7 @@ generate \
83 if test -f "$src"; then 87 if test -f "$src"; then
84 mkdir -p -- "$d" 2>/dev/null 88 mkdir -p -- "$d" 2>/dev/null
85 89
86 s=`sed -n 's@^//config:@@p' -- "$srctree/$d"/*.c` 90 s=`sed -n 's@^//config:@@p' "$srctree/$d"/*.c`
87 generate \ 91 generate \
88 "${src}" "${dst}" \ 92 "${src}" "${dst}" \
89 "# DO NOT EDIT. This file is generated from Config.src" \ 93 "# DO NOT EDIT. This file is generated from Config.src" \
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 9befa2b54..6e097889f 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -3,6 +3,8 @@
3 * Released under the terms of the GNU GPL v2.0. 3 * Released under the terms of the GNU GPL v2.0.
4 */ 4 */
5 5
6#define _XOPEN_SOURCE 700
7
6#include <ctype.h> 8#include <ctype.h>
7#include <stdlib.h> 9#include <stdlib.h>
8#include <stdio.h> 10#include <stdio.h>
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d292b46cc..d3f69f8f5 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -8,6 +8,8 @@
8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> 8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
9 */ 9 */
10 10
11#define _XOPEN_SOURCE 700
12
11#include <sys/ioctl.h> 13#include <sys/ioctl.h>
12#include <sys/wait.h> 14#include <sys/wait.h>
13#include <ctype.h> 15#include <ctype.h>
@@ -18,6 +20,7 @@
18#include <stdarg.h> 20#include <stdarg.h>
19#include <stdlib.h> 21#include <stdlib.h>
20#include <string.h> 22#include <string.h>
23#include <strings.h> /* for strcasecmp */
21#include <termios.h> 24#include <termios.h>
22#include <unistd.h> 25#include <unistd.h>
23#include <locale.h> 26#include <locale.h>
diff --git a/scripts/mkconfigs b/scripts/mkconfigs
index 7488d294e..db94fcc44 100755
--- a/scripts/mkconfigs
+++ b/scripts/mkconfigs
@@ -63,7 +63,7 @@ echo "\
63 */ 63 */
64static const char bbconfig_config_bz2[] ALIGN1 = {" 64static const char bbconfig_config_bz2[] ALIGN1 = {"
65 65
66grep '^#\? \?CONFIG_' "$config" \ 66grep -e '^# CONFIG_' -e '^CONFIG_' "$config" \
67| bzip2 -1 | dd bs=2 skip=1 2>/dev/null \ 67| bzip2 -1 | dd bs=2 skip=1 2>/dev/null \
68| od -v -t x1 \ 68| od -v -t x1 \
69| sed -e 's/^[^ ]*//' \ 69| sed -e 's/^[^ ]*//' \
diff --git a/selinux/chcon.c b/selinux/chcon.c
index e00cdda1b..8644502b5 100644
--- a/selinux/chcon.c
+++ b/selinux/chcon.c
@@ -7,6 +7,39 @@
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//usage:#define chcon_trivial_usage
12//usage: "[OPTIONS] CONTEXT FILE..."
13//usage: "\n chcon [OPTIONS] [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE..."
14//usage: IF_FEATURE_CHCON_LONG_OPTIONS(
15//usage: "\n chcon [OPTIONS] --reference=RFILE FILE..."
16//usage: )
17//usage:#define chcon_full_usage "\n\n"
18//usage: "Change the security context of each FILE to CONTEXT\n"
19//usage: IF_FEATURE_CHCON_LONG_OPTIONS(
20//usage: "\n -v,--verbose Verbose"
21//usage: "\n -c,--changes Report changes made"
22//usage: "\n -h,--no-dereference Affect symlinks instead of their targets"
23//usage: "\n -f,--silent,--quiet Suppress most error messages"
24//usage: "\n --reference=RFILE Use RFILE's group instead of using a CONTEXT value"
25//usage: "\n -u,--user=USER Set user/role/type/range in the target"
26//usage: "\n -r,--role=ROLE security context"
27//usage: "\n -t,--type=TYPE"
28//usage: "\n -l,--range=RANGE"
29//usage: "\n -R,--recursive Recurse"
30//usage: )
31//usage: IF_NOT_FEATURE_CHCON_LONG_OPTIONS(
32//usage: "\n -v Verbose"
33//usage: "\n -c Report changes made"
34//usage: "\n -h Affect symlinks instead of their targets"
35//usage: "\n -f Suppress most error messages"
36//usage: "\n -u USER Set user/role/type/range in the target security context"
37//usage: "\n -r ROLE"
38//usage: "\n -t TYPE"
39//usage: "\n -l RNG"
40//usage: "\n -R Recurse"
41//usage: )
42
10#include <getopt.h> 43#include <getopt.h>
11#include <selinux/context.h> 44#include <selinux/context.h>
12 45
diff --git a/selinux/getenforce.c b/selinux/getenforce.c
index d9d9d0f65..56611d693 100644
--- a/selinux/getenforce.c
+++ b/selinux/getenforce.c
@@ -7,6 +7,9 @@
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 9
10//usage:#define getenforce_trivial_usage NOUSAGE_STR
11//usage:#define getenforce_full_usage ""
12
10#include "libbb.h" 13#include "libbb.h"
11 14
12int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 15int getenforce_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/selinux/getsebool.c b/selinux/getsebool.c
index 924356cae..e8f0fefb0 100644
--- a/selinux/getsebool.c
+++ b/selinux/getsebool.c
@@ -7,6 +7,11 @@
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 9
10//usage:#define getsebool_trivial_usage
11//usage: "-a or getsebool boolean..."
12//usage:#define getsebool_full_usage "\n\n"
13//usage: " -a Show all selinux booleans"
14
10#include "libbb.h" 15#include "libbb.h"
11 16
12int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 17int getsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/selinux/load_policy.c b/selinux/load_policy.c
index 8fc92dbf3..ce139dbf2 100644
--- a/selinux/load_policy.c
+++ b/selinux/load_policy.c
@@ -4,6 +4,10 @@
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//usage:#define load_policy_trivial_usage NOUSAGE_STR
9//usage:#define load_policy_full_usage ""
10
7#include "libbb.h" 11#include "libbb.h"
8 12
9int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 13int load_policy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/selinux/matchpathcon.c b/selinux/matchpathcon.c
index ec49077c8..9e5728eb3 100644
--- a/selinux/matchpathcon.c
+++ b/selinux/matchpathcon.c
@@ -5,6 +5,16 @@
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//usage:#define matchpathcon_trivial_usage
10//usage: "[-n] [-N] [-f file_contexts_file] [-p prefix] [-V]"
11//usage:#define matchpathcon_full_usage "\n\n"
12//usage: " -n Don't display path"
13//usage: "\n -N Don't use translations"
14//usage: "\n -f Use alternate file_context file"
15//usage: "\n -p Use prefix to speed translations"
16//usage: "\n -V Verify file context on disk matches defaults"
17
8#include "libbb.h" 18#include "libbb.h"
9 19
10static int print_matchpathcon(char *path, int noprint) 20static int print_matchpathcon(char *path, int noprint)
diff --git a/selinux/runcon.c b/selinux/runcon.c
index 54349b25c..f0b21269f 100644
--- a/selinux/runcon.c
+++ b/selinux/runcon.c
@@ -28,6 +28,28 @@
28 * 28 *
29 * Licensed under GPLv2, see file LICENSE in this source tree. 29 * Licensed under GPLv2, see file LICENSE in this source tree.
30 */ 30 */
31
32//usage:#define runcon_trivial_usage
33//usage: "[-c] [-u USER] [-r ROLE] [-t TYPE] [-l RANGE] PROG ARGS\n"
34//usage: "runcon CONTEXT PROG ARGS"
35//usage:#define runcon_full_usage "\n\n"
36//usage: "Run PROG in a different security context\n"
37//usage: "\n CONTEXT Complete security context\n"
38//usage: IF_FEATURE_RUNCON_LONG_OPTIONS(
39//usage: "\n -c,--compute Compute process transition context before modifying"
40//usage: "\n -t,--type=TYPE Type (for same role as parent)"
41//usage: "\n -u,--user=USER User identity"
42//usage: "\n -r,--role=ROLE Role"
43//usage: "\n -l,--range=RNG Levelrange"
44//usage: )
45//usage: IF_NOT_FEATURE_RUNCON_LONG_OPTIONS(
46//usage: "\n -c Compute process transition context before modifying"
47//usage: "\n -t TYPE Type (for same role as parent)"
48//usage: "\n -u USER User identity"
49//usage: "\n -r ROLE Role"
50//usage: "\n -l RNG Levelrange"
51//usage: )
52
31#include <getopt.h> 53#include <getopt.h>
32#include <selinux/context.h> 54#include <selinux/context.h>
33#include <selinux/flask.h> 55#include <selinux/flask.h>
diff --git a/selinux/selinuxenabled.c b/selinux/selinuxenabled.c
index aa4e63f74..ce830dc22 100644
--- a/selinux/selinuxenabled.c
+++ b/selinux/selinuxenabled.c
@@ -6,6 +6,10 @@
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//usage:#define selinuxenabled_trivial_usage NOUSAGE_STR
11//usage:#define selinuxenabled_full_usage ""
12
9#include "libbb.h" 13#include "libbb.h"
10 14
11int selinuxenabled_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 15int selinuxenabled_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/selinux/sestatus.c b/selinux/sestatus.c
index aa12e806c..0bd1a0dda 100644
--- a/selinux/sestatus.c
+++ b/selinux/sestatus.c
@@ -8,6 +8,12 @@
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 10
11//usage:#define sestatus_trivial_usage
12//usage: "[-vb]"
13//usage:#define sestatus_full_usage "\n\n"
14//usage: " -v Verbose"
15//usage: "\n -b Display current state of booleans"
16
11#include "libbb.h" 17#include "libbb.h"
12 18
13extern char *selinux_mnt; 19extern char *selinux_mnt;
diff --git a/selinux/setenforce.c b/selinux/setenforce.c
index be5432147..c5bc0a5a6 100644
--- a/selinux/setenforce.c
+++ b/selinux/setenforce.c
@@ -7,6 +7,10 @@
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 9
10//usage:#define setenforce_trivial_usage
11//usage: "[Enforcing | Permissive | 1 | 0]"
12//usage:#define setenforce_full_usage ""
13
10#include "libbb.h" 14#include "libbb.h"
11 15
12/* These strings are arranged so that odd ones 16/* These strings are arranged so that odd ones
diff --git a/selinux/setfiles.c b/selinux/setfiles.c
index 989510e3d..ca3fd9361 100644
--- a/selinux/setfiles.c
+++ b/selinux/setfiles.c
@@ -4,6 +4,46 @@
4 Port to BusyBox (c) 2007 by Yuichi Nakamura <ynakam@hitachisoft.jp> 4 Port to BusyBox (c) 2007 by Yuichi Nakamura <ynakam@hitachisoft.jp>
5*/ 5*/
6 6
7//usage:#define setfiles_trivial_usage
8//usage: "[-dnpqsvW] [-e DIR]... [-o FILE] [-r alt_root_path]"
9//usage: IF_FEATURE_SETFILES_CHECK_OPTION(
10//usage: " [-c policyfile] spec_file"
11//usage: )
12//usage: " pathname"
13//usage:#define setfiles_full_usage "\n\n"
14//usage: "Reset file contexts under pathname according to spec_file\n"
15//usage: IF_FEATURE_SETFILES_CHECK_OPTION(
16//usage: "\n -c FILE Check the validity of the contexts against the specified binary policy"
17//usage: )
18//usage: "\n -d Show which specification matched each file"
19//usage: "\n -l Log changes in file labels to syslog"
20//usage: "\n -n Don't change any file labels"
21//usage: "\n -q Suppress warnings"
22//usage: "\n -r DIR Use an alternate root path"
23//usage: "\n -e DIR Exclude DIR"
24//usage: "\n -F Force reset of context to match file_context for customizable files"
25//usage: "\n -o FILE Save list of files with incorrect context"
26//usage: "\n -s Take a list of files from stdin (instead of command line)"
27//usage: "\n -v Show changes in file labels, if type or role are changing"
28//usage: "\n -vv Show changes in file labels, if type, role, or user are changing"
29//usage: "\n -W Display warnings about entries that had no matching files"
30//usage:
31//usage:#define restorecon_trivial_usage
32//usage: "[-iFnRv] [-e EXCLUDEDIR]... [-o FILE] [-f FILE]"
33//usage:#define restorecon_full_usage "\n\n"
34//usage: "Reset security contexts of files in pathname\n"
35//usage: "\n -i Ignore files that don't exist"
36//usage: "\n -f FILE File with list of files to process"
37//usage: "\n -e DIR Directory to exclude"
38//usage: "\n -R,-r Recurse"
39//usage: "\n -n Don't change any file labels"
40//usage: "\n -o FILE Save list of files with incorrect context"
41//usage: "\n -v Verbose"
42//usage: "\n -vv Show changed labels"
43//usage: "\n -F Force reset of context to match file_context"
44//usage: "\n for customizable files, or the user section,"
45//usage: "\n if it has changed"
46
7#include "libbb.h" 47#include "libbb.h"
8#if ENABLE_FEATURE_SETFILES_CHECK_OPTION 48#if ENABLE_FEATURE_SETFILES_CHECK_OPTION
9#include <sepol/sepol.h> 49#include <sepol/sepol.h>
diff --git a/selinux/setsebool.c b/selinux/setsebool.c
index a8cc00407..ec682e5c5 100644
--- a/selinux/setsebool.c
+++ b/selinux/setsebool.c
@@ -8,6 +8,11 @@
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 10
11//usage:#define setsebool_trivial_usage
12//usage: "boolean value"
13//usage:#define setsebool_full_usage "\n\n"
14//usage: "Change boolean setting"
15
11#include "libbb.h" 16#include "libbb.h"
12 17
13int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 18int setsebool_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/shell/Config.src b/shell/Config.src
index e96c21620..b31e62dda 100644
--- a/shell/Config.src
+++ b/shell/Config.src
@@ -136,4 +136,14 @@ config FEATURE_SH_NOFORK
136 This feature is relatively new. Use with care. Report bugs 136 This feature is relatively new. Use with care. Report bugs
137 to project mailing list. 137 to project mailing list.
138 138
139config FEATURE_SH_HISTFILESIZE
140 bool "Use $HISTFILESIZE"
141 default y
142 depends on HUSH || ASH
143 help
144 This option makes busybox shells to use $HISTFILESIZE variable
145 to set shell history size. Note that its max value is capped
146 by "History size" setting in library tuning section.
147
148
139endmenu 149endmenu
diff --git a/shell/ash.c b/shell/ash.c
index d12a483a3..eaaa71967 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -3658,13 +3658,18 @@ setsignal(int signo)
3658 switch (new_act) { 3658 switch (new_act) {
3659 case S_CATCH: 3659 case S_CATCH:
3660 act.sa_handler = signal_handler; 3660 act.sa_handler = signal_handler;
3661 act.sa_flags = 0; /* matters only if !DFL and !IGN */
3662 sigfillset(&act.sa_mask); /* ditto */
3663 break; 3661 break;
3664 case S_IGN: 3662 case S_IGN:
3665 act.sa_handler = SIG_IGN; 3663 act.sa_handler = SIG_IGN;
3666 break; 3664 break;
3667 } 3665 }
3666
3667 /* flags and mask matter only if !DFL and !IGN, but we do it
3668 * for all cases for more deterministic behavior:
3669 */
3670 act.sa_flags = 0;
3671 sigfillset(&act.sa_mask);
3672
3668 sigaction_set(signo, &act); 3673 sigaction_set(signo, &act);
3669 3674
3670 *t = new_act; 3675 *t = new_act;
@@ -13765,10 +13770,9 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
13765#if ENABLE_FEATURE_EDITING_SAVEHISTORY 13770#if ENABLE_FEATURE_EDITING_SAVEHISTORY
13766 if (iflag) { 13771 if (iflag) {
13767 const char *hp = lookupvar("HISTFILE"); 13772 const char *hp = lookupvar("HISTFILE");
13768 13773 if (!hp) {
13769 if (hp == NULL) {
13770 hp = lookupvar("HOME"); 13774 hp = lookupvar("HOME");
13771 if (hp != NULL) { 13775 if (hp) {
13772 char *defhp = concat_path_file(hp, ".ash_history"); 13776 char *defhp = concat_path_file(hp, ".ash_history");
13773 setvar("HISTFILE", defhp, 0); 13777 setvar("HISTFILE", defhp, 0);
13774 free(defhp); 13778 free(defhp);
@@ -13817,6 +13821,10 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
13817 const char *hp = lookupvar("HISTFILE"); 13821 const char *hp = lookupvar("HISTFILE");
13818 if (hp) 13822 if (hp)
13819 line_input_state->hist_file = hp; 13823 line_input_state->hist_file = hp;
13824# if ENABLE_FEATURE_SH_HISTFILESIZE
13825 hp = lookupvar("HISTFILESIZE");
13826 line_input_state->max_history = size_from_HISTFILESIZE(hp);
13827# endif
13820 } 13828 }
13821#endif 13829#endif
13822 state4: /* XXX ??? - why isn't this before the "if" statement */ 13830 state4: /* XXX ??? - why isn't this before the "if" statement */
diff --git a/shell/hush.c b/shell/hush.c
index e4c3a7d77..d3e957c2f 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -445,8 +445,6 @@ enum {
445/* Used for initialization: o_string foo = NULL_O_STRING; */ 445/* Used for initialization: o_string foo = NULL_O_STRING; */
446#define NULL_O_STRING { NULL } 446#define NULL_O_STRING { NULL }
447 447
448/* I can almost use ordinary FILE*. Is open_memstream() universally
449 * available? Where is it documented? */
450typedef struct in_str { 448typedef struct in_str {
451 const char *p; 449 const char *p;
452 /* eof_flag=1: last char in ->p is really an EOF */ 450 /* eof_flag=1: last char in ->p is really an EOF */
@@ -455,6 +453,7 @@ typedef struct in_str {
455#if ENABLE_HUSH_INTERACTIVE 453#if ENABLE_HUSH_INTERACTIVE
456 smallint promptmode; /* 0: PS1, 1: PS2 */ 454 smallint promptmode; /* 0: PS1, 1: PS2 */
457#endif 455#endif
456 int last_char;
458 FILE *file; 457 FILE *file;
459 int (*get) (struct in_str *) FAST_FUNC; 458 int (*get) (struct in_str *) FAST_FUNC;
460 int (*peek) (struct in_str *) FAST_FUNC; 459 int (*peek) (struct in_str *) FAST_FUNC;
@@ -1077,22 +1076,22 @@ static void die_if_script(unsigned lineno, const char *fmt, ...)
1077 xfunc_die(); 1076 xfunc_die();
1078} 1077}
1079 1078
1080static void syntax_error(unsigned lineno, const char *msg) 1079static void syntax_error(unsigned lineno UNUSED_PARAM, const char *msg)
1081{ 1080{
1082 if (msg) 1081 if (msg)
1083 die_if_script(lineno, "syntax error: %s", msg); 1082 bb_error_msg("syntax error: %s", msg);
1084 else 1083 else
1085 die_if_script(lineno, "syntax error", NULL); 1084 bb_error_msg("syntax error");
1086} 1085}
1087 1086
1088static void syntax_error_at(unsigned lineno, const char *msg) 1087static void syntax_error_at(unsigned lineno UNUSED_PARAM, const char *msg)
1089{ 1088{
1090 die_if_script(lineno, "syntax error at '%s'", msg); 1089 bb_error_msg("syntax error at '%s'", msg);
1091} 1090}
1092 1091
1093static void syntax_error_unterm_str(unsigned lineno, const char *s) 1092static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s)
1094{ 1093{
1095 die_if_script(lineno, "syntax error: unterminated %s", s); 1094 bb_error_msg("syntax error: unterminated %s", s);
1096} 1095}
1097 1096
1098static void syntax_error_unterm_ch(unsigned lineno, char ch) 1097static void syntax_error_unterm_ch(unsigned lineno, char ch)
@@ -1101,12 +1100,12 @@ static void syntax_error_unterm_ch(unsigned lineno, char ch)
1101 syntax_error_unterm_str(lineno, msg); 1100 syntax_error_unterm_str(lineno, msg);
1102} 1101}
1103 1102
1104static void syntax_error_unexpected_ch(unsigned lineno, int ch) 1103static void syntax_error_unexpected_ch(unsigned lineno UNUSED_PARAM, int ch)
1105{ 1104{
1106 char msg[2]; 1105 char msg[2];
1107 msg[0] = ch; 1106 msg[0] = ch;
1108 msg[1] = '\0'; 1107 msg[1] = '\0';
1109 die_if_script(lineno, "syntax error: unexpected %s", ch == EOF ? "EOF" : msg); 1108 bb_error_msg("syntax error: unexpected %s", ch == EOF ? "EOF" : msg);
1110} 1109}
1111 1110
1112#if HUSH_DEBUG < 2 1111#if HUSH_DEBUG < 2
@@ -1843,6 +1842,7 @@ static int FAST_FUNC static_get(struct in_str *i)
1843 int ch = *i->p; 1842 int ch = *i->p;
1844 if (ch != '\0') { 1843 if (ch != '\0') {
1845 i->p++; 1844 i->p++;
1845 i->last_char = ch;
1846 return ch; 1846 return ch;
1847 } 1847 }
1848 return EOF; 1848 return EOF;
@@ -1964,6 +1964,7 @@ static int FAST_FUNC file_get(struct in_str *i)
1964 do ch = fgetc(i->file); while (ch == '\0'); 1964 do ch = fgetc(i->file); while (ch == '\0');
1965 } 1965 }
1966 debug_printf("file_get: got '%c' %d\n", ch, ch); 1966 debug_printf("file_get: got '%c' %d\n", ch, ch);
1967 i->last_char = ch;
1967 return ch; 1968 return ch;
1968} 1969}
1969 1970
@@ -4008,7 +4009,7 @@ static int encode_string(o_string *as_string,
4008 * Scan input until EOF or end_trigger char. 4009 * Scan input until EOF or end_trigger char.
4009 * Return a list of pipes to execute, or NULL on EOF 4010 * Return a list of pipes to execute, or NULL on EOF
4010 * or if end_trigger character is met. 4011 * or if end_trigger character is met.
4011 * On syntax error, exit is shell is not interactive, 4012 * On syntax error, exit if shell is not interactive,
4012 * reset parsing machinery and start parsing anew, 4013 * reset parsing machinery and start parsing anew,
4013 * or return ERR_PTR. 4014 * or return ERR_PTR.
4014 */ 4015 */
@@ -4037,8 +4038,6 @@ static struct pipe *parse_stream(char **pstring,
4037 * here we should use blank chars as separators, not $IFS 4038 * here we should use blank chars as separators, not $IFS
4038 */ 4039 */
4039 4040
4040 reset: /* we come back here only on syntax errors in interactive shell */
4041
4042 if (MAYBE_ASSIGNMENT != 0) 4041 if (MAYBE_ASSIGNMENT != 0)
4043 dest.o_assignment = MAYBE_ASSIGNMENT; 4042 dest.o_assignment = MAYBE_ASSIGNMENT;
4044 initialize_context(&ctx); 4043 initialize_context(&ctx);
@@ -4530,22 +4529,15 @@ static struct pipe *parse_stream(char **pstring,
4530 } 4529 }
4531 IF_HAS_KEYWORDS(pctx = p2;) 4530 IF_HAS_KEYWORDS(pctx = p2;)
4532 } while (HAS_KEYWORDS && pctx); 4531 } while (HAS_KEYWORDS && pctx);
4533 /* Free text, clear all dest fields */ 4532
4534 o_free(&dest); 4533 o_free(&dest);
4535 /* If we are not in top-level parse, we return, 4534 G.last_exitcode = 1;
4536 * our caller will propagate error.
4537 */
4538 if (end_trigger != ';') {
4539#if !BB_MMU 4535#if !BB_MMU
4540 if (pstring) 4536 if (pstring)
4541 *pstring = NULL; 4537 *pstring = NULL;
4542#endif 4538#endif
4543 debug_leave(); 4539 debug_leave();
4544 return ERR_PTR; 4540 return ERR_PTR;
4545 }
4546 /* Discard cached input, force prompt */
4547 input->p = NULL;
4548 goto reset;
4549 } 4541 }
4550} 4542}
4551 4543
@@ -5550,8 +5542,24 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger)
5550 inp->promptmode = 0; /* PS1 */ 5542 inp->promptmode = 0; /* PS1 */
5551#endif 5543#endif
5552 pipe_list = parse_stream(NULL, inp, end_trigger); 5544 pipe_list = parse_stream(NULL, inp, end_trigger);
5553 if (!pipe_list) { /* EOF */ 5545 if (!pipe_list || pipe_list == ERR_PTR) { /* EOF/error */
5554 if (empty) 5546 /* If we are in "big" script
5547 * (not in `cmd` or something similar)...
5548 */
5549 if (pipe_list == ERR_PTR && end_trigger == ';') {
5550 /* Discard cached input (rest of line) */
5551 int ch = inp->last_char;
5552 while (ch != EOF && ch != '\n') {
5553 //bb_error_msg("Discarded:'%c'", ch);
5554 ch = i_getch(inp);
5555 }
5556 /* Force prompt */
5557 inp->p = NULL;
5558 /* This stream isn't empty */
5559 empty = 0;
5560 continue;
5561 }
5562 if (!pipe_list && empty)
5555 G.last_exitcode = 0; 5563 G.last_exitcode = 0;
5556 break; 5564 break;
5557 } 5565 }
@@ -7606,6 +7614,10 @@ int hush_main(int argc, char **argv)
7606 //set_local_var(xasprintf("HISTFILE=%s", ...)); 7614 //set_local_var(xasprintf("HISTFILE=%s", ...));
7607 } 7615 }
7608 } 7616 }
7617# if ENABLE_FEATURE_SH_HISTFILESIZE
7618 hp = get_local_var_value("HISTFILESIZE");
7619 G.line_input_state->max_history = size_from_HISTFILESIZE(hp);
7620# endif
7609 } 7621 }
7610# endif 7622# endif
7611#endif 7623#endif
@@ -8630,8 +8642,6 @@ static int FAST_FUNC builtin_source(char **argv)
8630#endif 8642#endif
8631 save_and_replace_G_args(&sv, argv); 8643 save_and_replace_G_args(&sv, argv);
8632 8644
8633//TODO: syntax errors in sourced file should never abort the "calling" script.
8634//Try: bash -c '. ./bad_file; echo YES'
8635 parse_and_run_file(input); 8645 parse_and_run_file(input);
8636 fclose(input); 8646 fclose(input);
8637 8647
diff --git a/shell/shell_common.c b/shell/shell_common.c
index c7b5b6122..75f4b3e54 100644
--- a/shell/shell_common.c
+++ b/shell/shell_common.c
@@ -286,6 +286,12 @@ static const struct limits limits_tbl[] = {
286#ifdef RLIMIT_LOCKS 286#ifdef RLIMIT_LOCKS
287 { RLIMIT_LOCKS, 0, 'w', "locks" }, 287 { RLIMIT_LOCKS, 0, 'w', "locks" },
288#endif 288#endif
289#ifdef RLIMIT_NICE
290 { RLIMIT_NICE, 0, 'e', "scheduling priority" },
291#endif
292#ifdef RLIMIT_RTPRIO
293 { RLIMIT_RTPRIO, 0, 'r', "real-time priority" },
294#endif
289}; 295};
290 296
291enum { 297enum {
@@ -328,6 +334,12 @@ static const char ulimit_opt_string[] = "-HSa"
328#ifdef RLIMIT_LOCKS 334#ifdef RLIMIT_LOCKS
329 "w::" 335 "w::"
330#endif 336#endif
337#ifdef RLIMIT_NICE
338 "e::"
339#endif
340#ifdef RLIMIT_RTPRIO
341 "r::"
342#endif
331 ; 343 ;
332 344
333#if ENABLE_PLATFORM_MINGW32 345#if ENABLE_PLATFORM_MINGW32
diff --git a/sysklogd/Config.src b/sysklogd/Config.src
index d62dc5f5c..b7a494eff 100644
--- a/sysklogd/Config.src
+++ b/sysklogd/Config.src
@@ -52,6 +52,13 @@ config FEATURE_SYSLOGD_DUP
52 Option -D instructs syslogd to drop consecutive messages 52 Option -D instructs syslogd to drop consecutive messages
53 which are totally the same. 53 which are totally the same.
54 54
55config FEATURE_SYSLOGD_CFG
56 bool "Support syslog.conf"
57 default y
58 depends on SYSLOGD
59 help
60 Supports restricted syslogd config. See docs/syslog.conf.txt
61
55config FEATURE_SYSLOGD_READ_BUFFER_SIZE 62config FEATURE_SYSLOGD_READ_BUFFER_SIZE
56 int "Read buffer size in bytes" 63 int "Read buffer size in bytes"
57 default 256 64 default 256
diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c
index db32065fb..3992081ca 100644
--- a/sysklogd/klogd.c
+++ b/sysklogd/klogd.c
@@ -17,6 +17,14 @@
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 19
20//usage:#define klogd_trivial_usage
21//usage: "[-c N] [-n]"
22//usage:#define klogd_full_usage "\n\n"
23//usage: "Kernel logger\n"
24//usage: "\nOptions:"
25//usage: "\n -c N Only messages with level < N are printed to console"
26//usage: "\n -n Run in foreground"
27
20#include "libbb.h" 28#include "libbb.h"
21#include <syslog.h> 29#include <syslog.h>
22 30
diff --git a/sysklogd/logger.c b/sysklogd/logger.c
index 120f6a718..0fabd97ca 100644
--- a/sysklogd/logger.c
+++ b/sysklogd/logger.c
@@ -7,6 +7,18 @@
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 9
10//usage:#define logger_trivial_usage
11//usage: "[OPTIONS] [MESSAGE]"
12//usage:#define logger_full_usage "\n\n"
13//usage: "Write MESSAGE (or stdin) to syslog\n"
14//usage: "\nOptions:"
15//usage: "\n -s Log to stderr as well as the system log"
16//usage: "\n -t TAG Log using the specified tag (defaults to user name)"
17//usage: "\n -p PRIO Priority (numeric or facility.level pair)"
18//usage:
19//usage:#define logger_example_usage
20//usage: "$ logger \"hello\"\n"
21
10/* 22/*
11 * Done in syslogd_and_logger.c: 23 * Done in syslogd_and_logger.c:
12#include "libbb.h" 24#include "libbb.h"
diff --git a/sysklogd/logread.c b/sysklogd/logread.c
index 52c97aa77..ae0b2194b 100644
--- a/sysklogd/logread.c
+++ b/sysklogd/logread.c
@@ -9,6 +9,13 @@
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 11
12//usage:#define logread_trivial_usage
13//usage: "[-f]"
14//usage:#define logread_full_usage "\n\n"
15//usage: "Show messages in syslogd's circular buffer\n"
16//usage: "\nOptions:"
17//usage: "\n -f Output data as log grows"
18
12#include "libbb.h" 19#include "libbb.h"
13#include <sys/ipc.h> 20#include <sys/ipc.h>
14#include <sys/sem.h> 21#include <sys/sem.h>
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 24cab3b6c..b6f409f41 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -13,6 +13,35 @@
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 15
16//usage:#define syslogd_trivial_usage
17//usage: "[OPTIONS]"
18//usage:#define syslogd_full_usage "\n\n"
19//usage: "System logging utility.\n"
20//usage: "This version of syslogd ignores /etc/syslog.conf\n"
21//usage: "\nOptions:"
22//usage: "\n -n Run in foreground"
23//usage: "\n -O FILE Log to given file (default:/var/log/messages)"
24//usage: "\n -l N Set local log level"
25//usage: "\n -S Smaller logging output"
26//usage: IF_FEATURE_ROTATE_LOGFILE(
27//usage: "\n -s SIZE Max size (KB) before rotate (default:200KB, 0=off)"
28//usage: "\n -b N N rotated logs to keep (default:1, max=99, 0=purge)")
29//usage: IF_FEATURE_REMOTE_LOG(
30//usage: "\n -R HOST[:PORT] Log to IP or hostname on PORT (default PORT=514/UDP)"
31//usage: "\n -L Log locally and via network (default is network only if -R)")
32//usage: IF_FEATURE_SYSLOGD_DUP(
33//usage: "\n -D Drop duplicates")
34//usage: IF_FEATURE_IPC_SYSLOG(
35//usage: "\n -C[size(KiB)] Log to shared mem buffer (read it using logread)")
36//usage: IF_FEATURE_SYSLOGD_CFG(
37//usage: "\n -f FILE Use FILE as config (default is /etc/syslog.conf)")
38/* NB: -Csize shouldn't have space (because size is optional) */
39/* //usage: "\n -m MIN Minutes between MARK lines (default:20, 0=off)" */
40//usage:
41//usage:#define syslogd_example_usage
42//usage: "$ syslogd -R masterlog:514\n"
43//usage: "$ syslogd -R 192.168.1.1:601\n"
44
16/* 45/*
17 * Done in syslogd_and_logger.c: 46 * Done in syslogd_and_logger.c:
18#include "libbb.h" 47#include "libbb.h"
@@ -66,10 +95,26 @@ typedef struct {
66} remoteHost_t; 95} remoteHost_t;
67#endif 96#endif
68 97
98typedef struct logFile_t {
99 const char *path;
100 int fd;
101#if ENABLE_FEATURE_ROTATE_LOGFILE
102 unsigned size;
103 uint8_t isRegular;
104#endif
105} logFile_t;
106
107#if ENABLE_FEATURE_SYSLOGD_CFG
108typedef struct logRule_t {
109 uint8_t enabled_facility_priomap[LOG_NFACILITIES];
110 struct logFile_t *file;
111 struct logRule_t *next;
112} logRule_t;
113#endif
114
69/* Allows us to have smaller initializer. Ugly. */ 115/* Allows us to have smaller initializer. Ugly. */
70#define GLOBALS \ 116#define GLOBALS \
71 const char *logFilePath; \ 117 logFile_t logFile; \
72 int logFD; \
73 /* interval between marks in seconds */ \ 118 /* interval between marks in seconds */ \
74 /*int markInterval;*/ \ 119 /*int markInterval;*/ \
75 /* level of messages to be logged */ \ 120 /* level of messages to be logged */ \
@@ -79,8 +124,6 @@ IF_FEATURE_ROTATE_LOGFILE( \
79 unsigned logFileSize; \ 124 unsigned logFileSize; \
80 /* number of rotated message files */ \ 125 /* number of rotated message files */ \
81 unsigned logFileRotate; \ 126 unsigned logFileRotate; \
82 unsigned curFileSize; \
83 smallint isRegular; \
84) \ 127) \
85IF_FEATURE_IPC_SYSLOG( \ 128IF_FEATURE_IPC_SYSLOG( \
86 int shmid; /* ipc shared memory id */ \ 129 int shmid; /* ipc shared memory id */ \
@@ -88,6 +131,9 @@ IF_FEATURE_IPC_SYSLOG( \
88 int shm_size; \ 131 int shm_size; \
89 struct sembuf SMwup[1]; \ 132 struct sembuf SMwup[1]; \
90 struct sembuf SMwdn[3]; \ 133 struct sembuf SMwdn[3]; \
134) \
135IF_FEATURE_SYSLOGD_CFG( \
136 logRule_t *log_rules; \
91) 137)
92 138
93struct init_globals { 139struct init_globals {
@@ -119,8 +165,10 @@ struct globals {
119}; 165};
120 166
121static const struct init_globals init_data = { 167static const struct init_globals init_data = {
122 .logFilePath = "/var/log/messages", 168 .logFile = {
123 .logFD = -1, 169 .path = "/var/log/messages",
170 .fd = -1,
171 },
124#ifdef SYSLOGD_MARK 172#ifdef SYSLOGD_MARK
125 .markInterval = 20 * 60, 173 .markInterval = 20 * 60,
126#endif 174#endif
@@ -132,7 +180,7 @@ static const struct init_globals init_data = {
132#if ENABLE_FEATURE_IPC_SYSLOG 180#if ENABLE_FEATURE_IPC_SYSLOG
133 .shmid = -1, 181 .shmid = -1,
134 .s_semid = -1, 182 .s_semid = -1,
135 .shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024), // default shm size 183 .shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024), /* default shm size */
136 .SMwup = { {1, -1, IPC_NOWAIT} }, 184 .SMwup = { {1, -1, IPC_NOWAIT} },
137 .SMwdn = { {0, 0}, {1, 0}, {1, +1} }, 185 .SMwdn = { {0, 0}, {1, 0}, {1, +1} },
138#endif 186#endif
@@ -157,6 +205,7 @@ enum {
157 IF_FEATURE_REMOTE_LOG( OPTBIT_locallog ,) // -L 205 IF_FEATURE_REMOTE_LOG( OPTBIT_locallog ,) // -L
158 IF_FEATURE_IPC_SYSLOG( OPTBIT_circularlog,) // -C 206 IF_FEATURE_IPC_SYSLOG( OPTBIT_circularlog,) // -C
159 IF_FEATURE_SYSLOGD_DUP( OPTBIT_dup ,) // -D 207 IF_FEATURE_SYSLOGD_DUP( OPTBIT_dup ,) // -D
208 IF_FEATURE_SYSLOGD_CFG( OPTBIT_cfg ,) // -f
160 209
161 OPT_mark = 1 << OPTBIT_mark , 210 OPT_mark = 1 << OPTBIT_mark ,
162 OPT_nofork = 1 << OPTBIT_nofork , 211 OPT_nofork = 1 << OPTBIT_nofork ,
@@ -169,6 +218,7 @@ enum {
169 OPT_locallog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_locallog )) + 0, 218 OPT_locallog = IF_FEATURE_REMOTE_LOG( (1 << OPTBIT_locallog )) + 0,
170 OPT_circularlog = IF_FEATURE_IPC_SYSLOG( (1 << OPTBIT_circularlog)) + 0, 219 OPT_circularlog = IF_FEATURE_IPC_SYSLOG( (1 << OPTBIT_circularlog)) + 0,
171 OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0, 220 OPT_dup = IF_FEATURE_SYSLOGD_DUP( (1 << OPTBIT_dup )) + 0,
221 OPT_cfg = IF_FEATURE_SYSLOGD_CFG( (1 << OPTBIT_cfg )) + 0,
172}; 222};
173#define OPTION_STR "m:nO:l:S" \ 223#define OPTION_STR "m:nO:l:S" \
174 IF_FEATURE_ROTATE_LOGFILE("s:" ) \ 224 IF_FEATURE_ROTATE_LOGFILE("s:" ) \
@@ -176,17 +226,195 @@ enum {
176 IF_FEATURE_REMOTE_LOG( "R:" ) \ 226 IF_FEATURE_REMOTE_LOG( "R:" ) \
177 IF_FEATURE_REMOTE_LOG( "L" ) \ 227 IF_FEATURE_REMOTE_LOG( "L" ) \
178 IF_FEATURE_IPC_SYSLOG( "C::") \ 228 IF_FEATURE_IPC_SYSLOG( "C::") \
179 IF_FEATURE_SYSLOGD_DUP( "D" ) 229 IF_FEATURE_SYSLOGD_DUP( "D" ) \
230 IF_FEATURE_SYSLOGD_CFG( "f:" )
180#define OPTION_DECL *opt_m, *opt_l \ 231#define OPTION_DECL *opt_m, *opt_l \
181 IF_FEATURE_ROTATE_LOGFILE(,*opt_s) \ 232 IF_FEATURE_ROTATE_LOGFILE(,*opt_s) \
182 IF_FEATURE_ROTATE_LOGFILE(,*opt_b) \ 233 IF_FEATURE_ROTATE_LOGFILE(,*opt_b) \
183 IF_FEATURE_IPC_SYSLOG( ,*opt_C = NULL) 234 IF_FEATURE_IPC_SYSLOG( ,*opt_C = NULL) \
184#define OPTION_PARAM &opt_m, &G.logFilePath, &opt_l \ 235 IF_FEATURE_SYSLOGD_CFG( ,*opt_f = NULL)
236#define OPTION_PARAM &opt_m, &(G.logFile.path), &opt_l \
185 IF_FEATURE_ROTATE_LOGFILE(,&opt_s) \ 237 IF_FEATURE_ROTATE_LOGFILE(,&opt_s) \
186 IF_FEATURE_ROTATE_LOGFILE(,&opt_b) \ 238 IF_FEATURE_ROTATE_LOGFILE(,&opt_b) \
187 IF_FEATURE_REMOTE_LOG( ,&remoteAddrList) \ 239 IF_FEATURE_REMOTE_LOG( ,&remoteAddrList) \
188 IF_FEATURE_IPC_SYSLOG( ,&opt_C) 240 IF_FEATURE_IPC_SYSLOG( ,&opt_C) \
241 IF_FEATURE_SYSLOGD_CFG( ,&opt_f)
242
243
244#if ENABLE_FEATURE_SYSLOGD_CFG
245static const CODE* find_by_name(char *name, const CODE* c_set)
246{
247 for (; c_set->c_name; c_set++) {
248 if (strcmp(name, c_set->c_name) == 0)
249 return c_set;
250 }
251 return NULL;
252}
253#endif
254static const CODE* find_by_val(int val, const CODE* c_set)
255{
256 for (; c_set->c_name; c_set++) {
257 if (c_set->c_val == val)
258 return c_set;
259 }
260 return NULL;
261}
262
263#if ENABLE_FEATURE_SYSLOGD_CFG
264static void parse_syslogdcfg(const char *file)
265{
266 char *t;
267 logRule_t **pp_rule;
268 /* tok[0] set of selectors */
269 /* tok[1] file name */
270 /* tok[2] has to be NULL */
271 char *tok[3];
272 parser_t *parser;
273
274 parser = config_open2(file ? file : "/etc/syslog.conf",
275 file ? xfopen_for_read : fopen_or_warn_stdin);
276 if (!parser)
277 /* didn't find default /etc/syslog.conf */
278 /* proceed as if we built busybox without config support */
279 return;
280
281 /* use ptr to ptr to avoid checking whether head was initialized */
282 pp_rule = &G.log_rules;
283 /* iterate through lines of config, skipping comments */
284 while (config_read(parser, tok, 3, 2, "# \t", PARSE_NORMAL | PARSE_MIN_DIE)) {
285 char *cur_selector;
286 logRule_t *cur_rule;
287
288 /* unexpected trailing token? */
289 if (tok[2])
290 goto cfgerr;
291
292 cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule));
293
294 cur_selector = tok[0];
295 /* iterate through selectors: "kern.info;kern.!err;..." */
296 do {
297 const CODE *code;
298 char *next_selector;
299 uint8_t negated_prio; /* "kern.!err" */
300 uint8_t single_prio; /* "kern.=err" */
301 uint32_t facmap; /* bitmap of enabled facilities */
302 uint8_t primap; /* bitmap of enabled priorities */
303 unsigned i;
304
305 next_selector = strchr(cur_selector, ';');
306 if (next_selector)
307 *next_selector++ = '\0';
308
309 t = strchr(cur_selector, '.');
310 if (!t)
311 goto cfgerr;
312 *t++ = '\0'; /* separate facility from priority */
313
314 negated_prio = 0;
315 single_prio = 0;
316 if (*t == '!') {
317 negated_prio = 1;
318 ++t;
319 }
320 if (*t == '=') {
321 single_prio = 1;
322 ++t;
323 }
324
325 /* parse priority */
326 if (*t == '*')
327 primap = 0xff; /* all 8 log levels enabled */
328 else {
329 uint8_t priority;
330 code = find_by_name(t, prioritynames);
331 if (!code)
332 goto cfgerr;
333 primap = 0;
334 priority = code->c_val;
335 if (priority == INTERNAL_NOPRI) {
336 /* ensure we take "enabled_facility_priomap[fac] &= 0" branch below */
337 negated_prio = 1;
338 } else {
339 priority = 1 << priority;
340 do {
341 primap |= priority;
342 if (single_prio)
343 break;
344 priority >>= 1;
345 } while (priority);
346 if (negated_prio)
347 primap = ~primap;
348 }
349 }
350
351 /* parse facility */
352 if (*cur_selector == '*')
353 facmap = (1<<LOG_NFACILITIES) - 1;
354 else {
355 char *next_facility;
356 facmap = 0;
357 t = cur_selector;
358 /* iterate through facilities: "kern,daemon.<priospec>" */
359 do {
360 next_facility = strchr(t, ',');
361 if (next_facility)
362 *next_facility++ = '\0';
363 code = find_by_name(t, facilitynames);
364 if (!code)
365 goto cfgerr;
366 /* "mark" is not a real facility, skip it */
367 if (code->c_val != INTERNAL_MARK)
368 facmap |= 1<<(LOG_FAC(code->c_val));
369 t = next_facility;
370 } while (t);
371 }
372
373 /* merge result with previous selectors */
374 for (i = 0; i < LOG_NFACILITIES; ++i) {
375 if (!(facmap & (1<<i)))
376 continue;
377 if (negated_prio)
378 cur_rule->enabled_facility_priomap[i] &= primap;
379 else
380 cur_rule->enabled_facility_priomap[i] |= primap;
381 }
382
383 cur_selector = next_selector;
384 } while (cur_selector);
385
386 /* check whether current file name was mentioned in previous rules or
387 * as global logfile (G.logFile).
388 */
389 if (strcmp(G.logFile.path, tok[1]) == 0) {
390 cur_rule->file = &G.logFile;
391 goto found;
392 }
393 /* temporarily use cur_rule as iterator, but *pp_rule still points
394 * to currently processing rule entry.
395 * NOTE: *pp_rule points to the current (and last in the list) rule.
396 */
397 for (cur_rule = G.log_rules; cur_rule != *pp_rule; cur_rule = cur_rule->next) {
398 if (strcmp(cur_rule->file->path, tok[1]) == 0) {
399 /* found - reuse the same file structure */
400 (*pp_rule)->file = cur_rule->file;
401 cur_rule = *pp_rule;
402 goto found;
403 }
404 }
405 cur_rule->file = xzalloc(sizeof(*cur_rule->file));
406 cur_rule->file->fd = -1;
407 cur_rule->file->path = xstrdup(tok[1]);
408 found:
409 pp_rule = &cur_rule->next;
410 }
411 config_close(parser);
412 return;
189 413
414 cfgerr:
415 bb_error_msg_and_die("error in '%s' at line %d", file, parser->lineno);
416}
417#endif
190 418
191/* circular buffer variables/structures */ 419/* circular buffer variables/structures */
192#if ENABLE_FEATURE_IPC_SYSLOG 420#if ENABLE_FEATURE_IPC_SYSLOG
@@ -231,7 +459,7 @@ static void ipcsyslog_init(void)
231 G.shbuf->size = G.shm_size - offsetof(struct shbuf_ds, data) - 1; 459 G.shbuf->size = G.shm_size - offsetof(struct shbuf_ds, data) - 1;
232 /*G.shbuf->tail = 0;*/ 460 /*G.shbuf->tail = 0;*/
233 461
234 // we'll trust the OS to set initial semval to 0 (let's hope) 462 /* we'll trust the OS to set initial semval to 0 (let's hope) */
235 G.s_semid = semget(KEY_ID, 2, IPC_CREAT | IPC_EXCL | 1023); 463 G.s_semid = semget(KEY_ID, 2, IPC_CREAT | IPC_EXCL | 1023);
236 if (G.s_semid == -1) { 464 if (G.s_semid == -1) {
237 if (errno == EEXIST) { 465 if (errno == EEXIST) {
@@ -244,9 +472,10 @@ static void ipcsyslog_init(void)
244} 472}
245 473
246/* Write message to shared mem buffer */ 474/* Write message to shared mem buffer */
247static void log_to_shmem(const char *msg, int len) 475static void log_to_shmem(const char *msg)
248{ 476{
249 int old_tail, new_tail; 477 int old_tail, new_tail;
478 int len;
250 479
251 if (semop(G.s_semid, G.SMwdn, 3) == -1) { 480 if (semop(G.s_semid, G.SMwdn, 3) == -1) {
252 bb_perror_msg_and_die("SMwdn"); 481 bb_perror_msg_and_die("SMwdn");
@@ -258,7 +487,7 @@ static void log_to_shmem(const char *msg, int len)
258 * tail's max value is (shbuf->size - 1) 487 * tail's max value is (shbuf->size - 1)
259 * Last byte of buffer is never used and remains NUL. 488 * Last byte of buffer is never used and remains NUL.
260 */ 489 */
261 len++; /* length with NUL included */ 490 len = strlen(msg) + 1; /* length with NUL included */
262 again: 491 again:
263 old_tail = G.shbuf->tail; 492 old_tail = G.shbuf->tail;
264 new_tail = old_tail + len; 493 new_tail = old_tail + len;
@@ -288,22 +517,15 @@ void ipcsyslog_init(void);
288void log_to_shmem(const char *msg); 517void log_to_shmem(const char *msg);
289#endif /* FEATURE_IPC_SYSLOG */ 518#endif /* FEATURE_IPC_SYSLOG */
290 519
291
292/* Print a message to the log file. */ 520/* Print a message to the log file. */
293static void log_locally(time_t now, char *msg) 521static void log_locally(time_t now, char *msg, logFile_t *log_file)
294{ 522{
295#ifdef SYSLOGD_WRLOCK 523#ifdef SYSLOGD_WRLOCK
296 struct flock fl; 524 struct flock fl;
297#endif 525#endif
298 int len = strlen(msg); 526 int len = strlen(msg);
299 527
300#if ENABLE_FEATURE_IPC_SYSLOG 528 if (log_file->fd >= 0) {
301 if ((option_mask32 & OPT_circularlog) && G.shbuf) {
302 log_to_shmem(msg, len);
303 return;
304 }
305#endif
306 if (G.logFD >= 0) {
307 /* Reopen log file every second. This allows admin 529 /* Reopen log file every second. This allows admin
308 * to delete the file and not worry about restarting us. 530 * to delete the file and not worry about restarting us.
309 * This costs almost nothing since it happens 531 * This costs almost nothing since it happens
@@ -313,15 +535,15 @@ static void log_locally(time_t now, char *msg)
313 now = time(NULL); 535 now = time(NULL);
314 if (G.last_log_time != now) { 536 if (G.last_log_time != now) {
315 G.last_log_time = now; 537 G.last_log_time = now;
316 close(G.logFD); 538 close(log_file->fd);
317 goto reopen; 539 goto reopen;
318 } 540 }
319 } else { 541 } else {
320 reopen: 542 reopen:
321 G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT 543 log_file->fd = open(log_file->path, O_WRONLY | O_CREAT
322 | O_NOCTTY | O_APPEND | O_NONBLOCK, 544 | O_NOCTTY | O_APPEND | O_NONBLOCK,
323 0666); 545 0666);
324 if (G.logFD < 0) { 546 if (log_file->fd < 0) {
325 /* cannot open logfile? - print to /dev/console then */ 547 /* cannot open logfile? - print to /dev/console then */
326 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK); 548 int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
327 if (fd < 0) 549 if (fd < 0)
@@ -334,9 +556,9 @@ static void log_locally(time_t now, char *msg)
334#if ENABLE_FEATURE_ROTATE_LOGFILE 556#if ENABLE_FEATURE_ROTATE_LOGFILE
335 { 557 {
336 struct stat statf; 558 struct stat statf;
337 G.isRegular = (fstat(G.logFD, &statf) == 0 && S_ISREG(statf.st_mode)); 559 log_file->isRegular = (fstat(log_file->fd, &statf) == 0 && S_ISREG(statf.st_mode));
338 /* bug (mostly harmless): can wrap around if file > 4gb */ 560 /* bug (mostly harmless): can wrap around if file > 4gb */
339 G.curFileSize = statf.st_size; 561 log_file->size = statf.st_size;
340 } 562 }
341#endif 563#endif
342 } 564 }
@@ -346,41 +568,41 @@ static void log_locally(time_t now, char *msg)
346 fl.l_start = 0; 568 fl.l_start = 0;
347 fl.l_len = 1; 569 fl.l_len = 1;
348 fl.l_type = F_WRLCK; 570 fl.l_type = F_WRLCK;
349 fcntl(G.logFD, F_SETLKW, &fl); 571 fcntl(log_file->fd, F_SETLKW, &fl);
350#endif 572#endif
351 573
352#if ENABLE_FEATURE_ROTATE_LOGFILE 574#if ENABLE_FEATURE_ROTATE_LOGFILE
353 if (G.logFileSize && G.isRegular && G.curFileSize > G.logFileSize) { 575 if (G.logFileSize && log_file->isRegular && log_file->size > G.logFileSize) {
354 if (G.logFileRotate) { /* always 0..99 */ 576 if (G.logFileRotate) { /* always 0..99 */
355 int i = strlen(G.logFilePath) + 3 + 1; 577 int i = strlen(log_file->path) + 3 + 1;
356 char oldFile[i]; 578 char oldFile[i];
357 char newFile[i]; 579 char newFile[i];
358 i = G.logFileRotate - 1; 580 i = G.logFileRotate - 1;
359 /* rename: f.8 -> f.9; f.7 -> f.8; ... */ 581 /* rename: f.8 -> f.9; f.7 -> f.8; ... */
360 while (1) { 582 while (1) {
361 sprintf(newFile, "%s.%d", G.logFilePath, i); 583 sprintf(newFile, "%s.%d", log_file->path, i);
362 if (i == 0) break; 584 if (i == 0) break;
363 sprintf(oldFile, "%s.%d", G.logFilePath, --i); 585 sprintf(oldFile, "%s.%d", log_file->path, --i);
364 /* ignore errors - file might be missing */ 586 /* ignore errors - file might be missing */
365 rename(oldFile, newFile); 587 rename(oldFile, newFile);
366 } 588 }
367 /* newFile == "f.0" now */ 589 /* newFile == "f.0" now */
368 rename(G.logFilePath, newFile); 590 rename(log_file->path, newFile);
369#ifdef SYSLOGD_WRLOCK 591#ifdef SYSLOGD_WRLOCK
370 fl.l_type = F_UNLCK; 592 fl.l_type = F_UNLCK;
371 fcntl(G.logFD, F_SETLKW, &fl); 593 fcntl(log_file->fd, F_SETLKW, &fl);
372#endif 594#endif
373 close(G.logFD); 595 close(log_file->fd);
374 goto reopen; 596 goto reopen;
375 } 597 }
376 ftruncate(G.logFD, 0); 598 ftruncate(log_file->fd, 0);
377 } 599 }
378 G.curFileSize += 600 log_file->size +=
379#endif 601#endif
380 full_write(G.logFD, msg, len); 602 full_write(log_file->fd, msg, len);
381#ifdef SYSLOGD_WRLOCK 603#ifdef SYSLOGD_WRLOCK
382 fl.l_type = F_UNLCK; 604 fl.l_type = F_UNLCK;
383 fcntl(G.logFD, F_SETLKW, &fl); 605 fcntl(log_file->fd, F_SETLKW, &fl);
384#endif 606#endif
385} 607}
386 608
@@ -388,29 +610,15 @@ static void parse_fac_prio_20(int pri, char *res20)
388{ 610{
389 const CODE *c_pri, *c_fac; 611 const CODE *c_pri, *c_fac;
390 612
391 if (pri != 0) { 613 c_fac = find_by_val(LOG_FAC(pri) << 3, facilitynames);
392 c_fac = facilitynames; 614 if (c_fac) {
393 while (c_fac->c_name) { 615 c_pri = find_by_val(LOG_PRI(pri), prioritynames);
394 if (c_fac->c_val != (LOG_FAC(pri) << 3)) { 616 if (c_pri) {
395 c_fac++; 617 snprintf(res20, 20, "%s.%s", c_fac->c_name, c_pri->c_name);
396 continue; 618 return;
397 }
398 /* facility is found, look for prio */
399 c_pri = prioritynames;
400 while (c_pri->c_name) {
401 if (c_pri->c_val != LOG_PRI(pri)) {
402 c_pri++;
403 continue;
404 }
405 snprintf(res20, 20, "%s.%s",
406 c_fac->c_name, c_pri->c_name);
407 return;
408 }
409 /* prio not found, bail out */
410 break;
411 } 619 }
412 snprintf(res20, 20, "<%d>", pri);
413 } 620 }
621 snprintf(res20, 20, "<%d>", pri);
414} 622}
415 623
416/* len parameter is used only for "is there a timestamp?" check. 624/* len parameter is used only for "is there a timestamp?" check.
@@ -444,7 +652,32 @@ static void timestamp_and_log(int pri, char *msg, int len)
444 } 652 }
445 653
446 /* Log message locally (to file or shared mem) */ 654 /* Log message locally (to file or shared mem) */
447 log_locally(now, G.printbuf); 655#if ENABLE_FEATURE_SYSLOGD_CFG
656 {
657 bool match = 0;
658 logRule_t *rule;
659 uint8_t facility = LOG_FAC(pri);
660 uint8_t prio_bit = 1 << LOG_PRI(pri);
661
662 for (rule = G.log_rules; rule; rule = rule->next) {
663 if (rule->enabled_facility_priomap[facility] & prio_bit) {
664 log_locally(now, G.printbuf, rule->file);
665 match = 1;
666 }
667 }
668 if (match)
669 return;
670 }
671#endif
672 if (LOG_PRI(pri) < G.logLevel) {
673#if ENABLE_FEATURE_IPC_SYSLOG
674 if ((option_mask32 & OPT_circularlog) && G.shbuf) {
675 log_to_shmem(msg);
676 return;
677 }
678#endif
679 log_locally(now, G.printbuf, &G.logFile);
680 }
448} 681}
449 682
450static void timestamp_and_log_internal(const char *msg) 683static void timestamp_and_log_internal(const char *msg)
@@ -489,8 +722,7 @@ static void split_escape_and_log(char *tmpbuf, int len)
489 *q = '\0'; 722 *q = '\0';
490 723
491 /* Now log it */ 724 /* Now log it */
492 if (LOG_PRI(pri) < G.logLevel) 725 timestamp_and_log(pri, G.parsebuf, q - G.parsebuf);
493 timestamp_and_log(pri, G.parsebuf, q - G.parsebuf);
494 } 726 }
495} 727}
496 728
@@ -719,10 +951,12 @@ int syslogd_main(int argc UNUSED_PARAM, char **argv)
719 if (opt_C) // -Cn 951 if (opt_C) // -Cn
720 G.shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024; 952 G.shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024;
721#endif 953#endif
722
723 /* If they have not specified remote logging, then log locally */ 954 /* If they have not specified remote logging, then log locally */
724 if (ENABLE_FEATURE_REMOTE_LOG && !(opts & OPT_remotelog)) // -R 955 if (ENABLE_FEATURE_REMOTE_LOG && !(opts & OPT_remotelog)) // -R
725 option_mask32 |= OPT_locallog; 956 option_mask32 |= OPT_locallog;
957#if ENABLE_FEATURE_SYSLOGD_CFG
958 parse_syslogdcfg(opt_f);
959#endif
726 960
727 /* Store away localhost's name before the fork */ 961 /* Store away localhost's name before the fork */
728 G.hostname = safe_gethostname(); 962 G.hostname = safe_gethostname();
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 90606bcae..bb45705a9 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -144,6 +144,7 @@ config FDISK_SUPPORT_LARGE_DISKS
144 bool "Support over 4GB disks" 144 bool "Support over 4GB disks"
145 default y 145 default y
146 depends on FDISK 146 depends on FDISK
147 depends on !LFS # with LFS no special code is needed
147 help 148 help
148 Enable this option to support large disks > 4GB. 149 Enable this option to support large disks > 4GB.
149 150
diff --git a/util-linux/acpid.c b/util-linux/acpid.c
index ce4c98ebe..c9eed2a7f 100644
--- a/util-linux/acpid.c
+++ b/util-linux/acpid.c
@@ -6,6 +6,30 @@
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//usage:#define acpid_trivial_usage
11//usage: "[-d] [-c CONFDIR] [-l LOGFILE] [-a ACTIONFILE] [-M MAPFILE] [-e PROC_EVENT_FILE] [-p PIDFILE]"
12//usage:#define acpid_full_usage "\n\n"
13//usage: "Listen to ACPI events and spawn specific helpers on event arrival\n"
14//usage: "\nOptions:"
15//usage: "\n -c DIR Config directory [/etc/acpi]"
16//usage: "\n -d Don't daemonize, (implies -f)"
17//usage: "\n -e FILE /proc event file [/proc/acpi/event]"
18//usage: "\n -f Run in foreground"
19//usage: "\n -l FILE Log file [/var/log/acpid.log]"
20//usage: "\n -p FILE Pid file [/var/run/acpid.pid]"
21//usage: "\n -a FILE Action file [/etc/acpid.conf]"
22//usage: "\n -M FILE Map file [/etc/acpi.map]"
23//usage: IF_FEATURE_ACPID_COMPAT(
24//usage: "\n\nAccept and ignore compatibility options -g -m -s -S -v"
25//usage: )
26//usage:
27//usage:#define acpid_example_usage
28//usage: "Without -e option, acpid uses all /dev/input/event* files\n"
29//usage: "# acpid\n"
30//usage: "# acpid -l /var/log/my-acpi-log\n"
31//usage: "# acpid -e /proc/acpi/event\n"
32
9#include "libbb.h" 33#include "libbb.h"
10#include <syslog.h> 34#include <syslog.h>
11#include <linux/input.h> 35#include <linux/input.h>
diff --git a/util-linux/blkid.c b/util-linux/blkid.c
index fe88fb31d..c30360c65 100644
--- a/util-linux/blkid.c
+++ b/util-linux/blkid.c
@@ -7,6 +7,11 @@
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 9
10//usage:#define blkid_trivial_usage
11//usage: ""
12//usage:#define blkid_full_usage "\n\n"
13//usage: "Print UUIDs of all filesystems"
14
10#include "libbb.h" 15#include "libbb.h"
11#include "volume_id.h" 16#include "volume_id.h"
12 17
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c
index 6e43a22f5..412bf024b 100644
--- a/util-linux/dmesg.c
+++ b/util-linux/dmesg.c
@@ -8,6 +8,16 @@
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//usage:#define dmesg_trivial_usage
13//usage: "[-c] [-n LEVEL] [-s SIZE]"
14//usage:#define dmesg_full_usage "\n\n"
15//usage: "Print or control the kernel ring buffer\n"
16//usage: "\nOptions:"
17//usage: "\n -c Clear ring buffer after printing"
18//usage: "\n -n LEVEL Set console logging level"
19//usage: "\n -s SIZE Buffer size"
20
11#include <sys/klog.h> 21#include <sys/klog.h>
12#include "libbb.h" 22#include "libbb.h"
13 23
diff --git a/util-linux/fbset.c b/util-linux/fbset.c
index 77cc1fc12..75d41b882 100644
--- a/util-linux/fbset.c
+++ b/util-linux/fbset.c
@@ -12,6 +12,21 @@
12 * Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be) 12 * Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
13 */ 13 */
14 14
15//usage:#define fbset_trivial_usage
16//usage: "[OPTIONS] [MODE]"
17//usage:#define fbset_full_usage "\n\n"
18//usage: "Show and modify frame buffer settings"
19//usage:
20//usage:#define fbset_example_usage
21//usage: "$ fbset\n"
22//usage: "mode \"1024x768-76\"\n"
23//usage: " # D: 78.653 MHz, H: 59.949 kHz, V: 75.694 Hz\n"
24//usage: " geometry 1024 768 1024 768 16\n"
25//usage: " timings 12714 128 32 16 4 128 4\n"
26//usage: " accel false\n"
27//usage: " rgba 5/11,6/5,5/0,0/0\n"
28//usage: "endmode\n"
29
15#include "libbb.h" 30#include "libbb.h"
16 31
17#define DEFAULTFBDEV FB_0 32#define DEFAULTFBDEV FB_0
diff --git a/util-linux/fdformat.c b/util-linux/fdformat.c
index 57e9c26f8..bf7098e71 100644
--- a/util-linux/fdformat.c
+++ b/util-linux/fdformat.c
@@ -5,6 +5,13 @@
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 7
8//usage:#define fdformat_trivial_usage
9//usage: "[-n] DEVICE"
10//usage:#define fdformat_full_usage "\n\n"
11//usage: "Format floppy disk\n"
12//usage: "\nOptions:"
13//usage: "\n -n Don't verify after format"
14
8#include "libbb.h" 15#include "libbb.h"
9 16
10 17
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 0b93c22cc..da03e683e 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -7,6 +7,28 @@
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 9
10/* Looks like someone forgot to add this to config system */
11//usage:#ifndef ENABLE_FEATURE_FDISK_BLKSIZE
12//usage:# define ENABLE_FEATURE_FDISK_BLKSIZE 0
13//usage:# define IF_FEATURE_FDISK_BLKSIZE(a)
14//usage:#endif
15//usage:
16//usage:#define fdisk_trivial_usage
17//usage: "[-ul" IF_FEATURE_FDISK_BLKSIZE("s") "] "
18//usage: "[-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK"
19//usage:#define fdisk_full_usage "\n\n"
20//usage: "Change partition table\n"
21//usage: "\nOptions:"
22//usage: "\n -u Start and End are in sectors (instead of cylinders)"
23//usage: "\n -l Show partition table for each DISK, then exit"
24//usage: IF_FEATURE_FDISK_BLKSIZE(
25//usage: "\n -s Show partition sizes in kb for each DISK, then exit"
26//usage: )
27//usage: "\n -b 2048 (for certain MO disks) use 2048-byte sectors"
28//usage: "\n -C CYLINDERS Set number of cylinders/heads/sectors"
29//usage: "\n -H HEADS"
30//usage: "\n -S SECTORS"
31
10#ifndef _LARGEFILE64_SOURCE 32#ifndef _LARGEFILE64_SOURCE
11/* For lseek64 */ 33/* For lseek64 */
12# define _LARGEFILE64_SOURCE 34# define _LARGEFILE64_SOURCE
diff --git a/util-linux/findfs.c b/util-linux/findfs.c
index e1ec41f1b..49e8979ac 100644
--- a/util-linux/findfs.c
+++ b/util-linux/findfs.c
@@ -8,6 +8,14 @@
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 10
11//usage:#define findfs_trivial_usage
12//usage: "LABEL=label or UUID=uuid"
13//usage:#define findfs_full_usage "\n\n"
14//usage: "Find a filesystem device based on a label or UUID"
15//usage:
16//usage:#define findfs_example_usage
17//usage: "$ findfs LABEL=MyDevice"
18
11#include "libbb.h" 19#include "libbb.h"
12#include "volume_id.h" 20#include "volume_id.h"
13 21
diff --git a/util-linux/flock.c b/util-linux/flock.c
index 77fe1f809..8fecb54d4 100644
--- a/util-linux/flock.c
+++ b/util-linux/flock.c
@@ -3,6 +3,17 @@
3 * 3 *
4 * This is free software, licensed under the GNU General Public License v2. 4 * This is free software, licensed under the GNU General Public License v2.
5 */ 5 */
6
7//usage:#define flock_trivial_usage
8//usage: "[-sxun] FD|{FILE [-c] PROG ARGS}"
9//usage:#define flock_full_usage "\n\n"
10//usage: "[Un]lock file descriptor, or lock FILE, run PROG\n"
11//usage: "\nOptions:"
12//usage: "\n -s Shared lock"
13//usage: "\n -x Exclusive lock (default)"
14//usage: "\n -u Unlock FD"
15//usage: "\n -n Fail rather than wait"
16
6#include <sys/file.h> 17#include <sys/file.h>
7#include "libbb.h" 18#include "libbb.h"
8 19
diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c
index 7ad443086..a89ae1a39 100644
--- a/util-linux/freeramdisk.c
+++ b/util-linux/freeramdisk.c
@@ -8,6 +8,20 @@
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//usage:#define freeramdisk_trivial_usage
13//usage: "DEVICE"
14//usage:#define freeramdisk_full_usage "\n\n"
15//usage: "Free all memory used by the specified ramdisk"
16//usage:
17//usage:#define freeramdisk_example_usage
18//usage: "$ freeramdisk /dev/ram2\n"
19//usage:
20//usage:#define fdflush_trivial_usage
21//usage: "DEVICE"
22//usage:#define fdflush_full_usage "\n\n"
23//usage: "Force floppy disk drive to detect disk change"
24
11#include <sys/mount.h> 25#include <sys/mount.h>
12#include "libbb.h" 26#include "libbb.h"
13 27
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index e02e05fa4..b53c97248 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -87,6 +87,19 @@
87 * enforced (but it's not much fun on a character device :-). 87 * enforced (but it's not much fun on a character device :-).
88 */ 88 */
89 89
90//usage:#define fsck_minix_trivial_usage
91//usage: "[-larvsmf] BLOCKDEV"
92//usage:#define fsck_minix_full_usage "\n\n"
93//usage: "Check MINIX filesystem\n"
94//usage: "\nOptions:"
95//usage: "\n -l List all filenames"
96//usage: "\n -r Perform interactive repairs"
97//usage: "\n -a Perform automatic repairs"
98//usage: "\n -v Verbose"
99//usage: "\n -s Output superblock information"
100//usage: "\n -m Show \"mode not cleared\" warnings"
101//usage: "\n -f Force file system check"
102
90#include <mntent.h> 103#include <mntent.h>
91#include "libbb.h" 104#include "libbb.h"
92#include "minix.h" 105#include "minix.h"
diff --git a/util-linux/getopt.c b/util-linux/getopt.c
index 7c498538f..10e1dc49b 100644
--- a/util-linux/getopt.c
+++ b/util-linux/getopt.c
@@ -31,6 +31,54 @@
31 * 31 *
32 */ 32 */
33 33
34//usage:#define getopt_trivial_usage
35//usage: "[OPTIONS]"
36//usage:#define getopt_full_usage "\n\n"
37//usage: "Options:"
38//usage: IF_LONG_OPTS(
39//usage: "\n -a,--alternative Allow long options starting with single -"
40//usage: "\n -l,--longoptions=longopts Long options to be recognized"
41//usage: "\n -n,--name=progname The name under which errors are reported"
42//usage: "\n -o,--options=optstring Short options to be recognized"
43//usage: "\n -q,--quiet Disable error reporting by getopt(3)"
44//usage: "\n -Q,--quiet-output No normal output"
45//usage: "\n -s,--shell=shell Set shell quoting conventions"
46//usage: "\n -T,--test Test for getopt(1) version"
47//usage: "\n -u,--unquoted Don't quote the output"
48//usage: )
49//usage: IF_NOT_LONG_OPTS(
50//usage: "\n -a Allow long options starting with single -"
51//usage: "\n -l longopts Long options to be recognized"
52//usage: "\n -n progname The name under which errors are reported"
53//usage: "\n -o optstring Short options to be recognized"
54//usage: "\n -q Disable error reporting by getopt(3)"
55//usage: "\n -Q No normal output"
56//usage: "\n -s shell Set shell quoting conventions"
57//usage: "\n -T Test for getopt(1) version"
58//usage: "\n -u Don't quote the output"
59//usage: )
60//usage:
61//usage:#define getopt_example_usage
62//usage: "$ cat getopt.test\n"
63//usage: "#!/bin/sh\n"
64//usage: "GETOPT=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \\\n"
65//usage: " -n 'example.busybox' -- \"$@\"`\n"
66//usage: "if [ $? != 0 ]; then exit 1; fi\n"
67//usage: "eval set -- \"$GETOPT\"\n"
68//usage: "while true; do\n"
69//usage: " case $1 in\n"
70//usage: " -a|--a-long) echo \"Option a\"; shift;;\n"
71//usage: " -b|--b-long) echo \"Option b, argument '$2'\"; shift 2;;\n"
72//usage: " -c|--c-long)\n"
73//usage: " case \"$2\" in\n"
74//usage: " \"\") echo \"Option c, no argument\"; shift 2;;\n"
75//usage: " *) echo \"Option c, argument '$2'\"; shift 2;;\n"
76//usage: " esac;;\n"
77//usage: " --) shift; break;;\n"
78//usage: " *) echo \"Internal error!\"; exit 1;;\n"
79//usage: " esac\n"
80//usage: "done\n"
81
34#include <getopt.h> 82#include <getopt.h>
35#include "libbb.h" 83#include "libbb.h"
36 84
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c
index a38fe05e7..1f5d57d74 100644
--- a/util-linux/hexdump.c
+++ b/util-linux/hexdump.c
@@ -9,6 +9,30 @@
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 11
12//usage:#define hexdump_trivial_usage
13//usage: "[-bcCdefnosvx" IF_FEATURE_HEXDUMP_REVERSE("R") "] [FILE]..."
14//usage:#define hexdump_full_usage "\n\n"
15//usage: "Display FILEs (or stdin) in a user specified format\n"
16//usage: "\nOptions:"
17//usage: "\n -b One-byte octal display"
18//usage: "\n -c One-byte character display"
19//usage: "\n -C Canonical hex+ASCII, 16 bytes per line"
20//usage: "\n -d Two-byte decimal display"
21//usage: "\n -e FORMAT_STRING"
22//usage: "\n -f FORMAT_FILE"
23//usage: "\n -n LENGTH Interpret only LENGTH bytes of input"
24//usage: "\n -o Two-byte octal display"
25//usage: "\n -s OFFSET Skip OFFSET bytes"
26//usage: "\n -v Display all input data"
27//usage: "\n -x Two-byte hexadecimal display"
28//usage: IF_FEATURE_HEXDUMP_REVERSE(
29//usage: "\n -R Reverse of 'hexdump -Cv'")
30//usage:
31//usage:#define hd_trivial_usage
32//usage: "FILE..."
33//usage:#define hd_full_usage "\n\n"
34//usage: "hd is an alias for hexdump -C"
35
12#include "libbb.h" 36#include "libbb.h"
13#include "dump.h" 37#include "dump.h"
14 38
diff --git a/util-linux/ipcrm.c b/util-linux/ipcrm.c
index e597ed637..bdd019f6f 100644
--- a/util-linux/ipcrm.c
+++ b/util-linux/ipcrm.c
@@ -8,6 +8,16 @@
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 10
11//usage:#define ipcrm_trivial_usage
12//usage: "[-MQS key] [-mqs id]"
13//usage:#define ipcrm_full_usage "\n\n"
14//usage: "Upper-case options MQS remove an object by shmkey value.\n"
15//usage: "Lower-case options remove an object by shmid value.\n"
16//usage: "\nOptions:"
17//usage: "\n -mM Remove memory segment after last detach"
18//usage: "\n -qQ Remove message queue"
19//usage: "\n -sS Remove semaphore"
20
11#include "libbb.h" 21#include "libbb.h"
12 22
13/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */ 23/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
diff --git a/util-linux/ipcs.c b/util-linux/ipcs.c
index 14df65280..33035c62e 100644
--- a/util-linux/ipcs.c
+++ b/util-linux/ipcs.c
@@ -8,6 +8,22 @@
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 10
11//usage:#define ipcs_trivial_usage
12//usage: "[[-smq] -i shmid] | [[-asmq] [-tcplu]]"
13//usage:#define ipcs_full_usage "\n\n"
14//usage: " -i Show specific resource"
15//usage: "\nResource specification:"
16//usage: "\n -m Shared memory segments"
17//usage: "\n -q Message queues"
18//usage: "\n -s Semaphore arrays"
19//usage: "\n -a All (default)"
20//usage: "\nOutput format:"
21//usage: "\n -t Time"
22//usage: "\n -c Creator"
23//usage: "\n -p Pid"
24//usage: "\n -l Limits"
25//usage: "\n -u Summary"
26
11/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */ 27/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
12/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */ 28/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
13/* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */ 29/* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 776f784f5..7e11e292d 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -7,6 +7,24 @@
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 9
10//usage:#define losetup_trivial_usage
11//usage: "[-o OFS] LOOPDEV FILE - associate loop devices\n"
12//usage: " losetup -d LOOPDEV - disassociate\n"
13//usage: " losetup [-f] - show"
14//usage:#define losetup_full_usage "\n\n"
15//usage: "Options:"
16//usage: "\n -o OFS Start OFS bytes into FILE"
17//usage: "\n -f Show first free loop device"
18//usage:
19//usage:#define losetup_notes_usage
20//usage: "No arguments will display all current associations.\n"
21//usage: "One argument (losetup /dev/loop1) will display the current association\n"
22//usage: "(if any), or disassociate it (with -d). The display shows the offset\n"
23//usage: "and filename of the file the loop device is currently bound to.\n\n"
24//usage: "Two arguments (losetup /dev/loop1 file.img) create a new association,\n"
25//usage: "with an optional offset (-o 12345). Encryption is not yet supported.\n"
26//usage: "losetup -f will show the first loop free loop device\n\n"
27
10#include "libbb.h" 28#include "libbb.h"
11 29
12int losetup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 30int losetup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/util-linux/lspci.c b/util-linux/lspci.c
index 46e93b04d..f59aec8a5 100644
--- a/util-linux/lspci.c
+++ b/util-linux/lspci.c
@@ -6,6 +6,15 @@
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//usage:#define lspci_trivial_usage
11//usage: "[-mk]"
12//usage:#define lspci_full_usage "\n\n"
13//usage: "List all PCI devices"
14//usage: "\n"
15//usage: "\n -m Parseable output"
16//usage: "\n -k Show driver"
17
9#include "libbb.h" 18#include "libbb.h"
10 19
11enum { 20enum {
diff --git a/util-linux/lsusb.c b/util-linux/lsusb.c
index 6f9b54daa..540f21ec6 100644
--- a/util-linux/lsusb.c
+++ b/util-linux/lsusb.c
@@ -6,6 +6,10 @@
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//usage:#define lsusb_trivial_usage NOUSAGE_STR
11//usage:#define lsusb_full_usage ""
12
9#include "libbb.h" 13#include "libbb.h"
10 14
11static int FAST_FUNC fileAction( 15static int FAST_FUNC fileAction(
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index a970f91f2..2f225ac0b 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -7,6 +7,41 @@
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//usage:#define mdev_trivial_usage
12//usage: "[-s]"
13//usage:#define mdev_full_usage "\n\n"
14//usage: " -s Scan /sys and populate /dev during system boot\n"
15//usage: "\n"
16//usage: "It can be run by kernel as a hotplug helper. To activate it:\n"
17//usage: " echo /sbin/mdev > /proc/sys/kernel/hotplug\n"
18//usage: IF_FEATURE_MDEV_CONF(
19//usage: "It uses /etc/mdev.conf with lines\n"
20//usage: "[-]DEVNAME UID:GID PERM"
21//usage: IF_FEATURE_MDEV_RENAME(" [>|=PATH]")
22//usage: IF_FEATURE_MDEV_EXEC(" [@|$|*PROG]")
23//usage: )
24//usage:
25//usage:#define mdev_notes_usage ""
26//usage: IF_FEATURE_MDEV_CONFIG(
27//usage: "The mdev config file contains lines that look like:\n"
28//usage: " hd[a-z][0-9]* 0:3 660\n\n"
29//usage: "That's device name (with regex match), uid:gid, and permissions.\n\n"
30//usage: IF_FEATURE_MDEV_EXEC(
31//usage: "Optionally, that can be followed (on the same line) by a special character\n"
32//usage: "and a command line to run after creating/before deleting the corresponding\n"
33//usage: "device(s). The environment variable $MDEV indicates the active device node\n"
34//usage: "(which is useful if it's a regex match). For example:\n\n"
35//usage: " hdc root:cdrom 660 *ln -s $MDEV cdrom\n\n"
36//usage: "The special characters are @ (run after creating), $ (run before deleting),\n"
37//usage: "and * (run both after creating and before deleting). The commands run in\n"
38//usage: "the /dev directory, and use system() which calls /bin/sh.\n\n"
39//usage: )
40//usage: "Config file parsing stops on the first matching line. If no config\n"
41//usage: "entry is matched, devices are created with default 0:0 660. (Make\n"
42//usage: "the last line match .* to override this.)\n\n"
43//usage: )
44
10#include "libbb.h" 45#include "libbb.h"
11#include "xregex.h" 46#include "xregex.h"
12 47
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index 871ec835e..f6ccc9c9e 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -7,6 +7,45 @@
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//usage:#define mkfs_ext2_trivial_usage
12//usage: "[-Fn] "
13/* //usage: "[-c|-l filename] " */
14//usage: "[-b BLK_SIZE] "
15/* //usage: "[-f fragment-size] [-g blocks-per-group] " */
16//usage: "[-i INODE_RATIO] [-I INODE_SIZE] "
17/* //usage: "[-j] [-J journal-options] [-N number-of-inodes] " */
18//usage: "[-m RESERVED_PERCENT] "
19/* //usage: "[-o creator-os] [-O feature[,...]] [-q] " */
20/* //usage: "[r fs-revision-level] [-E extended-options] [-v] [-F] " */
21//usage: "[-L LABEL] "
22/* //usage: "[-M last-mounted-directory] [-S] [-T filesystem-type] " */
23//usage: "BLOCKDEV [KBYTES]"
24//usage:#define mkfs_ext2_full_usage "\n\n"
25//usage: " -b BLK_SIZE Block size, bytes"
26/* //usage: "\n -c Check device for bad blocks" */
27/* //usage: "\n -E opts Set extended options" */
28/* //usage: "\n -f size Fragment size in bytes" */
29//usage: "\n -F Force"
30/* //usage: "\n -g N Number of blocks in a block group" */
31//usage: "\n -i RATIO Max number of files is filesystem_size / RATIO"
32//usage: "\n -I BYTES Inode size (min 128)"
33/* //usage: "\n -j Create a journal (ext3)" */
34/* //usage: "\n -J opts Set journal options (size/device)" */
35/* //usage: "\n -l file Read bad blocks list from file" */
36//usage: "\n -L LBL Volume label"
37//usage: "\n -m PERCENT Percent of blocks to reserve for admin"
38/* //usage: "\n -M dir Set last mounted directory" */
39//usage: "\n -n Dry run"
40/* //usage: "\n -N N Number of inodes to create" */
41/* //usage: "\n -o os Set the 'creator os' field" */
42/* //usage: "\n -O features Dir_index/filetype/has_journal/journal_dev/sparse_super" */
43/* //usage: "\n -q Quiet" */
44/* //usage: "\n -r rev Set filesystem revision" */
45/* //usage: "\n -S Write superblock and group descriptors only" */
46/* //usage: "\n -T fs-type Set usage type (news/largefile/largefile4)" */
47/* //usage: "\n -v Verbose" */
48
10#include "libbb.h" 49#include "libbb.h"
11#include <linux/fs.h> 50#include <linux/fs.h>
12#include <linux/ext2_fs.h> 51#include <linux/ext2_fs.h>
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 95499ba17..a8bc4b80d 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -63,6 +63,17 @@
63 * removed getopt based parser and added a hand rolled one. 63 * removed getopt based parser and added a hand rolled one.
64 */ 64 */
65 65
66//usage:#define mkfs_minix_trivial_usage
67//usage: "[-c | -l FILE] [-nXX] [-iXX] BLOCKDEV [KBYTES]"
68//usage:#define mkfs_minix_full_usage "\n\n"
69//usage: "Make a MINIX filesystem\n"
70//usage: "\nOptions:"
71//usage: "\n -c Check device for bad blocks"
72//usage: "\n -n [14|30] Maximum length of filenames"
73//usage: "\n -i INODES Number of inodes for the filesystem"
74//usage: "\n -l FILE Read bad blocks list from FILE"
75//usage: "\n -v Make version 2 filesystem"
76
66#include "libbb.h" 77#include "libbb.h"
67#include <mntent.h> 78#include <mntent.h>
68 79
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c
index 00ce8f1d1..463ae1e2a 100644
--- a/util-linux/mkfs_reiser.c
+++ b/util-linux/mkfs_reiser.c
@@ -6,6 +6,15 @@
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//usage:#define mkfs_reiser_trivial_usage
11//usage: "[-f] [-l LABEL] BLOCKDEV [4K-BLOCKS]"
12//usage:#define mkfs_reiser_full_usage "\n\n"
13//usage: "Make a ReiserFS V3 filesystem\n"
14//usage: "\nOptions:"
15//usage: "\n -f Force"
16//usage: "\n -l LBL Volume label"
17
9#include "libbb.h" 18#include "libbb.h"
10#include <linux/fs.h> 19#include <linux/fs.h>
11 20
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index bb5b59c66..e83ae7510 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -7,6 +7,23 @@
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//usage:#define mkfs_vfat_trivial_usage
12//usage: "[-v] [-n LABEL] BLOCKDEV [KBYTES]"
13/* Accepted but ignored:
14 "[-c] [-C] [-I] [-l bad-block-file] [-b backup-boot-sector] "
15 "[-m boot-msg-file] [-i volume-id] "
16 "[-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs] "
17 "[-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors] "
18*/
19//usage:#define mkfs_vfat_full_usage "\n\n"
20//usage: "Make a FAT32 filesystem\n"
21//usage: "\nOptions:"
22/* //usage: "\n -c Check device for bad blocks" */
23//usage: "\n -v Verbose"
24/* //usage: "\n -I Allow to use entire disk device (e.g. /dev/hda)" */
25//usage: "\n -n LBL Volume label"
26
10#include "libbb.h" 27#include "libbb.h"
11 28
12#include <linux/hdreg.h> /* HDIO_GETGEO */ 29#include <linux/hdreg.h> /* HDIO_GETGEO */
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c
index 2e9662b2b..ef6932c6c 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -5,6 +5,14 @@
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//usage:#define mkswap_trivial_usage
10//usage: "[-L LBL] BLOCKDEV [KBYTES]"
11//usage:#define mkswap_full_usage "\n\n"
12//usage: "Prepare BLOCKDEV to be used as swap partition\n"
13//usage: "\nOptions:"
14//usage: "\n -L LBL Label"
15
8#include "libbb.h" 16#include "libbb.h"
9 17
10#if ENABLE_SELINUX 18#if ENABLE_SELINUX
diff --git a/util-linux/more.c b/util-linux/more.c
index 7160b8b00..efceb71ec 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -14,6 +14,14 @@
14 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 14 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
15 */ 15 */
16 16
17//usage:#define more_trivial_usage
18//usage: "[FILE]..."
19//usage:#define more_full_usage "\n\n"
20//usage: "View FILE (or stdin) one screenful at a time"
21//usage:
22//usage:#define more_example_usage
23//usage: "$ dmesg | more\n"
24
17#include "libbb.h" 25#include "libbb.h"
18 26
19/* Support for FEATURE_USE_TERMIOS */ 27/* Support for FEATURE_USE_TERMIOS */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 722d0be92..3e2ba1fab 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -16,6 +16,66 @@
16// singlemount() can loop through /etc/filesystems for fstype detection. 16// singlemount() can loop through /etc/filesystems for fstype detection.
17// mount_it_now() does the actual mount. 17// mount_it_now() does the actual mount.
18// 18//
19
20//usage:#define mount_trivial_usage
21//usage: "[OPTIONS] [-o OPTS] DEVICE NODE"
22//usage:#define mount_full_usage "\n\n"
23//usage: "Mount a filesystem. Filesystem autodetection requires /proc.\n"
24//usage: "\nOptions:"
25//usage: "\n -a Mount all filesystems in fstab"
26//usage: IF_FEATURE_MOUNT_FAKE(
27//usage: IF_FEATURE_MTAB_SUPPORT(
28//usage: "\n -f Update /etc/mtab, but don't mount"
29//usage: )
30//usage: IF_NOT_FEATURE_MTAB_SUPPORT(
31//usage: "\n -f Dry run"
32//usage: )
33//usage: )
34//usage: IF_FEATURE_MOUNT_HELPERS(
35//usage: "\n -i Don't run mount helper"
36//usage: )
37//usage: IF_FEATURE_MTAB_SUPPORT(
38//usage: "\n -n Don't update /etc/mtab"
39//usage: )
40//usage: "\n -r Read-only mount"
41//usage: "\n -w Read-write mount (default)"
42//usage: "\n -t FSTYPE Filesystem type"
43//usage: "\n -O OPT Mount only filesystems with option OPT (-a only)"
44//usage: "\n-o OPT:"
45//usage: IF_FEATURE_MOUNT_LOOP(
46//usage: "\n loop Ignored (loop devices are autodetected)"
47//usage: )
48//usage: IF_FEATURE_MOUNT_FLAGS(
49//usage: "\n [a]sync Writes are [a]synchronous"
50//usage: "\n [no]atime Disable/enable updates to inode access times"
51//usage: "\n [no]diratime Disable/enable atime updates to directories"
52//usage: "\n [no]relatime Disable/enable atime updates relative to modification time"
53//usage: "\n [no]dev (Dis)allow use of special device files"
54//usage: "\n [no]exec (Dis)allow use of executable files"
55//usage: "\n [no]suid (Dis)allow set-user-id-root programs"
56//usage: "\n [r]shared Convert [recursively] to a shared subtree"
57//usage: "\n [r]slave Convert [recursively] to a slave subtree"
58//usage: "\n [r]private Convert [recursively] to a private subtree"
59//usage: "\n [un]bindable Make mount point [un]able to be bind mounted"
60//usage: "\n [r]bind Bind a file or directory [recursively] to another location"
61//usage: "\n move Relocate an existing mount point"
62//usage: )
63//usage: "\n remount Remount a mounted filesystem, changing flags"
64//usage: "\n ro/rw Same as -r/-w"
65//usage: "\n"
66//usage: "\nThere are filesystem-specific -o flags."
67//usage:
68//usage:#define mount_example_usage
69//usage: "$ mount\n"
70//usage: "/dev/hda3 on / type minix (rw)\n"
71//usage: "proc on /proc type proc (rw)\n"
72//usage: "devpts on /dev/pts type devpts (rw)\n"
73//usage: "$ mount /dev/fd0 /mnt -t msdos -o ro\n"
74//usage: "$ mount /tmp/diskimage /opt -t ext2 -o loop\n"
75//usage: "$ mount cd_image.iso mydir\n"
76//usage:#define mount_notes_usage
77//usage: "Returns 0 for success, number of failed mounts for -a, or errno for one mount."
78
19#include <mntent.h> 79#include <mntent.h>
20#include <syslog.h> 80#include <syslog.h>
21#include <sys/mount.h> 81#include <sys/mount.h>
diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c
index ac52a7aed..83f01fabd 100644
--- a/util-linux/pivot_root.c
+++ b/util-linux/pivot_root.c
@@ -8,6 +8,13 @@
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//usage:#define pivot_root_trivial_usage
13//usage: "NEW_ROOT PUT_OLD"
14//usage:#define pivot_root_full_usage "\n\n"
15//usage: "Move the current root file system to PUT_OLD and make NEW_ROOT\n"
16//usage: "the new root file system"
17
11#include "libbb.h" 18#include "libbb.h"
12 19
13extern int pivot_root(const char * new_root,const char * put_old); 20extern int pivot_root(const char * new_root,const char * put_old);
diff --git a/util-linux/rdate.c b/util-linux/rdate.c
index 2c3de74bc..628df0da7 100644
--- a/util-linux/rdate.c
+++ b/util-linux/rdate.c
@@ -8,6 +8,14 @@
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 10
11//usage:#define rdate_trivial_usage
12//usage: "[-sp] HOST"
13//usage:#define rdate_full_usage "\n\n"
14//usage: "Get and possibly set the system date and time from a remote HOST\n"
15//usage: "\nOptions:"
16//usage: "\n -s Set the system date and time (default)"
17//usage: "\n -p Print the date and time"
18
11#include "libbb.h" 19#include "libbb.h"
12 20
13enum { RFC_868_BIAS = 2208988800UL }; 21enum { RFC_868_BIAS = 2208988800UL };
diff --git a/util-linux/rdev.c b/util-linux/rdev.c
index 2fbb4d377..1212f841e 100644
--- a/util-linux/rdev.c
+++ b/util-linux/rdev.c
@@ -9,6 +9,15 @@
9 * 9 *
10 */ 10 */
11 11
12//usage:#define rdev_trivial_usage
13//usage: ""
14//usage:#define rdev_full_usage "\n\n"
15//usage: "Print the device node associated with the filesystem mounted at '/'"
16//usage:
17//usage:#define rdev_example_usage
18//usage: "$ rdev\n"
19//usage: "/dev/mtdblock9 /\n"
20
12#include "libbb.h" 21#include "libbb.h"
13 22
14int rdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 23int rdev_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/util-linux/readprofile.c b/util-linux/readprofile.c
index f8a6e0cd0..7b7aa7c9f 100644
--- a/util-linux/readprofile.c
+++ b/util-linux/readprofile.c
@@ -32,6 +32,21 @@
32 * Paul Mundt <lethal@linux-sh.org>. 32 * Paul Mundt <lethal@linux-sh.org>.
33 */ 33 */
34 34
35//usage:#define readprofile_trivial_usage
36//usage: "[OPTIONS]"
37//usage:#define readprofile_full_usage "\n\n"
38//usage: "Options:"
39//usage: "\n -m mapfile (Default: /boot/System.map)"
40//usage: "\n -p profile (Default: /proc/profile)"
41//usage: "\n -M NUM Set the profiling multiplier to NUM"
42//usage: "\n -i Print only info about the sampling step"
43//usage: "\n -v Verbose"
44//usage: "\n -a Print all symbols, even if count is 0"
45//usage: "\n -b Print individual histogram-bin counts"
46//usage: "\n -s Print individual counters within functions"
47//usage: "\n -r Reset all the counters (root only)"
48//usage: "\n -n Disable byte order auto-detection"
49
35#include "libbb.h" 50#include "libbb.h"
36#include <sys/utsname.h> 51#include <sys/utsname.h>
37 52
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c
index 06ed7eafc..735a29822 100644
--- a/util-linux/rtcwake.c
+++ b/util-linux/rtcwake.c
@@ -23,6 +23,29 @@
23 * That flag should not be needed on systems with adjtime support. 23 * That flag should not be needed on systems with adjtime support.
24 */ 24 */
25 25
26//usage:#define rtcwake_trivial_usage
27//usage: "[-a | -l | -u] [-d DEV] [-m MODE] [-s SEC | -t TIME]"
28//usage:#define rtcwake_full_usage "\n\n"
29//usage: "Enter a system sleep state until specified wakeup time\n"
30//usage: IF_LONG_OPTS(
31//usage: "\n -a,--auto Read clock mode from adjtime"
32//usage: "\n -l,--local Clock is set to local time"
33//usage: "\n -u,--utc Clock is set to UTC time"
34//usage: "\n -d,--device=DEV Specify the RTC device"
35//usage: "\n -m,--mode=MODE Set the sleep state (default: standby)"
36//usage: "\n -s,--seconds=SEC Set the timeout in SEC seconds from now"
37//usage: "\n -t,--time=TIME Set the timeout to TIME seconds from epoch"
38//usage: )
39//usage: IF_NOT_LONG_OPTS(
40//usage: "\n -a Read clock mode from adjtime"
41//usage: "\n -l Clock is set to local time"
42//usage: "\n -u Clock is set to UTC time"
43//usage: "\n -d DEV Specify the RTC device"
44//usage: "\n -m MODE Set the sleep state (default: standby)"
45//usage: "\n -s SEC Set the timeout in SEC seconds from now"
46//usage: "\n -t TIME Set the timeout to TIME seconds from epoch"
47//usage: )
48
26#include "libbb.h" 49#include "libbb.h"
27#include "rtc_.h" 50#include "rtc_.h"
28 51
diff --git a/util-linux/script.c b/util-linux/script.c
index 47efc4526..26f16ebf5 100644
--- a/util-linux/script.c
+++ b/util-linux/script.c
@@ -10,6 +10,19 @@
10 * 10 *
11 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 11 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
12 */ 12 */
13
14//usage:#define script_trivial_usage
15//usage: "[-afq" IF_SCRIPTREPLAY("t") "] [-c PROG] [OUTFILE]"
16//usage:#define script_full_usage "\n\n"
17//usage: "Options:"
18//usage: "\n -a Append output"
19//usage: "\n -c PROG Run PROG, not shell"
20//usage: "\n -f Flush output after each write"
21//usage: "\n -q Quiet"
22//usage: IF_SCRIPTREPLAY(
23//usage: "\n -t Send timing to stderr"
24//usage: )
25
13#include "libbb.h" 26#include "libbb.h"
14 27
15int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28int script_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/util-linux/scriptreplay.c b/util-linux/scriptreplay.c
index 6eaba43fa..382f56d9a 100644
--- a/util-linux/scriptreplay.c
+++ b/util-linux/scriptreplay.c
@@ -7,6 +7,12 @@
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 */ 9 */
10
11//usage:#define scriptreplay_trivial_usage
12//usage: "timingfile [typescript [divisor]]"
13//usage:#define scriptreplay_full_usage "\n\n"
14//usage: "Play back typescripts, using timing information"
15
10#include "libbb.h" 16#include "libbb.h"
11 17
12int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 18int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
diff --git a/util-linux/setarch.c b/util-linux/setarch.c
index 7d5dc247c..7b9421af1 100644
--- a/util-linux/setarch.c
+++ b/util-linux/setarch.c
@@ -5,7 +5,20 @@
5 * Copyright 2002 Andi Kleen, SuSE Labs. 5 * Copyright 2002 Andi Kleen, SuSE Labs.
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//usage:#define setarch_trivial_usage
11//usage: "personality PROG ARGS"
12//usage:#define setarch_full_usage "\n\n"
13//usage: "Personality may be:\n"
14//usage: " linux32 Set 32bit uname emulation\n"
15//usage: " linux64 Set 64bit uname emulation"
16//usage:
17//usage:#define linux32_trivial_usage NOUSAGE_STR
18//usage:#define linux32_full_usage ""
19//usage:
20//usage:#define linux64_trivial_usage NOUSAGE_STR
21//usage:#define linux64_full_usage ""
9 22
10#include <sys/personality.h> 23#include <sys/personality.h>
11 24
diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c
index e2c060f30..b7cf69833 100644
--- a/util-linux/swaponoff.c
+++ b/util-linux/swaponoff.c
@@ -7,6 +7,23 @@
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 9
10//usage:#define swapon_trivial_usage
11//usage: "[-a]" IF_FEATURE_SWAPON_PRI(" [-p PRI]") " [DEVICE]"
12//usage:#define swapon_full_usage "\n\n"
13//usage: "Start swapping on DEVICE\n"
14//usage: "\nOptions:"
15//usage: "\n -a Start swapping on all swap devices"
16//usage: IF_FEATURE_SWAPON_PRI(
17//usage: "\n -p PRI Set swap device priority"
18//usage: )
19//usage:
20//usage:#define swapoff_trivial_usage
21//usage: "[-a] [DEVICE]"
22//usage:#define swapoff_full_usage "\n\n"
23//usage: "Stop swapping on DEVICE\n"
24//usage: "\nOptions:"
25//usage: "\n -a Stop swapping on all swap devices"
26
10#include "libbb.h" 27#include "libbb.h"
11#include <mntent.h> 28#include <mntent.h>
12#include <sys/swap.h> 29#include <sys/swap.h>
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index d471437fd..7794de18d 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -5,6 +5,16 @@
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//usage:#define switch_root_trivial_usage
10//usage: "[-c /dev/console] NEW_ROOT NEW_INIT [ARGS]"
11//usage:#define switch_root_full_usage "\n\n"
12//usage: "Free initramfs and switch to another root fs:\n"
13//usage: "chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,\n"
14//usage: "execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.\n"
15//usage: "\nOptions:"
16//usage: "\n -c DEV Reopen stdio to DEV after switch"
17
8#include <sys/vfs.h> 18#include <sys/vfs.h>
9#include <sys/mount.h> 19#include <sys/mount.h>
10#include "libbb.h" 20#include "libbb.h"
diff --git a/util-linux/umount.c b/util-linux/umount.c
index 5597d9eba..1e576ca4e 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -7,6 +7,28 @@
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//usage:#define umount_trivial_usage
12//usage: "[OPTIONS] FILESYSTEM|DIRECTORY"
13//usage:#define umount_full_usage "\n\n"
14//usage: "Unmount file systems\n"
15//usage: "\nOptions:"
16//usage: IF_FEATURE_UMOUNT_ALL(
17//usage: "\n -a Unmount all file systems" IF_FEATURE_MTAB_SUPPORT(" in /etc/mtab")
18//usage: )
19//usage: IF_FEATURE_MTAB_SUPPORT(
20//usage: "\n -n Don't erase /etc/mtab entries"
21//usage: )
22//usage: "\n -r Try to remount devices as read-only if mount is busy"
23//usage: "\n -l Lazy umount (detach filesystem)"
24//usage: "\n -f Force umount (i.e., unreachable NFS server)"
25//usage: IF_FEATURE_MOUNT_LOOP(
26//usage: "\n -d Free loop device if it has been used"
27//usage: )
28//usage:
29//usage:#define umount_example_usage
30//usage: "$ umount /dev/hdc1\n"
31
10#include <mntent.h> 32#include <mntent.h>
11#include <sys/mount.h> 33#include <sys/mount.h>
12#include "libbb.h" 34#include "libbb.h"