aboutsummaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-11-10 14:29:11 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2019-11-15 23:37:40 +0100
commit7bb0691475702654868c7560eae02cf9cee61155 (patch)
treecbc40a71dd9e24c3dc312568f4ac605497b98ac6 /board
parentf3546d4e7cab1ff164f49b719c351a9013b1f91f (diff)
downloadbuildroot-7bb0691475702654868c7560eae02cf9cee61155.tar.gz
buildroot-7bb0691475702654868c7560eae02cf9cee61155.tar.bz2
DEVELOPERS: add Carlo Caione for jailhouse
The jailhouse package was added in commit ee4990721c14c624c99295598fde29e395647fb9 by Carlo Caione, but no entry in the DEVELOPERS file was added. Let's fix this to ensure we have a registered maintainer for the Jailhouse package. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Cc: Carlo Caione <ccaione@baylibre.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Diffstat (limited to 'board')
0 files changed, 0 insertions, 0 deletions
> -rw-r--r--TODO21
-rw-r--r--TODO_config_nommu3
-rw-r--r--applets/usage.c5
-rw-r--r--archival/Config.in7
-rw-r--r--archival/cpio.c241
-rw-r--r--archival/dpkg.c127
-rw-r--r--archival/gzip.c68
-rw-r--r--archival/libunarchive/decompress_unzip.c5
-rw-r--r--archival/libunarchive/get_header_tar.c73
-rw-r--r--archival/libunarchive/header_verbose_list.c4
-rw-r--r--archival/tar.c9
-rw-r--r--console-tools/loadfont.c2
-rw-r--r--coreutils/Config.in16
-rw-r--r--coreutils/Kbuild3
-rw-r--r--coreutils/cksum.c7
-rw-r--r--coreutils/cp.c50
-rw-r--r--coreutils/dd.c1
-rw-r--r--coreutils/df.c18
-rw-r--r--coreutils/du.c82
-rw-r--r--coreutils/env.c18
-rw-r--r--coreutils/expand.c120
-rw-r--r--coreutils/expr.c23
-rw-r--r--coreutils/head.c8
-rw-r--r--coreutils/id.c14
-rw-r--r--coreutils/length.c3
-rw-r--r--coreutils/libcoreutils/coreutils.h10
-rw-r--r--coreutils/ls.c549
-rw-r--r--coreutils/md5_sha1_sum.c35
-rw-r--r--coreutils/printenv.c6
-rw-r--r--coreutils/printf.c118
-rw-r--r--coreutils/readlink.c33
-rw-r--r--coreutils/rm.c5
-rw-r--r--coreutils/seq.c23
-rw-r--r--coreutils/stat.c27
-rw-r--r--coreutils/tee.c1
-rw-r--r--coreutils/test.c13
-rw-r--r--coreutils/touch.c20
-rw-r--r--coreutils/tr.c297
-rw-r--r--coreutils/tty.c2
-rw-r--r--coreutils/uname.c123
-rw-r--r--coreutils/uniq.c2
-rw-r--r--coreutils/who.c1
-rw-r--r--coreutils/whoami.c2
-rw-r--r--docs/busybox.net/FAQ.html2
-rw-r--r--docs/busybox.net/download.html2
-rw-r--r--docs/busybox.net/header.html4
-rw-r--r--docs/busybox.net/images/busybox2.pngbin71850 -> 0 bytes-rw-r--r--docs/busybox.net/lists.html4
-rw-r--r--docs/busybox.net/news.html304
-rw-r--r--docs/busybox.net/oldnews.html42
-rw-r--r--docs/busybox.net/products.html3
-rw-r--r--docs/busybox.net/subversion.html4
-rw-r--r--docs/busybox.net/svnindex.css92
-rw-r--r--docs/busybox.net/svnindex.xsl108
-rw-r--r--docs/logging_and_backgrounding.txt96
-rw-r--r--e2fsprogs/e2fs_defs.h6
-rw-r--r--e2fsprogs/e2fs_lib.c3
-rw-r--r--e2fsprogs/e2fs_lib.h8
-rw-r--r--e2fsprogs/fsck.c5
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/blkid.h7
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/blkidP.h7
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/devname.c4
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/list.h4
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/probe.c4
-rw-r--r--e2fsprogs/old_e2fsprogs/blkid/probe.h17
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsbb.h6
-rw-r--r--e2fsprogs/old_e2fsprogs/e2fsck.c38
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/bb_inode.c4
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_fs.h7
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2_io.h8
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/ext2fs.h7
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/kernel-jbd.h7
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/kernel-list.h4
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/mkjournal.c2
-rw-r--r--e2fsprogs/old_e2fsprogs/ext2fs/res_gdt.c4
-rw-r--r--e2fsprogs/old_e2fsprogs/fsck.c5
-rw-r--r--e2fsprogs/old_e2fsprogs/mke2fs.c3
-rw-r--r--e2fsprogs/old_e2fsprogs/tune2fs.c5
-rw-r--r--e2fsprogs/old_e2fsprogs/util.c5
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/gen_uuid.c2
-rw-r--r--e2fsprogs/old_e2fsprogs/uuid/uuid.h5
-rw-r--r--editors/awk.c47
-rw-r--r--editors/diff.c16
-rw-r--r--editors/vi.c157
-rwxr-xr-xexamples/depmod.pl76
-rw-r--r--findutils/find.c22
-rw-r--r--findutils/grep.c21
-rw-r--r--include/applets.h14
-rw-r--r--include/busybox.h14
-rw-r--r--include/dump.h8
-rw-r--r--include/grp_.h17
-rw-r--r--include/libbb.h142
-rw-r--r--include/platform.h77
-rw-r--r--include/pwd_.h12
-rw-r--r--include/rtc_.h47
-rw-r--r--include/shadow_.h8
-rw-r--r--include/unarchive.h12
-rw-r--r--include/usage.h429
-rw-r--r--include/xatonum.h8
-rw-r--r--include/xregex.h12
-rw-r--r--init/Config.in5
-rw-r--r--init/halt.c16
-rw-r--r--init/init.c866
-rw-r--r--init/mesg.c2
-rw-r--r--libbb/Kbuild12
-rw-r--r--libbb/appletlib.c6
-rw-r--r--libbb/bb_askpass.c14
-rw-r--r--libbb/bb_pwd.c123
-rw-r--r--libbb/correct_password.c2
-rw-r--r--libbb/crc32.c2
-rw-r--r--libbb/create_icmp6_socket.c2
-rw-r--r--libbb/create_icmp_socket.c2
-rw-r--r--libbb/crypt_make_salt.c45
-rw-r--r--libbb/die_if_bad_username.c2
-rw-r--r--libbb/dump.c12
-rw-r--r--libbb/fgets_str.c26
-rw-r--r--libbb/find_mount_point.c22
-rw-r--r--libbb/find_pid_by_name.c13
-rw-r--r--libbb/getopt32.c12
-rw-r--r--libbb/human_readable.c2
-rw-r--r--libbb/inet_common.c2
-rw-r--r--libbb/info_msg.c26
-rw-r--r--libbb/inode_hash.c2
-rw-r--r--libbb/lineedit.c150
-rw-r--r--libbb/llist.c64
-rw-r--r--libbb/match_fstype.c36
-rw-r--r--libbb/md5.c561
-rw-r--r--libbb/md5prime.c460
-rw-r--r--libbb/parse_config.c1
-rw-r--r--libbb/procps.c12
-rw-r--r--libbb/pw_encrypt.c84
-rw-r--r--libbb/pw_encrypt_des.c72
-rw-r--r--libbb/pw_encrypt_md5.c569
-rw-r--r--libbb/pw_encrypt_sha.c286
-rw-r--r--libbb/read.c10
-rw-r--r--libbb/rtc.c2
-rw-r--r--libbb/selinux_common.c2
-rw-r--r--libbb/sha1.c491
-rw-r--r--libbb/signals.c2
-rw-r--r--libbb/simplify_path.c32
-rw-r--r--libbb/speed_table.c1
-rw-r--r--libbb/update_passwd.c167
-rw-r--r--libbb/vfork_daemon_rexec.c19
-rw-r--r--libbb/wfopen.c2
-rw-r--r--libbb/write.c5
-rw-r--r--libbb/xatonum_template.c4
-rw-r--r--libbb/xconnect.c34
-rw-r--r--libbb/xfuncs.c19
-rw-r--r--libbb/xfuncs_printf.c29
-rw-r--r--libbb/xgetcwd.c4
-rw-r--r--libbb/xreadlink.c12
-rw-r--r--loginutils/Config.in23
-rw-r--r--loginutils/addgroup.c78
-rw-r--r--loginutils/adduser.c52
-rw-r--r--loginutils/chpasswd.c5
-rw-r--r--loginutils/cryptpw.c137
-rw-r--r--loginutils/deluser.c133
-rw-r--r--loginutils/getty.c24
-rw-r--r--loginutils/login.c126
-rw-r--r--loginutils/passwd.c23
-rw-r--r--loginutils/su.c6
-rw-r--r--loginutils/sulogin.c4
-rw-r--r--loginutils/vlock.c7
-rw-r--r--mailutils/Config.in16
-rw-r--r--mailutils/mail.c62
-rw-r--r--mailutils/popmaildir.c52
-rw-r--r--mailutils/sendmail.c347
-rw-r--r--miscutils/Config.in74
-rw-r--r--miscutils/Kbuild3
-rw-r--r--miscutils/chat.c97
-rw-r--r--miscutils/crond.c28
-rw-r--r--miscutils/crontab.c14
-rw-r--r--miscutils/fbsplash.c62
-rw-r--r--miscutils/flash_eraseall.c194
-rw-r--r--miscutils/hdparm.c4
-rw-r--r--miscutils/inotifyd.c90
-rw-r--r--miscutils/ionice.c99
-rw-r--r--miscutils/less.c4
-rw-r--r--miscutils/man.c103
-rw-r--r--miscutils/mountpoint.c80
-rw-r--r--miscutils/setsid.c3
-rw-r--r--miscutils/strings.c9
-rw-r--r--miscutils/time.c4
-rw-r--r--miscutils/timeout.c115
-rw-r--r--miscutils/watchdog.c9
-rw-r--r--modutils/Config.in39
-rw-r--r--modutils/depmod.c44
-rw-r--r--modutils/insmod.c12
-rw-r--r--modutils/modprobe-small.c4
-rw-r--r--modutils/modprobe.c454
-rw-r--r--modutils/modutils-24.c375
-rw-r--r--modutils/modutils.c30
-rw-r--r--modutils/modutils.h37
-rw-r--r--modutils/rmmod.c14
-rw-r--r--networking/Config.in60
-rw-r--r--networking/Kbuild2
-rw-r--r--networking/arp.c72
-rw-r--r--networking/arping.c25
-rw-r--r--networking/brctl.c18
-rw-r--r--networking/dnsd.c570
-rw-r--r--networking/ether-wake.c4
-rw-r--r--networking/ftpd.c1351
-rw-r--r--networking/httpd.c535
-rw-r--r--networking/ifconfig.c2
-rw-r--r--networking/ifenslave.c5
-rw-r--r--networking/ifupdown.c24
-rw-r--r--networking/inetd.c4
-rw-r--r--networking/interface.c182
-rw-r--r--networking/isrv.h8
-rw-r--r--networking/isrv_identd.c2
-rw-r--r--networking/libiproute/ip_common.h14
-rw-r--r--networking/libiproute/ipaddress.c11
-rw-r--r--networking/libiproute/iplink.c17
-rw-r--r--networking/libiproute/iproute.c9
-rw-r--r--networking/libiproute/iprule.c8
-rw-r--r--networking/libiproute/iptunnel.c36
-rw-r--r--networking/libiproute/libnetlink.c4
-rw-r--r--networking/libiproute/libnetlink.h15
-rw-r--r--networking/libiproute/ll_addr.c38
-rw-r--r--networking/libiproute/ll_map.c4
-rw-r--r--networking/libiproute/ll_map.h14
-rw-r--r--networking/libiproute/ll_proto.c10
-rw-r--r--networking/libiproute/rt_names.h14
-rw-r--r--networking/libiproute/rtm_map.h14
-rw-r--r--networking/libiproute/utils.c149
-rw-r--r--networking/libiproute/utils.h36
-rw-r--r--networking/nameif.c6
-rw-r--r--networking/nslookup.c42
-rw-r--r--networking/route.c2
-rw-r--r--networking/tc.c8
-rw-r--r--networking/tcpudp.c3
-rw-r--r--networking/tcpudp_perhost.h8
-rw-r--r--networking/telnet.c233
-rw-r--r--networking/telnetd.c122
-rw-r--r--networking/telnetd.ctrlSQ.patch175
-rw-r--r--networking/tftp.c30
-rw-r--r--networking/traceroute.c897
-rw-r--r--networking/tunctl.c139
-rw-r--r--networking/udhcp/arpping.c2
-rw-r--r--networking/udhcp/common.h13
-rw-r--r--networking/udhcp/dhcpc.c36
-rw-r--r--networking/udhcp/dhcpc.h13
-rw-r--r--networking/udhcp/dhcpd.c50
-rw-r--r--networking/udhcp/dhcpd.h57
-rw-r--r--networking/udhcp/dhcprelay.c135
-rw-r--r--networking/udhcp/dumpleases.c67
-rw-r--r--networking/udhcp/files.c138
-rw-r--r--networking/udhcp/leases.c100
-rw-r--r--networking/udhcp/options.c103
-rw-r--r--networking/udhcp/options.h135
-rw-r--r--networking/udhcp/packet.c6
-rw-r--r--networking/udhcp/script.c80
-rw-r--r--networking/udhcp/serverpacket.c75
-rw-r--r--networking/udhcp/socket.c4
-rw-r--r--networking/udhcp/static_leases.c68
-rw-r--r--networking/vconfig.c13
-rw-r--r--networking/wget.c93
-rw-r--r--networking/zcip.c5
-rw-r--r--printutils/lpr.c2
-rw-r--r--procps/fuser.c5
-rw-r--r--procps/kill.c57
-rw-r--r--procps/nmeter.c1
-rw-r--r--procps/pidof.c10
-rw-r--r--procps/sysctl.c396
-rw-r--r--procps/top.c24
-rw-r--r--runit/runit_lib.h8
-rw-r--r--runit/runsv.c25
-rw-r--r--runit/runsvdir.c18
-rw-r--r--runit/sv.c4
-rw-r--r--runit/svlogd.c8
-rw-r--r--scripts/defconfig49
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/util.c8
-rwxr-xr-xscripts/objsizes2
-rwxr-xr-xscripts/randomtest15
-rwxr-xr-xscripts/trylink5
-rw-r--r--selinux/chcon.c2
-rw-r--r--selinux/getenforce.c1
-rw-r--r--selinux/getsebool.c1
-rw-r--r--selinux/load_policy.c2
-rw-r--r--selinux/matchpathcon.c1
-rw-r--r--selinux/runcon.c2
-rw-r--r--selinux/selinuxenabled.c1
-rw-r--r--selinux/sestatus.c7
-rw-r--r--selinux/setenforce.c1
-rw-r--r--selinux/setsebool.c2
-rw-r--r--shell/Config.in88
-rw-r--r--shell/Kbuild3
-rw-r--r--shell/ash.c1538
-rw-r--r--shell/ash_doc.txt91
-rw-r--r--shell/ash_test/ash-misc/last_amp.right2
-rwxr-xr-xshell/ash_test/ash-misc/last_amp.tests8
-rw-r--r--shell/hush.c7223
-rw-r--r--[-rwxr-xr-x]shell/hush_leaktool.sh6
-rw-r--r--shell/hush_test/hush-arith/arith.right138
-rwxr-xr-xshell/hush_test/hush-arith/arith.tests302
-rwxr-xr-xshell/hush_test/hush-arith/arith1.sub40
-rwxr-xr-xshell/hush_test/hush-arith/arith2.sub57
-rw-r--r--shell/hush_test/hush-bugs/and_or_and_backgrounding.right4
-rwxr-xr-xshell/hush_test/hush-bugs/and_or_and_backgrounding.tests31
-rw-r--r--shell/hush_test/hush-leak/leak_argv1.right2
-rwxr-xr-xshell/hush_test/hush-leak/leak_argv1.tests117
-rw-r--r--shell/hush_test/hush-misc/and-or.right18
-rwxr-xr-xshell/hush_test/hush-misc/and-or.tests34
-rw-r--r--shell/hush_test/hush-misc/continue2.right1
-rwxr-xr-xshell/hush_test/hush-misc/continue2.tests3
-rw-r--r--shell/hush_test/hush-misc/continue3.right2
-rwxr-xr-xshell/hush_test/hush-misc/continue3.tests3
-rw-r--r--shell/hush_test/hush-misc/exec.right6
-rwxr-xr-xshell/hush_test/hush-misc/exec.tests30
-rw-r--r--shell/hush_test/hush-misc/exit1.right1
-rwxr-xr-xshell/hush_test/hush-misc/exit1.tests4
-rw-r--r--shell/hush_test/hush-misc/export.right6
-rwxr-xr-xshell/hush_test/hush-misc/export.tests7
-rw-r--r--shell/hush_test/hush-misc/for_with_bslashes.right8
-rwxr-xr-xshell/hush_test/hush-misc/for_with_bslashes.tests10
-rw-r--r--shell/hush_test/hush-misc/func1.right6
-rwxr-xr-xshell/hush_test/hush-misc/func1.tests16
-rw-r--r--shell/hush_test/hush-misc/func2.right5
-rwxr-xr-xshell/hush_test/hush-misc/func2.tests9
-rw-r--r--shell/hush_test/hush-misc/heredoc1.right5
-rwxr-xr-xshell/hush_test/hush-misc/heredoc1.tests9
-rw-r--r--shell/hush_test/hush-misc/heredoc2.right9
-rwxr-xr-xshell/hush_test/hush-misc/heredoc2.tests12
-rw-r--r--shell/hush_test/hush-misc/heredoc3.right9
-rwxr-xr-xshell/hush_test/hush-misc/heredoc3.tests12
-rw-r--r--shell/hush_test/hush-misc/heredoc_huge.right3
-rwxr-xr-xshell/hush_test/hush-misc/heredoc_huge.tests9
-rw-r--r--shell/hush_test/hush-misc/if_false_exitcode.right1
-rwxr-xr-xshell/hush_test/hush-misc/if_false_exitcode.tests2
-rw-r--r--shell/hush_test/hush-misc/redir1.right12
-rwxr-xr-xshell/hush_test/hush-misc/redir1.tests40
-rw-r--r--shell/hush_test/hush-misc/redir2.right1
-rwxr-xr-xshell/hush_test/hush-misc/redir2.tests2
-rw-r--r--shell/hush_test/hush-misc/redir3.right14
-rwxr-xr-xshell/hush_test/hush-misc/redir3.tests9
-rw-r--r--shell/hush_test/hush-misc/redir4.right18
-rwxr-xr-xshell/hush_test/hush-misc/redir4.tests85
-rw-r--r--shell/hush_test/hush-misc/syntax_err.right2
-rw-r--r--shell/hush_test/hush-misc/syntax_err_negate.right2
-rw-r--r--shell/hush_test/hush-misc/until1.right3
-rwxr-xr-xshell/hush_test/hush-misc/until1.tests11
-rw-r--r--shell/hush_test/hush-misc/while2.right2
-rwxr-xr-xshell/hush_test/hush-misc/while2.tests2
-rwxr-xr-xshell/hush_test/hush-parsing/escape1.tests2
-rwxr-xr-xshell/hush_test/hush-parsing/escape3.tests2
-rw-r--r--shell/hush_test/hush-parsing/escape5.right9
-rwxr-xr-xshell/hush_test/hush-parsing/escape5.tests7
-rwxr-xr-xshell/hush_test/hush-parsing/negate.tests12
-rw-r--r--shell/hush_test/hush-parsing/starquoted2.right2
-rwxr-xr-xshell/hush_test/hush-parsing/starquoted2.tests4
-rwxr-xr-xshell/hush_test/hush-psubst/tick3.tests2
-rw-r--r--shell/hush_test/hush-psubst/tick_huge.right3
-rwxr-xr-xshell/hush_test/hush-psubst/tick_huge.tests7
-rw-r--r--shell/hush_test/hush-trap/catch.right4
-rwxr-xr-xshell/hush_test/hush-trap/catch.tests20
-rw-r--r--shell/hush_test/hush-trap/exit.right2
-rwxr-xr-xshell/hush_test/hush-trap/exit.tests3
-rw-r--r--shell/hush_test/hush-trap/save-ret.right2
-rwxr-xr-xshell/hush_test/hush-trap/save-ret.tests4
-rw-r--r--shell/hush_test/hush-trap/usage.right14
-rwxr-xr-xshell/hush_test/hush-trap/usage.tests23
-rw-r--r--shell/hush_test/hush-vars/param_expand_alt.right8
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_alt.tests22
-rw-r--r--shell/hush_test/hush-vars/param_expand_assign.right27
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_assign.tests38
-rw-r--r--shell/hush_test/hush-vars/param_expand_default.right8
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_default.tests22
-rw-r--r--shell/hush_test/hush-vars/param_expand_indicate_error.right28
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_indicate_error.tests40
-rw-r--r--shell/hush_test/hush-vars/param_expand_len.right4
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_len.tests12
-rw-r--r--shell/hush_test/hush-vars/param_subshell.right7
-rwxr-xr-xshell/hush_test/hush-vars/param_subshell.tests15
-rw-r--r--shell/hush_test/hush-vars/unset.right19
-rwxr-xr-xshell/hush_test/hush-vars/unset.tests36
-rw-r--r--shell/hush_test/hush-vars/var1.right4
-rwxr-xr-xshell/hush_test/hush-vars/var1.tests4
-rw-r--r--shell/hush_test/hush-vars/var3.right2
-rwxr-xr-xshell/hush_test/hush-vars/var3.tests4
-rw-r--r--shell/hush_test/hush-vars/var_in_pipes.right6
-rwxr-xr-xshell/hush_test/hush-vars/var_in_pipes.tests7
-rw-r--r--shell/hush_test/hush-vars/var_posix1.right33
-rwxr-xr-xshell/hush_test/hush-vars/var_posix1.tests43
-rw-r--r--shell/hush_test/hush-z_slow/leak_all1.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_all1.tests145
-rw-r--r--shell/hush_test/hush-z_slow/leak_all2.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_all2.tests93
-rw-r--r--shell/hush_test/hush-z_slow/leak_heredoc1.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_heredoc1.tests34
-rw-r--r--shell/hush_test/hush-z_slow/leak_var.right2
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_var.tests103
-rw-r--r--shell/hush_test/hush-z_slow/leak_var2.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_var2.tests37
-rw-r--r--shell/hush_test/hush-z_slow/leak_var3.right3
-rwxr-xr-xshell/hush_test/hush-z_slow/leak_var3.tests41
-rwxr-xr-xshell/hush_test/run-all26
-rw-r--r--shell/lash_unused.c5
-rw-r--r--shell/match.c140
-rw-r--r--shell/match.h26
-rw-r--r--shell/math.c700
-rw-r--r--shell/math.h103
-rw-r--r--shell/msh.c15
-rw-r--r--shell/msh_test/msh-execution/exitcode_EACCES.right2
-rwxr-xr-xshell/msh_test/run-all4
-rw-r--r--sysklogd/klogd.c34
-rw-r--r--sysklogd/logger.c13
-rw-r--r--sysklogd/syslogd.c79
-rwxr-xr-xtestsuite/awk.tests18
-rwxr-xr-xtestsuite/expand.tests15
-rw-r--r--testsuite/ls/ls-1-works6
-rw-r--r--testsuite/ls/ls-h-works6
-rw-r--r--testsuite/ls/ls-l-works4
-rw-r--r--testsuite/ls/ls-s-works4
-rwxr-xr-xtestsuite/seq.tests7
-rwxr-xr-xtestsuite/test.tests10
-rw-r--r--testsuite/tr.tests31
-rwxr-xr-xtestsuite/unexpand.tests30
-rw-r--r--util-linux/Config.in28
-rw-r--r--util-linux/Kbuild2
-rw-r--r--util-linux/acpid.c167
-rw-r--r--util-linux/fbset.c40
-rw-r--r--util-linux/fdformat.c7
-rw-r--r--util-linux/fdisk.c2
-rw-r--r--util-linux/fdisk_aix.c4
-rw-r--r--util-linux/fdisk_osf.c2
-rw-r--r--util-linux/fdisk_sgi.c12
-rw-r--r--util-linux/fdisk_sun.c27
-rw-r--r--util-linux/mdev.c295
-rw-r--r--util-linux/mkfs_minix.c15
-rw-r--r--util-linux/mkfs_vfat.c614
-rw-r--r--util-linux/more.c4
-rw-r--r--util-linux/mount.c361
-rw-r--r--util-linux/rtcwake.c4
-rw-r--r--util-linux/script.c2
-rw-r--r--util-linux/umount.c6
-rw-r--r--util-linux/volume_id/cramfs.c3
-rw-r--r--util-linux/volume_id/ext.c3
-rw-r--r--util-linux/volume_id/fat.c17
-rw-r--r--util-linux/volume_id/get_devname.c2
-rw-r--r--util-linux/volume_id/hfs.c3
-rw-r--r--util-linux/volume_id/iso9660.c3
-rw-r--r--util-linux/volume_id/jfs.c3
-rw-r--r--util-linux/volume_id/linux_raid.c5
-rw-r--r--util-linux/volume_id/linux_swap.c3
-rw-r--r--util-linux/volume_id/luks.c3
-rw-r--r--util-linux/volume_id/ntfs.c3
-rw-r--r--util-linux/volume_id/ocfs2.c3
-rw-r--r--util-linux/volume_id/reiserfs.c3
-rw-r--r--util-linux/volume_id/romfs.c3
-rw-r--r--util-linux/volume_id/sysv.c3
-rw-r--r--util-linux/volume_id/udf.c3
-rw-r--r--util-linux/volume_id/util.c102
-rw-r--r--util-linux/volume_id/volume_id.c42
-rw-r--r--util-linux/volume_id/volume_id_internal.h98
-rw-r--r--util-linux/volume_id/xfs.c3
461 files changed, 11253 insertions, 21418 deletions
diff --git a/Config.in b/Config.in
index fff6d83d5..4fd9d1111 100644
--- a/Config.in
+++ b/Config.in
@@ -408,18 +408,12 @@ config CROSS_COMPILER_PREFIX
Note that CROSS_COMPILE environment variable or
"make CROSS_COMPILE=xxx ..." will override this selection.
Native builds leave this empty.
-config EXTRA_CFLAGS
- string "Additional CFLAGS"
- default ""
- help
- Additional CFLAGS to pass to the compiler verbatim.
-
endmenu
menu 'Debugging Options'
config DEBUG
bool "Build BusyBox with extra Debugging symbols"
diff --git a/Makefile b/Makefile
index 9e1bd876e..0212d8642 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
VERSION = 1
-PATCHLEVEL = 14
-SUBLEVEL = 3
+PATCHLEVEL = 13
+SUBLEVEL = 4
EXTRAVERSION =
NAME = Unnamed
# *DOCUMENTATION*
# To see a list of typical targets execute "make help"
# More info can be located in ./README
@@ -165,13 +165,12 @@ CROSS_COMPILE ?=
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
# and it has not been included yet... thus using an awkward syntax.
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
-#")
endif
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
diff --git a/Makefile.custom b/Makefile.custom
index d9a2367ab..140ff45c2 100644
--- a/Makefile.custom
+++ b/Makefile.custom
@@ -103,16 +103,14 @@ bigdata: busybox_unstripped
# Documentation Targets
.PHONY: doc
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
# FIXME: Doesn't belong here
- cmd_doc =
- quiet_cmd_doc = $(Q)echo " DOC $(@F)"
-silent_cmd_doc =
-disp_doc = $($(quiet)cmd_doc)
+disp_doc = \
+ @$(if $(quiet),echo " DOC $(@F)")
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
$(srctree)/include/usage.h \
$(srctree)/docs/busybox_footer.pod \
$(srctree)/docs/autodocifier.pl
$(disp_doc)
diff --git a/Makefile.flags b/Makefile.flags
index 2109fdf11..e31480204 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -20,13 +20,12 @@ CPPFLAGS += \
CFLAGS += $(call cc-option,-Wall,)
CFLAGS += $(call cc-option,-Wshadow,)
CFLAGS += $(call cc-option,-Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef,)
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
-CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
# still possible to build bbox without warnings.
@@ -79,17 +78,12 @@ endif
ifeq ($(CONFIG_PIE),y)
CFLAGS_busybox += $(ARCH_PIE)
CFLAGS += $(ARCH_FPIE)
endif
-ifneq ($(CONFIG_EXTRA_CFLAGS),)
-CFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_CFLAGS)))
-#"))
-endif
-
LDLIBS += m crypt
ifeq ($(CONFIG_PAM),y)
LDLIBS += pam pam_misc
endif
@@ -102,18 +96,18 @@ LDLIBS += efence
endif
ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += dmalloc
endif
-# If a flat binary should be built, CFLAGS_busybox="-elf2flt"
+# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
# env var should be set for make invocation.
# Here we check whether CFLAGS_busybox indeed contains that flag.
# (For historical reasons, we also check LDFLAGS, which doesn't
-# seem to be entirely correct variable to put "-elf2flt" into).
-W_ELF2FLT = -elf2flt
+# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
+W_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
SKIP_STRIP = y
endif
# Busybox is a stack-fatty so make sure we increase default size
# TODO: use "make stksizes" to find & fix big stack users
diff --git a/README b/README
index 40490449e..57407b550 100644
--- a/README
+++ b/README
@@ -75,13 +75,13 @@ Downloading the current source code:
For those that are actively contributing and would like to check files in,
see:
http://busybox.net/developer.html
The developers also have a bug and patch tracking system
- (https://bugs.busybox.net) although posting a bug/patch to the mailing list
+ (http://bugs.busybox.net) although posting a bug/patch to the mailing list
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
Note: if you want to compile busybox in a busybox environment you must
select ENABLE_DESKTOP.
diff --git a/TODO b/TODO
index d6a60d1dd..f887905e9 100644
--- a/TODO
+++ b/TODO
@@ -20,13 +20,13 @@ Rob Landley suggested these:
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant.
lash is phased out. hush can be configured down to be nearly as small,
but less buggy :)
init
- General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG).
+ General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
@@ -100,12 +100,17 @@ Rob Landley suggested these:
Bernhard Reutner-Fischer <busybox@busybox.net> suggests to look at these:
New debug options:
-Wlarger-than-127
Cleanup any big users
+ -Wunused-parameter
+ Facilitate applet PROTOTYPES to provide means for having applets that
+ do a) not take any arguments b) need only one of argc or argv c) need
+ both argc and argv. All of these three options should go for the most
+ feature complete denominator.
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
make bb_common_bufsiz1 configurable, size wise.
make pipesize configurable, size wise.
Use bb_common_bufsiz1 throughout applets!
As yet unclaimed:
@@ -124,12 +129,20 @@ patch
Should have simple fuzz factor support to apply patches at an offset which
shouldn't take up too much space.
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
+man
+ It would be nice to have a man command. Not one that handles troff or
+ anything, just one that can handle preformatted ascii man pages, possibly
+ compressed. This could probably be a script in the extras directory that
+ calls cat/zcat/bzcat | less
+
+ (How doclifter might work into this is anybody's guess.)
+---
ar
Write support!
---
stty / catv
stty's visible() function and catv's guts are identical. Merge them into
an appropriate libbb function.
@@ -167,13 +180,14 @@ Unify archivers
This could clean up tar and zip, and make it cheaper to add cpio and ar
write support, and possibly even cheaply add things like mkisofs or
mksquashfs someday, if they become relevant.
---
Text buffer support.
Several existing applets (sort, vi, less...) read
- a whole file into memory and act on it. Use open_read_close().
+ a whole file into memory and act on it. There might be an opportunity
+ for shared code in there that could be moved into libbb...
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
allocation on the stack or the heap. Unfortunately, we're not using it much.
We need to audit our memory allocations and turn a lot of malloc/free calls
into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
@@ -219,13 +233,13 @@ Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include
files. We've experienced collisions before.)
---
FEATURE_CLEAN_UP
This is more an unresolved issue than a to-do item. More thought is needed.
- Normally we rely on exit() to free memory, close files and unmap segments
+ Normally we rely on exit() to free memory, close files, and unmap segments
for us. This makes most calls to free(), close(), and unmap() optional in
busybox applets that don't intend to run for very long, and optional stuff
can be omitted to save size.
The idea was raised that we could simulate fork/exit with setjmp/longjmp
for _really_ brainless embedded systems, or speed up the standalone shell
@@ -270,13 +284,12 @@ Minor stuff:
---
See grep -r strtod
Alot of duplication that wants cleanup.
---
in_ether duplicated in network/{interface,ifconfig}.c
---
- unify progress_meter. wget, flash_eraseall, pipe_progress, fbsplash, setfiles.
Code cleanup:
Replace deprecated functions.
diff --git a/TODO_config_nommu b/TODO_config_nommu
index 2061bfd1c..b2496cf3c 100644
--- a/TODO_config_nommu
+++ b/TODO_config_nommu
@@ -107,13 +107,12 @@ CONFIG_FEATURE_SEAMLESS_Z=y
CONFIG_AR=y
CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
-CONFIG_FEATURE_CPIO_P=y
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
CONFIG_GUNZIP=y
CONFIG_GZIP=y
CONFIG_RPM2CPIO=y
@@ -628,15 +627,17 @@ CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
CONFIG_HTTPD=y
CONFIG_FEATURE_HTTPD_RANGES=y
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
+CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y
CONFIG_FEATURE_HTTPD_SETUID=y
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
+CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y
CONFIG_FEATURE_HTTPD_CGI=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
CONFIG_FEATURE_HTTPD_PROXY=y
diff --git a/applets/usage.c b/applets/usage.c
index 1e038b367..a35817f9f 100644
--- a/applets/usage.c
+++ b/applets/usage.c
@@ -1,12 +1,7 @@
/* vi: set sw=4 ts=4: */
-/*
- * Copyright (C) 2008 Denys Vlasenko.
- *
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
- */
#include <unistd.h>
/* Just #include "autoconf.h" doesn't work for builds in separate
* object directory */
#include "../include/autoconf.h"
diff --git a/archival/Config.in b/archival/Config.in
index 64b44c218..0b5cf3750 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -107,19 +107,12 @@ config FEATURE_CPIO_O
default n
depends on CPIO
help
This implementation of cpio can create cpio archives in the "newc"
format only.
-config FEATURE_CPIO_P
- bool "Support for passthrough mode"
- default n
- depends on FEATURE_CPIO_O
- help
- Passthrough mode. Rarely used.
-
config DPKG
bool "dpkg"
default n
select FEATURE_SEAMLESS_GZ
help
dpkg is a medium-level tool to install, build, remove and manage
diff --git a/archival/cpio.c b/archival/cpio.c
index 11b22e478..1c30d89a8 100644
--- a/archival/cpio.c
+++ b/archival/cpio.c
@@ -11,93 +11,12 @@
* Only supports new ASCII and CRC formats
*
*/
#include "libbb.h"
#include "unarchive.h"
-/* GNU cpio 2.9 --help (abridged):
-
- Modes:
- -t, --list List the archive
- -i, --extract Extract files from an archive
- -o, --create Create the archive
- -p, --pass-through Copy-pass mode [was ist das?!]
-
- Options valid in any mode:
- --block-size=SIZE I/O block size = SIZE * 512 bytes
- -B I/O block size = 5120 bytes
- -c Use the old portable (ASCII) archive format
- -C, --io-size=NUMBER I/O block size in bytes
- -f, --nonmatching Only copy files that do not match given pattern
- -F, --file=FILE Use FILE instead of standard input or output
- -H, --format=FORMAT Use given archive FORMAT
- -M, --message=STRING Print STRING when the end of a volume of the
- backup media is reached
- -n, --numeric-uid-gid If -v, show numeric UID and GID
- --quiet Do not print the number of blocks copied
- --rsh-command=COMMAND Use remote COMMAND instead of rsh
- -v, --verbose Verbosely list the files processed
- -V, --dot Print a "." for each file processed
- -W, --warning=FLAG Control warning display: 'none','truncate','all';
- multiple options accumulate
-
- Options valid only in --extract mode:
- -b, --swap Swap both halfwords of words and bytes of
- halfwords in the data (equivalent to -sS)
- -r, --rename Interactively rename files
- -s, --swap-bytes Swap the bytes of each halfword in the files
- -S, --swap-halfwords Swap the halfwords of each word (4 bytes)
- --to-stdout Extract files to standard output
- -E, --pattern-file=FILE Read additional patterns specifying filenames to
- extract or list from FILE
- --only-verify-crc Verify CRC's, don't actually extract the files
-
- Options valid only in --create mode:
- -A, --append Append to an existing archive
- -O FILE File to use instead of standard output
-
- Options valid only in --pass-through mode:
- -l, --link Link files instead of copying them, when possible
-
- Options valid in --extract and --create modes:
- --absolute-filenames Do not strip file system prefix components from
- the file names
- --no-absolute-filenames Create all files relative to the current dir
-
- Options valid in --create and --pass-through modes:
- -0, --null A list of filenames is terminated by a NUL
- -a, --reset-access-time Reset the access times of files after reading them
- -I FILE File to use instead of standard input
- -L, --dereference Dereference symbolic links (copy the files
- that they point to instead of copying the links)
- -R, --owner=[USER][:.][GROUP] Set owner of created files
-
- Options valid in --extract and --pass-through modes:
- -d, --make-directories Create leading directories where needed
- -m, --preserve-modification-time Retain mtime when creating files
- --no-preserve-owner Do not change the ownership of the files
- --sparse Write files with blocks of zeros as sparse files
- -u, --unconditional Replace all files unconditionally
- */
-enum {
- CPIO_OPT_EXTRACT = (1 << 0),
- CPIO_OPT_TEST = (1 << 1),
- CPIO_OPT_NUL_TERMINATED = (1 << 2),
- CPIO_OPT_UNCONDITIONAL = (1 << 3),
- CPIO_OPT_VERBOSE = (1 << 4),
- CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
- CPIO_OPT_PRESERVE_MTIME = (1 << 6),
- CPIO_OPT_DEREF = (1 << 7),
- CPIO_OPT_FILE = (1 << 8),
- CPIO_OPT_CREATE = (1 << 9) * ENABLE_FEATURE_CPIO_O,
- CPIO_OPT_FORMAT = (1 << 10) * ENABLE_FEATURE_CPIO_O,
- CPIO_OPT_PASSTHROUGH = (1 << 11) * ENABLE_FEATURE_CPIO_P,
-};
-
-#define OPTION_STR "it0uvdmLF:"
-
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
i = (- size) & 3;
@@ -127,31 +46,26 @@ static int cpio_o(void)
while (1) {
const char *name;
char *line;
struct stat st;
- line = (option_mask32 & CPIO_OPT_NUL_TERMINATED)
- ? bb_get_chunk_from_file(stdin, NULL)
- : xmalloc_fgetline(stdin);
+ line = xmalloc_fgetline(stdin);
if (line) {
/* Strip leading "./[./]..." from the filename */
name = line;
while (name[0] == '.' && name[1] == '/') {
while (*++name == '/')
continue;
}
if (!*name) { /* line is empty */
free(line);
continue;
}
- if ((option_mask32 & CPIO_OPT_DEREF)
- ? stat(name, &st)
- : lstat(name, &st)
- ) {
+ if (lstat(name, &st)) {
abort_cpio_o:
bb_simple_perror_msg_and_die(name);
}
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
st.st_size = 0; /* paranoia */
@@ -262,115 +176,142 @@ static int cpio_o(void)
free(line);
} /* end of "while (1)" */
}
#endif
+/* GNU cpio 2.9 --help (abridged):
+
+ Modes:
+ -i, --extract Extract files from an archive
+ -o, --create Create the archive
+ -p, --pass-through Copy-pass mode [was ist das?!]
+ -t, --list List the archive
+
+ Options valid in any mode:
+ --block-size=SIZE I/O block size = SIZE * 512 bytes
+ -B I/O block size = 5120 bytes
+ -c Use the old portable (ASCII) archive format
+ -C, --io-size=NUMBER I/O block size in bytes
+ -f, --nonmatching Only copy files that do not match given pattern
+ -F, --file=FILE Use FILE instead of standard input or output
+ -H, --format=FORMAT Use given archive FORMAT
+ -M, --message=STRING Print STRING when the end of a volume of the
+ backup media is reached
+ -n, --numeric-uid-gid If -v, show numeric UID and GID
+ --quiet Do not print the number of blocks copied
+ --rsh-command=COMMAND Use remote COMMAND instead of rsh
+ -v, --verbose Verbosely list the files processed
+ -V, --dot Print a "." for each file processed
+ -W, --warning=FLAG Control warning display: 'none','truncate','all';
+ multiple options accumulate
+
+ Options valid only in --extract mode:
+ -b, --swap Swap both halfwords of words and bytes of
+ halfwords in the data (equivalent to -sS)
+ -r, --rename Interactively rename files
+ -s, --swap-bytes Swap the bytes of each halfword in the files
+ -S, --swap-halfwords Swap the halfwords of each word (4 bytes)
+ --to-stdout Extract files to standard output
+ -E, --pattern-file=FILE Read additional patterns specifying filenames to
+ extract or list from FILE
+ --only-verify-crc Verify CRC's, don't actually extract the files
+
+ Options valid only in --create mode:
+ -A, --append Append to an existing archive
+ -O FILE File to use instead of standard output
+
+ Options valid only in --pass-through mode:
+ -l, --link Link files instead of copying them, when possible
+
+ Options valid in --extract and --create modes:
+ --absolute-filenames Do not strip file system prefix components from
+ the file names
+ --no-absolute-filenames Create all files relative to the current dir
+
+ Options valid in --create and --pass-through modes:
+ -0, --null A list of filenames is terminated by a NUL
+ -a, --reset-access-time Reset the access times of files after reading them
+ -I FILE File to use instead of standard input
+ -L, --dereference Dereference symbolic links (copy the files
+ that they point to instead of copying the links)
+ -R, --owner=[USER][:.][GROUP] Set owner of created files
+
+ Options valid in --extract and --pass-through modes:
+ -d, --make-directories Create leading directories where needed
+ -m, --preserve-modification-time Retain mtime when creating files
+ --no-preserve-owner Do not change the ownership of the files
+ --sparse Write files with blocks of zeros as sparse files
+ -u, --unconditional Replace all files unconditionally
+ */
+
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cpio_main(int argc UNUSED_PARAM, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename;
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
unsigned opt;
+ enum {
+ CPIO_OPT_EXTRACT = (1 << 0),
+ CPIO_OPT_TEST = (1 << 1),
+ CPIO_OPT_UNCONDITIONAL = (1 << 2),
+ CPIO_OPT_VERBOSE = (1 << 3),
+ CPIO_OPT_FILE = (1 << 4),
+ CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
+ CPIO_OPT_PRESERVE_MTIME = (1 << 6),
+ CPIO_OPT_CREATE = (1 << 7),
+ CPIO_OPT_FORMAT = (1 << 8),
+ };
#if ENABLE_GETOPT_LONG
applet_long_options =
"extract\0" No_argument "i"
"list\0" No_argument "t"
#if ENABLE_FEATURE_CPIO_O
"create\0" No_argument "o"
"format\0" Required_argument "H"
-#if ENABLE_FEATURE_CPIO_P
- "pass-through\0" No_argument "p"
-#endif
#endif
;
#endif
- /* As of now we do not enforce this: */
- /* -i,-t,-o,-p are mutually exclusive */
- /* -u,-d,-m make sense only with -i or -p */
- /* -L makes sense only with -o or -p */
+ /* Initialize */
+ archive_handle = init_handle();
+ archive_handle->src_fd = STDIN_FILENO;
+ archive_handle->seek = seek_by_read;
+ archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
-#if !ENABLE_FEATURE_CPIO_O
- opt = getopt32(argv, OPTION_STR, &cpio_filename);
-#else
- opt = getopt32(argv, OPTION_STR "oH:" USE_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt);
- if (opt & CPIO_OPT_PASSTHROUGH) {
- pid_t pid;
- struct fd_pair pp;
+#if ENABLE_FEATURE_CPIO_O
+ opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
- if (argv[optind] == NULL)
- bb_show_usage();
- if (opt & CPIO_OPT_CREATE_LEADING_DIR)
- mkdir(argv[optind], 0777);
- /* Crude existence check:
- * close(xopen(argv[optind], O_RDONLY | O_DIRECTORY));
- * We can also xopen, fstat, IS_DIR, later fchdir.
- * This would check for existence earlier and cleaner.
- * As it stands now, if we fail xchdir later,
- * child dies on EPIPE, unless it caught
- * a diffrerent problem earlier.
- * This is good enough for now.
- */
-#if !BB_MMU
- pp.rd = 3;
- pp.wr = 4;
- if (!re_execed) {
- close(3);
- close(4);
- xpiped_pair(pp);
- }
-#else
- xpiped_pair(pp);
-#endif
- pid = fork_or_rexec(argv);
- if (pid == 0) { /* child */
- close(pp.rd);
- xmove_fd(pp.wr, STDOUT_FILENO);
- goto dump;
- }
- /* parent */
- xchdir(argv[optind++]);
- close(pp.wr);
- xmove_fd(pp.rd, STDIN_FILENO);
- opt &= ~CPIO_OPT_PASSTHROUGH;
- opt |= CPIO_OPT_EXTRACT;
- goto skip;
- }
- /* -o */
if (opt & CPIO_OPT_CREATE) {
- if (*cpio_fmt != 'n') /* we _require_ "-H newc" */
+ if (*cpio_fmt != 'n')
bb_show_usage();
if (opt & CPIO_OPT_FILE) {
fclose(stdout);
stdout = fopen_for_write(cpio_filename);
/* Paranoia: I don't trust libc that much */
xdup2(fileno(stdout), STDOUT_FILENO);
}
- dump:
return cpio_o();
}
- skip:
+#else
+ opt = getopt32(argv, "ituvF:dm", &cpio_filename);
#endif
argv += optind;
- archive_handle = init_handle();
- archive_handle->src_fd = STDIN_FILENO;
- archive_handle->seek = seek_by_read;
- archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
-
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
bb_show_usage();
}
if (opt & CPIO_OPT_TEST) {
/* if both extract and test options are given, ignore extract option */
- opt &= ~CPIO_OPT_EXTRACT;
+ if (opt & CPIO_OPT_EXTRACT) {
+ opt &= ~CPIO_OPT_EXTRACT;
+ }
archive_handle->action_header = header_list;
}
if (opt & CPIO_OPT_EXTRACT) {
archive_handle->action_data = data_extract_all;
}
if (opt & CPIO_OPT_UNCONDITIONAL) {
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 577b77fec..1bc8d27ce 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -3,16 +3,12 @@
* mini dpkg implementation for busybox.
* this is not meant as a replacement for dpkg
*
* written by glenn mcgrath with the help of others
* copyright (c) 2001 by glenn mcgrath
*
- * parts of the version comparison code is plucked from the real dpkg
- * application which is licensed GPLv2 and
- * copyright (c) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
- *
* started life as a busybox implementation of udpkg
*
* licensed under gplv2 or later, see file license in this tarball for details.
*/
/*
@@ -136,13 +132,13 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
/* Maybe i should have uses a "proper" hashing algorithm here instead
* of making one up myself, seems to be working ok though. */
for (i = 1; i < len; i++) {
/* shifts the ascii based value and adds it to previous value
* shift amount is mod 24 because long int is 32 bit and data
* to be shifted is 8, don't want to shift data to where it has
- * no effect */
+ * no effect*/
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
}
*start = (unsigned) hash_num % hash_prime;
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
}
@@ -184,98 +180,111 @@ static unsigned search_status_hashtable(const char *key)
probe_address += STATUS_HASH_PRIME;
}
}
return probe_address;
}
-static int order(char x)
-{
- return (x == '~' ? -1
- : x == '\0' ? 0
- : isdigit(x) ? 0
- : isalpha(x) ? x
- : (unsigned char)x + 256
- );
-}
-
-/* This code is taken from dpkg and modified slightly to work with busybox */
-static int version_compare_part(const char *val, const char *ref)
+/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */
+static int version_compare_part(const char *version1, const char *version2)
{
- if (!val) val = "";
- if (!ref) ref = "";
-
- while (*val || *ref) {
- int first_diff;
-
- while ((*val && !isdigit(*val)) || (*ref && !isdigit(*ref))) {
- int vc = order(*val);
- int rc = order(*ref);
- if (vc != rc)
- return vc - rc;
- val++;
- ref++;
+ int upstream_len1 = 0;
+ int upstream_len2 = 0;
+ char *name1_char;
+ char *name2_char;
+ int len1 = 0;
+ int len2 = 0;
+ int tmp_int;
+ int ver_num1;
+ int ver_num2;
+
+ if (version1 == NULL) {
+ version1 = xstrdup("");
+ }
+ if (version2 == NULL) {
+ version2 = xstrdup("");
+ }
+ upstream_len1 = strlen(version1);
+ upstream_len2 = strlen(version2);
+
+ while ((len1 < upstream_len1) || (len2 < upstream_len2)) {
+ /* Compare non-digit section */
+ tmp_int = strcspn(&version1[len1], "0123456789");
+ name1_char = xstrndup(&version1[len1], tmp_int);
+ len1 += tmp_int;
+ tmp_int = strcspn(&version2[len2], "0123456789");
+ name2_char = xstrndup(&version2[len2], tmp_int);
+ len2 += tmp_int;
+ tmp_int = strcmp(name1_char, name2_char);
+ free(name1_char);
+ free(name2_char);
+ if (tmp_int != 0) {
+ return tmp_int;
}
- while (*val == '0')
- val++;
- while (*ref == '0')
- ref++;
-
- first_diff = 0;
- while (isdigit(*val) && isdigit(*ref)) {
- if (first_diff == 0)
- first_diff = *val - *ref;
- val++;
- ref++;
+ /* Compare digits */
+ tmp_int = strspn(&version1[len1], "0123456789");
+ name1_char = xstrndup(&version1[len1], tmp_int);
+ len1 += tmp_int;
+ tmp_int = strspn(&version2[len2], "0123456789");
+ name2_char = xstrndup(&version2[len2], tmp_int);
+ len2 += tmp_int;
+ ver_num1 = atoi(name1_char);
+ ver_num2 = atoi(name2_char);
+ free(name1_char);
+ free(name2_char);
+ if (ver_num1 < ver_num2) {
+ return -1;
}
- if (isdigit(*val))
+ if (ver_num1 > ver_num2) {
return 1;
- if (isdigit(*ref))
- return -1;
- if (first_diff)
- return first_diff;
+ }
}
return 0;
}
/* if ver1 < ver2 return -1,
* if ver1 = ver2 return 0,
* if ver1 > ver2 return 1,
*/
static int version_compare(const unsigned ver1, const unsigned ver2)
{
char *ch_ver1 = name_hashtable[ver1];
char *ch_ver2 = name_hashtable[ver2];
- unsigned long epoch1 = 0, epoch2 = 0;
- char *colon;
+
+ char epoch1, epoch2;
char *deb_ver1, *deb_ver2;
+ char *ver1_ptr, *ver2_ptr;
char *upstream_ver1;
char *upstream_ver2;
int result;
/* Compare epoch */
- colon = strchr(ch_ver1, ':');
- if (colon) {
- epoch1 = atoi(ch_ver1);
- ch_ver1 = colon + 1;
+ if (ch_ver1[1] == ':') {
+ epoch1 = ch_ver1[0];
+ ver1_ptr = strchr(ch_ver1, ':') + 1;
+ } else {
+ epoch1 = '0';
+ ver1_ptr = ch_ver1;
}
- colon = strchr(ch_ver2, ':');
- if (colon) {
- epoch2 = atoi(ch_ver2);
- ch_ver2 = colon + 1;
+ if (ch_ver2[1] == ':') {
+ epoch2 = ch_ver2[0];
+ ver2_ptr = strchr(ch_ver2, ':') + 1;
+ } else {
+ epoch2 = '0';
+ ver2_ptr = ch_ver2;
}
if (epoch1 < epoch2) {
return -1;
}
- if (epoch1 > epoch2) {
+ else if (epoch1 > epoch2) {
return 1;
}
/* Compare upstream version */
- upstream_ver1 = xstrdup(ch_ver1);
- upstream_ver2 = xstrdup(ch_ver2);
+ upstream_ver1 = xstrdup(ver1_ptr);
+ upstream_ver2 = xstrdup(ver2_ptr);
/* Chop off debian version, and store for later use */
deb_ver1 = strrchr(upstream_ver1, '-');
deb_ver2 = strrchr(upstream_ver2, '-');
if (deb_ver1) {
deb_ver1[0] = '\0';
diff --git a/archival/gzip.c b/archival/gzip.c
index a76e1d3bd..43804b2e4 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -386,12 +386,25 @@ static void put_32bit(ulg n)
{
put_16bit(n);
put_16bit(n >> 16);
}
/* ===========================================================================
+ * Clear input and output buffers
+ */
+static void clear_bufs(void)
+{
+ G1.outcnt = 0;
+#ifdef DEBUG
+ G1.insize = 0;
+#endif
+ G1.isize = 0;
+}
+
+
+/* ===========================================================================
* Run a set of bytes through the crc shift register. If s is a NULL
* pointer, then initialize the crc shift register contents instead.
* Return the current crc in either case.
*/
static uint32_t updcrc(uch * s, unsigned n)
{
@@ -2003,43 +2016,13 @@ char* make_new_name_gzip(char *filename)
static
USE_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
{
struct stat s;
- /* Clear input and output buffers */
- G1.outcnt = 0;
-#ifdef DEBUG
- G1.insize = 0;
-#endif
- G1.isize = 0;
-
- /* Reinit G2.xxx */
- memset(&G2, 0, sizeof(G2));
- G2.l_desc.dyn_tree = G2.dyn_ltree;
- G2.l_desc.static_tree = G2.static_ltree;
- G2.l_desc.extra_bits = extra_lbits;
- G2.l_desc.extra_base = LITERALS + 1;
- G2.l_desc.elems = L_CODES;
- G2.l_desc.max_length = MAX_BITS;
- //G2.l_desc.max_code = 0;
- G2.d_desc.dyn_tree = G2.dyn_dtree;
- G2.d_desc.static_tree = G2.static_dtree;
- G2.d_desc.extra_bits = extra_dbits;
- //G2.d_desc.extra_base = 0;
- G2.d_desc.elems = D_CODES;
- G2.d_desc.max_length = MAX_BITS;
- //G2.d_desc.max_code = 0;
- G2.bl_desc.dyn_tree = G2.bl_tree;
- //G2.bl_desc.static_tree = NULL;
- G2.bl_desc.extra_bits = extra_blbits,
- //G2.bl_desc.extra_base = 0;
- G2.bl_desc.elems = BL_CODES;
- G2.bl_desc.max_length = MAX_BL_BITS;
- //G2.bl_desc.max_code = 0;
-
+ clear_bufs();
s.st_ctime = 0;
fstat(STDIN_FILENO, &s);
zip(s.st_ctime);
return 0;
}
@@ -2078,12 +2061,35 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
//if (opt & 0x4) // -v
argv += optind;
SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ sizeof(struct globals));
barrier();
+ G2.l_desc.dyn_tree = G2.dyn_ltree;
+ G2.l_desc.static_tree = G2.static_ltree;
+ G2.l_desc.extra_bits = extra_lbits;
+ G2.l_desc.extra_base = LITERALS + 1;
+ G2.l_desc.elems = L_CODES;
+ G2.l_desc.max_length = MAX_BITS;
+ //G2.l_desc.max_code = 0;
+
+ G2.d_desc.dyn_tree = G2.dyn_dtree;
+ G2.d_desc.static_tree = G2.static_dtree;
+ G2.d_desc.extra_bits = extra_dbits;
+ //G2.d_desc.extra_base = 0;
+ G2.d_desc.elems = D_CODES;
+ G2.d_desc.max_length = MAX_BITS;
+ //G2.d_desc.max_code = 0;
+
+ G2.bl_desc.dyn_tree = G2.bl_tree;
+ //G2.bl_desc.static_tree = NULL;
+ G2.bl_desc.extra_bits = extra_blbits,
+ //G2.bl_desc.extra_base = 0;
+ G2.bl_desc.elems = BL_CODES;
+ G2.bl_desc.max_length = MAX_BL_BITS;
+ //G2.bl_desc.max_code = 0;
/* Allocate all global buffers (for DYN_ALLOC option) */
ALLOC(uch, G1.l_buf, INBUFSIZ);
ALLOC(uch, G1.outbuf, OUTBUFSIZ);
ALLOC(ush, G1.d_buf, DIST_BUFSIZE);
ALLOC(uch, G1.window, 2L * WSIZE);
diff --git a/archival/libunarchive/decompress_unzip.c b/archival/libunarchive/decompress_unzip.c
index 86969251e..e83cd4f45 100644
--- a/archival/libunarchive/decompress_unzip.c
+++ b/archival/libunarchive/decompress_unzip.c
@@ -1080,26 +1080,27 @@ static int top_up(STATE_PARAM unsigned n)
}
static uint16_t buffer_read_le_u16(STATE_PARAM_ONLY)
{
uint16_t res;
#if BB_LITTLE_ENDIAN
- move_from_unaligned16(res, &bytebuffer[bytebuffer_offset]);
+ /* gcc 4.2.1 is very clever */
+ memcpy(&res, &bytebuffer[bytebuffer_offset], 2);
#else
res = bytebuffer[bytebuffer_offset];
res |= bytebuffer[bytebuffer_offset + 1] << 8;
#endif
bytebuffer_offset += 2;
return res;
}
static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY)
{
uint32_t res;
#if BB_LITTLE_ENDIAN
- move_from_unaligned32(res, &bytebuffer[bytebuffer_offset]);
+ memcpy(&res, &bytebuffer[bytebuffer_offset], 4);
#else
res = bytebuffer[bytebuffer_offset];
res |= bytebuffer[bytebuffer_offset + 1] << 8;
res |= bytebuffer[bytebuffer_offset + 2] << 16;
res |= bytebuffer[bytebuffer_offset + 3] << 24;
#endif
diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
index 443052f7e..4c063b387 100644
--- a/archival/libunarchive/get_header_tar.c
+++ b/archival/libunarchive/get_header_tar.c
@@ -11,80 +11,12 @@
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
*/
#include "libbb.h"
#include "unarchive.h"
-/*
- * GNU tar uses "base-256 encoding" for very large numbers (>8 billion).
- * Encoding is binary, with highest bit always set as a marker
- * and sign in next-highest bit:
- * 80 00 .. 00 - zero
- * bf ff .. ff - largest positive number
- * ff ff .. ff - minus 1
- * c0 00 .. 00 - smallest negative number
- *
- * We expect it only in size field, where negative numbers don't make sense.
- */
-static off_t getBase256_len12(const char *str)
-{
- off_t value;
- int len;
-
- /* if (*str & 0x40) error; - caller prevents this */
-
- if (sizeof(off_t) >= 12) {
- /* Probably 128-bit (16 byte) off_t. Can be optimized. */
- len = 12;
- value = *str++ & 0x3f;
- while (--len)
- value = (value << 8) + (unsigned char) *str++;
- return value;
- }
-
-#ifdef CHECK_FOR_OVERFLOW
- /* Can be optimized to eat 32-bit chunks */
- char c = *str++ & 0x3f;
- len = 12;
- while (1) {
- if (c)
- bb_error_msg_and_die("overflow in base-256 encoded file size");
- if (--len == sizeof(off_t))
- break;
- c = *str++;
- }
-#else
- str += (12 - sizeof(off_t));
-#endif
-
-/* Now str points to sizeof(off_t) least significant bytes.
- *
- * Example of tar file with 8914993153 (0x213600001) byte file.
- * Field starts at offset 7c:
- * 00070 30 30 30 00 30 30 30 30 30 30 30 00 80 00 00 00 |000.0000000.....|
- * 00080 00 00 00 02 13 60 00 01 31 31 31 32 30 33 33 36 |.....`..11120336|
- *
- * str is at offset 80 or 84 now (64-bit or 32-bit off_t).
- * We (ab)use the fact that value happens to be aligned,
- * and fetch it in one go:
- */
- if (sizeof(off_t) == 8) {
- value = *(off_t*)str;
- value = SWAP_BE64(value);
- } else if (sizeof(off_t) == 4) {
- value = *(off_t*)str;
- value = SWAP_BE32(value);
- } else {
- value = 0;
- len = sizeof(off_t);
- while (--len)
- value = (value << 8) + (unsigned char) *str++;
- }
- return value;
-}
-
/* NB: _DESTROYS_ str[len] character! */
static unsigned long long getOctal(char *str, int len)
{
unsigned long long v;
/* NB: leading spaces are allowed. Using strtoull to handle that.
* The downside is that we accept e.g. "-123" too :)
@@ -299,16 +231,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
}
#if ENABLE_FEATURE_TAR_UNAME_GNAME
file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
#endif
file_header->mtime = GET_OCTAL(tar.mtime);
- /* Size field: handle GNU tar's "base256 encoding" */
- file_header->size = (*tar.size & 0xc0) == 0x80 /* positive base256? */
- ? getBase256_len12(tar.size)
- : GET_OCTAL(tar.size);
+ file_header->size = GET_OCTAL(tar.size);
file_header->gid = GET_OCTAL(tar.gid);
file_header->uid = GET_OCTAL(tar.uid);
/* Set bits 0-11 of the files mode */
file_header->mode = 07777 & GET_OCTAL(tar.mode);
file_header->name = NULL;
diff --git a/archival/libunarchive/header_verbose_list.c b/archival/libunarchive/header_verbose_list.c
index dc3100361..f059dd981 100644
--- a/archival/libunarchive/header_verbose_list.c
+++ b/archival/libunarchive/header_verbose_list.c
@@ -21,17 +21,17 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
user = uid;
}
if (group == NULL) {
snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
group = gid;
}
- printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
+ printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
user,
group,
- file_header->size,
+ (unsigned int) file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
mtime->tm_hour,
mtime->tm_min,
mtime->tm_sec,
diff --git a/archival/tar.c b/archival/tar.c
index eeaf3586b..b6beede0d 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -354,14 +354,13 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
chksum_and_xwrite(tbInfo->tarFd, &header);
/* Now do the verbose thing (or not) */
if (tbInfo->verboseFlag) {
FILE *vbFd = stdout;
- /* If archive goes to stdout, verbose goes to stderr */
- if (tbInfo->tarFd == STDOUT_FILENO)
+ if (tbInfo->tarFd == STDOUT_FILENO) /* If the archive goes to stdout, verbose to stderr */
vbFd = stderr;
/* GNU "tar cvvf" prints "extended" listing a-la "ls -l" */
/* We don't have such excesses here: for us "v" == "vv" */
/* '/' is probably a GNUism */
fprintf(vbFd, "%s%s\n", header_name,
S_ISDIR(statbuf->st_mode) ? "/" : "");
@@ -932,14 +931,16 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
}
if (LONE_DASH(tar_filename)) {
tar_handle->src_fd = fileno(tar_stream);
tar_handle->seek = seek_by_read;
} else {
- if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) {
- get_header_ptr = get_header_tar;
+ if (ENABLE_FEATURE_TAR_AUTODETECT
+ && get_header_ptr == get_header_tar
+ && flags == O_RDONLY
+ ) {
tar_handle->src_fd = open_zipped(tar_filename);
if (tar_handle->src_fd < 0)
bb_perror_msg_and_die("can't open '%s'", tar_filename);
} else {
tar_handle->src_fd = xopen(tar_filename, flags);
}
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 336418061..863c6efcd 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -3,14 +3,12 @@
* loadfont.c - Eugene Crosser & Andries Brouwer
*
* Version 0.96bb
*
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
- *
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include <sys/kd.h>
#ifndef KDFONTOP
#define KDFONTOP 0x4B72
diff --git a/coreutils/Config.in b/coreutils/Config.in
index b047ce5e2..8cbc92f1e 100644
--- a/coreutils/Config.in
+++ b/coreutils/Config.in
@@ -186,13 +186,13 @@ config ECHO
echo is used to print a specified string to stdout.
# this entry also appears in shell/Config.in, next to the echo builtin
config FEATURE_FANCY_ECHO
bool "Enable echo options (-n and -e)"
default y
- depends on ECHO || ASH_BUILTIN_ECHO || HUSH
+ depends on ECHO || ASH_BUILTIN_ECHO
help
This adds options (-n and -e) to echo.
config ENV
bool "env"
default n
@@ -506,24 +506,12 @@ config SEQ
config SHA1SUM
bool "sha1sum"
default n
help
Compute and check SHA1 message digest
-config SHA256SUM
- bool "sha256sum"
- default n
- help
- Compute and check SHA256 message digest
-
-config SHA512SUM
- bool "sha512sum"
- default n
- help
- Compute and check SHA512 message digest
-
config SLEEP
bool "sleep"
default n
help
sleep is used to pause for a specified number of seconds.
It comes in 3 versions:
@@ -763,13 +751,13 @@ config WC
config FEATURE_WC_LARGE
bool "Support very large files in wc"
default n
depends on WC
help
- Use "unsigned long long" in wc for counter variables.
+ Use "unsigned long long" in wc for count variables.
config WHO
bool "who"
default n
select FEATURE_UTMP
help
diff --git a/coreutils/Kbuild b/coreutils/Kbuild
index 57100a9cf..a5a2d4c26 100644
--- a/coreutils/Kbuild
+++ b/coreutils/Kbuild
@@ -41,13 +41,12 @@ lib-$(CONFIG_HOSTID) += hostid.o
lib-$(CONFIG_ID) += id.o
lib-$(CONFIG_INSTALL) += install.o
lib-$(CONFIG_LENGTH) += length.o
lib-$(CONFIG_LN) += ln.o
lib-$(CONFIG_LOGNAME) += logname.o
lib-$(CONFIG_LS) += ls.o
-lib-$(CONFIG_FTPD) += ls.o
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
lib-$(CONFIG_MKDIR) += mkdir.o
lib-$(CONFIG_MKFIFO) += mkfifo.o
lib-$(CONFIG_MKNOD) += mknod.o
lib-$(CONFIG_MV) += mv.o
lib-$(CONFIG_NICE) += nice.o
@@ -60,14 +59,12 @@ lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_READLINK) += readlink.o
lib-$(CONFIG_REALPATH) += realpath.o
lib-$(CONFIG_RM) += rm.o
lib-$(CONFIG_RMDIR) += rmdir.o
lib-$(CONFIG_SEQ) += seq.o
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
-lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
-lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SPLIT) += split.o
lib-$(CONFIG_SORT) += sort.o
lib-$(CONFIG_STAT) += stat.o
lib-$(CONFIG_STTY) += stty.o
lib-$(CONFIG_SUM) += sum.o
diff --git a/coreutils/cksum.c b/coreutils/cksum.c
index 3a77c753a..546532c3c 100644
--- a/coreutils/cksum.c
+++ b/coreutils/cksum.c
@@ -12,29 +12,26 @@ int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cksum_main(int argc UNUSED_PARAM, char **argv)
{
uint32_t *crc32_table = crc32_filltable(NULL, 1);
uint32_t crc;
off_t length, filesize;
int bytes_read;
- int exit_code = EXIT_SUCCESS;
uint8_t *cp;
#if ENABLE_DESKTOP
getopt32(argv, ""); /* coreutils 6.9 compat */
argv += optind;
#else
argv++;
#endif
do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
- if (fd < 0) {
- exit_code = EXIT_FAILURE;
+ if (fd < 0)
continue;
- }
crc = 0;
length = 0;
#define read_buf bb_common_bufsiz1
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
cp = (uint8_t *) read_buf;
@@ -60,8 +57,8 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
crc = ~crc;
printf((*argv ? "%"PRIu32" %"OFF_FMT"i %s\n" : "%"PRIu32" %"OFF_FMT"i\n"),
crc, filesize, *argv);
} while (*argv && *++argv);
- fflush_stdout_and_exit(exit_code);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/coreutils/cp.c b/coreutils/cp.c
index 71a29396f..40d3625b3 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -43,61 +43,13 @@ int cp_main(int argc, char **argv)
// Soft- and hardlinking doesn't mix
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -R (and therefore -r) turns on -d (coreutils does this)
// -a = -pdR
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
- // -v (--verbose) is ignored
- flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHv");
- /* Options of cp from GNU coreutils 6.10:
- * -a, --archive
- * -f, --force
- * -i, --interactive
- * -l, --link
- * -L, --dereference
- * -P, --no-dereference
- * -R, -r, --recursive
- * -s, --symbolic-link
- * -v, --verbose
- * -H follow command-line symbolic links in SOURCE
- * -d same as --no-dereference --preserve=links
- * -p same as --preserve=mode,ownership,timestamps
- * -c same as --preserve=context
- * NOT SUPPORTED IN BBOX:
- * long options are not supported (even those above).
- * --backup[=CONTROL]
- * make a backup of each existing destination file
- * -b like --backup but does not accept an argument
- * --copy-contents
- * copy contents of special files when recursive
- * --preserve[=ATTR_LIST]
- * preserve attributes (default: mode,ownership,timestamps),
- * if possible additional attributes: security context,links,all
- * --no-preserve=ATTR_LIST
- * --parents
- * use full source file name under DIRECTORY
- * --remove-destination
- * remove each existing destination file before attempting to open
- * --sparse=WHEN
- * control creation of sparse files
- * --strip-trailing-slashes
- * remove any trailing slashes from each SOURCE argument
- * -S, --suffix=SUFFIX
- * override the usual backup suffix
- * -t, --target-directory=DIRECTORY
- * copy all SOURCE arguments into DIRECTORY
- * -T, --no-target-directory
- * treat DEST as a normal file
- * -u, --update
- * copy only when the SOURCE file is newer than the destination
- * file or when the destination file is missing
- * -x, --one-file-system
- * stay on this file system
- * -Z, --context=CONTEXT
- * (SELinux) set SELinux security context of copy to CONTEXT
- */
+ flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
argc -= optind;
argv += optind;
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
/* coreutils 6.9 compat:
* by default, "cp" derefs symlinks (creates regular dest files),
* but "cp -R" does not. We switch off deref if -r or -R (see above).
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 38dacc71d..8a40aa77f 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -5,12 +5,13 @@
*
* Copyright (C) 2000,2001 Matt Kraai
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
enum {
diff --git a/coreutils/df.c b/coreutils/df.c
index e9a865c19..1c7d6cb38 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -41,21 +41,23 @@ int df_main(int argc, char **argv)
unsigned long df_disp_hr = 1024;
int status = EXIT_SUCCESS;
unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
+ static const char ignored_mounts[] ALIGN1 =
+ "rootfs\0";
enum {
OPT_KILO = (1 << 0),
OPT_POSIX = (1 << 1),
OPT_ALL = (1 << 2) * ENABLE_FEATURE_DF_FANCY,
OPT_INODE = (1 << 3) * ENABLE_FEATURE_DF_FANCY,
OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
- OPT_HUMAN = (1 << (2 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
- OPT_MEGA = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
+ OPT_HUMAN = (1 << 5) * ENABLE_FEATURE_HUMAN_READABLE,
+ OPT_MEGA = (1 << 6) * ENABLE_FEATURE_HUMAN_READABLE,
};
const char *disp_units_hdr = NULL;
char *chp;
#if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY
opt_complementary = "k-mB:m-Bk:B-km";
@@ -116,27 +118,27 @@ int df_main(int argc, char **argv)
break;
}
} else {
mount_point = *argv++;
if (!mount_point)
break;
- mount_entry = find_mount_point(mount_point);
+ mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
if (!mount_entry) {
bb_error_msg("%s: can't find mount point", mount_point);
- set_error:
+ SET_ERROR:
status = EXIT_FAILURE;
continue;
}
}
device = mount_entry->mnt_fsname;
mount_point = mount_entry->mnt_dir;
if (statfs(mount_point, &s) != 0) {
bb_simple_perror_msg(mount_point);
- goto set_error;
+ goto SET_ERROR;
}
if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
if (opt & OPT_INODE) {
s.f_blocks = s.f_files;
s.f_bavail = s.f_bfree = s.f_ffree;
@@ -150,24 +152,24 @@ int df_main(int argc, char **argv)
if (blocks_used + s.f_bavail) {
blocks_percent_used = (blocks_used * 100ULL
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
}
- /* GNU coreutils 6.10 skips certain mounts, try to be compatible. */
- if (strcmp(device, "rootfs") == 0)
+ /* GNU coreutils 6.10 skip certain mounts, try to be compatible. */
+ if (index_in_strings(device, ignored_mounts) != -1)
continue;
#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
/* ... and also this is the only user of find_block_device */
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
device = find_block_device("/");
if (!device) {
- goto set_error;
+ goto SET_ERROR;
}
}
#endif
if (printf("\n%-20s" + 1, device) > 20)
printf("\n%-20s", "");
diff --git a/coreutils/du.c b/coreutils/du.c
index 16c773243..efc9bb9fa 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -22,34 +22,25 @@
* 3) Added error checking of output.
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
*/
#include "libbb.h"
-enum {
- OPT_a_files_too = (1 << 0),
- OPT_H_follow_links = (1 << 1),
- OPT_k_kbytes = (1 << 2),
- OPT_L_follow_links = (1 << 3),
- OPT_s_total_norecurse = (1 << 4),
- OPT_x_one_FS = (1 << 5),
- OPT_d_maxdepth = (1 << 6),
- OPT_l_hardlinks = (1 << 7),
- OPT_c_total = (1 << 8),
- OPT_h_for_humans = (1 << 9),
- OPT_m_mbytes = (1 << 10),
-};
-
struct globals {
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned long disp_hr;
#else
unsigned disp_k;
#endif
+
int max_print_depth;
+ nlink_t count_hardlinks;
+
bool status;
+ bool one_file_system;
+ int print_files;
int slink_depth;
int du_depth;
dev_t dir_dev;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
@@ -78,40 +69,37 @@ static unsigned long du(const char *filename)
if (lstat(filename, &statbuf) != 0) {
bb_simple_perror_msg(filename);
G.status = EXIT_FAILURE;
return 0;
}
- if (option_mask32 & OPT_x_one_FS) {
+ if (G.one_file_system) {
if (G.du_depth == 0) {
G.dir_dev = statbuf.st_dev;
} else if (G.dir_dev != statbuf.st_dev) {
return 0;
}
}
sum = statbuf.st_blocks;
if (S_ISLNK(statbuf.st_mode)) {
- if (G.slink_depth > G.du_depth) { /* -H or -L */
+ if (G.slink_depth > G.du_depth) { /* -H or -L */
if (stat(filename, &statbuf) != 0) {
bb_simple_perror_msg(filename);
G.status = EXIT_FAILURE;
return 0;
}
sum = statbuf.st_blocks;
if (G.slink_depth == 1) {
- /* Convert -H to -L */
- G.slink_depth = INT_MAX;
+ G.slink_depth = INT_MAX; /* Convert -H to -L. */
}
}
}
- if (!(option_mask32 & OPT_l_hardlinks)
- && statbuf.st_nlink > 1
- ) {
+ if (statbuf.st_nlink > G.count_hardlinks) {
/* Add files/directories with links only once */
if (is_in_ino_dev_hashtable(&statbuf)) {
return 0;
}
add_to_ino_dev_hashtable(&statbuf, NULL);
}
@@ -124,88 +112,112 @@ static unsigned long du(const char *filename)
dir = warn_opendir(filename);
if (!dir) {
G.status = EXIT_FAILURE;
return sum;
}
+ newfile = last_char_is(filename, '/');
+ if (newfile)
+ *newfile = '\0';
+
while ((entry = readdir(dir))) {
- newfile = concat_subpath_file(filename, entry->d_name);
+ char *name = entry->d_name;
+
+ newfile = concat_subpath_file(filename, name);
if (newfile == NULL)
continue;
++G.du_depth;
sum += du(newfile);
--G.du_depth;
free(newfile);
}
closedir(dir);
- } else {
- if (!(option_mask32 & OPT_a_files_too) && G.du_depth != 0)
- return sum;
+ } else if (G.du_depth > G.print_files) {
+ return sum;
}
if (G.du_depth <= G.max_print_depth) {
print(sum, filename);
}
return sum;
}
int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int du_main(int argc UNUSED_PARAM, char **argv)
{
unsigned long total;
int slink_depth_save;
+ bool print_final_total;
unsigned opt;
#if ENABLE_FEATURE_HUMAN_READABLE
USE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
SKIP_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
G.disp_hr = 512;
#else
USE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
/* SKIP_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 0;) - G is pre-zeroed */
#endif
G.max_print_depth = INT_MAX;
+ G.count_hardlinks = 1;
/* Note: SUSv3 specifies that -a and -s options cannot be used together
* in strictly conforming applications. However, it also says that some
* du implementations may produce output when -a and -s are used together.
* gnu du exits with an error code in this case. We choose to simply
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
argv += optind;
- if (opt & OPT_h_for_humans) {
+ if (opt & (1 << 9)) {
+ /* -h opt */
G.disp_hr = 0;
}
- if (opt & OPT_m_mbytes) {
+ if (opt & (1 << 10)) {
+ /* -m opt */
G.disp_hr = 1024*1024;
}
- if (opt & OPT_k_kbytes) {
+ if (opt & (1 << 2)) {
+ /* -k opt */
G.disp_hr = 1024;
}
#else
opt_complementary = "H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
argv += optind;
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
- if (opt & OPT_k_kbytes) {
+ if (opt & (1 << 2)) {
+ /* -k opt */
G.disp_k = 1;
}
#endif
#endif
- if (opt & OPT_H_follow_links) {
+ if (opt & (1 << 0)) {
+ /* -a opt */
+ G.print_files = INT_MAX;
+ }
+ if (opt & (1 << 1)) {
+ /* -H opt */
G.slink_depth = 1;
}
- if (opt & OPT_L_follow_links) {
+ if (opt & (1 << 3)) {
+ /* -L opt */
G.slink_depth = INT_MAX;
}
- if (opt & OPT_s_total_norecurse) {
+ if (opt & (1 << 4)) {
+ /* -s opt */
G.max_print_depth = 0;
}
+ G.one_file_system = opt & (1 << 5); /* -x opt */
+ if (opt & (1 << 7)) {
+ /* -l opt */
+ G.count_hardlinks = MAXINT(nlink_t);
+ }
+ print_final_total = opt & (1 << 8); /* -c opt */
/* go through remaining args (if any) */
if (!*argv) {
*--argv = (char*)".";
if (G.slink_depth == 1) {
G.slink_depth = 0;
@@ -213,16 +225,16 @@ int du_main(int argc UNUSED_PARAM, char **argv)
}
slink_depth_save = G.slink_depth;
total = 0;
do {
total += du(*argv);
- /* otherwise du /dir /dir won't show /dir twice: */
- reset_ino_dev_hashtable();
G.slink_depth = slink_depth_save;
} while (*++argv);
- if (opt & OPT_c_total)
+ if (ENABLE_FEATURE_CLEAN_UP)
+ reset_ino_dev_hashtable();
+ if (print_final_total)
print(total, "total");
fflush_stdout_and_exit(G.status);
}
diff --git a/coreutils/env.c b/coreutils/env.c
index f50a03e8b..2f8c8b71d 100644
--- a/coreutils/env.c
+++ b/coreutils/env.c
@@ -40,12 +40,14 @@ static const char env_longopts[] ALIGN1 =
;
#endif
int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int env_main(int argc UNUSED_PARAM, char **argv)
{
+ /* cleanenv was static - why? */
+ char *cleanenv[1];
char **ep;
unsigned opt;
llist_t *unset_env = NULL;
opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -55,22 +57,18 @@ int env_main(int argc UNUSED_PARAM, char **argv)
argv += optind;
if (*argv && LONE_DASH(argv[0])) {
opt |= 1;
++argv;
}
if (opt & 1) {
- clearenv();
- }
- while (unset_env) {
- char *var = llist_pop(&unset_env);
- /* This does not handle -uVAR=VAL
- * (coreutils _sets_ the variable in that case): */
- /*unsetenv(var);*/
- /* This does, but uses somewhan undocumented feature that
- * putenv("name_without_equal_sign") unsets the variable: */
- putenv(var);
+ cleanenv[0] = NULL;
+ environ = cleanenv;
+ } else {
+ while (unset_env) {
+ unsetenv(llist_pop(&unset_env));
+ }
}
while (*argv && (strchr(*argv, '=') != NULL)) {
if (putenv(*argv) < 0) {
bb_perror_msg_and_die("putenv");
}
diff --git a/coreutils/expand.c b/coreutils/expand.c
index 0967e2534..ee51c032f 100644
--- a/coreutils/expand.c
+++ b/coreutils/expand.c
@@ -26,84 +26,104 @@
enum {
OPT_INITIAL = 1 << 0,
OPT_TABS = 1 << 1,
OPT_ALL = 1 << 2,
};
+static void xputchar(char c)
+{
+ if (putchar(c) < 0)
+ bb_error_msg_and_die(bb_msg_write_error);
+}
+
#if ENABLE_EXPAND
-static void expand(FILE *file, int tab_size, unsigned opt)
+static void expand(FILE *file, unsigned tab_size, unsigned opt)
{
char *line;
+ char *ptr;
+ int convert;
+ unsigned pos;
- tab_size = -tab_size;
+ /* Increment tab_size by 1 locally.*/
+ tab_size++;
while ((line = xmalloc_fgets(file)) != NULL) {
- int pos;
- unsigned char c;
- char *ptr = line;
-
- goto start;
- while ((c = *ptr) != '\0') {
- if ((opt & OPT_INITIAL) && !isblank(c)) {
- fputs(ptr, stdout);
- break;
+ convert = 1;
+ pos = 0;
+ ptr = line;
+ while (*line) {
+ pos++;
+ if (*line == '\t' && convert) {
+ for (; pos < tab_size; pos++) {
+ xputchar(' ');
+ }
+ } else {
+ if ((opt & OPT_INITIAL) && !isblank(*line)) {
+ convert = 0;
+ }
+ xputchar(*line);
}
- ptr++;
- if (c == '\t') {
- c = ' ';
- while (++pos < 0)
- bb_putchar(c);
- }
- bb_putchar(c);
- if (++pos >= 0) {
- start:
- pos = tab_size;
+ if (pos == tab_size) {
+ pos = 0;
}
+ line++;
}
- free(line);
+ free(ptr);
}
}
#endif
#if ENABLE_UNEXPAND
-static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
+static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
{
char *line;
+ char *ptr;
+ int convert;
+ int pos;
+ int i = 0;
+ unsigned column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
- char *ptr = line;
- unsigned column = 0;
-
- while (*ptr) {
- unsigned n;
-
- while (*ptr == ' ') {
+ convert = 1;
+ pos = 0;
+ ptr = line;
+ while (*line) {
+ while ((*line == ' ' || *line == '\t') && convert) {
+ pos += (*line == ' ') ? 1 : tab_size;
+ line++;
column++;
- ptr++;
- }
- if (*ptr == '\t') {
- column += tab_size - (column % tab_size);
- ptr++;
- continue;
+ if ((opt & OPT_ALL) && column == tab_size) {
+ column = 0;
+ goto put_tab;
+ }
}
-
- n = column / tab_size;
- column = column % tab_size;
- while (n--)
- putchar('\t');
-
- if ((opt & OPT_INITIAL) && ptr != line) {
- printf("%*s%s", column, "", ptr);
- break;
+ if (pos) {
+ i = pos / tab_size;
+ if (i) {
+ for (; i > 0; i--) {
+ put_tab:
+ xputchar('\t');
+ }
+ } else {
+ for (i = pos % tab_size; i > 0; i--) {
+ xputchar(' ');
+ }
+ }
+ pos = 0;
+ } else {
+ if (opt & OPT_INITIAL) {
+ convert = 0;
+ }
+ if (opt & OPT_ALL) {
+ column++;
+ }
+ xputchar(*line);
+ line++;
}
- n = strcspn(ptr, "\t ");
- printf("%*s%.*s", column, "", n, ptr);
- ptr += n;
- column = (column + n) % tab_size;
}
- free(line);
+ free(ptr);
}
}
#endif
int expand_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int expand_main(int argc UNUSED_PARAM, char **argv)
diff --git a/coreutils/expr.c b/coreutils/expr.c
index 54c2ee165..2f9c5c1e3 100644
--- a/coreutils/expr.c
+++ b/coreutils/expr.c
@@ -220,41 +220,41 @@ static VALUE *docolon(VALUE *sv, VALUE *pv)
regmatch_t re_regs[NMATCH];
tostring(sv);
tostring(pv);
if (pv->u.s[0] == '^') {
- bb_error_msg(
-"warning: '%s': using '^' as the first character\n"
-"of a basic regular expression is not portable; it is ignored", pv->u.s);
+ bb_error_msg("\
+warning: unportable BRE: `%s': using `^' as the first character\n\
+of a basic regular expression is not portable; it is being ignored", pv->u.s);
}
memset(&re_buffer, 0, sizeof(re_buffer));
- memset(re_regs, 0, sizeof(re_regs));
+ memset(re_regs, 0, sizeof(*re_regs));
xregcomp(&re_buffer, pv->u.s, 0);
/* expr uses an anchored pattern match, so check that there was a
* match and that the match starts at offset 0. */
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH
&& re_regs[0].rm_so == 0
) {
/* Were \(...\) used? */
- if (re_buffer.re_nsub > 0 && re_regs[1].rm_so >= 0) {
+ if (re_buffer.re_nsub > 0) {
sv->u.s[re_regs[1].rm_eo] = '\0';
v = str_value(sv->u.s + re_regs[1].rm_so);
} else {
v = int_value(re_regs[0].rm_eo);
}
} else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
v = str_value("");
else
v = int_value(0);
}
- regfree(&re_buffer);
+//FIXME: sounds like here is a bit missing: regfree(&re_buffer);
return v;
}
/* Handle bare operands and ( expr ) syntax. */
static VALUE *eval7(void)
@@ -478,24 +478,27 @@ static VALUE *eval(void)
freev(r);
}
return l;
}
int expr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int expr_main(int argc UNUSED_PARAM, char **argv)
+int expr_main(int argc, char **argv)
{
VALUE *v;
- xfunc_error_retval = 2; /* coreutils compat */
- G.args = argv + 1;
- if (*G.args == NULL) {
+ if (argc == 1) {
bb_error_msg_and_die("too few arguments");
}
+
+ G.args = argv + 1;
+
v = eval();
if (*G.args)
bb_error_msg_and_die("syntax error");
+
if (v->type == INTEGER)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
+
fflush_stdout_and_exit(null(v));
}
diff --git a/coreutils/head.c b/coreutils/head.c
index ac476d091..570f140b1 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -37,22 +37,23 @@ int head_main(int argc, char **argv)
unsigned long count = 10;
unsigned long i;
#if ENABLE_FEATURE_FANCY_HEAD
int count_bytes = 0;
int header_threshhold = 1;
#endif
+
FILE *fp;
const char *fmt;
char *p;
int opt;
int c;
int retval = EXIT_SUCCESS;
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
/* Allow legacy syntax of an initial numeric option without -n. */
- if (argv[1] && argv[1][0] == '-'
+ if (argc > 1 && argv[1][0] == '-'
&& isdigit(argv[1][1])
) {
--argc;
++argv;
p = (*argv) + 1;
goto GET_COUNT;
@@ -75,12 +76,13 @@ int head_main(int argc, char **argv)
#endif
case 'n':
p = optarg;
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
GET_COUNT:
#endif
+
#if !ENABLE_FEATURE_FANCY_HEAD
count = xatoul(p);
#else
count = xatoul_sfx(p, head_suffixes);
#endif
break;
@@ -123,18 +125,16 @@ int head_main(int argc, char **argv)
if (count_bytes || (c == '\n')) {
--i;
}
putchar(c);
}
if (fclose_if_not_stdin(fp)) {
- bb_simple_perror_msg(*argv);
+ bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
retval = EXIT_FAILURE;
}
die_if_ferror_stdout();
- } else {
- retval = EXIT_FAILURE;
}
fmt = header_fmt_str;
} while (*++argv);
fflush_stdout_and_exit(retval);
}
diff --git a/coreutils/id.c b/coreutils/id.c
index 43f403fa3..6ddb23666 100644
--- a/coreutils/id.c
+++ b/coreutils/id.c
@@ -33,14 +33,18 @@ enum {
JUST_ALL_GROUPS = (1 << 4),
#if ENABLE_SELINUX
JUST_CONTEXT = (1 << 5),
#endif
};
-static int print_common(unsigned id, const char *name, const char *prefix)
+static int print_common(unsigned id,
+ char* FAST_FUNC bb_getXXXid(char *name, int bufsize, long uid),
+ const char *prefix)
{
+ const char *name = bb_getXXXid(NULL, 0, id);
+
if (prefix) {
printf("%s", prefix);
}
if (!(option_mask32 & NAME_NOT_NUMBER) || !name) {
printf("%u", id);
}
@@ -58,18 +62,18 @@ static int print_common(unsigned id, const char *name, const char *prefix)
}
return EXIT_SUCCESS;
}
static int print_group(gid_t id, const char *prefix)
{
- return print_common(id, gid2group(id), prefix);
+ return print_common(id, bb_getgrgid, prefix);
}
static int print_user(uid_t id, const char *prefix)
{
- return print_common(id, uid2uname(id), prefix);
+ return print_common(id, bb_getpwuid, prefix);
}
/* On error set *n < 0 and return >= 0
* If *n is too small, update it and return < 0
* (ok to trash groups[] in both cases)
* Otherwise fill in groups[] and return >= 0
@@ -121,13 +125,15 @@ int id_main(int argc UNUSED_PARAM, char **argv)
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
USE_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
opt = getopt32(argv, "rnugG" USE_SELINUX("Z"));
username = argv[optind];
if (username) {
- struct passwd *p = xgetpwnam(username);
+ struct passwd *p = getpwnam(username);
+ if (!p)
+ bb_error_msg_and_die("unknown user %s", username);
euid = ruid = p->pw_uid;
egid = rgid = p->pw_gid;
} else {
egid = getegid();
rgid = getgid();
euid = geteuid();
diff --git a/coreutils/length.c b/coreutils/length.c
index 43a0f5988..c7523a02a 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -1,10 +1,7 @@
/* vi: set sw=4 ts=4: */
-/*
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
- */
/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
diff --git a/coreutils/libcoreutils/coreutils.h b/coreutils/libcoreutils/coreutils.h
index 99b67b14d..89cd9532f 100644
--- a/coreutils/libcoreutils/coreutils.h
+++ b/coreutils/libcoreutils/coreutils.h
@@ -1,20 +1,24 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#ifndef COREUTILS_H
-#define COREUTILS_H 1
+#define COREUTILS_H 1
-PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
+#if __GNUC_PREREQ(4,1)
+# pragma GCC visibility push(hidden)
+#endif
typedef int (*stat_func)(const char *fn, struct stat *ps);
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf) FAST_FUNC;
int cp_mv_stat(const char *fn, struct stat *fn_stat) FAST_FUNC;
mode_t getopt_mk_fifo_nod(char **argv) FAST_FUNC;
-POP_SAVED_FUNCTION_VISIBILITY
+#if __GNUC_PREREQ(4,1)
+# pragma GCC visibility pop
+#endif
#endif
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 38957e93d..f4e71bc6a 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -3,61 +3,44 @@
* tiny-ls.c version 0.1.0: A minimalist 'ls'
* Copyright (C) 1996 Brian Candler <B.Candler@pobox.com>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-/* [date unknown. Perhaps before year 2000]
+/*
* To achieve a small memory footprint, this version of 'ls' doesn't do any
* file sorting, and only has the most essential command line switches
* (i.e., the ones I couldn't live without :-) All features which involve
* linking in substantial chunks of libc can be disabled.
*
* Although I don't really want to add new features to this program to
* keep it small, I *am* interested to receive bug fixes and ways to make
* it more portable.
*
* KNOWN BUGS:
* 1. ls -l of a directory doesn't give "total <blocks>" header
- * 2. hidden files can make column width too large
+ * 2. ls of a symlink to a directory doesn't list directory contents
+ * 3. hidden files can make column width too large
*
* NON-OPTIMAL BEHAVIOUR:
* 1. autowidth reads directories twice
* 2. if you do a short directory listing without filetype characters
* appended, there's no need to stat each one
* PORTABILITY:
* 1. requires lstat (BSD) - how do you do it without?
- *
- * [2009-03]
- * ls sorts listing now, and supports almost all options.
*/
#include "libbb.h"
#if ENABLE_FEATURE_ASSUME_UNICODE
#include <wchar.h>
#endif
/* This is a NOEXEC applet. Be very careful! */
-#if ENABLE_FTPD
-/* ftpd uses ls, and without timestamps Mozilla won't understand
- * ftpd's LIST output.
- */
-# undef CONFIG_FEATURE_LS_TIMESTAMPS
-# undef ENABLE_FEATURE_LS_TIMESTAMPS
-# undef USE_FEATURE_LS_TIMESTAMPS
-# undef SKIP_FEATURE_LS_TIMESTAMPS
-# define CONFIG_FEATURE_LS_TIMESTAMPS 1
-# define ENABLE_FEATURE_LS_TIMESTAMPS 1
-# define USE_FEATURE_LS_TIMESTAMPS(...) __VA_ARGS__
-# define SKIP_FEATURE_LS_TIMESTAMPS(...)
-#endif
-
-
enum {
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
COLUMN_GAP = 2, /* includes the file type char */
/* what is the overall style of the listing */
@@ -73,13 +56,13 @@ LIST_BLOCKS = 1 << 1,
LIST_MODEBITS = 1 << 2,
LIST_NLINKS = 1 << 3,
LIST_ID_NAME = 1 << 4,
LIST_ID_NUMERIC = 1 << 5,
LIST_CONTEXT = 1 << 6,
LIST_SIZE = 1 << 7,
-//LIST_DEV = 1 << 8, - unused, synonym to LIST_SIZE
+LIST_DEV = 1 << 8,
LIST_DATE_TIME = 1 << 9,
LIST_FULLTIME = 1 << 10,
LIST_FILENAME = 1 << 11,
LIST_SYMLINK = 1 << 12,
LIST_FILETYPE = 1 << 13,
LIST_EXEC = 1 << 14,
@@ -124,117 +107,19 @@ LIST_LONG = LIST_MODEBITS | LIST_NLINKS | LIST_ID_NAME | LIST_SIZE | \
SPLIT_DIR = 1,
SPLIT_FILE = 0,
SPLIT_SUBDIR = 2,
};
-/* "[-]Cadil1", POSIX mandated options, busybox always supports */
-/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
-/* "[-]Q" GNU option? busybox always supports */
-/* "[-]Ak" GNU options, busybox always supports */
-/* "[-]FLRctur", POSIX mandated options, busybox optionally supports */
-/* "[-]p", POSIX non-mandated options, busybox optionally supports */
-/* "[-]SXvThw", GNU options, busybox optionally supports */
-/* "[-]K", SELinux mandated options, busybox optionally supports */
-/* "[-]e", I think we made this one up */
-static const char ls_options[] ALIGN1 =
- "Cadil1gnsxQAk" /* 13 opts, total 13 */
- USE_FEATURE_LS_TIMESTAMPS("cetu") /* 4, 17 */
- USE_FEATURE_LS_SORTFILES("SXrv") /* 4, 21 */
- USE_FEATURE_LS_FILETYPES("Fp") /* 2, 23 */
- USE_FEATURE_LS_FOLLOWLINKS("L") /* 1, 24 */
- USE_FEATURE_LS_RECURSIVE("R") /* 1, 25 */
- USE_FEATURE_HUMAN_READABLE("h") /* 1, 26 */
- USE_SELINUX("KZ") /* 2, 28 */
- USE_FEATURE_AUTOWIDTH("T:w:") /* 2, 30 */
- ;
-enum {
- //OPT_C = (1 << 0),
- //OPT_a = (1 << 1),
- //OPT_d = (1 << 2),
- //OPT_i = (1 << 3),
- //OPT_l = (1 << 4),
- //OPT_1 = (1 << 5),
- OPT_g = (1 << 6),
- //OPT_n = (1 << 7),
- //OPT_s = (1 << 8),
- //OPT_x = (1 << 9),
- OPT_Q = (1 << 10),
- //OPT_A = (1 << 11),
- //OPT_k = (1 << 12),
- OPTBIT_color = 13
- + 4 * ENABLE_FEATURE_LS_TIMESTAMPS
- + 4 * ENABLE_FEATURE_LS_SORTFILES
- + 2 * ENABLE_FEATURE_LS_FILETYPES
- + 1 * ENABLE_FEATURE_LS_FOLLOWLINKS
- + 1 * ENABLE_FEATURE_LS_RECURSIVE
- + 1 * ENABLE_FEATURE_HUMAN_READABLE
- + 2 * ENABLE_SELINUX
- + 2 * ENABLE_FEATURE_AUTOWIDTH,
- OPT_color = 1 << OPTBIT_color,
-};
-
-enum {
- LIST_MASK_TRIGGER = 0,
- STYLE_MASK_TRIGGER = STYLE_MASK,
- DISP_MASK_TRIGGER = DISP_ROWS,
- SORT_MASK_TRIGGER = SORT_MASK,
-};
-
-/* TODO: simple toggles may be stored as OPT_xxx bits instead */
-static const unsigned opt_flags[] = {
- LIST_SHORT | STYLE_COLUMNS, /* C */
- DISP_HIDDEN | DISP_DOT, /* a */
- DISP_NOLIST, /* d */
- LIST_INO, /* i */
- LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */
- LIST_SHORT | STYLE_SINGLE, /* 1 */
- 0, /* g (don't show group) - handled via OPT_g */
- LIST_ID_NUMERIC, /* n */
- LIST_BLOCKS, /* s */
- DISP_ROWS, /* x */
- 0, /* Q (quote filename) - handled via OPT_Q */
- DISP_HIDDEN, /* A */
- ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
-#if ENABLE_FEATURE_LS_TIMESTAMPS
- TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
- LIST_FULLTIME, /* e */
- ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
- TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
-#endif
-#if ENABLE_FEATURE_LS_SORTFILES
- SORT_SIZE, /* S */
- SORT_EXT, /* X */
- SORT_REVERSE, /* r */
- SORT_VERSION, /* v */
-#endif
-#if ENABLE_FEATURE_LS_FILETYPES
- LIST_FILETYPE | LIST_EXEC, /* F */
- LIST_FILETYPE, /* p */
-#endif
-#if ENABLE_FEATURE_LS_FOLLOWLINKS
- FOLLOW_LINKS, /* L */
-#endif
-#if ENABLE_FEATURE_LS_RECURSIVE
- DISP_RECURSIVE, /* R */
-#endif
-#if ENABLE_FEATURE_HUMAN_READABLE
- LS_DISP_HR, /* h */
-#endif
-#if ENABLE_SELINUX
- LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
-#endif
-#if ENABLE_SELINUX
- LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */
-#endif
- (1U<<31)
- /* options after Z are not processed through opt_flags:
- * T, w - ignored
- */
-};
-
+#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
+#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
+#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
+#define COLOR(mode) ("\000\043\043\043\042\000\043\043"\
+ "\000\000\044\000\043\000\000\040" [TYPEINDEX(mode)])
+#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
+ "\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
/*
* a directory entry and its stat info are stored here
*/
struct dnode { /* the basic node */
const char *name; /* the dir entry name */
@@ -342,52 +227,24 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
cur->name = name;
cur->dstat = dstat;
USE_SELINUX(cur->sid = sid;)
return cur;
}
-
-/* FYI type values: 1:fifo 2:char 4:dir 6:blk 8:file 10:link 12:socket
- * (various wacky OSes: 13:Sun door 14:BSD whiteout 5:XENIX named file
- * 3/7:multiplexed char/block device)
- * and we use 0 for unknown and 15 for executables (see below) */
-#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
-#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
-#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
-/* 036 black foreground 050 black background
- 037 red foreground 051 red background
- 040 green foreground 052 green background
- 041 brown foreground 053 brown background
- 042 blue foreground 054 blue background
- 043 magenta (purple) foreground 055 magenta background
- 044 cyan (light blue) foreground 056 cyan background
- 045 gray foreground 057 white background
-*/
-#define COLOR(mode) ( \
- /*un fi chr dir blk file link sock exe */ \
- "\037\043\043\045\042\045\043\043\000\045\044\045\043\045\045\040" \
- [TYPEINDEX(mode)])
-/* Select normal (0) [actually "reset all"] or bold (1)
- * (other attributes are 2:dim 4:underline 5:blink 7:reverse,
- * let's use 7 for "impossible" types, just for fun)
- * Note: coreutils 6.9 uses inverted red for setuid binaries.
- */
-#define ATTR(mode) ( \
- /*un fi chr dir blk file link sock exe */ \
- "\01\00\01\07\01\07\01\07\00\07\01\07\01\07\07\01" \
- [TYPEINDEX(mode)])
-
#if ENABLE_FEATURE_LS_COLOR
-/* mode of zero is interpreted as "unknown" (stat failed) */
static char fgcolor(mode_t mode)
{
+ /* Check wheter the file is existing (if so, color it red!) */
+ if (errno == ENOENT)
+ return '\037';
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return COLOR(0xF000); /* File is executable ... */
return COLOR(mode);
}
-static char bold(mode_t mode)
+
+static char bgcolor(mode_t mode)
{
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return ATTR(0xF000); /* File is executable ... */
return ATTR(mode);
}
#endif
@@ -404,13 +261,12 @@ static char append_char(mode_t mode)
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return '*';
return APPCHAR(mode);
}
#endif
-
#define countdirs(A, B) count_dirs((A), (B), 1)
#define countsubdirs(A, B) count_dirs((A), (B), 0)
static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs)
{
int i, dirs;
@@ -714,47 +570,16 @@ static struct dnode **list_dir(const char *path)
}
return dnp;
}
-static int print_name(const char *name)
-{
- if (option_mask32 & OPT_Q) {
-#if ENABLE_FEATURE_ASSUME_UNICODE
- int len = 2 + mbstrlen(name);
-#else
- int len = 2;
-#endif
- putchar('"');
- while (*name) {
- if (*name == '"') {
- putchar('\\');
- len++;
- }
- putchar(*name++);
- if (!ENABLE_FEATURE_ASSUME_UNICODE)
- len++;
- }
- putchar('"');
- return len;
- }
- /* No -Q: */
-#if ENABLE_FEATURE_ASSUME_UNICODE
- fputs(name, stdout);
- return mbstrlen(name);
-#else
- return printf("%s", name);
-#endif
-}
-
-
static int list_single(const struct dnode *dn)
{
- int column = 0;
- char *lpath = lpath; /* for compiler */
+ int i, column = 0;
+
#if ENABLE_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
#endif
#if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR
struct stat info;
@@ -773,165 +598,250 @@ static int list_single(const struct dnode *dn)
filetime = ctime(&ttime);
#endif
#if ENABLE_FEATURE_LS_FILETYPES
append = append_char(dn->dstat.st_mode);
#endif
- /* Do readlink early, so that if it fails, error message
- * does not appear *inside* of the "ls -l" line */
- if (all_fmt & LIST_SYMLINK)
- if (S_ISLNK(dn->dstat.st_mode))
- lpath = xmalloc_readlink_or_warn(dn->fullname);
-
- if (all_fmt & LIST_INO)
- column += printf("%7lu ", (long) dn->dstat.st_ino);
- if (all_fmt & LIST_BLOCKS)
- column += printf("%4"OFF_FMT"u ", (off_t) dn->dstat.st_blocks >> 1);
- if (all_fmt & LIST_MODEBITS)
- column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
- if (all_fmt & LIST_NLINKS)
- column += printf("%4lu ", (long) dn->dstat.st_nlink);
+ for (i = 0; i <= 31; i++) {
+ switch (all_fmt & (1 << i)) {
+ case LIST_INO:
+ column += printf("%7ld ", (long) dn->dstat.st_ino);
+ break;
+ case LIST_BLOCKS:
+ column += printf("%4"OFF_FMT"d ", (off_t) dn->dstat.st_blocks >> 1);
+ break;
+ case LIST_MODEBITS:
+ column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
+ break;
+ case LIST_NLINKS:
+ column += printf("%4ld ", (long) dn->dstat.st_nlink);
+ break;
+ case LIST_ID_NAME:
#if ENABLE_FEATURE_LS_USERNAME
- if (all_fmt & LIST_ID_NAME) {
- if (option_mask32 & OPT_g) {
- column += printf("%-8.8s",
- get_cached_username(dn->dstat.st_uid));
- } else {
- column += printf("%-8.8s %-8.8s",
+ printf("%-8.8s %-8.8s",
get_cached_username(dn->dstat.st_uid),
get_cached_groupname(dn->dstat.st_gid));
- }
- }
-#endif
- if (all_fmt & LIST_ID_NUMERIC) {
- if (option_mask32 & OPT_g)
- column += printf("%-8u", (int) dn->dstat.st_uid);
- else
- column += printf("%-8u %-8u",
- (int) dn->dstat.st_uid,
- (int) dn->dstat.st_gid);
- }
- if (all_fmt & (LIST_SIZE /*|LIST_DEV*/ )) {
- if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
- column += printf("%4u, %3u ",
- (int) major(dn->dstat.st_rdev),
- (int) minor(dn->dstat.st_rdev));
- } else {
- if (all_fmt & LS_DISP_HR) {
- column += printf("%9s ",
- make_human_readable_str(dn->dstat.st_size, 1, 0));
+ column += 17;
+ break;
+#endif
+ case LIST_ID_NUMERIC:
+ column += printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
+ break;
+ case LIST_SIZE:
+ case LIST_DEV:
+ if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
+ column += printf("%4d, %3d ", (int) major(dn->dstat.st_rdev),
+ (int) minor(dn->dstat.st_rdev));
} else {
- column += printf("%9"OFF_FMT"u ", (off_t) dn->dstat.st_size);
+ if (all_fmt & LS_DISP_HR) {
+ column += printf("%9s ",
+ make_human_readable_str(dn->dstat.st_size, 1, 0));
+ } else {
+ column += printf("%9"OFF_FMT"d ", (off_t) dn->dstat.st_size);
+ }
}
- }
- }
+ break;
#if ENABLE_FEATURE_LS_TIMESTAMPS
- if (all_fmt & LIST_FULLTIME)
- column += printf("%24.24s ", filetime);
- if (all_fmt & LIST_DATE_TIME)
- if ((all_fmt & LIST_FULLTIME) == 0) {
- /* current_time_t ~== time(NULL) */
- age = current_time_t - ttime;
- printf("%6.6s ", filetime + 4);
- if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
- /* hh:mm if less than 6 months old */
- printf("%5.5s ", filetime + 11);
- } else {
- printf(" %4.4s ", filetime + 20);
+ case LIST_FULLTIME:
+ printf("%24.24s ", filetime);
+ column += 25;
+ break;
+ case LIST_DATE_TIME:
+ if ((all_fmt & LIST_FULLTIME) == 0) {
+ /* current_time_t ~== time(NULL) */
+ age = current_time_t - ttime;
+ printf("%6.6s ", filetime + 4);
+ if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
+ /* hh:mm if less than 6 months old */
+ printf("%5.5s ", filetime + 11);
+ } else {
+ printf(" %4.4s ", filetime + 20);
+ }
+ column += 13;
}
- column += 13;
- }
+ break;
#endif
#if ENABLE_SELINUX
- if (all_fmt & LIST_CONTEXT) {
- column += printf("%-32s ", dn->sid ? dn->sid : "unknown");
- freecon(dn->sid);
- }
+ case LIST_CONTEXT:
+ {
+ char context[80];
+ int len = 0;
+
+ if (dn->sid) {
+ /* I assume sid initilized with NULL */
+ len = strlen(dn->sid) + 1;
+ safe_strncpy(context, dn->sid, len);
+ freecon(dn->sid);
+ } else {
+ safe_strncpy(context, "unknown", 8);
+ }
+ printf("%-32s ", context);
+ column += MAX(33, len);
+ }
+ break;
#endif
- if (all_fmt & LIST_FILENAME) {
+ case LIST_FILENAME:
+ errno = 0;
#if ENABLE_FEATURE_LS_COLOR
- if (show_color) {
- info.st_mode = 0; /* for fgcolor() */
- lstat(dn->fullname, &info);
- printf("\033[%u;%um", bold(info.st_mode),
- fgcolor(info.st_mode));
- }
+ if (show_color && !lstat(dn->fullname, &info)) {
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }
#endif
- column += print_name(dn->name);
- if (show_color) {
- printf("\033[0m");
- }
- }
- if (all_fmt & LIST_SYMLINK) {
- if (S_ISLNK(dn->dstat.st_mode) && lpath) {
- printf(" -> ");
-#if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR
-#if ENABLE_FEATURE_LS_COLOR
- info.st_mode = 0; /* for fgcolor() */
+#if ENABLE_FEATURE_ASSUME_UNICODE
+ printf("%s", dn->name);
+ column += mbstrlen(dn->name);
+#else
+ column += printf("%s", dn->name);
#endif
- if (stat(dn->fullname, &info) == 0) {
- append = append_char(info.st_mode);
+ if (show_color) {
+ printf("\033[0m");
}
+ break;
+ case LIST_SYMLINK:
+ if (S_ISLNK(dn->dstat.st_mode)) {
+ char *lpath = xmalloc_readlink_or_warn(dn->fullname);
+ if (!lpath) break;
+ printf(" -> ");
+#if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR
+ if (!stat(dn->fullname, &info)) {
+ append = append_char(info.st_mode);
+ }
#endif
#if ENABLE_FEATURE_LS_COLOR
- if (show_color) {
- printf("\033[%u;%um", bold(info.st_mode),
- fgcolor(info.st_mode));
- }
+ if (show_color) {
+ errno = 0;
+ printf("\033[%d;%dm", bgcolor(info.st_mode),
+ fgcolor(info.st_mode));
+ }
#endif
- column += print_name(lpath) + 4;
- if (show_color) {
- printf("\033[0m");
+ column += printf("%s", lpath) + 4;
+ if (show_color) {
+ printf("\033[0m");
+ }
+ free(lpath);
}
- free(lpath);
- }
- }
+ break;
#if ENABLE_FEATURE_LS_FILETYPES
- if (all_fmt & LIST_FILETYPE) {
- if (append) {
- putchar(append);
- column++;
+ case LIST_FILETYPE:
+ if (append) {
+ putchar(append);
+ column++;
+ }
+ break;
+#endif
}
}
-#endif
return column;
}
+/* "[-]Cadil1", POSIX mandated options, busybox always supports */
+/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
+/* "[-]Ak" GNU options, busybox always supports */
+/* "[-]FLRctur", POSIX mandated options, busybox optionally supports */
+/* "[-]p", POSIX non-mandated options, busybox optionally supports */
+/* "[-]SXvThw", GNU options, busybox optionally supports */
+/* "[-]K", SELinux mandated options, busybox optionally supports */
+/* "[-]e", I think we made this one up */
+static const char ls_options[] ALIGN1 =
+ "Cadil1gnsxAk"
+ USE_FEATURE_LS_TIMESTAMPS("cetu")
+ USE_FEATURE_LS_SORTFILES("SXrv")
+ USE_FEATURE_LS_FILETYPES("Fp")
+ USE_FEATURE_LS_FOLLOWLINKS("L")
+ USE_FEATURE_LS_RECURSIVE("R")
+ USE_FEATURE_HUMAN_READABLE("h")
+ USE_SELINUX("K")
+ USE_FEATURE_AUTOWIDTH("T:w:")
+ USE_SELINUX("Z");
+
+enum {
+ LIST_MASK_TRIGGER = 0,
+ STYLE_MASK_TRIGGER = STYLE_MASK,
+ DISP_MASK_TRIGGER = DISP_ROWS,
+ SORT_MASK_TRIGGER = SORT_MASK,
+};
+
+static const unsigned opt_flags[] = {
+ LIST_SHORT | STYLE_COLUMNS, /* C */
+ DISP_HIDDEN | DISP_DOT, /* a */
+ DISP_NOLIST, /* d */
+ LIST_INO, /* i */
+ LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */
+ LIST_SHORT | STYLE_SINGLE, /* 1 */
+ 0, /* g - ingored */
+ LIST_ID_NUMERIC, /* n */
+ LIST_BLOCKS, /* s */
+ DISP_ROWS, /* x */
+ DISP_HIDDEN, /* A */
+ ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
+#if ENABLE_FEATURE_LS_TIMESTAMPS
+ TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
+ LIST_FULLTIME, /* e */
+ ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
+ TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
+#endif
+#if ENABLE_FEATURE_LS_SORTFILES
+ SORT_SIZE, /* S */
+ SORT_EXT, /* X */
+ SORT_REVERSE, /* r */
+ SORT_VERSION, /* v */
+#endif
+#if ENABLE_FEATURE_LS_FILETYPES
+ LIST_FILETYPE | LIST_EXEC, /* F */
+ LIST_FILETYPE, /* p */
+#endif
+#if ENABLE_FEATURE_LS_FOLLOWLINKS
+ FOLLOW_LINKS, /* L */
+#endif
+#if ENABLE_FEATURE_LS_RECURSIVE
+ DISP_RECURSIVE, /* R */
+#endif
+#if ENABLE_FEATURE_HUMAN_READABLE
+ LS_DISP_HR, /* h */
+#endif
+#if ENABLE_SELINUX
+ LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
+#endif
+#if ENABLE_FEATURE_AUTOWIDTH
+ 0, 0, /* T, w - ignored */
+#endif
+#if ENABLE_SELINUX
+ LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */
+#endif
+ (1U<<31)
+};
+
+
+/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
+#if ENABLE_FEATURE_LS_COLOR
+/* long option entry used only for --color, which has no short option
+ * equivalent */
+static const char ls_color_opt[] ALIGN1 =
+ "color\0" Optional_argument "\xff" /* no short equivalent */
+ ;
+#endif
+
+
+int ls_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ls_main(int argc UNUSED_PARAM, char **argv)
{
struct dnode **dnd;
struct dnode **dnf;
struct dnode **dnp;
struct dnode *dn;
struct dnode *cur;
unsigned opt;
int nfiles;
int dnfiles;
int dndirs;
int i;
-#if ENABLE_FEATURE_LS_COLOR
- /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
- /* coreutils 6.10:
- * # ls --color=BOGUS
- * ls: invalid argument 'BOGUS' for '--color'
- * Valid arguments are:
- * 'always', 'yes', 'force'
- * 'never', 'no', 'none'
- * 'auto', 'tty', 'if-tty'
- * (and substrings: "--color=alwa" work too)
- */
- static const char ls_longopts[] ALIGN1 =
- "color\0" Optional_argument "\xff"; /* no short equivalent */
- static const char color_str[] ALIGN1 =
- "always\0""yes\0""force\0"
- "auto\0""tty\0""if-tty\0";
/* need to initialize since --color has _an optional_ argument */
- const char *color_opt = color_str; /* "always" */
-#endif
+ USE_FEATURE_LS_COLOR(const char *color_opt = "always";)
INIT_G();
all_fmt = LIST_SHORT |
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));
@@ -940,13 +850,13 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
get_terminal_width_height(STDIN_FILENO, &terminal_width, NULL);
/* Go one less... */
terminal_width--;
#endif
/* process options */
- USE_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
+ USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
#if ENABLE_FEATURE_AUTOWIDTH
opt_complementary = "T+:w+"; /* -T N, -w N */
opt = getopt32(argv, ls_options, &tabstops, &terminal_width
USE_FEATURE_LS_COLOR(, &color_opt));
#else
opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
@@ -979,26 +889,19 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) {
char *p = getenv("LS_COLORS");
/* LS_COLORS is unset, or (not empty && not "none") ? */
if (!p || (p[0] && strcmp(p, "none") != 0))
show_color = 1;
}
- if (opt & OPT_color) {
- if (color_opt[0] == 'n')
+ if (opt & (1 << i)) { /* next flag after short options */
+ if (strcmp("always", color_opt) == 0)
+ show_color = 1;
+ else if (strcmp("never", color_opt) == 0)
show_color = 0;
- else switch (index_in_substrings(color_str, color_opt)) {
- case 3:
- case 4:
- case 5:
- if (isatty(STDOUT_FILENO)) {
- case 0:
- case 1:
- case 2:
- show_color = 1;
- }
- }
+ else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO))
+ show_color = 1;
}
#endif
/* sort out which command line options take precedence */
if (ENABLE_FEATURE_LS_RECURSIVE && (all_fmt & DISP_NOLIST))
all_fmt &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
@@ -1026,14 +929,14 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
/* stuff the command line file names into a dnode array */
dn = NULL;
nfiles = 0;
do {
- /* NB: follow links on command line unless -l or -s */
- cur = my_stat(*argv, *argv, !(all_fmt & (STYLE_LONG|LIST_BLOCKS)));
+ /* ls w/o -l follows links on command line */
+ cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
argv++;
if (!cur)
continue;
cur->allocated = 0;
cur->next = dn;
dn = cur;
diff --git a/coreutils/md5_sha1_sum.c b/coreutils/md5_sha1_sum.c