Major rework of the directory structure and the entire build system.

-Erik
This commit is contained in:
Eric Andersen 2001-10-24 05:00:29 +00:00
parent 9260fc5552
commit bdfd0d78bc
362 changed files with 8837 additions and 75874 deletions

View File

@ -2,3 +2,4 @@ busybox
busybox.links
_install
applet_source_list
.config

View File

@ -8,7 +8,7 @@ incorect, _please_ let me know.
-----------
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Erik Andersen <andersen@codepoet.org>, <andersee@debian.org>
Tons of new stuff, major rewrite of most of the
core apps, tons of new apps as noted in header files.

View File

@ -52,8 +52,8 @@
-- Fixed msh to support underscores in variable names.
-- Fixed a sed problem with unsatisfied backrefs (the problem was
noted by Martin Bene).
-- Removed BB_SH define entirely. Now one simply picks the shell
or shells they want as BB_<foo> in Config.h
-- Removed CONFIG_SH define entirely. Now one simply picks the shell
or shells they want as CONFIG_<foo> in Config.h
-- Fixed head to use ferror(3) to check for errors, not errno.
* Shu-Hao Chang <shuhao_chang@trend.com.tw>
-- Fixed sed handling of multiple -e commands
@ -62,10 +62,10 @@
* Jaspreet Singh <jsingh@somanetworks.com>
-- Fixed both a segfault and cosmetic bug in route
* Erik Andersen
-- Made the insmod options BB_FEATURE_NEW_MODULE_INTERFACE and
BB_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
-- Made the insmod options CONFIG_FEATURE_NEW_MODULE_INTERFACE and
CONFIG_FEATURE_OLD_MODULE_INTERFACE mutually exclusive
-- xgetcwd.c now includes sys/param.h to ensure PATH_MAX is defined
-- Fixed a potential segfault with lash + BB_FEATURE_CLEAN_UP
-- Fixed a potential segfault with lash + CONFIG_FEATURE_CLEAN_UP
-- Removed uint64_t from dos2unix, avoiding C lib compat. problems.
* Glenn McGrath
-- Rewrite of tftp (commands match atftp, accepts -b, can use
@ -136,7 +136,7 @@
* Matt Kraai
-- Made tar read 20 512byte blocks at a time (like GNU tar)
-- Allow msh.c assignments with the export and readonly commands.
-- Added BB_FEATURE_DEVFS to enable devfs device names.
-- Added CONFIG_FEATURE_DEVFS to enable devfs device names.
-- Better devfs support
-- Don't save/restore vi readonly flag if vi is compiled read-only.
-- Reworked rdate option handling (is now smaller).
@ -317,7 +317,7 @@
* Magnus Damm -- added a tftp applet
* Magnus Damm -- powerpc support for busybox insmod.
* David Douthitt -- fixed a build error in df.c when
BB_FEATURE_HUMAN_READABLE was disabled
CONFIG_FEATURE_HUMAN_READABLE was disabled
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
generate the documentation from the source code, making life
much simpler for all.
@ -424,7 +424,7 @@
* Mark Whitley -- Updates to style guide
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
de-macro-ifying some variables and functions
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
* Erik Andersen -- ls now honors CONFIG_FEATURE_AUTOWIDTH so it can find
the width and height of the console.
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
* Erik Andersen -- updates so you can now select from the Makefile
@ -440,7 +440,7 @@
0.48
* Glenn McGrath -- tar now supports uncompressing tar files,
define BB_FEATURE_TAR_GZIP to use the -z option.
define CONFIG_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.
@ -472,7 +472,7 @@
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
precedence over applets unless CONFIG_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
@ -605,7 +605,7 @@
0.45
* Now compiles vs libc5 (which can save lots of space for
embedded systems).
* Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
* Added CONFIG_FEATURE_TRIVIAL_HELP which compiles out most all of the
help messages (i.e --help). Saves 17k over a full compile.
* Added cut and tr from minix, since due to the license change,
we can now use minix code. Minix tr saves 4k.
@ -626,7 +626,7 @@
* Replaced the telnet implementation with one written by
Tomi Ollila <too@iki.fi> It works great and costs 3k.
* BusyBox sh (lash) now supports being used as a standalone shell. When
BB_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
CONFIG_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
be invoked as shell internals. Best used when compiling staticly
(i.e. DOSTATIC=true)
* BusyBox sh (lash) internals now behave as expected wrt pipes
@ -678,7 +678,7 @@
* Fixed exit status for killall - Pavel Roskin
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
* Fixed 'mount -a' so it works as expected.
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
* Implemented 'ls -R' (enabled by enabling CONFIG_FEATURE_LS_RECURSIVE)
* Implemented "ping -s", fixed error messages and argument parsing -
Pavel Roskin
* Syslogd will not go to background if "-n" is given. Better help
@ -716,7 +716,7 @@
saving a bunch of memory (kernel /proc support is not thin). This
is done by making use of some nice kernel patches I wrote up to
support the features that busybox requires and that /proc usually
provides. To enable this, turn on BB_FEATURE_USE_DEVPS_PATCH and
provides. To enable this, turn on CONFIG_FEATURE_USE_DEVPS_PATCH and
patch your kernel with the devps patch in the kernel-patches/
directory.
* Wrote basename, dirname, killall, and uptime.
@ -761,7 +761,7 @@
* An initial telnet implementation was added by
Randolph Chung <tausq@debian.org>.
* Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
* ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
* ps now supports CONFIG_FEATURE_AUTOWIDTH, and can adjust its width
to match the terminal (defaults to width=79 when this is off).
* ps now accepts (and ignores) all options except for "--help" (which
as would be expected displays help).
@ -784,7 +784,7 @@
* Fairly massive restructuring of umount.c to deal with remounting
busy devices read-only. Adds a -r option to control that; it is
optionally compiled in with BB_FEATURE_REMOUNT
optionally compiled in with CONFIG_FEATURE_REMOUNT
* Added a bunch of functions to mtab.c to interact with the
{get,set,end}mntent interface; as it turns out, those functions do
not appear to be re-entrant, and that causes a lot of problems with
@ -855,7 +855,7 @@
* Created a tiny tail implementation, removing -c, -q, -v, and making
tail -f work only with a single file. This reduced tail from 6k to
2.4k. The bigger/more featured tail can still be had by disabling
BB_FEATURE_SIMPLE_TAIL in busybox.defs.h
CONFIG_FEATURE_SIMPLE_TAIL in busybox.defs.h
* Ping now falls back to doing the right thing if /etc/protocols
turns up missing.
* Fixed mount and umount. Previously they could leak loop device
@ -907,14 +907,14 @@
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
<bcollins@debian.org>
* Several fixes from Marco Pantaleoni <panta@prosa.it> compile in
* fullWrite() not only if BB_TAR is defined, but also
if BB_CP or BB_MV are (fullWrite() is referenced by copyFile())
* fullWrite() not only if CONFIG_TAR is defined, but also
if CONFIG_CP or CONFIG_MV are (fullWrite() is referenced by copyFile())
* add some compiler optimizations to further reduce executable size
(as a side note, on my machines the largest code is generated
by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with
-O2 -m386 ...)
* Compile now won't fail if busybox.def.h defines
BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be
CONFIG_FEATURE_INITRD but not CONFIG_INIT. (init_main used to be
referenced, but not compiled)
* Fixed a bug in setting TERM for serial console support. TERM now
defaults to "ansi" for serial consoles.
@ -974,7 +974,7 @@
to suit my evil purposes. Costs 6k. I'll make it smaller
sometime.
* on reboot, init called 'umount -a -n', which caused errors
when BB_MTAB was not enabled. Changed to 'umount -a', which does
when CONFIG_MTAB was not enabled. Changed to 'umount -a', which does
the right thing.
* init will now try to run /sbin/getty if it is present (for easy
integration with the about-to-be-released tinylogin.)
@ -1009,7 +1009,7 @@
* I've taken a first step to making busybox not need the /proc
filesystem. Most apps don't need it. Those that _require_ it,
will complain if you enable them when you disable
BB_FEATURE_USE_PROCFS.
CONFIG_FEATURE_USE_PROCFS.
-Erik Andersen, Dec 5, 1999
@ -1047,7 +1047,7 @@
* from
Eric Delaunay).
* Made createPath be quiet (again thanks to Eric Delaunay). If
* BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
* CONFIG_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
command you define it as will be run if the init script exits.
* Updated install.sh to make it more robust (thanks to Adam Di Carlo)
* NFS support added to mount by Eric Delaunay. It costs 10k when
@ -1103,7 +1103,7 @@
to Eric Delaunay.
* more started to read from stdin after the last file was finished, and
options were not parsed correctly (fix thanks to Eric Delaunay).
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
* more will now use the terminal size if CONFIG_FEATURE_AUTOWIDTH is on.
* rm wouldn't remove a symlink unless the symlink was valid. This was
a side effect of the busybox 0.32 recursiveAction() fix. Things
should now work correctly.
@ -1121,7 +1121,7 @@
* Removed some debugging noise from init.c
* Fixed ln so it works now (it was very broken).
* Fixed df so it won't segfault when there is no /etc/fstab,
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
* If CONFIG_MTAB is not defined, df and mount will whine if /etc/fstab
is not installed (since they cannot fixup "/dev/root" to
state the real root device name)
* merged some redundant code from mtab.c/df.c into utility.c
@ -1129,9 +1129,8 @@
-Erik Andersen, Nov 5, 1999
0.32
* More changes -- many thanks to Lineo for paying me to work on
busybox. If you have any problems please let me know ASAP at
andersen@lineo.com or andersee@debian.org
* More changes -- If you have any problems please let me know ASAP at
andersee@debian.org
* usage() now prints the BusyBox version. This will help folks
realize that they are not in Kansas anymore.
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
@ -1142,11 +1141,11 @@
* with full regular expressions!). Fixed a stupid seg-fault in sync
* Fixed mount -- mount -a failed to parse and apply mount options Fixed
* umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
* umount -a no longer umounts /proc Added BB_MTAB, allowing (at the
* umount -a no longer umounts /proc Added CONFIG_MTAB, allowing (at the
* cost of ~1.5k and the need for a rw /etc)
folks to use a real /etc/mtab file instead of a symlink to
/proc/mounts. mount, and umount will add/remove entries and df
will now use /etc/mtab if BB_MTAB is defined.
will now use /etc/mtab if CONFIG_MTAB is defined.
* Fixed a nice bug in recursiveAction() which caused it to infinitely
hunt through /proc/../fd/* creating new file descriptors if it
followed the /dev/fd link over to /proc. recursiveAction() now
@ -1173,10 +1172,9 @@
-Erik Andersen, Oct 21, 1999
0.30
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
paying me to make these updates. If you have any problems with busybox,
or notice any bugs -- please let me know so I can fix it. These
changes include:
Major changes -- lots of stuff rewritten. If you have any problems
with busybox, or notice any bugs -- please let me know so I can fix
it. These changes include:
Core Changes:
* busybox can now invoke apps in two ways: via symlinks to the

494
Config.h
View File

@ -1,494 +0,0 @@
/* 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_ADDGROUP
//#define BB_ADDUSER
//#define BB_ADJTIMEX
//#define BB_AR
//#define BB_ASH
#define BB_BASENAME
//#define BB_BUNZIP2
#define BB_CAT
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP
//#define BB_CPIO
#define BB_CUT
#define BB_DATE
//#define BB_DC
#define BB_DD
//#define BB_DEALLOCVT
//#define BB_DELGROUP
//#define BB_DELUSER
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
//#define BB_DOS2UNIX
//#define BB_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
//#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_GETTY
#define BB_GREP
#define BB_GUNZIP
#define BB_GZIP
#define BB_HALT
#define BB_HEAD
//#define BB_HOSTID
//#define BB_HOSTNAME
//#define BB_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#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_MODPROBE
#define BB_MORE
#define BB_MOUNT
#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
#define BB_PIDOF
//#define BB_PING
//#define BB_PIVOT_ROOT
#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_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
//#define BB_START_STOP_DAEMON
#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_TFTP
#define BB_TOUCH
//#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
//#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#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).
//
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//
// 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. 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
//
// show verbose usage messages
//#define BB_FEATURE_VERBOSE_USAGE
//
// 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 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
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_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
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_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_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...
//
// If you are using uClibc, be sure that you've already compiled
// uClibc with INCLUDE_RPC=true (contained in the Config file)
//#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 uniqe sort
#define BB_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//
//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. Off by default.
// Only relevant if a shell is enabled.
//#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.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//
//Make interactive shells not print busybox messages
//#define BB_FEATURE_SH_EXTRA_QUIET
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 7k.
//#define BB_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
//#define BB_FEATURE_IFCONFIG_HW
//
// Allows "broadcast +" to set broadcast automatically based on hostaddr
// and netmask, at a cost of about 100 bytes of code (i386).
//#define BB_FEATURE_IFCONFIG_BROADCAST_PLUS
//
// 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_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
//
// 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
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
//
// Support for the find -mtine option.
#define BB_FEATURE_FIND_MTIME
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
//#define BB_FEATURE_TFTP_BLOCKSIZE
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
//
// Support for devfs.
//#define BB_FEATURE_DEVFS
//
// End of Features List
//
//
//
//
//
//
//---------------------------------------------------
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#endif
//
#if (defined BB_ASH || defined BB_HUSH || defined BB_MSH) && ! defined BB_TEST
#define BB_TEST
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif

View File

@ -17,15 +17,14 @@ Copyright 1998 Dave Cinege <dcinege@psychosis.com>
mini-gzip(gzip), mini-netcat(mnc)
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
Tons of new stuff as noted in header files
Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen and Erik Andersen
Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>

331
Makefile
View File

@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
# 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
@ -20,12 +20,19 @@
PROG := busybox
VERSION := 0.61.pre
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
export VERSION
TOPDIR := ${shell /bin/pwd}
HOSTCC := gcc
HOSTCFLAGS:= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
TARGET_OS := linux
# 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
# make CROSS=powerpc-linux- CONFIG_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
# If you want to add some simple compiler switches (like -march=i686),
# especially from the command line, use this instead of CFLAGS directly.
@ -39,18 +46,6 @@ DOSTATIC = false
# Leave this set to `false' for production use.
DODEBUG = false
# Setting this to `true' will cause busybox to directly use the system's
# password and group functions. Assuming you use GNU libc, when this is
# `true', you will need to install the /etc/nsswitch.conf configuration file
# and the required libnss_* libraries. This generally makes your embedded
# system quite a bit larger... If you leave this off, busybox will directly use
# the /etc/password, /etc/group files (and your system will be smaller, and I
# will get fewer emails asking about how glibc NSS works). Enabling this adds
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs).
# Note that if you want hostname resolution to work with glibc, you still need
# the libnss_* libraries.
USE_SYSTEM_PWD_GRP = true
# This enables compiling with dmalloc ( http://dmalloc.com/ )
# which is an excellent public domain mem leak and malloc problem
# detector. To enable dmalloc, before running busybox you will
@ -72,17 +67,24 @@ DOEFENCE = false
# larger than 2GB!
DOLFS = false
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
# If you have a "pristine" source directory, point CONFIG_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 =
CONFIG_SRC_DIR =
# If you are running a cross compiler, you may want to set this
# to something more interesting, like "powerpc-linux-".
# If you are running a cross compiler, you may want to set CROSS
# to something more interesting, like "arm-linux-".
CROSS =
CC = $(CROSS)gcc
AR = $(CROSS)ar
STRIPTOOL = $(CROSS)strip
CC = $(CROSS)gcc
AR = $(CROSS)ar
AS = $(CROSS)as
LD = $(CROSS)ld
NM = $(CROSS)nm
STRIP = $(CROSS)strip
CPP = $(CC) -E
MAKEFILES = $(TOPDIR)/.config
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# Everything should compile and work as expected these days...
@ -107,10 +109,11 @@ STRIPTOOL = $(CROSS)strip
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
# use '-Os' optimization if available, else use -O2
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "-Os"; else echo "-O2" ; fi)
OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1; then echo "-Os"; else echo "-O2" ; fi}
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
CFLAGS = -I $(TOPDIR)/include -I $(TOPDIR)/busybox
ARFLAGS = -r
#
@ -142,25 +145,14 @@ endif
ifeq ($(strip $(DODEBUG)),true)
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += -Wl,-warn-common
STRIP =
STRIPCMD =
else
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
LDFLAGS += -s -Wl,-warn-common
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
STRIPCMD = $(STRIP) --remove-section=.note --remove-section=.comment $(PROG)
endif
ifeq ($(strip $(DOSTATIC)),true)
LDFLAGS += --static
#
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
# work) to try and strip out any unused junk. Doesn't do much for me,
# but you may want to give it a shot...
#
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
# --gc-sections -v >/dev/null && echo 1),1)
# CFLAGS += -ffunction-sections -fdata-sections
# LDFLAGS += --gc-sections
#endif
endif
ifndef $(PREFIX)
@ -169,125 +161,77 @@ endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in BB_SRC_DIR, both during the compilation phase and the
# the copy in CONFIG_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>.
#
ifneq ($(strip $(BB_SRC_DIR)),)
VPATH = $(BB_SRC_DIR)
ifneq ($(strip $(CONFIG_SRC_DIR)),)
VPATH = $(CONFIG_SRC_DIR)
endif
#ifneq ($(strip $(VPATH)),)
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
#endif
# We need to set APPLET_SOURCES to something like
# $(shell busybox.sh Config.h)
# but in a manner that works with VPATH and BB_SRC_DIR.
# Possible ways to approach this:
#
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
#
# 2. Explicity search through .:$(VPATH) for slist.mk,
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
#
# 3. Create slist.mk in this directory, with commands embedded in
# a $(shell ...) command, and $(MAKE) it immediately.
#
# 4. Use a real rule within this makefile to create a file that sets
# APPLET_SOURCE_LIST, then include that file. Has complications
# with the first trip through the makefile (before processing the
# include) trying to do too much, and a spurious warning the first
# time make is run.
#
# This is option 3:
#
#APPLET_SOURCES = $(shell \
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
#)
# And option 4:
-include applet_source_list
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
CFLAGS += -DBB_VER='"$(VERSION)"'
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
ifdef CONFIG_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(CONFIG_INIT_SCRIPT)"'
endif
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
PWD_GRP = pwd_grp
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
PWD_LIB = libpwd.a
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
initgroups.c setgroups.c
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
ifneq ($(strip $(BB_SRC_DIR)),)
PWD_CFLAGS = -I- -I.
endif
PWD_CFLAGS += -I$(PWD_GRP_DIR)
else
CFLAGS += -DUSE_SYSTEM_PWD_GRP
endif
LIBBB = libbb
LIBBB_LIB = libbb.a
LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
copy_file_chunk.c libc5.c device_open.c error_msg.c \
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
find_root_device.c full_read.c full_write.c get_console.c \
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
simplify_path.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
ifeq ($(strip $(BB_SRC_DIR)),)
LIBBB_CFLAGS += -I$(LIBBB)
else
LIBBB_CFLAGS = -I- -I. -I./$(LIBBB) -I$(BB_SRC_DIR)/$(LIBBB) -I$(BB_SRC_DIR)
endif
LIBBB_MSRC=libbb/messages.c
LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
write_error too_few_args name_longer_than_foo unknown can_not_create_raw_socket
LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
LIBBB_ARCSRC=libbb/unarchive.c
LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \
get_header_ar get_header_cpio get_header_tar deb_extract
LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ))
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
.EXPORT_ALL_VARIABLES:
all: applet_source_list busybox busybox.links doc
all: do-it-all
applet_source_list: busybox.sh Config.h
(echo -n "APPLET_SOURCES := "; CC="$(CC)" BB_SRC_DIR="$(BB_SRC_DIR)" $(SHELL) $^) > $@
#
# Make "config" the default target if there is no configuration file or
# "depend" the target if there is no top-level dependency information.
ifeq (.config,$(wildcard .config))
include .config
ifeq (.depend,$(wildcard .depend))
include .depend
do-it-all: busybox busybox.links doc
else
CONFIGURATION = depend
do-it-all: depend
endif
else
CONFIGURATION = menuconfig
do-it-all: menuconfig
endif
SUBDIRS =applets archival console-tools editors fileutils findutils init \
miscutils modutils networking pwd_grp shell shellutils sysklogd \
textutils tinylogin util-linux libbb
bbsubdirs: $(patsubst %, _dir_%, $(SUBDIRS))
$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER
$(MAKE) CFLAGS="$(CFLAGS)" -C $(patsubst _dir_%, %, $@)
busybox: bbsubdirs
$(CC) $(LDFLAGS) -o $@ $(shell find $(SUBDIRS) -name \*.a) $(LIBCONFIG_LIB) $(LIBRARIES)
$(STRIPCMD)
busybox.links: applets/busybox.mkll
- $(SHELL) $^ >$@
install: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
install-hardlinks: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
# Documentation Targets
doc: olddoc
# Old Docs...
olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod : docs/busybox_header.pod usage.h docs/busybox_footer.pod
docs/busybox.pod : docs/busybox_header.pod applets/usage.h docs/busybox_footer.pod
- ( cat docs/busybox_header.pod; \
docs/autodocifier.pl usage.h; \
docs/autodocifier.pl applets/usage.h; \
cat docs/busybox_footer.pod ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
@ -340,86 +284,89 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
- mkdir -p docs
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
# The nifty new buildsystem stuff
scripts/mkdep: scripts/mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
$(STRIP)
scripts/split-include: scripts/split-include.c
$(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
# but with VPATH, some or all of those file names are resolved to the
# directories in which they live.
busybox.links: busybox.mkll Config.h applets.h
- $(SHELL) $^ >$@
dep-files: scripts/mkdep #archdep
rm -f .depend .hdepend
scripts/mkdep -I $(TOPDIR)/include -- `find $(TOPDIR) -name \*.c -print` >> .depend
scripts/mkdep -I $(TOPDIR)/include -- `find $(TOPDIR) -name \*.h -print` >> .hdepend
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)"
depend dep: dep-files
@ echo -e "\n\nNow run 'make' to build BusyBox\n\n"
CONFIG_SHELL := ${shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi}
include/config/MARKER: scripts/split-include include/config.h
scripts/split-include include/config.h include/config
@ touch include/config/MARKER
menuconfig:
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig sysdeps/$(TARGET_OS)/config.in
config:
$(CONFIG_SHELL) scripts/Configure sysdeps/$(TARGET_OS)/config.in
oldconfig:
$(CONFIG_SHELL) scripts/Configure -d sysdeps/$(TARGET_OS)/config.in
ifdef CONFIGURATION
..$(CONFIGURATION):
@echo
@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
@echo
$(MAKE) $(CONFIGURATION)
@echo
@echo "Successful. Try re-making (ignore the error that follows)"
@echo
exit 1
dummy:
nfsmount.o cmdedit.o: %.o: %.h
ash.o hush.o lash.o msh.o: cmdedit.h
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
ifeq ($(strip $(BB_SRC_DIR)),)
$(CC) $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
else
$(CC) $(CFLAGS) -I- -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
dummy:
endif
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
- mkdir -p $(PWD_GRP)
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
$(LIBBB_MOBJ): $(LIBBB_MSRC)
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
- mkdir -p $(LIBBB)
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
libpwd.a: $(PWD_OBJS)
$(AR) $(ARFLAGS) $@ $^
libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
$(AR) $(ARFLAGS) $@ $^
usage.o: usage.h
libbb/loop.o: libbb/loop.h
libbb/loop.h: mk_loop_h.sh
@ $(SHELL) $< > $@
include Rules.mak
# Testing...
test tests:
# old way of doing it
#cd tests && $(MAKE) all
# new way of doing it
cd tests && ./tester.sh
# Cleanup
clean:
- cd tests && $(MAKE) clean
- $(MAKE) -C tests clean
- $(MAKE) -C scripts/lxdialog 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 -f multibuild.log Config.h.orig *.gdb *.elf
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
docs/busybox.pdf docs/busybox.lineo.com/busybox.html \
docs/busybox _install pod2htm* *.gdb *.elf *~ core
- rm -f busybox.links libbb/loop.h .config.old .hdepend
- rm -f scripts/split-include scripts/mkdep .*config.log
- rm -rf include/config include/config.h
- find -name .\*.flags -o -name .depend -exec rm -f {} \;
- find -name \*.o -exec rm -f {} \;
- find -name \*.a -exec rm -f {} \;
distclean: clean
- rm -f busybox applet_source_list
- rm -f busybox
- cd tests && $(MAKE) distclean
install: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
install-hardlinks: install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
debug_pristine:
@ echo VPATH=\"$(VPATH)\"
@ echo OBJECTS=\"$(OBJECTS)\"
dist release: distclean doc
cd ..; \
rm -rf busybox-$(VERSION); \
@ -437,6 +384,8 @@ dist release: distclean doc
\
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
.PHONY: tags
tags:
ctags -R .

15
README
View File

@ -82,7 +82,7 @@ top of ash.c as well, so check those out if you want to tweak things.
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
archives at http://oss.lineo.com/lists/busybox/ or even join
the mailing list if you are interested.
----------------
@ -130,23 +130,18 @@ Source for the latest released version can always be downloaded from
CVS:
BusyBox now has its own publicly browsable CVS tree at:
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
http://oss.lineo.com/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://opensource.lineo.com/cvs_anon.html
http://oss.lineo.com/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://opensource.lineo.com/cvs_write.html
http://oss.lineo.com/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Erik Andersen
<andersen@lineo.com>
<andersen@codepoet.org>
<andersee@debian.org>
<andersee@codepoet.org>
<blatant plug>
Many thanks to go to Lineo for paying me to work on busybox.
</blatant plug>

View File

@ -1,178 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* addgroup - add users to /etc/passwd and /etc/shadow
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* 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 <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
#define GROUP_FILE "/etc/group"
#define SHADOW_FILE "/etc/gshadow"
/* structs __________________________ */
/* data _____________________________ */
/* defaults : should this be in an external file? */
static char *default_passwd = "x";
/* make sure gr_name isn't taken, make sure gid is kosher
* return 1 on failure */
static int group_study(const char *filename, struct group *g)
{
FILE *etc_group;
gid_t desired;
struct group *grp;
const int max = 65000;
/* FIXME : make an fopen_wrapper */
etc_group = fopen(filename, "r");
if (!etc_group) {
perror_msg_and_die("%s", filename);
}
/* make sure gr_name isn't taken, make sure gid is kosher */
desired = g->gr_gid;
while ((grp = fgetgrent(etc_group))) {
if ((strcmp(grp->gr_name, g->gr_name)) == 0) {
error_msg_and_die("%s: group already in use\n", g->gr_name);
}
if ((desired) && grp->gr_gid == desired) {
error_msg_and_die("%d: gid has already been allocated\n",
desired);
}
if ((grp->gr_gid > g->gr_gid) && (grp->gr_gid < max)) {
g->gr_gid = grp->gr_gid;
}
}
fclose(etc_group);
/* gid */
if (desired) {
g->gr_gid = desired;
} else {
g->gr_gid++;
}
/* return 1; */
return 0;
}
/* append a new user to the passwd file */
static int addgroup(const char *filename, char *group, gid_t gid)
{
FILE *etc_group;
FILE *etc_gshadow;
char *gshadow = SHADOW_FILE;
struct group gr;
/* group:passwd:gid:userlist */
const char *entryfmt = "%s:%s:%d:%s\n";
/* make sure gid and group haven't already been allocated */
gr.gr_gid = gid;
gr.gr_name = group;
if (group_study(filename, &gr))
return 1;
/* add entry to group */
etc_group = fopen(filename, "a");
if (!etc_group) {
perror_msg_and_die("%s", filename);
}
fprintf(etc_group, entryfmt, group, default_passwd, gr.gr_gid, "");
fclose(etc_group);
/* add entry to gshadow if necessary */
if (access(gshadow, F_OK|W_OK) == 0) {
etc_gshadow = xfopen(gshadow, "a");
fprintf(etc_gshadow, "%s:!::\n", group);
fclose(etc_gshadow);
}
/* return 1; */
return 0;
}
/*
* addgroup will take a login_name as its first parameter.
*
* gid
*
* can be customized via command-line parameters.
* ________________________________________________________________________ */
int addgroup_main(int argc, char **argv)
{
int i;
char opt;
char *group;
gid_t gid = 0;
/* get remaining args */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
show_usage();
break;
case 'g':
gid = strtol(argv[++i], NULL, 10);
break;
default:
error_msg_and_die("addgroup: invalid option -- %c\n", opt);
}
} else {
break;
}
}
if (i >= argc) {
show_usage();
} else {
group = argv[i];
}
if (geteuid() != 0) {
error_msg_and_die
("addgroup: Only root may add a group to the system.\n");
}
/* werk */
return addgroup(GROUP_FILE, group, gid);
}
/* $Id: addgroup.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */

