Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95d1f6d7c7 | ||
|
|
4362200712 | ||
|
|
1e1d232f38 | ||
|
|
235f66dea3 | ||
|
|
d0fa0a12f1 | ||
|
|
02ced93ec2 | ||
|
|
46948366fa | ||
|
|
21125543e1 | ||
|
|
4836fd44f0 | ||
|
|
bd193a42a5 | ||
|
|
77508b29fa | ||
|
|
f361ac29b0 | ||
|
|
483262f633 | ||
|
|
4d4b3b1d88 | ||
|
|
e3a48d865a | ||
|
|
d9d03b83f8 | ||
|
|
b12e506d8d | ||
|
|
69a6b2d4ae | ||
|
|
e48eea63d3 | ||
|
|
a2d61e761e | ||
|
|
5ec241d3b3 | ||
|
|
2d6282bb37 | ||
|
|
d323d32c5b | ||
|
|
5a964f9d0b | ||
|
|
20c2bdd7f2 | ||
|
|
5c365da884 | ||
|
|
4ed17829ac | ||
|
|
b2356f6de9 | ||
|
|
59ec601b8e | ||
|
|
a293a516ad | ||
|
|
394cf22668 | ||
|
|
cf7982e908 | ||
|
|
70d09ed1cf | ||
|
|
9962cd9f78 | ||
|
|
c8eedd56ac | ||
|
|
46f44d24fc | ||
|
|
00732b57c7 | ||
|
|
c52a97d79f | ||
|
|
9df3833370 | ||
|
|
29edd005f9 | ||
|
|
afdde3e356 | ||
|
|
5b5db38a7d | ||
|
|
1bca5ed886 | ||
|
|
8c28fd7849 | ||
|
|
7da312058c | ||
|
|
f21aa84389 | ||
|
|
eb4218d0a4 | ||
|
|
bf2b8ae49a | ||
|
|
76fef0a5d0 | ||
|
|
9cff4fbac9 | ||
|
|
5e09b6e3a8 | ||
|
|
f3b2b52b58 | ||
|
|
f57c944e09 | ||
|
|
7b5c16ebe5 | ||
|
|
87afb526b5 | ||
|
|
1e1d9d1c95 | ||
|
|
da7b82981b | ||
|
|
02553a2a18 | ||
|
|
3d957c87b7 | ||
|
|
6b78fe383f | ||
|
|
1e7cea952b | ||
|
|
bc5941a540 | ||
|
|
bfa54143f6 | ||
|
|
8ffabf5825 | ||
|
|
1d3523b7aa | ||
|
|
21adca750a | ||
|
|
e884970c87 | ||
|
|
92ed8a3519 | ||
|
|
ab147f608d | ||
|
|
26a3adb244 | ||
|
|
deb9d4d765 | ||
|
|
4758368505 | ||
|
|
cf61fe14ae | ||
|
|
d27753afd9 | ||
|
|
0e836ed8db | ||
|
|
2187adc619 | ||
|
|
8cede00b9e | ||
|
|
f484e7e65c | ||
|
|
868c057d25 | ||
|
|
e73fda8311 | ||
|
|
29be79c5f6 | ||
|
|
4c45e0991a | ||
|
|
b8b8d81c24 | ||
|
|
4d449c42f2 | ||
|
|
e2f6e12213 | ||
|
|
09a34e5368 | ||
|
|
02f3b2e0c8 | ||
|
|
87559829ff | ||
|
|
3e856ce428 | ||
|
|
b558e76eb1 | ||
|
|
cabafae7b0 | ||
|
|
c119ab9e29 | ||
|
|
8c725e624a | ||
|
|
8c2d3f46ab | ||
|
|
9bd71e8323 | ||
|
|
8fff78d66e | ||
|
|
ddea368dbe | ||
|
|
618e8ed4c4 | ||
|
|
0730943b49 | ||
|
|
20ea5c3352 | ||
|
|
7b5d59464f | ||
|
|
cf1189f5a7 | ||
|
|
4bfb6b7b67 | ||
|
|
e500d20835 | ||
|
|
d58ff8731c | ||
|
|
9a71af54f5 | ||
|
|
ab8f9e286b | ||
|
|
768a2340b5 | ||
|
|
e93abf9e69 | ||
|
|
5022d0e55f | ||
|
|
0053087587 | ||
|
|
9028e2c96a | ||
|
|
a683ee81d9 | ||
|
|
e5aef92e22 | ||
|
|
cf32e23796 | ||
|
|
50b3113dc2 | ||
|
|
337ec1bb32 | ||
|
|
e790ddb2e1 | ||
|
|
4e573f4729 | ||
|
|
8045c08e1c | ||
|
|
e2e2c29ea1 | ||
|
|
3c5ee9a379 | ||
|
|
46f0beb167 | ||
|
|
2aa1091130 | ||
|
|
6d5b73d183 | ||
|
|
f61caf0411 | ||
|
|
7918e1fd54 | ||
|
|
d8ad76cb31 | ||
|
|
63a862272c | ||
|
|
eb69ead091 | ||
|
|
e7ff2842dd | ||
|
|
2dc192fd99 | ||
|
|
a75466e981 | ||
|
|
ef936da7c5 | ||
|
|
3e07541e5f | ||
|
|
269e07cadc | ||
|
|
a5bd26831f | ||
|
|
b273d66518 | ||
|
|
c559d30776 | ||
|
|
b344c21709 | ||
|
|
d1ee7e39f7 | ||
|
|
84bdc75c7e | ||
|
|
e8c55f42c1 | ||
|
|
2dab174daa | ||
|
|
a0428eee9e | ||
|
|
ef5529b278 | ||
|
|
9133c98a9d | ||
|
|
3180413e76 | ||
|
|
ac1169b20f | ||
|
|
97d2612566 | ||
|
|
324a778f31 | ||
|
|
b60208dd8f | ||
|
|
130005cd89 | ||
|
|
207061ac0d | ||
|
|
2be4797a06 | ||
|
|
6050618096 | ||
|
|
69229a6c92 | ||
|
|
4f94e826cf | ||
|
|
567cdd1d51 | ||
|
|
9a6e67c960 | ||
|
|
33fdae54d1 | ||
|
|
e7e1e2dcad | ||
|
|
0d5835a767 | ||
|
|
872138de50 | ||
|
|
7a86e61a54 | ||
|
|
62f987e95f | ||
|
|
958c78f9a1 | ||
|
|
13241dfbdd | ||
|
|
aa3908d1b7 | ||
|
|
b520e083e0 | ||
|
|
25b669c144 | ||
|
|
ba1ff9b4eb | ||
|
|
c2bf5cad79 | ||
|
|
43f3e6114c | ||
|
|
8d369e98a5 | ||
|
|
c0321f9bc6 | ||
|
|
e7c1af1e0d | ||
|
|
bbaef66b3f | ||
|
|
e0bcce09ba | ||
|
|
8ce85ce4e3 | ||
|
|
bdcc6fbd95 |
No files matched your search
@@ -28,6 +28,9 @@ Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Karl M. Hegbloom <karlheg@debian.org>
|
||||
cp_mv.c, the test suite, various fixes to utility.c, &c.
|
||||
|
||||
@@ -46,6 +49,9 @@ Glenn McGrath <bug1@netconnect.com.au>
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox. His code is still in many apps.
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patchs.
|
||||
|
||||
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
|
||||
wget - Contributed by permission of Covad Communications
|
||||
|
||||
|
||||
@@ -1,3 +1,61 @@
|
||||
0.48
|
||||
|
||||
* Glenn McGrath -- tar now supports uncompressing tar files,
|
||||
define BB_FEATURE_TAR_GZIP to use the -z option.
|
||||
* Matt Kraai -- fix all usage of TRUE and FALSE so all apps now
|
||||
return EXIT_SUCCESS or EXIT_FAILURE to the system.
|
||||
Now TRUE and FALSE are set to the C standard where TRUE=1.
|
||||
* me -- Fixed uname problem causing the kernel version to be
|
||||
mis-detected (causing problems with poweroff, init,
|
||||
and other things).
|
||||
* Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
|
||||
Nicolas Ferre <nicolas.ferre@alcove.fr> -- insmod support on ARM
|
||||
and StrongArm, and suport for lsmod on older 2.0.x kernels.
|
||||
* Kent Robotti -- Renamed unrpm to original rpmunpack, so you can use
|
||||
an included shell script called unrpm as a front end to it. There's
|
||||
also a shell script called undeb included for debian packages.
|
||||
* Matt Kraai -- fix an infinite loop with ls -aR
|
||||
* Larry Doolittle -- Shaved off about 100 bytes and 200 bytes heap
|
||||
from date.c. Also document the "-d" option in the usage message.
|
||||
* Gennady Feldman -- fixed dd to use blocksize when reading/writing,
|
||||
(it was reading the whole thing and then writing it out). Also
|
||||
updated usage information (was missing conv=notrunc) and added
|
||||
conv=sync feature.
|
||||
* Larry Doolittle (in collaboration with Matt Kraai) -- allow for a
|
||||
pristine source directory -- where all the .o files and such are
|
||||
not placed into the source tree. Thanks Larry!
|
||||
* Larry Doolittle -- use the applet definitions in applets.h
|
||||
to autogenerate the applet function and usage prototypes.
|
||||
* Sebastien Huet, Arne Bernin, and Kent Robotti -- Add in tar -X and
|
||||
fixed a bug breaking tar --exclude.
|
||||
* Jonas Holmberg -- echo option handling made GNU-echo compatible
|
||||
* Aleksey Demidov <asd@ixcelerator.com> -- date option handling made
|
||||
GNU-date compatible
|
||||
* me -- Progress meter (optional) in wget
|
||||
* Doolittle/me -- programs invoked by full path name take
|
||||
precedence over applets unless BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
|
||||
* Gaute B Strokkenes <gs234@cam.ac.uk> -- applets found using a
|
||||
binary search instead of linear search. Much faster!
|
||||
* new applets: cmp readlink
|
||||
* Mark Whitley -- Removed advertising clause of Berkeley license
|
||||
according to decision by the Regents of the University of
|
||||
California; included reference
|
||||
* tail's confusing special treatment of single digit options removed;
|
||||
people should use -n instead
|
||||
* Larry Doolittle -- \r handled now in echo and tr
|
||||
* Matt Kraai -- rewrite of uniq
|
||||
* Mark Whitley -- remix of xargs
|
||||
* Jim Gleason <jimg@lineo.com> -- fixed tar so it no longer breaks
|
||||
hard links.
|
||||
* Matt Kraai -- logger now logs all arguments, not just the first
|
||||
* Gennady Feldman -- syslogd no longer logs to localhost if compiled
|
||||
for remote logging...
|
||||
* Richard June <rjune@ims1.imagestream-is.com> -- support for 'gzip -d'
|
||||
* various artists -- Other good stuff that I forgot to document.
|
||||
|
||||
|
||||
-Erik Andersen, 13 December 2000
|
||||
|
||||
0.47
|
||||
|
||||
* A bug in syslogd was fixed that allowed it to potentially fork-bomb
|
||||
@@ -434,7 +492,7 @@
|
||||
* Major init re-work. init now supports inittab (slightly different
|
||||
but similar to sysvinit), allowing me to get all the policy out of
|
||||
init and into the conf file. It works just fine without inittab
|
||||
being present, but if you dont like the defautl behavior you can
|
||||
being present, but if you dont like the default behavior you can
|
||||
now do something about it. Init is much cleaner as a result.
|
||||
* Fixed an bug in syslogd causing it to stop after 20 minutes. -erik
|
||||
* Fixed an embarrasing segfault in head -beppu Fixed the embarrasing
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
@@ -76,12 +77,14 @@
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
@@ -99,7 +102,6 @@
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
#define BB_UNRPM
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
@@ -163,7 +165,7 @@
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names (still a bit buggy)
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
@@ -208,7 +210,9 @@
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
@@ -218,11 +222,11 @@
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for s///p pattern matching
|
||||
#define BB_FEATURE_SED_PATTERN_SPACE
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
@@ -230,11 +234,19 @@
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
@@ -251,6 +263,12 @@
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
@@ -263,6 +281,9 @@
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
//#define BB_FEATURE_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
@@ -306,6 +327,14 @@
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
|
||||
@@ -218,9 +218,6 @@
|
||||
// Enable support for "--exclude" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for s///p pattern matching
|
||||
#define BB_FEATURE_SED_PATTERN_SPACE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
|
||||
@@ -19,10 +19,15 @@
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.47
|
||||
VERSION := 0.48
|
||||
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
# developers use), all of the following configuration values can be
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = false
|
||||
|
||||
@@ -49,21 +54,26 @@ DODMALLOC = false
|
||||
# larger than 2GB!
|
||||
DOLFS = false
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@opensource.lineo.com> if you do or don't like it so far.
|
||||
BB_SRC_DIR = .
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting...
|
||||
CROSS = #powerpc-linux-
|
||||
# to something more interesting, like "powerpc-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
|
||||
# To compile vs an alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs. This is how I make
|
||||
# busybox compile with uC-Libc...
|
||||
#LIBCDIR=/home/andersen/CVS/uC-libc
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
#CFLAGS+=-nostdinc -fno-builtin -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
# busybox compile with uC-Libc (needs BB_GETOPT and BB_FEATURE_NFSMOUNT
|
||||
# disabled at the moment).
|
||||
#LIBCDIR=/home/andersen/CVS/uClibc
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = $(LIBCDIR)/libc.a
|
||||
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
#--------------------------------------------------------
|
||||
|
||||
@@ -84,14 +94,13 @@ ifeq ($(DODMALLOC),true)
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
endif
|
||||
# -D_GNU_SOURCE is needed because environ is used in init.c
|
||||
ifeq ($(DODEBUG),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS +=
|
||||
STRIP =
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
else
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
|
||||
LDFLAGS += -s
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(DOSTATIC),true)
|
||||
@@ -113,7 +122,23 @@ ifndef $(PREFIX)
|
||||
PREFIX = `pwd`/_install
|
||||
endif
|
||||
|
||||
OBJECTS = $(shell ./busybox.sh) busybox.o messages.o usage.o utility.o
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Config.h in the build directory should take precedence over the
|
||||
# copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
#
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
# If it gets in your way, set DISABLE_VPATH=yes
|
||||
ifeq ($(DISABLE_VPATH),yes)
|
||||
CONFIG_H = Config.h
|
||||
else
|
||||
VPATH = .:$(BB_SRC_DIR)
|
||||
CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
|
||||
CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
|
||||
CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH))) $(CROSS_CFLAGS)
|
||||
endif
|
||||
|
||||
OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
@@ -132,18 +157,23 @@ docs/BusyBox.txt: docs/busybox.pod
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
- pod2text docs/busybox.pod > docs/BusyBox.txt
|
||||
-mkdir -p docs
|
||||
-pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" docs/busybox.pod > docs/BusyBox.1
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/BusyBox.html
|
||||
- ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
- pod2html --noindex docs/busybox.pod > docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f pod2html*
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
- pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2html*
|
||||
|
||||
|
||||
# New docs based on DOCBOOK SGML
|
||||
@@ -153,18 +183,23 @@ docs/busybox.txt: docs/busybox.sgml
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b txt busybox.sgml)
|
||||
|
||||
docs/busybox.dvi: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b dvi busybox.sgml)
|
||||
|
||||
docs/busybox.ps: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b ps busybox.sgml)
|
||||
|
||||
docs/busybox.pdf: docs/busybox.ps
|
||||
- mkdir -p docs
|
||||
(cd docs; ps2pdf busybox.ps)
|
||||
|
||||
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
|
||||
@@ -174,37 +209,43 @@ busybox: $(OBJECTS)
|
||||
$(STRIP)
|
||||
|
||||
busybox.links: Config.h
|
||||
- ./busybox.mkll | sort >$@
|
||||
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
$(OBJECTS): %.o: Config.h busybox.h %.c Makefile
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h Makefile
|
||||
|
||||
utility.o: loop.h
|
||||
|
||||
loop.h:
|
||||
@./mk_loop_h.sh
|
||||
loop.h: mk_loop_h.sh
|
||||
@ sh $<
|
||||
|
||||
test tests:
|
||||
cd tests && $(MAKE) all
|
||||
|
||||
clean:
|
||||
cd tests && $(MAKE) clean
|
||||
- cd tests && $(MAKE) clean
|
||||
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
|
||||
- rm -rf docs/busybox _install
|
||||
- rm -f busybox.links *~ *.o core
|
||||
- rm -f busybox.links loop.h *~ *.o core
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
install: busybox busybox.links
|
||||
./install.sh $(PREFIX)
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX)
|
||||
|
||||
install-hardlinks: busybox busybox.links
|
||||
./install.sh $(PREFIX) --hardlinks
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
|
||||
@ echo CONFIG_H=\"$(CONFIG_H)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
cd ..; \
|
||||
|
||||
@@ -4,51 +4,84 @@ BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
|
||||
emdedded system. The utilities in BusyBox generally have fewer options then
|
||||
embedded system. The utilities in BusyBox generally have fewer options than
|
||||
their full featured GNU cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their GNU counterparts.
|
||||
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add a kernel, a shell (such as ash),
|
||||
and an editor (such as elvis-tiny or ae).
|
||||
systems. To create a working system, just add a kernel and an editor (such as
|
||||
e3 (http://www.sax.de/~adlibiti) or elvis-tiny).
|
||||
|
||||
Busybox was originally written to support the Debian Rescue/Install disks, but
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
As of version 0.20 there is a version number. : ) Also as of version 0.20,
|
||||
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
|
||||
BusyBox is now modularized to easily allow you to build only the components you
|
||||
need, thereby reducing binary size. To turn off unwanted Busybox components,
|
||||
simply edit the file "Config.h" and comment out the components you do not
|
||||
need using C++ style (//) comments.
|
||||
need, thereby reducing binary size. To turn off unwanted BusyBox components,
|
||||
simply edit the file "Config.h" and comment out the components you do not need
|
||||
using C++ style (//) comments.
|
||||
|
||||
After the build is complete a busybox.links file is generated which is then
|
||||
After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e. make PREFIX="/tmp/foo" install)
|
||||
variable (i.e., make PREFIX="/tmp/foo" install)
|
||||
|
||||
----------------
|
||||
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://opensource.lineo.com/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
Bugs:
|
||||
If you find bugs, follow the instructions at http://bugs.lineo.com/Reporting.html
|
||||
and submit a bug report. This way, we can be sure nothing falls through the
|
||||
cracks...
|
||||
|
||||
If you find bugs, please submit a bug report. Full instructions on how to
|
||||
report a bug are found at http://bugs.lineo.com/Reporting.html.
|
||||
|
||||
For the impatient: To submit a bug, simply send an email describing the problem
|
||||
to submit@bugs.lineo.com. Bug reports should look something like this:
|
||||
|
||||
To: submit@bugs.lineo.com
|
||||
From: diligent@testing.linux.org
|
||||
Subject: /bin/true doesn't work
|
||||
|
||||
Package: busybox
|
||||
Version: 0.48
|
||||
|
||||
When I invoke '/bin/true' it doesn't work. I expected it to return
|
||||
a "0" but it returned a "1" instead. Here is the transcript:
|
||||
$ /bin/true ; echo $?
|
||||
1
|
||||
With GNU /bin/true, I get the following output:
|
||||
$ /bin/true ; echo $?
|
||||
0
|
||||
I am using Debian 2.2r2, kernel version 2.2.18, and the latest
|
||||
uClibc from CVS. Thanks for the wonderful program!
|
||||
-Diligent
|
||||
|
||||
Note the careful description and use of examples showing not only what BusyBox
|
||||
does, but also a counter example showing what an equivalent GNU app does. Bug
|
||||
reports lacking such detail may take a _long_ time to be fixed... Thanks for
|
||||
understanding.
|
||||
|
||||
----------------
|
||||
|
||||
FTP:
|
||||
|
||||
Source for the latest released version can always be downloaded from
|
||||
ftp://ftp.lineo.com/pub/busybox.
|
||||
|
||||
----------------
|
||||
|
||||
CVS:
|
||||
BusyBox now has its own publically browsable CVS tree at:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
@@ -57,7 +90,6 @@ Anonymous CVS access is available. For instructions, check out:
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://opensource.lineo.com/cvs_write.html
|
||||
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
@@ -65,7 +97,7 @@ Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
|
||||
<blatent plug>
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
</blatent plug>
|
||||
</blatant plug>
|
||||
|
||||
@@ -6,36 +6,47 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* Networking apps are probably going to be split out some time soon into a
|
||||
separate package (named perhaps netkit-tiny?). This would remove the
|
||||
following items from BusyBox: hostid, hostname, nc, nslookup, telnet, and
|
||||
ping. nfs mounting and syslogd (network logging) will remain in BusyBox.
|
||||
* Networking apps are going to be split out to a new package called netkit-tiny
|
||||
before the next release of Busybox. This will remove the following items
|
||||
from BusyBox: hostid, hostname, nc, nslookup, telnet, and ping. nfs
|
||||
mounting and syslogd (network logging) will remain in BusyBox.
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
* dnsdomainname
|
||||
* traceroute/netstat
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* stty
|
||||
* tftp
|
||||
* ftp
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------------------
|
||||
|
||||
The Busybox lash shell needs to be taught Bourne shell grammer. This
|
||||
is planned for the next release of Busybox. Look out ash, we are coming
|
||||
for you...
|
||||
|
||||
-----------------------
|
||||
|
||||
Running the following:
|
||||
|
||||
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
|
||||
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
|
||||
|
||||
reveals the list of all external (i.e. libc) things that BusyBox depends on.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, and
|
||||
then create a microLibc to provide these functions. There is no good reason
|
||||
for GNU libc to be so big. I'm sure it can be a lot better.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox when staticly linking with libraries such as
|
||||
uClibc.
|
||||
|
||||
(BTW, this is more informative if BB_FEATURE_NFSMOUNT is turned off...)
|
||||
-----------------------
|
||||
|
||||
Currently, busybox bypasses libc NSS. Some folks might want that,
|
||||
so perhaps adding in the option to choose whether to go to libc for
|
||||
things like getpwnam() or whether to use the busybox version might
|
||||
be nice.
|
||||
|
||||
-----------------------
|
||||
|
||||
Most wanted list:
|
||||
|
||||
|
||||
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* applets.h - a listing of all busybox applets.
|
||||
*
|
||||
* If you write a new applet, you need to add an entry to this list to make
|
||||
* busybox aware of it.
|
||||
*
|
||||
* It is CRUCIAL that this listing be kept in ascii order, otherwise the binary
|
||||
* search lookup contributed by Gaute B Strokkenes stops working. If you value
|
||||
* your kneecaps, you'll be sure to *make sure* that any changes made to this
|
||||
* file result in the listing remaining in ascii order. You have been warned.
|
||||
*/
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c,d) \
|
||||
extern int b(int argc, char **argv); \
|
||||
extern const char d[];
|
||||
#define APPLET_NOUSAGE(a,b,c) \
|
||||
extern int b(int argc, char **argv);
|
||||
#elif defined(MAKE_LINKS)
|
||||
#define APPLET(a,b,c,d) LINK c a
|
||||
#define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c,d) {a,b,c,d},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c,NULL},
|
||||
#endif
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET("[", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET("ar", ar_main, _BB_DIR_USR_BIN, ar_usage)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET("basename", basename_main, _BB_DIR_USR_BIN, basename_usage)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET("cat", cat_main, _BB_DIR_BIN, cat_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET("chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET("chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET("clear", clear_main, _BB_DIR_USR_BIN, clear_usage)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET("cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("cp", cp_mv_main, _BB_DIR_BIN, cp_usage)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET("cut", cut_main, _BB_DIR_USR_BIN, cut_usage)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET("date", date_main, _BB_DIR_BIN, date_usage)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET("dc", dc_main, _BB_DIR_USR_BIN, dc_usage)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET("dd", dd_main, _BB_DIR_BIN, dd_usage)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET("deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET("df", df_main, _BB_DIR_BIN, df_usage)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET("dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET("dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET("dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET("dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET("echo", echo_main, _BB_DIR_BIN, echo_usage)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET("expr", expr_main, _BB_DIR_USR_BIN, expr_usage)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("false", false_main, _BB_DIR_BIN, false_usage)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET_NOUSAGE("fbset", fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET("fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET("find", find_main, _BB_DIR_USR_BIN, find_usage)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET("free", free_main, _BB_DIR_USR_BIN, free_usage)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET("freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET("getopt", getopt_main, _BB_DIR_BIN, getopt_usage)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET("grep", grep_main, _BB_DIR_BIN, grep_usage)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET("gzip", gzip_main, _BB_DIR_BIN, gzip_usage)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET("halt", halt_main, _BB_DIR_SBIN, halt_usage)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET("head", head_main, _BB_DIR_USR_BIN, head_usage)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET("hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET("hostname", hostname_main, _BB_DIR_BIN, hostname_usage)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET("id", id_main, _BB_DIR_USR_BIN, id_usage)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET_NOUSAGE("init", init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET("insmod", insmod_main, _BB_DIR_SBIN, insmod_usage)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET("kill", kill_main, _BB_DIR_BIN, kill_usage)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET("killall", kill_main, _BB_DIR_USR_BIN, killall_usage)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET("length", length_main, _BB_DIR_USR_BIN, length_usage)
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET("ln", ln_main, _BB_DIR_BIN, ln_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET("loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET("loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET("loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET("logger", logger_main, _BB_DIR_USR_BIN, logger_usage)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET("logname", logname_main, _BB_DIR_USR_BIN, logname_usage)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET("ls", ls_main, _BB_DIR_BIN, ls_usage)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET("lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET("makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET("md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET("mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET("mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET("mknod", mknod_main, _BB_DIR_BIN, mknod_usage)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET("mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET("mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET("more", more_main, _BB_DIR_BIN, more_usage)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET("mount", mount_main, _BB_DIR_BIN, mount_usage)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET("mt", mt_main, _BB_DIR_BIN, mt_usage)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("mv", cp_mv_main, _BB_DIR_BIN, mv_usage)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET("nc", nc_main, _BB_DIR_USR_BIN, nc_usage)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET("nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET("printf", printf_main, _BB_DIR_USR_BIN, printf_usage)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET("ps", ps_main, _BB_DIR_BIN, ps_usage)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET("pwd", pwd_main, _BB_DIR_BIN, pwd_usage)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET("rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET("readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET("reboot", reboot_main, _BB_DIR_SBIN, reboot_usage)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET("renice", renice_main, _BB_DIR_USR_BIN, renice_usage)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET("reset", reset_main, _BB_DIR_USR_BIN, reset_usage)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET("rm", rm_main, _BB_DIR_BIN, rm_usage)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET("rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET("rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET("rpmunpack", rpmunpack_main, _BB_DIR_USR_BIN, rpmunpack_usage)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET("sed", sed_main, _BB_DIR_BIN, sed_usage)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET("setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET("sh", shell_main, _BB_DIR_BIN, shell_usage)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET("sleep", sleep_main, _BB_DIR_BIN, sleep_usage)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET("sort", sort_main, _BB_DIR_USR_BIN, sort_usage)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET("sync", sync_main, _BB_DIR_BIN, sync_usage)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET("syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET("tail", tail_main, _BB_DIR_USR_BIN, tail_usage)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET("tar", tar_main, _BB_DIR_BIN, tar_usage)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET("tee", tee_main, _BB_DIR_USR_BIN, tee_usage)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET("telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET("test", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET("touch", touch_main, _BB_DIR_BIN, touch_usage)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET("tr", tr_main, _BB_DIR_USR_BIN, tr_usage)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("true", true_main, _BB_DIR_BIN, true_usage)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET("tty", tty_main, _BB_DIR_USR_BIN, tty_usage)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET("umount", umount_main, _BB_DIR_BIN, umount_usage)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET("uname", uname_main, _BB_DIR_BIN, uname_usage)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET("uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET("unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET("update", update_main, _BB_DIR_SBIN, update_usage)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET("uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET("usleep", usleep_main, _BB_DIR_BIN, usleep_usage)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET("uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET("wget", wget_main, _BB_DIR_USR_BIN, wget_usage)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET("which", which_main, _BB_DIR_USR_BIN, which_usage)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET("whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET("xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET("yes", yes_main, _BB_DIR_USR_BIN, yes_usage)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_LINKS)
|
||||
{ 0,NULL,0,NULL}
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,NULL} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
+43
-368
@@ -4,365 +4,17 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
const struct BB_applet applets[] = {
|
||||
|
||||
#ifdef BB_AR
|
||||
{"ar", ar_main, _BB_DIR_USR_BIN, ar_usage},
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
{"basename", basename_main, _BB_DIR_USR_BIN, basename_usage},
|
||||
#endif
|
||||
{"busybox", busybox_main, _BB_DIR_BIN, NULL},
|
||||
#ifdef BB_CAT
|
||||
{"cat", cat_main, _BB_DIR_BIN, cat_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage},
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
{"chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage},
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
{"clear", clear_main, _BB_DIR_USR_BIN, clear_usage},
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
{"cut", cut_main, _BB_DIR_USR_BIN, cut_usage},
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
{"date", date_main, _BB_DIR_BIN, date_usage},
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
{"dc", dc_main, _BB_DIR_USR_BIN, dc_usage},
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
{"dd", dd_main, _BB_DIR_BIN, dd_usage},
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
{"df", df_main, _BB_DIR_BIN, df_usage},
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
{"dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage},
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
{"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage},
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
{"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage},
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
{"du", du_main, _BB_DIR_USR_BIN, du_usage},
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage},
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage},
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
{"echo", echo_main, _BB_DIR_BIN, echo_usage},
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
{"expr", expr_main, _BB_DIR_USR_BIN, expr_usage},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"false", false_main, _BB_DIR_BIN, false_usage},
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
{"fbset", fbset_main, _BB_DIR_USR_SBIN, NULL},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
{"fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage},
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
{"find", find_main, _BB_DIR_USR_BIN, find_usage},
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
{"free", free_main, _BB_DIR_USR_BIN, free_usage},
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage},
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
{"getopt", getopt_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
{"grep", grep_main, _BB_DIR_BIN, grep_usage},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage},
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
{"gzip", gzip_main, _BB_DIR_BIN, gzip_usage},
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
{"halt", halt_main, _BB_DIR_SBIN, halt_usage},
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
{"head", head_main, _BB_DIR_USR_BIN, head_usage},
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
{"hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage},
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
{"hostname", hostname_main, _BB_DIR_BIN, hostname_usage},
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
{"id", id_main, _BB_DIR_USR_BIN, id_usage},
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
{"init", init_main, _BB_DIR_SBIN, NULL},
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
{"insmod", insmod_main, _BB_DIR_SBIN, insmod_usage},
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
{"kill", kill_main, _BB_DIR_BIN, kill_usage},
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
{"killall", kill_main, _BB_DIR_USR_BIN, kill_usage},
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
{"length", length_main, _BB_DIR_USR_BIN, length_usage},
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
{"linuxrc", init_main, _BB_DIR_ROOT, NULL},
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
{"ln", ln_main, _BB_DIR_BIN, ln_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
{"loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
{"loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
{"loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage},
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
{"logger", logger_main, _BB_DIR_USR_BIN, logger_usage},
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
{"logname", logname_main, _BB_DIR_USR_BIN, logname_usage},
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
{"ls", ls_main, _BB_DIR_BIN, ls_usage},
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
{"lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
{"makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage},
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
{"md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage},
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
{"mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage},
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage},
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
{"mknod", mknod_main, _BB_DIR_BIN, mknod_usage},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
{"mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage},
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
{"mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage},
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
{"nc", nc_main, _BB_DIR_USR_BIN, nc_usage},
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
{"more", more_main, _BB_DIR_BIN, more_usage},
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
{"mount", mount_main, _BB_DIR_BIN, mount_usage},
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
{"mt", mt_main, _BB_DIR_BIN, mt_usage},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"mv", cp_mv_main, _BB_DIR_BIN, mv_usage},
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
{"nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage},
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
{"ping", ping_main, _BB_DIR_BIN, ping_usage},
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
{"poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage},
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
{"printf", printf_main, _BB_DIR_USR_BIN, printf_usage},
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
{"ps", ps_main, _BB_DIR_BIN, ps_usage},
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
{"pwd", pwd_main, _BB_DIR_BIN, pwd_usage},
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
{"renice", renice_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
{"reset", reset_main, _BB_DIR_USR_BIN, reset_usage},
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
{"rm", rm_main, _BB_DIR_BIN, rm_usage},
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
{"rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage},
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
{"rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage},
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
{"sed", sed_main, _BB_DIR_BIN, sed_usage},
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage},
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
{"sh", shell_main, _BB_DIR_BIN, shell_usage},
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
{"sleep", sleep_main, _BB_DIR_BIN, sleep_usage},
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
{"sort", sort_main, _BB_DIR_USR_BIN, sort_usage},
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
{"sync", sync_main, _BB_DIR_BIN, sync_usage},
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
{"syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage},
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
{"tail", tail_main, _BB_DIR_USR_BIN, tail_usage},
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
{"tar", tar_main, _BB_DIR_BIN, tar_usage},
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
{"telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"test", test_main, _BB_DIR_USR_BIN, test_usage},
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
{"tee", tee_main, _BB_DIR_USR_BIN, tee_usage},
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
{"touch", touch_main, _BB_DIR_BIN, touch_usage},
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
{"tr", tr_main, _BB_DIR_USR_BIN, tr_usage},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"true", true_main, _BB_DIR_BIN, true_usage},
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
{"tty", tty_main, _BB_DIR_USR_BIN, tty_usage},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
{"umount", umount_main, _BB_DIR_BIN, umount_usage},
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
{"uname", uname_main, _BB_DIR_BIN, uname_usage},
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
{"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage},
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
{"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage},
|
||||
#endif
|
||||
#ifdef BB_UNRPM
|
||||
{"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage},
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
{"update", update_main, _BB_DIR_SBIN, update_usage},
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
{"uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage},
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
{"uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage},
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
{"uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage},
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
{"usleep", usleep_main, _BB_DIR_BIN, usleep_usage},
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
{"wc", wc_main, _BB_DIR_USR_BIN, wc_usage},
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
{"wget", wget_main, _BB_DIR_USR_BIN, wget_usage},
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
{"which", which_main, _BB_DIR_USR_BIN, which_usage},
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
{"whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage},
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
{"xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage},
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
{"yes", yes_main, _BB_DIR_USR_BIN, yes_usage},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"[", test_main, _BB_DIR_USR_BIN, test_usage},
|
||||
#endif
|
||||
{0,NULL,0,NULL}
|
||||
};
|
||||
|
||||
const char *applet_name;
|
||||
|
||||
@@ -402,7 +54,7 @@ static char *busybox_fullpath()
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
errorMsg("%s: %s\n", proc, strerror(errno));
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
@@ -426,18 +78,17 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
errorMsg("%s: %s\n", command, strerror(errno));
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
const struct BB_applet *a = applets;
|
||||
applet_name = "busybox";
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -475,8 +126,6 @@ int main(int argc, char **argv)
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
*argv = (char*)applet_name;
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
@@ -485,14 +134,16 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(applet_name, a->name) == 0) {
|
||||
if (a->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(a->usage);
|
||||
exit(((*(a->main)) (argc, argv)));
|
||||
}
|
||||
a++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
@@ -500,10 +151,12 @@ int main(int argc, char **argv)
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
@@ -528,8 +181,30 @@ int busybox_main(int argc, char **argv)
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* If we've already been here once, exit now */
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
+13
-16
@@ -1,19 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="Config.h"
|
||||
MF="busybox.c"
|
||||
|
||||
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
|
||||
for j in $i; do
|
||||
if [ -z $j ] ; then
|
||||
continue;
|
||||
fi;
|
||||
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
|
||||
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
|
||||
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
|
||||
done;
|
||||
done
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
+8
-5
@@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 ` \
|
||||
gcc -E -dM Config.h | \
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
|
||||
+64
-22
@@ -93,6 +93,15 @@ const char clear_usage[] =
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_CMP
|
||||
const char cmp_usage[] =
|
||||
"cmp FILE1 [FILE2]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCompare files.\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_CP_MV
|
||||
const char cp_usage[] =
|
||||
"cp [OPTION]... SOURCE DEST\n"
|
||||
@@ -131,9 +140,10 @@ const char date_usage[] =
|
||||
" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDisplays the current time in the given FORMAT, or sets the system date.\n"
|
||||
"\nOptions:\n\t-R\tOutputs RFC-822 compliant date string\n"
|
||||
"\t-s\tSets time described by STRING\n"
|
||||
"\t-u\tPrints or sets Coordinated Universal Time\n"
|
||||
"\nOptions:\n\t-R\t\tOutputs RFC-822 compliant date string\n"
|
||||
"\t-d STRING\tdisplay time described by STRING, not `now'\n"
|
||||
"\t-s\t\tSets time described by STRING\n"
|
||||
"\t-u\t\tPrints or sets Coordinated Universal Time\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -151,7 +161,7 @@ const char dc_usage[] =
|
||||
|
||||
#if defined BB_DD
|
||||
const char dd_usage[] =
|
||||
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N]\n"
|
||||
"dd [if=FILE] [of=FILE] [bs=N] [count=N] [skip=N] [seek=N] [conv=notrunc|sync]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCopy a file, converting and formatting according to options\n\n"
|
||||
"\tif=FILE\tread from FILE instead of stdin\n"
|
||||
@@ -161,6 +171,7 @@ const char dd_usage[] =
|
||||
"\tskip=N\tskip N input blocks\n"
|
||||
"\tseek=N\tskip N output blocks\n"
|
||||
"\tconv=notrunc\t dont truncate of at end of write\n"
|
||||
"\tconv=sync\t pad the last block with zeros until blocksize\n"
|
||||
"\n"
|
||||
"Numbers may be suffixed by w (x2), k (x1024), b (x512), or M (x1024^2)\n"
|
||||
#endif
|
||||
@@ -366,6 +377,24 @@ const char fsck_minix_usage[] =
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_GETOPT
|
||||
const char getopt_usage[] =
|
||||
"getopt [OPTIONS]...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"Parse command options\n"
|
||||
" -a, --alternative Allow long options starting with single -\n"
|
||||
" -l, --longoptions=longopts Long options to be recognized\n"
|
||||
" -n, --name=progname The name under which errors are reported\n"
|
||||
" -o, --options=optstring Short options to be recognized\n"
|
||||
" -q, --quiet Disable error reporting by getopt(3)\n"
|
||||
" -Q, --quiet-output No normal output\n"
|
||||
" -s, --shell=shell Set shell quoting conventions\n"
|
||||
" -T, --test Test for getopt(1) version\n"
|
||||
" -u, --unqote Do not quote the output\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_GREP
|
||||
const char grep_usage[] =
|
||||
"grep [-ihHnqvs] pattern [files...]\n"
|
||||
@@ -403,6 +432,7 @@ const char gzip_usage[] =
|
||||
"When FILE is '-', reads standard input. Implies -c.\n\n"
|
||||
"Options:\n"
|
||||
"\t-c\tWrite output to standard output instead of FILE.gz\n"
|
||||
"\t-d\tdecompress\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -449,7 +479,7 @@ const char hostname_usage[] =
|
||||
|
||||
"\t-i\t\tAddresses for the hostname\n"
|
||||
"\t-d\t\tDNS domain name\n"
|
||||
"\t-F FILE\t\tUse the contents of FILE to specify the hostname\n"
|
||||
"\t-F, --file FILE\tUse the contents of FILE to specify the hostname\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -959,6 +989,15 @@ const char rdate_usage[] =
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_READLINK
|
||||
const char readlink_usage[] =
|
||||
"readlink\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nRead a symbolic link.\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_REBOOT
|
||||
const char reboot_usage[] =
|
||||
"reboot\n"
|
||||
@@ -967,7 +1006,6 @@ const char reboot_usage[] =
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
|
||||
#if defined BB_RENICE
|
||||
const char renice_usage[] =
|
||||
@@ -1023,6 +1061,15 @@ const char rmmod_usage[] =
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_RPMUNPACK
|
||||
const char rpmunpack_usage[] =
|
||||
"rpmunpack < package.rpm | gunzip | cpio -idmuv\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nExtracts an rpm archive.\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_SED
|
||||
const char sed_usage[] =
|
||||
"sed [-Vhnef] pattern [files...]\n"
|
||||
@@ -1130,6 +1177,7 @@ const char syslogd_usage[] =
|
||||
"\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n"
|
||||
#ifdef BB_FEATURE_REMOTE_LOG
|
||||
"\t-R HOST[:PORT]\t\tLog remotely to IP or hostname on PORT (default PORT=514/UDP)\n"
|
||||
"\t-L\t\tLog locally as well as network logging (default is network only)\n"
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
@@ -1147,7 +1195,6 @@ const char tail_usage[] =
|
||||
"\t-c=N[kbm]\toutput the last N bytes\n"
|
||||
#endif
|
||||
"\t-n NUM\t\tPrint last NUM lines instead of first 10\n"
|
||||
"\t\t\tAlso can be -NUM or +NUM.\n"
|
||||
"\t-f\t\tOutput data as the file grows.\n"
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
"\t-q\t\tnever output headers giving file names\n"
|
||||
@@ -1173,11 +1220,11 @@ const char tar_usage[] =
|
||||
#endif
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
"[--exclude File] "
|
||||
"[-X File]"
|
||||
#endif
|
||||
"[-f tarFile] [FILE(s)] ...\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nCreate, extract, or list files from a tar file. Note that\n"
|
||||
"this version of tar treats hard links as separate files.\n\n"
|
||||
"\nCreate, extract, or list files from a tar file.\n\n"
|
||||
"Main operation mode:\n"
|
||||
#ifdef BB_FEATURE_TAR_CREATE
|
||||
"\tc\t\tcreate\n"
|
||||
@@ -1189,6 +1236,7 @@ const char tar_usage[] =
|
||||
"\tO\t\textract to stdout\n"
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
"\texclude\t\tfile to exclude\n"
|
||||
"\tX\t\tfile with names to exclude\n"
|
||||
#endif
|
||||
"\nInformative output:\n"
|
||||
"\tv\t\tverbosely list files processed\n"
|
||||
@@ -1318,6 +1366,10 @@ const char uniq_usage[] =
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nDiscard all but one of successive identical lines from INPUT\n"
|
||||
"(or standard input), writing to OUTPUT (or standard output).\n"
|
||||
"Options:\n"
|
||||
"\t-c\tprefix lines by the number of occurrences\n"
|
||||
"\t-d\tonly print duplicate lines\n"
|
||||
"\t-u\tonly print unique lines\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -1331,15 +1383,6 @@ const char unix2dos_usage[] =
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_UNRPM
|
||||
const char unrpm_usage[] =
|
||||
"unrpm < package.rpm | gzip -d | cpio -idmuv\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nExtracts an rpm archive.\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
#if defined BB_UPDATE
|
||||
const char update_usage[] =
|
||||
"update [options]\n"
|
||||
@@ -1439,11 +1482,9 @@ const char whoami_usage[] =
|
||||
#endif
|
||||
|
||||
#if defined BB_XARGS
|
||||
const char xargs_usage[] = "xargs [OPTIONS] [COMMAND] [ARGS...]\n"
|
||||
const char xargs_usage[] = "xargs [COMMAND] [ARGS...]\n"
|
||||
#ifndef BB_FEATURE_TRIVIAL_HELP
|
||||
"\nExecutes COMMAND on every item given by standard input.\n\n"
|
||||
"Options:\n"
|
||||
"\t-t\tPrint the command just before it is run\n"
|
||||
"\nExecutes COMMAND on every item given by standard input.\n"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -1456,3 +1497,4 @@ const char yes_usage[] =
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
@@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
fullRead(srcFd, magic, 6);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
@@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
@@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, arMagic, 8) != 8) {
|
||||
errorMsg("fatal error\n");
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
@@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
fullRead(srcFd, tempName, entry->size);
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
@@ -226,7 +226,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
else {
|
||||
errorMsg("Invalid long filename\n");
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
fatalError("Cannot read %s\n", argv[optind]);
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
@@ -368,24 +368,24 @@ extern int ar_main(int argc, char **argv)
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
|
||||
createPath(extractList->name, 0666);
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copySubFile(srcFd, dstFd, (size_t) extractList->size);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copySubFile(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", modeString(extractList->mode),
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, timeString(extractList->mtime));
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
}
|
||||
return (TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+15
-15
@@ -106,7 +106,7 @@ static int checkTarMagic(int srcFd)
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
fullRead(srcFd, magic, 6);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
@@ -123,7 +123,7 @@ static int readTarHeader(int srcFd, headerL_t *current)
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
@@ -157,8 +157,8 @@ static int checkArMagic(int srcFd)
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, arMagic, 8) != 8) {
|
||||
errorMsg("fatal error\n");
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
@@ -178,7 +178,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (fullRead(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
fullRead(srcFd, tempName, entry->size);
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
@@ -226,7 +226,7 @@ static int readArEntry(int srcFd, headerL_t *entry)
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
else {
|
||||
errorMsg("Invalid long filename\n");
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ extern int ar_main(int argc, char **argv)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
fatalError("Cannot read %s\n", argv[optind]);
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
@@ -368,24 +368,24 @@ extern int ar_main(int argc, char **argv)
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (isDirectory(extractList->name, TRUE, NULL)==FALSE)
|
||||
createPath(extractList->name, 0666);
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copySubFile(srcFd, dstFd, (size_t) extractList->size);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copySubFile(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", modeString(extractList->mode),
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, timeString(extractList->mtime));
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
}
|
||||
return (TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+689
-1524
File diff suppressed because it is too large.
Load diff
+40
-35
@@ -114,7 +114,7 @@ extern int method; /* compression method */
|
||||
# define DECLARE(type, array, size) type * array
|
||||
# define ALLOC(type, array, size) { \
|
||||
array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
|
||||
if (array == NULL) errorMsg(memory_exhausted); \
|
||||
if (array == NULL) error_msg(memory_exhausted); \
|
||||
}
|
||||
# define FREE(array) {if (array != NULL) free(array), array=NULL;}
|
||||
#else
|
||||
@@ -251,7 +251,7 @@ extern int save_orig_name; /* set if original name must be saved */
|
||||
|
||||
/* Diagnostic functions */
|
||||
#ifdef DEBUG
|
||||
# define Assert(cond,msg) {if(!(cond)) errorMsg(msg);}
|
||||
# define Assert(cond,msg) {if(!(cond)) error_msg(msg);}
|
||||
# define Trace(x) fprintf x
|
||||
# define Tracev(x) {if (verbose) fprintf x ;}
|
||||
# define Tracevv(x) {if (verbose>1) fprintf x ;}
|
||||
@@ -1381,7 +1381,7 @@ int length;
|
||||
(char *) window + start, length) != EQUAL) {
|
||||
fprintf(stderr,
|
||||
" start %d, match %d, length %d\n", start, match, length);
|
||||
errorMsg("invalid match");
|
||||
error_msg("invalid match\n");
|
||||
}
|
||||
if (verbose > 1) {
|
||||
fprintf(stderr, "\\[%d,%d]", start - match, length);
|
||||
@@ -1754,34 +1754,23 @@ DECLARE(ush, tab_prefix1, 1L << (BITS - 1));
|
||||
|
||||
/* local variables */
|
||||
|
||||
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
||||
int decompress = 0; /* decompress (-d) */
|
||||
int no_name = -1; /* don't save or restore the original file name */
|
||||
int no_time = -1; /* don't save or restore the original file time */
|
||||
int foreground; /* set if program run in foreground */
|
||||
char *progname; /* program name */
|
||||
static int foreground; /* set if program run in foreground */
|
||||
static int method = DEFLATED; /* compression method */
|
||||
static int exit_code = OK; /* program exit code */
|
||||
int save_orig_name; /* set if original name must be saved */
|
||||
int last_member; /* set for .zip and .Z files */
|
||||
int part_nb; /* number of parts in .gz file */
|
||||
long time_stamp; /* original time stamp (modification time) */
|
||||
long ifile_size; /* input file size, -1 for devices (debug only) */
|
||||
char *env; /* contents of GZIP env variable */
|
||||
char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
|
||||
int z_len; /* strlen(z_suffix) */
|
||||
static int part_nb; /* number of parts in .gz file */
|
||||
static long time_stamp; /* original time stamp (modification time) */
|
||||
static long ifile_size; /* input file size, -1 for devices (debug only) */
|
||||
static char z_suffix[MAX_SUFFIX + 1]; /* default suffix (can be set with --suffix) */
|
||||
static int z_len; /* strlen(z_suffix) */
|
||||
|
||||
long bytes_in; /* number of input bytes */
|
||||
long bytes_out; /* number of output bytes */
|
||||
char ifname[MAX_PATH_LEN]; /* input file name */
|
||||
char ofname[MAX_PATH_LEN]; /* output file name */
|
||||
int remove_ofname = 0; /* remove output file on error */
|
||||
struct stat istat; /* status for input file */
|
||||
int ifd; /* input file descriptor */
|
||||
int ofd; /* output file descriptor */
|
||||
unsigned insize; /* valid bytes in inbuf */
|
||||
unsigned inptr; /* index of next byte to be processed in inbuf */
|
||||
unsigned outcnt; /* bytes in output buffer */
|
||||
static long bytes_in; /* number of input bytes */
|
||||
static long bytes_out; /* number of output bytes */
|
||||
static char ifname[MAX_PATH_LEN]; /* input file name */
|
||||
static char ofname[MAX_PATH_LEN]; /* output file name */
|
||||
static int ifd; /* input file descriptor */
|
||||
static int ofd; /* output file descriptor */
|
||||
static unsigned insize; /* valid bytes in inbuf */
|
||||
static unsigned outcnt; /* bytes in output buffer */
|
||||
|
||||
/* local functions */
|
||||
|
||||
@@ -1819,6 +1808,8 @@ int gzip_main(int argc, char **argv)
|
||||
case '1': case '2': case '3': case '4': case '5':
|
||||
case '6': case '7': case '8': case '9':
|
||||
break;
|
||||
case 'd':
|
||||
exit(gunzip_main(argc, argv));
|
||||
default:
|
||||
usage(gzip_usage);
|
||||
}
|
||||
@@ -1830,9 +1821,9 @@ int gzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (isatty(fileno(stdin)) && fromstdin==1 && force==0)
|
||||
fatalError( "data not read from terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not read from terminal. Use -f to force it.\n");
|
||||
if (isatty(fileno(stdout)) && tostdout==1 && force==0)
|
||||
fatalError( "data not written to terminal. Use -f to force it.\n");
|
||||
error_msg_and_die( "data not written to terminal. Use -f to force it.\n");
|
||||
|
||||
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
|
||||
if (foreground) {
|
||||
@@ -1941,7 +1932,7 @@ int gzip_main(int argc, char **argv)
|
||||
|
||||
if (unlink(delFileName) < 0) {
|
||||
perror(delFileName);
|
||||
exit(FALSE);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2911,7 +2902,7 @@ int eof; /* true if this is the last block for a file */
|
||||
#endif
|
||||
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
|
||||
if (buf == (char *) 0)
|
||||
errorMsg("block vanished");
|
||||
error_msg("block vanished\n");
|
||||
|
||||
copy_block(buf, (unsigned) stored_len, 0); /* without header */
|
||||
compressed_len = stored_len << 3;
|
||||
@@ -3094,7 +3085,7 @@ local void set_file_type()
|
||||
bin_freq += dyn_ltree[n++].Freq;
|
||||
*file_type = bin_freq > (ascii_freq >> 2) ? BINARY : ASCII;
|
||||
if (*file_type == BINARY && translate_eol) {
|
||||
errorMsg("-l used on binary file");
|
||||
error_msg("-l used on binary file\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3250,13 +3241,13 @@ char *env; /* name of environment variable */
|
||||
nargv = (char **) calloc(*argcp + 1, sizeof(char *));
|
||||
|
||||
if (nargv == NULL)
|
||||
errorMsg(memory_exhausted);
|
||||
error_msg(memory_exhausted);
|
||||
oargv = *argvp;
|
||||
*argvp = nargv;
|
||||
|
||||
/* Copy the program name first */
|
||||
if (oargc-- < 0)
|
||||
errorMsg("argc<=0");
|
||||
error_msg("argc<=0\n");
|
||||
*(nargv++) = *(oargv++);
|
||||
|
||||
/* Then copy the environment args */
|
||||
@@ -3391,3 +3382,17 @@ unsigned size;
|
||||
isize += (ulg) len;
|
||||
return (int) len;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Write the output buffer outbuf[0..outcnt-1] and update bytes_out.
|
||||
* (used for the compressed data only)
|
||||
*/
|
||||
void flush_outbuf()
|
||||
{
|
||||
if (outcnt == 0)
|
||||
return;
|
||||
|
||||
write_buf(ofd, (char *) outbuf, outcnt);
|
||||
bytes_out += (ulg) outcnt;
|
||||
outcnt = 0;
|
||||
}
|
||||
+285
-103
@@ -39,7 +39,7 @@
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#define bb_need_name_longer_then_foo
|
||||
#define bb_need_name_longer_than_foo
|
||||
#include "messages.c"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
@@ -52,6 +52,11 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
extern int unzip(int in, int out);
|
||||
extern int gunzip_init();
|
||||
#endif
|
||||
|
||||
/* Tar file constants */
|
||||
#ifndef MAJOR
|
||||
#define MAJOR(dev) (((dev)>>8)&0xff)
|
||||
@@ -129,44 +134,81 @@ struct TarInfo
|
||||
typedef struct TarInfo TarInfo;
|
||||
|
||||
/* Local procedures to restore files from a tar file. */
|
||||
static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
static int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList,
|
||||
char** excludeList);
|
||||
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_TAR_CREATE
|
||||
/* Local procedures to save files into a tar file. */
|
||||
static int writeTarFile(const char* tarName, int tostdoutFlag,
|
||||
int verboseFlag, int argc, char **argv, char** excludeList);
|
||||
static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
char** excludeList);
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* Signal handler for when child gzip process dies... */
|
||||
void child_died()
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int tar_unzip_init(int tarFd)
|
||||
{
|
||||
int child_pid;
|
||||
static int unzip_pipe[2];
|
||||
/* Cope if child dies... Otherwise we block forever in read()... */
|
||||
signal(SIGCHLD, child_died);
|
||||
|
||||
if (pipe(unzip_pipe)!=0)
|
||||
error_msg_and_die("pipe error\n");
|
||||
|
||||
if ( (child_pid = fork()) == -1)
|
||||
error_msg_and_die("fork failure\n");
|
||||
|
||||
if (child_pid==0) {
|
||||
/* child process */
|
||||
gunzip_init();
|
||||
unzip(tarFd, unzip_pipe[1]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
/* return fd of uncompressed data to parent process */
|
||||
return(unzip_pipe[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int tar_main(int argc, char **argv)
|
||||
{
|
||||
char** excludeList=NULL;
|
||||
char** extractList=NULL;
|
||||
const char *tarName="-";
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
int excludeListSize=0;
|
||||
char *excludeFileName ="-";
|
||||
FILE *fileList;
|
||||
char file[256];
|
||||
#endif
|
||||
#if defined BB_FEATURE_TAR_GZIP
|
||||
int unzipFlag = FALSE;
|
||||
#endif
|
||||
const char *tarName="-";
|
||||
int listFlag = FALSE;
|
||||
int extractFlag = FALSE;
|
||||
int createFlag = FALSE;
|
||||
int verboseFlag = FALSE;
|
||||
int tostdoutFlag = FALSE;
|
||||
int firstOpt = TRUE;
|
||||
int status = FALSE;
|
||||
int firstOpt = TRUE;
|
||||
int stopIt;
|
||||
|
||||
|
||||
if (argc <= 1)
|
||||
usage(tar_usage);
|
||||
|
||||
/* do normal option parsing */
|
||||
while (--argc > 0 && ((*argv && **(++argv) == '-') ||
|
||||
(firstOpt==TRUE && strspn(*argv, "-cxt") ))) {
|
||||
while (*(++argv) && (**argv == '-' || firstOpt == TRUE)) {
|
||||
firstOpt=FALSE;
|
||||
stopIt=FALSE;
|
||||
while (stopIt==FALSE && *argv && **argv) {
|
||||
switch (**argv) {
|
||||
while (stopIt==FALSE && **argv) {
|
||||
switch (*((*argv)++)) {
|
||||
case 'c':
|
||||
if (extractFlag == TRUE || listFlag == TRUE)
|
||||
goto flagError;
|
||||
@@ -182,34 +224,33 @@ extern int tar_main(int argc, char **argv)
|
||||
goto flagError;
|
||||
listFlag = TRUE;
|
||||
break;
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
case 'z':
|
||||
unzipFlag = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
verboseFlag = TRUE;
|
||||
break;
|
||||
case 'O':
|
||||
tostdoutFlag = TRUE;
|
||||
tarName = "-";
|
||||
break;
|
||||
case 'f':
|
||||
if (--argc == 0) {
|
||||
fatalError( "Option requires an argument: No file specified\n");
|
||||
}
|
||||
if (*tarName != '-')
|
||||
fatalError( "Only one 'f' option allowed\n");
|
||||
error_msg_and_die( "Only one 'f' option allowed\n");
|
||||
tarName = *(++argv);
|
||||
if (tarName == NULL)
|
||||
fatalError( "Option requires an argument: No file specified\n");
|
||||
if (!strcmp(tarName, "-") && createFlag == TRUE)
|
||||
tostdoutFlag = TRUE;
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
case 'e':
|
||||
if (strcmp(*argv, "-exclude")==0) {
|
||||
if (--argc == 0) {
|
||||
fatalError( "Option requires an argument: No file specified\n");
|
||||
}
|
||||
excludeList=xrealloc( excludeList, sizeof(char**) * (excludeListSize+2));
|
||||
if (strcmp(*argv, "xclude")==0) {
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = *(++argv);
|
||||
if (excludeList[excludeListSize] == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
/* Remove leading "/"s */
|
||||
if (*excludeList[excludeListSize] =='/')
|
||||
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||
@@ -218,13 +259,36 @@ extern int tar_main(int argc, char **argv)
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
}
|
||||
case 'X':
|
||||
if (*excludeFileName != '-')
|
||||
error_msg_and_die("Only one 'X' option allowed\n");
|
||||
excludeFileName = *(++argv);
|
||||
if (excludeFileName == NULL)
|
||||
error_msg_and_die("Option requires an argument: No file specified\n");
|
||||
fileList = fopen (excludeFileName, "r");
|
||||
if (! fileList)
|
||||
error_msg_and_die("Exclude file: file not found\n");
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Remove leading "/"s */
|
||||
while (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize]++;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
fclose(fileList);
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
#endif
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
usage(tar_usage);
|
||||
}
|
||||
++(*argv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,17 +298,43 @@ extern int tar_main(int argc, char **argv)
|
||||
*/
|
||||
if (createFlag == TRUE) {
|
||||
#ifndef BB_FEATURE_TAR_CREATE
|
||||
fatalError( "This version of tar was not compiled with tar creation support.\n");
|
||||
error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
|
||||
#else
|
||||
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
if (unzipFlag==TRUE)
|
||||
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip\n");
|
||||
#endif
|
||||
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
|
||||
#endif
|
||||
}
|
||||
if (listFlag == TRUE || extractFlag == TRUE) {
|
||||
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, &argv[optind], excludeList));
|
||||
int tarFd;
|
||||
if (*argv)
|
||||
extractList = argv;
|
||||
/* Open the tar file for reading. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
tarFd = fileno(stdin);
|
||||
else
|
||||
tarFd = open(tarName, O_RDONLY);
|
||||
if (tarFd < 0)
|
||||
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* unzip tarFd in a seperate process */
|
||||
if (unzipFlag == TRUE)
|
||||
tarFd = tar_unzip_init(tarFd);
|
||||
#endif
|
||||
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
||||
verboseFlag, extractList, excludeList);
|
||||
}
|
||||
|
||||
if (status == TRUE)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
|
||||
flagError:
|
||||
fatalError( "Exactly one of 'c', 'x' or 't' must be specified\n");
|
||||
error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -274,10 +364,10 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
|
||||
/* Create the path to the file, just in case it isn't there...
|
||||
* This should not screw up path permissions or anything. */
|
||||
createPath(header->name, 0777);
|
||||
create_path(header->name, 0777);
|
||||
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
|
||||
header->mode & ~S_IFMT)) < 0) {
|
||||
errorMsg(io_error, header->name, strerror(errno));
|
||||
error_msg(io_error, header->name, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
}
|
||||
@@ -295,9 +385,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
readSize = size;
|
||||
writeSize = size;
|
||||
}
|
||||
if ( (readSize = fullRead(header->tarFd, buffer, readSize)) <= 0 ) {
|
||||
if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
|
||||
/* Tarball seems to have a problem */
|
||||
errorMsg("Unexpected EOF in archive\n");
|
||||
error_msg("Unexpected EOF in archive\n");
|
||||
return( FALSE);
|
||||
}
|
||||
if ( readSize < writeSize )
|
||||
@@ -306,9 +396,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
/* Write out the file, if we are supposed to be doing that */
|
||||
if (extractFlag==TRUE) {
|
||||
|
||||
if ((actualWriteSz=fullWrite(outFd, buffer, writeSize)) != writeSize ) {
|
||||
if ((actualWriteSz=full_write(outFd, buffer, writeSize)) != writeSize ) {
|
||||
/* Output file seems to have a problem */
|
||||
errorMsg(io_error, header->name, strerror(errno));
|
||||
error_msg(io_error, header->name, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
} else {
|
||||
@@ -334,13 +424,13 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
if (extractFlag==FALSE || tostdoutFlag==TRUE)
|
||||
return( TRUE);
|
||||
|
||||
if (createPath(header->name, header->mode) != TRUE) {
|
||||
errorMsg("%s: Cannot mkdir: %s\n",
|
||||
if (create_path(header->name, header->mode) != TRUE) {
|
||||
error_msg("%s: Cannot mkdir: %s\n",
|
||||
header->name, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
/* make the final component, just in case it was
|
||||
* omitted by createPath() (which will skip the
|
||||
* omitted by create_path() (which will skip the
|
||||
* directory if it doesn't have a terminating '/') */
|
||||
if (mkdir(header->name, header->mode) == 0) {
|
||||
fixUpPermissions(header);
|
||||
@@ -355,7 +445,7 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
return( TRUE);
|
||||
|
||||
if (link(header->linkname, header->name) < 0) {
|
||||
errorMsg("%s: Cannot create hard link to '%s': %s\n",
|
||||
error_msg("%s: Cannot create hard link to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -373,7 +463,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (symlink(header->linkname, header->name) < 0) {
|
||||
errorMsg("%s: Cannot create symlink to '%s': %s\n",
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -388,7 +478,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
/* Do not change permissions or date on symlink,
|
||||
* since it changes the pointed to file instead. duh. */
|
||||
#else
|
||||
errorMsg("%s: Cannot create symlink to '%s': %s\n",
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
header->name, header->linkname,
|
||||
"symlinks not supported");
|
||||
#endif
|
||||
@@ -403,13 +493,13 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
|
||||
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
|
||||
errorMsg("%s: Cannot mknod: %s\n",
|
||||
error_msg("%s: Cannot mknod: %s\n",
|
||||
header->name, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
} else if (S_ISFIFO(header->mode)) {
|
||||
if (mkfifo(header->name, header->mode) < 0) {
|
||||
errorMsg("%s: Cannot mkfifo: %s\n",
|
||||
error_msg("%s: Cannot mkfifo: %s\n",
|
||||
header->name, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -428,9 +518,9 @@ static long getOctal(const char *cp, int size)
|
||||
long val = 0;
|
||||
|
||||
for(;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size == 0) || !isOctal(*cp))
|
||||
if ((size == 0) || !is_octal(*cp))
|
||||
return -1;
|
||||
for(; (size > 0) && isOctal(*cp); size--) {
|
||||
for(; (size > 0) && is_octal(*cp); size--) {
|
||||
val = val * 8 + *cp++ - '0';
|
||||
}
|
||||
for (;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
@@ -457,7 +547,7 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
++*(header->name);
|
||||
|
||||
if (alreadyWarned == FALSE) {
|
||||
errorMsg("Removing leading '/' from member names\n");
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
alreadyWarned = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -494,33 +584,23 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
* Read a tar file and extract or list the specified files within it.
|
||||
* If the list is empty than all files are extracted or listed.
|
||||
*/
|
||||
static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList,
|
||||
char** excludeList)
|
||||
{
|
||||
int status, tarFd=-1;
|
||||
int status;
|
||||
int errorFlag=FALSE;
|
||||
int skipNextHeaderFlag=FALSE;
|
||||
TarHeader rawHeader;
|
||||
TarInfo header;
|
||||
char** tmpList;
|
||||
|
||||
/* Open the tar file for reading. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
tarFd = fileno(stdin);
|
||||
else
|
||||
tarFd = open(tarName, O_RDONLY);
|
||||
if (tarFd < 0) {
|
||||
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up permission setting for us later. */
|
||||
umask(0);
|
||||
|
||||
/* Read the tar file, and iterate over it one file at a time */
|
||||
while ( (status = fullRead(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
|
||||
while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
|
||||
|
||||
/* Try to read the header */
|
||||
if ( readTarHeader(&rawHeader, &header) == FALSE ) {
|
||||
@@ -528,7 +608,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
goto endgame;
|
||||
} else {
|
||||
errorFlag=TRUE;
|
||||
errorMsg("Bad tar header, skipping\n");
|
||||
error_msg("Bad tar header, skipping\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -539,13 +619,15 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
/* Skip funky extra GNU headers that precede long files */
|
||||
if ( (header.type == GNULONGNAME) || (header.type == GNULONGLINK) ) {
|
||||
skipNextHeaderFlag=TRUE;
|
||||
tarExtractRegularFile(&header, FALSE, FALSE);
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
continue;
|
||||
}
|
||||
if ( skipNextHeaderFlag == TRUE ) {
|
||||
skipNextHeaderFlag=FALSE;
|
||||
errorMsg(name_longer_then_foo, NAME_SIZE);
|
||||
tarExtractRegularFile(&header, FALSE, FALSE);
|
||||
error_msg(name_longer_than_foo, NAME_SIZE);
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -564,7 +646,8 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
tarExtractRegularFile(&header, FALSE, FALSE);
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
skipFlag=TRUE;
|
||||
break;
|
||||
@@ -575,7 +658,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (*extractList != NULL) {
|
||||
if (extractList != NULL) {
|
||||
int skipFlag = TRUE;
|
||||
for (tmpList = extractList; *tmpList != NULL; tmpList++) {
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
@@ -586,13 +669,17 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
skipFlag = FALSE;
|
||||
memmove(extractList+1, extractList,
|
||||
sizeof(*extractList)*(tmpList-extractList));
|
||||
extractList++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* There are not the droids you're looking for, move along */
|
||||
if (skipFlag == TRUE) {
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 )
|
||||
tarExtractRegularFile(&header, FALSE, FALSE);
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -604,14 +691,12 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
char buf[35];
|
||||
struct tm *tm = localtime (&(header.mtime));
|
||||
|
||||
len=printf("%s ", modeString(header.mode));
|
||||
memset(buf, 0, 8*sizeof(char));
|
||||
len=printf("%s ", mode_string(header.mode));
|
||||
my_getpwuid(buf, header.uid);
|
||||
if (! *buf)
|
||||
len+=printf("%d", header.uid);
|
||||
else
|
||||
len+=printf("%s", buf);
|
||||
memset(buf, 0, 8*sizeof(char));
|
||||
my_getgrgid(buf, header.gid);
|
||||
if (! *buf)
|
||||
len+=printf("/%-d ", header.gid);
|
||||
@@ -697,7 +782,7 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errorMsg("Unknown file type '%c' in tar file\n", header.type);
|
||||
error_msg("Unknown file type '%c' in tar file\n", header.type);
|
||||
close( tarFd);
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -705,11 +790,11 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
close(tarFd);
|
||||
if (status > 0) {
|
||||
/* Bummer - we read a partial header */
|
||||
errorMsg( "Error reading '%s': %s\n", tarName, strerror(errno));
|
||||
error_msg( "Error reading tar file: %s\n", strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
else if (errorFlag==TRUE) {
|
||||
errorMsg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
return( FALSE);
|
||||
} else
|
||||
return( status);
|
||||
@@ -717,9 +802,15 @@ static int readTarFile(const char* tarName, int extractFlag, int listFlag,
|
||||
/* Stuff to do when we are done */
|
||||
endgame:
|
||||
close( tarFd);
|
||||
if (extractList != NULL) {
|
||||
for (; *extractList != NULL; extractList++) {
|
||||
error_msg("%s: Not found in archive\n", *extractList);
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
}
|
||||
if ( *(header.name) == '\0' ) {
|
||||
if (errorFlag==TRUE)
|
||||
errorMsg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
else
|
||||
return( TRUE);
|
||||
}
|
||||
@@ -729,6 +820,21 @@ endgame:
|
||||
|
||||
#ifdef BB_FEATURE_TAR_CREATE
|
||||
|
||||
/*
|
||||
** writeTarFile(), writeFileToTarball(), and writeTarHeader() are
|
||||
** the only functions that deal with the HardLinkInfo structure.
|
||||
** Even these functions use the xxxHardLinkInfo() functions.
|
||||
*/
|
||||
typedef struct HardLinkInfo HardLinkInfo;
|
||||
struct HardLinkInfo
|
||||
{
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
};
|
||||
|
||||
/* Some info to be carried along when creating a new tarball */
|
||||
struct TarBallInfo
|
||||
{
|
||||
@@ -741,10 +847,62 @@ struct TarBallInfo
|
||||
to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
char** excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
};
|
||||
typedef struct TarBallInfo TarBallInfo;
|
||||
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static void
|
||||
addHardLinkInfo (HardLinkInfo **hlInfoHeadPtr, dev_t dev, ino_t ino,
|
||||
short linkCount, const char *name)
|
||||
{
|
||||
/* Note: hlInfoHeadPtr can never be NULL! */
|
||||
HardLinkInfo *hlInfo;
|
||||
|
||||
hlInfo = (HardLinkInfo *)xmalloc(sizeof(HardLinkInfo)+strlen(name)+1);
|
||||
if (hlInfo) {
|
||||
hlInfo->next = *hlInfoHeadPtr;
|
||||
*hlInfoHeadPtr = hlInfo;
|
||||
hlInfo->dev = dev;
|
||||
hlInfo->ino = ino;
|
||||
hlInfo->linkCount = linkCount;
|
||||
strcpy(hlInfo->name, name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
freeHardLinkInfo (HardLinkInfo **hlInfoHeadPtr)
|
||||
{
|
||||
HardLinkInfo *hlInfo = NULL;
|
||||
HardLinkInfo *hlInfoNext = NULL;
|
||||
|
||||
if (hlInfoHeadPtr) {
|
||||
hlInfo = *hlInfoHeadPtr;
|
||||
while (hlInfo) {
|
||||
hlInfoNext = hlInfo->next;
|
||||
free(hlInfo);
|
||||
hlInfo = hlInfoNext;
|
||||
}
|
||||
*hlInfoHeadPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static HardLinkInfo *
|
||||
findHardLinkInfo (HardLinkInfo *hlInfo, dev_t dev, ino_t ino)
|
||||
{
|
||||
while(hlInfo) {
|
||||
if ((ino == hlInfo->ino) && (dev == hlInfo->dev))
|
||||
break;
|
||||
hlInfo = hlInfo->next;
|
||||
}
|
||||
return(hlInfo);
|
||||
}
|
||||
|
||||
/* Put an octal string into the specified buffer.
|
||||
* The number is zero and space padded and possibly null padded.
|
||||
* Returns TRUE if successful. */
|
||||
@@ -796,7 +954,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
if (*fileName=='/') {
|
||||
static int alreadyWarned=FALSE;
|
||||
if (alreadyWarned==FALSE) {
|
||||
errorMsg("Removing leading '/' from member names\n");
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
alreadyWarned=TRUE;
|
||||
}
|
||||
strncpy(header.name, fileName+1, sizeof(header.name));
|
||||
@@ -839,14 +997,17 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
if (! *header.uname)
|
||||
strcpy(header.uname, "root");
|
||||
|
||||
/* WARNING/NOTICE: I break Hard Links */
|
||||
if (S_ISLNK(statbuf->st_mode)) {
|
||||
if (tbInfo->hlInfo) {
|
||||
/* This is a hard link */
|
||||
header.typeflag = LNKTYPE;
|
||||
strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname));
|
||||
} else if (S_ISLNK(statbuf->st_mode)) {
|
||||
int link_size=0;
|
||||
char buffer[BUFSIZ];
|
||||
header.typeflag = SYMTYPE;
|
||||
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
|
||||
if ( link_size < 0) {
|
||||
errorMsg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
buffer[link_size] = '\0';
|
||||
@@ -868,7 +1029,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
header.typeflag = REGTYPE;
|
||||
putOctal(header.size, sizeof(header.size), statbuf->st_size);
|
||||
} else {
|
||||
errorMsg("%s: Unknown file type\n", fileName);
|
||||
error_msg("%s: Unknown file type\n", fileName);
|
||||
return ( FALSE);
|
||||
}
|
||||
|
||||
@@ -884,8 +1045,8 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
putOctal(header.chksum, 7, chksum);
|
||||
|
||||
/* Now write the header out to disk */
|
||||
if ((size=fullWrite(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
|
||||
errorMsg(io_error, fileName, strerror(errno));
|
||||
if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
|
||||
error_msg(io_error, fileName, strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
/* Pad the header up to the tar block size */
|
||||
@@ -908,9 +1069,25 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *)userData;
|
||||
|
||||
/*
|
||||
** Check to see if we are dealing with a hard link.
|
||||
** If so -
|
||||
** Treat the first occurance of a given dev/inode as a file while
|
||||
** treating any additional occurances as hard links. This is done
|
||||
** by adding the file information to the HardLinkInfo linked list.
|
||||
*/
|
||||
tbInfo->hlInfo = NULL;
|
||||
if (statbuf->st_nlink > 1) {
|
||||
tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf->st_dev,
|
||||
statbuf->st_ino);
|
||||
if (tbInfo->hlInfo == NULL)
|
||||
addHardLinkInfo (&tbInfo->hlInfoHead, statbuf->st_dev,
|
||||
statbuf->st_ino, statbuf->st_nlink, fileName);
|
||||
}
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
errorMsg("%s: socket ignored\n", fileName);
|
||||
error_msg("%s: socket ignored\n", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
@@ -919,12 +1096,12 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
* the new tarball */
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
|
||||
tbInfo->statBuf.st_ino == statbuf->st_ino) {
|
||||
errorMsg("%s: file is the archive; skipping\n", fileName);
|
||||
error_msg("%s: file is the archive; skipping\n", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
if (strlen(fileName) >= NAME_SIZE) {
|
||||
errorMsg(name_longer_then_foo, NAME_SIZE);
|
||||
error_msg(name_longer_than_foo, NAME_SIZE);
|
||||
return ( TRUE);
|
||||
}
|
||||
|
||||
@@ -933,28 +1110,29 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
}
|
||||
|
||||
/* Now, if the file is a regular file, copy it out to the tarball */
|
||||
if (S_ISREG(statbuf->st_mode)) {
|
||||
if ((tbInfo->hlInfo == NULL)
|
||||
&& (S_ISREG(statbuf->st_mode))) {
|
||||
int inputFileFd;
|
||||
char buffer[BUFSIZ];
|
||||
ssize_t size=0, readSize=0;
|
||||
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
|
||||
errorMsg("%s: Cannot open: %s\n", fileName, strerror(errno));
|
||||
error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
/* write the file to the archive */
|
||||
while ( (size = fullRead(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
|
||||
if (fullWrite(tbInfo->tarFd, buffer, size) != size ) {
|
||||
while ( (size = full_read(inputFileFd, buffer, sizeof(buffer))) > 0 ) {
|
||||
if (full_write(tbInfo->tarFd, buffer, size) != size ) {
|
||||
/* Output file seems to have a problem */
|
||||
errorMsg(io_error, fileName, strerror(errno));
|
||||
error_msg(io_error, fileName, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
readSize+=size;
|
||||
}
|
||||
if (size == -1) {
|
||||
errorMsg(io_error, fileName, strerror(errno));
|
||||
error_msg(io_error, fileName, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
/* Pad the file up to the tar block size */
|
||||
@@ -967,41 +1145,43 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
static int writeTarFile(const char* tarName, int tostdoutFlag,
|
||||
int verboseFlag, int argc, char **argv, char** excludeList)
|
||||
static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
char** excludeList)
|
||||
{
|
||||
int tarFd=-1;
|
||||
int errorFlag=FALSE;
|
||||
ssize_t size;
|
||||
struct TarBallInfo tbInfo;
|
||||
tbInfo.verboseFlag = verboseFlag;
|
||||
tbInfo.hlInfoHead = NULL;
|
||||
|
||||
/* Make sure there is at least one file to tar up. */
|
||||
if (argc <= 0)
|
||||
fatalError("Cowardly refusing to create an empty archive\n");
|
||||
if (*argv == NULL)
|
||||
error_msg_and_die("Cowardly refusing to create an empty archive\n");
|
||||
|
||||
/* Open the tar file for writing. */
|
||||
if (tostdoutFlag == TRUE)
|
||||
if (!strcmp(tarName, "-"))
|
||||
tbInfo.tarFd = fileno(stdout);
|
||||
else
|
||||
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (tbInfo.tarFd < 0) {
|
||||
errorMsg( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return ( FALSE);
|
||||
}
|
||||
tbInfo.excludeList=excludeList;
|
||||
/* Store the stat info for the tarball's file, so
|
||||
* can avoid including the tarball into itself.... */
|
||||
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
|
||||
fatalError(io_error, tarName, strerror(errno));
|
||||
error_msg_and_die(io_error, tarName, strerror(errno));
|
||||
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up permission setting for us later. */
|
||||
umask(0);
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (argc-- > 0) {
|
||||
if (recursiveAction(*argv++, TRUE, FALSE, FALSE,
|
||||
while (*argv != NULL) {
|
||||
if (recursive_action(*argv++, TRUE, FALSE, FALSE,
|
||||
writeFileToTarball, writeFileToTarball,
|
||||
(void*) &tbInfo) == FALSE) {
|
||||
errorFlag = TRUE;
|
||||
@@ -1013,16 +1193,18 @@ static int writeTarFile(const char* tarName, int tostdoutFlag,
|
||||
}
|
||||
|
||||
/* To be pedantically correct, we would check if the tarball
|
||||
* is smaller then 20 tar blocks, and pad it if it was smaller,
|
||||
* is smaller than 20 tar blocks, and pad it if it was smaller,
|
||||
* but that isn't necessary for GNU tar interoperability, and
|
||||
* so is considered a waste of space */
|
||||
|
||||
/* Hang up the tools, close up shop, head home */
|
||||
close(tarFd);
|
||||
if (errorFlag == TRUE) {
|
||||
errorMsg("Error exit delayed from previous errors\n");
|
||||
error_msg("Error exit delayed from previous errors\n");
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return(FALSE);
|
||||
}
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -45,5 +45,5 @@ extern int basename_main(int argc, char **argv)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -4,365 +4,17 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
const struct BB_applet applets[] = {
|
||||
|
||||
#ifdef BB_AR
|
||||
{"ar", ar_main, _BB_DIR_USR_BIN, ar_usage},
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
{"basename", basename_main, _BB_DIR_USR_BIN, basename_usage},
|
||||
#endif
|
||||
{"busybox", busybox_main, _BB_DIR_BIN, NULL},
|
||||
#ifdef BB_CAT
|
||||
{"cat", cat_main, _BB_DIR_BIN, cat_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage},
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
{"chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage},
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
{"chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage},
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
{"clear", clear_main, _BB_DIR_USR_BIN, clear_usage},
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
{"cut", cut_main, _BB_DIR_USR_BIN, cut_usage},
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
{"date", date_main, _BB_DIR_BIN, date_usage},
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
{"dc", dc_main, _BB_DIR_USR_BIN, dc_usage},
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
{"dd", dd_main, _BB_DIR_BIN, dd_usage},
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
{"df", df_main, _BB_DIR_BIN, df_usage},
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
{"dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage},
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
{"dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage},
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
{"dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage},
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
{"du", du_main, _BB_DIR_USR_BIN, du_usage},
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
{"dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage},
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
{"dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage},
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
{"echo", echo_main, _BB_DIR_BIN, echo_usage},
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
{"expr", expr_main, _BB_DIR_USR_BIN, expr_usage},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"false", false_main, _BB_DIR_BIN, false_usage},
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
{"fbset", fbset_main, _BB_DIR_USR_SBIN, NULL},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
{"fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage},
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
{"find", find_main, _BB_DIR_USR_BIN, find_usage},
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
{"free", free_main, _BB_DIR_USR_BIN, free_usage},
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
{"freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage},
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
{"deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage},
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
{"fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage},
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
{"getopt", getopt_main, _BB_DIR_BIN},
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
{"grep", grep_main, _BB_DIR_BIN, grep_usage},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage},
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
{"gzip", gzip_main, _BB_DIR_BIN, gzip_usage},
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
{"halt", halt_main, _BB_DIR_SBIN, halt_usage},
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
{"head", head_main, _BB_DIR_USR_BIN, head_usage},
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
{"hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage},
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
{"hostname", hostname_main, _BB_DIR_BIN, hostname_usage},
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
{"id", id_main, _BB_DIR_USR_BIN, id_usage},
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
{"init", init_main, _BB_DIR_SBIN, NULL},
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
{"insmod", insmod_main, _BB_DIR_SBIN, insmod_usage},
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
{"kill", kill_main, _BB_DIR_BIN, kill_usage},
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
{"killall", kill_main, _BB_DIR_USR_BIN, kill_usage},
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
{"length", length_main, _BB_DIR_USR_BIN, length_usage},
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
{"linuxrc", init_main, _BB_DIR_ROOT, NULL},
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
{"ln", ln_main, _BB_DIR_BIN, ln_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
{"loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
{"loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
{"loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage},
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
{"logger", logger_main, _BB_DIR_USR_BIN, logger_usage},
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
{"logname", logname_main, _BB_DIR_USR_BIN, logname_usage},
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
{"ls", ls_main, _BB_DIR_BIN, ls_usage},
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
{"lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
{"makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage},
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
{"md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage},
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
{"mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage},
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
{"mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage},
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
{"mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage},
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
{"mknod", mknod_main, _BB_DIR_BIN, mknod_usage},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
{"mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage},
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
{"mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage},
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
{"nc", nc_main, _BB_DIR_USR_BIN, nc_usage},
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
{"more", more_main, _BB_DIR_BIN, more_usage},
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
{"mount", mount_main, _BB_DIR_BIN, mount_usage},
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
{"mt", mt_main, _BB_DIR_BIN, mt_usage},
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
{"mv", cp_mv_main, _BB_DIR_BIN, mv_usage},
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
{"nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage},
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
{"ping", ping_main, _BB_DIR_BIN, ping_usage},
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
{"poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage},
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
{"printf", printf_main, _BB_DIR_USR_BIN, printf_usage},
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
{"ps", ps_main, _BB_DIR_BIN, ps_usage},
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
{"pwd", pwd_main, _BB_DIR_BIN, pwd_usage},
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
{"renice", renice_main, _BB_DIR_USR_BIN},
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
{"reset", reset_main, _BB_DIR_USR_BIN, reset_usage},
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
{"rm", rm_main, _BB_DIR_BIN, rm_usage},
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
{"rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage},
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
{"rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage},
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
{"sed", sed_main, _BB_DIR_BIN, sed_usage},
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
{"setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage},
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
{"sh", shell_main, _BB_DIR_BIN, shell_usage},
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
{"sleep", sleep_main, _BB_DIR_BIN, sleep_usage},
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
{"sort", sort_main, _BB_DIR_USR_BIN, sort_usage},
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
{"sync", sync_main, _BB_DIR_BIN, sync_usage},
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
{"syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage},
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
{"swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage},
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
{"tail", tail_main, _BB_DIR_USR_BIN, tail_usage},
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
{"tar", tar_main, _BB_DIR_BIN, tar_usage},
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
{"telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"test", test_main, _BB_DIR_USR_BIN, test_usage},
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
{"tee", tee_main, _BB_DIR_USR_BIN, tee_usage},
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
{"touch", touch_main, _BB_DIR_BIN, touch_usage},
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
{"tr", tr_main, _BB_DIR_USR_BIN, tr_usage},
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
{"true", true_main, _BB_DIR_BIN, true_usage},
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
{"tty", tty_main, _BB_DIR_USR_BIN, tty_usage},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
{"umount", umount_main, _BB_DIR_BIN, umount_usage},
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
{"uname", uname_main, _BB_DIR_BIN, uname_usage},
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
{"uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage},
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
{"unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage},
|
||||
#endif
|
||||
#ifdef BB_UNRPM
|
||||
{"unrpm", unrpm_main, _BB_DIR_USR_BIN, unrpm_usage},
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
{"update", update_main, _BB_DIR_SBIN, update_usage},
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
{"uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage},
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
{"uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage},
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
{"uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage},
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
{"usleep", usleep_main, _BB_DIR_BIN, usleep_usage},
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
{"wc", wc_main, _BB_DIR_USR_BIN, wc_usage},
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
{"wget", wget_main, _BB_DIR_USR_BIN, wget_usage},
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
{"which", which_main, _BB_DIR_USR_BIN, which_usage},
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
{"whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage},
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
{"xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage},
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
{"yes", yes_main, _BB_DIR_USR_BIN, yes_usage},
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
{"zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage},
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
{"[", test_main, _BB_DIR_USR_BIN, test_usage},
|
||||
#endif
|
||||
{0,NULL,0,NULL}
|
||||
};
|
||||
|
||||
const char *applet_name;
|
||||
|
||||
@@ -402,7 +54,7 @@ static char *busybox_fullpath()
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
errorMsg("%s: %s\n", proc, strerror(errno));
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
@@ -426,18 +78,17 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
errorMsg("%s: %s\n", command, strerror(errno));
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
const struct BB_applet *a = applets;
|
||||
applet_name = "busybox";
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -475,8 +126,6 @@ int main(int argc, char **argv)
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
*argv = (char*)applet_name;
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
@@ -485,14 +134,16 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(applet_name, a->name) == 0) {
|
||||
if (a->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(a->usage);
|
||||
exit(((*(a->main)) (argc, argv)));
|
||||
}
|
||||
a++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
@@ -500,10 +151,12 @@ int main(int argc, char **argv)
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
@@ -528,8 +181,30 @@ int busybox_main(int argc, char **argv)
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
}
|
||||
/* If we've already been here once, exit now */
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
#define FALSE ((int) 1)
|
||||
#define TRUE ((int) 0)
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
|
||||
/* for mtab.c */
|
||||
#define MTAB_GETMOUNTPT '1'
|
||||
@@ -55,11 +55,8 @@
|
||||
#define BUF_SIZE 8192
|
||||
#define EXPAND_ALLOC 1024
|
||||
|
||||
|
||||
#define isBlank(ch) (((ch) == ' ') || ((ch) == '\t'))
|
||||
#define isDecimal(ch) (((ch) >= '0') && ((ch) <= '9'))
|
||||
#define isOctal(ch) (((ch) >= '0') && ((ch) <= '7'))
|
||||
#define isWildCard(ch) (((ch) == '*') || ((ch) == '?') || ((ch) == '['))
|
||||
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
|
||||
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
/* Macros for min/max. */
|
||||
#ifndef MIN
|
||||
@@ -108,242 +105,28 @@ struct BB_applet {
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
|
||||
extern int ar_main(int argc, char **argv);
|
||||
extern int basename_main(int argc, char **argv);
|
||||
extern int bogomips_main(int argc, char **argv);
|
||||
extern int busybox_main(int argc, char** argv);
|
||||
extern int cat_main(int argc, char** argv);
|
||||
extern int chmod_chown_chgrp_main(int argc, char** argv);
|
||||
extern int chroot_main(int argc, char** argv);
|
||||
extern int chvt_main(int argc, char** argv);
|
||||
extern int clear_main(int argc, char** argv);
|
||||
extern int cp_mv_main(int argc, char** argv);
|
||||
extern int cut_main(int argc, char** argv);
|
||||
extern int date_main(int argc, char** argv);
|
||||
extern int dc_main(int argc, char** argv);
|
||||
extern int dd_main(int argc, char** argv);
|
||||
extern int dirname_main(int argc, char** argv);
|
||||
extern int deallocvt_main(int argc, char** argv);
|
||||
extern int df_main(int argc, char** argv);
|
||||
extern int dmesg_main(int argc, char** argv);
|
||||
extern int dos2unix_main(int argc, char** argv);
|
||||
extern int du_main(int argc, char** argv);
|
||||
extern int dumpkmap_main(int argc, char** argv);
|
||||
extern int dutmp_main(int argc, char** argv);
|
||||
extern int echo_main(int argc, char** argv);
|
||||
extern int expr_main(int argc, char** argv);
|
||||
extern int false_main(int argc, char** argv);
|
||||
extern int fbset_main(int argc, char** argv);
|
||||
extern int fdisk_main(int argc, char** argv);
|
||||
extern int fdflush_main(int argc, char **argv);
|
||||
extern int fsck_minix_main(int argc, char **argv);
|
||||
extern int find_main(int argc, char** argv);
|
||||
extern int free_main(int argc, char** argv);
|
||||
extern int freeramdisk_main(int argc, char** argv);
|
||||
extern int getopt_main(int argc, char** argv);
|
||||
extern int grep_main(int argc, char** argv);
|
||||
extern int gunzip_main (int argc, char** argv);
|
||||
extern int gzip_main(int argc, char** argv);
|
||||
extern int halt_main(int argc, char** argv);
|
||||
extern int head_main(int argc, char** argv);
|
||||
extern int hostid_main(int argc, char** argv);
|
||||
extern int hostname_main(int argc, char** argv);
|
||||
extern int id_main(int argc, char** argv);
|
||||
extern int init_main(int argc, char** argv);
|
||||
extern int insmod_main(int argc, char** argv);
|
||||
extern int kill_main(int argc, char** argv);
|
||||
extern int length_main(int argc, char** argv);
|
||||
extern int ln_main(int argc, char** argv);
|
||||
extern int loadacm_main(int argc, char** argv);
|
||||
extern int loadfont_main(int argc, char** argv);
|
||||
extern int loadkmap_main(int argc, char** argv);
|
||||
extern int losetup_main(int argc, char** argv);
|
||||
extern int logger_main(int argc, char **argv);
|
||||
extern int logname_main(int argc, char **argv);
|
||||
extern int ls_main(int argc, char** argv);
|
||||
extern int lsmod_main(int argc, char** argv);
|
||||
extern int makedevs_main(int argc, char** argv);
|
||||
extern int md5sum_main(int argc, char** argv);
|
||||
extern int mkdir_main(int argc, char** argv);
|
||||
extern int mkfifo_main(int argc, char **argv);
|
||||
extern int mkfs_minix_main(int argc, char **argv);
|
||||
extern int mknod_main(int argc, char** argv);
|
||||
extern int mkswap_main(int argc, char** argv);
|
||||
extern int mktemp_main(int argc, char **argv);
|
||||
extern int nc_main(int argc, char** argv);
|
||||
extern int more_main(int argc, char** argv);
|
||||
extern int mount_main(int argc, char** argv);
|
||||
extern int mt_main(int argc, char** argv);
|
||||
extern int nslookup_main(int argc, char **argv);
|
||||
extern int ping_main(int argc, char **argv);
|
||||
extern int poweroff_main(int argc, char **argv);
|
||||
extern int printf_main(int argc, char** argv);
|
||||
extern int ps_main(int argc, char** argv);
|
||||
extern int pwd_main(int argc, char** argv);
|
||||
extern int rdate_main(int argc, char** argv);
|
||||
extern int reboot_main(int argc, char** argv);
|
||||
extern int renice_main(int argc, char** argv);
|
||||
extern int reset_main(int argc, char** argv);
|
||||
extern int rm_main(int argc, char** argv);
|
||||
extern int rmdir_main(int argc, char **argv);
|
||||
extern int rmmod_main(int argc, char** argv);
|
||||
extern int sed_main(int argc, char** argv);
|
||||
extern int sfdisk_main(int argc, char** argv);
|
||||
extern int setkeycodes_main(int argc, char** argv);
|
||||
extern int shell_main(int argc, char** argv);
|
||||
extern int sleep_main(int argc, char** argv);
|
||||
extern int sort_main(int argc, char** argv);
|
||||
extern int swap_on_off_main(int argc, char** argv);
|
||||
extern int sync_main(int argc, char** argv);
|
||||
extern int syslogd_main(int argc, char **argv);
|
||||
extern int tail_main(int argc, char** argv);
|
||||
extern int tar_main(int argc, char** argv);
|
||||
extern int tee_main(int argc, char** argv);
|
||||
extern int test_main(int argc, char** argv);
|
||||
extern int telnet_main(int argc, char** argv);
|
||||
extern int touch_main(int argc, char** argv);
|
||||
extern int tr_main(int argc, char** argv);
|
||||
extern int true_main(int argc, char** argv);
|
||||
extern int tput_main(int argc, char** argv);
|
||||
extern int tryopen_main(int argc, char** argv);
|
||||
extern int tty_main(int argc, char** argv);
|
||||
extern int umount_main(int argc, char** argv);
|
||||
extern int uname_main(int argc, char** argv);
|
||||
extern int uniq_main(int argc, char** argv);
|
||||
extern int unix2dos_main(int argc, char** argv);
|
||||
extern int unrpm_main(int argc, char** argv);
|
||||
extern int update_main(int argc, char** argv);
|
||||
extern int uptime_main(int argc, char** argv);
|
||||
extern int usleep_main(int argc, char** argv);
|
||||
extern int uuencode_main(int argc, char** argv);
|
||||
extern int uudecode_main(int argc, char** argv);
|
||||
extern int wc_main(int argc, char** argv);
|
||||
extern int wget_main(int argc, char** argv);
|
||||
extern int which_main(int argc, char** argv);
|
||||
extern int whoami_main(int argc, char** argv);
|
||||
extern int xargs_main(int argc, char** argv);
|
||||
extern int yes_main(int argc, char** argv);
|
||||
|
||||
extern const char ar_usage[];
|
||||
extern const char basename_usage[];
|
||||
extern const char cat_usage[];
|
||||
extern const char chgrp_usage[];
|
||||
extern const char chmod_usage[];
|
||||
extern const char chown_usage[];
|
||||
extern const char chroot_usage[];
|
||||
extern const char chvt_usage[];
|
||||
extern const char clear_usage[];
|
||||
extern const char cp_usage[];
|
||||
extern const char cut_usage[];
|
||||
extern const char date_usage[];
|
||||
extern const char dc_usage[];
|
||||
extern const char dd_usage[];
|
||||
extern const char deallocvt_usage[];
|
||||
extern const char df_usage[];
|
||||
extern const char dirname_usage[];
|
||||
extern const char dmesg_usage[];
|
||||
extern const char dos2unix_usage[];
|
||||
extern const char du_usage[];
|
||||
extern const char dumpkmap_usage[];
|
||||
extern const char dutmp_usage[];
|
||||
extern const char echo_usage[];
|
||||
extern const char expr_usage[];
|
||||
extern const char false_usage[];
|
||||
extern const char fdflush_usage[];
|
||||
extern const char find_usage[];
|
||||
extern const char free_usage[];
|
||||
extern const char freeramdisk_usage[];
|
||||
extern const char fsck_minix_usage[];
|
||||
extern const char grep_usage[];
|
||||
extern const char gunzip_usage[];
|
||||
extern const char gzip_usage[];
|
||||
extern const char halt_usage[];
|
||||
extern const char head_usage[];
|
||||
extern const char hostid_usage[];
|
||||
extern const char hostname_usage[];
|
||||
extern const char id_usage[];
|
||||
extern const char insmod_usage[];
|
||||
extern const char kill_usage[];
|
||||
extern const char killall_usage[];
|
||||
extern const char length_usage[];
|
||||
extern const char ln_usage[];
|
||||
extern const char loadacm_usage[];
|
||||
extern const char loadfont_usage[];
|
||||
extern const char loadkmap_usage[];
|
||||
extern const char logger_usage[];
|
||||
extern const char logname_usage[];
|
||||
extern const char ls_usage[];
|
||||
extern const char lsmod_usage[];
|
||||
extern const char makedevs_usage[];
|
||||
extern const char md5sum_usage[];
|
||||
extern const char mkdir_usage[];
|
||||
extern const char mkfifo_usage[];
|
||||
extern const char mkfs_minix_usage[];
|
||||
extern const char mknod_usage[];
|
||||
extern const char mkswap_usage[];
|
||||
extern const char mktemp_usage[];
|
||||
extern const char more_usage[];
|
||||
extern const char mount_usage[];
|
||||
extern const char mt_usage[];
|
||||
extern const char mv_usage[];
|
||||
extern const char nc_usage[];
|
||||
extern const char nslookup_usage[];
|
||||
extern const char ping_usage[];
|
||||
extern const char poweroff_usage[];
|
||||
extern const char printf_usage[];
|
||||
extern const char ps_usage[];
|
||||
extern const char pwd_usage[];
|
||||
extern const char rdate_usage[];
|
||||
extern const char reboot_usage[];
|
||||
extern const char renice_usage[];
|
||||
extern const char reset_usage[];
|
||||
extern const char rm_usage[];
|
||||
extern const char rmdir_usage[];
|
||||
extern const char rmmod_usage[];
|
||||
extern const char sed_usage[];
|
||||
extern const char setkeycodes_usage[];
|
||||
extern const char shell_usage[];
|
||||
extern const char sleep_usage[];
|
||||
extern const char sort_usage[];
|
||||
extern const char swapoff_usage[];
|
||||
extern const char swapon_usage[];
|
||||
extern const char sync_usage[];
|
||||
extern const char syslogd_usage[];
|
||||
extern const char tail_usage[];
|
||||
extern const char tar_usage[];
|
||||
extern const char tee_usage[];
|
||||
extern const char telnet_usage[];
|
||||
extern const char test_usage[];
|
||||
extern const char touch_usage[];
|
||||
extern const char tr_usage[];
|
||||
extern const char true_usage[];
|
||||
extern const char tty_usage[];
|
||||
extern const char umount_usage[];
|
||||
extern const char uname_usage[];
|
||||
extern const char uniq_usage[];
|
||||
extern const char unix2dos_usage[];
|
||||
extern const char unrpm_usage[];
|
||||
extern const char update_usage[];
|
||||
extern const char uptime_usage[];
|
||||
extern const char usleep_usage[];
|
||||
extern const char uudecode_usage[];
|
||||
extern const char uuencode_usage[];
|
||||
extern const char wc_usage[];
|
||||
extern const char wget_usage[];
|
||||
extern const char which_usage[];
|
||||
extern const char whoami_usage[];
|
||||
extern const char xargs_usage[];
|
||||
extern const char yes_usage[];
|
||||
/* Automagically pull in all the applet function prototypes and
|
||||
* applet usage strings. These are all of the form:
|
||||
* extern int foo_main(int argc, char **argv);
|
||||
* extern const char foo_usage[];
|
||||
* These are all autogenerated from the set of currently defined applets.
|
||||
*/
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
extern const char *applet_name;
|
||||
extern int applet_name_compare(const void *x, const void *y);
|
||||
|
||||
extern void usage(const char *usage) __attribute__ ((noreturn));
|
||||
extern void errorMsg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void fatalError(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
|
||||
const char *modeString(int mode);
|
||||
const char *timeString(time_t timeVal);
|
||||
int isDirectory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
int isDevice(const char *name);
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
@@ -356,28 +139,28 @@ int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
|
||||
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
|
||||
void reset_ino_dev_hashtable(void);
|
||||
|
||||
int copyFile(const char *srcName, const char *destName,
|
||||
int copy_file(const char *srcName, const char *destName,
|
||||
int setModes, int followLinks, int forceFlag);
|
||||
int copySubFile(int srcFd, int dstFd, size_t remaining);
|
||||
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
|
||||
char *buildName(const char *dirName, const char *fileName);
|
||||
int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
int fullWrite(int fd, const char *buf, int len);
|
||||
int fullRead(int fd, char *buf, int len);
|
||||
int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
int full_write(int fd, const char *buf, int len);
|
||||
int full_read(int fd, char *buf, int len);
|
||||
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
void* userData);
|
||||
|
||||
extern int createPath (const char *name, int mode);
|
||||
extern int create_path (const char *name, int mode);
|
||||
extern int parse_mode( const char* s, mode_t* theMode);
|
||||
|
||||
extern int get_kernel_revision(void);
|
||||
|
||||
extern int get_console_fd(char* tty_name);
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table);
|
||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||
extern void write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags);
|
||||
extern void erase_mtab(const char * name);
|
||||
@@ -386,8 +169,8 @@ extern char *mtab_first(void **iter);
|
||||
extern char *mtab_next(void **iter);
|
||||
extern char *mtab_getinfo(const char *match, const char which);
|
||||
extern int check_wildcard_match(const char* text, const char* pattern);
|
||||
extern long getNum (const char *cp);
|
||||
extern pid_t* findPidByName( char* pidName);
|
||||
extern long atoi_w_units (const char *cp);
|
||||
extern pid_t* find_pid_by_name( char* pidName);
|
||||
extern int find_real_root_device_name(char* name);
|
||||
extern char *get_line_from_file(FILE *file);
|
||||
extern void print_file(FILE *file);
|
||||
@@ -395,6 +178,8 @@ extern int print_file_by_name(char *filename);
|
||||
extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern void xregcomp(regex_t *preg, const char *regex, int cflags);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
|
||||
+13
-16
@@ -1,19 +1,16 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="Config.h"
|
||||
MF="busybox.c"
|
||||
|
||||
LIST="$(gcc -E -dM $DF | sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/BB_\1/gp;' | sort)"
|
||||
|
||||
for def in ${LIST}; do
|
||||
i=`sed -n '/^#ifdef \<'$def'\>.*/,/^#endif/{ s/.*\"\(.*\)\".*\(_BB_DIR_[A-Z_]*\).*$/\2\/\1/gp; }' $MF`
|
||||
for j in $i; do
|
||||
if [ -z $j ] ; then
|
||||
continue;
|
||||
fi;
|
||||
echo $j | sed -e 's/_BB_DIR_ROOT//g;s/_BB_DIR_BIN/\/bin/g;' \
|
||||
-e 's/_BB_DIR_SBIN/\/sbin/g;s/_BB_DIR_USR_BIN/\/usr\/bin/g;' \
|
||||
-e 's/_BB_DIR_USR_SBIN/\/usr\/sbin/g;'
|
||||
done;
|
||||
done
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
+8
-5
@@ -1,10 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 ` \
|
||||
gcc -E -dM Config.h | \
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
` 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.47
|
||||
Version: 0.48
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
|
||||
@@ -26,20 +26,21 @@
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
exit(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+8
-8
@@ -64,7 +64,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
case CHMOD_APP:
|
||||
/* Parse the specified modes */
|
||||
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
|
||||
fatalError( "unknown mode: %s\n", theMode);
|
||||
error_msg_and_die( "unknown mode: %s\n", theMode);
|
||||
}
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
@@ -111,7 +111,7 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (argc == 0 || *argv == NULL) {
|
||||
errorMsg(too_few_args);
|
||||
error_msg(too_few_args);
|
||||
}
|
||||
|
||||
if (whichApp == CHMOD_APP) {
|
||||
@@ -149,24 +149,24 @@ int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
if (*argv == p)
|
||||
uid = my_getpwnam(*argv);
|
||||
if (uid == -1) {
|
||||
fatalError( "unknown user name: %s\n", *argv);
|
||||
error_msg_and_die( "unknown user name: %s\n", *argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
if (argc < 1) {
|
||||
fatalError(too_few_args);
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
while (argc-- > 1) {
|
||||
if (recursiveAction (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE)
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bad_group:
|
||||
fatalError( "unknown group name: %s\n", groupName);
|
||||
error_msg_and_die( "unknown group name: %s\n", groupName);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -54,10 +54,10 @@ int chroot_main(int argc, char **argv)
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
exit (0);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
fatalError("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ int chvt_main(int argc, char **argv)
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,5 +29,5 @@
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ static struct history *his_end = NULL; /* Last element in command line list */
|
||||
#endif
|
||||
|
||||
/* Current termio and the previous termio before starting sh */
|
||||
struct termios initial_settings, new_settings;
|
||||
static struct termios initial_settings, new_settings;
|
||||
|
||||
|
||||
#ifndef _POSIX_VDISABLE
|
||||
@@ -106,7 +106,7 @@ cmdedit_setwidth(int w)
|
||||
cmdedit_termw = w;
|
||||
cmdedit_scroll = w / 3;
|
||||
} else {
|
||||
errorMsg("\n*** Error: minimum screen width is 21\n");
|
||||
error_msg("\n*** Error: minimum screen width is 21\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void clean_up_and_die(int sig)
|
||||
cmdedit_reset_term();
|
||||
fprintf(stdout, "\n");
|
||||
if (sig!=SIGINT)
|
||||
exit(TRUE);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Go to HOME position */
|
||||
@@ -283,12 +283,12 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
|
||||
return (matches);
|
||||
}
|
||||
|
||||
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
||||
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
|
||||
{
|
||||
/* Do TAB completion */
|
||||
static int num_matches=0;
|
||||
static char **matches = (char **) NULL;
|
||||
int pos = cursor;
|
||||
int pos = *cursor;
|
||||
|
||||
|
||||
if (lastWasTab == FALSE) {
|
||||
@@ -303,7 +303,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
||||
/* Make a local copy of the string -- up
|
||||
* to the position of the cursor */
|
||||
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
|
||||
strncpy(matchBuf, command, cursor);
|
||||
strncpy(matchBuf, command, *cursor);
|
||||
tmp=matchBuf;
|
||||
|
||||
/* skip past any command seperator tokens */
|
||||
@@ -343,10 +343,10 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
||||
if (matches && num_matches==1) {
|
||||
/* write out the matched command */
|
||||
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
|
||||
len=strlen(command);
|
||||
cursor=len;
|
||||
*len=strlen(command);
|
||||
*cursor=*len;
|
||||
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
|
||||
break;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/* Ok -- the last char was a TAB. Since they
|
||||
@@ -372,9 +372,9 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
||||
/* Rewrite the prompt */
|
||||
xwrite(outputFd, prompt, strlen(prompt));
|
||||
/* Rewrite the command */
|
||||
xwrite(outputFd, command, len);
|
||||
xwrite(outputFd, command, *len);
|
||||
/* Put the cursor back to where it used to be */
|
||||
for (cursor=len; cursor > pos; cursor--)
|
||||
for (cursor=len; *cursor > pos; cursor--)
|
||||
xwrite(outputFd, "\b", 1);
|
||||
}
|
||||
}
|
||||
@@ -505,7 +505,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
|
||||
break;
|
||||
case '\t':
|
||||
#ifdef BB_FEATURE_SH_TAB_COMPLETION
|
||||
input_tab(command, prompt, outputFd, &cursor, &len);
|
||||
input_tab(command, prompt, outputFd, &cursor,
|
||||
&len, lastWasTab);
|
||||
#endif
|
||||
break;
|
||||
case 14:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
#ifdef BB_FEATURE_SH_COMMAND_EDITING
|
||||
/* unix systems can #define POSIX to use termios, otherwise
|
||||
* the bsd or sysv interface will be used
|
||||
*/
|
||||
|
||||
#ifdef __STDC__
|
||||
#include <stddef.h>
|
||||
|
||||
typedef size_t (*cmdedit_strwidth_proc)(char *);
|
||||
@@ -21,18 +21,6 @@ extern int (*cmdedit_in_hook)(char *);
|
||||
extern int (*cmdedit_out_hook)(char *);
|
||||
extern int (*cmdedit_tab_hook)(char *, int, int *);
|
||||
|
||||
#else /* not __STDC__ */
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command);
|
||||
void cmdedit_setwidth();
|
||||
void cmdedit_histadd();
|
||||
void cmdedit_strwidth();
|
||||
|
||||
extern int (*cmdedit_in_hook)();
|
||||
extern int (*cmdedit_out_hook)();
|
||||
extern int (*cmdedit_tab_hook)();
|
||||
|
||||
#endif /* __STDC__ */
|
||||
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -0,0 +1,65 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -25,13 +25,13 @@ int chvt_main(int argc, char **argv)
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,5 +29,5 @@
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -28,21 +28,21 @@ printf("erik: A\n");
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
exit( FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
printf("erik: B\n");
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
errorMsg("0: illegal VT number\n");
|
||||
error_msg("0: illegal VT number\n");
|
||||
else if (num == 1)
|
||||
errorMsg("VT 1 cannot be deallocated\n");
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
fatalError("could not deallocate console %d\n", num);
|
||||
error_msg_and_die("could not deallocate console %d\n", num);
|
||||
}
|
||||
}
|
||||
printf("erik: C\n");
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -50,8 +50,8 @@ int dumpkmap_main(int argc, char **argv)
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return 1;
|
||||
error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
write(1, magic, 7);
|
||||
@@ -78,7 +78,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
errorMsg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
@@ -88,5 +88,5 @@ int dumpkmap_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+12
-15
@@ -39,18 +39,18 @@ int loadacm_main(int argc, char **argv)
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
errorMsg("Error opening /dev/tty1: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
errorMsg("Error loading acm: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
error_msg("Error loading acm: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int screen_map_load(int fd, FILE * fp)
|
||||
@@ -72,7 +72,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
errorMsg("16bit screen-map MUST be a regular file.\n"),
|
||||
error_msg("16bit screen-map MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek failed reading binary 16bit screen-map"),
|
||||
@@ -83,7 +83,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
perror("Cannot read [new] map from file"), exit(1);
|
||||
#if 0
|
||||
else
|
||||
errorMsg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
errorMsg("Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek failed assuming 8bit screen-map"), exit(1);
|
||||
@@ -113,7 +113,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
errorMsg("fseek() returned ESPIPE !\n"),
|
||||
error_msg("fseek() returned ESPIPE !\n"),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek for binary 8bit screen-map"), exit(1);
|
||||
@@ -123,7 +123,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
perror("Cannot read [old] map from file"), exit(1);
|
||||
#if 0
|
||||
else
|
||||
errorMsg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
errorMsg("Error parsing symbolic map\n");
|
||||
error_msg("Error parsing symbolic map\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -330,10 +330,7 @@ void saveoldmap(int fd, char *omfil)
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((fp = fopen(omfil, "w")) == NULL) {
|
||||
perror(omfil);
|
||||
exit(1);
|
||||
}
|
||||
fp = xfopen(omfil, "w");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
if (is_old_map) {
|
||||
#endif
|
||||
|
||||
+25
-46
@@ -43,18 +43,15 @@ extern int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
if (argc != 1)
|
||||
usage(loadfont_usage);
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
loadnewfont(fd);
|
||||
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
@@ -64,10 +61,8 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32) {
|
||||
errorMsg("Bad character size %d\n", unit);
|
||||
exit(1);
|
||||
}
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d\n", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -82,13 +77,11 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf)) {
|
||||
perror("PIO_FONT ioctl error");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
perror_msg_and_die("PIO_FONT ioctl error");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -126,12 +119,11 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
errorMsg("It seems this kernel is older than 1.1.92\n");
|
||||
errorMsg("No Unicode mapping table loaded.\n");
|
||||
error_msg("It seems this kernel is older than 1.1.92\n");
|
||||
error_msg_and_die("No Unicode mapping table loaded.\n");
|
||||
} else
|
||||
#endif
|
||||
perror("PIO_UNIMAPCLR");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
}
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
@@ -141,8 +133,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
/* change advice parameters */
|
||||
}
|
||||
#endif
|
||||
perror("PIO_UNIMAP");
|
||||
exit(1);
|
||||
perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,18 +149,14 @@ static void loadnewfont(int fd)
|
||||
* just read the entire file.
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin)) {
|
||||
perror("Error reading input font");
|
||||
exit(1);
|
||||
}
|
||||
if (ferror(stdin))
|
||||
perror_msg_and_die("Error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin)) {
|
||||
perror("Font too large");
|
||||
exit(1);
|
||||
}
|
||||
if (!feof(stdin))
|
||||
perror_msg_and_die("Font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
@@ -186,26 +173,20 @@ static void loadnewfont(int fd)
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE) {
|
||||
errorMsg("Unsupported psf file mode\n");
|
||||
exit(1);
|
||||
}
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode\n");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256) {
|
||||
errorMsg("Only fontsize 256 supported\n");
|
||||
exit(1);
|
||||
}
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported\n");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth)) {
|
||||
errorMsg("Input file: bad length\n");
|
||||
exit(1);
|
||||
}
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length\n");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
@@ -219,10 +200,8 @@ static void loadnewfont(int fd)
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377) {
|
||||
errorMsg("Bad input file size\n");
|
||||
exit(1);
|
||||
}
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size\n");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
+13
-23
@@ -26,6 +26,8 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
@@ -43,29 +45,21 @@ int loadkmap_main(int argc, char **argv)
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap", buff[7];
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
if (argc != 1)
|
||||
usage(loadkmap_usage);
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
errorMsg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, magic, 7)) {
|
||||
errorMsg("This is not a valid binary keymap.\n");
|
||||
exit(FALSE);
|
||||
}
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.\n");
|
||||
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS)) {
|
||||
errorMsg("Error reading keymap flags: %s\n",
|
||||
strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
ibuff = (u_short *) xmalloc(ibuffsz);
|
||||
|
||||
@@ -73,12 +67,8 @@ int loadkmap_main(int argc, char **argv)
|
||||
if (flags[i] == 1) {
|
||||
pos = 0;
|
||||
while (pos < ibuffsz) {
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos))
|
||||
< 0) {
|
||||
errorMsg("Error reading keymap: %s\n",
|
||||
strerror(errno));
|
||||
exit(FALSE);
|
||||
}
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
|
||||
perror_msg_and_die("Error reading keymap");
|
||||
pos += readsz;
|
||||
}
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
@@ -92,5 +82,5 @@ int loadkmap_main(int argc, char **argv)
|
||||
/* Don't bother to close files. Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* close(fd); */
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -29,6 +29,6 @@
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033c");
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -52,21 +52,21 @@ setkeycodes_main(int argc, char** argv)
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
fatalError("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
fatalError("SCANCODE or KEYCODE outside bounds\n");
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
fatalError("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -45,5 +45,5 @@ extern int basename_main(int argc, char **argv)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+5
-4
@@ -26,20 +26,21 @@
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
exit(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
perror(*argv);
|
||||
exit(FALSE);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ int chroot_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
fatalError("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -54,10 +54,10 @@ int chroot_main(int argc, char **argv)
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
exit (0);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
fatalError("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+47
-34
@@ -54,12 +54,12 @@ static void decompose_list(const char *list)
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
fatalError("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
fatalError("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static void decompose_list(const char *list)
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
fatalError("missing list of fields\n");
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
@@ -102,10 +102,10 @@ static void decompose_list(const char *list)
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
@@ -129,34 +129,47 @@ static void cut_file(FILE *file)
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,14 +188,14 @@ extern int cut_main(int argc, char **argv)
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
fatalError("only one type of list may be specified");
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
fatalError("the delimiter must be a single character\n");
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
@@ -196,16 +209,16 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
fatalError("you must specify a list of bytes, characters, or fields\n");
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
fatalError("suppressing non-delimited lines makes sense
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense
|
||||
only when operating on fields\n");
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
fatalError("a delimiter may be specified only when operating on fields\n");
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
@@ -220,7 +233,7 @@ extern int cut_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
errorMsg("%s: %s\n", argv[i], strerror(errno));
|
||||
error_msg("%s: %s\n", argv[i], strerror(errno));
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
@@ -228,5 +241,5 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+71
-78
@@ -56,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
fatalError(invalid_date, t_string);
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
@@ -74,73 +74,57 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm itm_time, jtm_time, ktm_time, ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
struct tm t;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour, &itm_time.tm_min, &itm_time.tm_sec) == 3) {
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
*tm_time = itm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour, &jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min, &ktm_time.tm_sec) == 5) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour, <m_time.tm_min) == 4) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min, &mtm_time.tm_sec) == 6) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return (tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour, &ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
fatalError(invalid_date, t_string);
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,26 +144,27 @@ int date_main(int argc, char **argv)
|
||||
/* Interpret command line args */
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
fatalError(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,9 +173,13 @@ int date_main(int argc, char **argv)
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
} else {
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
@@ -216,12 +205,16 @@ int date_main(int argc, char **argv)
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
fatalError(invalid_date, date_str);
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
fatalError("can't set date.\n");
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +232,7 @@ int date_main(int argc, char **argv)
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
@@ -253,5 +246,5 @@ int date_main(int argc, char **argv)
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+32
-18
@@ -49,14 +49,15 @@ extern int dd_main(int argc, char **argv)
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int trunc=TRUE;
|
||||
long blockSize = 512;
|
||||
int sync=FALSE;
|
||||
long blockSize = 512,ibs;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t inTotal = 0;
|
||||
uintmax_t outTotal = 0;
|
||||
uintmax_t totalSize;
|
||||
uintmax_t readSize;
|
||||
|
||||
unsigned char buf[BUFSIZ];
|
||||
char *keyword = NULL;
|
||||
|
||||
@@ -70,34 +71,36 @@ extern int dd_main(int argc, char **argv)
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = getNum((strchr(*argv, '=')) + 1);
|
||||
count = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (count < 0) {
|
||||
errorMsg("Bad count value %s\n", *argv);
|
||||
error_msg("Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = getNum((strchr(*argv, '=')) + 1);
|
||||
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
errorMsg("Bad block size value %s\n", *argv);
|
||||
error_msg("Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
errorMsg("Bad skip value %s\n", *argv);
|
||||
error_msg("Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
errorMsg("Bad seek value %s\n", *argv);
|
||||
error_msg("Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "conv", 4) == 0) {
|
||||
keyword = (strchr(*argv, '=') + 1);
|
||||
if (strcmp(keyword, "notrunc") == 0)
|
||||
trunc=FALSE;
|
||||
if (strcmp(keyword, "sync") == 0)
|
||||
sync=TRUE;
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
@@ -116,7 +119,7 @@ extern int dd_main(int argc, char **argv)
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
fatalError( inFile);
|
||||
perror_msg_and_die("%s", inFile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
@@ -131,19 +134,30 @@ extern int dd_main(int argc, char **argv)
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
fatalError( outFile);
|
||||
perror_msg_and_die("%s", outFile);
|
||||
}
|
||||
|
||||
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
|
||||
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
|
||||
totalSize=count*blockSize;
|
||||
while ((readSize = totalSize - inTotal) > 0) {
|
||||
if (readSize > BUFSIZ)
|
||||
readSize=BUFSIZ;
|
||||
inCc = fullRead(inFd, buf, readSize);
|
||||
|
||||
ibs=blockSize;
|
||||
if (ibs > BUFSIZ)
|
||||
ibs=BUFSIZ;
|
||||
|
||||
while (totalSize > outTotal) {
|
||||
inCc = full_read(inFd, buf, ibs);
|
||||
inTotal += inCc;
|
||||
if ((outCc = fullWrite(outFd, buf, inCc)) < 1)
|
||||
if ( (sync==TRUE) && (inCc>0) )
|
||||
while (inCc<ibs)
|
||||
buf[inCc++]='\0';
|
||||
|
||||
if ((outCc = full_write(outFd, buf, inCc)) < 1){
|
||||
if (outCc < 0 ){
|
||||
perror("Error during write");
|
||||
}
|
||||
break;
|
||||
}
|
||||
outTotal += outCc;
|
||||
}
|
||||
if (trunc == TRUE) {
|
||||
@@ -160,7 +174,7 @@ extern int dd_main(int argc, char **argv)
|
||||
(inTotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
|
||||
+13
-14
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint)
|
||||
long blocks_percent_used;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
perror_msg("%s", mountPoint);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -63,45 +63,44 @@ static int df(char *device, const char *mountPoint)
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage(df_usage);
|
||||
}
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
|
||||
errorMsg("%s: can't find mount point.\n", argv[1]);
|
||||
exit(FALSE);
|
||||
}
|
||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (status != 0)
|
||||
exit(status);
|
||||
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.\n", argv[1]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit(TRUE);
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
perror(mtab_file);
|
||||
exit(FALSE);
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+7
-6
@@ -32,13 +32,14 @@ extern int dirname_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s && *s == '/') {
|
||||
*s = '\0';
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s != *argv && *s == '/') {
|
||||
*s-- = '\0';
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s && *s)
|
||||
if (s != NULL && s == *argv)
|
||||
s[1] = '\0';
|
||||
else if (s != NULL)
|
||||
*s = '\0';
|
||||
printf("%s\n", (s)? *argv : ".");
|
||||
return(TRUE);
|
||||
puts(s ? *argv : ".");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -41,5 +41,5 @@ int dos2unix_main( int argc, char **argv ) {
|
||||
putchar(c);
|
||||
c = getchar();
|
||||
}
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+10
-8
@@ -60,8 +60,7 @@ static long du(char *filename)
|
||||
int len;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
printf("du: %s: %s\n", filename, strerror(errno));
|
||||
return 0;
|
||||
perror_msg_and_die("%s", filename);
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
@@ -97,7 +96,7 @@ static long du(char *filename)
|
||||
}
|
||||
|
||||
if (len + strlen(name) + 1 > BUFSIZ) {
|
||||
errorMsg(name_too_long);
|
||||
error_msg(name_too_long);
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
@@ -125,6 +124,7 @@ static long du(char *filename)
|
||||
|
||||
int du_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int i;
|
||||
int c;
|
||||
|
||||
@@ -147,23 +147,25 @@ int du_main(int argc, char **argv)
|
||||
|
||||
/* go through remaining args (if any) */
|
||||
if (optind >= argc) {
|
||||
du(".");
|
||||
if (du(".") == 0)
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
long sum;
|
||||
|
||||
for (i=optind; i < argc; i++) {
|
||||
sum = du(argv[i]);
|
||||
if (sum && isDirectory(argv[i], FALSE, NULL)) {
|
||||
if ((sum = du(argv[i])) == 0)
|
||||
status = EXIT_FAILURE;
|
||||
if (is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.25 2000/09/25 21:45:57 andersen Exp $ */
|
||||
/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
||||
+70
-32
@@ -28,47 +28,86 @@
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
{
|
||||
register char **ap;
|
||||
char *p;
|
||||
int c;
|
||||
int nflag = 0;
|
||||
int eflag = 0;
|
||||
|
||||
/* Skip argv[0]. */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while ((c = getopt(argc, argv, "neE")) != EOF) {
|
||||
switch (c) {
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
break;
|
||||
case 'e':
|
||||
eflag = 1;
|
||||
break;
|
||||
case 'E':
|
||||
eflag = 0;
|
||||
break;
|
||||
default:
|
||||
usage(echo_usage);
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int index;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (index = 0; temp[index]; index++)
|
||||
{
|
||||
if (strrchr("neE", temp[index]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
if (!*temp)
|
||||
goto just_echo;
|
||||
|
||||
/*
|
||||
* All of the options in temp are valid options to echo.
|
||||
* Handle them.
|
||||
*/
|
||||
while (*temp)
|
||||
{
|
||||
if (*temp == 'n')
|
||||
nflag = 1;
|
||||
else if (*temp == 'e')
|
||||
eflag = 1;
|
||||
else if (*temp == 'E')
|
||||
eflag = 0;
|
||||
else
|
||||
goto just_echo;
|
||||
|
||||
temp++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
ap = &argv[optind];
|
||||
while ((p = *ap++) != NULL) {
|
||||
while ((c = *p++) != '\0') {
|
||||
if (c == '\\' && eflag) {
|
||||
if (*p == 'c')
|
||||
exit(0);
|
||||
else
|
||||
c = process_escape_sequence(&p);
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
char *arg = argv[0];
|
||||
register int c;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
|
||||
/* Check for escape sequence. */
|
||||
if (c == '\\' && eflag && *arg) {
|
||||
if (*arg == 'c') {
|
||||
/* '\c' means cancel newline. */
|
||||
nflag = 1;
|
||||
arg++;
|
||||
continue;
|
||||
} else {
|
||||
c = process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
if (*ap)
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc > 0)
|
||||
putchar(' ');
|
||||
}
|
||||
if (! nflag)
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
return( 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -86,9 +125,10 @@ echo_main(int argc, char** argv)
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
@@ -108,5 +148,3 @@ echo_main(int argc, char** argv)
|
||||
*
|
||||
* @(#)echo.c 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
|
||||
|
||||
+10
-10
@@ -74,14 +74,14 @@ int expr_main (int argc, char **argv)
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
fatalError("too few arguments\n");
|
||||
error_msg_and_die("too few arguments\n");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
fatalError ("syntax error\n");
|
||||
error_msg_and_die ("syntax error\n");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
@@ -216,7 +216,7 @@ static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
fatalError ("non-numeric argument\n"); \
|
||||
error_msg_and_die ("non-numeric argument\n"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
@@ -224,9 +224,9 @@ int name (l, r) VALUE *l; VALUE *r; \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
fatalError ( "non-numeric argument\n"); \
|
||||
error_msg_and_die ( "non-numeric argument\n"); \
|
||||
if (r->u.i == 0) \
|
||||
fatalError ( "division by zero\n"); \
|
||||
error_msg_and_die ( "division by zero\n"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ of a basic regular expression is not portable; it is being ignored",
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
fatalError("%s\n", errmsg);
|
||||
error_msg_and_die("%s\n", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
@@ -301,19 +301,19 @@ static VALUE *eval7 (void)
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
fatalError ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
fatalError ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
fatalError ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ static VALUE *eval6 (void)
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
fatalError ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
|
||||
+44
-51
@@ -26,17 +26,16 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int head(int len, FILE * src)
|
||||
int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char buffer[1024];
|
||||
char *input;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
fgets(buffer, 1024, src);
|
||||
if (feof(src)) {
|
||||
if ((input = get_line_from_file(fp)) == NULL)
|
||||
break;
|
||||
}
|
||||
fputs(buffer, stdout);
|
||||
fputs(input, stdout);
|
||||
free(input);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -44,60 +43,54 @@ int head(int len, FILE * src)
|
||||
/* BusyBoxed head(1) */
|
||||
int head_main(int argc, char **argv)
|
||||
{
|
||||
char opt;
|
||||
int len = 10, tmplen, i;
|
||||
FILE *fp;
|
||||
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
tmplen = 0;
|
||||
if (++i < argc)
|
||||
tmplen = atoi(argv[i]);
|
||||
if (tmplen < 1)
|
||||
usage(head_usage);
|
||||
len = tmplen;
|
||||
while ((opt = getopt(argc, argv, "n:")) > 0) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
len = atoi(optarg);
|
||||
if (len >= 1)
|
||||
break;
|
||||
case '-':
|
||||
case 'h':
|
||||
usage(head_usage);
|
||||
default:
|
||||
errorMsg("invalid option -- %c\n", opt);
|
||||
usage(head_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
usage(head_usage);
|
||||
}
|
||||
}
|
||||
|
||||
/* get rest of argv[] or stdin if nothing's left */
|
||||
if (i >= argc) {
|
||||
if (argv[optind] == NULL) {
|
||||
head(len, stdin);
|
||||
return status;
|
||||
}
|
||||
|
||||
} else {
|
||||
int need_headers = ((argc - i) > 1);
|
||||
|
||||
for (; i < argc; i++) {
|
||||
FILE *src;
|
||||
|
||||
src = fopen(argv[i], "r");
|
||||
if (!src) {
|
||||
errorMsg("%s: %s\n", argv[i], strerror(errno));
|
||||
} else {
|
||||
/* emulating GNU behaviour */
|
||||
if (need_headers) {
|
||||
fprintf(stdout, "==> %s <==\n", argv[i]);
|
||||
}
|
||||
head(len, src);
|
||||
if (i < argc - 1) {
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
need_headers = optind != (argc - 1);
|
||||
while (argv[optind]) {
|
||||
if (strcmp(argv[optind], "-") == 0) {
|
||||
fp = stdin;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
if ((fp = wfopen(argv[optind], "r")) == NULL)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
fprintf(stdout, "==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
fprintf(stdout, "\n");
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* $Id: head.c,v 1.14 2000/09/25 21:45:57 andersen Exp $ */
|
||||
return status;
|
||||
}
|
||||
+1
-1
@@ -26,5 +26,5 @@
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
printf("%lx\n", gethostid());
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+5
-9
@@ -31,12 +31,11 @@
|
||||
extern int id_main(int argc, char **argv)
|
||||
{
|
||||
int no_user = 0, no_group = 0, print_real = 0;
|
||||
char *cp, *user, *group;
|
||||
char user[9], group[9];
|
||||
long gid;
|
||||
long pwnam, grnam;
|
||||
int opt;
|
||||
|
||||
cp = user = group = NULL;
|
||||
gid = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ugr")) > 0) {
|
||||
@@ -57,11 +56,7 @@ extern int id_main(int argc, char **argv)
|
||||
|
||||
if (no_user && no_group) usage(id_usage);
|
||||
|
||||
user = argv[optind];
|
||||
|
||||
if (user == NULL) {
|
||||
user = xcalloc(9, sizeof(char));
|
||||
group = xcalloc(9, sizeof(char));
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
my_getpwuid(user, getuid());
|
||||
my_getgrgid(group, getgid());
|
||||
@@ -70,7 +65,8 @@ extern int id_main(int argc, char **argv)
|
||||
my_getgrgid(group, getegid());
|
||||
}
|
||||
} else {
|
||||
group = xcalloc(9, sizeof(char));
|
||||
strncpy(user, argv[optind], 8);
|
||||
user[8] = '\0';
|
||||
gid = my_getpwnamegid(user);
|
||||
my_getgrgid(group, gid);
|
||||
}
|
||||
@@ -78,7 +74,7 @@ extern int id_main(int argc, char **argv)
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
if (gid == -1 || pwnam==-1 || grnam==-1) {
|
||||
fatalError("%s: No such user\n", user);
|
||||
error_msg_and_die("%s: No such user\n", user);
|
||||
}
|
||||
if (no_group)
|
||||
printf("%ld\n", pwnam);
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@ extern int length_main(int argc, char **argv)
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return (TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+70
-83
@@ -30,96 +30,83 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int symlinkFlag = FALSE;
|
||||
static int removeoldFlag = FALSE;
|
||||
static int followLinks = TRUE;
|
||||
#define LN_SYMLINK 1
|
||||
#define LN_FORCE 2
|
||||
#define LN_NODEREFERENCE 4
|
||||
|
||||
/*
|
||||
* linkDestName is where the link points to,
|
||||
* linkSrcName is the name of the link to be created.
|
||||
*/
|
||||
static int fs_link(const char *link_DestName, const char *link_SrcName, const int flag)
|
||||
{
|
||||
int status;
|
||||
int srcIsDir;
|
||||
char *srcName;
|
||||
|
||||
if (link_DestName==NULL)
|
||||
return(FALSE);
|
||||
|
||||
srcName = (char *) malloc(strlen(link_SrcName)+strlen(link_DestName)+1);
|
||||
|
||||
if (link_SrcName==NULL)
|
||||
strcpy(srcName, link_DestName);
|
||||
else
|
||||
strcpy(srcName, link_SrcName);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
srcIsDir = is_directory(srcName, TRUE, NULL);
|
||||
else
|
||||
srcIsDir = is_directory(srcName, FALSE, NULL);
|
||||
|
||||
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
strcat(srcName, "/");
|
||||
strcat(srcName, link_DestName);
|
||||
}
|
||||
|
||||
if (flag&LN_FORCE)
|
||||
unlink(srcName);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_DestName, srcName);
|
||||
else
|
||||
status = link(link_DestName, srcName);
|
||||
|
||||
if (status != 0) {
|
||||
perror(srcName);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
char *linkName, *dirName=NULL;
|
||||
int linkIntoDirFlag;
|
||||
int stopIt = FALSE;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
int status = EXIT_SUCCESS;
|
||||
int flag = 0;
|
||||
int opt;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && stopIt == FALSE) {
|
||||
if (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 's':
|
||||
symlinkFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
removeoldFlag = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
followLinks = FALSE;
|
||||
break;
|
||||
case '-':
|
||||
stopIt = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
while ((opt=getopt(argc, argv, "sfn")) != -1) {
|
||||
switch(opt) {
|
||||
case 's':
|
||||
flag |= LN_SYMLINK;
|
||||
break;
|
||||
case 'f':
|
||||
flag |= LN_FORCE;
|
||||
break;
|
||||
case 'n':
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
usage(ln_usage);
|
||||
while(optind<(argc-1)) {
|
||||
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
optind++;
|
||||
}
|
||||
|
||||
linkName = argv[argc - 1];
|
||||
|
||||
linkIntoDirFlag = isDirectory(linkName, followLinks, NULL);
|
||||
if ((argc >= 3) && linkIntoDirFlag == FALSE) {
|
||||
errorMsg(not_a_directory, linkName);
|
||||
exit FALSE;
|
||||
}
|
||||
|
||||
if (linkIntoDirFlag == TRUE)
|
||||
dirName = linkName;
|
||||
|
||||
while (argc-- >= 2) {
|
||||
int status;
|
||||
|
||||
if (linkIntoDirFlag == TRUE) {
|
||||
char *baseName = get_last_path_component(*argv);
|
||||
linkName = (char *)xmalloc(strlen(dirName)+strlen(baseName)+2);
|
||||
strcpy(linkName, dirName);
|
||||
if(dirName[strlen(dirName)-1] != '/')
|
||||
strcat(linkName, "/");
|
||||
strcat(linkName,baseName);
|
||||
}
|
||||
|
||||
if (removeoldFlag == TRUE) {
|
||||
status = (unlink(linkName) && errno != ENOENT);
|
||||
if (status != 0) {
|
||||
perror(linkName);
|
||||
exit FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (symlinkFlag == TRUE)
|
||||
status = symlink(*argv, linkName);
|
||||
else
|
||||
status = link(*argv, linkName);
|
||||
if (status != 0) {
|
||||
perror(linkName);
|
||||
exit FALSE;
|
||||
}
|
||||
|
||||
if (linkIntoDirFlag == TRUE)
|
||||
free(linkName);
|
||||
|
||||
argv++;
|
||||
}
|
||||
return( TRUE);
|
||||
return(status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+4
-5
@@ -25,16 +25,15 @@
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char *user = xmalloc(9);
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
usage(logname_usage);
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (user) {
|
||||
if (*user) {
|
||||
puts(user);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
errorMsg("no login name\n");
|
||||
return(FALSE);
|
||||
error_msg_and_die("no login name\n");
|
||||
}
|
||||
+109
-74
@@ -127,6 +127,7 @@
|
||||
|
||||
#define SPLIT_DIR 0
|
||||
#define SPLIT_FILE 1
|
||||
#define SPLIT_SUBDIR 2
|
||||
|
||||
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
|
||||
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
|
||||
@@ -173,6 +174,31 @@ static unsigned short tabstops = 8;
|
||||
#define column_width COLUMN_WIDTH
|
||||
#endif
|
||||
|
||||
static int status = EXIT_SUCCESS;
|
||||
|
||||
static int my_stat(struct dnode *cur)
|
||||
{
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
if (follow_links == TRUE) {
|
||||
if (stat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (lstat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void newline(void)
|
||||
{
|
||||
if (column > 0) {
|
||||
@@ -211,11 +237,16 @@ static void nexttabstop( void )
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int is_subdir(struct dnode *dn)
|
||||
{
|
||||
return (S_ISDIR(dn->dstat.st_mode) && strcmp(dn->name, ".") != 0 &&
|
||||
strcmp(dn->name, "..") != 0);
|
||||
}
|
||||
|
||||
int countdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, dirs;
|
||||
|
||||
/* count how many dirs and regular files there are */
|
||||
if (dn==NULL || nfiles < 1) return(0);
|
||||
dirs= 0;
|
||||
for (i=0; i<nfiles; i++) {
|
||||
@@ -224,6 +255,18 @@ int countdirs(struct dnode **dn, int nfiles)
|
||||
return(dirs);
|
||||
}
|
||||
|
||||
int countsubdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, subdirs;
|
||||
|
||||
if (dn == NULL || nfiles < 1) return 0;
|
||||
subdirs = 0;
|
||||
for (i = 0; i < nfiles; i++)
|
||||
if (is_subdir(dn[i]))
|
||||
subdirs++;
|
||||
return subdirs;
|
||||
}
|
||||
|
||||
int countfiles(struct dnode **dnp)
|
||||
{
|
||||
int nfiles;
|
||||
@@ -271,9 +314,13 @@ struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
if (dn==NULL || nfiles < 1) return(NULL);
|
||||
|
||||
/* count how many dirs and regular files there are */
|
||||
dncnt= countdirs(dn, nfiles); /* assume we are looking for dirs */
|
||||
if (which != SPLIT_DIR)
|
||||
dncnt= nfiles - dncnt; /* looking for files */
|
||||
if (which == SPLIT_SUBDIR)
|
||||
dncnt = countsubdirs(dn, nfiles);
|
||||
else {
|
||||
dncnt= countdirs(dn, nfiles); /* assume we are looking for dirs */
|
||||
if (which == SPLIT_FILE)
|
||||
dncnt= nfiles - dncnt; /* looking for files */
|
||||
}
|
||||
|
||||
/* allocate a file array and a dir array */
|
||||
dnp= dnalloc(dncnt);
|
||||
@@ -284,6 +331,10 @@ struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
if (S_ISDIR(dn[i]->dstat.st_mode)) {
|
||||
dnp[d++]= dn[i];
|
||||
} /* else skip the file */
|
||||
} else if (which == SPLIT_SUBDIR) {
|
||||
if (is_subdir(dn[i])) {
|
||||
dnp[d++]= dn[i];
|
||||
} /* else skip the file or dir */
|
||||
} else {
|
||||
if (!(S_ISDIR(dn[i]->dstat.st_mode))) {
|
||||
dnp[d++]= dn[i];
|
||||
@@ -408,7 +459,7 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
{
|
||||
int i, nfiles;
|
||||
struct dnode **subdnp;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
int dndirs;
|
||||
struct dnode **dnd;
|
||||
#endif
|
||||
@@ -430,10 +481,12 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
#ifdef BB_FEATURE_LS_RECURSIVE
|
||||
if (disp_opts & DISP_RECURSIVE) {
|
||||
/* recursive- list the sub-dirs */
|
||||
dnd= splitdnarray(subdnp, nfiles, SPLIT_DIR);
|
||||
dndirs= countdirs(subdnp, nfiles);
|
||||
dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
|
||||
dndirs= countsubdirs(subdnp, nfiles);
|
||||
if (dndirs > 0) {
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
shellsort(dnd, dndirs);
|
||||
#endif
|
||||
showdirs(dnd, dndirs);
|
||||
free(dnd); /* free the array of dnode pointers to the dirs */
|
||||
}
|
||||
@@ -450,49 +503,32 @@ struct dnode **list_dir(char *path)
|
||||
struct dnode *dn, *cur, **dnp;
|
||||
struct dirent *entry;
|
||||
DIR *dir;
|
||||
char *fnend, fullname[BUFSIZ+1] ;
|
||||
int i, nfiles;
|
||||
|
||||
if (path==NULL) return(NULL);
|
||||
strcpy(fullname, path);
|
||||
fnend = fullname + strlen(fullname);
|
||||
if (fnend[-1] != '/') {
|
||||
strcat(fullname, "/");
|
||||
fnend++;
|
||||
}
|
||||
|
||||
dn= NULL;
|
||||
nfiles= 0;
|
||||
dir = opendir(fullname);
|
||||
dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
errorMsg("%s: %s\n", fullname, strerror(errno));
|
||||
error_msg("%s: %s\n", path, strerror(errno));
|
||||
status = EXIT_FAILURE;
|
||||
return(NULL); /* could not open the dir */
|
||||
}
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
/* are we going to list the file- it may be . or .. or a hidden file */
|
||||
strcpy(fnend, entry->d_name);
|
||||
if ((strcmp(fnend, ".")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((strcmp(fnend, "..")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((fnend[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue;
|
||||
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue;
|
||||
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
|
||||
cur->fullname= xstrdup(fullname);
|
||||
cur->name= cur->fullname + (int)(fnend - fullname) ;
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
if (follow_links == TRUE) {
|
||||
if (stat(fullname, &cur->dstat)) {
|
||||
errorMsg("%s: %s\n", fullname, strerror(errno));
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
continue;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (lstat(fullname, &cur->dstat)) { /* get file stat info into node */
|
||||
errorMsg("%s: %s\n", fullname, strerror(errno));
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1);
|
||||
strcpy(cur->fullname, path);
|
||||
if (cur->fullname[strlen(cur->fullname)-1] != '/')
|
||||
strcat(cur->fullname, "/");
|
||||
cur->name= cur->fullname + strlen(cur->fullname);
|
||||
strcat(cur->fullname, entry->d_name);
|
||||
if (my_stat(cur))
|
||||
continue;
|
||||
}
|
||||
cur->next= dn;
|
||||
dn= cur;
|
||||
nfiles++;
|
||||
@@ -521,8 +557,10 @@ int list_single(struct dnode *dn)
|
||||
char *filetime;
|
||||
time_t ttime, age;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
#if defined (BB_FEATURE_LS_FILETYPES)
|
||||
struct stat info;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
char append;
|
||||
#endif
|
||||
|
||||
@@ -553,7 +591,7 @@ int list_single(struct dnode *dn)
|
||||
column += 5;
|
||||
break;
|
||||
case LIST_MODEBITS:
|
||||
fprintf(stdout, "%10s", (char *)modeString(dn->dstat.st_mode));
|
||||
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_NLINKS:
|
||||
@@ -562,28 +600,17 @@ int list_single(struct dnode *dn)
|
||||
break;
|
||||
case LIST_ID_NAME:
|
||||
#ifdef BB_FEATURE_LS_USERNAME
|
||||
{
|
||||
memset(&info, 0, sizeof(struct stat));
|
||||
memset(scratch, 0, sizeof(scratch));
|
||||
if (!stat(dn->fullname, &info)) {
|
||||
my_getpwuid(scratch, info.st_uid);
|
||||
}
|
||||
if (*scratch) {
|
||||
fprintf(stdout, "%-8.8s ", scratch);
|
||||
} else {
|
||||
fprintf(stdout, "%-8d ", dn->dstat.st_uid);
|
||||
}
|
||||
memset(scratch, 0, sizeof(scratch));
|
||||
if (info.st_ctime != 0) {
|
||||
my_getgrgid(scratch, info.st_gid);
|
||||
}
|
||||
if (*scratch) {
|
||||
fprintf(stdout, "%-8.8s", scratch);
|
||||
} else {
|
||||
fprintf(stdout, "%-8d", dn->dstat.st_gid);
|
||||
}
|
||||
my_getpwuid(scratch, dn->dstat.st_uid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s ", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d ", dn->dstat.st_uid);
|
||||
my_getgrgid(scratch, dn->dstat.st_gid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d", dn->dstat.st_gid);
|
||||
column += 17;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case LIST_ID_NUMERIC:
|
||||
@@ -677,7 +704,6 @@ extern int ls_main(int argc, char **argv)
|
||||
#endif
|
||||
nfiles=0;
|
||||
|
||||
applet_name= argv[0];
|
||||
/* process options */
|
||||
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
@@ -705,7 +731,6 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'a': disp_opts |= DISP_HIDDEN | DISP_DOT; break;
|
||||
case 'C': style_fmt = STYLE_COLUMNS; break;
|
||||
case 'd': disp_opts |= DISP_NOLIST; break;
|
||||
case 'e': list_fmt |= LIST_FULLTIME; break;
|
||||
case 'g': /* ignore -- for ftp servers */ break;
|
||||
case 'i': list_fmt |= LIST_INO; break;
|
||||
case 'l': style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; break;
|
||||
@@ -726,9 +751,24 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'X': sort_opts= SORT_EXT; break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
case 'c': time_fmt = TIME_CHANGE; sort_opts= SORT_CTIME; break;
|
||||
case 't': sort_opts= SORT_MTIME; break;
|
||||
case 'u': time_fmt = TIME_ACCESS; sort_opts= SORT_ATIME; break;
|
||||
case 'e': list_fmt |= LIST_FULLTIME; break;
|
||||
case 'c':
|
||||
time_fmt = TIME_CHANGE;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_CTIME;
|
||||
#endif
|
||||
break;
|
||||
case 'u':
|
||||
time_fmt = TIME_ACCESS;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_ATIME;
|
||||
#endif
|
||||
break;
|
||||
case 't':
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_MTIME;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
case 'L': follow_links= TRUE; break;
|
||||
@@ -747,7 +787,7 @@ extern int ls_main(int argc, char **argv)
|
||||
if (disp_opts & DISP_NOLIST)
|
||||
disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#if defined (BB_FEATURE_LS_TIMESTAMPS) && defined (BB_FEATURE_LS_SORTFILES)
|
||||
if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME;
|
||||
if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME;
|
||||
#endif
|
||||
@@ -790,13 +830,9 @@ extern int ls_main(int argc, char **argv)
|
||||
for (oi=0 ; oi < ac; oi++) {
|
||||
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
|
||||
cur->fullname= xstrdup(av[oi]);
|
||||
cur->name= cur->fullname ;
|
||||
if (lstat(av[oi], &cur->dstat)) { /* get file info into node */
|
||||
errorMsg("%s: %s\n", av[oi], strerror(errno));
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
cur->name= cur->fullname;
|
||||
if (my_stat(cur))
|
||||
continue;
|
||||
}
|
||||
cur->next= dn;
|
||||
dn= cur;
|
||||
nfiles++;
|
||||
@@ -836,9 +872,8 @@ extern int ls_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
return(status);
|
||||
|
||||
print_usage_message:
|
||||
usage(ls_usage);
|
||||
return(FALSE);
|
||||
}
|
||||
+29
-66
@@ -107,48 +107,8 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
the resulting executable. Locally running cross-compiled executables
|
||||
is usually not possible. */
|
||||
|
||||
#ifdef _LIBC
|
||||
# include <sys/types.h>
|
||||
typedef u_int32_t md5_uint32;
|
||||
#else
|
||||
# if defined __STDC__ && __STDC__
|
||||
# define UINT_MAX_32_BITS 4294967295U
|
||||
# else
|
||||
# define UINT_MAX_32_BITS 0xFFFFFFFF
|
||||
# endif
|
||||
|
||||
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
|
||||
This should be valid for all systems GNU cares about because
|
||||
that doesn't include 16-bit systems, and only modern systems
|
||||
(that certainly have <limits.h>) have 64+-bit integral types. */
|
||||
|
||||
# ifndef UINT_MAX
|
||||
# define UINT_MAX UINT_MAX_32_BITS
|
||||
# endif
|
||||
|
||||
# if UINT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned int md5_uint32;
|
||||
# else
|
||||
# if USHRT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned short md5_uint32;
|
||||
# else
|
||||
# if ULONG_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned long md5_uint32;
|
||||
# else
|
||||
/* The following line is intended to evoke an error.
|
||||
Using #error is not portable enough. */
|
||||
"Cannot determine unsigned 32-bit data type."
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef __P
|
||||
#if defined (__STDC__) && __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
struct md5_ctx
|
||||
@@ -691,13 +651,13 @@ static int md5_file(const char *filename,
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
errorMsg("%s: %s\n", filename, strerror(errno));
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
errorMsg("%s: %s\n", filename, strerror(errno));
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
@@ -705,7 +665,7 @@ static int md5_file(const char *filename,
|
||||
}
|
||||
|
||||
if (fp != stdin && fclose(fp) == EOF) {
|
||||
errorMsg("%s: %s\n", filename, strerror(errno));
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -729,7 +689,7 @@ static int md5_check(const char *checkfile_name)
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
errorMsg("%s: %s\n", checkfile_name, strerror(errno));
|
||||
error_msg("%s: %s\n", checkfile_name, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -762,7 +722,7 @@ static int md5_check(const char *checkfile_name)
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
errorMsg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
checkfile_name, (unsigned long) line_number);
|
||||
}
|
||||
} else {
|
||||
@@ -810,18 +770,18 @@ static int md5_check(const char *checkfile_name)
|
||||
free(line);
|
||||
|
||||
if (ferror(checkfile_stream)) {
|
||||
errorMsg("%s: read error", checkfile_name); /* */
|
||||
error_msg("%s: read error\n", checkfile_name); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
|
||||
errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_properly_formated_lines == 0) {
|
||||
/* Warn if no tests are found. */
|
||||
errorMsg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
checkfile_name);
|
||||
return FALSE;
|
||||
} else {
|
||||
@@ -830,13 +790,13 @@ static int md5_check(const char *checkfile_name)
|
||||
- n_open_or_read_failures);
|
||||
|
||||
if (n_open_or_read_failures > 0) {
|
||||
errorMsg("WARNING: %d of %d listed files could not be read\n",
|
||||
error_msg("WARNING: %d of %d listed files could not be read\n",
|
||||
n_open_or_read_failures, n_properly_formated_lines);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0) {
|
||||
errorMsg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
n_mismatched_checksums, n_computed_checkums);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -901,31 +861,31 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (file_type_specified && do_check) {
|
||||
errorMsg("the -b and -t options are meaningless when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg("the -b and -t options are meaningless when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (n_strings > 0 && do_check) {
|
||||
errorMsg("the -g and -c options are mutually exclusive\n");
|
||||
exit FALSE;
|
||||
error_msg("the -g and -c options are mutually exclusive\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (status_only && !do_check) {
|
||||
errorMsg("the -s option is meaningful only when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg("the -s option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (warn && !do_check) {
|
||||
errorMsg("the -w option is meaningful only when verifying checksums\n");
|
||||
exit FALSE;
|
||||
error_msg("the -w option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (n_strings > 0) {
|
||||
size_t i;
|
||||
|
||||
if (optind < argc) {
|
||||
errorMsg("no files may be specified when using -g\n");
|
||||
exit FALSE;
|
||||
error_msg("no files may be specified when using -g\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i) {
|
||||
size_t cnt;
|
||||
@@ -938,7 +898,7 @@ int md5sum_main(int argc,
|
||||
}
|
||||
} else if (do_check) {
|
||||
if (optind + 1 < argc) {
|
||||
errorMsg("only one argument may be specified when using -c\n");
|
||||
error_msg("only one argument may be specified when using -c\n");
|
||||
}
|
||||
|
||||
err = md5_check ((optind == argc) ? "-" : argv[optind]);
|
||||
@@ -991,14 +951,17 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF) {
|
||||
errorMsg("write error");
|
||||
exit FALSE;
|
||||
error_msg("write error\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||
errorMsg("standard input");
|
||||
exit FALSE;
|
||||
error_msg("standard input\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
exit (err == 0 ? TRUE : FALSE);
|
||||
if (err == 0)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+9
-9
@@ -50,8 +50,8 @@ extern int mkdir_main(int argc, char **argv)
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if (parse_mode(*(++argv), &mode) == FALSE) {
|
||||
errorMsg("Unknown mode: %s\n", *argv);
|
||||
exit FALSE;
|
||||
error_msg("Unknown mode: %s\n", *argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
@@ -79,26 +79,26 @@ extern int mkdir_main(int argc, char **argv)
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (strlen(*argv) > BUFSIZ - 1) {
|
||||
errorMsg(name_too_long);
|
||||
exit FALSE;
|
||||
error_msg(name_too_long);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
strcpy(buf, *argv);
|
||||
status = stat(buf, &statBuf);
|
||||
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
|
||||
errorMsg("%s: File exists\n", buf);
|
||||
exit FALSE;
|
||||
error_msg("%s: File exists\n", buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (parentFlag == TRUE) {
|
||||
strcat(buf, "/");
|
||||
createPath(buf, mode);
|
||||
create_path(buf, mode);
|
||||
} else {
|
||||
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
|
||||
perror(buf);
|
||||
exit FALSE;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2
-2
@@ -55,7 +55,7 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
usage(mkfifo_usage);
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
perror("mkfifo");
|
||||
exit(255);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2
-2
@@ -84,7 +84,7 @@ int mknod_main(int argc, char **argv)
|
||||
mode |= perm;
|
||||
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
fatalError("%s: %s\n", argv[0], strerror(errno));
|
||||
return (TRUE);
|
||||
error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,8 +31,8 @@ extern int pwd_main(int argc, char **argv)
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
fatalError("%s\n", strerror(errno));
|
||||
error_msg_and_die("%s\n", strerror(errno));
|
||||
|
||||
printf("%s\n", buf);
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+7
-6
@@ -37,7 +37,7 @@ static const char *srcName;
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (unlink(fileName) < 0) {
|
||||
perror(fileName);
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
@@ -47,11 +47,11 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (recursiveFlag == FALSE) {
|
||||
errno = EISDIR;
|
||||
perror(fileName);
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror(fileName);
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
@@ -59,6 +59,7 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
extern int rm_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int stopIt=FALSE;
|
||||
struct stat statbuf;
|
||||
|
||||
@@ -100,11 +101,11 @@ extern int rm_main(int argc, char **argv)
|
||||
&& errno == ENOENT) {
|
||||
/* do not reports errors for non-existent files if -f, just skip them */
|
||||
} else {
|
||||
if (recursiveAction(srcName, recursiveFlag, FALSE,
|
||||
if (recursive_action(srcName, recursiveFlag, FALSE,
|
||||
TRUE, fileAction, dirAction, NULL) == FALSE) {
|
||||
exit(FALSE);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
+5
-3
@@ -28,14 +28,16 @@
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
errorMsg("%s\n", strerror(errno));
|
||||
exit(FALSE);
|
||||
perror_msg("%s", *argv);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
+2
-2
@@ -32,7 +32,7 @@ extern int sleep_main(int argc, char **argv)
|
||||
|
||||
if (sleep(atoi(*(++argv))) != 0) {
|
||||
perror("sleep");
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+20
-22
@@ -99,13 +99,13 @@ static Line *line_release(Line * self)
|
||||
/* ascii order */
|
||||
static int compare_ascii(const void *a, const void *b)
|
||||
{
|
||||
Line **doh;
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
|
||||
doh = (Line **) a;
|
||||
x = *doh;
|
||||
doh = (Line **) b;
|
||||
y = *doh;
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
|
||||
return APPLY_REVERSE(strcmp(x->data, y->data));
|
||||
@@ -114,14 +114,14 @@ static int compare_ascii(const void *a, const void *b)
|
||||
/* numeric order */
|
||||
static int compare_numeric(const void *a, const void *b)
|
||||
{
|
||||
Line **doh;
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
int xint, yint;
|
||||
|
||||
doh = (Line **) a;
|
||||
x = *doh;
|
||||
doh = (Line **) b;
|
||||
y = *doh;
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
xint = strtoul(x->data, NULL, 10);
|
||||
yint = strtoul(y->data, NULL, 10);
|
||||
@@ -247,7 +247,7 @@ int sort_main(int argc, char **argv)
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
errorMsg("invalid option -- %c\n", opt);
|
||||
error_msg("invalid option -- %c\n", opt);
|
||||
usage(sort_usage);
|
||||
}
|
||||
} else {
|
||||
@@ -255,19 +255,16 @@ int sort_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* this could be factored better */
|
||||
|
||||
/* work w/ stdin */
|
||||
if (i >= argc) {
|
||||
|
||||
/* work w/ stdin */
|
||||
while ((l = line_newFromFile(stdin))) {
|
||||
list_insert(&list, l);
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
} else {
|
||||
|
||||
/* work w/ what's left in argv[] */
|
||||
} else {
|
||||
FILE *src;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
@@ -280,12 +277,13 @@ int sort_main(int argc, char **argv)
|
||||
}
|
||||
fclose(src);
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* $Id: sort.c,v 1.22 2000/09/25 21:45:58 andersen Exp $ */
|
||||
/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
|
||||
+5
-25
@@ -61,7 +61,7 @@ static char verbose = 0;
|
||||
|
||||
static off_t units=0;
|
||||
|
||||
int tail_stream(int fd)
|
||||
static int tail_stream(int fd)
|
||||
{
|
||||
ssize_t startpoint;
|
||||
ssize_t endpoint=0;
|
||||
@@ -155,18 +155,6 @@ void add_file(char *name)
|
||||
strcpy(files[n_files - 1], name);
|
||||
}
|
||||
|
||||
void checknumbers(const char* name)
|
||||
{
|
||||
int test=atoi(name);
|
||||
if(test){
|
||||
units=test;
|
||||
if(units<0)
|
||||
units=units-1;
|
||||
} else {
|
||||
fatalError("Unrecognised number '%s'\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
int tail_main(int argc, char **argv)
|
||||
{
|
||||
int show_headers = 1;
|
||||
@@ -178,14 +166,9 @@ int tail_main(int argc, char **argv)
|
||||
|
||||
opterr = 0;
|
||||
|
||||
while ((opt=getopt(argc,argv,"c:fhn:s:q:v123456789+")) >0) {
|
||||
while ((opt=getopt(argc,argv,"c:fhn:s:q:v")) >0) {
|
||||
|
||||
switch (opt) {
|
||||
case '1':case '2':case '3':case '4':case '5':
|
||||
case '6':case '7':case '8':case '9':case '0':
|
||||
checknumbers(argv[optind-1]);
|
||||
break;
|
||||
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
case 'c':
|
||||
unit_type = BYTES;
|
||||
@@ -242,7 +225,7 @@ int tail_main(int argc, char **argv)
|
||||
usage(tail_usage);
|
||||
break;
|
||||
default:
|
||||
errorMsg("\nUnknown arg: %c.\n\n",optopt);
|
||||
error_msg("\nUnknown arg: %c.\n\n",optopt);
|
||||
usage(tail_usage);
|
||||
}
|
||||
}
|
||||
@@ -253,10 +236,7 @@ int tail_main(int argc, char **argv)
|
||||
else
|
||||
break;
|
||||
}else {
|
||||
if (*argv[optind] == '+') {
|
||||
checknumbers(argv[optind]);
|
||||
}
|
||||
else if (!strcmp(argv[optind], "-")) {
|
||||
if (!strcmp(argv[optind], "-")) {
|
||||
add_file(STDIN);
|
||||
} else {
|
||||
add_file(argv[optind]);
|
||||
@@ -283,7 +263,7 @@ int tail_main(int argc, char **argv)
|
||||
else
|
||||
fd[test] = open(files[test], O_RDONLY);
|
||||
if (fd[test] == -1)
|
||||
fatalError("Unable to open file %s.\n", files[test]);
|
||||
error_msg_and_die("Unable to open file %s.\n", files[test]);
|
||||
tail_stream(fd[test]);
|
||||
|
||||
bs=BUFSIZ;
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
errorMsg("%s: %s\n", argv[optind-1], strerror(errno));
|
||||
error_msg("%s: %s\n", argv[optind-1], strerror(errno));
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -184,7 +184,7 @@ test_main(int argc, char** argv)
|
||||
|
||||
if (strcmp(applet_name, "[") == 0) {
|
||||
if (strcmp(argv[--argc], "]"))
|
||||
fatalError("missing ]\n");
|
||||
error_msg_and_die("missing ]\n");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
@@ -233,9 +233,9 @@ syntax(op, msg)
|
||||
char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
fatalError("%s: %s\n", op, msg);
|
||||
error_msg_and_die("%s: %s\n", op, msg);
|
||||
else
|
||||
fatalError("%s\n", msg);
|
||||
error_msg_and_die("%s\n", msg);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -470,13 +470,13 @@ getn(s)
|
||||
r = strtol(s, &p, 10);
|
||||
|
||||
if (errno != 0)
|
||||
fatalError("%s: out of range\n", s);
|
||||
error_msg_and_die("%s: out of range\n", s);
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p)
|
||||
fatalError("%s: bad number\n", s);
|
||||
error_msg_and_die("%s: bad number\n", s);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
+4
-5
@@ -43,7 +43,6 @@ extern int touch_main(int argc, char **argv)
|
||||
break;
|
||||
default:
|
||||
usage(touch_usage);
|
||||
exit(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,18 +56,18 @@ extern int touch_main(int argc, char **argv)
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (fd < 0) {
|
||||
if (create == FALSE && errno == ENOENT)
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
else {
|
||||
fatalError("%s", strerror(errno));
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (utime(*argv, NULL)) {
|
||||
fatalError("%s", strerror(errno));
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+2
-9
@@ -34,13 +34,6 @@
|
||||
#define bb_need_write_error
|
||||
#include "messages.c"
|
||||
|
||||
#ifdef TRUE
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define ASCII 0377
|
||||
|
||||
/* some glabals shared across this file */
|
||||
@@ -70,7 +63,7 @@ static void convert()
|
||||
coded = vector[c];
|
||||
if (del_fl && invec[c])
|
||||
continue;
|
||||
if (sq_fl && last == coded && outvec[coded])
|
||||
if (sq_fl && last == coded && (invec[c] || outvec[coded]))
|
||||
continue;
|
||||
output[out_index++] = last = coded;
|
||||
if (out_index == BUFSIZ) {
|
||||
@@ -180,7 +173,7 @@ extern int tr_main(int argc, char **argv)
|
||||
input_length = complement(input, input_length);
|
||||
if (argv[index] != NULL) {
|
||||
if (*argv[index] == '\0')
|
||||
fatalError("STRING2 cannot be empty\n");
|
||||
error_msg_and_die("STRING2 cannot be empty\n");
|
||||
output_length = expand(argv[index], output);
|
||||
map(input, input_length, output, output_length);
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,5 +38,5 @@ extern int tty_main(int argc, char **argv)
|
||||
else
|
||||
puts("not a tty");
|
||||
}
|
||||
return(isatty(0) ? TRUE : FALSE);
|
||||
return(isatty(0) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
}
|
||||
+1
-1
@@ -138,7 +138,7 @@ int uname_main(int argc, char **argv)
|
||||
print_element(PRINT_MACHINE, name.machine);
|
||||
print_element(PRINT_PROCESSOR, processor);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* If the name element set in MASK is selected for printing in `toprint',
|
||||
|
||||
+42
-137
@@ -5,6 +5,7 @@
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,156 +28,60 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* max chars in line */
|
||||
#define UNIQ_MAX 4096
|
||||
static int print_count;
|
||||
static int print_uniq = 1;
|
||||
static int print_duplicates = 1;
|
||||
|
||||
typedef void (Print) (FILE *, const char *);
|
||||
|
||||
typedef int (Decide) (const char *, const char *);
|
||||
|
||||
/* container for two lines to be compared */
|
||||
typedef struct {
|
||||
char *a;
|
||||
char *b;
|
||||
int recurrence;
|
||||
FILE *in;
|
||||
FILE *out;
|
||||
void *func;
|
||||
} Subject;
|
||||
|
||||
/* set up all the variables of a uniq operation */
|
||||
static Subject *subject_init(Subject * self, FILE * in, FILE * out,
|
||||
void *func)
|
||||
static void print_line(char *line, int count, FILE *fp)
|
||||
{
|
||||
self->a = NULL;
|
||||
self->b = NULL;
|
||||
self->in = in;
|
||||
self->out = out;
|
||||
self->func = func;
|
||||
self->recurrence = 0;
|
||||
return self;
|
||||
if ((print_duplicates && count > 1) || (print_uniq && count == 1)) {
|
||||
if (print_count)
|
||||
fprintf(fp, "%7d\t%s", count, line);
|
||||
else
|
||||
fputs(line, fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* point a and b to the appropriate lines;
|
||||
* count the recurrences (if any) of a string;
|
||||
*/
|
||||
static Subject *subject_next(Subject * self)
|
||||
{
|
||||
/* tmp line holders */
|
||||
static char line[2][UNIQ_MAX];
|
||||
static int alternator = 0;
|
||||
|
||||
if (fgets(line[alternator], UNIQ_MAX, self->in)) {
|
||||
self->a = self->b;
|
||||
self->b = line[alternator];
|
||||
alternator ^= 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Subject *subject_last(Subject * self)
|
||||
{
|
||||
self->a = self->b;
|
||||
self->b = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
static Subject *subject_study(Subject * self)
|
||||
{
|
||||
if (self->a == NULL) {
|
||||
return self;
|
||||
}
|
||||
if (self->b == NULL) {
|
||||
fprintf(self->out, "%s", self->a);
|
||||
return self;
|
||||
}
|
||||
if (strcmp(self->a, self->b) == 0) {
|
||||
self->recurrence++;
|
||||
} else {
|
||||
fprintf(self->out, "%s", self->a);
|
||||
self->recurrence = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static int
|
||||
set_file_pointers(int schema, FILE ** in, FILE ** out, char **argv)
|
||||
{
|
||||
switch (schema) {
|
||||
case 0:
|
||||
*in = stdin;
|
||||
*out = stdout;
|
||||
break;
|
||||
case 1:
|
||||
*in = fopen(argv[0], "r");
|
||||
*out = stdout;
|
||||
break;
|
||||
case 2:
|
||||
*in = fopen(argv[0], "r");
|
||||
*out = fopen(argv[1], "w");
|
||||
break;
|
||||
}
|
||||
if (*in == NULL) {
|
||||
errorMsg("%s: %s\n", argv[0], strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
if (*out == NULL) {
|
||||
errorMsg("%s: %s\n", argv[1], strerror(errno));
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* one variable is the decision algo */
|
||||
/* another variable is the printing algo */
|
||||
|
||||
/* I don't think I have to have more than a 1 line memory
|
||||
this is the one constant */
|
||||
|
||||
/* it seems like GNU/uniq only takes one or two files as an option */
|
||||
|
||||
/* ________________________________________________________________________ */
|
||||
int uniq_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char opt;
|
||||
FILE *in, *out;
|
||||
Subject s;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
char *lastline = NULL, *input;
|
||||
int opt, count = 0;
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case '-':
|
||||
case 'h':
|
||||
usage(uniq_usage);
|
||||
default:
|
||||
usage(uniq_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
while ((opt = getopt(argc, argv, "cdu")) > 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
print_count = 1;
|
||||
break;
|
||||
case 'd':
|
||||
print_duplicates = 1;
|
||||
print_uniq = 0;
|
||||
break;
|
||||
case 'u':
|
||||
print_duplicates = 0;
|
||||
print_uniq = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 0 src: stdin; dst: stdout */
|
||||
/* 1 src: file; dst: stdout */
|
||||
/* 2 src: file; dst: file */
|
||||
if (set_file_pointers((argc - 1), &in, &out, &argv[i])) {
|
||||
exit(1);
|
||||
if (argv[optind] != NULL) {
|
||||
in = xfopen(argv[optind], "r");
|
||||
if (argv[optind+1] != NULL)
|
||||
out = xfopen(argv[optind+1], "w");
|
||||
}
|
||||
|
||||
subject_init(&s, in, out, NULL);
|
||||
while (subject_next(&s)) {
|
||||
subject_study(&s);
|
||||
while ((input = get_line_from_file(in)) != NULL) {
|
||||
if (lastline == NULL || strcmp(input, lastline) != 0) {
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
lastline = input;
|
||||
count = 0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
subject_last(&s);
|
||||
subject_study(&s);
|
||||
print_line(lastline, count, out);
|
||||
free(lastline);
|
||||
|
||||
return(0);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* $Id: uniq.c,v 1.14 2000/09/25 21:45:58 andersen Exp $ */
|
||||
+1
-1
@@ -32,5 +32,5 @@ extern int usleep_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
usleep(atoi(*(++argv))); /* return void */
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+53
-48
@@ -15,41 +15,12 @@
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93.
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
@@ -72,7 +43,7 @@ static int read_stduu (const char *inname)
|
||||
char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
errorMsg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -107,7 +78,7 @@ static int read_stduu (const char *inname)
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL
|
||||
|| strcmp (buf, "end\n")) {
|
||||
errorMsg("%s: No `end' line\n", inname);
|
||||
error_msg("%s: No `end' line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -157,7 +128,7 @@ static int read_base64 (const char *inname)
|
||||
unsigned char *p;
|
||||
|
||||
if (fgets (buf, sizeof(buf), stdin) == NULL) {
|
||||
errorMsg("%s: Short file\n", inname);
|
||||
error_msg("%s: Short file\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
p = buf;
|
||||
@@ -165,7 +136,7 @@ static int read_base64 (const char *inname)
|
||||
if (memcmp (buf, "====", 4) == 0)
|
||||
break;
|
||||
if (last_data != 0) {
|
||||
errorMsg("%s: data following `=' padding character\n", inname);
|
||||
error_msg("%s: data following `=' padding character\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -187,14 +158,14 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while ((b64_tab[*p] & '\100') != 0)
|
||||
if (*p == '\n' || *p++ == '=') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
c2 = b64_tab[*p++];
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
if (*p == '=') {
|
||||
@@ -206,7 +177,7 @@ static int read_base64 (const char *inname)
|
||||
|
||||
while (b64_tab[*p] == '\177')
|
||||
if (*p++ == '\n') {
|
||||
errorMsg("%s: illegal line\n", inname);
|
||||
error_msg("%s: illegal line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
putchar (c1 << 2 | c2 >> 4);
|
||||
@@ -238,7 +209,7 @@ static int decode (const char *inname,
|
||||
|
||||
while (1) {
|
||||
if (fgets (buf, sizeof (buf), stdin) == NULL) {
|
||||
errorMsg("%s: No `begin' line\n", inname);
|
||||
error_msg("%s: No `begin' line\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -263,13 +234,13 @@ static int decode (const char *inname,
|
||||
while (*p != '/')
|
||||
++p;
|
||||
if (*p == '\0') {
|
||||
errorMsg("%s: Illegal ~user\n", inname);
|
||||
error_msg("%s: Illegal ~user\n", inname);
|
||||
return FALSE;
|
||||
}
|
||||
*p++ = '\0';
|
||||
pw = getpwnam (buf + 1);
|
||||
if (pw == NULL) {
|
||||
errorMsg("%s: No user `%s'\n", inname, buf + 1);
|
||||
error_msg("%s: No user `%s'\n", inname, buf + 1);
|
||||
return FALSE;
|
||||
}
|
||||
n = strlen (pw->pw_dir);
|
||||
@@ -286,7 +257,7 @@ static int decode (const char *inname,
|
||||
&& (freopen (outname, "w", stdout) == NULL
|
||||
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
|
||||
)) {
|
||||
errorMsg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
|
||||
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -323,16 +294,16 @@ int uudecode_main (int argc,
|
||||
}
|
||||
|
||||
if (optind == argc)
|
||||
exit_status = decode ("stdin", outname) == 0 ? TRUE : FALSE;
|
||||
exit_status = decode ("stdin", outname) == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
else {
|
||||
exit_status = TRUE;
|
||||
exit_status = EXIT_SUCCESS;
|
||||
do {
|
||||
if (freopen (argv[optind], "r", stdin) != NULL) {
|
||||
if (decode (argv[optind], outname) != 0)
|
||||
exit_status = FALSE;
|
||||
} else {
|
||||
errorMsg("%s: %s\n", argv[optind], strerror(errno));
|
||||
exit_status = FALSE;
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
@@ -340,3 +311,37 @@ int uudecode_main (int argc,
|
||||
}
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+42
-38
@@ -15,43 +15,13 @@
|
||||
* along with this product; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
/* Reworked to GNU style by Ian Lance Taylor, ian@airs.com, August 93. */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt */
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -172,7 +142,7 @@ static void encode()
|
||||
}
|
||||
|
||||
if (ferror (stdin))
|
||||
errorMsg("Read error\n");
|
||||
error_msg("Read error\n");
|
||||
|
||||
if (trans_ptr == uu_std) {
|
||||
putchar (ENC ('\0'));
|
||||
@@ -208,8 +178,8 @@ int uuencode_main (int argc,
|
||||
case 2:
|
||||
/* Optional first argument is input file. */
|
||||
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
|
||||
errorMsg("%s: %s\n", argv[optind], strerror(errno));
|
||||
exit FALSE;
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
optind++;
|
||||
@@ -229,8 +199,42 @@ int uuencode_main (int argc,
|
||||
encode();
|
||||
printf(trans_ptr == uu_std ? "end\n" : "====\n");
|
||||
if (ferror (stdout)) {
|
||||
errorMsg("Write error\n");
|
||||
exit FALSE;
|
||||
error_msg("Write error\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Copyright (c) 1983 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+7
-8
@@ -105,7 +105,7 @@ int wc_main(int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
unsigned int num_files_counted = 0;
|
||||
int opt;
|
||||
int opt, status = EXIT_SUCCESS;
|
||||
|
||||
total_lines = total_words = total_chars = max_length = 0;
|
||||
print_lines = print_words = print_chars = print_length = 0;
|
||||
@@ -134,14 +134,13 @@ int wc_main(int argc, char **argv)
|
||||
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
wc_file(stdin, "");
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
} else {
|
||||
while (optind < argc) {
|
||||
file = fopen(argv[optind], "r");
|
||||
if (file == NULL) {
|
||||
fatalError(argv[optind]);
|
||||
}
|
||||
wc_file(file, argv[optind]);
|
||||
if ((file = wfopen(argv[optind], "r")) != NULL)
|
||||
wc_file(file, argv[optind]);
|
||||
else
|
||||
status = EXIT_FAILURE;
|
||||
num_files_counted++;
|
||||
optind++;
|
||||
}
|
||||
@@ -151,5 +150,5 @@ int wc_main(int argc, char **argv)
|
||||
print_counts(total_lines, total_words, total_chars,
|
||||
max_length, "total");
|
||||
|
||||
return 0 ;
|
||||
return status;
|
||||
}
|
||||
+4
-5
@@ -26,17 +26,16 @@
|
||||
|
||||
extern int whoami_main(int argc, char **argv)
|
||||
{
|
||||
char *user = xmalloc(9);
|
||||
char user[9];
|
||||
uid_t uid = geteuid();
|
||||
|
||||
if (argc > 1)
|
||||
usage(whoami_usage);
|
||||
|
||||
my_getpwuid(user, uid);
|
||||
if (user) {
|
||||
if (*user) {
|
||||
puts(user);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
errorMsg("cannot find username for UID %u\n", (unsigned) uid);
|
||||
return(FALSE);
|
||||
error_msg_and_die("cannot find username for UID %u\n", (unsigned) uid);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ static void name_too_long__exit (void) __attribute__((noreturn));
|
||||
static
|
||||
void name_too_long__exit (void)
|
||||
{
|
||||
fatalError(name_too_long);
|
||||
error_msg_and_die(name_too_long);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -109,14 +109,14 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
if (srcDirFlag == TRUE) {
|
||||
if (recursiveFlag == FALSE) {
|
||||
errorMsg(omitting_directory, baseSrcName);
|
||||
error_msg(omitting_directory, baseSrcName);
|
||||
return TRUE;
|
||||
}
|
||||
srcBasename = (strstr(fileName, baseSrcName)
|
||||
+ strlen(baseSrcName));
|
||||
|
||||
if (destLen + strlen(srcBasename) > BUFSIZ) {
|
||||
errorMsg(name_too_long);
|
||||
error_msg(name_too_long);
|
||||
return FALSE;
|
||||
}
|
||||
strcat(destName, srcBasename);
|
||||
@@ -130,7 +130,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (mv_Action_first_time && (dz_i == is_mv)) {
|
||||
mv_Action_first_time = errno = 0;
|
||||
if (rename(fileName, destName) < 0 && errno != EXDEV) {
|
||||
errorMsg("rename(%s, %s): %s\n", fileName, destName,
|
||||
error_msg("rename(%s, %s): %s\n", fileName, destName,
|
||||
strerror(errno));
|
||||
goto do_copyFile; /* Try anyway... */
|
||||
}
|
||||
@@ -143,7 +143,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
|
||||
if (is_in_ino_dev_hashtable(statbuf, &name)) {
|
||||
if (link(name, destName) < 0) {
|
||||
errorMsg("link(%s, %s): %s\n", name, destName, strerror(errno));
|
||||
error_msg("link(%s, %s): %s\n", name, destName, strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -152,7 +152,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
add_to_ino_dev_hashtable(statbuf, destName);
|
||||
}
|
||||
}
|
||||
return copyFile(fileName, destName, preserveFlag, followLinks, forceFlag);
|
||||
return copy_file(fileName, destName, preserveFlag, followLinks, forceFlag);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -162,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
|
||||
|
||||
if (S_ISDIR(statbuf->st_mode)) {
|
||||
if (rmdir(fileName) < 0) {
|
||||
errorMsg("rmdir(%s): %s\n", fileName, strerror(errno));
|
||||
error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
|
||||
status = FALSE;
|
||||
}
|
||||
} else if (unlink(fileName) < 0) {
|
||||
errorMsg("unlink(%s): %s\n", fileName, strerror(errno));
|
||||
error_msg("unlink(%s): %s\n", fileName, strerror(errno));
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
@@ -224,7 +224,7 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
|
||||
|
||||
if (strlen(argv[argc - 1]) > BUFSIZ) {
|
||||
errorMsg(name_too_long);
|
||||
error_msg(name_too_long);
|
||||
goto exit_false;
|
||||
}
|
||||
strcpy(baseDestName, argv[argc - 1]);
|
||||
@@ -232,9 +232,9 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
if (baseDestLen == 0)
|
||||
goto exit_false;
|
||||
|
||||
destDirFlag = isDirectory(baseDestName, TRUE, &destStatBuf);
|
||||
destDirFlag = is_directory(baseDestName, TRUE, &destStatBuf);
|
||||
if (argc - optind > 2 && destDirFlag == FALSE) {
|
||||
errorMsg(not_a_directory, baseDestName);
|
||||
error_msg(not_a_directory, baseDestName);
|
||||
goto exit_false;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
|
||||
if (srcLen == 0) continue; /* "" */
|
||||
|
||||
srcDirFlag = isDirectory(baseSrcName, followLinks, &srcStatBuf);
|
||||
srcDirFlag = is_directory(baseSrcName, followLinks, &srcStatBuf);
|
||||
|
||||
if ((flags_memo = (recursiveFlag == TRUE &&
|
||||
srcDirFlag == TRUE && destDirFlag == TRUE))) {
|
||||
@@ -260,26 +260,26 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
char *pushd, *d, *p;
|
||||
|
||||
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
errorMsg("getcwd(): %s\n", strerror(errno));
|
||||
error_msg("getcwd(): %s\n", strerror(errno));
|
||||
continue;
|
||||
}
|
||||
if (chdir(baseDestName) < 0) {
|
||||
errorMsg("chdir(%s): %s\n", baseSrcName, strerror(errno));
|
||||
error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
|
||||
continue;
|
||||
}
|
||||
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
|
||||
errorMsg("getcwd(): %s\n", strerror(errno));
|
||||
error_msg("getcwd(): %s\n", strerror(errno));
|
||||
continue;
|
||||
}
|
||||
while (!state && *d != '\0') {
|
||||
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
|
||||
errorMsg("stat(%s): %s\n", d, strerror(errno));
|
||||
error_msg("stat(%s): %s\n", d, strerror(errno));
|
||||
state = -1;
|
||||
continue;
|
||||
}
|
||||
if ((sb.st_ino == srcStatBuf.st_ino) &&
|
||||
(sb.st_dev == srcStatBuf.st_dev)) {
|
||||
errorMsg("Cannot %s `%s' into a subdirectory of itself, "
|
||||
error_msg("Cannot %s `%s' into a subdirectory of itself, "
|
||||
"`%s/%s'\n", applet_name, baseSrcName,
|
||||
baseDestName, baseSrcName);
|
||||
state = -1;
|
||||
@@ -290,7 +290,7 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (chdir(pushd) < 0) {
|
||||
errorMsg("chdir(%s): %s\n", pushd, strerror(errno));
|
||||
error_msg("chdir(%s): %s\n", pushd, strerror(errno));
|
||||
free(pushd);
|
||||
free(d);
|
||||
continue;
|
||||
@@ -305,20 +305,20 @@ extern int cp_mv_main(int argc, char **argv)
|
||||
status = setjmp(catch);
|
||||
if (status == 0) {
|
||||
mv_Action_first_time = 1;
|
||||
if (recursiveAction(baseSrcName,
|
||||
if (recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, FALSE,
|
||||
cp_mv_Action, cp_mv_Action, NULL) == FALSE) goto exit_false;
|
||||
if (dz_i == is_mv &&
|
||||
recursiveAction(baseSrcName,
|
||||
recursive_action(baseSrcName,
|
||||
recursiveFlag, followLinks, TRUE,
|
||||
rm_Action, rm_Action, NULL) == FALSE) goto exit_false;
|
||||
}
|
||||
if (flags_memo)
|
||||
*(baseDestName + baseDestLen) = '\0';
|
||||
}
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
exit_false:
|
||||
return( FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -54,12 +54,12 @@ static void decompose_list(const char *list)
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
fatalError("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
fatalError("invalid byte or field list\n");
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static void decompose_list(const char *list)
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
fatalError("missing list of fields\n");
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
@@ -102,10 +102,10 @@ static void decompose_list(const char *list)
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
@@ -129,34 +129,47 @@ static void cut_file(FILE *file)
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,14 +188,14 @@ extern int cut_main(int argc, char **argv)
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
fatalError("only one type of list may be specified");
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
fatalError("the delimiter must be a single character\n");
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
@@ -196,16 +209,16 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
fatalError("you must specify a list of bytes, characters, or fields\n");
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
fatalError("suppressing non-delimited lines makes sense
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense
|
||||
only when operating on fields\n");
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
fatalError("a delimiter may be specified only when operating on fields\n");
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
@@ -220,7 +233,7 @@ extern int cut_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
errorMsg("%s: %s\n", argv[i], strerror(errno));
|
||||
error_msg("%s: %s\n", argv[i], strerror(errno));
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
@@ -228,5 +241,5 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
fatalError(invalid_date, t_string);
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
@@ -74,73 +74,57 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm itm_time, jtm_time, ktm_time, ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
struct tm t;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour, &itm_time.tm_min, &itm_time.tm_sec) == 3) {
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
*tm_time = itm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour, &jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min, &ktm_time.tm_sec) == 5) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour, <m_time.tm_min) == 4) {
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min, &mtm_time.tm_sec) == 6) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return (tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour, &ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return (tm_time);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
fatalError(invalid_date, t_string);
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,26 +144,27 @@ int date_main(int argc, char **argv)
|
||||
/* Interpret command line args */
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
fatalError(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,9 +173,13 @@ int date_main(int argc, char **argv)
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
} else {
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
@@ -216,12 +205,16 @@ int date_main(int argc, char **argv)
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
fatalError(invalid_date, date_str);
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
fatalError("can't set date.\n");
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -239,7 +232,7 @@ int date_main(int argc, char **argv)
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
@@ -253,5 +246,5 @@ int date_main(int argc, char **argv)
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -13,19 +13,15 @@ static unsigned int pointer;
|
||||
|
||||
static void push(double a)
|
||||
{
|
||||
if (pointer >= (sizeof(stack) / sizeof(*stack))) {
|
||||
errorMsg("stack overflow\n");
|
||||
exit(-1);
|
||||
} else
|
||||
stack[pointer++] = a;
|
||||
if (pointer >= (sizeof(stack) / sizeof(*stack)))
|
||||
error_msg_and_die("stack overflow\n");
|
||||
stack[pointer++] = a;
|
||||
}
|
||||
|
||||
static double pop()
|
||||
{
|
||||
if (pointer == 0) {
|
||||
errorMsg("stack underflow\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (pointer == 0)
|
||||
error_msg_and_die("stack underflow\n");
|
||||
return stack[--pointer];
|
||||
}
|
||||
|
||||
@@ -124,8 +120,7 @@ static void stack_machine(const char *argument)
|
||||
}
|
||||
o++;
|
||||
}
|
||||
errorMsg("%s: syntax error.\n", argument);
|
||||
exit(-1);
|
||||
error_msg_and_die("%s: syntax error.\n", argument);
|
||||
}
|
||||
|
||||
/* return pointer to next token in buffer and set *buffer to one char
|
||||
@@ -182,5 +177,5 @@ int dc_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
stack_machine(0);
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -49,14 +49,15 @@ extern int dd_main(int argc, char **argv)
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int trunc=TRUE;
|
||||
long blockSize = 512;
|
||||
int sync=FALSE;
|
||||
long blockSize = 512,ibs;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t inTotal = 0;
|
||||
uintmax_t outTotal = 0;
|
||||
uintmax_t totalSize;
|
||||
uintmax_t readSize;
|
||||
|
||||
unsigned char buf[BUFSIZ];
|
||||
char *keyword = NULL;
|
||||
|
||||
@@ -70,34 +71,36 @@ extern int dd_main(int argc, char **argv)
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = getNum((strchr(*argv, '=')) + 1);
|
||||
count = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (count < 0) {
|
||||
errorMsg("Bad count value %s\n", *argv);
|
||||
error_msg("Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = getNum((strchr(*argv, '=')) + 1);
|
||||
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
errorMsg("Bad block size value %s\n", *argv);
|
||||
error_msg("Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
errorMsg("Bad skip value %s\n", *argv);
|
||||
error_msg("Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = getNum((strchr(*argv, '=')) + 1);
|
||||
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
errorMsg("Bad seek value %s\n", *argv);
|
||||
error_msg("Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "conv", 4) == 0) {
|
||||
keyword = (strchr(*argv, '=') + 1);
|
||||
if (strcmp(keyword, "notrunc") == 0)
|
||||
trunc=FALSE;
|
||||
if (strcmp(keyword, "sync") == 0)
|
||||
sync=TRUE;
|
||||
} else {
|
||||
goto usage;
|
||||
}
|
||||
@@ -116,7 +119,7 @@ extern int dd_main(int argc, char **argv)
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
fatalError( inFile);
|
||||
perror_msg_and_die("%s", inFile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
@@ -131,19 +134,30 @@ extern int dd_main(int argc, char **argv)
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
fatalError( outFile);
|
||||
perror_msg_and_die("%s", outFile);
|
||||
}
|
||||
|
||||
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
|
||||
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
|
||||
totalSize=count*blockSize;
|
||||
while ((readSize = totalSize - inTotal) > 0) {
|
||||
if (readSize > BUFSIZ)
|
||||
readSize=BUFSIZ;
|
||||
inCc = fullRead(inFd, buf, readSize);
|
||||
|
||||
ibs=blockSize;
|
||||
if (ibs > BUFSIZ)
|
||||
ibs=BUFSIZ;
|
||||
|
||||
while (totalSize > outTotal) {
|
||||
inCc = full_read(inFd, buf, ibs);
|
||||
inTotal += inCc;
|
||||
if ((outCc = fullWrite(outFd, buf, inCc)) < 1)
|
||||
if ( (sync==TRUE) && (inCc>0) )
|
||||
while (inCc<ibs)
|
||||
buf[inCc++]='\0';
|
||||
|
||||
if ((outCc = full_write(outFd, buf, inCc)) < 1){
|
||||
if (outCc < 0 ){
|
||||
perror("Error during write");
|
||||
}
|
||||
break;
|
||||
}
|
||||
outTotal += outCc;
|
||||
}
|
||||
if (trunc == TRUE) {
|
||||
@@ -160,7 +174,7 @@ extern int dd_main(int argc, char **argv)
|
||||
(inTotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
|
||||
+5
-5
@@ -28,21 +28,21 @@ printf("erik: A\n");
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
exit( FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
printf("erik: B\n");
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
errorMsg("0: illegal VT number\n");
|
||||
error_msg("0: illegal VT number\n");
|
||||
else if (num == 1)
|
||||
errorMsg("VT 1 cannot be deallocated\n");
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
fatalError("could not deallocate console %d\n", num);
|
||||
error_msg_and_die("could not deallocate console %d\n", num);
|
||||
}
|
||||
}
|
||||
printf("erik: C\n");
|
||||
return( TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Vendored
+358
@@ -0,0 +1,358 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
#define BB_INIT
|
||||
#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
#define BB_POWEROFF
|
||||
#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UNIX2DOS
|
||||
#define BB_UPDATE
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
//#define BB_FEATURE_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#endif
|
||||
#endif
|
||||
Vendored
+345
@@ -0,0 +1,345 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
//#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
//#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
//#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
#define BB_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
//#define BB_LSMOD
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
#define BB_POWEROFF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD
|
||||
//#define BB_RPMUNPACK
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES
|
||||
//#define BB_SH
|
||||
#define BB_SLEEP
|
||||
//#define BB_SORT
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
//#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
//#define BB_TTY
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
//#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UNIX2DOS
|
||||
//#define BB_UPDATE
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
//#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may no -o nolock if no local portmapper is running.
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
//#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
//#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
//#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
//#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell builtins can be called using full path
|
||||
//names. This causes builtins (i.e. every single busybox command) to override
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//#define BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
//#define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#define BB_FEATURE_STATUSBAR
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#endif
|
||||
#endif
|
||||
Vendored
+8
@@ -1,3 +1,11 @@
|
||||
busybox (0.48-1) unstable; urgency=low
|
||||
|
||||
* Lots more source updates and bug fixes. See changelog for details.
|
||||
* Now includes .udeb support for the debian-installer. The .udeb
|
||||
probably needs some more work, but this should be a good start.
|
||||
|
||||
-- Erik Andersen <andersee@debian.org> Wed, 13 Dec 2000 08:36:07 -0700
|
||||
|
||||
busybox (0.47-1) unstable; urgency=low
|
||||
|
||||
* New version released. See changelog for details.
|
||||
|
||||
Vendored
+26
-9
@@ -1,16 +1,16 @@
|
||||
Source: busybox
|
||||
Priority: optional
|
||||
Maintainer: Erik Andersen <andersee@debian.org>
|
||||
Build-Depends: debhelper
|
||||
Standards-Version: 3.1.1
|
||||
Build-Depends: debhelper (>= 2.1.18), dpkg-dev (1.7.0)
|
||||
Standards-Version: 3.2.1.0
|
||||
|
||||
Package: busybox
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Conflicts: binutils, bsdutils, console-tools, cpio, debianutils, dnsutils, dpkg, fbset, fdflush, fileutils, grep, gzip, hostname, modutils, mount, netbase, procps, psmisc, sed, sharutils, shellutils, sysklogd, sysvinit, tar, textutils, update, util-linux
|
||||
Replaces: netbase
|
||||
Conflicts:
|
||||
Replaces:
|
||||
Section: utils
|
||||
Description: Tiny utilities for the debian-installer and for embedded systems.
|
||||
Description: Tiny utilities for small and embedded systems.
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for the most common
|
||||
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
|
||||
@@ -19,10 +19,10 @@ Description: Tiny utilities for the debian-installer and for embedded systems.
|
||||
provide the expected functionality and behave very much like their GNU
|
||||
counterparts.
|
||||
.
|
||||
BusyBox is used by the debian-installer. Installing BusyBox onto your Debian
|
||||
system is not recommended, unless you are intended to make a very small
|
||||
embedded system. Chances are good that for embedded systems, you will want to
|
||||
recompile to only include the tools and utilities you wish to include.
|
||||
This package installs the BusyBox binary but does not install symlinks
|
||||
for any of the supported utilities. You can use /bin/busybox --install
|
||||
to install BusyBox to the current directory (you do not want to do this
|
||||
in / on your Debian system!).
|
||||
|
||||
Package: busybox-static
|
||||
Architecture: any
|
||||
@@ -44,3 +44,20 @@ Description: Provides a stand alone rescue shell with tons of builtin utilities.
|
||||
your system from certain destruction. Invoke "busybox", and it will list the
|
||||
available builtin commands.
|
||||
|
||||
Package: busybox-udeb
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Section: debian-installer
|
||||
Description: Tiny utilities for the debian-installer
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for the most common
|
||||
utilities you would usually find on your desktop system (i.e. ls, cp, mv,
|
||||
mount, tar, etc). The utilities in BusyBox generally have fewer options than
|
||||
their full-featured GNU cousins; however, the options that are included
|
||||
provide the expected functionality and behave very much like their GNU
|
||||
counterparts.
|
||||
.
|
||||
busybox-udeb is used by the debian-installer, so unless you are working
|
||||
on the debian-installer, this package is not for you. Installing this
|
||||
on your Debian system is a very, very bad idea. You have been warned.
|
||||
|
||||
Vendored
+113
-50
@@ -1,50 +1,60 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
# This is a bit unusual, in that I have to completely recompile everything
|
||||
# twice. The first is the normal, dynamically linked package. The second is
|
||||
# for the statically linked package. This file has been adjusted accordingly.
|
||||
# for each package I build (obviously static and dynamic builds require
|
||||
# things to be recompiled...)
|
||||
|
||||
# This is the debhelper compatability version to use.
|
||||
export DH_COMPAT=1
|
||||
#export DH_COMPAT=1
|
||||
|
||||
bbbd=debian/busybox_builddir
|
||||
bb=debian/tmp
|
||||
bbsbd=debian/busybox_static_builddir
|
||||
bbs=debian/busybox-static
|
||||
bbubd=debian/busybox_udeb_builddir
|
||||
bbu=debian/busybox-udeb
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp-busybox build-stamp-busybox-static
|
||||
rm -f debian/build-stamp-busybox debian/build-stamp-busybox-static debian/build-stamp-busybox-udeb
|
||||
-$(MAKE) clean
|
||||
-rm -rf $(bb) $(bbs)
|
||||
-rm -rf $(bb) $(bbbd) $(bbs) $(bbsbd) $(bbubd) $(bbu)
|
||||
dh_clean
|
||||
|
||||
half_clean:
|
||||
build: debian/build-stamp-busybox
|
||||
debian/build-stamp-busybox:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -rf $(bbs) build-stamp-busybox-static
|
||||
-$(MAKE) clean
|
||||
|
||||
build: build-stamp-busybox
|
||||
build-stamp-busybox:
|
||||
dh_testdir
|
||||
$(MAKE)
|
||||
touch build-stamp-busybox
|
||||
mkdir -p $(bbbd)
|
||||
cp Makefile $(bbbd)
|
||||
cp debian/Config.h-deb $(bbbd)/Config.h
|
||||
(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../")
|
||||
touch debian/build-stamp-busybox
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
$(MAKE) "PREFIX=$(bb)" install
|
||||
# Do not run 'make install', since we do not want all the symlinks.
|
||||
# This just installes the busybox binary...
|
||||
#(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bb)" install)
|
||||
mkdir -p $(bb)/bin/
|
||||
cp $(bbbd)/busybox $(bb)/bin/busybox
|
||||
mkdir -p $(bb)/usr/share/doc/busybox/busybox.lineo.com
|
||||
cp $(bbbd)/docs/busybox.lineo.com/BusyBox.html $(bb)/usr/share/doc/busybox/busybox.lineo.com/
|
||||
mkdir -p $(bb)/usr/share/man/man1
|
||||
cp docs/BusyBox.1 $(bb)/usr/share/man/man1/busybox.1
|
||||
cp $(bbbd)/docs/BusyBox.1 $(bb)/usr/share/man/man1/busybox.1
|
||||
|
||||
# Now for the statically linked stuff
|
||||
build-static: build-stamp-busybox-static
|
||||
build-stamp-busybox-static:
|
||||
build-static: debian/build-stamp-busybox-static
|
||||
debian/build-stamp-busybox-static:
|
||||
dh_testdir
|
||||
$(MAKE) DOSTATIC=true
|
||||
touch build-stamp-busybox-static
|
||||
mkdir -p $(bbsbd)
|
||||
cp Makefile $(bbsbd)
|
||||
cp debian/Config.h-deb $(bbsbd)/Config.h
|
||||
(cd $(bbsbd); $(MAKE) DOSTATIC=true "BB_SRC_DIR=../../")
|
||||
touch debian/build-stamp-busybox-static
|
||||
|
||||
install-static: build
|
||||
dh_testdir
|
||||
@@ -53,51 +63,83 @@ install-static: build
|
||||
dh_installdirs
|
||||
# Do not run 'make install', since we do not want all the symlinks.
|
||||
# This just installes the busybox binary...
|
||||
#$(MAKE) "PREFIX=$(bbs)" install
|
||||
#(cd $(bbsbd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbs)" install)
|
||||
mkdir -p $(bbs)/bin/
|
||||
cp busybox $(bbs)/bin/busybox
|
||||
cp $(bbsbd)/busybox $(bbs)/bin/busybox
|
||||
mkdir -p $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com
|
||||
cp $(bbsbd)/docs/busybox.lineo.com/BusyBox.html $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/
|
||||
mkdir -p $(bbs)/usr/share/man/man1/
|
||||
cp docs/BusyBox.1 $(bbs)/usr/share/man/man1/busybox.1
|
||||
cp $(bbsbd)/docs/BusyBox.1 $(bbs)/usr/share/man/man1/busybox.1
|
||||
|
||||
half_clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -rf $(bbs) debian/build-stamp-busybox-static
|
||||
-$(MAKE) clean
|
||||
|
||||
do_static: half_clean build-static install-static
|
||||
|
||||
|
||||
|
||||
# Now for the .udeb stuff
|
||||
PACKAGE=busybox
|
||||
VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
|
||||
ARCH=$(shell dpkg --print-architecture)
|
||||
FILENAME=$(PACKAGE)_$(VERSION)_$(ARCH).udeb
|
||||
PRIORITY=$(shell grep ^Priority: debian/control | cut -d ' ' -f 2)
|
||||
|
||||
build-udeb: debian/build-stamp-busybox-udeb
|
||||
debian/build-stamp-busybox-udeb:
|
||||
dh_testdir
|
||||
mkdir -p $(bbubd)
|
||||
cp Makefile $(bbubd)
|
||||
cp debian/Config.h-udeb $(bbubd)/Config.h
|
||||
(cd $(bbubd); $(MAKE) "BB_SRC_DIR=../../")
|
||||
touch debian/build-stamp-busybox-udeb
|
||||
|
||||
install-udeb: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
(cd $(bbubd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbu)" install)
|
||||
mkdir -p $(bbu)/usr/share/man/man1/
|
||||
cp $(bbubd)/docs/BusyBox.1 $(bbu)/usr/share/man/man1/busybox.1
|
||||
|
||||
three_quarter_clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -rf $(bbu) debian/build-stamp-busybox-udeb
|
||||
-$(MAKE) clean
|
||||
|
||||
do_udeb: three_quarter_clean build-udeb install-udeb
|
||||
|
||||
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep:
|
||||
# We have nothing to do by default.
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: busybox busybox-static
|
||||
binary-arch: busybox busybox-static busybox-udeb
|
||||
|
||||
busybox: install
|
||||
@echo "--- Building: $@"
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installdirs
|
||||
#
|
||||
#Note that for busybox, we do not install any docs,
|
||||
# or man apges or anything else. This is in blatent violation of every
|
||||
# Debian policy out there, since this package is intended to be used
|
||||
# _only_ by the debian-installer.
|
||||
#
|
||||
#dh_installdocs -p$@ docs/BusyBox.txt \
|
||||
# docs/BusyBox.html docs/busybox.lineo.com AUTHORS README TODO
|
||||
#rm -rf $(bb)/usr/share/doc/busybox/busybox.lineo.com/CVS \
|
||||
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/.cvsignore \
|
||||
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/images/CVS \
|
||||
# $(bb)/usr/share/doc/busybox/busybox.lineo.com/images/.cvsignore
|
||||
#dh_undocumented -p$@
|
||||
dh_installdocs -p$@ $(bbbd)/docs/BusyBox.txt \
|
||||
$(bbbd)/docs/BusyBox.html docs/style-guide.txt \
|
||||
docs/busybox.lineo.com AUTHORS README TODO
|
||||
rm -rf `find $(bb) -name CVS`
|
||||
rm -f `find $(bb) -name .cvsignore`
|
||||
dh_installchangelogs -p$@ Changelog
|
||||
dh_undocumented -p$@
|
||||
dh_strip -p$@
|
||||
dh_compress -p$@
|
||||
dh_fixperms -p$@
|
||||
dh_installdeb -p$@
|
||||
dh_shlibdeps -p$@
|
||||
#
|
||||
#Make _very_ sure there are no docs lurking about.
|
||||
#
|
||||
rm -rf $(bb)/usr/share/doc
|
||||
rm -rf $(bb)/usr/share/man
|
||||
dh_gencontrol -p$@
|
||||
dh_md5sums -p$@
|
||||
dh_builddeb -p$@
|
||||
@@ -108,14 +150,13 @@ busybox-static: do_static
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installdirs
|
||||
dh_installdocs -p$@ docs/BusyBox.txt \
|
||||
docs/BusyBox.html docs/busybox.lineo.com AUTHORS README TODO
|
||||
rm -rf $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/CVS \
|
||||
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/.cvsignore \
|
||||
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/images/CVS \
|
||||
$(bbs)/usr/share/doc/busybox-static/busybox.lineo.com/images/.cvsignore
|
||||
dh_undocumented -p$@
|
||||
dh_installdocs -p$@ $(bbsbd)/docs/BusyBox.txt \
|
||||
$(bbsbd)/docs/BusyBox.html docs/style-guide.txt \
|
||||
docs/busybox.lineo.com AUTHORS README TODO
|
||||
rm -rf `find $(bbs) -name CVS`
|
||||
rm -f `find $(bbs) -name .cvsignore`
|
||||
dh_installchangelogs -p$@ Changelog
|
||||
dh_undocumented -p$@
|
||||
dh_strip -p$@
|
||||
dh_compress -p$@
|
||||
dh_fixperms -p$@
|
||||
@@ -126,5 +167,27 @@ busybox-static: do_static
|
||||
dh_builddeb -p$@
|
||||
|
||||
|
||||
# Note that this builds a .udeb, which is not policy compliant or anything.
|
||||
#
|
||||
busybox-udeb: do_udeb
|
||||
@echo "--- Building: $@"
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installdirs
|
||||
dh_strip -p$@
|
||||
dh_compress -p$@
|
||||
dh_fixperms -p$@
|
||||
dh_installdeb -p$@
|
||||
dh_shlibdeps -p$@
|
||||
#Make _very_ sure there are no docs lurking about.
|
||||
rm -rf $(bbu)/usr/share/man
|
||||
#dh_gencontrol -p$@
|
||||
# Don't write your stupid guesses to debian/files.
|
||||
dh_gencontrol -p$@ -- -fdebian/files~
|
||||
# Register file manually.
|
||||
dpkg-distaddfile $(FILENAME) debian-installer $(PRIORITY)
|
||||
dh_md5sums -p$@
|
||||
dh_builddeb -p$@ --filename=$(FILENAME)
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install
|
||||
@@ -36,7 +36,7 @@ static int df(char *device, const char *mountPoint)
|
||||
long blocks_percent_used;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
perror_msg("%s", mountPoint);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -63,45 +63,44 @@ static int df(char *device, const char *mountPoint)
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage(df_usage);
|
||||
}
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) == 0) {
|
||||
errorMsg("%s: can't find mount point.\n", argv[1]);
|
||||
exit(FALSE);
|
||||
}
|
||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (status != 0)
|
||||
exit(status);
|
||||
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.\n", argv[1]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
exit(TRUE);
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
perror(mtab_file);
|
||||
exit(FALSE);
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -32,13 +32,14 @@ extern int dirname_main(int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s && *s == '/') {
|
||||
*s = '\0';
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s != *argv && *s == '/') {
|
||||
*s-- = '\0';
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s && *s)
|
||||
if (s != NULL && s == *argv)
|
||||
s[1] = '\0';
|
||||
else if (s != NULL)
|
||||
*s = '\0';
|
||||
printf("%s\n", (s)? *argv : ".");
|
||||
return(TRUE);
|
||||
puts(s ? *argv : ".");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ int dmesg_main(int argc, char **argv)
|
||||
if (n < 0) {
|
||||
goto klogctl_error;
|
||||
}
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (bufsize < 4096)
|
||||
@@ -86,7 +86,7 @@ int dmesg_main(int argc, char **argv)
|
||||
|
||||
lastc = '\n';
|
||||
for (i = 0; i < n; i++) {
|
||||
if ((i == 0 || buf[i - 1] == '\n') && buf[i] == '<') {
|
||||
if (lastc == '\n' && buf[i] == '<') {
|
||||
i++;
|
||||
while (buf[i] >= '0' && buf[i] <= '9')
|
||||
i++;
|
||||
@@ -98,11 +98,11 @@ int dmesg_main(int argc, char **argv)
|
||||
}
|
||||
if (lastc != '\n')
|
||||
putchar('\n');
|
||||
exit(TRUE);
|
||||
return EXIT_SUCCESS;
|
||||
end:
|
||||
usage(dmesg_usage);
|
||||
exit(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
klogctl_error:
|
||||
perror("klogctl");
|
||||
return(FALSE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
BusyBox.txt
|
||||
BusyBox.1
|
||||
BusyBox.html
|
||||
busybox.txt
|
||||
busybox.ps
|
||||
busybox.pdf
|
||||
busybox
|
||||
|
||||
+49
-46
@@ -47,7 +47,8 @@ BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add a kernel, a shell (such as ash),
|
||||
and an editor (such as elvis-tiny or ae).
|
||||
and an editor (such as elvis-tiny or ae). For a really minimal system, just
|
||||
the the busybox shell (not a POSIX shell, but very small and quite usable).
|
||||
<p>
|
||||
|
||||
BusyBox is now maintained by
|
||||
@@ -76,45 +77,36 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
|
||||
|
||||
<ul>
|
||||
|
||||
<p> <li> <b>11 July 2000 -- BusyBox 0.46 released</b>
|
||||
<p> <li> <b>13 December 2000 -- BusyBox 0.48 released</b>
|
||||
<br>
|
||||
|
||||
This release fixes several bugs (including a ugly bug in tar,
|
||||
and fixes for NFSv3 mount support). Added a dumpkmap to allow
|
||||
people to dump a binary keymaps for use with 'loadkmap', and a
|
||||
completely reworked 'grep' and 'sed' which should behave better.
|
||||
BusyBox shell can now also be used as a login shell.
|
||||
See the <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for complete details.
|
||||
This release fixes lots and lots of bugs. This has had some very
|
||||
rigorous testing, and looks very, very clean. The usual tar
|
||||
update of course: tar no longer breaks hardlinks, tar -xzf is
|
||||
optionally supported, and the LRP folks will be pleased to know
|
||||
that 'tar -X' and 'tar --exclude' are both now in. Applets are
|
||||
now looked up using a binary search makeing lash (the busybox
|
||||
shell) much faster. For the new debian-installer (for Debian
|
||||
woody) a .udeb can now be generated.
|
||||
<p>
|
||||
The curious can get a list of some of the more interesting chages by reading
|
||||
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
|
||||
<p>
|
||||
Many thanks go out to the many many people that have contributed to
|
||||
this release, especially Matt Kraai, Larry Doolittle, and Kent Robotti.
|
||||
|
||||
|
||||
<p> <li> <b>21 June 2000 -- BusyBox 0.45 released</b>
|
||||
<p> <li> <b>26 September 2000 -- BusyBox 0.47 released</b>
|
||||
<br>
|
||||
|
||||
This release has been slow in coming, but is very solid at this
|
||||
point. BusyBox now supports libc5 as well as GNU libc. This
|
||||
release provides the following new apps: cut, tr, insmod, ar,
|
||||
mktemp, setkeycodes, md5sum, uuencode, uudecode, which, and
|
||||
telnet. There are bug fixes for just about every app as well (see
|
||||
the <a href="ftp://ftp.lineo.com/pub/busybox/Changelog">changelog</a> for
|
||||
details).
|
||||
<p>
|
||||
Also, some exciting infrastructure news! Busybox now has its own
|
||||
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>,
|
||||
publically browsable
|
||||
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
|
||||
anonymous
|
||||
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
|
||||
for those that are actively contributing there is even
|
||||
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
|
||||
I think this will be a huge help to the ongoing development of BusyBox.
|
||||
<p>
|
||||
Also, for the curious, there is no 0.44 release. Somehow 0.44 got announced
|
||||
a few weeks ago prior to its actually being released. To avoid any confusion
|
||||
we are just skipping 0.44.
|
||||
<p>
|
||||
Many thanks go out to the many people that have contributed to this release
|
||||
of BusyBox (esp. Pavel Roskin)!
|
||||
|
||||
This release fixes lots of bugs (including an ugly bug in 0.46
|
||||
syslogd that could fork-bomb your system). Added several new
|
||||
apps: rdate, wget, getopt, dos2unix, unix2dos, reset, unrpm,
|
||||
renice, xargs, and expr. syslogd now supports network logging.
|
||||
There are the usual tar updates. Most apps now use getopt for
|
||||
more correct option parsing.
|
||||
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
|
||||
for complete details.
|
||||
|
||||
|
||||
<p> <li> <b>Old News</b>
|
||||
@@ -133,7 +125,7 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
|
||||
<TR><TD BGCOLOR="#eeeee0">
|
||||
<ul>
|
||||
<li> Source for the latest release can always be downloaded from
|
||||
<a href="ftp://ftp.lineo.com/pub/busybox">ftp://ftp.lineo.com/pub/busybox</a>.
|
||||
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
|
||||
<li> BusyBox now has its own publically browsable
|
||||
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
|
||||
anonymous
|
||||
@@ -153,13 +145,18 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
|
||||
<TR><TD BGCOLOR="#eeeee0">
|
||||
Current documentation for BusyBox includes:
|
||||
<ul>
|
||||
<li> <a href="BusyBox.html">BusyBox.html</a>
|
||||
This is a list of the all the available commands in BusyBox with complete
|
||||
usage information and examples of how to use each app. I spent
|
||||
a <em>lot</em> of time updating these docs and trying to make them
|
||||
fairly comprehensive for the BusyBox 0.43 release. If you find any
|
||||
errors (factual, grammatical, whatever) please let me know.
|
||||
<li> <a href="ftp://oss.lineo.com/busybox/BusyBox.html">BusyBox.html</a>.
|
||||
This is a list of the all the available commands in BusyBox with
|
||||
complete usage information and examples of how to use each app. I
|
||||
have spent a <em>lot</em> of time updating these docs and trying to
|
||||
make them fairly comprehensive. If you find any errors (factual,
|
||||
grammatical, whatever) please let me know.
|
||||
<li> <a href="ftp://oss.lineo.com/busybox/BusyBox.pdf">BusyBox.pdf</a>.
|
||||
This is basically the same document, but in pdf format.
|
||||
<li> <a href="ftp://oss.lineo.com/busybox/README">README</a>.
|
||||
This is the README file included in the busybox source release.
|
||||
<li> <a href="http://bugs.lineo.com/db/pa/lbusybox.html">BusyBoxBugs</a>.
|
||||
Need to report a bug? Need to check if a bug has been filed?
|
||||
<li> If you need more help, the BusyBox
|
||||
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a> is
|
||||
a good place to start.
|
||||
@@ -170,15 +167,17 @@ Current documentation for BusyBox includes:
|
||||
|
||||
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
|
||||
<A NAME="projects"><BIG><B>
|
||||
Products/Projects using BusyBox
|
||||
Products/Projects Using BusyBox
|
||||
</A></B></BIG>
|
||||
</TD></TR>
|
||||
<TR><TD BGCOLOR="#eeeee0">
|
||||
I know of the following products and/or projects that use BusyBox -- listed
|
||||
in the order I happen to add them to the web page:
|
||||
|
||||
<p> I know of the following products and/or projects that use BusyBox --
|
||||
listed in the order I happen to add them to the web page:
|
||||
|
||||
<ul>
|
||||
<li> <a href="http://www.lineo.com/products/embedix_linux/">Lineo Embedix Linux</a>
|
||||
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian boot floppies project</a>
|
||||
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian installer (boot floppies) project</a>
|
||||
<li> <a href="http://www.linuxrouter.org/">Linux Router Project </a>
|
||||
<li> <a href="http://linux-embedded.org/">LEM</a>
|
||||
<li> <a href="http://www.toms.net/rb/">tomsrtbt</a>
|
||||
@@ -190,9 +189,13 @@ in the order I happen to add them to the web page:
|
||||
<li> <a href="http://www.linuxmagic.com/vpn/">LinuxMagic VPN Firewall</a>
|
||||
<li> <a href="http://byld.sourceforge.net/">Build Your Linux Disk</a>
|
||||
<li> <a href="http://homepages.ihug.co.nz/~ichi/baslinux.html">BasicLinux</a>
|
||||
<li> <a href="http://ibiblio.org/pub/Linux/system/recovery">Zdisk</a>
|
||||
<li> <a href="http://www.adtran.com">AdTran - VPN/firewall VPN Linux Distribution</a>
|
||||
|
||||
</ul>
|
||||
Do you use BusyBox? I'd love to know about it and I'd be happy to link to you.
|
||||
|
||||
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to
|
||||
you.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,6 +41,47 @@
|
||||
<p> <li> <b>Take me back to the <a href="http://busybox.lineo.com/">BusyBox</a> web site.</b>
|
||||
<hr>
|
||||
|
||||
<p> <li> <b>11 July 2000 -- BusyBox 0.46 released</b>
|
||||
<br>
|
||||
|
||||
This release fixes several bugs (including a ugly bug in tar,
|
||||
and fixes for NFSv3 mount support). Added a dumpkmap to allow
|
||||
people to dump a binary keymaps for use with 'loadkmap', and a
|
||||
completely reworked 'grep' and 'sed' which should behave better.
|
||||
BusyBox shell can now also be used as a login shell.
|
||||
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
|
||||
for complete details.
|
||||
|
||||
|
||||
<p> <li> <b>21 June 2000 -- BusyBox 0.45 released</b>
|
||||
<br>
|
||||
|
||||
This release has been slow in coming, but is very solid at this
|
||||
point. BusyBox now supports libc5 as well as GNU libc. This
|
||||
release provides the following new apps: cut, tr, insmod, ar,
|
||||
mktemp, setkeycodes, md5sum, uuencode, uudecode, which, and
|
||||
telnet. There are bug fixes for just about every app as well (see
|
||||
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a> for
|
||||
details).
|
||||
<p>
|
||||
Also, some exciting infrastructure news! Busybox now has its own
|
||||
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>,
|
||||
publically browsable
|
||||
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
|
||||
anonymous
|
||||
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
|
||||
for those that are actively contributing there is even
|
||||
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
|
||||
I think this will be a huge help to the ongoing development of BusyBox.
|
||||
<p>
|
||||
Also, for the curious, there is no 0.44 release. Somehow 0.44 got announced
|
||||
a few weeks ago prior to its actually being released. To avoid any confusion
|
||||
we are just skipping 0.44.
|
||||
<p>
|
||||
Many thanks go out to the many people that have contributed to this release
|
||||
of BusyBox (esp. Pavel Roskin)!
|
||||
|
||||
|
||||
<p> <li> <b>19 April 2000 -- syslogd bugfix</b>
|
||||
<br>
|
||||
Turns out that there was still a bug in busybox syslogd.
|
||||
|
||||
+48
-16
@@ -453,7 +453,7 @@ Example:
|
||||
|
||||
Usage: dumpkmap
|
||||
|
||||
Prints out a binary keyboard translation table to standard input.
|
||||
Prints out a binary keyboard translation table to standard output.
|
||||
|
||||
Example:
|
||||
|
||||
@@ -506,7 +506,7 @@ Example:
|
||||
|
||||
-------------------------------
|
||||
|
||||
=item echo
|
||||
=item expr
|
||||
|
||||
|
||||
Usage: expr EXPRESSION
|
||||
@@ -765,6 +765,7 @@ When FILE is '-', reads standard input. Implies B<-c>.
|
||||
Options:
|
||||
|
||||
-c Write output to standard output instead of FILE.gz
|
||||
-d decompress
|
||||
|
||||
Example:
|
||||
|
||||
@@ -827,7 +828,7 @@ Options:
|
||||
-s Short
|
||||
-i Addresses for the hostname
|
||||
-d DNS domain name
|
||||
-F FILE Use the contents of FILE to specify the hostname
|
||||
-F, --file FILE Use the contents of FILE to specify the hostname
|
||||
|
||||
Example:
|
||||
|
||||
@@ -900,13 +901,37 @@ If you choose to use an /etc/inittab file, the inittab entry format is as follow
|
||||
Valid actions include: sysinit, respawn, askfirst, wait,
|
||||
once, and ctrlaltdel.
|
||||
|
||||
askfirst acts just like respawn, but before running the specified
|
||||
process it displays the line "Please press Enter to activate this
|
||||
console." and then waits for the user to press enter before starting
|
||||
the specified process.
|
||||
|
||||
Unrecognized actions (like initdefault) will cause init to emit
|
||||
an error message, and then go along with its business.
|
||||
The available actions can be classified into two groups: actions
|
||||
that are run only once, and actions that are re-run when the specified
|
||||
process exits.
|
||||
|
||||
Run only-once actions:
|
||||
|
||||
'sysinit' is the first item run on boot. init waits until all
|
||||
sysinit actions are completed before continuing. Following the
|
||||
completion of all sysinit actions, all 'wait' actions are run.
|
||||
'wait' actions, like 'sysinit' actions, cause init to wait until
|
||||
the specified task completes. 'once' actions are asyncronous,
|
||||
therefore, init does not wait for them to complete. 'ctrlaltdel'
|
||||
actions are run immediately before init causes the system to reboot
|
||||
(unmounting filesystems with a 'ctrlaltdel' action is a very good
|
||||
idea).
|
||||
|
||||
Run repeatedly actions:
|
||||
|
||||
'respawn' actions are run after the 'once' actions. When a process
|
||||
started with a 'respawn' action exits, init automatically restarts
|
||||
it. Unlike sysvinit, BusyBox init does not stop processes from
|
||||
respawning out of control. The 'askfirst' actions acts just like
|
||||
respawn, except that before running the specified process it
|
||||
displays the line "Please press Enter to activate this console."
|
||||
and then waits for the user to press enter before starting the
|
||||
specified process.
|
||||
|
||||
Unrecognized actions (like initdefault) will cause init to emit an
|
||||
error message, and then go along with its business. All actions are
|
||||
run in the reverse order from how they appear in /etc/inittab.
|
||||
|
||||
<process>:
|
||||
|
||||
@@ -936,11 +961,11 @@ Example /etc/inittab file:
|
||||
|
||||
# Example of how to put a getty on a serial line (for a terminal)
|
||||
#
|
||||
#ttyS0::respawn:/sbin/getty -L ttyS0 9600 vt100
|
||||
#ttyS1::respawn:/sbin/getty -L ttyS1 9600 vt100
|
||||
#::respawn:/sbin/getty -L ttyS0 9600 vt100
|
||||
#::respawn:/sbin/getty -L ttyS1 9600 vt100
|
||||
#
|
||||
# Example how to put a getty on a modem line.
|
||||
#ttyS2::respawn:/sbin/getty -x0 -s 57600 ttyS2
|
||||
#::respawn:/sbin/getty 57600 ttyS2
|
||||
|
||||
# Stuff to do before rebooting
|
||||
::ctrlaltdel:/bin/umount -a -r
|
||||
@@ -1702,11 +1727,12 @@ Note that this version of syslogd/klogd ignores /etc/syslog.conf.
|
||||
|
||||
Options:
|
||||
|
||||
-m NUM Interval between MARK lines (default=20min, 0=off)
|
||||
-m NUM Interval between MARK lines (default=20min, 0=off)
|
||||
-n Run as a foreground process
|
||||
-K Do not start up the klogd process
|
||||
-O FILE Use an alternate log file (default=/var/log/messages)
|
||||
-R HOST[:PORT] Log messages to HOST on PORT (default=514) over UDP.
|
||||
-O FILE Use an alternate log file (default=/var/log/messages)
|
||||
-R HOST[:PORT] Log remotely to IP or hostname on PORT (default PORT=514/UDP)
|
||||
-L Log locally as well as network logging (default is network only)
|
||||
|
||||
Example:
|
||||
|
||||
@@ -1929,6 +1955,12 @@ Usage: uniq [OPTION]... [INPUT [OUTPUT]]
|
||||
|
||||
Discard all but one of successive identical lines from INPUT
|
||||
(or standard input), writing to OUTPUT (or standard output).
|
||||
|
||||
Options:
|
||||
|
||||
-c prefix lines by the number of occurrences
|
||||
-d only print duplicate lines
|
||||
-u only print unique lines
|
||||
|
||||
Example:
|
||||
|
||||
@@ -2261,4 +2293,4 @@ Enrique Zanardi <ezanardi@ull.es>
|
||||
|
||||
=cut
|
||||
|
||||
# $Id: busybox.pod,v 1.73 2000/09/24 02:41:44 andersen Exp $
|
||||
# $Id: busybox.pod,v 1.83 2000/12/13 17:59:37 andersen Exp $
|
||||
Loaded 100 of 254 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user