366
adduser.c
View File

@ -1,366 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* adduser - add users to /etc/passwd and /etc/shadow
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* 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 <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <shadow.h>
#include <time.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "busybox.h"
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
#define PASSWD_FILE "/etc/passwd"
#define SHADOW_FILE "/etc/gshadow"
#if 0
# define PASSWD_FILE "passwd"
# define SHADOW_FILE "shadow"
#endif
/* structs __________________________ */
typedef struct {
uid_t u;
gid_t g;
} Id;
/* data _____________________________ */
/* defaults : should this be in an external file? */
static char *default_passwd = "x";
static char *default_gecos = "Embedix User,,,";
static char *default_home_prefix = "/home";
static char *default_shell = "/bin/sh";
/* shadow in use? */
static int shadow_enabled = 0;
/* I was doing this all over the place */
static FILE *fopen_wrapper(const char *filename, const char *mode)
{
FILE *f;
f = fopen(filename, mode);
if (f == NULL) {
fprintf(stderr, "adduser: %s: %s\n", filename, strerror(errno));
}
return f;
}
/* remix */
/* EDR recoded such that the uid may be passed in *p */
static int passwd_study(const char *filename, struct passwd *p)
{
struct passwd *pw;
FILE *passwd;
const int min = 500;
const int max = 65000;
passwd = fopen_wrapper(filename, "r");
if (!passwd)
return 4;
/* EDR if uid is out of bounds, set to min */
if ((p->pw_uid > max) || (p->pw_uid < min))
p->pw_uid = min;
/* stuff to do:
* make sure login isn't taken;
* find free uid and gid;
*/
while ((pw = fgetpwent(passwd))) {
if (strcmp(pw->pw_name, p->pw_name) == 0) {
/* return 0; */
return 1;
}
if ((pw->pw_uid >= p->pw_uid) && (pw->pw_uid < max)
&& (pw->pw_uid >= min)) {
p->pw_uid = pw->pw_uid + 1;
}
}
/* EDR check for an already existing gid */
while (getgrgid(p->pw_uid) != NULL)
p->pw_uid++;
/* EDR also check for an existing group definition */
if (getgrnam(p->pw_name) != NULL)
return 3;
/* EDR bounds check */
if ((p->pw_uid > max) || (p->pw_uid < min))
return 2;
/* EDR create new gid always = uid */
p->pw_gid = p->pw_uid;
/* return 1; */
return 0;
}
static void addgroup_wrapper(const char *login, gid_t gid)
{
int argc = 4;
char *argv[] = { "addgroup", "-g", NULL, NULL };
char group_id[8];
char group_name[32];
strncpy(group_name, login, 32);
argv[3] = group_name;
sprintf(group_id, "%d", gid);
argv[2] = group_id;
addgroup_main(argc, argv);
}
static void passwd_wrapper(const char *login)
{
char *prog = "passwd";
execlp(prog, prog, login, NULL);
error_msg_and_die("Failed to execute 'passwd', you must set the password for '%s' manually\n", login);
}
/*
* pwd_to_spwd - create entries for new spwd structure
*
* pwd_to_spwd() creates a new (struct spwd) containing the
* information in the pointed-to (struct passwd).
*/
#define DAY (24L*3600L)
#define WEEK (7*DAY)
#define SCALE DAY
static struct spwd *pwd_to_spwd(const struct passwd *pw)
{
static struct spwd sp;
/*
* Nice, easy parts first. The name and passwd map directly
* from the old password structure to the new one.
*/
sp.sp_namp = pw->pw_name;
sp.sp_pwdp = pw->pw_passwd;
/*
* Defaults used if there is no pw_age information.
*/
sp.sp_min = 0;
sp.sp_max = (10000L * DAY) / SCALE;
sp.sp_lstchg = time((time_t *) 0) / SCALE;
/*
* These fields have no corresponding information in the password
* file. They are set to uninitialized values.
*/
sp.sp_warn = -1;
sp.sp_expire = -1;
sp.sp_inact = -1;
sp.sp_flag = -1;
return &sp;
}
/* putpwent(3) remix */
static int adduser(const char *filename, struct passwd *p)
{
FILE *passwd;
int r;
FILE *shadow;
struct spwd *sp;
/* make sure everything is kosher and setup uid && gid */
passwd = fopen_wrapper(filename, "a");
if (passwd == NULL) {
/* return -1; */
return 1;
}
fseek(passwd, 0, SEEK_END);
/* if (passwd_study(filename, p) == 0) { */
r = passwd_study(filename, p);
if (r) {
if (r == 1)
error_msg("%s: login already in use\n", p->pw_name);
else if (r == 2)
error_msg("illegal uid or no uids left\n");
else if (r == 3)
error_msg("group name %s already in use\n", p->pw_name);
else
error_msg("generic error.\n");
/* return -1; */
return 1;
}
/* add to passwd */
if (putpwent(p, passwd) == -1) {
/* return -1; */
return 1;
}
fclose(passwd);
/* add to shadow if necessary */
if (shadow_enabled) {
shadow = fopen_wrapper(SHADOW_FILE, "a");
if (shadow == NULL) {
/* return -1; */
return 1;
}
fseek(shadow, 0, SEEK_END);
sp = pwd_to_spwd(p);
sp->sp_max = 99999; /* debianish */
sp->sp_warn = 7;
fprintf(shadow, "%s:!:%ld:%ld:%ld:%ld:::\n",
sp->sp_namp, sp->sp_lstchg, sp->sp_min, sp->sp_max,
sp->sp_warn);
fclose(shadow);
}
/* add to group */
/* addgroup should be responsible for dealing w/ gshadow */
addgroup_wrapper(p->pw_name, p->pw_gid);
/* Clear the umask for this process so it doesn't
* * screw up the permissions on the mkdir and chown. */
umask(0);
/* mkdir */
if (mkdir(p->pw_dir, 0755)) {
perror_msg("%s", p->pw_dir);
}
/* Set the owner and group so it is owned by the new user. */
if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) {
perror_msg("%s", p->pw_dir);
}
/* Now fix up the permissions to 2755. Can't do it before now
* since chown will clear the setgid bit */
if (chmod(p->pw_dir, 02755)) {
perror_msg("%s", p->pw_dir);
}
/* interactively set passwd */
passwd_wrapper(p->pw_name);
return 0;
}
/* return current uid (root is always uid == 0, right?) */
static uid_t i_am_not_root()
{
return geteuid();
}
/*
* adduser will take a login_name as its first parameter.
*
* home
* shell
* gecos
*
* can be customized via command-line parameters.
* ________________________________________________________________________ */
int adduser_main(int argc, char **argv)
{
int i;
char opt;
char *login;
char *gecos;
char *home = NULL;
char *shell;
char path[MAXPATHLEN];
struct passwd pw;
/* init */
if (argc < 2) {
show_usage();
}
gecos = default_gecos;
shell = default_shell;
/* get args */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
home = argv[++i];
break;
case 'g':
gecos = argv[++i];
break;
case 's':
shell = argv[++i];
break;
default:
error_msg("invalid option -- %c\n", opt);
break;
}
} else {
break;
}
}
/* got root? */
if (i_am_not_root()) {
error_msg_and_die( "Only root may add a user or group to the system.\n");
}
/* get login */
if (i >= argc) {
error_msg_and_die( "adduser: no user specified\n");
}
login = argv[i];
/* create string for $HOME if not specified already */
if (!home) {
snprintf(path, MAXPATHLEN, "%s/%s", default_home_prefix, login);
path[MAXPATHLEN - 1] = 0;
home = path;
}
/* is /etc/shadow in use? */
shadow_enabled = (0 == access(SHADOW_FILE, F_OK));
/* create a passwd struct */
pw.pw_name = login;
pw.pw_passwd = default_passwd;
pw.pw_uid = 0;
pw.pw_gid = 0;
pw.pw_gecos = gecos;
pw.pw_dir = home;
pw.pw_shell = shell;
/* grand finale */
i = adduser(PASSWD_FILE, &pw);
return (i);
}
/* $Id: adduser.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */

View File

@ -1,176 +0,0 @@
/*
* adjtimex.c - read, and possibly modify, the Linux kernel `timex' variables.
*
* Originally written: October 1997
* Last hack: March 2001
* Copyright 1997, 2000, 2001 Larry Doolittle <LRDoolittle@lbl.gov>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (Version 2,
* June 1991) as published by the Free Software Foundation. At the
* time of writing, that license was published by the FSF with the URL
* http://www.gnu.org/copyleft/gpl.html, and is incorporated herein by
* reference.
*
* 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.
*
* This adjtimex(1) is very similar in intent to adjtimex(8) by Steven
* Dick <ssd@nevets.oau.org> and Jim Van Zandt <jrv@vanzandt.mv.com>
* (see http://metalab.unc.edu/pub/Linux/system/admin/time/adjtimex*).
* That version predates this one, and is _much_ bigger and more
* featureful. My independently written version was very similar to
* Steven's from the start, because they both follow the kernel timex
* structure. I further tweaked this version to be equivalent to Steven's
* where possible, but I don't like getopt_long, so the actual usage
* syntax is incompatible.
*
* Amazingly enough, my Red Hat 5.2 sys/timex (and sub-includes)
* don't actually give a prototype for adjtimex(2), so building
* this code (with -Wall) gives a warning. Later versions of
* glibc fix this issue.
*
* This program is too simple for a Makefile, just build with:
* gcc -Wall -O adjtimex.c -o adjtimex
*
* busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
* It will autosense if it is built in a busybox environment, based
* on the BB_VER preprocessor macro.
*/
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#if __GNU_LIBRARY__ < 5
#include <sys/timex.h>
extern int adjtimex(struct timex *buf);
#else
#include <sys/timex.h>
#endif
#ifdef BB_VER
#include "busybox.h"
#endif
static struct {int bit; char *name;} statlist[] = {
{ STA_PLL, "PLL" },
{ STA_PPSFREQ, "PPSFREQ" },
{ STA_PPSTIME, "PPSTIME" },
{ STA_FLL, "FFL" },
{ STA_INS, "INS" },
{ STA_DEL, "DEL" },
{ STA_UNSYNC, "UNSYNC" },
{ STA_FREQHOLD, "FREQHOLD" },
{ STA_PPSSIGNAL, "PPSSIGNAL" },
{ STA_PPSJITTER, "PPSJITTER" },
{ STA_PPSWANDER, "PPSWANDER" },
{ STA_PPSERROR, "PPSERROR" },
{ STA_CLOCKERR, "CLOCKERR" },
{ 0, NULL } };
static char *ret_code_descript[] = {
"clock synchronized",
"insert leap second",
"delete leap second",
"leap second in progress",
"leap second has occurred",
"clock not synchronized" };
#ifdef BB_VER
#define main adjtimex_main
#else
void usage(char *prog)
{
fprintf(stderr,
"Usage: %s [ -q ] [ -o offset ] [ -f frequency ] [ -p timeconstant ] [ -t tick ]\n",
prog);
}
#define show_usage() usage(argv[0])
#endif
int main(int argc, char ** argv)
{
struct timex txc;
int quiet=0;
int c, i, ret, sep;
char *descript;
txc.modes=0;
for (;;) {
c = getopt( argc, argv, "qo:f:p:t:");
if (c == EOF) break;
switch (c) {
case 'q':
quiet=1;
break;
case 'o':
txc.offset = atoi(optarg);
txc.modes |= ADJ_OFFSET_SINGLESHOT;
break;
case 'f':
txc.freq = atoi(optarg);
txc.modes |= ADJ_FREQUENCY;
break;
case 'p':
txc.constant = atoi(optarg);
txc.modes |= ADJ_TIMECONST;
break;
case 't':
txc.tick = atoi(optarg);
txc.modes |= ADJ_TICK;
break;
default:
show_usage();
exit(1);
}
}
if (argc != optind) { /* no valid non-option parameters */
show_usage();
exit(1);
}
ret = adjtimex(&txc);
if (ret < 0) perror("adjtimex");
if (!quiet && ret>=0) {
printf(
" mode: %d\n"
"-o offset: %ld\n"
"-f frequency: %ld\n"
" maxerror: %ld\n"
" esterror: %ld\n"
" status: %d ( ",
txc.modes, txc.offset, txc.freq, txc.maxerror,
txc.esterror, txc.status);
/* representative output of next code fragment:
"PLL | PPSTIME" */
sep=0;
for (i=0; statlist[i].name; i++) {
if (txc.status & statlist[i].bit) {
if (sep) fputs(" | ",stdout);
fputs(statlist[i].name,stdout);
sep=1;
}
}
descript = "error";
if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
printf(" )\n"
"-p timeconstant: %ld\n"
" precision: %ld\n"
" tolerance: %ld\n"
"-t tick: %ld\n"
" time.tv_sec: %ld\n"
" time.tv_usec: %ld\n"
" return value: %d (%s)\n",
txc.constant,
txc.precision, txc.tolerance, txc.tick,
(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
}
return (ret<0);
}

116
applets.c
View File

@ -1,116 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) tons of folks. Tracking down who wrote what
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* 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
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#include "applets.h"
struct BB_applet *applet_using;
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
extern void show_usage(void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
for (i = applet_using - applets; i > 0; ) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if(*usage_string == 0)
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string,
full_version, applet_using->name, usage_string);
exit(EXIT_FAILURE);
}
static int applet_name_compare(const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp(name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
static int recurse_level = 0;
extern int been_there_done_that; /* From busybox.c */
recurse_level++;
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name(name)) != NULL) {
applet_name = applet_using->name;
if (argv[1] && strcmp(argv[1], "--help") == 0) {
if (strcmp(applet_using->name, "busybox")==0) {
if(argv[2])
applet_using = find_applet_by_name(argv[2]);
else
applet_using = NULL;
}
if(applet_using)
show_usage();
been_there_done_that=1;
busybox_main(0, NULL);
}
exit((*(applet_using->main)) (argc, argv));
}
/* Just in case they have renamed busybox - Check argv[1] */
if (recurse_level == 1) {
run_applet_by_name("busybox", argc, argv);
}
recurse_level--;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

500
applets.h
View File

@ -1,500 +0,0 @@
/*
* 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.
*/
#undef APPLET
#undef APPLET_ODDNAME
#undef APPLET_NOUSAGE
#if defined(PROTOTYPES)
#define APPLET(a,b,c) extern int b(int argc, char **argv);
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
extern const char usage_messages[];
#elif defined(MAKE_USAGE)
#ifdef BB_FEATURE_VERBOSE_USAGE
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
#else
#define APPLET(a,b,c) a##_trivial_usage "\0"
#define APPLET_NOUSAGE(a,b,c) "\0"
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
#endif
#elif defined(MAKE_LINKS)
# define APPLET(a,b,c) LINK c a
# define APPLET_NOUSAGE(a,b,c) LINK c a
# define APPLET_ODDNAME(a,b,c,d) LINK c a
#else
const struct BB_applet applets[] = {
#define APPLET(a,b,c) {#a,b,c},
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
#endif
#ifdef BB_TEST
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ADDGROUP
APPLET(addgroup, addgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADDUSER
APPLET(adduser, adduser_main, _BB_DIR_BIN)
#endif
#ifdef BB_ADJTIMEX
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
#endif
#ifdef BB_AR
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_ASH
APPLET_NOUSAGE("ash", ash_main, _BB_DIR_BIN)
#endif
#ifdef BB_BASENAME
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_BUNZIP2
APPLET(bunzip2, bunzip2_main, _BB_DIR_USR_BIN)
#endif
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
#ifdef BB_CAT
APPLET(cat, cat_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHGRP
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHMOD
APPLET(chmod, chmod_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHOWN
APPLET(chown, chown_main, _BB_DIR_BIN)
#endif
#ifdef BB_CHROOT
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_CHVT
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CLEAR
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CMP
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_CP
APPLET(cp, cp_main, _BB_DIR_BIN)
#endif
#ifdef BB_CPIO
APPLET(cpio, cpio_main, _BB_DIR_BIN)
#endif
#ifdef BB_CUT
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DATE
APPLET(date, date_main, _BB_DIR_BIN)
#endif
#ifdef BB_DC
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DD
APPLET(dd, dd_main, _BB_DIR_BIN)
#endif
#ifdef BB_DEALLOCVT
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DELGROUP
APPLET(delgroup, delgroup_main, _BB_DIR_BIN)
#endif
#ifdef BB_DELUSER
APPLET(deluser, deluser_main, _BB_DIR_BIN)
#endif
#ifdef BB_DF
APPLET(df, df_main, _BB_DIR_BIN)
#endif
#ifdef BB_DIRNAME
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DMESG
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
#endif
#ifdef BB_DOS2UNIX
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DPKG_DEB
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
#endif
#ifdef BB_DU
APPLET(du, du_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_DUMPKMAP
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
#endif
#ifdef BB_DUTMP
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_ECHO
APPLET(echo, echo_main, _BB_DIR_BIN)
#endif
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_ENV
APPLET(env, env_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_EXPR
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(false, false_main, _BB_DIR_BIN)
#endif
#ifdef BB_FBSET
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
#endif
#ifdef BB_FDFLUSH
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
#endif
#ifdef BB_FIND
APPLET(find, find_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREE
APPLET(free, free_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FREERAMDISK
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
#endif
#ifdef BB_FSCK_MINIX
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
#endif
#ifdef BB_GETOPT
APPLET(getopt, getopt_main, _BB_DIR_BIN)
#endif
#ifdef BB_GETTY
APPLET(getty, getty_main, _BB_DIR_SBIN)
#endif
#ifdef BB_GREP
APPLET(grep, grep_main, _BB_DIR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_GZIP
APPLET(gzip, gzip_main, _BB_DIR_BIN)
#endif
#ifdef BB_HALT
APPLET(halt, halt_main, _BB_DIR_SBIN)
#endif
#ifdef BB_HEAD
APPLET(head, head_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTID
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_HOSTNAME
APPLET(hostname, hostname_main, _BB_DIR_BIN)
#endif
#ifdef BB_HUSH
APPLET_NOUSAGE("hush", hush_main, _BB_DIR_BIN)
#endif
#ifdef BB_ID
APPLET(id, id_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_IFCONFIG
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INIT
APPLET(init, init_main, _BB_DIR_SBIN)
#endif
#ifdef BB_INSMOD
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_KILL
APPLET(kill, kill_main, _BB_DIR_BIN)
#endif
#ifdef BB_KILLALL
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_KLOGD
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LASH
APPLET(lash, lash_main, _BB_DIR_BIN)
#endif
#ifdef BB_LENGTH
APPLET(length, length_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_FEATURE_LINUXRC
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
#endif
#ifdef BB_LN
APPLET(ln, ln_main, _BB_DIR_BIN)
#endif
#ifdef BB_LOADACM
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADFONT
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOADKMAP
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LOGGER
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGNAME
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_LOGREAD
APPLET(logread, logread_main, _BB_DIR_SBIN)
#endif
#ifdef BB_LS
APPLET(ls, ls_main, _BB_DIR_BIN)
#endif
#ifdef BB_LSMOD
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MAKEDEVS
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MD5SUM
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKDIR
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKFIFO
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_MKFS_MINIX
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
#endif
#ifdef BB_MKNOD
APPLET(mknod, mknod_main, _BB_DIR_BIN)
#endif
#ifdef BB_MKSWAP
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MKTEMP
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
#endif
#ifdef BB_MODPROBE
APPLET(modprobe, modprobe_main, _BB_DIR_SBIN)
#endif
#ifdef BB_MORE
APPLET(more, more_main, _BB_DIR_BIN)
#endif
#ifdef BB_MOUNT
APPLET(mount, mount_main, _BB_DIR_BIN)
#endif
#ifdef BB_MSH
APPLET_NOUSAGE("msh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_MT
APPLET(mt, mt_main, _BB_DIR_BIN)
#endif
#ifdef BB_MV
APPLET(mv, mv_main, _BB_DIR_BIN)
#endif
#ifdef BB_NC
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_NSLOOKUP
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PIDOF
APPLET(pidof, pidof_main, _BB_DIR_BIN)
#endif
#ifdef BB_PING
APPLET(ping, ping_main, _BB_DIR_BIN)
#endif
#ifdef BB_PIVOT_ROOT
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
#endif
#ifdef BB_POWEROFF
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
#endif
#ifdef BB_PRINTF
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_PS
APPLET(ps, ps_main, _BB_DIR_BIN)
#endif
#ifdef BB_PWD
APPLET(pwd, pwd_main, _BB_DIR_BIN)
#endif
#ifdef BB_RDATE
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_READLINK
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_REBOOT
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RENICE
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RESET
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_RM
APPLET(rm, rm_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMDIR
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
#endif
#ifdef BB_RMMOD
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
#endif
#ifdef BB_ROUTE
APPLET(route, route_main, _BB_DIR_SBIN)
#endif
#ifdef BB_RPM2CPIO
APPLET(rpm2cpio, rpm2cpio_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_SED
APPLET(sed, sed_main, _BB_DIR_BIN)
#endif
#ifdef BB_SETKEYCODES
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
#endif
#if defined(BB_FEATURE_SH_IS_ASH) && defined(BB_ASH)
APPLET_NOUSAGE("sh", ash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_HUSH) && defined(BB_HUSH)
APPLET_NOUSAGE("sh", hush_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_LASH) && defined(BB_LASH)
APPLET_NOUSAGE("sh", lash_main, _BB_DIR_BIN)
#elif defined(BB_FEATURE_SH_IS_MSH) && defined(BB_MSH)
APPLET_NOUSAGE("sh", msh_main, _BB_DIR_BIN)
#endif
#ifdef BB_SLEEP
APPLET(sleep, sleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_SORT
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_START_STOP_DAEMON
APPLET_ODDNAME("start-stop-daemon", start_stop_daemon_main, _BB_DIR_SBIN, start_stop_daemon)
#endif
#ifdef BB_STTY
APPLET(stty, stty_main, _BB_DIR_BIN)
#endif
#ifdef BB_SWAPONOFF
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SWAPONOFF
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
#endif
#ifdef BB_SYNC
APPLET(sync, sync_main, _BB_DIR_BIN)
#endif
#ifdef BB_SYSLOGD
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
#endif
#ifdef BB_TAIL
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TAR
APPLET(tar, tar_main, _BB_DIR_BIN)
#endif
#ifdef BB_TEE
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TELNET
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TEST
APPLET(test, test_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TFTP
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TOUCH
APPLET(touch, touch_main, _BB_DIR_BIN)
#endif
#ifdef BB_TR
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRACEROUTE
APPLET(traceroute, traceroute_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_TRUE_FALSE
APPLET(true, true_main, _BB_DIR_BIN)
#endif
#ifdef BB_TTY
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UMOUNT
APPLET(umount, umount_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNAME
APPLET(uname, uname_main, _BB_DIR_BIN)
#endif
#ifdef BB_UNIQ
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UNIX2DOS
APPLET(unix2dos, dos2unix_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UPDATE
APPLET(update, update_main, _BB_DIR_SBIN)
#endif
#ifdef BB_UPTIME
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_USLEEP
APPLET(usleep, usleep_main, _BB_DIR_BIN)
#endif
#ifdef BB_UUDECODE
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_UUENCODE
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_VI
APPLET(vi, vi_main, _BB_DIR_BIN)
#endif
#ifdef BB_WATCHDOG
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
#endif
#ifdef BB_WC
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WGET
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHICH
APPLET(which, which_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_WHOAMI
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_XARGS
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_YES
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
#endif
#ifdef BB_GUNZIP
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
#endif
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
{ 0,NULL,0 }
};
#endif

View File

@ -5,14 +5,14 @@
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#ifdef BB_LOCALE_SUPPORT
#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
#endif
int been_there_done_that = 0; /* Also used in applets.c */
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
#ifdef CONFIG_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
@ -63,7 +63,7 @@ static void install_links(const char *busybox, int use_symbolic_links)
}
}
#endif /* BB_FEATURE_INSTALLER */
#endif /* CONFIG_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
@ -79,8 +79,8 @@ int main(int argc, char **argv)
applet_name = s;
}
#ifdef BB_LOCALE_SUPPORT
#ifdef BB_INIT
#ifdef CONFIG_LOCALE_SUPPORT
#ifdef CONFIG_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
@ -97,7 +97,7 @@ int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
#ifdef CONFIG_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
@ -125,7 +125,7 @@ int busybox_main(int argc, char **argv)
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
#endif /* CONFIG_FEATURE_INSTALLER */
argc--;

View File

@ -5,11 +5,11 @@ export LC_CTYPE=POSIX
RAW=` \
$CC -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
sed -n -e '/^.*CONFIG_FEATURE.*$/d;s/^#define.*\<CONFIG_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
if [ -d "$CONFIG_SRC_DIR" ]; then cd $CONFIG_SRC_DIR; fi
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '

View File

@ -247,7 +247,7 @@
#define deluser_full_usage \
"Deletes user USER from the system"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
#define USAGE_HUMAN_READABLE(a) a
#define USAGE_NOT_HUMAN_READABLE(a)
#else
@ -464,17 +464,17 @@
#define fdflush_full_usage \
"Forces floppy disk drive to detect disk change"
#ifdef BB_FEATURE_FIND_TYPE
#ifdef CONFIG_FEATURE_FIND_TYPE
#define USAGE_FIND_TYPE(a) a
#else
#define USAGE_FIND_TYPE(a)
#endif
#ifdef BB_FEATURE_FIND_PERM
#ifdef CONFIG_FEATURE_FIND_PERM
#define USAGE_FIND_PERM(a) a
#else
#define USAGE_FIND_PERM(a)
#endif
#ifdef BB_FEATURE_FIND_MTIME
#ifdef CONFIG_FEATURE_FIND_MTIME
#define USAGE_FIND_MTIME(a) a
#else
#define USAGE_FIND_MTIME(a)
@ -678,22 +678,22 @@
"$ id\n" \
"uid=1000(andersen) gid=1000(andersen)\n"
#ifdef BB_FEATURE_IFCONFIG_SLIP
#ifdef CONFIG_FEATURE_IFCONFIG_SLIP
#define USAGE_SIOCSKEEPALIVE(a) a
#else
#define USAGE_SIOCSKEEPALIVE(a)
#endif
#ifdef BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
#ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
#define USAGE_IFCONFIG_MII(a) a
#else
#define USAGE_IFCONFIG_MII(a)
#endif
#ifdef BB_FEATURE_IFCONFIG_HW
#ifdef CONFIG_FEATURE_IFCONFIG_HW
#define USAGE_IFCONFIG_HW(a) a
#else
#define USAGE_IFCONFIG_HW(a)
#endif
#ifdef BB_FEATURE_IFCONFIG_STATUS
#ifdef CONFIG_FEATURE_IFCONFIG_STATUS
#define USAGE_IFCONFIG_OPT_A(a) a
#else
#define USAGE_IFCONFIG_OPT_A(a)
@ -950,32 +950,32 @@
#define logread_full_usage \
"Shows the messages from syslogd (using circular buffer)."
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
#define USAGE_LS_TIMESTAMPS(a) a
#else
#define USAGE_LS_TIMESTAMPS(a)
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
#define USAGE_LS_FILETYPES(a) a
#else
#define USAGE_LS_FILETYPES(a)
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
#define USAGE_LS_FOLLOWLINKS(a) a
#else
#define USAGE_LS_FOLLOWLINKS(a)
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
#define USAGE_LS_RECURSIVE(a) a
#else
#define USAGE_LS_RECURSIVE(a)
#endif
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
#define USAGE_LS_SORTFILES(a) a
#else
#define USAGE_LS_SORTFILES(a)
#endif
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
#define USAGE_AUTOWIDTH(a) a
#else
#define USAGE_AUTOWIDTH(a)
@ -1145,12 +1145,12 @@
#define more_example_usage \
"$ dmesg | more\n"
#ifdef BB_FEATURE_MOUNT_LOOP
#ifdef CONFIG_FEATURE_MOUNT_LOOP
#define USAGE_MOUNT_LOOP(a) a
#else
#define USAGE_MOUNT_LOOP(a)
#endif
#ifdef BB_FEATURE_MTAB_SUPPORT
#ifdef CONFIG_FEATURE_MTAB_SUPPORT
#define USAGE_MTAB(a) a
#else
#define USAGE_MTAB(a)
@ -1245,7 +1245,7 @@
"$ pidof init\n" \
"1\n"
#ifndef BB_FEATURE_FANCY_PING
#ifndef CONFIG_FEATURE_FANCY_PING
#define ping_trivial_usage "host"
#define ping_full_usage "Send ICMP ECHO_REQUEST packets to network hosts"
#else
@ -1431,12 +1431,12 @@
"[2 second delay results]\n"
#ifdef BB_FEATURE_SORT_UNIQUE
#ifdef CONFIG_FEATURE_SORT_UNIQUE
#define USAGE_SORT_UNIQUE(a) a
#else
#define USAGE_SORT_UNIQUE(a)
#endif
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
#define USAGE_SORT_REVERSE(a) a
#else
#define USAGE_SORT_REVERSE(a)
@ -1503,7 +1503,7 @@
"Write all buffered filesystem blocks to disk."
#ifdef BB_FEATURE_REMOTE_LOG
#ifdef CONFIG_FEATURE_REMOTE_LOG
#define USAGE_REMOTE_LOG(a) a
#else
#define USAGE_REMOTE_LOG(a)
@ -1525,7 +1525,7 @@
"$ syslogd -R 192.168.1.1:601\n"
#ifndef BB_FEATURE_FANCY_TAIL
#ifndef CONFIG_FEATURE_FANCY_TAIL
#define USAGE_UNSIMPLE_TAIL(a)
#else
#define USAGE_UNSIMPLE_TAIL(a) a
@ -1550,12 +1550,12 @@
"$ tail -n 1 /etc/resolv.conf\n" \
"nameserver 10.0.0.1\n"
#ifdef BB_FEATURE_TAR_CREATE
#ifdef CONFIG_FEATURE_TAR_CREATE
#define USAGE_TAR_CREATE(a) a
#else
#define USAGE_TAR_CREATE(a)
#endif
#ifdef BB_FEATURE_TAR_EXCLUDE
#ifdef CONFIG_FEATURE_TAR_EXCLUDE
#define USAGE_TAR_EXCLUDE(a) a
#else
#define USAGE_TAR_EXCLUDE(a)
@ -1619,17 +1619,17 @@
"$ echo $?\n" \
"1\n"
#ifdef BB_FEATURE_TFTP_GET
#ifdef CONFIG_FEATURE_TFTP_GET
#define USAGE_TFTP_GET(a) a
#else
#define USAGE_TFTP_GET(a)
#endif
#ifdef BB_FEATURE_TFTP_PUT
#ifdef CONFIG_FEATURE_TFTP_PUT
#define USAGE_TFTP_PUT(a) a
#else
#define USAGE_TFTP_PUT(a)
#endif
#ifdef BB_FEATURE_TFTP_BLOCKSIZE
#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
#define USAGE_TFTP_BS(a) a
#else
#define USAGE_TFTP_BS(a)
@ -1719,7 +1719,7 @@
"$ tty\n" \
"/dev/tty2\n"
#ifdef BB_FEATURE_MOUNT_FORCE
#ifdef CONFIG_FEATURE_MOUNT_FORCE
#define USAGE_MOUNT_FORCE(a) a
#else
#define USAGE_MOUNT_FORCE(a)

89
ar.c
View File

@ -1,89 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* 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 <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
extern int ar_main(int argc, char **argv)
{
FILE *src_stream = NULL;
char **extract_names = NULL;
char ar_magic[8];
int extract_function = extract_unconditional;
int opt;
int num_of_entries = 0;
extern off_t archive_offset;
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
extract_function |= extract_preserve_date;
break;
case 'v':
extract_function |= extract_verbose_list;
break;
case 't':
extract_function |= extract_list;
break;
case 'p':
extract_function |= extract_to_stdout;
break;
case 'x':
extract_function |= extract_all_to_fs;
break;
default:
show_usage();
}
}
/* check the src filename was specified */
if (optind == argc) {
show_usage();
}
src_stream = xfopen(argv[optind++], "r");
/* check ar magic */
fread(ar_magic, 1, 8, src_stream);
archive_offset = 8;
if (strncmp(ar_magic,"!<arch>",7) != 0) {
error_msg_and_die("invalid magic");
}
/* Create a list of files to extract */
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_ar, extract_function, "./", extract_names, NULL);
return EXIT_SUCCESS;
}

43
archival/Makefile Normal file
View File

@ -0,0 +1,43 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
# 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
#
TOPDIR :=..
L_TARGET := archival.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_AR) += ar.o
obj-$(CONFIG_BUNZIP2) += bunzip2.o
obj-$(CONFIG_CPIO) += cpio.o
obj-$(CONFIG_DPKG) += dpkg.o
obj-$(CONFIG_DPKG_DEB) += dpkg_deb.o
obj-$(CONFIG_GUNZIP) += gunzip.o
obj-$(CONFIG_GZIP) += gzip.o
obj-$(CONFIG_RPMUNPACK) += rpm2cpio.o
obj-$(CONFIG_TAR) += tar.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
clean:
rm -f $(L_TARGET) *.o core

19
archival/config.in Normal file
View File

@ -0,0 +1,19 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu_option next_comment
comment 'Archival Utilities'
bool 'ar' CONFIG_AR
bool 'bunzip2' CONFIG_BUNZIP2
bool 'cpio' CONFIG_CPIO
bool 'dpkg' CONFIG_DPKG
bool 'dpkg_deb' CONFIG_DPKG_DEB
bool 'gunzip' CONFIG_GUNZIP
bool 'gzip' CONFIG_GZIP
bool 'rpm2cpio' CONFIG_RPM2CPIO
bool 'tar' CONFIG_TAR
endmenu

View File

@ -1231,7 +1231,7 @@ int gzip_main(int argc, char **argv)
break;
case 'q':
break;
#ifdef BB_GUNZIP
#ifdef CONFIG_GUNZIP
case 'd':
optind = 1;
return gunzip_main(argc, argv);

View File

@ -9,8 +9,8 @@
* ground up. It still has remnents of the old code lying about, but it is
* very different now (i.e., cleaner, less global variables, etc.)
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* Based in part in the tar implementation in sash
* Copyright (c) 1999 by David I. Bell
@ -49,7 +49,7 @@
#include <errno.h>
#include "busybox.h"
#ifdef BB_FEATURE_TAR_CREATE
#ifdef CONFIG_FEATURE_TAR_CREATE
/* Tar file constants */
# define TAR_MAGIC "ustar" /* ustar and a null */
@ -395,11 +395,11 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
if (header_name[0] == '\0')
return TRUE;
# if defined BB_FEATURE_TAR_EXCLUDE
# if defined CONFIG_FEATURE_TAR_EXCLUDE
if (exclude_file(tbInfo->excludeList, header_name)) {
return SKIP;
}
# endif //BB_FEATURE_TAR_EXCLUDE
# endif //CONFIG_FEATURE_TAR_EXCLUDE
if (writeTarHeader(tbInfo, header_name, fileName, statbuf)==FALSE) {
return( FALSE);
@ -527,7 +527,7 @@ void append_file_list_to_list(char *filename, char ***name_list, int *num_of_ent
fclose(src_stream);
}
#ifdef BB_FEATURE_TAR_EXCLUDE
#ifdef CONFIG_FEATURE_TAR_EXCLUDE
/*
* Create a list of names that are in the include list AND NOT in the exclude lists
*/
@ -626,7 +626,7 @@ int tar_main(int argc, char **argv)
/* These are optional */
/* Exclude or Include files listed in <filename>*/
#ifdef BB_FEATURE_TAR_EXCLUDE
#ifdef CONFIG_FEATURE_TAR_EXCLUDE
case 'X':
append_file_list_to_list(optarg, &exclude_list, &exclude_list_count);
break;
@ -660,7 +660,7 @@ int tar_main(int argc, char **argv)
}
extract_function |= extract_list;
break;
#ifdef BB_FEATURE_TAR_GZIP
#ifdef CONFIG_FEATURE_TAR_GZIP
case 'z':
untar_funct |= untar_unzip;
break;
@ -698,43 +698,43 @@ int tar_main(int argc, char **argv)
} else {
src_stream = stdin;
}
#ifdef BB_FEATURE_TAR_GZIP
#ifdef CONFIG_FEATURE_TAR_GZIP
/* Get a binary tree of all the tar file headers */
if (untar_funct & untar_unzip) {
uncompressed_stream = gz_open(src_stream, &gunzip_pid);
} else
#endif // BB_FEATURE_TAR_GZIP
#endif // CONFIG_FEATURE_TAR_GZIP
uncompressed_stream = src_stream;
/* extract or list archive */
unarchive(uncompressed_stream, stdout, &get_header_tar, extract_function, dst_prefix, include_list, exclude_list);
fclose(uncompressed_stream);
}
#ifdef BB_FEATURE_TAR_CREATE
#ifdef CONFIG_FEATURE_TAR_CREATE
/* create an archive */
else if (untar_funct & untar_create) {
int verboseFlag = FALSE;
#ifdef BB_FEATURE_TAR_GZIP
#ifdef CONFIG_FEATURE_TAR_GZIP
if (untar_funct && untar_unzip) {
error_msg_and_die("Creation of compressed tarfile not internally support by tar, pipe to busybox gunzip");
}
#endif // BB_FEATURE_TAR_GZIP
#endif // CONFIG_FEATURE_TAR_GZIP
if (extract_function & extract_verbose_list) {
verboseFlag = TRUE;
}
writeTarFile(src_filename, verboseFlag, &argv[argc - 1], include_list);
}
#endif // BB_FEATURE_TAR_CREATE
#endif // CONFIG_FEATURE_TAR_CREATE
/* Cleanups */
#ifdef BB_FEATURE_TAR_GZIP
#ifdef CONFIG_FEATURE_TAR_GZIP
if (untar_funct & untar_unzip) {
fclose(src_stream);
close(gz_fd);
gz_close(gunzip_pid);
}
#endif // BB_FEATURE_TAR_GZIP
#endif // CONFIG_FEATURE_TAR_GZIP
if (src_filename) {
free(src_filename);
}

12825
ash.c

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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
*
*/
/* getopt not needed */
#include <stdlib.h>
#include "busybox.h"
#include <string.h>
extern int basename_main(int argc, char **argv)
{
int m, n;
char *s;
if ((argc < 2) || (**(argv + 1) == '-')) {
show_usage();
}
argv++;
s = get_last_path_component(*argv);
if (argc>2) {
argv++;
n = strlen(*argv);
m = strlen(s);
if (m>n && strncmp(s+m-n, *argv, n)==0)
s[m-n] = '\0';
}
puts(s);
return EXIT_SUCCESS;
}

2340
bunzip2.c

File diff suppressed because it is too large Load Diff

181
busybox.c
View File

@ -1,181 +0,0 @@
/* vi: set sw=4 ts=4: */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#ifdef BB_LOCALE_SUPPORT
#include <locale.h>
#endif
int been_there_done_that = 0; /* Also used in applets.c */
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static char* install_dir[] = {
"/",
"/bin",
"/sbin",
"/usr/bin",
"/usr/sbin",
};
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static char *busybox_fullpath()
{
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, fpc);
if (rc!=0 && errno!=EEXIST) {
perror_msg("%s", fpc);
}
free(fpc);
}
}
#endif /* BB_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
for (s = applet_name; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_LOCALE_SUPPORT
#ifdef BB_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
setlocale(LC_ALL, "");
}
#endif
run_applet_by_name(applet_name, argc, argv);
error_msg_and_die("applet not found");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2) {
if ((strcmp(argv[2], "-s") == 0)) {
use_symbolic_links = 1;
}
}
/* link */
busybox = busybox_fullpath();
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
#endif /* BB_FEATURE_INSTALLER */
argc--;
/* If we've already been here once, exit now */
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", full_version);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > 60 && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
}
}
fprintf(stderr, "\n\n");
exit(0);
}
/* Flag that we've been here already */
been_there_done_that = 1;
/* Move the command line down a notch */
len = argv[argc] + strlen(argv[argc]) - argv[1];
memmove(argv[0], argv[1], len);
memset(argv[0] + len, 0, argv[1] - argv[0]);
/* Fix up the argv pointers */
len = argv[1] - argv[0];
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
for (i = 0; i < argc; i++)
argv[i] -= len;
return (main(argc, argv));
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

106
busybox.h
View File

@ -1,106 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Busybox main internal header file
*
*
* 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
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
*/
#ifndef _BB_INTERNAL_H_
#define _BB_INTERNAL_H_ 1
#include "Config.h"
#include <stdio.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#include <features.h>
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
_BB_DIR_SBIN,
_BB_DIR_USR_BIN,
_BB_DIR_USR_SBIN
};
struct BB_applet {
const char* name;
int (*main)(int argc, char** argv);
enum Location location;
};
/* From busybox.c */
extern const struct BB_applet applets[];
/* 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
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
#endif
/* Bit map related macros -- libc5 doens't provide these... sigh. */
#ifndef setbit
#define NBBY CHAR_BIT
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
#ifndef RB_POWER_OFF
/* Stop system and switch power off if possible. */
#define RB_POWER_OFF 0x4321fedc
#endif
/* Pull in the utility routines from libbb */
#include "libbb/libbb.h"
#endif /* _BB_INTERNAL_H_ */

View File

@ -1,24 +0,0 @@
#!/bin/sh
# Make busybox links list file.
# input $1: full path to Config.h
# input $2: full path to applets.h
# output (stdout): list of pathnames that should be linked to busybox
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
gsub("\"","",file)
if (file=="busybox") next
print tolower(dir) "/" file
}'

View File

@ -1,16 +0,0 @@
#!/bin/sh
export LC_ALL=POSIX
export LC_CTYPE=POSIX
RAW=` \
$CC -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
# By running $RAW through "ls", we avoid listing
# source files that don't exist.
ls $RAW 2>/dev/null | tr '\n' ' '

View File

@ -1,44 +0,0 @@
%define name busybox
%define epoch 0
%define version 0.61.pre
%define release %(date -I | sed -e 's/-/_/g')
%define serial 1
Name: %{name}
#Epoch: %{epoch}
Version: %{version}
Release: %{release}
Serial: %{serial}
Copyright: GPL
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
URL: http://busybox.lineo.com/
Source: ftp://oss.lineo.com/busybox/%{name}-%{version}.tar.gz
Buildroot: /var/tmp/%{name}-%{version}
Packager : Erik Andersen <andersen@lineo.com>
%Description
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
their full featured GNU cousins; however, the options that are provided behave
very much like their GNU counterparts.
%Prep
%setup -q -n %{name}-%{version}
%Build
make
%Install
rm -rf $RPM_BUILD_ROOT
make PREFIX=$RPM_BUILD_ROOT install
%Clean
rm -rf $RPM_BUILD_ROOT
%Files
%defattr(-,root,root)
/

53
cat.c
View File

@ -1,53 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int cat_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
if (argc == 1) {
print_file(stdin);
return status;
}
while (--argc > 0) {
if(!(strcmp(*++argv, "-"))) {
print_file(stdin);
} else if (print_file_by_name(*argv) == FALSE) {
status = EXIT_FAILURE;
}
}
return status;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

91
chgrp.c
View File

@ -1,91 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long gid;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chgrp_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "R")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
default:
show_usage();
}
}
if (argc > optind && argc > 2 && argv[optind]) {
/* Find the selected group */
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
if (argv[optind] == p)
gid = my_getgrnam(argv[optind]);
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

85
chmod.c
View File

@ -1,85 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "busybox.h"
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
error_msg_and_die("internal error");
if (chmod(fileName, statbuf->st_mode) == 0)
return (TRUE);
perror(fileName);
return (FALSE);
}
int chmod_main(int argc, char **argv)
{
int i;
int opt;
int recursiveFlag = FALSE;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "R")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
default:
show_usage();
}
}
if (argc > optind && argc > 2 && argv[optind]) {
/* Parse the specified mode */
mode_t mode;
if (parse_mode(argv[optind], &mode) == FALSE) {
error_msg_and_die( "unknown mode: %s", argv[optind]);
}
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
for (i = optind + 1; i < argc; i++) {
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
fileAction, argv[optind]) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

113
chown.c
View File

@ -1,113 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
/* Don't use lchown for libc5 or glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long uid;
static long gid;
static int (*chown_func)(const char *, __uid_t, __gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
return (TRUE);
}
perror(fileName);
return (FALSE);
}
int chown_main(int argc, char **argv)
{
int opt;
int recursiveFlag = FALSE,
noderefFlag = FALSE;
char *groupName=NULL;
char *p=NULL;
/* do normal option parsing */
while ((opt = getopt(argc, argv, "Rh")) > 0) {
switch (opt) {
case 'R':
recursiveFlag = TRUE;
break;
case 'h':
noderefFlag = TRUE;
break;
default:
show_usage();
}
}
if (noderefFlag) chown_func = lchown;
if (argc > optind && argc > 2 && argv[optind]) {
/* First, check if there is a group name here */
groupName = strchr(argv[optind], '.');
if (groupName == NULL)
groupName = strchr(argv[optind], ':');
if (groupName) {
*groupName++ = '\0';
gid = strtoul(groupName, &p, 10);
if (groupName == p)
gid = my_getgrnam(groupName);
} else {
gid = -1;
}
/* Now check for the username */
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
if (argv[optind] == p) {
uid = my_getpwnam(argv[optind]);
}
} else {
error_msg_and_die(too_few_args);
}
/* Ok, ready to do the deed now */
while (++optind < argc) {
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
fileAction, fileAction, NULL) == FALSE) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

View File

@ -1,75 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include "busybox.h"
int chroot_main(int argc, char **argv)
{
char *prog;
if ((argc < 2) || (**(argv + 1) == '-')) {
show_usage();
}
argc--;
argv++;
if (chroot(*argv) || (chdir("/"))) {
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
argv++;
if (argc >= 1) {
prog = *argv;
execvp(*argv, argv);
} else {
#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;
shell_main(1, shell_argv);
return EXIT_SUCCESS;
#else
prog = getenv("SHELL");
if (!prog)
prog = "/bin/sh";
execlp(prog, prog, NULL);
#endif
}
perror_msg_and_die("cannot execute %s", prog);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

43
chvt.c
View File

@ -1,43 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* chvt.c - aeb - 940227 - Change virtual terminal
*
* busyboxed by Erik Andersen
*/
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_ACTIVATE = 0x5606; /* make vt active */
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
int chvt_main(int argc, char **argv)
{
int fd, num;
if ((argc != 2) || (**(argv + 1) == '-'))
show_usage();
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num))
perror_msg_and_die("VT_ACTIVATE");
if (ioctl(fd, VT_WAITACTIVE, num))
perror_msg_and_die("VT_WAITACTIVE");
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

34
clear.c
View File

@ -1,34 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include "busybox.h"
extern int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
return EXIT_SUCCESS;
}

1521
cmdedit.c

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
#ifndef CMDEDIT_H
#define CMDEDIT_H
int cmdedit_read_input(char* promptStr, char* command);
#endif /* CMDEDIT_H */

80
cmp.c
View File

@ -1,80 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 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 <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <getopt.h>
#include "busybox.h"
int cmp_main(int argc, char **argv)
{
FILE *fp1 = NULL, *fp2 = stdin;
char *filename1, *filename2 = "-";
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
while ((c = getopt(argc, argv, "s")) != EOF) {
switch (c) {
case 's':
silent = TRUE;
break;
default:
show_usage();
}
}
filename1 = argv[optind];
switch (argc - optind) {
case 2:
fp2 = xfopen(filename2 = argv[optind + 1], "r");
case 1:
fp1 = xfopen(filename1, "r");
break;
default:
show_usage();
}
do {
c1 = fgetc(fp1);
c2 = fgetc(fp2);
if (c1 != c2) {
if (silent)
return EXIT_FAILURE;
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;
}

43
console-tools/Makefile Normal file
View File

@ -0,0 +1,43 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
# 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
#
TOPDIR :=..
L_TARGET := console-tools.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_CHVT) += chvt.o
obj-$(CONFIG_CLEAR) += clear.o
obj-$(CONFIG_DEALLOCVT) += deallocvt.o
obj-$(CONFIG_DUMPKMAP) += dumpkmap.o
obj-$(CONFIG_LOADACM) += loadacm.o
obj-$(CONFIG_LOADFONT) += loadfont.o
obj-$(CONFIG_LOADKMAP) += loadkmap.o
obj-$(CONFIG_RESET) += reset.o
obj-$(CONFIG_SETKEYCODES) += setkeycodes.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
clean:
rm -f $(L_TARGET) *.o core

View File

@ -2,9 +2,8 @@
/*
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

18
console-tools/config.in Normal file
View File

@ -0,0 +1,18 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu_option next_comment
comment 'Console Utilities'
bool 'chvt' CONFIG_CHVT
bool 'clear' CONFIG_CLEAR
bool 'deallocvt' CONFIG_DEALLOCVT
bool 'dumpkmap' CONFIG_DUMPKMAP
bool 'loadacm' CONFIG_LOADACM
bool 'loadfont' CONFIG_LOADFONT
bool 'loadkmap' CONFIG_LOADKMAP
bool 'reset' CONFIG_RESET
bool 'setkeycodes' CONFIG_SETKEYCODES
endmenu

View File

@ -2,10 +2,9 @@
/*
* Mini reset implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* and Kent Robotti <robotti@metconnect.com>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
*
* 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

View File

@ -2,8 +2,8 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -2,8 +2,8 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -1,10 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
* Mini chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -1,10 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
* Mini chmod implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -1,10 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Mini chown/chmod/chgrp implementation for busybox
* Mini chown implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -2,9 +2,8 @@
/*
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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
@ -48,7 +47,7 @@ int chroot_main(int argc, char **argv)
prog = *argv;
execvp(*argv, argv);
} else {
#if defined shell_main && defined BB_FEATURE_SH_STANDALONE_SHELL
#if defined shell_main && defined CONFIG_FEATURE_SH_STANDALONE_SHELL
char shell[] = "/bin/sh";
char *shell_argv[2] = { shell, NULL };
applet_name = shell;

View File

@ -2,9 +2,7 @@
/*
* Mini cmp implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 2000,2001 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

View File

@ -2,8 +2,8 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
@ -31,7 +31,7 @@
#include "busybox.h"
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long df_disp_hr = KILOBYTE;
#endif
@ -61,7 +61,7 @@ static int do_df(char *device, const char *mount_point)
if(device==NULL)
return FALSE;
}
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
@ -92,13 +92,13 @@ extern int df_main(int argc, char **argv)
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
while ((opt = getopt(argc, argv, "k"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"hm"
#endif
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h':
df_disp_hr = 0;
strcpy(disp_units_hdr, " Size");

View File

@ -2,8 +2,8 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -2,9 +2,8 @@
/*
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999,2000,2001 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
*
* 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
@ -33,7 +32,7 @@
#include "busybox.h"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long disp_hr = KILOBYTE;
#endif
@ -46,7 +45,7 @@ static Display *print;
static void print_normal(long size, char *filename)
{
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
@ -207,7 +206,7 @@ int du_main(int argc, char **argv)
/* parse argv[] */
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
@ -218,7 +217,7 @@ int du_main(int argc, char **argv)
case 'l':
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
#endif
@ -247,7 +246,7 @@ int du_main(int argc, char **argv)
return status;
}
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
/* $Id: du.c,v 1.51 2001/10/24 04:59:27 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"

View File

@ -2,9 +2,8 @@
/*
* Mini head implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
*
* 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

View File

@ -2,8 +2,8 @@
/*
* Mini ln implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -65,7 +65,7 @@ enum {
#include <sys/ioctl.h>
#include "busybox.h"
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
#include <time.h>
#endif
@ -108,7 +108,7 @@ STYLE_COLUMNS = 3 /* fill columns */
#define DISP_RECURSIVE (1<<4) /* show directory and everything below it */
#define DISP_ROWS (1<<5) /* print across rows */
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
/* how will the files be sorted */
static const int SORT_FORWARD = 0; /* sort in reverse order */
static const int SORT_REVERSE = 1; /* sort in reverse order */
@ -122,7 +122,7 @@ static const int SORT_EXT = 8; /* sort by file name extension */
static const int SORT_DIR = 9; /* sort by file or directory */
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
/* which of the three times will be used */
static const int TIME_MOD = 0;
static const int TIME_CHANGE = 1;
@ -142,7 +142,7 @@ static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
#endif
@ -164,19 +164,19 @@ static int list_single(struct dnode *);
static unsigned int disp_opts;
static unsigned int style_fmt;
static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
static unsigned int sort_opts;
static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
#endif
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
static unsigned short terminal_width = TERMINAL_WIDTH;
static unsigned short column_width = COLUMN_WIDTH;
static unsigned short tabstops = COLUMN_GAP;
@ -186,13 +186,13 @@ static unsigned short column_width = COLUMN_WIDTH;
static int status = EXIT_SUCCESS;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
static unsigned long ls_disp_hr = 0;
#endif
static int my_stat(struct dnode *cur)
{
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
perror_msg("%s", cur->fullname);
@ -222,7 +222,7 @@ static void newline(void)
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
static char append_char(mode_t mode)
{
if ( !(list_fmt & LIST_FILETYPE))
@ -304,7 +304,7 @@ static struct dnode **dnalloc(int num)
return(p);
}
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
static void dfree(struct dnode **dnp)
{
struct dnode *cur, *next;
@ -361,7 +361,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
}
/*----------------------------------------------------------------------*/
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
static int sortcmp(struct dnode *d1, struct dnode *d2)
{
int cmp, dif;
@ -426,13 +426,13 @@ static void shellsort(struct dnode **dn, int size)
static void showfiles(struct dnode **dn, int nfiles)
{
int i, ncols, nrows, row, nc;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
int len;
#endif
if(dn==NULL || nfiles < 1) return;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
/* find the longest file name- use that as the column width */
column_width= 0;
for (i=0; i<nfiles; i++) {
@ -488,7 +488,7 @@ static void showdirs(struct dnode **dn, int ndirs)
{
int i, nfiles;
struct dnode **subdnp;
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
int dndirs;
struct dnode **dnd;
#endif
@ -503,17 +503,17 @@ static void showdirs(struct dnode **dn, int ndirs)
nfiles= countfiles(subdnp);
if (nfiles > 0) {
/* list all files at this level */
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(subdnp, nfiles);
#endif
showfiles(subdnp, nfiles);
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_RECURSIVE) {
/* recursive- list the sub-dirs */
dnd= splitdnarray(subdnp, nfiles, SPLIT_SUBDIR);
dndirs= countsubdirs(subdnp, nfiles);
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);
@ -582,26 +582,26 @@ static int list_single(struct dnode *dn)
{
int i;
char scratch[BUFSIZ + 1];
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
#endif
#if defined (BB_FEATURE_LS_FILETYPES)
#if defined (CONFIG_FEATURE_LS_FILETYPES)
struct stat info;
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
char append;
#endif
if (dn==NULL || dn->fullname==NULL) return(0);
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
ttime= dn->dstat.st_mtime; /* the default time */
if (time_fmt & TIME_ACCESS) ttime= dn->dstat.st_atime;
if (time_fmt & TIME_CHANGE) ttime= dn->dstat.st_ctime;
filetime= ctime(&ttime);
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
append = append_char(dn->dstat.st_mode);
#endif
@ -612,7 +612,7 @@ static int list_single(struct dnode *dn)
column += 8;
break;
case LIST_BLOCKS:
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1,
KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE));
#else
@ -633,7 +633,7 @@ static int list_single(struct dnode *dn)
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
#ifdef CONFIG_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
printf("%-8.8s ", scratch);
my_getgrgid(scratch, dn->dstat.st_gid);
@ -650,7 +650,7 @@ static int list_single(struct dnode *dn)
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
if (ls_disp_hr==TRUE) {
fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0));
} else
@ -665,7 +665,7 @@ static int list_single(struct dnode *dn)
}
column += 10;
break;
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
@ -693,7 +693,7 @@ static int list_single(struct dnode *dn)
char *lpath = xreadlink(dn->fullname);
if (lpath) {
printf(" -> %s", lpath);
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
@ -703,7 +703,7 @@ static int list_single(struct dnode *dn)
}
}
break;
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
printf("%1c", append);
@ -727,21 +727,21 @@ extern int ls_main(int argc, char **argv)
int opt;
int oi, ac;
char **av;
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
struct winsize win = { 0, 0, 0, 0 };
#endif
disp_opts= DISP_NORMAL;
style_fmt= STYLE_AUTO;
list_fmt= LIST_SHORT;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_NAME;
sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
if (win.ws_row > 4)
column_width = win.ws_row - 2;
@ -752,25 +752,25 @@ extern int ls_main(int argc, char **argv)
/* process options */
while ((opt = getopt(argc, argv, "1AaCdgilnsx"
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
"T:w:"
#endif
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
"Fp"
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
"R"
#endif
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
"rSvX"
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
"cetu"
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
"L"
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
"h"
#endif
"k")) > 0) {
@ -785,54 +785,54 @@ extern int ls_main(int argc, char **argv)
case 'l':
style_fmt = STYLE_LONG;
list_fmt |= LIST_LONG;
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
ls_disp_hr = FALSE;
#endif
break;
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
case 's': list_fmt |= LIST_BLOCKS; break;
case 'x': disp_opts = DISP_ROWS; break;
#ifdef BB_FEATURE_LS_FILETYPES
#ifdef CONFIG_FEATURE_LS_FILETYPES
case 'F': list_fmt |= LIST_FILETYPE | LIST_EXEC; break;
case 'p': list_fmt |= LIST_FILETYPE; break;
#endif
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
case 'R': disp_opts |= DISP_RECURSIVE; break;
#endif
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
case 'r': sort_order |= SORT_REVERSE; break;
case 'S': sort_opts= SORT_SIZE; break;
case 'v': sort_opts= SORT_VERSION; break;
case 'X': sort_opts= SORT_EXT; break;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
#ifdef CONFIG_FEATURE_LS_TIMESTAMPS
case 'e': list_fmt |= LIST_FULLTIME; break;
case 'c':
time_fmt = TIME_CHANGE;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_CTIME;
#endif
break;
case 'u':
time_fmt = TIME_ACCESS;
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_ATIME;
#endif
break;
case 't':
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
sort_opts= SORT_MTIME;
#endif
break;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
#ifdef CONFIG_FEATURE_LS_FOLLOWLINKS
case 'L': follow_links= TRUE; break;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
#ifdef CONFIG_FEATURE_AUTOWIDTH
case 'T': tabstops= atoi(optarg); break;
case 'w': terminal_width= atoi(optarg); break;
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
#ifdef CONFIG_FEATURE_HUMAN_READABLE
case 'h': ls_disp_hr = TRUE; break;
#endif
case 'k': break;
@ -842,17 +842,17 @@ extern int ls_main(int argc, char **argv)
}
/* sort out which command line options take precedence */
#ifdef BB_FEATURE_LS_RECURSIVE
#ifdef CONFIG_FEATURE_LS_RECURSIVE
if (disp_opts & DISP_NOLIST)
disp_opts &= ~DISP_RECURSIVE; /* no recurse if listing only dir */
#endif
#if defined (BB_FEATURE_LS_TIMESTAMPS) && defined (BB_FEATURE_LS_SORTFILES)
#if defined (CONFIG_FEATURE_LS_TIMESTAMPS) && defined (CONFIG_FEATURE_LS_SORTFILES)
if (time_fmt & TIME_CHANGE) sort_opts= SORT_CTIME;
if (time_fmt & TIME_ACCESS) sort_opts= SORT_ATIME;
#endif
if (style_fmt != STYLE_LONG)
list_fmt &= ~LIST_ID_NUMERIC; /* numeric uid only for long list */
#ifdef BB_FEATURE_LS_USERNAME
#ifdef CONFIG_FEATURE_LS_USERNAME
if (style_fmt == STYLE_LONG && (list_fmt & LIST_ID_NUMERIC))
list_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
#endif
@ -908,7 +908,7 @@ extern int ls_main(int argc, char **argv)
if (disp_opts & DISP_NOLIST) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnp, nfiles);
#endif
if (nfiles > 0) showfiles(dnp, nfiles);
@ -918,13 +918,13 @@ extern int ls_main(int argc, char **argv)
dndirs= countdirs(dnp, nfiles);
dnfiles= nfiles - dndirs;
if (dnfiles > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnf, dnfiles);
#endif
showfiles(dnf, dnfiles);
}
if (dndirs > 0) {
#ifdef BB_FEATURE_LS_SORTFILES
#ifdef CONFIG_FEATURE_LS_SORTFILES
shellsort(dnd, dndirs);
#endif
showdirs(dnd, dndirs);

View File

@ -2,9 +2,8 @@
/*
* Mini rmdir implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -43,10 +43,10 @@ int sort_main(int argc, char **argv)
char *line, **lines = NULL;
int i, opt, nlines = 0;
int (*compare)(const void *, const void *) = compare_ascii;
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
#ifdef CONFIG_FEATURE_SORT_UNIQUE
int unique = FALSE;
#endif
@ -55,12 +55,12 @@ int sort_main(int argc, char **argv)
case 'n':
compare = compare_numeric;
break;
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
case 'r':
reverse = TRUE;
break;
#endif
#ifdef BB_FEATURE_SORT_UNIQUE
#ifdef CONFIG_FEATURE_SORT_UNIQUE
case 'u':
unique = TRUE;
break;
@ -88,17 +88,17 @@ int sort_main(int argc, char **argv)
qsort(lines, nlines, sizeof(char *), compare);
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
#ifdef CONFIG_FEATURE_SORT_REVERSE
if (reverse) {
for (i = --nlines; 0 <= i; i--)
#ifdef BB_FEATURE_SORT_UNIQUE
#ifdef CONFIG_FEATURE_SORT_UNIQUE
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
#endif
puts(lines[i]);
} else
#endif
for (i = 0; i < nlines; i++)
#ifdef BB_FEATURE_SORT_UNIQUE
#ifdef CONFIG_FEATURE_SORT_UNIQUE
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
#endif
puts(lines[i]);

View File

@ -73,7 +73,7 @@ int tail_main(int argc, char **argv)
case 'f':
follow = 1;
break;
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
case 'c':
units = BYTES;
/* FALLS THROUGH */
@ -85,7 +85,7 @@ int tail_main(int argc, char **argv)
if (optarg[0] == '+')
from_top = 1;
break;
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
case 'q':
hide_headers = 1;
break;
@ -118,7 +118,7 @@ int tail_main(int argc, char **argv)
}
}
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
/* tail the files */
if (!from_top && units == BYTES)
tailbuf = xmalloc(count);
@ -136,7 +136,7 @@ int tail_main(int argc, char **argv)
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (from_top) {
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (count - 1 <= seen)
nwrite = nread;
@ -169,7 +169,7 @@ int tail_main(int argc, char **argv)
break;
}
} else {
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (units == BYTES) {
if (nread < count) {
memmove(tailbuf, tailbuf + nread, count - nread);
@ -203,7 +203,7 @@ int tail_main(int argc, char **argv)
status = EXIT_FAILURE;
}
#ifdef BB_FEATURE_FANCY_TAIL
#ifdef CONFIG_FEATURE_FANCY_TAIL
if (!from_top && units == BYTES) {
if (count < seen)
seen = count;

View File

@ -2,8 +2,7 @@
/*
* Mini tee implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* Copyright (C) 2000,2001 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

View File

@ -2,9 +2,8 @@
/*
* Mini touch implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
* Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* 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

View File

@ -155,11 +155,11 @@ extern int tr_main(int argc, char **argv)
int output_length=0, input_length;
int idx = 1;
int i;
RESERVE_BB_BUFFER(output, BUFSIZ);
RESERVE_BB_BUFFER(input, BUFSIZ);
RESERVE_BB_UBUFFER(vector, ASCII+1);
RESERVE_BB_BUFFER(invec, ASCII+1);
RESERVE_BB_BUFFER(outvec, ASCII+1);
RESERVE_CONFIG_BUFFER(output, BUFSIZ);
RESERVE_CONFIG_BUFFER(input, BUFSIZ);
RESERVE_CONFIG_UBUFFER(vector, ASCII+1);
RESERVE_CONFIG_BUFFER(invec, ASCII+1);
RESERVE_CONFIG_BUFFER(outvec, ASCII+1);
/* ... but make them available globally */
poutput = output;

View File

@ -2,9 +2,8 @@
/*
* Mini uniq implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Copyright (C) 1999 by Lineo, inc. and John Beppu
* Copyright (C) 1999,2000,2001 by John Beppu <beppu@codepoet.org>
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify

View File

@ -84,8 +84,8 @@ int uuencode_main(int argc, char **argv)
{
const int src_buf_size = 60; // This *MUST* be a multiple of 3
const int dst_buf_size = 4 * ((src_buf_size + 2) / 3);
RESERVE_BB_BUFFER(src_buf, src_buf_size + 1);
RESERVE_BB_BUFFER(dst_buf, dst_buf_size + 1);
RESERVE_CONFIG_BUFFER(src_buf, src_buf_size + 1);
RESERVE_CONFIG_BUFFER(dst_buf, dst_buf_size + 1);
struct stat stat_buf;
FILE *src_stream = stdin;
char *tbl = tbl_std;

114
cp.c
View File

@ -1,114 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cp implementation for busybox
*
*
* Copyright (C) 2000 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 <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <dirent.h>
#include <stdlib.h>
#include "busybox.h"
extern int cp_main(int argc, char **argv)
{
int status = 0;
int opt;
int flags = FILEUTILS_DEREFERENCE;
int i;
while ((opt = getopt(argc, argv, "adfipR")) != -1)
switch (opt) {
case 'a':
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
/* fallthrough */
case 'd':
flags &= ~FILEUTILS_DEREFERENCE;
break;
case 'f':
flags |= FILEUTILS_FORCE;
break;
case 'i':
flags |= FILEUTILS_INTERACTIVE;
break;
case 'p':
flags |= FILEUTILS_PRESERVE_STATUS;
break;
case 'R':
flags |= FILEUTILS_RECUR;
break;
default:
show_usage();
}
if (optind + 2 > argc)
show_usage();
/* If there are only two arguments and... */
if (optind + 2 == argc) {
struct stat source_stat;
struct stat dest_stat;
int source_exists = 1;
int dest_exists = 1;
if ((!(flags & FILEUTILS_DEREFERENCE) &&
lstat(argv[optind], &source_stat) < 0) ||
((flags & FILEUTILS_DEREFERENCE) &&
stat(argv[optind], &source_stat))) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind]);
source_exists = 0;
}
if (stat(argv[optind + 1], &dest_stat) < 0) {
if (errno != ENOENT)
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
dest_exists = 0;
}
/* ...if neither is a directory or... */
if (((!source_exists || !S_ISDIR(source_stat.st_mode)) &&
(!dest_exists || !S_ISDIR(dest_stat.st_mode))) ||
/* ...recursing, the first is a directory, and the
* second doesn't exist, then... */
((flags & FILEUTILS_RECUR) && S_ISDIR(source_stat.st_mode) &&
!dest_exists)) {
/* ...do a simple copy. */
if (copy_file(argv[optind], argv[optind + 1], flags) < 0)
status = 1;
return status;
}
}
for (i = optind; i < argc - 1; i++) {
char *dest = concat_path_file(argv[argc - 1],
get_last_path_component(argv[i]));
if (copy_file(argv[i], dest, flags) < 0)
status = 1;
free(dest);
}
return status;
}

95
cpio.c
View File

@ -1,95 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini cpio implementation for busybox
*
* Copyright (C) 2001 by Glenn McGrath
*
* 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
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
extern int cpio_main(int argc, char **argv)
{
FILE *src_stream = stdin;
char **extract_names = NULL;
int extract_function = 0;
int num_of_entries = 0;
int opt = 0;
mode_t oldmask = 0;
while ((opt = getopt(argc, argv, "idmuvtF:")) != -1) {
switch (opt) {
case 'i': // extract
extract_function |= extract_all_to_fs;
break;
case 'd': // create _leading_ directories
extract_function |= extract_create_leading_dirs;
oldmask = umask(077); /* Make make_directory act like GNU cpio */
break;
case 'm': // preserve modification time
extract_function |= extract_preserve_date;
break;
case 'v': // verbosly list files
extract_function |= extract_verbose_list;
break;
case 'u': // unconditional
extract_function |= extract_unconditional;
break;
case 't': // list files
extract_function |= extract_list;
break;
case 'F':
src_stream = xfopen(optarg, "r");
break;
default:
show_usage();
}
}
if ((extract_function & extract_all_to_fs) && (extract_function & extract_list)) {
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
}
if ((extract_function & extract_all_to_fs) && (extract_function & extract_verbose_list)) {
/* The meaning of v changes on extract */
extract_function ^= extract_verbose_list;
extract_function |= extract_list;
}
while (optind < argc) {
extract_names = xrealloc(extract_names, sizeof(char *) * (num_of_entries + 2));
extract_names[num_of_entries] = xstrdup(argv[optind]);
num_of_entries++;
extract_names[num_of_entries] = NULL;
optind++;
}
unarchive(src_stream, stdout, &get_header_cpio, extract_function, "./", extract_names, NULL);
if (oldmask) {
umask(oldmask); /* Restore umask if we changed it */
}
return EXIT_SUCCESS;
}

356
cut.c
View File

@ -1,356 +0,0 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* getopt */
#include <string.h>
#include <limits.h>
#include "busybox.h"
/* globals from other files */
extern int optind;
extern char *optarg;
/* option vars */
static char part = 0; /* (b)yte, (c)har, (f)ields */
static unsigned int supress_non_delimited_lines = 0;
static char delim = '\t'; /* delimiter, default is tab */
struct cut_list {
int startpos;
int endpos;
};
static const int BOL = 0;
static const int EOL = INT_MAX;
static const int NON_RANGE = -1;
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
static unsigned int nlists = 0; /* number of elements in above list */
static int cmpfunc(const void *a, const void *b)
{
struct cut_list *la = (struct cut_list *)a;
struct cut_list *lb = (struct cut_list *)b;
if (la->startpos > lb->startpos)
return 1;
if (la->startpos < lb->startpos)
return -1;
return 0;
}
/*
* parse_lists() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
* more than one list can be seperated by commas
*/
static void parse_lists(char *lists)
{
char *ltok = NULL;
char *ntok = NULL;
char *junk;
int s = 0, e = 0;
/* take apart the lists, one by one (they are seperated with commas */
while ((ltok = strsep(&lists, ",")) != NULL) {
/* it's actually legal to pass an empty list */
if (strlen(ltok) == 0)
continue;
/* get the start pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
fprintf(stderr, "Help ntok is null for starting position! What do I do?\n");
} else if (strlen(ntok) == 0) {
s = BOL;
} else {
s = strtoul(ntok, &junk, 10);
if(*junk != '\0' || s < 0)
error_msg_and_die("invalid byte or field list");
/* account for the fact that arrays are zero based, while the user
* expects the first char on the line to be char # 1 */
if (s != 0)
s--;
}
/* get the end pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
e = NON_RANGE;
} else if (strlen(ntok) == 0) {
e = EOL;
} else {
e = strtoul(ntok, &junk, 10);
if(*junk != '\0' || e < 0)
error_msg_and_die("invalid byte or field list");
/* if the user specified and end position of 0, that means "til the
* end of the line */
if (e == 0)
e = INT_MAX;
e--; /* again, arrays are zero based, lines are 1 based */
if (e == s)
e = NON_RANGE;
}
/* if there's something left to tokenize, the user past an invalid list */
if (ltok)
error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
cut_lists[nlists-1].endpos = e;
}
/* make sure we got some cut positions out of all that */
if (nlists == 0)
error_msg_and_die("missing list of positions");
/* now that the lists are parsed, we need to sort them to make life easier
* on us when it comes time to print the chars / fields / lines */
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
}
static void cut_line_by_chars(const char *line)
{
int c, l;
/* set up a list so we can keep track of what's been printed */
char *printed = xcalloc(strlen(line), sizeof(char));
/* print the chars specified in each cut list */
for (c = 0; c < nlists; c++) {
l = cut_lists[c].startpos;
while (l < strlen(line)) {
if (!printed[l]) {
putchar(line[l]);
printed[l] = 'X';
}
l++;
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos)
break;
}
}
putchar('\n'); /* cuz we were handed a chomped line */
free(printed);
}
static void cut_line_by_fields(char *line)
{
int c, f;
int ndelim = -1; /* zero-based / one-based problem */
int nfields_printed = 0;
char *field = NULL;
char d[2] = { delim, 0 };
char *printed;
/* test the easy case first: does this line contain any delimiters? */
if (strchr(line, delim) == NULL) {
if (!supress_non_delimited_lines)
puts(line);
return;
}
/* set up a list so we can keep track of what's been printed */
printed = xcalloc(strlen(line), sizeof(char));
/* process each list on this line, for as long as we've got a line to process */
for (c = 0; c < nlists && line; c++) {
f = cut_lists[c].startpos;
do {
/* find the field we're looking for */
while (line && ndelim < f) {
field = strsep(&line, d);
ndelim++;
}
/* we found it, and it hasn't been printed yet */
if (field && ndelim == f && !printed[ndelim]) {
/* if this isn't our first time through, we need to print the
* delimiter after the last field that was printed */
if (nfields_printed > 0)
putchar(delim);
fputs(field, stdout);
printed[ndelim] = 'X';
nfields_printed++;
}
f++;
/* keep going as long as we have a line to work with, this is a
* list, and we're not at the end of that list */
} while (line && cut_lists[c].endpos != NON_RANGE && f <= cut_lists[c].endpos);
}
/* if we printed anything at all, we need to finish it with a newline cuz
* we were handed a chomped line */
putchar('\n');
free(printed);
}
static void cut_file_by_lines(const char *line, unsigned int linenum)
{
static int c = 0;
static int l = -1;
/* I can't initialize this above cuz the "initializer isn't
* constant" *sigh* */
if (l == -1)
l = cut_lists[c].startpos;
/* get out if we have no more lists to process or if the lines are lower
* than what we're interested in */
if (c >= nlists || linenum < l)
return;
/* if the line we're looking for is lower than the one we were passed, it
* means we displayed it already, so move on */
while (l < linenum) {
l++;
/* move on to the next list if we're at the end of this one */
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos) {
c++;
/* get out if there's no more lists to process */
if (c >= nlists)
return;
l = cut_lists[c].startpos;
/* get out if the current line is lower than the one we just became
* interested in */
if (linenum < l)
return;
}
}
/* If we made it here, it means we've found the line we're looking for, so print it */
puts(line);
}
/*
* snippy-snip
*/
static void cut_file(FILE *file)
{
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
while ((line = get_line_from_file(file)) != NULL) {
chomp(line);
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
if (part == 'c' || part == 'b')
cut_line_by_chars(line);
/* cut based on fields */
else if (part == 'f') {
if (delim == '\n')
cut_file_by_lines(line, linenum);
else
cut_line_by_fields(line);
}
linenum++;
free(line);
}
}
extern int cut_main(int argc, char **argv)
{
int opt;
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
switch (opt) {
case 'b':
case 'c':
case 'f':
/* make sure they didn't ask for two types of lists */
if (part != 0) {
error_msg_and_die("only one type of list may be specified");
}
part = (char)opt;
parse_lists(optarg);
break;
case 'd':
if (strlen(optarg) > 1) {
error_msg_and_die("the delimiter must be a single character");
}
delim = optarg[0];
break;
case 'n':
/* no-op */
break;
case 's':
supress_non_delimited_lines++;
break;
}
}
if (part == 0) {
error_msg_and_die("you must specify a list of bytes, characters, or fields");
}
/* non-field (char or byte) cutting has some special handling */
if (part != 'f') {
if (supress_non_delimited_lines) {
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields");
}
if (delim != '\t' && part != 'f') {
error_msg_and_die("a delimiter may be specified only when operating on fields");
}
}
/* argv[(optind)..(argc-1)] should be names of file to process. If no
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
cut_file(stdin);
}
else {
int i;
FILE *file;
for (i = optind; i < argc; i++) {
file = wfopen(argv[i], "r");
if(file) {
cut_file(file);
fclose(file);
}
}
}
return EXIT_SUCCESS;
}

247
date.c
View File

@ -1,247 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini date implementation for busybox
*
* by Matthew Grant <grantma@anathoth.gen.nz>
*
* 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 <stdlib.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying int, as well as
an RFC 822 complient date output for shell scripting
mail commands */
/* Input parsing code is always bulky - used heavy duty libc stuff as
much as possible, missed out a lot of bounds checking */
/* Default input handling to save suprising some people */
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
{
int nr;
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
&(tm_time->tm_mon),
&(tm_time->tm_mday),
&(tm_time->tm_hour),
&(tm_time->tm_min), &(tm_time->tm_year));
if (nr < 4 || nr > 5) {
error_msg_and_die(invalid_date, t_string);
}
/* correct for century - minor Y2K problem here? */
if (tm_time->tm_year >= 1900)
tm_time->tm_year -= 1900;
/* adjust date */
tm_time->tm_mon -= 1;
return (tm_time);
}
/* The new stuff for LRP */
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
{
struct tm t;
/* Parse input and assign appropriately to tm_time */
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
/* no adjustments needed */
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
&t.tm_hour, &t.tm_min) == 2) {
/* no adjustments needed */
} 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) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} 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) {
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} 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) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} 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);
}
*tm_time = t;
return (tm_time);
}
int date_main(int argc, char **argv)
{
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int c;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
int use_arg = 0;
time_t tm;
struct tm tm_time;
/* 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)) {
show_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))
show_usage();
break;
default:
show_usage();
}
}
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
date_fmt = &argv[optind][1]; /* Skip over the '+' */
else if (date_str == NULL) {
set_time = 1;
date_str = argv[optind];
}
#if 0
else {
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
show_usage();
}
#endif
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
/* Zero out fields - take her back to midnight! */
if (date_str != NULL) {
tm_time.tm_sec = 0;
tm_time.tm_min = 0;
tm_time.tm_hour = 0;
}
/* Process any date input to UNIX time since 1 Jan 1970 */
if (date_str != NULL) {
if (strchr(date_str, ':') != NULL) {
date_conv_ftime(&tm_time, date_str);
} else {
date_conv_time(&tm_time, date_str);
}
/* Correct any day of week and day of year etc. fields */
tm = mktime(&tm_time);
if (tm < 0)
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) {
perror_msg("cannot set date");
}
}
}
/* Display output */
/* Deal with format string */
if (date_fmt == NULL) {
date_fmt = (rfc822
? (utc
? "%a, %_d %b %Y %H:%M:%S GMT"
: "%a, %_d %b %Y %H:%M:%S %z")
: "%a %b %e %H:%M:%S %Z %Y");
} else if (*date_fmt == '\0') {
/* Imitate what GNU 'date' does with NO format string! */
printf("\n");
return EXIT_SUCCESS;
}
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = "%Y.%m.%d-%H:%M:%S";
}
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
puts(t_buff);
return EXIT_SUCCESS;
}

182
dc.c
View File

@ -1,182 +0,0 @@
/* vi: set sw=4 ts=4: */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
#include "busybox.h"
/* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */
static double stack[100];
static unsigned int pointer;
static void push(double a)
{
if (pointer >= (sizeof(stack) / sizeof(*stack)))
error_msg_and_die("stack overflow");
stack[pointer++] = a;
}
static double pop()
{
if (pointer == 0)
error_msg_and_die("stack underflow");
return stack[--pointer];
}
static void add()
{
push(pop() + pop());
}
static void sub()
{
double subtrahend = pop();
push(pop() - subtrahend);
}
static void mul()
{
push(pop() * pop());
}
static void divide()
{
double divisor = pop();
push(pop() / divisor);
}
static void and()
{
push((unsigned int) pop() & (unsigned int) pop());
}
static void or()
{
push((unsigned int) pop() | (unsigned int) pop());
}
static void eor()
{
push((unsigned int) pop() ^ (unsigned int) pop());
}
static void not()
{
push(~(unsigned int) pop());
}
static void print()
{
printf("%g\n", pop());
}
struct op {
const char *name;
void (*function) ();
};
static const struct op operators[] = {
{"+", add},
{"add", add},
{"-", sub},
{"sub", sub},
{"*", mul},
{"mul", mul},
{"/", divide},
{"div", divide},
{"and", and},
{"or", or},
{"not", not},
{"eor", eor},
{0, 0}
};
static void stack_machine(const char *argument)
{
char *endPointer = 0;
double d;
const struct op *o = operators;
if (argument == 0) {
print();
return;
}
d = strtod(argument, &endPointer);
if (endPointer != argument) {
push(d);
return;
}
while (o->name != 0) {
if (strcmp(o->name, argument) == 0) {
(*(o->function)) ();
return;
}
o++;
}
error_msg_and_die("%s: syntax error.", argument);
}
/* return pointer to next token in buffer and set *buffer to one char
* past the end of the above mentioned token
*/
static char *get_token(char **buffer)
{
char *start = NULL;
char *current = *buffer;
while (isspace(*current)) { current++; }
if (*current != 0) {
start = current;
while (!isspace(*current) && current != 0) { current++; }
*buffer = current;
}
return start;
}
/* In Perl one might say, scalar m|\s*(\S+)\s*|g */
static int number_of_tokens(char *buffer)
{
int i = 0;
char *b = buffer;
while (get_token(&b)) { i++; }
return i;
}
int dc_main(int argc, char **argv)
{
/* take stuff from stdin if no args are given */
if (argc <= 1) {
int i, len;
char *line = NULL;
char *cursor = NULL;
char *token = NULL;
while ((line = get_line_from_file(stdin))) {
cursor = line;
len = number_of_tokens(line);
for (i = 0; i < len; i++) {
token = get_token(&cursor);
*cursor++ = 0;
stack_machine(token);
}
free(line);
}
} else {
if (*argv[1]=='-')
show_usage();
while (argc >= 2) {
stack_machine(argv[1]);
argv++;
argc--;
}
}
stack_machine(0);
return EXIT_SUCCESS;
}

154
dd.c
View File

@ -1,154 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dd implementation for busybox
*
*
* Copyright (C) 2000 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 <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "busybox.h"
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
{ "b", 512 },
{ "kD", 1000 },
{ "k", 1024 },
{ "MD", 1000000 },
{ "M", 1048576 },
{ "GD", 1000000000 },
{ "G", 1073741824 },
{ NULL, 0 }
};
int dd_main(int argc, char **argv)
{
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
size_t bs = 512, count = -1;
ssize_t n;
off_t seek = 0, skip = 0;
char *infile = NULL, *outfile = NULL, *buf;
for (i = 1; i < argc; i++) {
if (strncmp("bs=", argv[i], 3) == 0)
bs = parse_number(argv[i]+3, dd_suffixes);
else if (strncmp("count=", argv[i], 6) == 0)
count = parse_number(argv[i]+6, dd_suffixes);
else if (strncmp("seek=", argv[i], 5) == 0)
seek = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("skip=", argv[i], 5) == 0)
skip = parse_number(argv[i]+5, dd_suffixes);
else if (strncmp("if=", argv[i], 3) == 0)
infile = argv[i]+3;
else if (strncmp("of=", argv[i], 3) == 0)
outfile = argv[i]+3;
else if (strncmp("conv=", argv[i], 5) == 0) {
buf = argv[i]+5;
while (1) {
if (strncmp("notrunc", buf, 7) == 0) {
trunc = FALSE;
buf += 7;
} else if (strncmp("sync", buf, 4) == 0) {
sync_flag = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
}
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
show_usage();
}
buf = xmalloc(bs);
if (infile != NULL) {
if ((ifd = open(infile, O_RDONLY)) < 0)
perror_msg_and_die("%s", infile);
} else {
ifd = STDIN_FILENO;
infile = "standard input";
}
if (outfile != NULL) {
oflag = O_WRONLY | O_CREAT;
if (!seek && trunc)
oflag |= O_TRUNC;
if ((ofd = open(outfile, oflag, 0666)) < 0)
perror_msg_and_die("%s", outfile);
if (seek && trunc) {
if (ftruncate(ofd, seek * bs) < 0)
perror_msg_and_die("%s", outfile);
}
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
}
if (skip) {
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", infile);
}
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", outfile);
}
while (in_full + in_part != count) {
n = safe_read(ifd, buf, bs);
if (n < 0)
perror_msg_and_die("%s", infile);
if (n == 0)
break;
if (n == bs)
in_full++;
else
in_part++;
if (sync_flag) {
memset(buf + n, '\0', bs - n);
n = bs;
}
n = full_write(ofd, buf, n);
if (n < 0)
perror_msg_and_die("%s", outfile);
if (n == bs)
out_full++;
else
out_part++;
}
fprintf(stderr, "%ld+%ld records in\n", (long)in_full, (long)in_part);
fprintf(stderr, "%ld+%ld records out\n", (long)out_full, (long)out_part);
return EXIT_SUCCESS;
}

View File

@ -1,43 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
* Renamed deallocvt.
*/
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
int fd, num, i;
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
if (argc > 2)
show_usage();
fd = get_console_fd("/dev/console");
if (argc == 1) {
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0))
perror_msg_and_die("VT_DISALLOCATE");
} else {
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
if (num == 0)
error_msg("0: illegal VT number");
else if (num == 1)
error_msg("VT 1 cannot be deallocated");
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
}
return EXIT_SUCCESS;
}

498
debian/Config.h-deb vendored
View File

@ -3,142 +3,142 @@
// 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
// i.e., //#define CONFIG_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
//#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP
//#define BB_CPIO
#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_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
#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_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#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_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PIDOF
#define BB_PING
//#define BB_PIVOT_ROOT
#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_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
#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_TFTP
#define BB_TOUCH
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
#define BB_YES
//#define CONFIG_ADJTIMEX
#define CONFIG_AR
//#define CONFIG_ASH
#define CONFIG_BASENAME
#define CONFIG_CAT
#define CONFIG_CHGRP
#define CONFIG_CHMOD
#define CONFIG_CHOWN
#define CONFIG_CHROOT
#define CONFIG_CHVT
#define CONFIG_CLEAR
//#define CONFIG_CMP
#define CONFIG_CP
//#define CONFIG_CPIO
#define CONFIG_CUT
#define CONFIG_DATE
//#define CONFIG_DC
#define CONFIG_DD
//#define CONFIG_DEALLOCVT
#define CONFIG_DF
#define CONFIG_DIRNAME
#define CONFIG_DMESG
//#define CONFIG_DOS2UNIX
//#define CONFIG_DPKG
//#define CONFIG_DPKG_DEB
//#define CONFIG_DUTMP
#define CONFIG_DU
//#define CONFIG_DUMPKMAP
#define CONFIG_ECHO
#define CONFIG_ENV
#define CONFIG_EXPR
//#define CONFIG_FBSET
//#define CONFIG_FDFLUSH
#define CONFIG_FIND
#define CONFIG_FREE
//#define CONFIG_FREERAMDISK
//#define CONFIG_FSCK_MINIX
//#define CONFIG_GETOPT
#define CONFIG_GREP
#define CONFIG_GUNZIP
#define CONFIG_GZIP
#define CONFIG_HALT
#define CONFIG_HEAD
//#define CONFIG_HOSTID
//#define CONFIG_HOSTNAME
//#define CONFIG_HUSH
#define CONFIG_ID
//#define CONFIG_IFCONFIG
#define CONFIG_INIT
//#define CONFIG_INSMOD
#define CONFIG_KILL
#define CONFIG_KILLALL
#define CONFIG_KLOGD
//#define CONFIG_LASH
//#define CONFIG_LENGTH
#define CONFIG_LN
//#define CONFIG_LOADACM
//#define CONFIG_LOADFONT
#define CONFIG_LOADKMAP
#define CONFIG_LOGGER
//#define CONFIG_LOGNAME
#define CONFIG_LS
#define CONFIG_LSMOD
//#define CONFIG_MAKEDEVS
#define CONFIG_MD5SUM
#define CONFIG_MKDIR
//#define CONFIG_MKFIFO
//#define CONFIG_MKFS_MINIX
#define CONFIG_MKNOD
#define CONFIG_MKSWAP
//#define CONFIG_MKTEMP
//#define CONFIG_MODPROBE
#define CONFIG_MORE
#define CONFIG_MOUNT
//#define CONFIG_MSH
//#define CONFIG_MT
#define CONFIG_MV
//#define CONFIG_NC
//#define CONFIG_NSLOOKUP
//#define CONFIG_PIDOF
#define CONFIG_PING
//#define CONFIG_PIVOT_ROOT
#define CONFIG_POWEROFF
//#define CONFIG_PRINTF
#define CONFIG_PS
#define CONFIG_PWD
//#define CONFIG_RDATE
//#define CONFIG_READLINK
#define CONFIG_REBOOT
//#define CONFIG_RENICE
#define CONFIG_RESET
#define CONFIG_RM
#define CONFIG_RMDIR
//#define CONFIG_RMMOD
//#define CONFIG_ROUTE
//#define CONFIG_RPM2CPIO
#define CONFIG_SED
//#define CONFIG_SETKEYCODES
#define CONFIG_SLEEP
#define CONFIG_SORT
//#define CONFIG_STTY
#define CONFIG_SWAPONOFF
#define CONFIG_SYNC
#define CONFIG_SYSLOGD
#define CONFIG_TAIL
#define CONFIG_TAR
//#define CONFIG_TEE
//#define CONFIG_TEST
#define CONFIG_TELNET
//#define CONFIG_TFTP
#define CONFIG_TOUCH
#define CONFIG_TR
//#define CONFIG_TRACEROUTE
#define CONFIG_TRUE_FALSE
#define CONFIG_TTY
//#define CONFIG_UNIX2DOS
//#define CONFIG_UUENCODE
//#define CONFIG_UUDECODE
#define CONFIG_UMOUNT
#define CONFIG_UNIQ
#define CONFIG_UNAME
//#define CONFIG_UPDATE
#define CONFIG_UPTIME
//#define CONFIG_USLEEP
#define CONFIG_VI
//#define CONFIG_WATCHDOG
#define CONFIG_WC
#define CONFIG_WGET
#define CONFIG_WHICH
#define CONFIG_WHOAMI
#define CONFIG_XARGS
#define CONFIG_YES
// End of Applications List
//
//
@ -151,21 +151,21 @@
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//#define CONFIG_FEATURE_SH_IS_ASH
//#define CONFIG_FEATURE_SH_IS_HUSH
//#define CONFIG_FEATURE_SH_IS_LASH
#define CONFIG_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
//#define CONFIG_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//#define CONFIG_FEATURE_BUFFERS_GO_IN_BSS
//
// 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
@ -176,212 +176,212 @@
// 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
//#define CONFIG_FEATURE_USE_DEVPS_PATCH
//
// show verbose usage messages
//#define BB_FEATURE_VERBOSE_USAGE
//#define CONFIG_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
#define CONFIG_FEATURE_AUTOWIDTH
//
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
#define CONFIG_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
#define CONFIG_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
#define CONFIG_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
#define CONFIG_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
#define CONFIG_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
#define CONFIG_FEATURE_LS_FOLLOWLINKS
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_PING
#define CONFIG_FEATURE_FANCY_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
#define CONFIG_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
#define CONFIG_FEATURE_INITRD
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//#define CONFIG_FEATURE_INIT_COREDUMPS
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//#define CONFIG_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
#define CONFIG_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//#define CONFIG_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_TAIL
#define CONFIG_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
#define CONFIG_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MTAB_SUPPORT
//#define CONFIG_FEATURE_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
#define CONFIG_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
#define CONFIG_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
#define CONFIG_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
#define CONFIG_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
#define CONFIG_FEATURE_TAR_GZIP
//
// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
#define CONFIG_FEATURE_SORT_REVERSE
//
// Enable uniqe sort
#define BB_FEATURE_SORT_UNIQUE
#define CONFIG_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
#define CONFIG_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
#define CONFIG_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//#define CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
//
//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. Off by default.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//#define CONFIG_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.
//only has meaning when CONFIG_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//#define CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//#define CONFIG_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//#define CONFIG_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//#define CONFIG_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//#define CONFIG_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//#define CONFIG_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//#define CONFIG_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//#define CONFIG_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 12k.
#define BB_FEATURE_IFCONFIG_STATUS
#define CONFIG_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//#define CONFIG_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//#define CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
#define CONFIG_FEATURE_IFCONFIG_HW
//
// 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
#define CONFIG_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
#define CONFIG_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
#define CONFIG_FEATURE_WGET_AUTHENTICATION
//
// 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
//#define CONFIG_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
#define CONFIG_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
#define CONFIG_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
#define CONFIG_FEATURE_FIND_PERM
//
// Support for the find -mtine option.
#define BB_FEATURE_FIND_MTIME
#define CONFIG_FEATURE_FIND_MTIME
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//#define CONFIG_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//#define CONFIG_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
#define CONFIG_FEATURE_TFTP_PUT
#define CONFIG_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
#define CONFIG_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define CONFIG_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define CONFIG_FEATURE_VI_SEARCH // search and replace cmds
#define CONFIG_FEATURE_VI_USE_SIGNALS // catch signals
#define CONFIG_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define CONFIG_FEATURE_VI_READONLY // vi -R and "view" mode
#define CONFIG_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define CONFIG_FEATURE_VI_SET // :set
#define CONFIG_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//#define CONFIG_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
#define CONFIG_FEATURE_TELNET_TTYPE
//
// End of Features List
//
@ -396,74 +396,74 @@
//
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#undef CONFIG_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef CONFIG_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef CONFIG_ASH /* Uses fork() */
#undef CONFIG_HUSH /* Uses fork() */
#undef CONFIG_LASH /* Uses fork() */
#undef CONFIG_INIT /* Uses fork() */
#undef CONFIG_FEATURE_TAR_GZIP /* Uses fork() */
#undef CONFIG_SYSLOGD /* Uses daemon() */
#undef CONFIG_KLOGD /* Uses daemon() */
#undef CONFIG_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#if defined CONFIG_ASH || defined CONFIG_HUSH || defined CONFIG_LASH || defined CONFIG_MSH
#if defined CONFIG_FEATURE_COMMAND_EDITING
#define CONFIG_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_COMMAND_EDITING
#undef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
#undef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef CONFIG_FEATURE_SH_STANDALONE_SHELL
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#ifdef CONFIG_KILLALL
#ifndef CONFIG_KILL
#define CONFIG_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#ifndef CONFIG_INIT
#undef CONFIG_FEATURE_INITRD
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#if defined CONFIG_MOUNT && defined CONFIG_FEATURE_NFSMOUNT
#define CONFIG_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#if defined CONFIG_FEATURE_AUTOWIDTH
#ifndef CONFIG_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#if defined CONFIG_INSMOD || defined CONFIG_LSMOD
#if ! defined CONFIG_FEATURE_NEW_MODULE_INTERFACE && ! defined CONFIG_FEATURE_OLD_MODULE_INTERFACE
#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#ifdef CONFIG_UNIX2DOS
#define CONFIG_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#ifdef CONFIG_SYSLOGD
#if defined CONFIG_FEATURE_IPC_SYSLOG
#define CONFIG_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
#if defined CONFIG_ASH && defined CONFIG_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
#elif defined CONFIG_HUSH && defined CONFIG_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
#elif defined CONFIG_LASH && defined CONFIG_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
#elif defined CONFIG_MSH && defined CONFIG_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif

498
debian/Config.h-static vendored
View File

@ -3,142 +3,142 @@
// 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
// i.e., //#define CONFIG_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
#define BB_AR
#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CMP
#define BB_CP
#define BB_CPIO
#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_DPKG
#define BB_DPKG_DEB
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
#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_HUSH
#define BB_ID
#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
#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_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
#define BB_MT
#define BB_MV
#define BB_NC
#define BB_NSLOOKUP
#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
#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_ROUTE
#define BB_RPM2CPIO
#define BB_SED
#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
#define BB_STTY
#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_TFTP
#define BB_TOUCH
#define BB_TR
#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UNIX2DOS
#define BB_UUENCODE
#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UPDATE
#define BB_UPTIME
#define BB_USLEEP
#define BB_VI
#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
#define BB_YES
//#define CONFIG_ADJTIMEX
#define CONFIG_AR
#define CONFIG_ASH
#define CONFIG_BASENAME
#define CONFIG_CAT
#define CONFIG_CHGRP
#define CONFIG_CHMOD
#define CONFIG_CHOWN
#define CONFIG_CHROOT
#define CONFIG_CHVT
#define CONFIG_CLEAR
#define CONFIG_CMP
#define CONFIG_CP
#define CONFIG_CPIO
#define CONFIG_CUT
#define CONFIG_DATE
#define CONFIG_DC
#define CONFIG_DD
#define CONFIG_DEALLOCVT
#define CONFIG_DF
#define CONFIG_DIRNAME
#define CONFIG_DMESG
#define CONFIG_DOS2UNIX
#define CONFIG_DPKG
#define CONFIG_DPKG_DEB
#define CONFIG_DUTMP
#define CONFIG_DU
#define CONFIG_DUMPKMAP
#define CONFIG_ECHO
#define CONFIG_ENV
#define CONFIG_EXPR
#define CONFIG_FBSET
#define CONFIG_FDFLUSH
#define CONFIG_FIND
#define CONFIG_FREE
#define CONFIG_FREERAMDISK
#define CONFIG_FSCK_MINIX
#define CONFIG_GETOPT
#define CONFIG_GREP
#define CONFIG_GUNZIP
#define CONFIG_GZIP
#define CONFIG_HALT
#define CONFIG_HEAD
#define CONFIG_HOSTID
#define CONFIG_HOSTNAME
//#define CONFIG_HUSH
#define CONFIG_ID
#define CONFIG_IFCONFIG
#define CONFIG_INIT
//#define CONFIG_INSMOD
#define CONFIG_KILL
#define CONFIG_KILLALL
#define CONFIG_KLOGD
//#define CONFIG_LASH
#define CONFIG_LENGTH
#define CONFIG_LN
#define CONFIG_LOADACM
#define CONFIG_LOADFONT
#define CONFIG_LOADKMAP
#define CONFIG_LOGGER
#define CONFIG_LOGNAME
#define CONFIG_LS
#define CONFIG_LSMOD
#define CONFIG_MAKEDEVS
#define CONFIG_MD5SUM
#define CONFIG_MKDIR
#define CONFIG_MKFIFO
#define CONFIG_MKFS_MINIX
#define CONFIG_MKNOD
#define CONFIG_MKSWAP
#define CONFIG_MKTEMP
//#define CONFIG_MODPROBE
#define CONFIG_MORE
#define CONFIG_MOUNT
//#define CONFIG_MSH
#define CONFIG_MT
#define CONFIG_MV
#define CONFIG_NC
#define CONFIG_NSLOOKUP
#define CONFIG_PIDOF
#define CONFIG_PING
#define CONFIG_PIVOT_ROOT
#define CONFIG_POWEROFF
#define CONFIG_PRINTF
#define CONFIG_PS
#define CONFIG_PWD
#define CONFIG_RDATE
#define CONFIG_READLINK
#define CONFIG_REBOOT
#define CONFIG_RENICE
#define CONFIG_RESET
#define CONFIG_RM
#define CONFIG_RMDIR
#define CONFIG_RMMOD
#define CONFIG_ROUTE
#define CONFIG_RPM2CPIO
#define CONFIG_SED
#define CONFIG_SETKEYCODES
#define CONFIG_SLEEP
#define CONFIG_SORT
#define CONFIG_STTY
#define CONFIG_SWAPONOFF
#define CONFIG_SYNC
#define CONFIG_SYSLOGD
#define CONFIG_TAIL
#define CONFIG_TAR
#define CONFIG_TEE
#define CONFIG_TEST
#define CONFIG_TELNET
#define CONFIG_TFTP
#define CONFIG_TOUCH
#define CONFIG_TR
#define CONFIG_TRACEROUTE
#define CONFIG_TRUE_FALSE
#define CONFIG_TTY
#define CONFIG_UNIX2DOS
#define CONFIG_UUENCODE
#define CONFIG_UUDECODE
#define CONFIG_UMOUNT
#define CONFIG_UNIQ
#define CONFIG_UNAME
#define CONFIG_UPDATE
#define CONFIG_UPTIME
#define CONFIG_USLEEP
#define CONFIG_VI
#define CONFIG_WATCHDOG
#define CONFIG_WC
#define CONFIG_WGET
#define CONFIG_WHICH
#define CONFIG_WHOAMI
#define CONFIG_XARGS
#define CONFIG_YES
// End of Applications List
//
//
@ -151,21 +151,21 @@
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
//#define BB_FEATURE_SH_IS_MSH
#define CONFIG_FEATURE_SH_IS_ASH
//#define CONFIG_FEATURE_SH_IS_HUSH
//#define CONFIG_FEATURE_SH_IS_LASH
//#define CONFIG_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
//#define CONFIG_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//#define CONFIG_FEATURE_BUFFERS_GO_IN_BSS
//
// 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
@ -176,212 +176,212 @@
// 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
//#define CONFIG_FEATURE_USE_DEVPS_PATCH
//
// show verbose usage messages
#define BB_FEATURE_VERBOSE_USAGE
#define CONFIG_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
#define CONFIG_FEATURE_AUTOWIDTH
//
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
#define CONFIG_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
#define CONFIG_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
#define CONFIG_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
#define CONFIG_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
#define CONFIG_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
#define CONFIG_FEATURE_LS_FOLLOWLINKS
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_PING
#define CONFIG_FEATURE_FANCY_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
#define CONFIG_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
#define CONFIG_FEATURE_INITRD
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//#define CONFIG_FEATURE_INIT_COREDUMPS
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//#define CONFIG_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
#define CONFIG_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//#define CONFIG_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_TAIL
#define CONFIG_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
#define CONFIG_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MTAB_SUPPORT
//#define CONFIG_FEATURE_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
#define CONFIG_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
#define CONFIG_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
#define CONFIG_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
#define CONFIG_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
#define CONFIG_FEATURE_TAR_GZIP
//
// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
#define CONFIG_FEATURE_SORT_REVERSE
//
// Enable uniqe sort
#define BB_FEATURE_SORT_UNIQUE
#define CONFIG_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
#define CONFIG_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
#define CONFIG_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//#define CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
//
//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. Off by default.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_STANDALONE_SHELL
#define CONFIG_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.
//only has meaning when CONFIG_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if a shell is enabled. Off by default.
#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#define CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if a shell is enabled.
#define BB_FEATURE_SH_FANCY_PROMPT
#define CONFIG_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//#define CONFIG_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//#define CONFIG_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
#define BB_FEATURE_NEW_MODULE_INTERFACE
#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//#define CONFIG_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//#define CONFIG_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//#define CONFIG_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//#define CONFIG_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 12k.
#define BB_FEATURE_IFCONFIG_STATUS
#define CONFIG_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//#define CONFIG_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//#define CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
#define CONFIG_FEATURE_IFCONFIG_HW
//
// 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
#define CONFIG_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
#define CONFIG_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
#define CONFIG_FEATURE_WGET_AUTHENTICATION
//
// 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
//#define CONFIG_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
#define CONFIG_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
#define CONFIG_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
#define CONFIG_FEATURE_FIND_PERM
//
// Support for the find -mtine option.
#define BB_FEATURE_FIND_MTIME
#define CONFIG_FEATURE_FIND_MTIME
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//#define CONFIG_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//#define CONFIG_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
#define CONFIG_FEATURE_TFTP_PUT
#define CONFIG_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
#define CONFIG_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define CONFIG_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define CONFIG_FEATURE_VI_SEARCH // search and replace cmds
#define CONFIG_FEATURE_VI_USE_SIGNALS // catch signals
#define CONFIG_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define CONFIG_FEATURE_VI_READONLY // vi -R and "view" mode
#define CONFIG_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define CONFIG_FEATURE_VI_SET // :set
#define CONFIG_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//#define CONFIG_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
#define CONFIG_FEATURE_TELNET_TTYPE
//
// End of Features List
//
@ -396,74 +396,74 @@
//
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#undef CONFIG_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef CONFIG_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef CONFIG_ASH /* Uses fork() */
#undef CONFIG_HUSH /* Uses fork() */
#undef CONFIG_LASH /* Uses fork() */
#undef CONFIG_INIT /* Uses fork() */
#undef CONFIG_FEATURE_TAR_GZIP /* Uses fork() */
#undef CONFIG_SYSLOGD /* Uses daemon() */
#undef CONFIG_KLOGD /* Uses daemon() */
#undef CONFIG_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#if defined CONFIG_ASH || defined CONFIG_HUSH || defined CONFIG_LASH || defined CONFIG_MSH
#if defined CONFIG_FEATURE_COMMAND_EDITING
#define CONFIG_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_COMMAND_EDITING
#undef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
#undef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef CONFIG_FEATURE_SH_STANDALONE_SHELL
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#ifdef CONFIG_KILLALL
#ifndef CONFIG_KILL
#define CONFIG_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#ifndef CONFIG_INIT
#undef CONFIG_FEATURE_INITRD
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#if defined CONFIG_MOUNT && defined CONFIG_FEATURE_NFSMOUNT
#define CONFIG_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#if defined CONFIG_FEATURE_AUTOWIDTH
#ifndef CONFIG_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#if defined CONFIG_INSMOD || defined CONFIG_LSMOD
#if ! defined CONFIG_FEATURE_NEW_MODULE_INTERFACE && ! defined CONFIG_FEATURE_OLD_MODULE_INTERFACE
#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#ifdef CONFIG_UNIX2DOS
#define CONFIG_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#ifdef CONFIG_SYSLOGD
#if defined CONFIG_FEATURE_IPC_SYSLOG
#define CONFIG_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
#if defined CONFIG_ASH && defined CONFIG_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
#elif defined CONFIG_HUSH && defined CONFIG_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
#elif defined CONFIG_LASH && defined CONFIG_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
#elif defined CONFIG_MSH && defined CONFIG_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif

498
debian/Config.h-udeb vendored
View File

@ -3,142 +3,142 @@
// 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
// i.e., //#define CONFIG_BLAH
//
//
// BusyBox Applications
//#define BB_ADJTIMEX
//#define BB_AR
//#define BB_ASH
#define BB_BASENAME
#define BB_CAT
#define BB_CHGRP
#define BB_CHMOD
#define BB_CHOWN
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
//#define BB_CMP
#define BB_CP
//#define BB_CPIO
#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_DPKG
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_ENV
#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_HUSH
#define BB_ID
//#define BB_IFCONFIG
#define BB_INIT
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_KLOGD
//#define BB_LASH
//#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_MODPROBE
#define BB_MORE
#define BB_MOUNT
//#define BB_MSH
//#define BB_MT
#define BB_MV
//#define BB_NC
//#define BB_NSLOOKUP
//#define BB_PIDOF
#define BB_PING
#define BB_PIVOT_ROOT
#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_ROUTE
//#define BB_RPM2CPIO
#define BB_SED
//#define BB_SETKEYCODES
#define BB_SLEEP
#define BB_SORT
//#define BB_STTY
#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_TFTP
#define BB_TOUCH
#define BB_TR
//#define BB_TRACEROUTE
#define BB_TRUE_FALSE
#define BB_TTY
//#define BB_UNIX2DOS
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
#define BB_VI
//#define BB_WATCHDOG
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_XARGS
#define BB_YES
//#define CONFIG_ADJTIMEX
//#define CONFIG_AR
//#define CONFIG_ASH
#define CONFIG_BASENAME
#define CONFIG_CAT
#define CONFIG_CHGRP
#define CONFIG_CHMOD
#define CONFIG_CHOWN
#define CONFIG_CHROOT
#define CONFIG_CHVT
#define CONFIG_CLEAR
//#define CONFIG_CMP
#define CONFIG_CP
//#define CONFIG_CPIO
#define CONFIG_CUT
#define CONFIG_DATE
//#define CONFIG_DC
#define CONFIG_DD
//#define CONFIG_DEALLOCVT
#define CONFIG_DF
#define CONFIG_DIRNAME
#define CONFIG_DMESG
//#define CONFIG_DOS2UNIX
//#define CONFIG_DPKG
//#define CONFIG_DPKG_DEB
//#define CONFIG_DUTMP
#define CONFIG_DU
//#define CONFIG_DUMPKMAP
#define CONFIG_ECHO
#define CONFIG_ENV
#define CONFIG_EXPR
//#define CONFIG_FBSET
//#define CONFIG_FDFLUSH
#define CONFIG_FIND
#define CONFIG_FREE
#define CONFIG_FREERAMDISK
//#define CONFIG_FSCK_MINIX
//#define CONFIG_GETOPT
#define CONFIG_GREP
#define CONFIG_GUNZIP
#define CONFIG_GZIP
#define CONFIG_HALT
#define CONFIG_HEAD
//#define CONFIG_HOSTID
//#define CONFIG_HOSTNAME
//#define CONFIG_HUSH
#define CONFIG_ID
//#define CONFIG_IFCONFIG
#define CONFIG_INIT
//#define CONFIG_INSMOD
#define CONFIG_KILL
#define CONFIG_KILLALL
#define CONFIG_KLOGD
//#define CONFIG_LASH
//#define CONFIG_LENGTH
#define CONFIG_LN
//#define CONFIG_LOADACM
//#define CONFIG_LOADFONT
#define CONFIG_LOADKMAP
#define CONFIG_LOGGER
//#define CONFIG_LOGNAME
#define CONFIG_LS
#define CONFIG_LSMOD
//#define CONFIG_MAKEDEVS
#define CONFIG_MD5SUM
#define CONFIG_MKDIR
//#define CONFIG_MKFIFO
//#define CONFIG_MKFS_MINIX
#define CONFIG_MKNOD
#define CONFIG_MKSWAP
//#define CONFIG_MKTEMP
//#define CONFIG_MODPROBE
#define CONFIG_MORE
#define CONFIG_MOUNT
//#define CONFIG_MSH
//#define CONFIG_MT
#define CONFIG_MV
//#define CONFIG_NC
//#define CONFIG_NSLOOKUP
//#define CONFIG_PIDOF
#define CONFIG_PING
#define CONFIG_PIVOT_ROOT
#define CONFIG_POWEROFF
//#define CONFIG_PRINTF
#define CONFIG_PS
#define CONFIG_PWD
//#define CONFIG_RDATE
//#define CONFIG_READLINK
#define CONFIG_REBOOT
//#define CONFIG_RENICE
#define CONFIG_RESET
#define CONFIG_RM
#define CONFIG_RMDIR
//#define CONFIG_RMMOD
//#define CONFIG_ROUTE
//#define CONFIG_RPM2CPIO
#define CONFIG_SED
//#define CONFIG_SETKEYCODES
#define CONFIG_SLEEP
#define CONFIG_SORT
//#define CONFIG_STTY
#define CONFIG_SWAPONOFF
#define CONFIG_SYNC
#define CONFIG_SYSLOGD
#define CONFIG_TAIL
#define CONFIG_TAR
//#define CONFIG_TEE
//#define CONFIG_TEST
#define CONFIG_TELNET
//#define CONFIG_TFTP
#define CONFIG_TOUCH
#define CONFIG_TR
//#define CONFIG_TRACEROUTE
#define CONFIG_TRUE_FALSE
#define CONFIG_TTY
//#define CONFIG_UNIX2DOS
//#define CONFIG_UUENCODE
//#define CONFIG_UUDECODE
#define CONFIG_UMOUNT
#define CONFIG_UNIQ
#define CONFIG_UNAME
//#define CONFIG_UPDATE
#define CONFIG_UPTIME
//#define CONFIG_USLEEP
#define CONFIG_VI
//#define CONFIG_WATCHDOG
#define CONFIG_WC
#define CONFIG_WGET
#define CONFIG_WHICH
#define CONFIG_WHOAMI
#define CONFIG_XARGS
#define CONFIG_YES
// End of Applications List
//
//
@ -151,21 +151,21 @@
//
// If you enabled one or more of the shells, you may select which one
// should be run when sh is invoked:
//#define BB_FEATURE_SH_IS_ASH
//#define BB_FEATURE_SH_IS_HUSH
//#define BB_FEATURE_SH_IS_LASH
#define BB_FEATURE_SH_IS_MSH
//#define CONFIG_FEATURE_SH_IS_ASH
//#define CONFIG_FEATURE_SH_IS_HUSH
//#define CONFIG_FEATURE_SH_IS_LASH
#define CONFIG_FEATURE_SH_IS_MSH
//
// BusyBox will, by default, malloc space for its buffers. This costs code
// size for the call to xmalloc. You can use the following feature to have
// them put on the stack. For some very small machines with limited stack
// space, this can be deadly. For most folks, this works just fine...
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
//#define CONFIG_FEATURE_BUFFERS_GO_ON_STACK
// The third alternative for buffer allocation is to use BSS. This works
// beautifully for computers with a real MMU (and OS support), but wastes
// runtime RAM for uCLinux. This behavior was the only one available for
// BusyBox versions 0.48 and earlier.
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
//#define CONFIG_FEATURE_BUFFERS_GO_IN_BSS
//
// 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
@ -176,212 +176,212 @@
// 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
//#define CONFIG_FEATURE_USE_DEVPS_PATCH
//
// show verbose usage messages
//#define BB_FEATURE_VERBOSE_USAGE
//#define CONFIG_FEATURE_VERBOSE_USAGE
//
// Use termios to manipulate the screen ('more' is prettier with this on)
#define BB_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
//
// calculate terminal & column widths (for more and ls)
#define BB_FEATURE_AUTOWIDTH
#define CONFIG_FEATURE_AUTOWIDTH
//
// show username/groupnames for ls
#define BB_FEATURE_LS_USERNAME
#define CONFIG_FEATURE_LS_USERNAME
//
// show file timestamps in ls
#define BB_FEATURE_LS_TIMESTAMPS
#define CONFIG_FEATURE_LS_TIMESTAMPS
//
// enable ls -p and -F
#define BB_FEATURE_LS_FILETYPES
#define CONFIG_FEATURE_LS_FILETYPES
//
// sort the file names
#define BB_FEATURE_LS_SORTFILES
#define CONFIG_FEATURE_LS_SORTFILES
//
// enable ls -R
#define BB_FEATURE_LS_RECURSIVE
#define CONFIG_FEATURE_LS_RECURSIVE
//
// enable ls -L
#define BB_FEATURE_LS_FOLLOWLINKS
#define CONFIG_FEATURE_LS_FOLLOWLINKS
//
// Disable for a smaller (but less functional) ping
#define BB_FEATURE_FANCY_PING
#define CONFIG_FEATURE_FANCY_PING
//
// Make init use a simplified /etc/inittab file (recommended).
#define BB_FEATURE_USE_INITTAB
#define CONFIG_FEATURE_USE_INITTAB
//
//Enable init being called as /linuxrc
#define BB_FEATURE_LINUXRC
#define CONFIG_FEATURE_INITRD
//
//Have init enable core dumping for child processes (for debugging only)
//#define BB_FEATURE_INIT_COREDUMPS
//#define CONFIG_FEATURE_INIT_COREDUMPS
//
//Make sure nothing is printed to the console on boot
//#define BB_FEATURE_EXTRA_QUIET
//#define CONFIG_FEATURE_EXTRA_QUIET
//
// enable syslogd -R remotehost
#define BB_FEATURE_REMOTE_LOG
#define CONFIG_FEATURE_REMOTE_LOG
//
// enable syslogd -C
//#define BB_FEATURE_IPC_SYSLOG
//#define CONFIG_FEATURE_IPC_SYSLOG
//
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_FANCY_TAIL
#define CONFIG_FEATURE_FANCY_TAIL
//
// Enable support for loop devices in mount
#define BB_FEATURE_MOUNT_LOOP
#define CONFIG_FEATURE_MOUNT_LOOP
//
// Enable support for a real /etc/mtab file instead of /proc/mounts
//#define BB_FEATURE_MTAB_SUPPORT
//#define CONFIG_FEATURE_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
#define CONFIG_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
// (i.e., in case of an unreachable NFS system).
#define BB_FEATURE_MOUNT_FORCE
#define CONFIG_FEATURE_MOUNT_FORCE
//
// Enable support for creation of tar files.
#define BB_FEATURE_TAR_CREATE
#define CONFIG_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" and "-X" for excluding files
#define BB_FEATURE_TAR_EXCLUDE
#define CONFIG_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
#define CONFIG_FEATURE_TAR_GZIP
//
// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
#define CONFIG_FEATURE_SORT_REVERSE
//
// Enable uniqe sort
#define BB_FEATURE_SORT_UNIQUE
#define CONFIG_FEATURE_SORT_UNIQUE
//
// Enable command line editing in the shell.
// Only relevant if a shell is enabled. On by default.
#define BB_FEATURE_COMMAND_EDITING
#define CONFIG_FEATURE_COMMAND_EDITING
//
// Enable tab completion in the shell. This is now working quite nicely.
// This feature adds a bit over 4k. Only relevant if a shell is enabled.
#define BB_FEATURE_COMMAND_TAB_COMPLETION
#define CONFIG_FEATURE_COMMAND_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
//#define CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
//
//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. Off by default.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//#define CONFIG_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.
//only has meaning when CONFIG_FEATURE_SH_STANDALONE_SHELL is enabled.
// Only relevant if a shell is enabled. Off by default.
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//#define CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Uncomment this option for a fancy shell prompt that includes the
// current username and hostname. On systems that don't have usernames
// or hostnames, this can look hideous.
// Only relevant if a shell is enabled.
//#define BB_FEATURE_SH_FANCY_PROMPT
//#define CONFIG_FEATURE_SH_FANCY_PROMPT
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
//#define CONFIG_FEATURE_FBSET_FANCY
//
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//#define CONFIG_FEATURE_FBSET_READMODE
//
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
//
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//#define CONFIG_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
//#define CONFIG_FEATURE_INSMOD_VERSION_CHECKING
//
// Support for uClinux memory usage optimization, which will load the image
// directly into the kernel memory. This divides memory requrements by three.
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
// disabled...
//#define BB_FEATURE_INSMOD_LOADINKMEM
//#define CONFIG_FEATURE_INSMOD_LOADINKMEM
//
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//#define CONFIG_FEATURE_MINIX2
//
// Enable ifconfig status reporting output -- this feature adds 12k.
#define BB_FEATURE_IFCONFIG_STATUS
#define CONFIG_FEATURE_IFCONFIG_STATUS
//
// Enable ifconfig slip-specific options "keepalive" and "outfill"
//#define BB_FEATURE_IFCONFIG_SLIP
//#define CONFIG_FEATURE_IFCONFIG_SLIP
//
// Enable ifconfig options "mem_start", "io_addr", and "irq".
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//#define CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
//
// Enable ifconfig option "hw". Currently works for only with "ether".
#define BB_FEATURE_IFCONFIG_HW
#define CONFIG_FEATURE_IFCONFIG_HW
//
// 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
#define CONFIG_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_WGET_STATUSBAR
#define CONFIG_FEATURE_WGET_STATUSBAR
//
// Enable HTTP authentication in wget
#define BB_FEATURE_WGET_AUTHENTICATION
#define CONFIG_FEATURE_WGET_AUTHENTICATION
//
// 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
//#define CONFIG_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
#define CONFIG_FEATURE_HUMAN_READABLE
//
// Support for the find -type option.
#define BB_FEATURE_FIND_TYPE
#define CONFIG_FEATURE_FIND_TYPE
//
// Support for the find -perm option.
#define BB_FEATURE_FIND_PERM
#define CONFIG_FEATURE_FIND_PERM
//
// Support for the find -mtine option.
#define BB_FEATURE_FIND_MTIME
#define CONFIG_FEATURE_FIND_MTIME
//
// Support for the -A -B and -C context flags in grep
//#define BB_FEATURE_GREP_CONTEXT
//#define CONFIG_FEATURE_GREP_CONTEXT
//
// Support for the EGREP applet (alias to the grep applet)
//#define BB_FEATURE_GREP_EGREP_ALIAS
//#define CONFIG_FEATURE_GREP_EGREP_ALIAS
//
// Tell tftp what commands that should be supported.
#define BB_FEATURE_TFTP_PUT
#define BB_FEATURE_TFTP_GET
#define CONFIG_FEATURE_TFTP_PUT
#define CONFIG_FEATURE_TFTP_GET
//
// features for vi
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define BB_FEATURE_VI_SEARCH // search and replace cmds
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define BB_FEATURE_VI_SET // :set
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
#define CONFIG_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
#define CONFIG_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
#define CONFIG_FEATURE_VI_SEARCH // search and replace cmds
#define CONFIG_FEATURE_VI_USE_SIGNALS // catch signals
#define CONFIG_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
#define CONFIG_FEATURE_VI_READONLY // vi -R and "view" mode
#define CONFIG_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
#define CONFIG_FEATURE_VI_SET // :set
#define CONFIG_FEATURE_VI_WIN_RESIZE // handle window resize
//
// Enable a if you system have setuped locale
//#define BB_LOCALE_SUPPORT
//#define CONFIG_LOCALE_SUPPORT
//
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
#define BB_FEATURE_TELNET_TTYPE
#define CONFIG_FEATURE_TELNET_TTYPE
//
// End of Features List
//
@ -396,74 +396,74 @@
//
#include <features.h>
#if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__
#undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef BB_ASH /* Uses fork() */
#undef BB_HUSH /* Uses fork() */
#undef BB_LASH /* Uses fork() */
#undef BB_INIT /* Uses fork() */
#undef BB_FEATURE_TAR_GZIP /* Uses fork() */
#undef BB_SYSLOGD /* Uses daemon() */
#undef BB_KLOGD /* Uses daemon() */
#undef BB_UPDATE /* Uses daemon() */
#undef CONFIG_RPM2CPIO /* Uses gz_open(), which uses fork() */
#undef CONFIG_DPKG_DEB /* Uses gz_open(), which uses fork() */
#undef CONFIG_ASH /* Uses fork() */
#undef CONFIG_HUSH /* Uses fork() */
#undef CONFIG_LASH /* Uses fork() */
#undef CONFIG_INIT /* Uses fork() */
#undef CONFIG_FEATURE_TAR_GZIP /* Uses fork() */
#undef CONFIG_SYSLOGD /* Uses daemon() */
#undef CONFIG_KLOGD /* Uses daemon() */
#undef CONFIG_UPDATE /* Uses daemon() */
#endif
#if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH
#if defined BB_FEATURE_COMMAND_EDITING
#define BB_CMDEDIT
#if defined CONFIG_ASH || defined CONFIG_HUSH || defined CONFIG_LASH || defined CONFIG_MSH
#if defined CONFIG_FEATURE_COMMAND_EDITING
#define CONFIG_CMDEDIT
#else
#undef BB_FEATURE_COMMAND_EDITING
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_COMMAND_EDITING
#undef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
#undef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
#else
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef BB_FEATURE_SH_STANDALONE_SHELL
#undef BB_FEATURE_SH_FANCY_PROMPT
#undef CONFIG_FEATURE_SH_APPLETS_ALWAYS_WIN
#undef CONFIG_FEATURE_SH_STANDALONE_SHELL
#undef CONFIG_FEATURE_SH_FANCY_PROMPT
#endif
//
#ifdef BB_KILLALL
#ifndef BB_KILL
#define BB_KILL
#ifdef CONFIG_KILLALL
#ifndef CONFIG_KILL
#define CONFIG_KILL
#endif
#endif
//
#ifndef BB_INIT
#undef BB_FEATURE_LINUXRC
#ifndef CONFIG_INIT
#undef CONFIG_FEATURE_INITRD
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#if defined CONFIG_MOUNT && defined CONFIG_FEATURE_NFSMOUNT
#define CONFIG_NFSMOUNT
#endif
//
#if defined BB_FEATURE_AUTOWIDTH
#ifndef BB_FEATURE_USE_TERMIOS
#define BB_FEATURE_USE_TERMIOS
#if defined CONFIG_FEATURE_AUTOWIDTH
#ifndef CONFIG_FEATURE_USE_TERMIOS
#define CONFIG_FEATURE_USE_TERMIOS
#endif
#endif
//
#if defined BB_INSMOD || defined BB_LSMOD
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#if defined CONFIG_INSMOD || defined CONFIG_LSMOD
#if ! defined CONFIG_FEATURE_NEW_MODULE_INTERFACE && ! defined CONFIG_FEATURE_OLD_MODULE_INTERFACE
#define CONFIG_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
//
#ifdef BB_UNIX2DOS
#define BB_DOS2UNIX
#ifdef CONFIG_UNIX2DOS
#define CONFIG_DOS2UNIX
#endif
//
#ifdef BB_SYSLOGD
#if defined BB_FEATURE_IPC_SYSLOG
#define BB_LOGREAD
#ifdef CONFIG_SYSLOGD
#if defined CONFIG_FEATURE_IPC_SYSLOG
#define CONFIG_LOGREAD
#endif
#endif
//
#if defined BB_ASH && defined BB_FEATURE_SH_IS_ASH
#if defined CONFIG_ASH && defined CONFIG_FEATURE_SH_IS_ASH
# define shell_main ash_main
#elif defined BB_HUSH && defined BB_FEATURE_SH_IS_HUSH
#elif defined CONFIG_HUSH && defined CONFIG_FEATURE_SH_IS_HUSH
# define shell_main hush_main
#elif defined BB_LASH && defined BB_FEATURE_SH_IS_LASH
#elif defined CONFIG_LASH && defined CONFIG_FEATURE_SH_IS_LASH
# define shell_main lash_main
#elif defined BB_MSH && defined BB_FEATURE_SH_IS_MSH
#elif defined CONFIG_MSH && defined CONFIG_FEATURE_SH_IS_MSH
# define shell_main msh_main
#endif

14
debian/rules vendored
View File

@ -28,8 +28,8 @@ debian/build-stamp-busybox:
mkdir -p $(bbbd)
cp Makefile $(bbbd)
cp debian/Config.h-deb $(bbbd)/Config.h
-(cd $(bbbd); $(MAKE) "BB_SRC_DIR=../../" applet_source_list)
(cd $(bbbd); $(MAKE) USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
-(cd $(bbbd); $(MAKE) "CONFIG_SRC_DIR=../../" applet_source_list)
(cd $(bbbd); $(MAKE) USE_SYSTEM_PWD_GRP=false "CONFIG_SRC_DIR=../../")
touch debian/build-stamp-busybox
install: build
@ -39,7 +39,7 @@ install: build
dh_installdirs
# 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)
#(cd $(bbbd); $(MAKE) "CONFIG_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
@ -54,7 +54,7 @@ debian/build-stamp-busybox-static:
mkdir -p $(bbsbd)
cp Makefile $(bbsbd)
cp debian/Config.h-static $(bbsbd)/Config.h
(cd $(bbsbd); $(MAKE) DOSTATIC=true USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
(cd $(bbsbd); $(MAKE) DOSTATIC=true USE_SYSTEM_PWD_GRP=false "CONFIG_SRC_DIR=../../")
touch debian/build-stamp-busybox-static
install-static: build
@ -64,7 +64,7 @@ install-static: build
dh_installdirs
# Do not run 'make install', since we do not want all the symlinks.
# This just installes the busybox binary...
#(cd $(bbsbd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbs)" install)
#(cd $(bbsbd); $(MAKE) "CONFIG_SRC_DIR=../../" "PREFIX=../../$(bbs)" install)
mkdir -p $(bbs)/bin/
cp $(bbsbd)/busybox $(bbs)/bin/busybox
mkdir -p $(bbs)/usr/share/doc/busybox-static/busybox.lineo.com
@ -94,7 +94,7 @@ debian/build-stamp-busybox-udeb:
mkdir -p $(bbubd)
cp Makefile $(bbubd)
cp debian/Config.h-udeb $(bbubd)/Config.h
(cd $(bbubd); $(MAKE) USE_SYSTEM_PWD_GRP=false "BB_SRC_DIR=../../")
(cd $(bbubd); $(MAKE) USE_SYSTEM_PWD_GRP=false "CONFIG_SRC_DIR=../../")
touch debian/build-stamp-busybox-udeb
install-udeb: build
@ -102,7 +102,7 @@ install-udeb: build
dh_testroot
dh_clean -k
dh_installdirs
(cd $(bbubd); $(MAKE) "BB_SRC_DIR=../../" "PREFIX=../../$(bbu)" install)
(cd $(bbubd); $(MAKE) "CONFIG_SRC_DIR=../../" "PREFIX=../../$(bbu)" install)
mkdir -p $(bbu)/usr/share/man/man1/
cp $(bbubd)/docs/BusyBox.1 $(bbu)/usr/share/man/man1/busybox.1

175
deluser.c
View File

@ -1,175 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* deluser (remove lusers from the system ;) for TinyLogin
*
*
* Copyright (C) 1999 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* 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 <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
#define PASSWD_FILE "/etc/passwd"
#define GROUP_FILE "/etc/group"
/* where to start and stop deletion */
typedef struct {
size_t start;
size_t stop;
} Bounds;
/* An interesting side-effect of boundary()'s
* implementation is that the first user (typically root)
* cannot be removed. Let's call it a feature. */
static Bounds boundary(const char *buffer, const char *login)
{
char needle[256];
char *start;
char *stop;
Bounds b;
snprintf(needle, 256, "\n%s", login);
needle[255] = 0;
start = strstr(buffer, needle);
if (!start) {
b.start = 0;
b.stop = 0;
return b;
}
start++;
stop = index(start, '\n'); /* index is a BSD-ism */
b.start = start - buffer;
b.stop = stop - buffer;
return b;
}
/* grep -v ^login (except it only deletes the first match) */
/* ...in fact, I think I'm going to simplify this later */
static int del_line_matching(char *login, char *filename)
{
char *buffer;
FILE *passwd;
size_t len;
Bounds b;
struct stat statbuf;
/* load into buffer */
passwd = fopen(filename, "r");
if (!passwd) {
return 1;
}
stat(filename, &statbuf);
len = statbuf.st_size;
buffer = (char *) malloc(len * sizeof(char));
if (!buffer) {
fclose(passwd);
return 1;
}
fread(buffer, len, sizeof(char), passwd);
fclose(passwd);
/* find the user to remove */
b = boundary(buffer, login);
if (b.stop == 0) {
free(buffer);
return 1;
}
/* write the file w/o the user */
passwd = fopen(filename, "w");
if (!passwd) {
return 1;
}
fwrite(buffer, (b.start - 1), sizeof(char), passwd);
fwrite(&buffer[b.stop], (len - b.stop), sizeof(char), passwd);
fclose(passwd);
return 0;
}
/* ________________________________________________________________________ */
int delgroup_main(int argc, char **argv)
{
/* int successful; */
int failure;
if (argc != 2) {
show_usage();
} else {
failure = del_line_matching(argv[1], GROUP_FILE);
#ifdef TLG_FEATURE_SHADOWPASSWDS
if (access(GSHADOW_FILE, W_OK) == 0) {
/* EDR the |= works if the error is not 0, so he had it wrong */
failure |= del_line_matching(argv[1], GSHADOW_FILE);
}
#endif /* TLG_FEATURE_SHADOWPASSWDS */
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: Group could not be removed\n", argv[1]);
}
}
return (EXIT_SUCCESS);
}
/* ________________________________________________________________________ */
int deluser_main(int argc, char **argv)
{
/* int successful; */
int failure;
if (argc != 2) {
show_usage();
} else {
failure = del_line_matching(argv[1], PASSWD_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], PASSWD_FILE);
}
#ifdef TLG_FEATURE_SHADOWPASSWDS
failure = del_line_matching(argv[1], SHADOW_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], SHADOW_FILE);
}
#endif /* TLG_FEATURE_SHADOWPASSWDS */
failure = del_line_matching(argv[1], GROUP_FILE);
/* if (!successful) { */
if (failure) {
error_msg_and_die("%s: User could not be removed from %s\n",
argv[1], GROUP_FILE);
}
}
return (EXIT_SUCCESS);
}
/* $Id: deluser.c,v 1.1 2001/08/21 16:18:59 andersen Exp $ */

158
df.c
View File

@ -1,158 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <getopt.h>
#include "busybox.h"
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
static unsigned long df_disp_hr = KILOBYTE;
#endif
static int do_df(char *device, const char *mount_point)
{
struct statfs s;
long blocks_used;
long blocks_percent_used;
if (statfs(mount_point, &s) != 0) {
perror_msg("%s", mount_point);
return FALSE;
}
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
if(blocks_used == 0)
blocks_percent_used = 0;
else {
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
}
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
device = find_real_root_device_name(device);
if(device==NULL)
return FALSE;
}
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
blocks_percent_used, mount_point);
#endif
}
return TRUE;
}
extern int df_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
while ((opt = getopt(argc, argv, "k"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h':
df_disp_hr = 0;
strcpy(disp_units_hdr, " Size");
break;
case 'm':
df_disp_hr = MEGABYTE;
strcpy(disp_units_hdr, "1M-blocks");
break;
#endif
case 'k':
/* default display is kilobytes */
break;
default:
show_usage();
}
}
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
"Used", "Available", "Use%", "Mounted on");
if(optind < argc) {
struct mntent *mount_entry;
for(i = optind; i < argc; i++)
{
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.", argv[i]);
status = EXIT_FAILURE;
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
} else {
FILE *mount_table;
struct mntent *mount_entry;
mount_table = setmntent(mtab_file, "r");
if (mount_table == 0) {
perror_msg("%s", mtab_file);
return EXIT_FAILURE;
}
while ((mount_entry = getmntent(mount_table))) {
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
status = EXIT_FAILURE;
}
endmntent(mount_table);
}
return status;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

View File

@ -1,40 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* 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
*
*/
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "busybox.h"
extern int dirname_main(int argc, char **argv)
{
if ((argc < 2) || (**(argv + 1) == '-'))
show_usage();
argv++;
puts (dirname (argv[0]));
return EXIT_SUCCESS;
}

95
dmesg.c
View File

@ -1,95 +0,0 @@
/* vi: set sw=4 ts=4: */
/* dmesg.c -- Print out the contents of the kernel ring buffer
* Created: Sat Oct 9 16:19:47 1993
* Revised: Thu Oct 28 21:52:17 1993 by faith@cs.unc.edu
* Copyright 1993 Theodore Ts'o (tytso@athena.mit.edu)
* This program comes with ABSOLUTELY NO WARRANTY.
* Modifications by Rick Sladkey (jrs@world.std.com)
* Larger buffersize 3 June 1998 by Nicolai Langfeldt, based on a patch
* by Peeter Joot. This was also suggested by John Hudson.
* 1999-02-22 Arkadiusz Mikiewicz <misiek@misiek.eu.org>
* - added Native Language Support
*
* from util-linux -- adapted for busybox by
* Erik Andersen <andersee@debian.org>. I ripped out Native Language
* Support, replaced getopt, added some gotos for redundant stuff.
*/
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#if __GNU_LIBRARY__ < 5
# ifdef __alpha__
# define klogctl syslog
# endif
#else
# include <sys/klog.h>
#endif
#include "busybox.h"
int dmesg_main(int argc, char **argv)
{
char *buf;
int c;
int bufsize = 8196;
int i;
int n;
int level = 0;
int lastc;
int cmd = 3;
while ((c = getopt(argc, argv, "cn:s:")) != EOF) {
switch (c) {
case 'c':
cmd = 4;
break;
case 'n':
cmd = 8;
if (optarg == NULL)
show_usage();
level = atoi(optarg);
break;
case 's':
if (optarg == NULL)
show_usage();
bufsize = atoi(optarg);
break;
default:
show_usage();
}
}
if (optind < argc) {
show_usage();
}
if (cmd == 8) {
if (klogctl(cmd, NULL, level) < 0)
perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
if (bufsize < 4096)
bufsize = 4096;
buf = (char *) xmalloc(bufsize);
if ((n = klogctl(cmd, buf, bufsize)) < 0)
perror_msg_and_die("klogctl");
lastc = '\n';
for (i = 0; i < n; i++) {
if (lastc == '\n' && buf[i] == '<') {
i++;
while (buf[i] >= '0' && buf[i] <= '9')
i++;
if (buf[i] == '>')
i++;
}
lastc = buf[i];
putchar(lastc);
}
if (lastc != '\n')
putchar('\n');
return EXIT_SUCCESS;
}

View File

@ -251,7 +251,7 @@ a command. I<REQUIRED>
=item B<full>
This should contain descriptions of each option. This will also
be displayed along with the trivial help if BB_FEATURE_TRIVIAL_HELP
be displayed along with the trivial help if CONFIG_FEATURE_TRIVIAL_HELP
is disabled. I<REQUIRED>
=item B<notes>
@ -284,4 +284,4 @@ John BEPPU <beppu@lineo.com>
=cut
# $Id: autodocifier.pl,v 1.21 2001/04/17 17:09:34 beppu Exp $
# $Id: autodocifier.pl,v 1.22 2001/10/24 04:59:20 andersen Exp $

View File

@ -295,7 +295,6 @@ listed in the order I happen to add them to the web page:
<ul>
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian installer (boot floppies) project</a>
<li> <a href="ftp://ftp.slackware.com/pub/slackware/slackware-8.0/source/rootdsks/">Slackware 8.0 installer</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>
@ -325,7 +324,7 @@ listed in the order I happen to add them to the web page:
<li> <a href="http://dutnux.sourceforge.net/">DutNux</a>
<li> <a href="http://www.cachier.com/">Cachier</a>
<li> <a href="http://www.microwerks.net/~hugo/mindi/">Mindi</a>
<li> <a href="http://www.tzi.de/~pharao90/ttylinux/">ttylinux</a>
</ul>
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to

View File

@ -74,12 +74,12 @@
<li> <b>Busybox Boot-Floppy Image</b>
<p>Because you asked for it, we have made available a <a href=
"ftp://opensource.lineo.com/busybox/busybox.floppy.img"> Busybox boot floppy
"ftp://oss.lineo.com/busybox/busybox.floppy.img"> Busybox boot floppy
image</a>. Here's how you use it:
<ol>
<li> <a href= "ftp://opensource.lineo.com/busybox/busybox.floppy.img">
<li> <a href= "ftp://oss.lineo.com/busybox/busybox.floppy.img">
Download the image</a>
<li> dd it onto a floppy like so: <tt> dd if=busybox.floppy.img
@ -203,13 +203,13 @@
details).
<p>
Also, some exciting infrastructure news! Busybox now has its own
<a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>,
<a href="http://oss.lineo.com/lists/busybox/">mailing list</a>,
publically browsable
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
<a href="http://oss.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
<a href="http://oss.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>.
<a href="http://oss.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
@ -398,13 +398,10 @@
Freshmeat AppIndex record for BusyBox</A>
<p>
<li> <a href="http://opensource.lineo.com/software.html">Other cool embedded software</a>.
<li> <a href="http://oss.lineo.com/software.html">Cool embedded software</a>.
<p>
<li> <a href="http://opensource.lineo.com/">opensource.lineo.com</a>.
<p>
<li> <A HREF="http://www.lineo.com/">Lineo</A> is sponsoring BusyBox development.
<li> <a href="http://oss.lineo.com/">oss.lineo.com</a>.
<p>
</ul>
@ -425,8 +422,8 @@
<TD>
<font size="-1" face="arial, helvetica, sans-serif">
Mail all comments, insults, suggestions and bribes to
<a href="mailto:andersen@lineo.com">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000, Erik Andersen.
<a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
The Busybox logo is copyright 1999,2000,2001 Erik Andersen.
</font>
</TD>

View File

@ -109,7 +109,7 @@ order, or else it will break the binary-search lookup algorithm in busybox.c
and the Gods of BusyBox smite you. Yea, verily:
/* all programs above here are alphabetically "less than" 'mu' */
#ifdef BB_MU
#ifdef CONFIG_MU
APPLET("mu", mu_main, _BB_DIR_USR_BIN, mu_usage)
#endif
/* all programs below here are alphabetically "greater than" 'mu' */
@ -117,7 +117,7 @@ and the Gods of BusyBox smite you. Yea, verily:
Finally, add a define for your applet to Config.h:
#define BB_MU
#define CONFIG_MU
Documentation

View File

@ -252,7 +252,7 @@ files, you can do the following in the busybox directory:
If you want to convert all the non-K&R vars in your file all at once, follow
these steps:
- In the busybox directory type 'scripts/mk2knr.pl files-to-convert'. This
- In the busybox directory type 'examples/mk2knr.pl files-to-convert'. This
does not do the actual conversion, rather, it generates a script called
'convertme.pl' that shows what will be converted, giving you a chance to
review the changes beforehand.
@ -269,7 +269,7 @@ these steps:
Please be aware of changes that have cascading effects into other files. For
example, if you're changing the name of something in, say utility.c, you
should probably run 'scripts/mk2knr.pl utility.c' at first, but when you run
should probably run 'examples/mk2knr.pl utility.c' at first, but when you run
the 'convertme.pl' script you should run it on _all_ files like so:
'./convertme.pl *.[ch]'.
@ -343,7 +343,7 @@ used in the code.
ret = my_func(bar, baz);
if (!ret)
return -1;
#ifdef BB_FEATURE_FUNKY
#ifdef CONFIG_FEATURE_FUNKY
maybe_do_funky_stuff(bar, baz);
#endif
@ -351,7 +351,7 @@ used in the code.
(in .h header file)
#ifdef BB_FEATURE_FUNKY
#ifdef CONFIG_FEATURE_FUNKY
static inline void maybe_do_funky_stuff (int bar, int baz)
{
/* lotsa code in here */
@ -487,7 +487,7 @@ very limited stack space (e.g., uCLinux).
A macro is declared in busybox.h that implements compile-time selection
between xmalloc() and stack creation, so you can code the line in question as
RESERVE_BB_BUFFER(buffer, BUFSIZ);
RESERVE_CONFIG_BUFFER(buffer, BUFSIZ);
and the right thing will happen, based on your configuration.

View File

@ -1,194 +0,0 @@
/*
* dos2unix for BusyBox
*
* dos2unix '\n' convertor 0.5.0
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
* All rights reserved.
*
* dos2unix filters reading input from stdin and writing output to stdout.
* Without arguments it reverts the format (e.i. if source is in UNIX format,
* output is in DOS format and vice versa).
*
* 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.
*
* See the COPYING file for license information.
*/
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
/* We are making a lame pseudo-random string generator here. in
* convert(), each pass through the while loop will add more and more
* stuff into value, which is _supposed_ to wrap. We don't care about
* it being accurate. We care about it being messy, since we then mod
* it by the sizeof(letters) and then use that as an index into letters
* to pick a random letter to add to out temporary file. */
typedef unsigned long int bb_uint64_t;
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
char tempFn[BUFSIZ];
static bb_uint64_t value=0;
FILE *in = stdin, *out = stdout;
if (fn != NULL) {
if ((in = wfopen(fn, "rw")) == NULL) {
return -1;
}
strcpy(tempFn, fn);
c = strlen(tempFn);
tempFn[c] = '.';
while(1) {
if (c >=BUFSIZ)
error_msg_and_die("unique name not found");
/* Get some semi random stuff to try and make a
* random filename based (and in the same dir as)
* the input file... */
gettimeofday (&tv, NULL);
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
tempFn[++c] = letters[value % 62];
tempFn[c+1] = '\0';
value /= 62;
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
continue;
}
out = fdopen(fd, "w+");
if (!out) {
close(fd);
remove(tempFn);
continue;
}
break;
}
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
remove(tempFn);
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
remove(tempFn);
if ((fclose(in) < 0) || (fclose(out) < 0)) {
perror_msg(NULL);
return -2;
}
return 0;
}
if (!ConvType) {
ConvType = CT_UNIX2DOS;
}
if (ConvType == CT_UNIX2DOS) {
fputc('\r', out);
}
fputc('\n', out);
break;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
perror_msg(NULL);
remove(tempFn);
return -2;
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
return 0;
}
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}
if (argv[0][0]=='u') {
ConvType = CT_UNIX2DOS;
}
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
case 'd':
ConvType = CT_UNIX2DOS;
break;
case 'u':
ConvType = CT_DOS2UNIX;
break;
default:
show_usage();
}
}
if (optind < argc) {
while(optind < argc)
if ((o = convert(argv[optind++], ConvType)) < 0)
break;
}
else
o = convert(NULL, ConvType);
return o;
}

1509
dpkg.c

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +0,0 @@
/*
* 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 Library 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 <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
extern int dpkg_deb_main(int argc, char **argv)
{
char *prefix = NULL;
char *filename = NULL;
char *output_buffer = NULL;
int opt = 0;
int arg_type = 0;
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
const int arg_type_prefix = 1;
const int arg_type_field = 2;
const int arg_type_filename = 4;
// const int arg_type_un_ar_gz = 8;
while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
switch (opt) {
case 'c':
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_verbose_list;
break;
case 'e':
arg_type = arg_type_prefix;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'f':
arg_type = arg_type_field;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
filename = xstrdup("./control");
break;
case 't': /* --fsys-tarfile, i just made up this short name */
/* Integrate the functionality needed with some code from ar.c */
error_msg_and_die("Option disabled");
// arg_type = arg_type_un_ar_gz;
break;
case 'X':
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
deb_extract_funct |= extract_list;
case 'x':
arg_type = arg_type_prefix;
deb_extract_funct |= extract_data_tar_gz;
deb_extract_funct |= extract_all_to_fs;
break;
case 'I':
arg_type = arg_type_filename;
deb_extract_funct |= extract_control_tar_gz;
deb_extract_funct |= extract_one_to_buffer;
break;
default:
show_usage();
}
}
if (optind == argc) {
show_usage();
}
/* Workout where to extract the files */
if (arg_type == arg_type_prefix) {
/* argument is a dir name */
if ((optind + 1) == argc ) {
prefix = xstrdup("./DEBIAN/");
} else {
prefix = (char *) xmalloc(strlen(argv[optind + 1]) + 2);
strcpy(prefix, argv[optind + 1]);
/* Make sure the directory has a trailing '/' */
if (last_char_is(prefix, '/') == NULL) {
strcat(prefix, "/");
}
}
mkdir(prefix, 0777);
}
if (arg_type == arg_type_filename) {
if ((optind + 1) != argc) {
filename = xstrdup(argv[optind + 1]);
} else {
error_msg_and_die("-I currently requires a filename to be specified");
}
}
output_buffer = deb_extract(argv[optind], stdout, deb_extract_funct, prefix, filename);
if ((arg_type == arg_type_filename) && (output_buffer != NULL)) {
puts(output_buffer);
}
else if (arg_type == arg_type_field) {
char *field = NULL;
char *name;
char *value;
int field_start = 0;
while (1) {
field_start += read_package_field(&output_buffer[field_start], &name, &value);
if (name == NULL) {
break;
}
if (strcmp(name, argv[optind + 1]) == 0) {
puts(value);
}
free(field);
}
}
return(EXIT_SUCCESS);
}

257
du.c
View File

@ -1,257 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
* 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 <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
#include <errno.h>
#include "busybox.h"
#ifdef BB_FEATURE_HUMAN_READABLE
static unsigned long disp_hr = KILOBYTE;
#endif
typedef void (Display) (long, char *);
static int du_depth = 0;
static int count_hardlinks = 0;
static Display *print;
static void print_normal(long size, char *filename)
{
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
#endif
}
static void print_summary(long size, char *filename)
{
if (du_depth == 1) {
print_normal(size, filename);
}
}
#define HASH_SIZE 311 /* Should be prime */
#define hash_inode(i) ((i) % HASH_SIZE)
typedef struct ino_dev_hash_bucket_struct {
struct ino_dev_hash_bucket_struct *next;
ino_t ino;
dev_t dev;
char name[1];
} ino_dev_hashtable_bucket_t;
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
/*
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
* `ino_dev_hashtable', else return 0
*
* If NAME is a non-NULL pointer to a character pointer, and there is
* a match, then set *NAME to the value of the name slot in that
* bucket.
*/
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
{
ino_dev_hashtable_bucket_t *bucket;
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
while (bucket != NULL) {
if ((bucket->ino == statbuf->st_ino) &&
(bucket->dev == statbuf->st_dev))
{
if (name) *name = bucket->name;
return 1;
}
bucket = bucket->next;
}
return 0;
}
/* Add statbuf to statbuf hash table */
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
{
int i;
size_t s;
ino_dev_hashtable_bucket_t *bucket;
i = hash_inode(statbuf->st_ino);
s = name ? strlen(name) : 0;
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
bucket->ino = statbuf->st_ino;
bucket->dev = statbuf->st_dev;
if (name)
strcpy(bucket->name, name);
else
bucket->name[0] = '\0';
bucket->next = ino_dev_hashtable[i];
ino_dev_hashtable[i] = bucket;
}
/* Clear statbuf hash table */
static void reset_ino_dev_hashtable(void)
{
int i;
ino_dev_hashtable_bucket_t *bucket;
for (i = 0; i < HASH_SIZE; i++) {
while (ino_dev_hashtable[i] != NULL) {
bucket = ino_dev_hashtable[i]->next;
free(ino_dev_hashtable[i]);
ino_dev_hashtable[i] = bucket;
}
}
}
/* tiny recursive du */
static long du(char *filename)
{
struct stat statbuf;
long sum;
if ((lstat(filename, &statbuf)) != 0) {
perror_msg("%s", filename);
return 0;
}
du_depth++;
sum = (statbuf.st_blocks >> 1);
/* Don't add in stuff pointed to by symbolic links */
if (S_ISLNK(statbuf.st_mode)) {
sum = 0L;
if (du_depth == 1) {
}
}
if (S_ISDIR(statbuf.st_mode)) {
DIR *dir;
struct dirent *entry;
char *newfile;
dir = opendir(filename);
if (!dir) {
du_depth--;
return 0;
}
newfile = last_char_is(filename, '/');
if (newfile)
*newfile = '\0';
while ((entry = readdir(dir))) {
char *name = entry->d_name;
if ((strcmp(name, "..") == 0)
|| (strcmp(name, ".") == 0)) {
continue;
}
newfile = concat_path_file(filename, name);
sum += du(newfile);
free(newfile);
}
closedir(dir);
print(sum, filename);
}
else if (statbuf.st_nlink > 1 && !count_hardlinks) {
/* Add files with hard links only once */
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
sum = 0L;
if (du_depth == 1)
print(sum, filename);
}
else {
add_to_ino_dev_hashtable(&statbuf, NULL);
}
}
du_depth--;
return sum;
}
int du_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int i;
int c;
/* default behaviour */
print = print_normal;
/* parse argv[] */
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
switch (c) {
case 's':
print = print_summary;
break;
case 'l':
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
#endif
case 'k': break;
default:
show_usage();
}
}
/* go through remaining args (if any) */
if (optind >= argc) {
if (du(".") == 0)
status = EXIT_FAILURE;
} else {
long sum;
for (i=optind; i < argc; i++) {
sum = du(argv[i]);
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
}
}
return status;
}
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/

View File

@ -1,95 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini dumpkmap implementation for busybox
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
* 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 <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include "busybox.h"
/* From <linux/kd.h> */
struct kbentry {
unsigned char kb_table;
unsigned char kb_index;
unsigned short kb_value;
};
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
show_usage();
}
fd = open(CURRENT_VC, O_RDWR);
if (fd < 0) {
perror_msg("Error opening " CURRENT_VC);
return EXIT_FAILURE;
}
write(1, magic, 7);
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
flags[0]=1;
flags[1]=1;
flags[2]=1;
flags[4]=1;
flags[5]=1;
flags[6]=1;
flags[8]=1;
flags[9]=1;
flags[10]=1;
flags[12]=1;
/* dump flags */
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
}
}
}
}
close(fd);
return EXIT_SUCCESS;
}

64
dutmp.c
View File

@ -1,64 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
*
* dutmp
* Takes utmp formated file on stdin and dumps it's contents
* out in colon delimited fields. Easy to 'cut' for shell based
* versions of 'who', 'last', etc. IP Addr is output in hex,
* little endian on x86.
*
* Modified to support all sorts of libcs by
* Erik Andersen <andersen@lineo.com>
*/
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <utmp.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int dutmp_main(int argc, char **argv)
{
int file;
struct utmp ut;
if (argc<2) {
file = fileno(stdin);
} else if (*argv[1] == '-' ) {
show_usage();
} else {
file = open(argv[1], O_RDONLY);
if (file < 0) {
perror_msg_and_die(io_error, argv[1]);
}
}
/* Kludge around the fact that the binary format for utmp has changed. */
#if __GNU_LIBRARY__ < 5 || defined __UCLIBC__
/* Linux libc5 */
while (read(file, (void*)&ut, sizeof(struct utmp))) {
printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ctime(&(ut.ut_time)),
(long)ut.ut_addr);
}
#else
/* Glibc, uClibc, etc. */
while (read(file, (void*)&ut, sizeof(struct utmp))) {
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
ut.ut_session,
ut.ut_tv.tv_sec, ut.ut_tv.tv_usec,
ut.ut_addr);
}
#endif
return EXIT_SUCCESS;
}

152
echo.c
View File

@ -1,152 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* echo implementation for busybox
*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* 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
*
* Original copyright notice is retained at the end of this file.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
extern int
echo_main(int argc, char** argv)
{
int nflag = 0;
int eflag = 0;
/* Skip argv[0]. */
argc--;
argv++;
while (argc > 0 && *argv[0] == '-')
{
register char *temp;
register int ix;
/*
* 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 (ix = 0; temp[ix]; ix++)
{
if (strrchr("neE", temp[ix]) == 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++;
}
just_echo:
while (argc > 0) {
const 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);
}
argc--;
argv++;
if (argc > 0)
putchar(' ');
}
if (!nflag)
putchar('\n');
fflush(stdout);
return EXIT_SUCCESS;
}
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* 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>
*
* 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.
*
* @(#)echo.c 8.1 (Berkeley) 5/31/93
*/

36
editors/Makefile Normal file
View File

@ -0,0 +1,36 @@
# Makefile for busybox
#
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
# 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
#
TOPDIR :=..
L_TARGET := editors.a
obj-y :=
obj-n :=
obj- :=
obj-$(CONFIG_SED) += sed.o
obj-$(CONFIG_VI) += vi.o
# Hand off to toplevel Rules.mak
include $(TOPDIR)/Rules.mak
clean:
rm -f $(L_TARGET) *.o core

12
editors/config.in Normal file
View File

@ -0,0 +1,12 @@
#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#
mainmenu_option next_comment
comment 'Editors'
bool 'sed' CONFIG_SED
bool 'vi' CONFIG_VI
endmenu

View File

@ -1,8 +1,8 @@
/*
* sed.c - very minimalist version of sed
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
* Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley
* Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org>
*
* 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
@ -104,7 +104,7 @@ static int ncmds = 0; /* number of sed commands */
/*static char *cur_file = NULL;*/ /* file currently being processed XXX: do I need this? */
#ifdef BB_FEATURE_CLEAN_UP
#ifdef CONFIG_FEATURE_CLEAN_UP
static void destroy_cmd_strs()
{
if (sed_cmds == NULL)
@ -791,7 +791,7 @@ extern int sed_main(int argc, char **argv)
{
int opt;
#ifdef BB_FEATURE_CLEAN_UP
#ifdef CONFIG_FEATURE_CLEAN_UP
/* destroy command strings on exit */
if (atexit(destroy_cmd_strs) == -1)
perror_msg_and_die("atexit");

File diff suppressed because it is too large Load Diff

106
env.c
View File

@ -1,106 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* env implementation for busybox
*
* Copyright (c) 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* 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
*
* Original copyright notice is retained at the end of this file.
*
* Modified for BusyBox by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*/
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
extern int env_main(int argc, char** argv)
{
char **ep, *p;
char *cleanenv[1];
int ignore_environment = 0;
int ch;
while ((ch = getopt(argc, argv, "+iu:")) != -1) {
switch(ch) {
case 'i':
ignore_environment = 1;
break;
case 'u':
unsetenv(optarg);
break;
default:
show_usage();
}
}
if (optind != argc && !strcmp(argv[optind], "-")) {
ignore_environment = 1;
argv++;
}
if (ignore_environment) {
environ = cleanenv;
cleanenv[0] = NULL;
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
if (putenv(*argv) < 0)
perror_msg_and_die("%s", *argv);
if (*argv) {
execvp(*argv, argv);
perror_msg_and_die("%s", *argv);
}
for (ep = environ; *ep; ep++)
puts(*ep);
return 0;
}
/*
* Copyright (c) 1988, 1993, 1994
* The 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.
*/

View File

@ -1,7 +1,7 @@
# /etc/inittab init(8) configuration for BusyBox
#
# Copyright (C) 1999 by Lineo, inc. Written by Erik Andersen
# <andersen@lineo.com>, <andersee@debian.org>
# Copyright (C) 1999 by Lineo, inc. and Erik Andersen
# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
#
#
# Note, BusyBox init doesn't support runlevels. The runlevels field is

View File

@ -44,7 +44,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+/*
+ * linux/drivers/char/devmtab.c
+ *
+ * Copyright (C) 2000 Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * May be copied or modified under the terms of the GNU General Public License.
+ * See linux/COPYING for more information.
@ -343,7 +343,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+/*
+ * linux/drivers/char/devps.c
+ *
+ * Copyright (C) 2000 Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * May be copied or modified under the terms of the GNU General Public License.
+ * See linux/COPYING for more information.
@ -900,7 +900,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+ * devmtab tester
+ *
+ *
+ * Copyright (C) 2000 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * 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
@ -1020,7 +1020,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+ * Mini ps implementation for use with the Linux devps driver
+ *
+ *
+ * Copyright (C) 2000 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * 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
@ -1311,7 +1311,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+/*
+ * -- <linux/devmtab.h>
+ *
+ * Copyright (C) 2000 Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * May be copied or modified under the terms of the GNU General Public License.
+ * See linux/COPYING for more information.
@ -1369,7 +1369,7 @@ diff -urN --exclude=.version --exclude=.config* --exclude=.*depend linux-2.2.18-
+/*
+ * -- <linux/devps.h>
+ *
+ * Copyright (C) 2000 Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ *
+ * May be copied or modified under the terms of the GNU General Public License.
+ * See linux/COPYING for more information.

View File

@ -3,7 +3,7 @@
# @(#) mk2knr.pl - generates a perl script that converts lexemes to K&R-style
#
# How to use this script:
# - In the busybox directory type 'scripts/mk2knr.pl files-you-want-to-convert'
# - In the busybox directory type 'examples/mk2knr.pl files-to-convert'
# - Review the 'convertme.pl' script generated and remove / edit any of the
# substitutions in there (please especially check for false positives)
# - Type './convertme.pl same-files-as-before'

535
expr.c
View File

@ -1,535 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini expr implementation for busybox
*
* based on GNU expr Mike Parker.
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
*
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
*
* 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
*
*/
/* This program evaluates expressions. Each token (operator, operand,
* parenthesis) of the expression must be a seperate argument. The
* parser used is a reasonably general one, though any incarnation of
* it is language-specific. It is especially nice for expressions.
*
* No parse tree is needed; a new node is evaluated immediately.
* One function can handle multiple operators all of equal precedence,
* provided they all associate ((x op x) op x). */
/* no getopt needed */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
#include <sys/types.h>
#include "busybox.h"
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
int i;
char *s;
} u;
};
typedef struct valinfo VALUE;
/* The arguments given to the program, minus the program name. */
static char **args;
static VALUE *docolon (VALUE *sv, VALUE *pv);
static VALUE *eval (void);
static VALUE *int_value (int i);
static VALUE *str_value (char *s);
static int nextarg (char *str);
static int null (VALUE *v);
static int toarith (VALUE *v);
static void freev (VALUE *v);
static void tostring (VALUE *v);
int expr_main (int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
error_msg_and_die("too few arguments");
}
args = argv + 1;
v = eval ();
if (*args)
error_msg_and_die ("syntax error");
if (v->type == integer)
printf ("%d\n", v->u.i);
else
puts (v->u.s);
exit (null (v));
}
/* Return a VALUE for I. */
static VALUE *int_value (int i)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = integer;
v->u.i = i;
return v;
}
/* Return a VALUE for S. */
static VALUE *str_value (char *s)
{
VALUE *v;
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strdup (s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev (VALUE *v)
{
if (v->type == string)
free (v->u.s);
free (v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null (VALUE *v)
{
switch (v->type) {
case integer:
return v->u.i == 0;
case string:
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
default:
abort ();
}
}
/* Coerce V to a string value (can't fail). */
static void tostring (VALUE *v)
{
char *temp;
if (v->type == integer) {
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
sprintf (temp, "%d", v->u.i);
v->u.s = temp;
v->type = string;
}
}
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static int toarith (VALUE *v)
{
int i;
switch (v->type) {
case integer:
return 1;
case string:
i = 0;
/* Don't interpret the empty string as an integer. */
if (v->u.s == 0)
return 0;
i = atoi(v->u.s);
free (v->u.s);
v->u.i = i;
v->type = integer;
return 1;
default:
abort ();
}
}
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int
nextarg (char *str)
{
if (*args == NULL)
return 0;
return strcmp (*args, str) == 0;
}
/* The comparison operator handling functions. */
#define cmpf(name, rel) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (l->type == string || r->type == string) { \
tostring (l); \
tostring (r); \
return strcmp (l->u.s, r->u.s) rel 0; \
} \
else \
return l->u.i rel r->u.i; \
}
cmpf (less_than, <)
cmpf (less_equal, <=)
cmpf (equal, ==)
cmpf (not_equal, !=)
cmpf (greater_equal, >=)
cmpf (greater_than, >)
#undef cmpf
/* The arithmetic operator handling functions. */
#define arithf(name, op) \
static \
int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ("non-numeric argument"); \
return l->u.i op r->u.i; \
}
#define arithdivf(name, op) \
static int name (l, r) VALUE *l; VALUE *r; \
{ \
if (!toarith (l) || !toarith (r)) \
error_msg_and_die ( "non-numeric argument"); \
if (r->u.i == 0) \
error_msg_and_die ( "division by zero"); \
return l->u.i op r->u.i; \
}
arithf (plus, +)
arithf (minus, -)
arithf (multiply, *)
arithdivf (divide, /)
arithdivf (mod, %)
#undef arithf
#undef arithdivf
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon (VALUE *sv, VALUE *pv)
{
VALUE *v;
const char *errmsg;
struct re_pattern_buffer re_buffer;
struct re_registers re_regs;
int len;
tostring (sv);
tostring (pv);
if (pv->u.s[0] == '^') {
fprintf (stderr, "\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored",
pv->u.s);
}
len = strlen (pv->u.s);
memset (&re_buffer, 0, sizeof (re_buffer));
memset (&re_regs, 0, sizeof (re_regs));
re_buffer.allocated = 2 * len;
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
re_buffer.translate = 0;
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
error_msg_and_die("%s", errmsg);
}
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (len >= 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
sv->u.s[re_regs.end[1]] = '\0';
v = str_value (sv->u.s + re_regs.start[1]);
}
else
v = int_value (len);
}
else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
v = str_value ("");
else
v = int_value (0);
}
free (re_buffer.buffer);
return v;
}
/* Handle bare operands and ( expr ) syntax. */
static VALUE *eval7 (void)
{
VALUE *v;
if (!*args)
error_msg_and_die ( "syntax error");
if (nextarg ("(")) {
args++;
v = eval ();
if (!nextarg (")"))
error_msg_and_die ( "syntax error");
args++;
return v;
}
if (nextarg (")"))
error_msg_and_die ( "syntax error");
return str_value (*args++);
}
/* Handle match, substr, index, length, and quote keywords. */
static VALUE *eval6 (void)
{
VALUE *l, *r, *v, *i1, *i2;
if (nextarg ("quote")) {
args++;
if (!*args)
error_msg_and_die ( "syntax error");
return str_value (*args++);
}
else if (nextarg ("length")) {
args++;
r = eval6 ();
tostring (r);
v = int_value (strlen (r->u.s));
freev (r);
return v;
}
else if (nextarg ("match")) {
args++;
l = eval6 ();
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
return v;
}
else if (nextarg ("index")) {
args++;
l = eval6 ();
r = eval6 ();
tostring (l);
tostring (r);
v = int_value (strcspn (l->u.s, r->u.s) + 1);
if (v->u.i == (int) strlen (l->u.s) + 1)
v->u.i = 0;
freev (l);
freev (r);
return v;
}
else if (nextarg ("substr")) {
args++;
l = eval6 ();
i1 = eval6 ();
i2 = eval6 ();
tostring (l);
if (!toarith (i1) || !toarith (i2)
|| i1->u.i > (int) strlen (l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value ("");
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
l->u.s + i1->u.i - 1, i2->u.i);
v->u.s[i2->u.i] = 0;
}
freev (l);
freev (i1);
freev (i2);
return v;
}
else
return eval7 ();
}
/* Handle : operator (pattern matching).
Calls docolon to do the real work. */
static VALUE *eval5 (void)
{
VALUE *l, *r, *v;
l = eval6 ();
while (nextarg (":")) {
args++;
r = eval6 ();
v = docolon (l, r);
freev (l);
freev (r);
l = v;
}
return l;
}
/* Handle *, /, % operators. */
static VALUE *eval4 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval5 ();
while (1) {
if (nextarg ("*"))
fxn = multiply;
else if (nextarg ("/"))
fxn = divide;
else if (nextarg ("%"))
fxn = mod;
else
return l;
args++;
r = eval5 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle +, - operators. */
static VALUE *eval3 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval4 ();
while (1) {
if (nextarg ("+"))
fxn = plus;
else if (nextarg ("-"))
fxn = minus;
else
return l;
args++;
r = eval4 ();
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle comparisons. */
static VALUE *eval2 (void)
{
VALUE *l, *r;
int (*fxn) (), val;
l = eval3 ();
while (1) {
if (nextarg ("<"))
fxn = less_than;
else if (nextarg ("<="))
fxn = less_equal;
else if (nextarg ("=") || nextarg ("=="))
fxn = equal;
else if (nextarg ("!="))
fxn = not_equal;
else if (nextarg (">="))
fxn = greater_equal;
else if (nextarg (">"))
fxn = greater_than;
else
return l;
args++;
r = eval3 ();
toarith (l);
toarith (r);
val = (*fxn) (l, r);
freev (l);
freev (r);
l = int_value (val);
}
}
/* Handle &. */
static VALUE *eval1 (void)
{
VALUE *l, *r;
l = eval2 ();
while (nextarg ("&")) {
args++;
r = eval2 ();
if (null (l) || null (r)) {
freev (l);
freev (r);
l = int_value (0);
}
else
freev (r);
}
return l;
}
/* Handle |. */
static VALUE *eval (void)
{
VALUE *l, *r;
l = eval1 ();
while (nextarg ("|")) {
args++;
r = eval1 ();
if (null (l)) {
freev (l);
l = r;
}
else
freev (r);
}
return l;
}

424
fbset.c
View File

@ -1,424 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Mini fbset implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
*
* 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
*
* This is a from-scratch implementation of fbset; but the de facto fbset
* implementation was a good reference. fbset (original) is released under
* the GPL, and is (c) 1995-1999 by:
* Geert Uytterhoeven (Geert.Uytterhoeven@cs.kuleuven.ac.be)
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <sys/ioctl.h>
#include "busybox.h"
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
static const int OPT_CHANGE = (1 << 0);
static const int OPT_INFO = (1 << 1);
static const int OPT_READMODE = (1 << 2);
enum {
CMD_FB = 1,
CMD_DB = 2,
CMD_GEOMETRY = 3,
CMD_TIMING = 4,
CMD_ACCEL = 5,
CMD_HSYNC = 6,
CMD_VSYNC = 7,
CMD_LACED = 8,
CMD_DOUBLE = 9,
/* CMD_XCOMPAT = 10, */
CMD_ALL = 11,
CMD_INFO = 12,
CMD_CHANGE = 13,
#ifdef BB_FEATURE_FBSET_FANCY
CMD_XRES = 100,
CMD_YRES = 101,
CMD_VXRES = 102,
CMD_VYRES = 103,
CMD_DEPTH = 104,
CMD_MATCH = 105,
CMD_PIXCLOCK = 106,
CMD_LEFT = 107,
CMD_RIGHT = 108,
CMD_UPPER = 109,
CMD_LOWER = 110,
CMD_HSLEN = 111,
CMD_VSLEN = 112,
CMD_CSYNC = 113,
CMD_GSYNC = 114,
CMD_EXTSYNC = 115,
CMD_BCAST = 116,
CMD_RGBA = 117,
CMD_STEP = 118,
CMD_MOVE = 119,
#endif
};
static unsigned int g_options = 0;
/* Stuff stolen from the kernel's fb.h */
static const int FBIOGET_VSCREENINFO = 0x4600;
static const int FBIOPUT_VSCREENINFO = 0x4601;
#define __u32 u_int32_t
struct fb_bitfield {
__u32 offset; /* beginning of bitfield */
__u32 length; /* length of bitfield */
__u32 msb_right; /* != 0 : Most significant bit is */
/* right */
};
struct fb_var_screeninfo {
__u32 xres; /* visible resolution */
__u32 yres;
__u32 xres_virtual; /* virtual resolution */
__u32 yres_virtual;
__u32 xoffset; /* offset from virtual to visible */
__u32 yoffset; /* resolution */
__u32 bits_per_pixel; /* guess what */
__u32 grayscale; /* != 0 Graylevels instead of colors */
struct fb_bitfield red; /* bitfield in fb mem if true color, */
struct fb_bitfield green; /* else only length is significant */
struct fb_bitfield blue;
struct fb_bitfield transp; /* transparency */
__u32 nonstd; /* != 0 Non standard pixel format */
__u32 activate; /* see FB_ACTIVATE_* */
__u32 height; /* height of picture in mm */
__u32 width; /* width of picture in mm */
__u32 accel_flags; /* acceleration flags (hints) */
/* Timing: All values in pixclocks, except pixclock (of course) */
__u32 pixclock; /* pixel clock in ps (pico seconds) */
__u32 left_margin; /* time from sync to picture */
__u32 right_margin; /* time from picture to sync */
__u32 upper_margin; /* time from sync to picture */
__u32 lower_margin;
__u32 hsync_len; /* length of horizontal sync */
__u32 vsync_len; /* length of vertical sync */
__u32 sync; /* see FB_SYNC_* */
__u32 vmode; /* see FB_VMODE_* */
__u32 reserved[6]; /* Reserved for future compatibility */
};
static struct cmdoptions_t {
char *name;
unsigned char param_count;
unsigned char code;
} g_cmdoptions[] = {
{
"-fb", 1, CMD_FB}, {
"-db", 1, CMD_DB}, {
"-a", 0, CMD_ALL}, {
"-i", 0, CMD_INFO}, {
"-g", 5, CMD_GEOMETRY}, {
"-t", 7, CMD_TIMING}, {
"-accel", 1, CMD_ACCEL}, {
"-hsync", 1, CMD_HSYNC}, {
"-vsync", 1, CMD_VSYNC}, {
"-laced", 1, CMD_LACED}, {
"-double", 1, CMD_DOUBLE}, {
"-n", 0, CMD_CHANGE}, {
#ifdef BB_FEATURE_FBSET_FANCY
"-all", 0, CMD_ALL}, {
"-xres", 1, CMD_XRES}, {
"-yres", 1, CMD_YRES}, {
"-vxres", 1, CMD_VXRES}, {
"-vyres", 1, CMD_VYRES}, {
"-depth", 1, CMD_DEPTH}, {
"-match", 0, CMD_MATCH}, {
"-geometry", 5, CMD_GEOMETRY}, {
"-pixclock", 1, CMD_PIXCLOCK}, {
"-left", 1, CMD_LEFT}, {
"-right", 1, CMD_RIGHT}, {
"-upper", 1, CMD_UPPER}, {
"-lower", 1, CMD_LOWER}, {
"-hslen", 1, CMD_HSLEN}, {
"-vslen", 1, CMD_VSLEN}, {
"-timings", 7, CMD_TIMING}, {
"-csync", 1, CMD_CSYNC}, {
"-gsync", 1, CMD_GSYNC}, {
"-extsync", 1, CMD_EXTSYNC}, {
"-bcast", 1, CMD_BCAST}, {
"-rgba", 1, CMD_RGBA}, {
"-step", 1, CMD_STEP}, {
"-move", 1, CMD_MOVE}, {
#endif
0, 0, 0}
};
#ifdef BB_FEATURE_FBSET_READMODE
/* taken from linux/fb.h */
static const int FB_VMODE_INTERLACED = 1; /* interlaced */
static const int FB_VMODE_DOUBLE = 2; /* double scan */
static const int FB_SYNC_HOR_HIGH_ACT = 1; /* horizontal sync high active */
static const int FB_SYNC_VERT_HIGH_ACT = 2; /* vertical sync high active */
static const int FB_SYNC_EXT = 4; /* external sync */
static const int FB_SYNC_COMP_HIGH_ACT = 8; /* composite sync high active */
#endif
static int readmode(struct fb_var_screeninfo *base, const char *fn,
const char *mode)
{
#ifdef BB_FEATURE_FBSET_READMODE
FILE *f;
char buf[256];
char *p = buf;
f = xfopen(fn, "r");
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
p += 5;
if ((p = strstr(buf, mode))) {
p += strlen(mode);
if (!isspace(*p) && (*p != 0) && (*p != '"')
&& (*p != '\r') && (*p != '\n'))
continue; /* almost, but not quite */
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if ((p = strstr(buf, "geometry "))) {
p += 9;
sscanf(p, "%d %d %d %d %d",
&(base->xres), &(base->yres),
&(base->xres_virtual), &(base->yres_virtual),
&(base->bits_per_pixel));
} else if ((p = strstr(buf, "timings "))) {
p += 8;
sscanf(p, "%d %d %d %d %d %d %d",
&(base->pixclock),
&(base->left_margin), &(base->right_margin),
&(base->upper_margin), &(base->lower_margin),
&(base->hsync_len), &(base->vsync_len));
} else if ((p = strstr(buf, "laced "))) {
p += 6;
if (strstr(buf, "false")) {
base->vmode &= ~FB_VMODE_INTERLACED;
} else {
base->vmode |= FB_VMODE_INTERLACED;
}
} else if ((p = strstr(buf, "double "))) {
p += 7;
if (strstr(buf, "false")) {
base->vmode &= ~FB_VMODE_DOUBLE;
} else {
base->vmode |= FB_VMODE_DOUBLE;
}
} else if ((p = strstr(buf, "vsync "))) {
p += 6;
if (strstr(buf, "low")) {
base->sync &= ~FB_SYNC_VERT_HIGH_ACT;
} else {
base->sync |= FB_SYNC_VERT_HIGH_ACT;
}
} else if ((p = strstr(buf, "hsync "))) {
p += 6;
if (strstr(buf, "low")) {
base->sync &= ~FB_SYNC_HOR_HIGH_ACT;
} else {
base->sync |= FB_SYNC_HOR_HIGH_ACT;
}
} else if ((p = strstr(buf, "csync "))) {
p += 6;
if (strstr(buf, "low")) {
base->sync &= ~FB_SYNC_COMP_HIGH_ACT;
} else {
base->sync |= FB_SYNC_COMP_HIGH_ACT;
}
} else if ((p = strstr(buf, "extsync "))) {
p += 8;
if (strstr(buf, "false")) {
base->sync &= ~FB_SYNC_EXT;
} else {
base->sync |= FB_SYNC_EXT;
}
}
if (strstr(buf, "endmode"))
return 1;
}
}
}
}
#else
error_msg( "mode reading not compiled in");
#endif
return 0;
}
static void setmode(struct fb_var_screeninfo *base,
struct fb_var_screeninfo *set)
{
if ((int) set->xres > 0)
base->xres = set->xres;
if ((int) set->yres > 0)
base->yres = set->yres;
if ((int) set->xres_virtual > 0)
base->xres_virtual = set->xres_virtual;
if ((int) set->yres_virtual > 0)
base->yres_virtual = set->yres_virtual;
if ((int) set->bits_per_pixel > 0)
base->bits_per_pixel = set->bits_per_pixel;
}
static void showmode(struct fb_var_screeninfo *v)
{
double drate = 0, hrate = 0, vrate = 0;
if (v->pixclock) {
drate = 1e12 / v->pixclock;
hrate =
drate / (v->left_margin + v->xres + v->right_margin +
v->hsync_len);
vrate =
hrate / (v->upper_margin + v->yres + v->lower_margin +
v->vsync_len);
}
printf("\nmode \"%ux%u-%u\"\n", v->xres, v->yres, (int) (vrate + 0.5));
#ifdef BB_FEATURE_FBSET_FANCY
printf("\t# D: %.3f MHz, H: %.3f kHz, V: %.3f Hz\n", drate / 1e6,
hrate / 1e3, vrate);
#endif
printf("\tgeometry %u %u %u %u %u\n", v->xres, v->yres,
v->xres_virtual, v->yres_virtual, v->bits_per_pixel);
printf("\ttimings %u %u %u %u %u %u %u\n", v->pixclock, v->left_margin,
v->right_margin, v->upper_margin, v->lower_margin, v->hsync_len,
v->vsync_len);
printf("\taccel %s\n", (v->accel_flags > 0 ? "true" : "false"));
printf("\trgba %u/%u,%u/%u,%u/%u,%u/%u\n", v->red.length,
v->red.offset, v->green.length, v->green.offset, v->blue.length,
v->blue.offset, v->transp.length, v->transp.offset);
printf("endmode\n\n");
}
#ifdef STANDALONE
int main(int argc, char **argv)
#else
extern int fbset_main(int argc, char **argv)
#endif
{
struct fb_var_screeninfo var, varset;
int fh, i;
char *fbdev = DEFAULTFBDEV;
char *modefile = DEFAULTFBMODE;
char *thisarg, *mode = NULL;
memset(&varset, 0xFF, sizeof(varset));
/* parse cmd args.... why do they have to make things so difficult? */
argv++;
argc--;
for (; argc > 0 && (thisarg = *argv); argc--, argv++) {
for (i = 0; g_cmdoptions[i].name; i++) {
if (!strcmp(thisarg, g_cmdoptions[i].name)) {
if (argc - 1 < g_cmdoptions[i].param_count)
show_usage();
switch (g_cmdoptions[i].code) {
case CMD_FB:
fbdev = argv[1];
break;
case CMD_DB:
modefile = argv[1];
break;
case CMD_GEOMETRY:
varset.xres = strtoul(argv[1], 0, 0);
varset.yres = strtoul(argv[2], 0, 0);
varset.xres_virtual = strtoul(argv[3], 0, 0);
varset.yres_virtual = strtoul(argv[4], 0, 0);
varset.bits_per_pixel = strtoul(argv[5], 0, 0);
break;
case CMD_TIMING:
varset.pixclock = strtoul(argv[1], 0, 0);
varset.left_margin = strtoul(argv[2], 0, 0);
varset.right_margin = strtoul(argv[3], 0, 0);
varset.upper_margin = strtoul(argv[4], 0, 0);
varset.lower_margin = strtoul(argv[5], 0, 0);
varset.hsync_len = strtoul(argv[6], 0, 0);
varset.vsync_len = strtoul(argv[7], 0, 0);
break;
case CMD_CHANGE:
g_options |= OPT_CHANGE;
break;
#ifdef BB_FEATURE_FBSET_FANCY
case CMD_XRES:
varset.xres = strtoul(argv[1], 0, 0);
break;
case CMD_YRES:
varset.yres = strtoul(argv[1], 0, 0);
break;
#endif
}
argc -= g_cmdoptions[i].param_count;
argv += g_cmdoptions[i].param_count;
break;
}
}
if (!g_cmdoptions[i].name) {
if (argc == 1) {
mode = *argv;
g_options |= OPT_READMODE;
} else {
show_usage();
}
}
}
if ((fh = open(fbdev, O_RDONLY)) < 0)
perror_msg_and_die("fbset(open)");
if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
perror_msg_and_die("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
error_msg("Unknown video mode `%s'", mode);
return EXIT_FAILURE;
}
}
setmode(&var, &varset);
if (g_options & OPT_CHANGE)
if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
perror_msg_and_die("fbset(ioctl)");
showmode(&var);
/* Don't close the file, as exiting will take care of that */
/* close(fh); */
return EXIT_SUCCESS;
}

Some files were not shown because too many files have changed in this diff Show More