Compare commits

..
132 Commits
Author SHA1 Message Date
Eric Andersen 8ec10a9483 Fix up copyright msgs. Bump version to 0.49 in preparation for
a release.  Update the website with release details.
 -Erik
2001-01-27 09:33:39 +00:00
Eric Andersen 90ca2848fd Fix some formatting 2001-01-27 08:32:57 +00:00
Eric Andersen ed3ef50c23 Fix header file usage -- there were many unnecessary header files included in
busybox.h which slowed compiles.  I left only what was needed and then fixed up
all the apps to include their own header files.  I also fixed naming for pwd.h
and grp.h functions.  Tested to compile and run with libc5, glibc, and uClibc.
 -Erik
2001-01-27 08:24:39 +00:00
Eric Andersen ab050f5522 Add in a patch to make busybox use the normal pwd.h and grp.h
functions.  Add in simple implementations of these functions,
which can, optionally, be used instead of the system versions.
 -Erik
2001-01-27 06:01:43 +00:00
Mark Whitley 3654ca56fa Applied patch from Larry Doolittle to list supported arches, libcs and kernels 2001-01-26 20:58:23 +00:00
Mark Whitley 4e33875759 Applied patch from Vladimir N. Oleynik <dzo@simtreas.ru> to do tab-completion
in Busybox shell.  (Thanks, Vlad.)
2001-01-26 20:42:23 +00:00
Eric Andersen a68b21a28e Cleanup patch from larry doolittle
-Erik
2001-01-26 20:31:02 +00:00
Mark Whitley 6e25f92636 Fixed a li'l thinko. 2001-01-26 19:19:23 +00:00
Eric Andersen a528dc7071 Fix my braindamage -- remove termios and sighandling since they are not
needed at all.  My bad.
 -Erik
2001-01-26 18:30:12 +00:00
Eric Andersen 1e4b957ac3 I am an idiot. Looking over my patch, ls doesn't need to do anything
more then the ioctl to get the win size.   None of the termios handling
crap is needed.
 -Erik
2001-01-26 18:09:13 +00:00
Eric Andersen 5c9c8b4b26 Make cin be static 2001-01-26 06:50:46 +00:00
Eric Andersen d5cad14b11 Update the arch-not-yet-supported msg to be more clear. 2001-01-26 02:23:57 +00:00
Eric Andersen dff9d54e32 Add errno.h 2001-01-26 02:04:49 +00:00
Eric Andersen 5307eca7de Make ls understand termios.
-Erik
2001-01-26 01:52:43 +00:00
Eric Andersen 114ad9c753 Fix a stupid bug I introduced yesterday. Doh!
-Erik
2001-01-26 01:52:14 +00:00
Eric Andersen dbb8f8d123 Update some comments to clarify things. 2001-01-26 00:11:54 +00:00
Eric Andersen d35c21587a Commit Larry Doolittle's buffers-on-stack/buffers-via-malloc patch.
-Erik
2001-01-25 23:49:09 +00:00
Eric Andersen ffde8673fe Add in spoon's watchdog timer app.
-Erik
2001-01-25 23:40:32 +00:00
Mark Whitley 8ba1b1120e Because you demanded it, source tree snapshots are made available daily. 2001-01-25 23:29:58 +00:00
Mark Whitley 0bc20caea5 Added Linux on nanoEngine to the list of known users. 2001-01-25 23:00:12 +00:00
Eric Andersen 537d165216 Update contact info. 2001-01-25 22:00:37 +00:00
Eric Andersen c1b8f1224c Apply a patch from Brent Priddy <brent.priddy@adtran.com> to add
'id -n' support.
 -Erik
2001-01-25 05:12:02 +00:00
Eric Andersen 155c89b0c3 I just wrote 'insmod -o' to close bug#1049. 2001-01-25 04:11:06 +00:00
Eric Andersen 15f29e7d86 Tar, by itself, could fail. 2001-01-25 00:53:46 +00:00
Eric Andersen cc2bcdc41d Cleanup from Larry Doolittle 2001-01-25 00:47:31 +00:00
Eric Andersen 39b727f498 Fix for dpkg-deb, courtesy of Larry Doolittle.
-Erik
2001-01-25 00:45:52 +00:00
Eric Andersen 3862423884 Add in Larry's CUSTOMIZED_BANNER patchlet, and let folks know that
BB_FEATURE_INIT_CHROOT needs to be rewritten to use pivot_root.
 -Erik
2001-01-25 00:04:16 +00:00
Eric Andersen 70c6086474 More regression testing found buglets 2001-01-25 00:00:04 +00:00
Eric Andersen 86f3d5bad6 Bug fix and small create_module cleanup from Larry Doolittle to
fix insmod, since I broke var=value args when I getopt'ified it.
2001-01-24 23:59:50 +00:00
Eric Andersen 54e9457920 Oops. I am an idiot. Put CFLAGS_EXTRA back. Sorry 'bout that.
-Erik
2001-01-24 23:53:43 +00:00
Eric Andersen 23a93f52aa More regression-found bug fixes 2001-01-24 23:47:21 +00:00
Eric Andersen f5d5e77321 more bugs fixed -- found doing regression testing
-Erik
2001-01-24 23:34:48 +00:00
Eric Andersen 26439a2991 Cleanup for build problem found using regression script 2001-01-24 22:46:16 +00:00
Eric Andersen 088d9e0f05 Fix _old_ bug so that the regression test actually works.
-Erik
2001-01-24 22:09:46 +00:00
Eric Andersen 7d69701d39 Some behavioral updates to wget so it acts a bit nicer.
-Erik
2001-01-24 20:28:35 +00:00
Eric Andersen 8c5cb31e1b Fix up insmod usage info to mention -L 2001-01-24 19:15:07 +00:00
Eric Andersen a18aaf1b6a Make insmod understand (and ignore) -L, and convert it to use getopt. 2001-01-24 19:07:09 +00:00
Eric Andersen c5cd470fdb Update comments re netkit-tiny...
-Erik
2001-01-24 18:47:30 +00:00
Eric Andersen f6c6d9aacc Remove the warning messages. By consensus, netkit-tiny doesn't
need to happen.
2001-01-24 18:44:54 +00:00
Eric Andersen 24be980004 Fix spelling. s/maintainence/maintenance/ 2001-01-24 17:37:07 +00:00
Mark Whitley a5b55ca8a9 - Added a section on avoiding static buffers, per mailing list discussions
- Added a section on avoiding dangerous, overrun-prone string functions, per
   mailing list comment by David Douthitt
 - Added comment on how to search-and-replace in multiple files per (very old)
   mailing list comment by Larry Doolittle.
2001-01-24 00:18:13 +00:00
Mark Whitley f1b0c77c22 Fixed tiny typo. 2001-01-23 22:31:10 +00:00
Mark Whitley 59ab025363 #define -> static const int. Also got rid of some big static buffers. 2001-01-23 22:30:04 +00:00
Eric Andersen 2b8d07c590 Bug fix. 2001-01-23 00:27:51 +00:00
Eric Andersen 9136e3c84e Remove host* applets from the default build. 2001-01-22 22:51:08 +00:00
Eric Andersen e132119f07 Fix silly typo 2001-01-22 22:50:01 +00:00
Eric Andersen 6705986f27 Warn about apps that will be going away in release 0.50
-Erik
2001-01-22 22:48:42 +00:00
Richard June 6d0921cc0b Add HUMAN_READABLE define for -m and -h support in du, df, and ls
Add support for -k in du, df, and ls(no define, it's for compatibliity with the GNU utils as bb does -k by default)
Fix bug #1084
2001-01-22 22:35:38 +00:00
Matt Kraai 3b3f5c364a Use getopt (or getopt_long). 2001-01-22 20:49:00 +00:00
Matt Kraai 8f8dab94e5 Fixed listed files to extract to be more like GNU. Reported by Deon George. 2001-01-22 05:25:19 +00:00
Eric Andersen 0d5a08ed92 Patch from Larry Doolittle to close bug #1086.
-Erik
2001-01-22 01:05:04 +00:00
Eric Andersen b098b6d74c Update time 2001-01-21 02:59:23 +00:00
Eric Andersen fe9888ad97 Fix naming to reflect reality 2001-01-20 21:51:21 +00:00
Eric Andersen 965fa326a1 Move \n to inside TRIVIAL_HELP, to save a few bytes for the default case.
Patch from Vladimir N. Oleynik <dzo@simtreas.ru>
2001-01-20 21:45:57 +00:00
Eric Andersen e2310b5a91 djust debian build targets 2001-01-20 21:43:43 +00:00
Eric Andersen c73a7f9ba0 lean up a potential error, thanks to Vladimir N. Oleynik <dzo@simtreas.ru>. 2001-01-20 21:41:11 +00:00
Eric Andersen 370fb08e79 Clarify the statusbar config option so it states which applet it applies to. 2001-01-20 20:07:00 +00:00
Eric Andersen 6092680305 Adjust the default feature set a wee bit 2001-01-20 19:48:21 +00:00
Eric Andersen 5f825ee6d6 Apply a patch from Vladimir N. Oleynik <dzo@simtreas.ru>,
and thereby save 64 bytes.
 -Erik
2001-01-20 16:22:58 +00:00
Glenn L McGrath f914a8af2b Close files before exit 2001-01-20 06:23:54 +00:00
Eric Andersen 6f65a3a7e8 More printf cleanups 2001-01-20 01:10:07 +00:00
Glenn L McGrath 1d269432b1 Close unused pipe handle before fork (for tar -z). 2001-01-20 00:12:21 +00:00
Matt Kraai 8392acd8fc All files include busybox.h, which includes applets.h, so the Makefile
should reflect this.  Thanks to Vladimir N. Oleynik for the idea.
2001-01-18 03:03:09 +00:00
Matt Kraai 12f417edbd Eliminate calls of the form "fprintf(stdout,". Thanks for the idea to
Vladimir N. Oleynik.
2001-01-18 02:57:08 +00:00
Matt Kraai c9acf8c766 Complicate truncate behavior. 2001-01-17 00:21:05 +00:00
Matt Kraai fd4c58d7c5 Fix the exit status of umount -a, a casualty of the TRUE/FALSE normalization.
Thanks to Francois-R Boyer <boyerf@IRO.UMontreal.CA> for the report.
2001-01-17 00:12:11 +00:00
Eric Andersen 9aa23ba5a8 Show an example of how to compile with uClibc.
-Erik
2001-01-16 21:20:46 +00:00
Matt Kraai 541ffe30a2 Fix ownership of extracted directories. 2001-01-13 21:46:25 +00:00
Mark Whitley 55787401ea Removed unused, unneeded, Lineo-specific script. 2001-01-09 23:09:45 +00:00
Eric Andersen 744b064a34 Needs to be NULL at init in all cases. 2001-01-05 21:23:44 +00:00
Eric Andersen 59d31b68c3 Changelog update/cleanup from larry. 2001-01-05 21:01:01 +00:00
Eric Andersen 8ea28be6d2 Patch from larry doolittle to be ever so careful to cleanup
all open file descriptors, lest wierdness happen later.
2001-01-05 20:58:22 +00:00
Eric Andersen 0bcc813a34 Better label the globals. 2001-01-05 19:37:32 +00:00
Eric Andersen b0970d4fed Patch from Larry Doolittle to set values to static variables that live in the
bss at runtime, since sh.c can call sh.c, which causes these variables to not
be set to their defaults as god intended.
 -Erik
2001-01-05 19:34:52 +00:00
Mark Whitley eb60d8bcd1 Turned some #define constants into static const ints. 2001-01-05 18:19:30 +00:00
Matt Kraai 55bccf315e Rewrote tail. 2001-01-05 02:57:53 +00:00
Matt Kraai defcd5e75e Fix a segfault by only constructing the prompt when we need to. If we don't
do this we will segfault processing /etc/.profile since cwd isn't yet set.
2001-01-05 02:53:11 +00:00
Mark Whitley 6c6ea6cba2 Changed email address to codepoet.org, updated list of applets / docs I
maintain in AUTHORS.
2001-01-04 22:21:13 +00:00
Mark Whitley 92386561f1 Included name of Larry Doolittle's build test script. Shameless self-crediting
of a few items.
2001-01-04 22:07:50 +00:00
Eric Andersen 05ebdd03d4 Update to changelog -- mostly from Larry Doolittle. 2001-01-04 21:14:15 +00:00
Matt Kraai 0810f723b1 Fixed -qv interaction (thanks to a report and patch from David Douthitt). 2001-01-04 15:11:52 +00:00
Eric Andersen 09acc06c10 Move window size handling to cmdedit.c. Move prompt setup to setup_prompt_string() 2001-01-04 11:10:38 +00:00
Eric Andersen 849083c886 Update interface per what now exists... 2001-01-04 11:09:00 +00:00
Eric Andersen b3dc3b8990 Cleanup -- move win handling to cmdedit.c, static-ify many functions. 2001-01-04 11:08:45 +00:00
Matt Kraai 70a7855980 Fix symbol table manipulation (report and fix by Larry Doolittle). 2001-01-04 02:00:17 +00:00
Mark Whitley 1171c2fcb4 Added new script from Larry Doolittle that builds each applet individually. 2001-01-04 01:05:55 +00:00
Matt Kraai be7499c83c Behave like GNU tar when matching excluded files. 2001-01-03 17:22:10 +00:00
Matt Kraai a9711a5969 Prevent / doubling and shrink parse_url. 2001-01-03 16:15:15 +00:00
Glenn L McGrath 59c09d06e3 Fix warning for unused variable 2001-01-03 01:44:49 +00:00
Glenn L McGrath 5e23e3d631 enable is_direcotry() for dpkg-deb 2001-01-03 01:38:29 +00:00
Glenn L McGrath fa0443216d Add dpkg-deb documentation 2001-01-03 01:06:30 +00:00
Eric Andersen 47b005217e Disable a bunch of less common stuff by default. This produces
a more reasonable sized default build.
2001-01-03 00:14:45 +00:00
Eric Andersen 5e8b3ea19d Logger forgot to NULL terminate strings from stdin. 2001-01-03 00:06:46 +00:00
Glenn L McGrath 58a408512b really add dpkg-deb.c this time 2001-01-02 23:49:26 +00:00
Glenn L McGrath 7541e3a812 add dpkg-deb command 2001-01-02 23:41:50 +00:00
Matt Kraai 004827d715 Update logger usage information. 2001-01-02 22:54:12 +00:00
Matt Kraai 1944f547bd Log stdin when no message given and use getopt. 2001-01-02 18:13:58 +00:00
Eric Andersen 28b3c53f0d I just whipped up support for arbitrary regex delimiters, so
now things such as
    $ echo foo | sed 'sxfooxb\arx'
    bar
will work as expected (and so doogie can stop complaining).
 -Erik
2001-01-02 11:01:31 +00:00
Eric Andersen 01bda5de6b Better dmalloc handling 2001-01-02 01:16:38 +00:00
Eric Andersen 27c7bec4d4 Be more careful about dmalloc handling 2001-01-02 01:16:02 +00:00
Matt Kraai e6e818309e Improvements from Vladimir N. Oleynik. 2000-12-30 07:46:23 +00:00
Matt Kraai e9e182e255 Fix lower casing for weird locales. 2000-12-26 16:36:10 +00:00
Eric Andersen 2d5b64273f Cleanup from Gennady Feldman <gfeldman@mail.com> 2000-12-22 18:02:02 +00:00
Matt Kraai a9819b2908 Use busybox error handling functions wherever possible. 2000-12-22 01:48:07 +00:00
Eric Andersen e9f07fb6e8 Another sh.c patch from Larry Doolittle. This makes redirects work properly
with non-forking shell builtins.  Especially helpful for "read".  This patch
also beautifies builtin_fg_bg, clarifies the problems with
run_command_predicate, makes if/then/else support the default, and corrects the
sense of the BB_FEATURE_SH_ENVIRONMENT comment.
2000-12-21 18:31:36 +00:00
Eric Andersen 16fdbe8b27 Make more things be static (like they are supposed to be). 2000-12-20 23:40:57 +00:00
Eric Andersen a6cd07099d Bump the version number to 0.49pre 2000-12-20 23:22:29 +00:00
Eric Andersen e111d69ca2 Turns out, md5sum was broken anyways. It uses backwards TRUE/FALSE
and wasnever updated when TRUE and FALSE were fixed.  So kludge it
by doing an #undef TRUE, then define it backwards...
2000-12-20 23:19:42 +00:00
Eric Andersen 70da6a66d2 Fix a warning in sh.c. Remove use of getline() in md5sum since
nobody else uses it and it is a GNU extension anyways...
2000-12-20 22:59:16 +00:00
Mark Whitley 3680c58084 Some corrections, some additions, some embellishments. 2000-12-20 22:35:12 +00:00
Matt Kraai 5e8c0ffb75 Rewrote. 2000-12-20 20:49:56 +00:00
Eric Andersen e75f6a972c Fix a stupid naming error. 2000-12-20 20:41:02 +00:00
Matt Kraai e80a2633bc Be sure to read from the given path, not the one used in the header. 2000-12-19 20:45:49 +00:00
Mark Whitley 8eb5985f94 More spelling fixes from Larry Doolittle. 2000-12-19 19:44:35 +00:00
Mark Whitley 8a6b619c96 Added a paragraph from Larry Dolittle, made some more section headers. 2000-12-19 17:54:38 +00:00
Mark Whitley eac2636513 New applet HOWTO. Written by Matt Kraai with some formating and additions by me. 2000-12-19 17:35:24 +00:00
Matt Kraai a1f9775981 Fix tar handling of absolute paths and excluded directories. 2000-12-19 06:24:08 +00:00
Matt Kraai 24ac017961 Rewrote dd. 2000-12-18 21:38:57 +00:00
Eric Andersen 0d2acb0ead Doc update from Matt Kraai, better describing the init process. 2000-12-18 20:36:02 +00:00
Eric Andersen 86349776d0 Ok, this is a pretty major update to sh.c. I renamed all the variables and
function names to conform with the style guide.  I also did a lot of work on
the if-then-alse-fi logic and added prototype (i.e. it segfaults when enabled)
line continuation support.

Furthermore, this patch includes Larry Doolittle's work on restructuring some
of the data structures that represent the job and child_program, allowing
several simplifications and fixing several bugs.

 -Erik
2000-12-18 20:25:50 +00:00
Matt Kraai 1fa1adea2a Change calls to error_msg.* and strerror to use perror_msg.*. 2000-12-18 03:57:16 +00:00
Matt Kraai 0dab829977 Add missing newlines to error messages. 2000-12-18 03:08:29 +00:00
Matt Kraai bfa7967c4a Rewrite nc to be simpler, smaller, and to check syscalls for errors. 2000-12-15 22:34:34 +00:00
Matt Kraai 8677d7b6ec Only say mailing list once. 2000-12-15 15:41:03 +00:00
Glenn L McGrath e699b9f0fb Remove defines for ar that arent needed 2000-12-15 06:50:54 +00:00
Glenn L McGrath 4f1b0124c7 Rewrite, fix a bug with multiple long filenames, simplify structure, remove cruft, make code conform closer to style guide, saves 350 Bytes. 2000-12-15 06:50:09 +00:00
Matt Kraai 8abc78aa84 Rewrite argv munger. 2000-12-15 00:35:22 +00:00
Eric Andersen 1b622ff5ac Add in mkCDrec - make CD-ROM recovery project. 2000-12-14 15:43:57 +00:00
Matt Kraai aefe5629ab Simplify error handling. 2000-12-14 05:44:36 +00:00
Matt Kraai 95fa0ea3d4 Shutdown sending on the socket when stdin closes. 2000-12-14 04:34:58 +00:00
Mark Whitley 6f6aa9b428 Added some necessary brackets, removed debug noise. 2000-12-13 23:23:30 +00:00
Matt Kraai e3a94f7d08 Ran aspell. 2000-12-13 19:50:48 +00:00
245 changed files with 9471 additions and 7876 deletions

No files matched your search

+2 -2
View File
@@ -64,8 +64,8 @@ Gyepi Sam <gyepi@praxis-sw.com>
Linus Torvalds <torvalds@transmeta.com>
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@lineo.com>
sed remix, bug fixes, style-guide, etc.
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
Charles P. Wright <cpwright@villagenet.com>
gzip, mini-netcat(nc)
+55
View File
@@ -1,3 +1,58 @@
0.49
* Matt Kraai -- new sort.c
* Matt Kraai -- new tail.c
* Glenn McGrath -- new 'dpkg-deb' applet
* Glenn McGrath -- new ar code
* spoon -- new watchdog applet
* Vladimir N. Oleynik <dzo@simtreas.ru> -- fixed cmdedit.c so now
scrolling and tab completion in lash work properly. Also several
byte saving optimizations.
* Erik Andersen -- disabled many less commonly used applets by default
* Mark Whitley -- more thrashing about to get clean perror_msg usage
* Matt Kraai -- new command line munging
* Larry Doolittle -- keep some locales from messing up busybox.sh
* Matt Kraai -- cleaned up dd and tail with new parse_number routine
* Mark Whitley -- remove debugging messages from deallocvt
* Matt Kraai and Mark Whitley -- new document "How to Add a New Applet
to BusyBox"
* David Douthitt -- fixed "grep -qv" bug
* Larry Doolittle -- fixed insmod bug with old kernels
* Matt Kraai -- logger remixed to use getopt, selection of stdin made
util-linux compatible
* Erik Andersen -- many more internal symbols classified static to
avoid namespace pollution
* Matt Kraai -- nc listening support
* Erik Andersen -- made sed understand arbitrary regexp delimiters
* Matt Kraai et al. -- more tar improvements and bug fixes, now
handles regexp file exclusion
* Larry Doolittle -- new script (multibuild.pl) to automate build rule
checking
* Matt Kraai -- update/cleanup of the docs on how to use init
* Erik Andersen -- renamed all sh.c symbols per the style guide,
better if-then-else-fi handling
* Erik Andersen -- cleaner division of labor between cmdedit.c and sh.c
* Larry Doolittle -- shell data structure cleanup, fixed buglets
in read, exec, and piped builtins
* Erik Andersen -- md5sum was broken in 0.48. Now fixed (and doesn't
use getline, shrinking static compiles (since nothing else used it).
* ?? -- squashed memory leak in shell prompt handling
* 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
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
whether or not to use the system's passwd and group functions.
Since most systems use GNU libc, this can save you from having to
install the /etc/nsswitch.conf configuration file and the required
libnss_* libraries. Adds 1.5k. You can now, also, disable this,
causing busybox to use the system's pwd.h and grp.h functions.
-Erik Andersen, 27 January 2001
0.48
* Glenn McGrath -- tar now supports uncompressing tar files,
+99 -73
View File
@@ -7,86 +7,87 @@
//
//
// BusyBox Applications
#define BB_AR
//#define BB_AR
#define BB_BASENAME
#define BB_CAT
#define BB_CHMOD_CHOWN_CHGRP
#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
#define BB_CMP
//#define BB_CMP
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_DC
//#define BB_DC
#define BB_DD
#define BB_DEALLOCVT
//#define BB_DEALLOCVT
#define BB_DF
#define BB_DIRNAME
#define BB_DMESG
#define BB_DOS2UNIX
#define BB_DUTMP
//#define BB_DOS2UNIX
//#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
//#define BB_DUMPKMAP
#define BB_ECHO
#define BB_EXPR
#define BB_FBSET
#define BB_FDFLUSH
//#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_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_HOSTID
//#define BB_HOSTNAME
#define BB_ID
#define BB_INIT
#define BB_INSMOD
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
//#define BB_LENGTH
#define BB_LN
#define BB_LOADACM
#define BB_LOADFONT
#define BB_LOADKMAP
//#define BB_LOADACM
//#define BB_LOADFONT
//#define BB_LOADKMAP
#define BB_LOGGER
#define BB_LOGNAME
//#define BB_LOGNAME
#define BB_LS
#define BB_LSMOD
#define BB_MAKEDEVS
#define BB_MD5SUM
//#define BB_MAKEDEVS
//#define BB_MD5SUM
#define BB_MKDIR
#define BB_MKFIFO
#define BB_MKFS_MINIX
//#define BB_MKFIFO
//#define BB_MKFS_MINIX
#define BB_MKNOD
#define BB_MKSWAP
#define BB_MKTEMP
#define BB_NC
//#define BB_MKTEMP
//#define BB_NC
#define BB_MORE
#define BB_MOUNT
#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
//#define BB_MT
//#define BB_NSLOOKUP
//#define BB_PING
#define BB_POWEROFF
#define BB_PRINTF
//#define BB_PRINTF
#define BB_PS
#define BB_PWD
#define BB_RDATE
#define BB_READLINK
//#define BB_RDATE
//#define BB_READLINK
#define BB_REBOOT
#define BB_RENICE
//#define BB_RENICE
#define BB_RESET
#define BB_RM
#define BB_RMDIR
#define BB_RMMOD
#define BB_RPMUNPACK
//#define BB_RMMOD
//#define BB_RPMUNPACK
#define BB_SED
#define BB_SETKEYCODES
//#define BB_SETKEYCODES
#define BB_SH
#define BB_SLEEP
#define BB_SORT
@@ -95,26 +96,27 @@
#define BB_SYSLOGD
#define BB_TAIL
#define BB_TAR
#define BB_TEE
#define BB_TEST
#define BB_TELNET
//#define BB_TEE
//#define BB_TEST
//#define BB_TELNET
#define BB_TOUCH
#define BB_TR
//#define BB_TR
#define BB_TRUE_FALSE
#define BB_TTY
#define BB_UPTIME
#define BB_USLEEP
#define BB_WC
#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
#define BB_UUENCODE
#define BB_UUDECODE
//#define BB_UUENCODE
//#define BB_UUDECODE
#define BB_UMOUNT
#define BB_UNIQ
#define BB_UNAME
#define BB_UNIX2DOS
#define BB_UPDATE
//#define BB_UNIX2DOS
//#define BB_UPDATE
#define BB_UPTIME
//#define BB_USLEEP
//#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
@@ -127,6 +129,11 @@
// pretty/useful).
//
//
// 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
//
// 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
@@ -192,7 +199,7 @@
//#define BB_FEATURE_INIT_CHROOT
//
//Make sure nothing is printed to the console on boot
#define BB_FEATURE_EXTRA_QUIET
//#define BB_FEATURE_EXTRA_QUIET
//
//Should syslogd also provide klogd support?
#define BB_FEATURE_KLOGD
@@ -201,7 +208,7 @@
#define BB_FEATURE_REMOTE_LOG
//
//Simple tail implementation (2.34k vs 3k for the full one).
//Both provide 'tail -f' support (only one file at a time.)
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
#define BB_FEATURE_SIMPLE_TAIL
//
// Enable support for loop devices in mount
@@ -231,12 +238,14 @@
//// Enable reverse sort
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
// Enable command line editing in the shell.
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things.
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell applets can be called using full path
@@ -245,11 +254,17 @@
//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 BB_SH is enabled.
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
//#define BB_FEATURE_SH_TAB_COMPLETION
// Only relevant if BB_SH is enabled.
#define BB_FEATURE_SH_TAB_COMPLETION
//
// Attempts to match usernames in a ~-prefixed path
// XXX: Doesn't work without NSS, off by default
//#define BB_FEATURE_USERNAME_COMPLETION /* require NSS */
//
//Turn on extra fbset options
//#define BB_FEATURE_FBSET_FANCY
@@ -257,17 +272,11 @@
//Turn on fbset readmode support
//#define BB_FEATURE_FBSET_READMODE
//
// You must enable one or both of these features
// Support installing modules from pre 2.1 kernels
//#define BB_FEATURE_INSMOD_OLD_KERNEL
// Support installing modules from kernel versions after 2.1.18
#define BB_FEATURE_INSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for post 2.1 kernels
//#define BB_FEATURE_NEW_MODULE_INTERFACE
//
// You must enable one or both of these features
// Support modules status from pre 2.1 kernels
//#define BB_FEATURE_LSMOD_OLD_KERNEL
// Support modules status from kernel versions after 2.1.18
#define BB_FEATURE_LSMOD_NEW_KERNEL
// Support insmod/lsmod/rmmod for pre 2.1 kernels
//#define BB_FEATURE_OLD_MODULE_INTERFACE
//
// Support module version checking
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
@@ -282,13 +291,16 @@
// #define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
//#define BB_FEATURE_STATUSBAR
#define BB_FEATURE_WGET_STATUSBAR
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
// have a really good reason for cleaning things up manually.
//#define BB_FEATURE_CLEAN_UP
//
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
#define BB_FEATURE_HUMAN_READABLE
//
// End of Features List
//
//
@@ -300,9 +312,13 @@
// Nothing beyond this point should ever be touched by
// mere mortals so leave this stuff alone.
//
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
#define BB_MTAB
#endif
#else
#undef BB_MTAB
#endif
//
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
#define BB_CMDEDIT
@@ -314,11 +330,9 @@
#endif
#endif
//
#ifdef BB_FEATURE_LINUXRC
#ifndef BB_INIT
#define BB_INIT
#endif
#define BB_LINUXRC
#undef BB_LINUXRC
#undef BB_FEATURE_LINUXRC
#endif
//
#ifdef BB_GZIP
@@ -327,6 +341,18 @@
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
@@ -351,8 +377,8 @@
#endif
#endif
//
#if defined BB_INSMOD
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
#define BB_FEATURE_INSMOD_NEW_KERNEL
#if defined BB_INSMOD || defined BB_LSMOD
#ifndef BB_FEATURE_NEW_MODULE_INTERFACE
#define BB_FEATURE_NEW_MODULE_INTERFACE
#endif
#endif
+1 -1
View File
@@ -18,7 +18,7 @@ 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 by Lineo, inc. and written by
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+48 -11
View File
@@ -1,7 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
# Copyright (C) 1999,2000,2001 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
@@ -19,7 +18,7 @@
#
PROG := busybox
VERSION := 0.48
VERSION := 0.49
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
export VERSION
@@ -28,6 +27,11 @@ export VERSION
# overridden at the command line. For example:
# make CROSS=powerpc-linux- BB_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.
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA =
# If you want a static binary, turn this on.
DOSTATIC = false
@@ -37,6 +41,17 @@ DOSTATIC = false
# Do not enable this for production builds...
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),
# Most people will want to leave this set to false.
USE_SYSTEM_PWD_GRP = false
# 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
@@ -65,11 +80,14 @@ CROSS =
CC = $(CROSS)gcc
STRIPTOOL = $(CROSS)strip
# To compile vs an alternative libc, you may need to use/adjust
# the following lines to meet your needs. This is how I make
# busybox compile with uC-Libc (needs BB_GETOPT and BB_FEATURE_NFSMOUNT
# disabled at the moment).
#LIBCDIR=/home/andersen/CVS/uClibc
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
# Isn't that easy? Right now, uClibc needs BB_FEATURE_NFSMOUNT disabled
# since uClibc's nfs support isn't ready yet.
#CC = ../uClibc/extra/gcc-uClibc/gcc-uClibc-i386
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#LIBCDIR=/usr/i486-linuxlibc1/
#LDFLAGS+=-nostdlib
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
@@ -145,6 +163,19 @@ ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
ifneq ($(USE_SYSTEM_PWD_GRP),true)
PWD_LIB = pwd_grp/libpwd.a
LIBRARIES += $(PWD_LIB)
else
CFLAGS += -DUSE_SYSTEM_PWD_GRP
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
.EXPORT_ALL_VARIABLES:
all: busybox busybox.links doc
@@ -204,15 +235,19 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
busybox: $(OBJECTS)
busybox: $(PWD_LIB) $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
$(STRIP)
busybox.links: Config.h
$(PWD_LIB):
$(MAKE) -eC pwd_grp
busybox.links: Config.h applets.h
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
nfsmount.o cmdedit.o: %.o: %.h
$(OBJECTS): %.o: %.c Config.h busybox.h Makefile
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
$(CC) $(CFLAGS) -c $*.c -o $*.o
utility.o: loop.h
@@ -224,10 +259,12 @@ test tests:
clean:
- cd tests && $(MAKE) clean
- cd pwd_grp && $(MAKE) clean
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.lineo.com/BusyBox.html
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
- rm -f Config.h.ORG bb.def.h busybox.REGRESS.sh.results bb.OptionsAndFeatures
- rm -rf docs/busybox _install
- rm -f busybox.links loop.h *~ *.o core
+22 -3
View File
@@ -11,8 +11,9 @@ the expected functionality and behave very much like their GNU counterparts.
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add a kernel and an editor (such as
e3 (http://www.sax.de/~adlibiti) or elvis-tiny).
systems. To create a working system, just add /dev, a kernel, and an editor,
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
the busybox shell (not Bourne compatible, but very small and quite usable).
BusyBox was originally written to support the Debian Rescue/Install disks, but
it also makes an excellent environment for any small or embedded system.
@@ -27,7 +28,25 @@ After the build is complete, a busybox.links file is generated. This is
used by 'make install' to create symlinks to the busybox binary for all
compiled in functions. By default, 'make install' will place the symlink
forest into `pwd`/_install unless you have defined the PREFIX environment
variable (i.e., make PREFIX="/tmp/foo" install)
variable (i.e., 'make PREFIX=/tmp/foo install')
----------------
Supported architectures:
Busybox in general will build on any architecture supported by gcc. It has
a few specialized features added for __sparc__ and __alpha__. insmod
functionality is currently limited to x86, ARM, and SH3/4.
Supported libcs:
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
newlib and diet-libc, but consider them unsupported, untested, or worse.
Supported kernels:
Full functionality requires Linux 2.0.x, 2.2.x, or 2.4.x. A large fraction
of the code should run on just about anything.
----------------
+14 -29
View File
@@ -6,10 +6,18 @@ around to it some time. If you have any good ideas, please let me know.
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
needed or wanted in busybox (or else I'd have to link to libcrypt).
* Networking apps are going to be split out to a new package called netkit-tiny
before the next release of Busybox. This will remove the following items
from BusyBox: hostid, hostname, nc, nslookup, telnet, and ping. nfs
mounting and syslogd (network logging) will remain in BusyBox.
* We _were_ going to split networking apps into a new package called
netkit-tiny. Per discussions on the mailing list, this isn't going
to happen. False alarm. Sorry about the confusion.
* The busybox shell, lash, is really too weak for serious use, although it is
possible to run simple systems with it. BusyBox 0.49 was supposed to have
a new shell, updated to understand full Bourne grammer. Well, that simply
didn't happen in time for the release. A rewrite is in progress that will
result in a new shell that understands the full Bourne grammar. This new
shell is being championed by Larry Doolittle <ldoolitt@recycle.lbl.gov>, and
could use your help. Please see the work in progress at
http://doolittle.faludi.com/~larry/parser.html
-Erik
@@ -23,12 +31,6 @@ Possible apps to include some time:
-----------------------
The Busybox lash shell needs to be taught Bourne shell grammer. This
is planned for the next release of Busybox. Look out ash, we are coming
for you...
-----------------------
Running the following:
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
@@ -36,25 +38,8 @@ Running the following:
reveals the list of all external (i.e. libc) things that BusyBox depends on.
It would be a very nice thing to reduce this list to an absolute minimum, to
reduce the footprint of busybox when staticly linking with libraries such as
uClibc.
-----------------------
Currently, busybox bypasses libc NSS. Some folks might want that,
so perhaps adding in the option to choose whether to go to libc for
things like getpwnam() or whether to use the busybox version might
be nice.
-----------------------
Most wanted list:
[andersen@slag busybox]$ grep -l getgroups *.[ch]
test.c
Policy violation. getgroups uses libc nss, which is unlikely
to be present in an embedded system.
reduce the footprint of busybox, especially when staticly linking with
libraries such as uClibc.
-----------------------
+6
View File
@@ -89,6 +89,9 @@ const struct BB_applet applets[] = {
#ifdef BB_DOS2UNIX
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
#endif
#ifdef BB_DPKG_DEB
APPLET("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb_usage)
#endif
#ifdef BB_DU
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
#endif
@@ -359,6 +362,9 @@ const struct BB_applet applets[] = {
#ifdef BB_UUENCODE
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
#endif
#ifdef BB_WATCHDOG
APPLET("watchdog", watchdog_main, _BB_DIR_SBIN, watchdog_usage)
#endif
#ifdef BB_WC
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
#endif
+48 -60
View File
@@ -2,7 +2,9 @@
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#undef APPLET
#undef APPLET_NOUSAGE
@@ -14,8 +16,6 @@
#include "messages.c"
static int been_there_done_that = 0;
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
if (len != -1) {
path[len] = 0;
} else {
error_msg("%s: %s\n", proc, strerror(errno));
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
@@ -69,16 +69,16 @@ static void install_links(const char *busybox, int use_symbolic_links)
int i;
int rc;
if (use_symbolic_links) Link = symlink;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location],
applets[i].name);
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, command);
if (rc) {
error_msg("%s: %s\n", command, strerror(errno));
perror_msg("%s", command);
}
}
}
@@ -89,7 +89,37 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
applet_name = "busybox";
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
@@ -121,39 +151,6 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0;
int ps_index;
char *index, *index2;
argc--;
/* If we've already been here once, exit now */
@@ -185,25 +182,16 @@ int busybox_main(int argc, char **argv)
/* Flag that we've been here already */
been_there_done_that = 1;
/* We do not want the word "busybox" to show up in ps, so we move
* everything in argv around to fake ps into showing what we want it to
* show. Since we are only shrinking the string, we don't need to move
* __environ or any of that tedious stuff... */
ps_index = 0;
index=*argv;
index2=argv[argc];
index2+=strlen(argv[argc]);
while(ps_index < argc) {
argv[ps_index]=index;
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
index+=(strlen(index));
*index='\0';
index++;
ps_index++;
}
while(index<=index2)
*index++='\0';
argv[ps_index]=NULL;
/* 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));
}
+7 -2
View File
@@ -1,12 +1,17 @@
#!/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>
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
match($2,"_BB_DIR[A-Z_]*")
dir=substr($2,RSTART+7,RLENGTH-7)
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
+1 -1
View File
@@ -3,7 +3,7 @@
RAW=` \
gcc -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr '[:upper:]' '[:lower:]' | sort
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
+399 -339
View File
File diff suppressed because it is too large. Load diff
+143 -311
View File
@@ -3,7 +3,7 @@
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
@@ -21,317 +21,142 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 20 September 2000
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
#define BLOCK_SIZE 60
#define PRESERVE_DATE 1 /* preserve original dates */
#define VERBOSE 2 /* be verbose */
#define DISPLAY 4 /* display contents */
#define EXT_TO_FILE 8 /* extract contents of archive */
#define EXT_TO_STDOUT 16 /* extract to stdout */
#define RECURSIVE 32
typedef struct ar_headers_s {
char *name;
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
#define MAX_NAME_LENGTH 100
//#define BB_DECLARE_EXTERN
//#define bb_need_io_error
//#include "messages.c"
//#define BB_AR_EXPERIMENTAL_UNTAR
#if defined BB_AR_EXPERIMENTAL_UNTAR
typedef struct rawTarHeader {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} rawTarHeader_t;
#endif
typedef struct rawArHeader { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6], gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} rawArHeader_t;
typedef struct headerL {
char name[MAX_NAME_LENGTH];
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct headerL *next;
} headerL_t;
#if defined BB_AR_EXPERIMENTAL_UNTAR
/*
* identify Tar header (magic field) and reset srcFd to entry position
* return the headerL_t struct for the filename descriptor
*/
static int checkTarMagic(int srcFd)
extern ar_headers_t get_headers(int srcFd)
{
off_t headerStart;
char magic[6];
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
return(TRUE);
}
static int readTarHeader(int srcFd, headerL_t *current)
{
rawTarHeader_t rawTarHeader;
unsigned char *temp = (unsigned char *) &rawTarHeader;
long sum = 0;
int i;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
for (i = 0; i < 148 ; i++)
sum += temp[i];
sum += ' ' * 8;
for (i = 156; i < 512 ; i++)
sum += temp[i];
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
return(FALSE);
sscanf(rawTarHeader.name, "%s", current->name);
current->size = strtol(rawTarHeader.size, NULL, 8);
current->uid = strtol(rawTarHeader.uid, NULL, 8);
current->gid = strtol(rawTarHeader.gid, NULL, 8);
current->mode = strtol(rawTarHeader.mode, NULL, 8);
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
current->offset = lseek(srcFd, 0 , SEEK_CUR);
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
current = current->next;
return(TRUE);
}
#endif
/*
* identify Ar header (magic) and reset srcFd to entry position
*/
static int checkArMagic(int srcFd)
{
off_t headerStart;
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, arMagic, 8) != 8) {
error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(arMagic,"!<arch>",7) != 0)
return(FALSE);
return(TRUE);
}
/*
* get, check and correct the converted header
*/
static int readArEntry(int srcFd, headerL_t *entry)
{
size_t nameLength;
rawArHeader_t rawArHeader;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
strncpy(entry->name, rawArHeader.name, 16);
nameLength=strcspn(entry->name, " \\");
entry->name[nameLength]='\0';
parse_mode(rawArHeader.mode, &entry->mode);
entry->mtime = atoi(rawArHeader.date);
entry->uid = atoi(rawArHeader.uid);
entry->gid = atoi(rawArHeader.gid);
entry->size = (size_t) atoi(rawArHeader.size);
entry->offset = initialOffset + (off_t) 60;
nameLength = strcspn(entry->name, "/");
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
/* handle GNU style short filenames, strip trailing '/' */
if (nameLength > 0)
entry->name[nameLength]='\0';
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* handle GNU style long filenames */
if (nameLength == 0) {
/* escape from recursive call */
if (entry->name[1]=='0')
return(TRUE);
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8)
error_msg_and_die("cannot read magic\n");
if (strncmp(ar_magic,"!<arch>",7) != 0)
error_msg_and_die("invalid magic\n");
/* the data section contains the real filename */
if (entry->name[1]=='/') {
char tempName[MAX_NAME_LENGTH];
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
/* be carefull, this is recursive */
if (readArEntry(srcFd, entry)==FALSE)
return(FALSE);
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline[1];
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, newline, 1);
if (newline[0]!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
entry->size = (size_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
error_msg("Invalid long filename\n");
return(FALSE);
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
}
return(TRUE);
}
/*
* return the headerL_t struct for the specified filename
*/
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
{
#if defined BB_AR_EXPERIMENTAL_UNTAR
int tar=FALSE;
#endif
int ar=FALSE;
headerL_t *list;
off_t initialOffset;
list = (headerL_t *) xmalloc(sizeof(headerL_t));
initialOffset=lseek(srcFd, 0, SEEK_CUR);
if (checkArMagic(srcFd)==TRUE)
ar=TRUE;
#if defined BB_AR_EXPERIMENTAL_UNTAR
if (checkTarMagic(srcFd)==TRUE)
tar=TRUE;
if (tar==TRUE) {
while(readTarHeader(srcFd, list)==TRUE) {
off_t tarOffset;
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if ((funct & RECURSIVE) == RECURSIVE)
head = getHeaders(srcFd, head, funct);
tarOffset = (off_t) head->size/512;
if ( head->size % 512 > 0)
tarOffset++;
tarOffset=tarOffset*512;
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
}
}
#endif
if (ar==TRUE) {
lseek(srcFd, 8, SEEK_CUR);
while(1) {
if (readArEntry(srcFd, list) == FALSE) {
lseek(srcFd, ++initialOffset, SEEK_CUR);
if (readArEntry(srcFd, list) == FALSE)
return(head);
}
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if (funct & RECURSIVE)
head = getHeaders(srcFd, head, funct);
lseek(srcFd, head->offset + head->size, SEEK_SET);
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
}
return(head);
}
entry->name[strcspn(entry->name, " /")]='\0';
/*
* find an entry in the linked list matching the filename
*/
static headerL_t *findEntry(headerL_t *head, const char *filename)
{
while(head->next != NULL) {
if (strcmp(filename, head->name)==0)
return(head);
head=head->next;
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(NULL);
return(*head);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
headerL_t *header, *entry, *extractList;
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= PRESERVE_DATE;
funct |= preserve_date;
break;
case 'v':
funct |= VERBOSE;
funct |= verbose;
break;
case 't':
funct |= DISPLAY;
break;
case 'x':
funct |= EXT_TO_FILE;
funct |= display;
break;
case 'p':
funct |= EXT_TO_STDOUT;
funct |= extract_to_stdout;
break;
case 'R':
funct |= RECURSIVE;
case 'x':
funct |= extract_to_file;
break;
default:
usage(ar_usage);
@@ -345,47 +170,54 @@ extern int ar_main(int argc, char **argv)
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
header = (headerL_t *) xmalloc(sizeof(headerL_t));
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
optind++;
head = get_headers(srcFd);
header = getHeaders(srcFd, header, funct);
/* find files to extract or display */
if (optind<argc) {
/* only handle specified files */
while(optind < argc) {
if ( (entry = findEntry(header, argv[optind])) != NULL) {
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*entry->next = *extractList;
*extractList = *entry;
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
optind++;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
}
else
extractList = header;
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
if (funct & EXT_TO_STDOUT) {
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid,
extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
}
extractList=extractList->next;
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
}
return EXIT_SUCCESS;
}
+143 -311
View File
@@ -3,7 +3,7 @@
* Mini ar implementation for busybox
*
* Copyright (C) 2000 by Glenn McGrath
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
@@ -21,317 +21,142 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Last modified 20 September 2000
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <malloc.h>
#include <getopt.h>
#include <unistd.h>
#include "busybox.h"
#define BLOCK_SIZE 60
#define PRESERVE_DATE 1 /* preserve original dates */
#define VERBOSE 2 /* be verbose */
#define DISPLAY 4 /* display contents */
#define EXT_TO_FILE 8 /* extract contents of archive */
#define EXT_TO_STDOUT 16 /* extract to stdout */
#define RECURSIVE 32
typedef struct ar_headers_s {
char *name;
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
#define MAX_NAME_LENGTH 100
//#define BB_DECLARE_EXTERN
//#define bb_need_io_error
//#include "messages.c"
//#define BB_AR_EXPERIMENTAL_UNTAR
#if defined BB_AR_EXPERIMENTAL_UNTAR
typedef struct rawTarHeader {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} rawTarHeader_t;
#endif
typedef struct rawArHeader { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6], gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} rawArHeader_t;
typedef struct headerL {
char name[MAX_NAME_LENGTH];
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct headerL *next;
} headerL_t;
#if defined BB_AR_EXPERIMENTAL_UNTAR
/*
* identify Tar header (magic field) and reset srcFd to entry position
* return the headerL_t struct for the filename descriptor
*/
static int checkTarMagic(int srcFd)
extern ar_headers_t get_headers(int srcFd)
{
off_t headerStart;
char magic[6];
typedef struct raw_ar_header_s { /* Byte Offset */
char name[16]; /* 0-15 */
char date[12]; /* 16-27 */
char uid[6];
char gid[6]; /* 28-39 */
char mode[8]; /* 40-47 */
char size[10]; /* 48-57 */
char fmag[2]; /* 58-59 */
} raw_ar_header_t;
raw_ar_header_t raw_ar_header;
headerStart = lseek(srcFd, 0, SEEK_CUR);
lseek(srcFd, (off_t) 257, SEEK_CUR);
full_read(srcFd, magic, 6);
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(magic, "ustar", 5)!=0)
return(FALSE);
return(TRUE);
}
static int readTarHeader(int srcFd, headerL_t *current)
{
rawTarHeader_t rawTarHeader;
unsigned char *temp = (unsigned char *) &rawTarHeader;
long sum = 0;
int i;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
for (i = 0; i < 148 ; i++)
sum += temp[i];
sum += ' ' * 8;
for (i = 156; i < 512 ; i++)
sum += temp[i];
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
return(FALSE);
sscanf(rawTarHeader.name, "%s", current->name);
current->size = strtol(rawTarHeader.size, NULL, 8);
current->uid = strtol(rawTarHeader.uid, NULL, 8);
current->gid = strtol(rawTarHeader.gid, NULL, 8);
current->mode = strtol(rawTarHeader.mode, NULL, 8);
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
current->offset = lseek(srcFd, 0 , SEEK_CUR);
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
current = current->next;
return(TRUE);
}
#endif
/*
* identify Ar header (magic) and reset srcFd to entry position
*/
static int checkArMagic(int srcFd)
{
off_t headerStart;
char arMagic[8];
headerStart = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, arMagic, 8) != 8) {
error_msg("fatal error\n");
return (FALSE);
}
lseek(srcFd, headerStart, SEEK_SET);
if (strncmp(arMagic,"!<arch>",7) != 0)
return(FALSE);
return(TRUE);
}
/*
* get, check and correct the converted header
*/
static int readArEntry(int srcFd, headerL_t *entry)
{
size_t nameLength;
rawArHeader_t rawArHeader;
off_t initialOffset;
initialOffset = lseek(srcFd, 0, SEEK_CUR);
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
lseek(srcFd, initialOffset, SEEK_SET);
return(FALSE);
}
strncpy(entry->name, rawArHeader.name, 16);
nameLength=strcspn(entry->name, " \\");
entry->name[nameLength]='\0';
parse_mode(rawArHeader.mode, &entry->mode);
entry->mtime = atoi(rawArHeader.date);
entry->uid = atoi(rawArHeader.uid);
entry->gid = atoi(rawArHeader.gid);
entry->size = (size_t) atoi(rawArHeader.size);
entry->offset = initialOffset + (off_t) 60;
nameLength = strcspn(entry->name, "/");
ar_headers_t *head, *entry;
char ar_magic[8];
char *long_name=NULL;
/* handle GNU style short filenames, strip trailing '/' */
if (nameLength > 0)
entry->name[nameLength]='\0';
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
/* handle GNU style long filenames */
if (nameLength == 0) {
/* escape from recursive call */
if (entry->name[1]=='0')
return(TRUE);
/* check ar magic */
if (full_read(srcFd, ar_magic, 8) != 8)
error_msg_and_die("cannot read magic\n");
if (strncmp(ar_magic,"!<arch>",7) != 0)
error_msg_and_die("invalid magic\n");
/* the data section contains the real filename */
if (entry->name[1]=='/') {
char tempName[MAX_NAME_LENGTH];
if (entry->size > MAX_NAME_LENGTH)
entry->size = MAX_NAME_LENGTH;
full_read(srcFd, tempName, entry->size);
tempName[entry->size-3]='\0';
/* read the second header for this entry */
/* be carefull, this is recursive */
if (readArEntry(srcFd, entry)==FALSE)
return(FALSE);
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
/* check the end of header markers are valid */
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
char newline[1];
if (raw_ar_header.fmag[1]!='`') {
break;
}
/* some version of ar, have an extra '\n' after each entry */
read(srcFd, newline, 1);
if (newline[0]!='\n') {
break;
}
/* fix up the header, we started reading 1 byte too early due to a '\n' */
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
/* dont worry about adding the last '\n', we dont need it now */
}
if ((entry->name[0]='/') && (entry->name[1]='0'))
strcpy(entry->name, tempName);
entry->size = (size_t) atoi(raw_ar_header.size);
/* long filenames have '/' as the first character */
if (raw_ar_header.name[0] == '/') {
if (raw_ar_header.name[1] == '/') {
/* multiple long filenames are stored as data in one entry */
long_name = (char *) xrealloc(long_name, entry->size);
full_read(srcFd, long_name, entry->size);
continue;
}
else {
error_msg("Invalid long filename\n");
return(FALSE);
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
strcpy(entry->name, &long_name[long_name_offset]);
}
}
}
return(TRUE);
}
/*
* return the headerL_t struct for the specified filename
*/
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
{
#if defined BB_AR_EXPERIMENTAL_UNTAR
int tar=FALSE;
#endif
int ar=FALSE;
headerL_t *list;
off_t initialOffset;
list = (headerL_t *) xmalloc(sizeof(headerL_t));
initialOffset=lseek(srcFd, 0, SEEK_CUR);
if (checkArMagic(srcFd)==TRUE)
ar=TRUE;
#if defined BB_AR_EXPERIMENTAL_UNTAR
if (checkTarMagic(srcFd)==TRUE)
tar=TRUE;
if (tar==TRUE) {
while(readTarHeader(srcFd, list)==TRUE) {
off_t tarOffset;
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if ((funct & RECURSIVE) == RECURSIVE)
head = getHeaders(srcFd, head, funct);
tarOffset = (off_t) head->size/512;
if ( head->size % 512 > 0)
tarOffset++;
tarOffset=tarOffset*512;
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
}
}
#endif
if (ar==TRUE) {
lseek(srcFd, 8, SEEK_CUR);
while(1) {
if (readArEntry(srcFd, list) == FALSE) {
lseek(srcFd, ++initialOffset, SEEK_CUR);
if (readArEntry(srcFd, list) == FALSE)
return(head);
}
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*list->next = *head;
*head = *list;
/* recursive check for sub-archives */
if (funct & RECURSIVE)
head = getHeaders(srcFd, head, funct);
lseek(srcFd, head->offset + head->size, SEEK_SET);
else {
/* short filenames */
entry->name = xmalloc(16);
strncpy(entry->name, raw_ar_header.name, 16);
}
}
return(head);
}
entry->name[strcspn(entry->name, " /")]='\0';
/*
* find an entry in the linked list matching the filename
*/
static headerL_t *findEntry(headerL_t *head, const char *filename)
{
while(head->next != NULL) {
if (strcmp(filename, head->name)==0)
return(head);
head=head->next;
/* convert the rest of the now valid char header to its typed struct */
parse_mode(raw_ar_header.mode, &entry->mode);
entry->mtime = atoi(raw_ar_header.date);
entry->uid = atoi(raw_ar_header.uid);
entry->gid = atoi(raw_ar_header.gid);
entry->offset = lseek(srcFd, 0, SEEK_CUR);
/* add this entries header to our combined list */
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*entry->next = *head;
*head = *entry;
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
}
return(NULL);
return(*head);
}
extern int ar_main(int argc, char **argv)
{
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
headerL_t *header, *entry, *extractList;
const int preserve_date = 1; /* preserve original dates */
const int verbose = 2; /* be verbose */
const int display = 4; /* display contents */
const int extract_to_file = 8; /* extract contents of archive */
const int extract_to_stdout = 16; /* extract to stdout */
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
int funct = 0, opt=0;
int srcFd=0, dstFd=0;
ar_headers_t head, *extract_list=NULL;
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
switch (opt) {
case 'o':
funct |= PRESERVE_DATE;
funct |= preserve_date;
break;
case 'v':
funct |= VERBOSE;
funct |= verbose;
break;
case 't':
funct |= DISPLAY;
break;
case 'x':
funct |= EXT_TO_FILE;
funct |= display;
break;
case 'p':
funct |= EXT_TO_STDOUT;
funct |= extract_to_stdout;
break;
case 'R':
funct |= RECURSIVE;
case 'x':
funct |= extract_to_file;
break;
default:
usage(ar_usage);
@@ -345,47 +170,54 @@ extern int ar_main(int argc, char **argv)
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
error_msg_and_die("Cannot read %s\n", argv[optind]);
optind++;
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
header = (headerL_t *) xmalloc(sizeof(headerL_t));
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
optind++;
head = get_headers(srcFd);
header = getHeaders(srcFd, header, funct);
/* find files to extract or display */
if (optind<argc) {
/* only handle specified files */
while(optind < argc) {
if ( (entry = findEntry(header, argv[optind])) != NULL) {
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
*entry->next = *extractList;
*extractList = *entry;
/* search through argv and build extract list */
for (;optind<argc; optind++) {
ar_headers_t *ar_entry;
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
ar_entry = &head;
while (ar_entry->next != NULL) {
if (strcmp(argv[optind], ar_entry->name) == 0) {
ar_headers_t *tmp;
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
*tmp = *extract_list;
*extract_list = *ar_entry;
extract_list->next = tmp;
break;
}
optind++;
}
ar_entry=ar_entry->next;
}
}
/* if individual files not found extract all files */
if (extract_list->next==NULL) {
extract_list = &head;
}
else
extractList = header;
while(extractList->next != NULL) {
if (funct & EXT_TO_FILE) {
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
create_path(extractList->name, 0666);
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
/* find files to extract or display */
while (extract_list->next != NULL) {
if (funct & extract_to_file) {
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
}
if (funct & EXT_TO_STDOUT) {
lseek(srcFd, extractList->offset, SEEK_SET);
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
else if (funct & extract_to_stdout) {
dstFd = fileno(stdout);
}
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
if (funct & VERBOSE)
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
extractList->uid, extractList->gid,
extractList->size, time_string(extractList->mtime));
printf("%s\n", extractList->name);
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
lseek(srcFd, extract_list->offset, SEEK_SET);
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
}
extractList=extractList->next;
if (funct & verbose) {
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
extract_list->uid, extract_list->gid,
extract_list->size, time_string(extract_list->mtime));
}
if ((funct & display) || (funct & verbose)){
printf("%s\n", extract_list->name);
}
extract_list=extract_list->next;
}
return EXIT_SUCCESS;
}
+163
View File
@@ -0,0 +1,163 @@
/*
* 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 <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
typedef struct ar_headers_s {
char *name;
size_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
off_t offset;
struct ar_headers_s *next;
} ar_headers_t;
extern ar_headers_t get_headers(int srcFd);
extern int tar_unzip_init(int tarFd);
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList);
extern int dpkg_deb_main(int argc, char **argv)
{
const int dpkg_deb_contents = 1;
const int dpkg_deb_control = 2;
// const int dpkg_deb_info = 4;
const int dpkg_deb_extract = 8;
const int dpkg_deb_verbose_extract = 16;
int opt=0;
int optflag=0;
int extract_flag = FALSE;
int list_flag = FALSE;
int verbose_flag = FALSE;
int extract_to_stdout = FALSE;
char ar_filename[15];
int srcFd=0;
int status=0;
ar_headers_t *ar_headers = NULL;
char **extract_list=NULL;
char *target_dir=NULL;
while ((opt = getopt(argc, argv, "cexX")) != -1) {
switch (opt) {
case 'c':
optflag |= dpkg_deb_contents;
break;
case 'e':
optflag |= dpkg_deb_control;
break;
/* case 'I':
optflag |= dpkg_deb_info;
break;
*/
case 'x':
optflag |= dpkg_deb_extract;
break;
case 'X':
optflag |= dpkg_deb_verbose_extract;
break;
default:
usage(dpkg_deb_usage);
return EXIT_FAILURE;
}
}
if (((optind + 1 ) > argc) || (optflag == 0)) {
usage(dpkg_deb_usage);
return(EXIT_FAILURE);
}
if (optflag & dpkg_deb_contents) {
list_flag = TRUE;
verbose_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
}
else if (optflag & dpkg_deb_control) {
extract_flag = TRUE;
strcpy(ar_filename, "control.tar.gz");
if ( (optind + 1) == argc ) {
target_dir = (char *) xmalloc(7);
strcpy(target_dir, "DEBIAN");
}
else {
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
}
/* else if (optflag & dpkg_deb_info) {
extract_flag = TRUE;
extract_to_stdout = TRUE;
strcpy(ar_filename, "control.tar.gz");
extract_list = argv+optind+1;
printf("list one is [%s]\n",extract_list[0]);
}
*/
else if (optflag & dpkg_deb_extract) {
extract_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
if ( (optind + 2) > argc ) {
error_msg_and_die("No directory specified\n");
}
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
else if (optflag & dpkg_deb_verbose_extract) {
extract_flag = TRUE;
list_flag = TRUE;
strcpy(ar_filename, "data.tar.gz");
if ( (optind + 2) > argc ) {
error_msg_and_die("No directory specified\n");
}
target_dir = (char *) xmalloc(strlen(argv[optind+1]));
strcpy(target_dir, argv[optind+1]);
}
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
srcFd = open(argv[optind], O_RDONLY);
*ar_headers = get_headers(srcFd);
if (ar_headers->next==NULL)
error_msg_and_die("Couldnt find %s in %s\n",ar_filename, argv[optind]);
while (ar_headers->next != NULL) {
if (strcmp(ar_headers->name, ar_filename)==0)
break;
ar_headers = ar_headers->next;
}
lseek(srcFd, ar_headers->offset, SEEK_SET);
srcFd = tar_unzip_init(srcFd);
if ( target_dir != NULL) {
if (is_directory(target_dir, TRUE, NULL)==FALSE) {
mkdir(target_dir, 0755);
}
if (chdir(target_dir)==-1) {
error_msg_and_die("Cannot change to dir %s\n",argv[optind+1]);
}
}
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
close (srcFd);
return(EXIT_SUCCESS);
}
+29 -26
View File
@@ -76,40 +76,40 @@ static char *license_msg[] = {
#define bb_need_name_too_long
#include "messages.c"
#define RECORD_IO 0
static const int RECORD_IO = 0;
/* Return codes from gzip */
#define OK 0
#define ERROR 1
#define WARNING 2
static const int OK = 0;
static const int ERROR = 1;
static const int WARNING = 2;
#define DEFLATED 8
#define INBUFSIZ 0x2000 /* input buffer size */
#define INBUF_EXTRA 64 /* required by unlzw() */
#define OUTBUFSIZ 8192 /* output buffer size */
#define OUTBUF_EXTRA 2048 /* required by unlzw() */
#define DIST_BUFSIZE 0x2000 /* buffer for distances, see trees.c */
static const int DEFLATED = 8;
static const int INBUFSIZ = 0x2000; /* input buffer size */
static const int INBUF_EXTRA = 64; /* required by unlzw() */
static const int OUTBUFSIZ = 8192; /* output buffer size */
static const int OUTBUF_EXTRA = 2048; /* required by unlzw() */
static const int DIST_BUFSIZE = 0x2000; /* buffer for distances, see trees.c */
#define GZIP_MAGIC "\037\213" /* Magic header for gzip files, 1F 8B */
/* gzip flag byte */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define WSIZE 0x8000 /* window size--must be a power of two, and */
static const int EXTRA_FIELD = 0x04; /* bit 2 set: extra field present */
static const int ORIG_NAME = 0x08; /* bit 3 set: original file name present */
static const int COMMENT = 0x10; /* bit 4 set: file comment present */
static const int WSIZE = 0x8000; /* window size--must be a power of two, and */
/* at least 32K for zip's deflate method */
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
#define N_MAX 288 /* maximum number of codes in any set */
static const int BMAX = 16; /* maximum bit length of any code (16 for explode) */
static const int N_MAX = 288; /* maximum number of codes in any set */
/* PKZIP header definitions */
#define LOCSIG 0x04034b50L /* four-byte lead-in (lsb first) */
#define LOCCRC 14 /* offset of crc */
#define LOCLEN 22 /* offset of uncompressed length */
#define EXTHDR 16 /* size of extended local header, inc sig */
static const int LOCSIG = 0x04034b50L; /* four-byte lead-in (lsb first) */
static const int LOCCRC = 14; /* offset of crc */
static const int LOCLEN = 22; /* offset of uncompressed length */
static const int EXTHDR = 16; /* size of extended local header, inc sig */
#define BITS 16
static const int BITS = 16;
/* Diagnostic functions */
#ifdef DEBUG
@@ -132,7 +132,7 @@ static char *license_msg[] = {
# ifdef BUFSIZ
# define MAX_PATH_LEN BUFSIZ
# else
# define MAX_PATH_LEN 1024
static const int MAX_PATH_LEN = 1024;
# endif
#endif
@@ -165,8 +165,8 @@ static ush *tab_prefix1;
/* local variables */
static int test_mode = 0; /* check file integrity option */
static int foreground; /* set if program run in foreground */
static int method = DEFLATED; /* compression method */
static int exit_code = OK; /* program exit code */
static int method; /* compression method */
static int exit_code; /* program exit code */
static int last_member; /* set for .zip and .Z files */
static int part_nb; /* number of parts in .gz file */
static long ifile_size; /* input file size, -1 for devices (debug only) */
@@ -1222,8 +1222,11 @@ int gunzip_main(int argc, char **argv)
int force = 0;
struct stat statBuf;
char *delFileName;
char ifname[MAX_PATH_LEN + 1]; /* input file name */
char ofname[MAX_PATH_LEN + 1]; /* output file name */
RESERVE_BB_BUFFER(ifname, MAX_PATH_LEN+1); /* input file name */
RESERVE_BB_BUFFER(ofname, MAX_PATH_LEN+1); /* output file name */
method = DEFLATED; /* default compression method */
exit_code = OK; /* let's go out on a limb and assume everything will run fine (wink wink) */
if (strcmp(applet_name, "zcat") == 0) {
force = 1;
+10 -18
View File
@@ -45,6 +45,7 @@
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#define memzero(s, n) memset ((void *)(s), 0, (n))
#ifndef RETSIGTYPE
@@ -1867,18 +1868,13 @@ int gzip_main(int argc, char **argv)
usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
/* Open input fille */
/* Open input file */
inFileNum = open(ifname, O_RDONLY);
if (inFileNum < 0) {
perror(ifname);
exit(WARNING);
}
if (inFileNum < 0)
perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
result = stat(ifname, &statBuf);
if (result < 0) {
perror(ifname);
exit(WARNING);
}
if (stat(ifname, &statBuf) < 0)
perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
@@ -1909,10 +1905,8 @@ int gzip_main(int argc, char **argv)
#else
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
#endif
if (outFileNum < 0) {
perror(ofname);
exit(WARNING);
}
if (outFileNum < 0)
perror_msg_and_die("%s", ofname);
SET_BINARY_MODE(outFileNum);
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
@@ -1930,10 +1924,8 @@ int gzip_main(int argc, char **argv)
else
delFileName = ofname;
if (unlink(delFileName) < 0) {
perror(delFileName);
exit(EXIT_FAILURE);
}
if (unlink(delFileName) < 0)
perror_msg_and_die("%s", delFileName);
}
return(exit_code);
+193 -200
View File
@@ -6,7 +6,7 @@
* 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) 2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Based in part in the tar implementation in sash
@@ -51,6 +51,10 @@
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <getopt.h>
#include <fnmatch.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#ifdef BB_FEATURE_TAR_GZIP
extern int unzip(int in, int out);
@@ -63,7 +67,7 @@ extern int gunzip_init();
#define MINOR(dev) ((dev)&0xff)
#endif
#define NAME_SIZE 100
enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
struct TarHeader
@@ -93,9 +97,9 @@ typedef struct TarHeader TarHeader;
/* A few useful constants */
#define TAR_MAGIC "ustar" /* ustar and a null */
#define TAR_VERSION " " /* Be compatable with GNU tar format */
#define TAR_MAGIC_LEN 6
#define TAR_VERSION_LEN 2
#define TAR_BLOCK_SIZE 512
static const int TAR_MAGIC_LEN = 6;
static const int TAR_VERSION_LEN = 2;
static const int TAR_BLOCK_SIZE = 512;
/* A nice enum with all the possible tar file content types */
enum TarFileType
@@ -134,7 +138,7 @@ struct TarInfo
typedef struct TarInfo TarInfo;
/* Local procedures to restore files from a tar file. */
static int readTarFile(int tarFd, int extractFlag, int listFlag,
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
int tostdoutFlag, int verboseFlag, char** extractList,
char** excludeList);
@@ -153,7 +157,7 @@ void child_died()
exit(EXIT_FAILURE);
}
static int tar_unzip_init(int tarFd)
extern int tar_unzip_init(int tarFd)
{
int child_pid;
static int unzip_pipe[2];
@@ -162,22 +166,32 @@ static int tar_unzip_init(int tarFd)
if (pipe(unzip_pipe)!=0)
error_msg_and_die("pipe error\n");
if ( (child_pid = fork()) == -1)
error_msg_and_die("fork failure\n");
if (child_pid==0) {
/* child process */
close(unzip_pipe[0]);
gunzip_init();
unzip(tarFd, unzip_pipe[1]);
exit(EXIT_SUCCESS);
}
else
else {
/* return fd of uncompressed data to parent process */
close(unzip_pipe[1]);
return(unzip_pipe[0]);
}
}
#endif
#if defined BB_FEATURE_TAR_EXCLUDE
struct option longopts[] = {
{ "exclude", 1, NULL, 'e' },
{ NULL, 0, NULL, 0 }
};
#endif
extern int tar_main(int argc, char **argv)
{
char** excludeList=NULL;
@@ -185,7 +199,6 @@ extern int tar_main(int argc, char **argv)
const char *tarName="-";
#if defined BB_FEATURE_TAR_EXCLUDE
int excludeListSize=0;
char *excludeFileName ="-";
FILE *fileList;
char file[256];
#endif
@@ -198,101 +211,84 @@ extern int tar_main(int argc, char **argv)
int verboseFlag = FALSE;
int tostdoutFlag = FALSE;
int status = FALSE;
int firstOpt = TRUE;
int stopIt;
int opt;
if (argc <= 1)
usage(tar_usage);
while (*(++argv) && (**argv == '-' || firstOpt == TRUE)) {
firstOpt=FALSE;
stopIt=FALSE;
while (stopIt==FALSE && **argv) {
switch (*((*argv)++)) {
case 'c':
if (extractFlag == TRUE || listFlag == TRUE)
goto flagError;
createFlag = TRUE;
break;
case 'x':
if (listFlag == TRUE || createFlag == TRUE)
goto flagError;
extractFlag = TRUE;
break;
case 't':
if (extractFlag == TRUE || createFlag == TRUE)
goto flagError;
listFlag = TRUE;
break;
if (argv[1][0] != '-') {
char *tmp = xmalloc(strlen(argv[1]) + 2);
tmp[0] = '-';
strcpy(tmp + 1, argv[1]);
argv[1] = tmp;
}
while (
#ifndef BB_FEATURE_TAR_EXCLUDE
(opt = getopt(argc, argv, "cxtzvOf:"))
#else
(opt = getopt_long(argc, argv, "cxtzvOf:X:", longopts, NULL))
#endif
> 0) {
switch (opt) {
case 'c':
if (extractFlag == TRUE || listFlag == TRUE)
goto flagError;
createFlag = TRUE;
break;
case 'x':
if (listFlag == TRUE || createFlag == TRUE)
goto flagError;
extractFlag = TRUE;
break;
case 't':
if (extractFlag == TRUE || createFlag == TRUE)
goto flagError;
listFlag = TRUE;
break;
#ifdef BB_FEATURE_TAR_GZIP
case 'z':
unzipFlag = TRUE;
break;
case 'z':
unzipFlag = TRUE;
break;
#endif
case 'v':
verboseFlag = TRUE;
break;
case 'O':
tostdoutFlag = TRUE;
break;
case 'f':
if (*tarName != '-')
error_msg_and_die( "Only one 'f' option allowed\n");
tarName = *(++argv);
if (tarName == NULL)
error_msg_and_die( "Option requires an argument: No file specified\n");
stopIt=TRUE;
break;
case 'v':
verboseFlag = TRUE;
break;
case 'O':
tostdoutFlag = TRUE;
break;
case 'f':
if (*tarName != '-')
error_msg_and_die( "Only one 'f' option allowed\n");
tarName = optarg;
break;
#if defined BB_FEATURE_TAR_EXCLUDE
case 'e':
if (strcmp(*argv, "xclude")==0) {
excludeList=xrealloc( excludeList,
sizeof(char *) * (excludeListSize+2));
excludeList[excludeListSize] = *(++argv);
if (excludeList[excludeListSize] == NULL)
error_msg_and_die( "Option requires an argument: No file specified\n");
/* Remove leading "/"s */
if (*excludeList[excludeListSize] =='/')
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
/* Tack a NULL onto the end of the list */
excludeList[++excludeListSize] = NULL;
stopIt=TRUE;
break;
}
case 'X':
if (*excludeFileName != '-')
error_msg_and_die("Only one 'X' option allowed\n");
excludeFileName = *(++argv);
if (excludeFileName == NULL)
error_msg_and_die("Option requires an argument: No file specified\n");
fileList = fopen (excludeFileName, "r");
if (! fileList)
error_msg_and_die("Exclude file: file not found\n");
while (fgets(file, sizeof(file), fileList) != NULL) {
excludeList = xrealloc(excludeList,
sizeof(char *) * (excludeListSize+2));
if (file[strlen(file)-1] == '\n')
file[strlen(file)-1] = '\0';
excludeList[excludeListSize] = xstrdup(file);
/* Remove leading "/"s */
while (*excludeList[excludeListSize] == '/')
excludeList[excludeListSize]++;
/* Tack a NULL onto the end of the list */
excludeList[++excludeListSize] = NULL;
}
fclose(fileList);
stopIt=TRUE;
break;
case 'e':
excludeList=xrealloc( excludeList,
sizeof(char *) * (excludeListSize+2));
excludeList[excludeListSize] = optarg;
/* Tack a NULL onto the end of the list */
excludeList[++excludeListSize] = NULL;
case 'X':
fileList = xfopen(optarg, "r");
while (fgets(file, sizeof(file), fileList) != NULL) {
excludeList = xrealloc(excludeList,
sizeof(char *) * (excludeListSize+2));
if (file[strlen(file)-1] == '\n')
file[strlen(file)-1] = '\0';
excludeList[excludeListSize] = xstrdup(file);
/* Tack a NULL onto the end of the list */
excludeList[++excludeListSize] = NULL;
}
fclose(fileList);
break;
#endif
case '-':
break;
default:
usage(tar_usage);
}
}
}
/*
/*
* Do the correct type of action supplying the rest of the
* command line arguments as the list of files to process.
*/
@@ -304,20 +300,20 @@ extern int tar_main(int argc, char **argv)
if (unzipFlag==TRUE)
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip\n");
#endif
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
status = writeTarFile(tarName, verboseFlag, argv + optind, excludeList);
#endif
}
if (listFlag == TRUE || extractFlag == TRUE) {
int tarFd;
if (*argv)
extractList = argv;
if (argv[optind])
extractList = argv + optind;
/* Open the tar file for reading. */
if (!strcmp(tarName, "-"))
tarFd = fileno(stdin);
else
tarFd = open(tarName, O_RDONLY);
if (tarFd < 0)
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno));
perror_msg_and_die("Error opening '%s'", tarName);
#ifdef BB_FEATURE_TAR_GZIP
/* unzip tarFd in a seperate process */
@@ -425,16 +421,18 @@ tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE);
if (create_path(header->name, header->mode) != TRUE) {
error_msg("%s: Cannot mkdir: %s\n",
header->name, strerror(errno));
perror_msg("%s: Cannot mkdir", header->name);
return( FALSE);
}
/* make the final component, just in case it was
* omitted by create_path() (which will skip the
* directory if it doesn't have a terminating '/') */
if (mkdir(header->name, header->mode) == 0) {
fixUpPermissions(header);
if (mkdir(header->name, header->mode) < 0 && errno != EEXIST) {
perror_msg("%s", header->name);
return FALSE;
}
fixUpPermissions(header);
return( TRUE);
}
@@ -445,8 +443,8 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
return( TRUE);
if (link(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create hard link to '%s': %s\n",
header->name, header->linkname, strerror(errno));
perror_msg("%s: Cannot create hard link to '%s'", header->name,
header->linkname);
return( FALSE);
}
@@ -463,8 +461,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
#ifdef S_ISLNK
if (symlink(header->linkname, header->name) < 0) {
error_msg("%s: Cannot create symlink to '%s': %s\n",
header->name, header->linkname, strerror(errno));
perror_msg("%s: Cannot create symlink to '%s'", header->name,
header->linkname);
return( FALSE);
}
/* Try to change ownership of the symlink.
@@ -493,14 +491,12 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
error_msg("%s: Cannot mknod: %s\n",
header->name, strerror(errno));
perror_msg("%s: Cannot mknod", header->name);
return( FALSE);
}
} else if (S_ISFIFO(header->mode)) {
if (mkfifo(header->name, header->mode) < 0) {
error_msg("%s: Cannot mkfifo: %s\n",
header->name, strerror(errno));
perror_msg("%s: Cannot mkfifo", header->name);
return( FALSE);
}
}
@@ -579,6 +575,47 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
return( FALSE);
}
int exclude_file(char **excluded_files, const char *file)
{
int i;
if (excluded_files == NULL)
return 0;
for (i = 0; excluded_files[i] != NULL; i++) {
if (excluded_files[i][0] == '/') {
if (fnmatch(excluded_files[i], file,
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
return 1;
} else {
const char *p;
for (p = file; p[0] != '\0'; p++) {
if ((p == file || p[-1] == '/') && p[0] != '/' &&
fnmatch(excluded_files[i], p,
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
return 1;
}
}
}
return 0;
}
int extract_file(char **extract_files, const char *file)
{
int i;
if (extract_files == NULL)
return 1;
for (i = 0; extract_files[i] != NULL; i++) {
if (fnmatch(extract_files[i], file, FNM_LEADING_DIR) == 0)
return 1;
}
return 0;
}
/*
* Read a tar file and extract or list the specified files within it.
@@ -593,7 +630,6 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
int skipNextHeaderFlag=FALSE;
TarHeader rawHeader;
TarInfo header;
char** tmpList;
/* Set the umask for this process so it doesn't
* screw up permission setting for us later. */
@@ -632,56 +668,29 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
}
#if defined BB_FEATURE_TAR_EXCLUDE
{
int skipFlag=FALSE;
/* Check for excluded files.... */
for (tmpList=excludeList; tmpList && *tmpList; tmpList++) {
/* Do some extra hoop jumping for when directory names
* end in '/' but the entry in tmpList doesn't */
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
header.name[strlen(header.name)-1]=='/'
&& strncmp( *tmpList, header.name,
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
/* If it is a regular file, pretend to extract it with
* the extractFlag set to FALSE, so the junk in the tarball
* is properly skipped over */
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
}
skipFlag=TRUE;
break;
}
}
if (exclude_file(excludeList, header.name)) {
/* There are not the droids you're looking for, move along */
if (skipFlag==TRUE)
continue;
/* If it is a regular file, pretend to extract it with
* the extractFlag set to FALSE, so the junk in the tarball
* is properly skipped over */
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
}
continue;
}
#endif
if (extractList != NULL) {
int skipFlag = TRUE;
for (tmpList = extractList; *tmpList != NULL; tmpList++) {
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
header.name[strlen(header.name)-1]=='/'
&& strncmp( *tmpList, header.name,
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
/* If it is a regular file, pretend to extract it with
* the extractFlag set to FALSE, so the junk in the tarball
* is properly skipped over */
skipFlag = FALSE;
memmove(extractList+1, extractList,
sizeof(*extractList)*(tmpList-extractList));
extractList++;
break;
}
}
if (!extract_file(extractList, header.name)) {
/* There are not the droids you're looking for, move along */
if (skipFlag == TRUE) {
if ( header.type==REGTYPE || header.type==REGTYPE0 )
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
continue;
/* If it is a regular file, pretend to extract it with
* the extractFlag set to FALSE, so the junk in the tarball
* is properly skipped over */
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
errorFlag = TRUE;
}
continue;
}
if (listFlag == TRUE) {
@@ -790,7 +799,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
close(tarFd);
if (status > 0) {
/* Bummer - we read a partial header */
error_msg( "Error reading tar file: %s\n", strerror(errno));
perror_msg("Error reading tar file");
return ( FALSE);
}
else if (errorFlag==TRUE) {
@@ -802,12 +811,6 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
/* Stuff to do when we are done */
endgame:
close( tarFd);
if (extractList != NULL) {
for (; *extractList != NULL; extractList++) {
error_msg("%s: Not found in archive\n", *extractList);
errorFlag = TRUE;
}
}
if ( *(header.name) == '\0' ) {
if (errorFlag==TRUE)
error_msg( "Error exit delayed from previous errors\n");
@@ -939,47 +942,17 @@ static int putOctal (char *cp, int len, long value)
/* Write out a tar header for the specified file/directory/whatever */
static int
writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *statbuf)
writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name,
const char *real_name, struct stat *statbuf)
{
long chksum=0;
struct TarHeader header;
#if defined BB_FEATURE_TAR_EXCLUDE
char** tmpList;
#endif
const unsigned char *cp = (const unsigned char *) &header;
ssize_t size = sizeof(struct TarHeader);
memset( &header, 0, size);
if (*fileName=='/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
strncpy(header.name, fileName+1, sizeof(header.name));
}
else {
strncpy(header.name, fileName, sizeof(header.name));
}
#if defined BB_FEATURE_TAR_EXCLUDE
/* Check for excluded files.... */
for (tmpList=tbInfo->excludeList; tmpList && *tmpList; tmpList++) {
/* Do some extra hoop jumping for when directory names
* end in '/' but the entry in tmpList doesn't */
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
header.name[strlen(header.name)-1]=='/'
&& strncmp( *tmpList, header.name,
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
/* Set the mode to something that is not a regular file, thereby
* faking out writeTarFile into thinking that nothing further need
* be done for this file. Yes, I know this is ugly, but it works. */
statbuf->st_mode = 0;
return( TRUE);
}
}
#endif
strncpy(header.name, header_name, sizeof(header.name));
putOctal(header.mode, sizeof(header.mode), statbuf->st_mode);
putOctal(header.uid, sizeof(header.uid), statbuf->st_uid);
@@ -1005,9 +978,9 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
int link_size=0;
char buffer[BUFSIZ];
header.typeflag = SYMTYPE;
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
link_size = readlink(real_name, buffer, sizeof(buffer) - 1);
if ( link_size < 0) {
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
perror_msg("Error reading symlink '%s'", header.name);
return ( FALSE);
}
buffer[link_size] = '\0';
@@ -1029,7 +1002,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
header.typeflag = REGTYPE;
putOctal(header.size, sizeof(header.size), statbuf->st_size);
} else {
error_msg("%s: Unknown file type\n", fileName);
error_msg("%s: Unknown file type\n", real_name);
return ( FALSE);
}
@@ -1046,7 +1019,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
/* Now write the header out to disk */
if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
error_msg(io_error, fileName, strerror(errno));
error_msg(io_error, real_name, strerror(errno));
return ( FALSE);
}
/* Pad the header up to the tar block size */
@@ -1068,6 +1041,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* userData)
{
struct TarBallInfo *tbInfo = (struct TarBallInfo *)userData;
const char *header_name;
/*
** Check to see if we are dealing with a hard link.
@@ -1100,12 +1074,31 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
return( TRUE);
}
header_name = fileName;
while (header_name[0] == '/') {
static int alreadyWarned=FALSE;
if (alreadyWarned==FALSE) {
error_msg("Removing leading '/' from member names\n");
alreadyWarned=TRUE;
}
header_name++;
}
if (strlen(fileName) >= NAME_SIZE) {
error_msg(name_longer_than_foo, NAME_SIZE);
return ( TRUE);
}
if (writeTarHeader(tbInfo, fileName, statbuf)==FALSE) {
if (header_name[0] == '\0')
return TRUE;
#if defined BB_FEATURE_TAR_EXCLUDE
if (exclude_file(tbInfo->excludeList, header_name)) {
return SKIP;
}
#endif
if (writeTarHeader(tbInfo, header_name, fileName, statbuf)==FALSE) {
return( FALSE);
}
@@ -1165,7 +1158,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
else
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (tbInfo.tarFd < 0) {
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
perror_msg( "Error opening '%s'", tarName);
freeHardLinkInfo(&tbInfo.hlInfoHead);
return ( FALSE);
}
+3 -2
View File
@@ -2,7 +2,7 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,7 +22,8 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int basename_main(int argc, char **argv)
{
+48 -60
View File
@@ -2,7 +2,9 @@
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#undef APPLET
#undef APPLET_NOUSAGE
@@ -14,8 +16,6 @@
#include "messages.c"
static int been_there_done_that = 0;
const char *applet_name;
#ifdef BB_FEATURE_INSTALLER
@@ -54,7 +54,7 @@ static char *busybox_fullpath()
if (len != -1) {
path[len] = 0;
} else {
error_msg("%s: %s\n", proc, strerror(errno));
perror_msg("%s", proc);
return NULL;
}
return strdup(path);
@@ -69,16 +69,16 @@ static void install_links(const char *busybox, int use_symbolic_links)
int i;
int rc;
if (use_symbolic_links) Link = symlink;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
sprintf ( command, "%s/%s",
install_dir[applets[i].location],
applets[i].name);
install_dir[applets[i].location], applets[i].name);
rc = Link(busybox, command);
if (rc) {
error_msg("%s: %s\n", command, strerror(errno));
perror_msg("%s", command);
}
}
}
@@ -89,7 +89,37 @@ int main(int argc, char **argv)
{
struct BB_applet search_applet, *applet;
const char *s;
applet_name = "busybox";
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
error_msg_and_die("applet not found\n");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef BB_FEATURE_INSTALLER
/*
@@ -121,39 +151,6 @@ int main(int argc, char **argv)
}
#endif /* BB_FEATURE_INSTALLER */
for (s = applet_name = argv[0]; *s != '\0';) {
if (*s++ == '/')
applet_name = s;
}
#ifdef BB_SH
/* Add in a special case hack -- whenever **argv == '-'
* (i.e. '-su' or '-sh') always invoke the shell */
if (**argv == '-' && *(*argv+1)!= '-') {
exit(((*(shell_main)) (argc, argv)));
}
#endif
/* Do a binary search to find the applet entry given the name. */
search_applet.name = applet_name;
applet = bsearch(&search_applet, applets, NUM_APPLETS,
sizeof(struct BB_applet), applet_name_compare);
if (applet != NULL) {
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
usage(applet->usage);
exit((*(applet->main)) (argc, argv));
}
return(busybox_main(argc, argv));
}
int busybox_main(int argc, char **argv)
{
int col = 0;
int ps_index;
char *index, *index2;
argc--;
/* If we've already been here once, exit now */
@@ -185,25 +182,16 @@ int busybox_main(int argc, char **argv)
/* Flag that we've been here already */
been_there_done_that = 1;
/* We do not want the word "busybox" to show up in ps, so we move
* everything in argv around to fake ps into showing what we want it to
* show. Since we are only shrinking the string, we don't need to move
* __environ or any of that tedious stuff... */
ps_index = 0;
index=*argv;
index2=argv[argc];
index2+=strlen(argv[argc]);
while(ps_index < argc) {
argv[ps_index]=index;
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
index+=(strlen(index));
*index='\0';
index++;
ps_index++;
}
while(index<=index2)
*index++='\0';
argv[ps_index]=NULL;
/* 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));
}
+30 -36
View File
@@ -26,27 +26,19 @@
#include "Config.h"
#include <stdio.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <mntent.h>
#include <regex.h>
/* for the _syscall() macros */
#include <sys/syscall.h>
#include <linux/unistd.h>
/* Some useful definitions */
#define FALSE ((int) 0)
#define TRUE ((int) 1)
#define SKIP ((int) 2)
/* for mtab.c */
#define MTAB_GETMOUNTPT '1'
@@ -68,26 +60,6 @@ static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
#endif
/* I don't like nested includes, but the string and io functions are used
* too often
*/
#include <stdio.h>
#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
# include <string.h>
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
# include <memory.h>
# endif
# define memzero(s, n) memset ((void *)(s), 0, (n))
#else
# include <strings.h>
# define strchr index
# define strrchr rindex
# define memcpy(d, s, n) bcopy((s), (d), (n))
# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
# define memzero(s, n) bzero((s), (n))
#endif
enum Location {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
@@ -147,6 +119,7 @@ int makeString(int argc, const char **argv, char *buf, int bufLen);
char *getChunk(int size);
char *chunkstrdup(const char *str);
void freeChunks(void);
ssize_t safe_read(int fd, void *buf, size_t count);
int full_write(int fd, const char *buf, int len);
int full_read(int fd, char *buf, int len);
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
@@ -177,11 +150,10 @@ extern void print_file(FILE *file);
extern int print_file_by_name(char *filename);
extern char process_escape_sequence(char **ptr);
extern char *get_last_path_component(char *path);
extern void xregcomp(regex_t *preg, const char *regex, int cflags);
extern FILE *wfopen(const char *path, const char *mode);
extern FILE *xfopen(const char *path, const char *mode);
#ifndef DMALLOC
#ifndef DMALLOC
extern void *xmalloc (size_t size);
extern void *xrealloc(void *old, size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
@@ -189,6 +161,13 @@ extern char *xstrdup (const char *s);
#endif
extern char *xstrndup (const char *s, int n);
struct suffix_mult {
char *suffix;
int mult;
};
extern unsigned long parse_number(const char *numstr, struct suffix_mult *suffixes);
/* These parse entries in /etc/passwd and /etc/group. This is desirable
* for BusyBox since we want to avoid using the glibc NSS stuff, which
@@ -250,4 +229,19 @@ extern int sysinfo (struct sysinfo* info);
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
char *format(unsigned long val, unsigned long hr);
#define KILOBYTE 1024
#define MEGABYTE (KILOBYTE*1024)
#define GIGABYTE (MEGABYTE*1024)
#endif
#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]
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
#endif
#endif /* _BB_INTERNAL_H_ */
+7 -2
View File
@@ -1,12 +1,17 @@
#!/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>
CONFIG_H=${1:-Config.h}
APPLETS_H=${2:-applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
match($2,"_BB_DIR[A-Z_]*")
dir=substr($2,RSTART+7,RLENGTH-7)
dir=substr($2,8)
gsub("_","/",dir)
if(dir=="/ROOT") dir=""
file=$3
+1 -1
View File
@@ -3,7 +3,7 @@
RAW=` \
gcc -E -dM ${1:-Config.h} | \
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
| tr '[:upper:]' '[:lower:]' | sort
| tr A-Z a-z | sort
`
test "${RAW}" != "" || exit
cd ${2:-.}
+1 -1
View File
@@ -1,5 +1,5 @@
Name: busybox
Version: 0.48
Version: 0.49
Release: 1
Group: System/Utilities
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
+2 -2
View File
@@ -2,7 +2,7 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,7 +22,7 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int cat_main(int argc, char **argv)
{
+4 -3
View File
@@ -3,7 +3,7 @@
* Mini chown/chmod/chgrp implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -29,8 +29,9 @@
#include "messages.c"
#include <stdio.h>
#include <grp.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static long uid = -1;
+4 -3
View File
@@ -3,7 +3,7 @@
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -25,6 +25,7 @@
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int chroot_main(int argc, char **argv)
@@ -38,7 +39,7 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
@@ -57,7 +58,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS;
#endif
}
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
perror_msg_and_die("cannot execute %s", prog);
}
+6 -10
View File
@@ -12,8 +12,8 @@
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
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)
{
@@ -23,14 +23,10 @@ int chvt_main(int argc, char **argv)
usage (chvt_usage);
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
return EXIT_FAILURE;
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
return EXIT_FAILURE;
}
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;
}
+2 -1
View File
@@ -3,7 +3,7 @@
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -24,6 +24,7 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int clear_main(int argc, char **argv)
+531 -261
View File
File diff suppressed because it is too large. Load diff
-13
View File
@@ -2,24 +2,11 @@
#define CMDEDIT_H
#ifdef BB_FEATURE_SH_COMMAND_EDITING
/* unix systems can #define POSIX to use termios, otherwise
* the bsd or sysv interface will be used
*/
#include <stddef.h>
typedef size_t (*cmdedit_strwidth_proc)(char *);
void cmdedit_init(void);
void cmdedit_terminate(void);
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
void cmdedit_setwidth(int); /* specify width of screen */
void cmdedit_histadd(char *); /* adds entries to hist */
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
extern int (*cmdedit_in_hook)(char *);
extern int (*cmdedit_out_hook)(char *);
extern int (*cmdedit_tab_hook)(char *, int, int *);
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
+2 -1
View File
@@ -3,7 +3,7 @@
* Mini cmp implementation for busybox
*
*
* Copyright (C) 2000 by Lineo, inc.
* 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
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
int cmp_main(int argc, char **argv)
{
+6 -10
View File
@@ -12,8 +12,8 @@
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_ACTIVATE 0x5606 /* make vt active */
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
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)
{
@@ -23,14 +23,10 @@ int chvt_main(int argc, char **argv)
usage (chvt_usage);
fd = get_console_fd("/dev/console");
num = atoi(argv[1]);
if (ioctl(fd, VT_ACTIVATE, num)) {
perror("VT_ACTIVATE");
return EXIT_FAILURE;
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
perror("VT_WAITACTIVE");
return EXIT_FAILURE;
}
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;
}
+2 -1
View File
@@ -3,7 +3,7 @@
* Mini clear implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -24,6 +24,7 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int clear_main(int argc, char **argv)
+8 -13
View File
@@ -11,7 +11,7 @@
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
@@ -24,25 +24,20 @@ int deallocvt_main(int argc, char *argv[])
fd = get_console_fd("/dev/console");
if (argc == 1) {
printf("erik: A\n");
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
return EXIT_FAILURE;
}
} else
printf("erik: B\n");
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\n");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
error_msg_and_die("could not deallocate console %d\n", num);
}
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
printf("erik: C\n");
}
return EXIT_SUCCESS;
}
+7 -4
View File
@@ -24,6 +24,9 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
/* From <linux/kd.h> */
@@ -32,11 +35,11 @@ struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int dumpkmap_main(int argc, char **argv)
{
@@ -50,7 +53,7 @@ int dumpkmap_main(int argc, char **argv)
fd = open("/dev/tty0", O_RDWR);
if (fd < 0) {
error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
perror_msg("Error opening /dev/tty0");
return EXIT_FAILURE;
}
+21 -32
View File
@@ -39,13 +39,11 @@ int loadacm_main(int argc, char **argv)
fd = open("/dev/tty", O_RDWR);
if (fd < 0) {
error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
return EXIT_FAILURE;
perror_msg_and_die("Error opening /dev/tty1");
}
if (screen_map_load(fd, stdin)) {
error_msg("Error loading acm: %s\n", strerror(errno));
return EXIT_FAILURE;
perror_msg_and_die("Error loading acm");
}
write(fd, "\033(K", 3);
@@ -62,7 +60,7 @@ int screen_map_load(int fd, FILE * fp)
int is_unicode;
if (fstat(fileno(fp), &stbuf))
perror("Cannot stat map file"), exit(1);
perror_msg_and_die("Cannot stat map file");
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
@@ -72,15 +70,13 @@ int screen_map_load(int fd, FILE * fp)
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
error_msg("16bit screen-map MUST be a regular file.\n"),
exit(1);
error_msg_and_die("16bit screen-map MUST be a regular file.\n");
else
perror("fseek failed reading binary 16bit screen-map"),
exit(1);
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
perror("Cannot read [new] map from file"), exit(1);
perror_msg_and_die("Cannot read [new] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
@@ -91,7 +87,7 @@ int screen_map_load(int fd, FILE * fp)
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
perror("PIO_UNISCRNMAP ioctl"), exit(1);
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
else
return 0;
}
@@ -103,7 +99,7 @@ int screen_map_load(int fd, FILE * fp)
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
perror("fseek failed assuming 8bit screen-map"), exit(1);
perror_msg_and_die("fseek failed assuming 8bit screen-map");
}
/* ... and try an old 8-bit screen-map */
@@ -113,14 +109,13 @@ int screen_map_load(int fd, FILE * fp)
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
error_msg("fseek() returned ESPIPE !\n"),
exit(1);
error_msg_and_die("fseek() returned ESPIPE !\n");
else
perror("fseek for binary 8bit screen-map"), exit(1);
perror_msg_and_die("fseek for binary 8bit screen-map");
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
perror("Cannot read [old] map from file"), exit(1);
perror_msg_and_die("Cannot read [old] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
@@ -128,7 +123,7 @@ int screen_map_load(int fd, FILE * fp)
}
if (ioctl(fd, PIO_SCRNMAP, buf))
perror("PIO_SCRNMAP ioctl"), exit(1);
perror_msg_and_die("PIO_SCRNMAP ioctl");
else
return 0;
}
@@ -176,10 +171,8 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
else {
perror("uni_screen_map_read_ascii() can't read line");
exit(2);
}
else
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
@@ -319,12 +312,11 @@ void saveoldmap(int fd, char *omfil)
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
perror("GIO_UNISCRNMAP ioctl error");
perror_msg("GIO_UNISCRNMAP ioctl error");
#endif
if (ioctl(fd, GIO_SCRNMAP, buf)) {
perror("GIO_SCRNMAP ioctl error");
exit(1);
} else
if (ioctl(fd, GIO_SCRNMAP, buf))
perror_msg_and_die("GIO_SCRNMAP ioctl error");
else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
@@ -334,14 +326,11 @@ void saveoldmap(int fd, char *omfil)
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
}
if (fwrite(buf, E_TABSZ, 1, fp) != 1)
perror_msg_and_die("Error writing map to file");
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
perror("Error writing map to file");
exit(1);
perror_msg_and_die("Error writing map to file");
}
#endif
+6 -6
View File
@@ -21,13 +21,13 @@
#include <sys/kd.h>
#include <endian.h>
#define PSF_MAGIC1 0x36
#define PSF_MAGIC2 0x04
static const int PSF_MAGIC1 = 0x36;
static const int PSF_MAGIC2 = 0x04;
#define PSF_MODE512 0x01
#define PSF_MODEHASTAB 0x02
#define PSF_MAXMODE 0x03
#define PSF_SEPARATOR 0xFFFF
static const int PSF_MODE512 = 0x01;
static const int PSF_MODEHASTAB = 0x02;
static const int PSF_MAXMODE = 0x03;
static const int PSF_SEPARATOR = 0xFFFF;
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
+6 -3
View File
@@ -24,6 +24,9 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#define BINARY_KEYMAP_MAGIC "bkeymap"
@@ -34,11 +37,11 @@ struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
/* From <linux/keyboard.h> */
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
int loadkmap_main(int argc, char **argv)
{
+2 -1
View File
@@ -3,7 +3,7 @@
* Mini reset implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
* and Kent Robotti <robotti@metconnect.com>
*
@@ -25,6 +25,7 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int reset_main(int argc, char **argv)
{
+1 -1
View File
@@ -33,7 +33,7 @@
struct kbkeycode {
unsigned int scancode, keycode;
};
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
extern int
setkeycodes_main(int argc, char** argv)
+3 -2
View File
@@ -2,7 +2,7 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,7 +22,8 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int basename_main(int argc, char **argv)
{
+2 -2
View File
@@ -2,7 +2,7 @@
/*
* Mini Cat implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -22,7 +22,7 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int cat_main(int argc, char **argv)
{
+4 -3
View File
@@ -3,7 +3,7 @@
* Mini chroot implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -25,6 +25,7 @@
#include "busybox.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int chroot_main(int argc, char **argv)
@@ -38,7 +39,7 @@ int chroot_main(int argc, char **argv)
argv++;
if (chroot(*argv) || (chdir("/"))) {
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
perror_msg_and_die("cannot change root directory to %s", *argv);
}
argc--;
@@ -57,7 +58,7 @@ int chroot_main(int argc, char **argv)
return EXIT_SUCCESS;
#endif
}
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
perror_msg_and_die("cannot execute %s", prog);
}
+2 -1
View File
@@ -3,7 +3,7 @@
* Mini cmp implementation for busybox
*
*
* Copyright (C) 2000 by Lineo, inc.
* 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
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
int cmp_main(int argc, char **argv)
{
+7 -6
View File
@@ -1,8 +1,8 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
* 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
@@ -188,7 +188,7 @@ extern int cut_main(int argc, char **argv)
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");
error_msg_and_die("only one type of list may be specified\n");
}
part = (char)opt;
decompose_list(optarg);
@@ -213,8 +213,9 @@ extern int cut_main(int argc, char **argv)
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
@@ -233,7 +234,7 @@ extern int cut_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
error_msg("%s: %s\n", argv[i], strerror(errno));
perror_msg("%s", argv[i]);
} else {
cut_file(file);
fclose(file);
+1
View File
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
+114 -137
View File
@@ -2,15 +2,8 @@
/*
* Mini dd implementation for busybox
*
* Copyright (C) 1999, 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Based in part on code taken from sash.
* Copyright (c) 1999 by David I. Bell
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Permission to distribute this code under the GPL has been granted.
* 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
@@ -28,154 +21,138 @@
*
*/
#include "busybox.h"
#include <features.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
#include <inttypes.h>
#else
typedef unsigned long long int uintmax_t;
#endif
extern int dd_main(int argc, char **argv)
static 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)
{
char *inFile = NULL;
char *outFile = NULL;
int inFd;
int outFd;
int inCc = 0;
int outCc;
int trunc=TRUE;
int sync=FALSE;
long blockSize = 512,ibs;
uintmax_t skipBlocks = 0;
uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t) - 1;
uintmax_t inTotal = 0;
uintmax_t outTotal = 0;
uintmax_t totalSize;
int i, ifd, ofd, oflag, sync = 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;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
unsigned char buf[BUFSIZ];
char *keyword = NULL;
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 = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
}
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
usage(dd_usage);
}
argc--;
argv++;
buf = xmalloc(bs);
/* Parse any options */
while (argc) {
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
inFile = ((strchr(*argv, '=')) + 1);
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) {
error_msg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
error_msg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
error_msg("Bad skip value %s\n", *argv);
goto usage;
}
if (infile != NULL) {
if ((ifd = open(infile, O_RDONLY)) < 0)
perror_msg_and_die("%s", infile);
} else {
ifd = STDIN_FILENO;
infile = "standard input";
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
error_msg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
keyword = (strchr(*argv, '=') + 1);
if (strcmp(keyword, "notrunc") == 0)
trunc=FALSE;
if (strcmp(keyword, "sync") == 0)
sync=TRUE;
} else {
goto usage;
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);
}
argc--;
argv++;
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (inFile == NULL)
inFd = fileno(stdin);
else
inFd = open(inFile, 0);
if (inFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* free(buf); */
perror_msg_and_die("%s", inFile);
if (skip) {
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", infile);
}
if (outFile == NULL)
outFd = fileno(stdout);
else
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
if (outFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* close(inFd);
free(buf); */
perror_msg_and_die("%s", outFile);
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", outfile);
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
totalSize=count*blockSize;
ibs=blockSize;
if (ibs > BUFSIZ)
ibs=BUFSIZ;
while (totalSize > outTotal) {
inCc = full_read(inFd, buf, ibs);
inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs)
buf[inCc++]='\0';
if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){
perror("Error during write");
}
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) {
memset(buf + n, '\0', bs - n);
n = bs;
}
outTotal += outCc;
}
if (trunc == TRUE) {
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
n = full_write(ofd, buf, n);
if (n < 0)
perror_msg_and_die("%s", outfile);
if (n == bs)
out_full++;
else
out_part++;
}
/* Note that we are not freeing memory or closing
* files here, to save a few bytes. */
#ifdef BB_FEATURE_CLEAN_UP
close(inFd);
close(outFd);
#endif
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
(inTotal % blockSize) != 0);
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
(outTotal % blockSize) != 0);
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
return EXIT_SUCCESS;
usage:
usage(dd_usage);
}
+58 -14
View File
@@ -2,7 +2,7 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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>.
*
@@ -24,10 +24,15 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <getopt.h>
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long disp_hr = KILOBYTE;
#endif
static int df(char *device, const char *mountPoint)
{
@@ -42,19 +47,32 @@ static int df(char *device, const char *mountPoint)
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
if(0 == blocks_used)
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 */
find_real_root_device_name( device);
}
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s",
device,
format((s.f_blocks * s.f_bsize), disp_hr));
printf(" %9s", format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr));
printf(" %9s %3ld%% %s\n",
format(s.f_bavail * s.f_bsize, disp_hr),
blocks_percent_used, mountPoint);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
blocks_percent_used, mountPoint);
#endif
}
@@ -64,24 +82,46 @@ static int df(char *device, const char *mountPoint)
extern int df_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
while ((opt = getopt(argc, argv, "?"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k"
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
case 'k': disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
case '?': goto print_df_usage; break;
}
}
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
#ifdef BB_FEATURE_HUMAN_READABLE
(KILOBYTE == disp_hr) ? "1k-blocks" : " Size",
#else
"1k-blocks",
#endif
"Used", "Available", "Use%", "Mounted on");
if (argc > 1) {
if(optind < argc) {
struct mntent *mountEntry;
if (**(argv + 1) == '-') {
usage(df_usage);
}
while (argc > 1) {
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[1]);
for(i = optind; i < argc; i++)
{
if ((mountEntry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[i]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
argc--;
argv++;
}
} else {
FILE *mountTable;
@@ -101,6 +141,10 @@ extern int df_main(int argc, char **argv)
}
return status;
print_df_usage:
usage(df_usage);
return(FALSE);
}
/*
+3 -1
View File
@@ -2,7 +2,7 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 2000 by Lineo, inc.
* 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
@@ -22,6 +22,8 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int dirname_main(int argc, char **argv)
{
+27 -5
View File
@@ -3,7 +3,7 @@
* Mini du implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -31,8 +31,14 @@
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long du_disp_hr = KILOBYTE;
#endif
typedef void (Display) (long, char *);
static int du_depth = 0;
@@ -42,12 +48,17 @@ static Display *print;
static void print_normal(long size, char *filename)
{
fprintf(stdout, "%ld\t%s\n", size, filename);
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%s\t%s\n", format((size * KILOBYTE), du_disp_hr), filename);
#else
printf("%ld\t%s\n", size, filename);
#endif
}
static void print_summary(long size, char *filename)
{
if (du_depth == 1) {
printf("summary\n");
print_normal(size, filename);
}
}
@@ -132,7 +143,11 @@ int du_main(int argc, char **argv)
print = print_normal;
/* parse argv[] */
while ((c = getopt(argc, argv, "sl")) != EOF) {
while ((c = getopt(argc, argv, "sl"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k")) != EOF) {
switch (c) {
case 's':
print = print_summary;
@@ -140,6 +155,13 @@ int du_main(int argc, char **argv)
case 'l':
count_hardlinks = 1;
break;
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': du_disp_hr = 0; break;
case 'm': du_disp_hr = MEGABYTE; break;
case 'k': du_disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
default:
usage(du_usage);
}
@@ -155,7 +177,7 @@ int du_main(int argc, char **argv)
for (i=optind; i < argc; i++) {
if ((sum = du(argv[i])) == 0)
status = EXIT_FAILURE;
if (is_directory(argv[i], FALSE, NULL)==FALSE) {
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
print_normal(sum, argv[i]);
}
reset_ino_dev_hashtable();
@@ -165,7 +187,7 @@ int du_main(int argc, char **argv)
return status;
}
/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
/* $Id: du.c,v 1.36 2001/01/27 09:33:38 andersen Exp $ */
/*
Local Variables:
c-file-style: "linux"
+2
View File
@@ -24,6 +24,8 @@
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
extern int
echo_main(int argc, char** argv)
+3 -1
View File
@@ -35,9 +35,11 @@
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <regex.h>
#include <sys/types.h>
#include <regex.h>
/* The kinds of value we can have. */
enum valtype {
+6 -4
View File
@@ -3,7 +3,7 @@
* Mini head implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -25,6 +25,8 @@
#include "busybox.h"
#include <errno.h>
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
int head(int len, FILE *fp)
{
@@ -76,16 +78,16 @@ int head_main(int argc, char **argv)
}
if (fp) {
if (need_headers) {
fprintf(stdout, "==> %s <==\n", argv[optind]);
printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
status = EXIT_FAILURE;
errno = 0;
}
if (optind < argc - 1)
fprintf(stdout, "\n");
putchar('\n');
if (fp != stdin)
fclose(fp);
}
+2
View File
@@ -22,6 +22,8 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern int hostid_main(int argc, char **argv)
{
+19 -8
View File
@@ -23,14 +23,14 @@
#include "busybox.h"
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#include <getopt.h>
#include <string.h>
#include <sys/types.h>
extern int id_main(int argc, char **argv)
{
int no_user = 0, no_group = 0, print_real = 0;
int name_not_number = 0;
char user[9], group[9];
long gid;
long pwnam, grnam;
@@ -38,7 +38,7 @@ extern int id_main(int argc, char **argv)
gid = 0;
while ((opt = getopt(argc, argv, "ugr")) > 0) {
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
switch (opt) {
case 'u':
no_group++;
@@ -49,6 +49,9 @@ extern int id_main(int argc, char **argv)
case 'r':
print_real++;
break;
case 'n':
name_not_number++;
break;
default:
usage(id_usage);
}
@@ -76,12 +79,20 @@ extern int id_main(int argc, char **argv)
if (gid == -1 || pwnam==-1 || grnam==-1) {
error_msg_and_die("%s: No such user\n", user);
}
if (no_group)
printf("%ld\n", pwnam);
else if (no_user)
printf("%ld\n", grnam);
else
if (no_group) {
if(name_not_number && user)
printf("%s\n",user);
else
printf("%ld\n", pwnam);
} else if (no_user) {
if(name_not_number && group)
printf("%s\n", group);
else
printf("%ld\n", grnam);
} else {
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
}
return(0);
}
+7 -4
View File
@@ -2,7 +2,7 @@
/*
* Mini ln implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -28,11 +28,14 @@
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#define LN_SYMLINK 1
#define LN_FORCE 2
#define LN_NODEREFERENCE 4
static const int LN_SYMLINK = 1;
static const int LN_FORCE = 2;
static const int LN_NODEREFERENCE = 4;
/*
* linkDestName is where the link points to,
+2
View File
@@ -22,6 +22,8 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern int logname_main(int argc, char **argv)
{
+113 -67
View File
@@ -41,9 +41,9 @@
* 1. requires lstat (BSD) - how do you do it without?
*/
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
#define COLUMN_GAP 2 /* includes the file type char, if present */
static const int TERMINAL_WIDTH = 80; /* use 79 if your terminal has linefold bug */
static const int COLUMN_WIDTH = 14; /* default if AUTOWIDTH not defined */
static const int COLUMN_GAP = 2; /* includes the file type char, if present */
/************************************************************************/
@@ -59,6 +59,11 @@
#include <time.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/ioctl.h>
#ifndef NAJOR
#define MAJOR(dev) (((dev)>>8)&0xff)
@@ -66,10 +71,12 @@
#endif
/* what is the overall style of the listing */
#define STYLE_AUTO 0
#define STYLE_LONG 1 /* one record per line, extended info */
#define STYLE_SINGLE 2 /* one record per line */
#define STYLE_COLUMNS 3 /* fill columns */
enum {
STYLE_AUTO = 0,
STYLE_LONG = 1, /* one record per line, extended info */
STYLE_SINGLE = 2, /* one record per line */
STYLE_COLUMNS = 3 /* fill columns */
};
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
/* what file information will be listed */
@@ -99,23 +106,23 @@
#ifdef BB_FEATURE_LS_SORTFILES
/* how will the files be sorted */
#define SORT_FORWARD 0 /* sort in reverse order */
#define SORT_REVERSE 1 /* sort in reverse order */
#define SORT_NAME 2 /* sort by file name */
#define SORT_SIZE 3 /* sort by file size */
#define SORT_ATIME 4 /* sort by last access time */
#define SORT_CTIME 5 /* sort by last change time */
#define SORT_MTIME 6 /* sort by last modification time */
#define SORT_VERSION 7 /* sort by version */
#define SORT_EXT 8 /* sort by file name extension */
#define SORT_DIR 9 /* sort by file or directory */
static const int SORT_FORWARD = 0; /* sort in reverse order */
static const int SORT_REVERSE = 1; /* sort in reverse order */
static const int SORT_NAME = 2; /* sort by file name */
static const int SORT_SIZE = 3; /* sort by file size */
static const int SORT_ATIME = 4; /* sort by last access time */
static const int SORT_CTIME = 5; /* sort by last change time */
static const int SORT_MTIME = 6; /* sort by last modification time */
static const int SORT_VERSION = 7; /* sort by version */
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
/* which of the three times will be used */
#define TIME_MOD 0
#define TIME_CHANGE 1
#define TIME_ACCESS 2
static const int TIME_MOD = 0;
static const int TIME_CHANGE = 1;
static const int TIME_ACCESS = 2;
#endif
#define LIST_SHORT (LIST_FILENAME)
@@ -125,9 +132,9 @@
LIST_SYMLINK)
#define LIST_ILONG (LIST_INO | LIST_LONG)
#define SPLIT_DIR 0
#define SPLIT_FILE 1
#define SPLIT_SUBDIR 2
static const int SPLIT_DIR = 0;
static const int SPLIT_FILE = 1;
static const int SPLIT_SUBDIR = 2;
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
@@ -150,15 +157,15 @@ struct dnode **list_dir(char *);
struct dnode **dnalloc(int);
int list_single(struct dnode *);
static unsigned int disp_opts= DISP_NORMAL;
static unsigned int style_fmt= STYLE_AUTO ;
static unsigned int list_fmt= LIST_SHORT ;
static unsigned int disp_opts;
static unsigned int style_fmt;
static unsigned int list_fmt;
#ifdef BB_FEATURE_LS_SORTFILES
static unsigned int sort_opts= SORT_FORWARD;
static unsigned int sort_order= SORT_FORWARD;
static unsigned int sort_opts;
static unsigned int sort_order;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
static unsigned int time_fmt= TIME_MOD;
static unsigned int time_fmt;
#endif
#ifdef BB_FEATURE_LS_FOLLOWLINKS
static unsigned int follow_links=FALSE;
@@ -166,22 +173,25 @@ static unsigned int follow_links=FALSE;
static unsigned short column = 0;
#ifdef BB_FEATURE_AUTOWIDTH
static unsigned short terminal_width = TERMINAL_WIDTH;
static unsigned short column_width = COLUMN_WIDTH;
static unsigned short tabstops = 8;
static unsigned short terminal_width;
static unsigned short column_width;
static unsigned short tabstops;
#else
#define terminal_width TERMINAL_WIDTH
#define column_width COLUMN_WIDTH
static unsigned short column_width = COLUMN_WIDTH;
#endif
static int status = EXIT_SUCCESS;
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long ls_disp_hr = KILOBYTE;
#endif
static int my_stat(struct dnode *cur)
{
#ifdef BB_FEATURE_LS_FOLLOWLINKS
if (follow_links == TRUE) {
if (stat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno));
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
@@ -190,7 +200,7 @@ static int my_stat(struct dnode *cur)
} else
#endif
if (lstat(cur->fullname, &cur->dstat)) {
error_msg("%s: %s\n", cur->fullname, strerror(errno));
perror_msg("%s", cur->fullname);
status = EXIT_FAILURE;
free(cur->fullname);
free(cur);
@@ -202,7 +212,7 @@ static int my_stat(struct dnode *cur)
static void newline(void)
{
if (column > 0) {
fprintf(stdout, "\n");
putchar('\n');
column = 0;
}
}
@@ -229,11 +239,11 @@ static void nexttabstop( void )
n= nexttab - column;
if (n < 1) n= 1;
while (n--) {
fprintf(stdout, " ");
putchar(' ');
column++;
}
}
nexttab= column + column_width + COLUMN_GAP ;
nexttab= column + column_width + COLUMN_GAP;
}
/*----------------------------------------------------------------------*/
@@ -426,8 +436,10 @@ void showfiles(struct dnode **dn, int nfiles)
;
if (column_width < len) column_width= len;
}
#endif
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
#else
ncols= TERMINAL_WIDTH;
#endif
switch (style_fmt) {
case STYLE_LONG: /* one record per line, extended info */
case STYLE_SINGLE: /* one record per line */
@@ -468,7 +480,7 @@ void showdirs(struct dnode **dn, int ndirs)
for (i=0; i<ndirs; i++) {
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
fprintf(stdout, "\n%s:\n", dn[i]->fullname);
printf("\n%s:\n", dn[i]->fullname);
}
subdnp= list_dir(dn[i]->fullname);
nfiles= countfiles(subdnp);
@@ -511,7 +523,7 @@ struct dnode **list_dir(char *path)
nfiles= 0;
dir = opendir(path);
if (dir == NULL) {
error_msg("%s: %s\n", path, strerror(errno));
perror_msg("%s", path);
status = EXIT_FAILURE;
return(NULL); /* could not open the dir */
}
@@ -579,53 +591,61 @@ int list_single(struct dnode *dn)
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
fprintf(stdout, "%7ld ", dn->dstat.st_ino);
printf("%7ld ", dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#if _FILE_OFFSET_BITS == 64
fprintf(stdout, "%4lld ", dn->dstat.st_blocks>>1);
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%5s ", format(dn->dstat.st_size, ls_disp_hr));
#else
fprintf(stdout, "%4ld ", dn->dstat.st_blocks>>1);
#if _FILE_OFFSET_BITS == 64
printf("%4lld ", dn->dstat.st_blocks>>1);
#else
printf("%4ld ", dn->dstat.st_blocks>>1);
#endif
#endif
column += 5;
break;
case LIST_MODEBITS:
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
printf("%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
fprintf(stdout, "%4d ", dn->dstat.st_nlink);
printf("%4d ", dn->dstat.st_nlink);
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
if (*scratch)
fprintf(stdout, "%-8.8s ", scratch);
printf("%-8.8s ", scratch);
else
fprintf(stdout, "%-8d ", dn->dstat.st_uid);
printf("%-8d ", dn->dstat.st_uid);
my_getgrgid(scratch, dn->dstat.st_gid);
if (*scratch)
fprintf(stdout, "%-8.8s", scratch);
printf("%-8.8s", scratch);
else
fprintf(stdout, "%-8d", dn->dstat.st_gid);
printf("%-8d", dn->dstat.st_gid);
column += 17;
break;
#endif
case LIST_ID_NUMERIC:
fprintf(stdout, "%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
column += 17;
break;
case LIST_SIZE:
case LIST_DEV:
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
fprintf(stdout, "%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#if _FILE_OFFSET_BITS == 64
fprintf(stdout, "%9lld ", dn->dstat.st_size);
#ifdef BB_FEATURE_HUMAN_READABLE
fprintf(stdout, "%9s ", format(dn->dstat.st_size, ls_disp_hr));
#else
fprintf(stdout, "%9ld ", dn->dstat.st_size);
#if _FILE_OFFSET_BITS == 64
printf("%9lld ", dn->dstat.st_size);
#else
printf("%9ld ", dn->dstat.st_size);
#endif
#endif
}
column += 10;
@@ -634,23 +654,23 @@ int list_single(struct dnode *dn)
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
fprintf(stdout, "%24.24s ", filetime);
printf("%24.24s ", filetime);
column += 25;
break;
}
age = time(NULL) - ttime;
fprintf(stdout, "%6.6s ", filetime+4);
printf("%6.6s ", filetime+4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
fprintf(stdout, "%5.5s ", filetime+11);
printf("%5.5s ", filetime+11);
} else {
fprintf(stdout, " %4.4s ", filetime+20);
printf(" %4.4s ", filetime+20);
}
column += 13;
break;
#endif
case LIST_FILENAME:
fprintf(stdout, "%s", dn->name);
printf("%s", dn->name);
column += strlen(dn->name);
break;
case LIST_SYMLINK:
@@ -658,7 +678,7 @@ int list_single(struct dnode *dn)
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
fprintf(stdout, " -> %s", scratch);
printf(" -> %s", scratch);
#ifdef BB_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
@@ -671,7 +691,7 @@ int list_single(struct dnode *dn)
#ifdef BB_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
fprintf(stdout, "%1c", append);
printf("%1c", append);
column++;
}
break;
@@ -692,16 +712,28 @@ extern int ls_main(int argc, char **argv)
int opt;
int oi, ac;
char **av;
#ifdef BB_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
sort_opts= SORT_NAME;
sort_order= SORT_FORWARD;
#endif
#ifdef BB_FEATURE_LS_TIMESTAMPS
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
ioctl(fileno(stdout), TIOCGWINSZ, &win);
if (win.ws_row > 4)
column_width = win.ws_row - 2;
if (win.ws_col > 0)
terminal_width = win.ws_col - 1;
#endif
tabstops = 8;
nfiles=0;
/* process options */
@@ -724,7 +756,10 @@ extern int ls_main(int argc, char **argv)
#ifdef BB_FEATURE_LS_FOLLOWLINKS
"L"
#endif
)) > 0) {
#ifdef BB_FEATURE_HUMAN_READABLE
"h"
#endif
"k")) > 0) {
switch (opt) {
case '1': style_fmt = STYLE_SINGLE; break;
case 'A': disp_opts |= DISP_HIDDEN; break;
@@ -733,7 +768,13 @@ extern int ls_main(int argc, char **argv)
case 'd': disp_opts |= DISP_NOLIST; break;
case 'g': /* ignore -- for ftp servers */ break;
case 'i': list_fmt |= LIST_INO; break;
case 'l': style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; break;
case 'l':
style_fmt = STYLE_LONG;
list_fmt |= LIST_LONG;
#ifdef BB_FEATURE_HUMAN_READABLE
ls_disp_hr = 1;
#endif
break;
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
case 's': list_fmt |= LIST_BLOCKS; break;
case 'x': disp_opts = DISP_ROWS; break;
@@ -776,6 +817,12 @@ extern int ls_main(int argc, char **argv)
#ifdef BB_FEATURE_AUTOWIDTH
case 'T': tabstops= atoi(optarg); break;
case 'w': terminal_width= atoi(optarg); break;
#endif
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': ls_disp_hr = 0; break;
case 'k': ls_disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
default:
goto print_usage_message;
@@ -871,7 +918,6 @@ extern int ls_main(int argc, char **argv)
showdirs(dnd, dndirs);
}
}
return(status);
print_usage_message:
+24 -37
View File
@@ -26,12 +26,11 @@
#include <ctype.h>
#include <getopt.h>
/* It turns out that libc5 doesn't have this in its headers
* even though it is actually in the lib. Force it to work */
#if ! defined __GLIBC__ && ! defined __UCLIBC__
#define getline __getline
extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
#endif
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
#undef FALSE
#define FALSE ((int) 1)
#define TRUE ((int) 0)
//----------------------------------------------------------------------------
//--------md5.c
@@ -92,7 +91,7 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _MD5_H
#define _MD5_H 1
static const int _MD5_H = 1;
#include <stdio.h>
@@ -252,7 +251,7 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
int md5_stream(FILE *stream, void *resblock)
{
/* Important: BLOCKSIZE must be a multiple of 64. */
#define BLOCKSIZE 4096
static const int BLOCKSIZE = 4096;
struct md5_ctx ctx;
char buffer[BLOCKSIZE + 72];
size_t sum;
@@ -530,7 +529,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
/* The minimum length of a valid digest line in a file produced
by `md5sum FILE' and read by `md5sum -c'. This length does
not include any newline character at the end of a line. */
#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
2 - blank and binary indicator
1 - minimum filename length */
@@ -651,13 +650,13 @@ static int md5_file(const char *filename,
} else {
fp = fopen(filename, OPENOPTS(binary));
if (fp == NULL) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
}
if (md5_stream(fp, md5_result)) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
if (fp != stdin)
fclose(fp);
@@ -665,7 +664,7 @@ static int md5_file(const char *filename,
}
if (fp != stdin && fclose(fp) == EOF) {
error_msg("%s: %s\n", filename, strerror(errno));
perror_msg("%s", filename);
return FALSE;
}
@@ -680,8 +679,7 @@ static int md5_check(const char *checkfile_name)
int n_open_or_read_failures = 0;
unsigned char md5buffer[16];
size_t line_number;
char *line;
size_t line_chars_allocated;
char line[BUFSIZ];
if (STREQ(checkfile_name, "-")) {
have_read_stdin = 1;
@@ -689,14 +687,12 @@ static int md5_check(const char *checkfile_name)
} else {
checkfile_stream = fopen(checkfile_name, "r");
if (checkfile_stream == NULL) {
error_msg("%s: %s\n", checkfile_name, strerror(errno));
perror_msg("%s", checkfile_name);
return FALSE;
}
}
line_number = 0;
line = 0;
line_chars_allocated = 0;
do {
char *filename;
@@ -706,9 +702,10 @@ static int md5_check(const char *checkfile_name)
++line_number;
line_length = getline(&line, &line_chars_allocated, checkfile_stream);
fgets(line, BUFSIZ-1, checkfile_stream);
line_length = strlen(line);
if (line_length <= 0)
if (line_length <= 0 || line==NULL)
break;
/* Ignore comment lines, which begin with a '#' character. */
@@ -766,16 +763,13 @@ static int md5_check(const char *checkfile_name)
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
if (line)
free(line);
if (ferror(checkfile_stream)) {
error_msg("%s: read error\n", checkfile_name); /* */
return FALSE;
}
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
perror_msg("md5sum: %s", checkfile_name);
return FALSE;
}
@@ -861,31 +855,26 @@ int md5sum_main(int argc,
}
if (file_type_specified && do_check) {
error_msg("the -b and -t options are meaningless when verifying checksums\n");
return EXIT_FAILURE;
error_msg_and_die("the -b and -t options are meaningless when verifying checksums\n");
}
if (n_strings > 0 && do_check) {
error_msg("the -g and -c options are mutually exclusive\n");
return EXIT_FAILURE;
error_msg_and_die("the -g and -c options are mutually exclusive\n");
}
if (status_only && !do_check) {
error_msg("the -s option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
error_msg_and_die("the -s option is meaningful only when verifying checksums\n");
}
if (warn && !do_check) {
error_msg("the -w option is meaningful only when verifying checksums\n");
return EXIT_FAILURE;
error_msg_and_die("the -w option is meaningful only when verifying checksums\n");
}
if (n_strings > 0) {
size_t i;
if (optind < argc) {
error_msg("no files may be specified when using -g\n");
return EXIT_FAILURE;
error_msg_and_die("no files may be specified when using -g\n");
}
for (i = 0; i < n_strings; ++i) {
size_t cnt;
@@ -951,13 +940,11 @@ int md5sum_main(int argc,
}
if (fclose (stdout) == EOF) {
error_msg("write error\n");
return EXIT_FAILURE;
error_msg_and_die("write error\n");
}
if (have_read_stdin && fclose (stdin) == EOF) {
error_msg("standard input\n");
return EXIT_FAILURE;
error_msg_and_die("standard input\n");
}
if (err == 0)
+3 -1
View File
@@ -2,7 +2,7 @@
/*
* Mini mkdir implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -28,6 +28,8 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
static int parentFlag = FALSE;
static mode_t mode = 0777;
+3 -4
View File
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
extern int mkfifo_main(int argc, char **argv)
{
@@ -53,9 +54,7 @@ extern int mkfifo_main(int argc, char **argv)
}
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
if (mkfifo(*argv, mode) < 0) {
perror("mkfifo");
return EXIT_FAILURE;
}
if (mkfifo(*argv, mode) < 0)
perror_msg_and_die("mkfifo");
return EXIT_SUCCESS;
}
+3 -1
View File
@@ -26,6 +26,8 @@
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
int mknod_main(int argc, char **argv)
{
@@ -84,7 +86,7 @@ int mknod_main(int argc, char **argv)
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
perror_msg_and_die("%s", argv[0]);
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -59,7 +59,7 @@
#ifndef S_IFMT
# define S_IFMT 0170000
static const int S_IFMT = 0170000;
#endif
#if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+4 -2
View File
@@ -25,14 +25,16 @@
#include <stdio.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
extern int pwd_main(int argc, char **argv)
{
char buf[BUFSIZ + 1];
if (getcwd(buf, sizeof(buf)) == NULL)
error_msg_and_die("%s\n", strerror(errno));
perror_msg_and_die("getcwd");
printf("%s\n", buf);
puts(buf);
return EXIT_SUCCESS;
}
+3 -1
View File
@@ -3,7 +3,7 @@
* Mini rm implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -28,6 +28,8 @@
#include <utime.h>
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
static int recursiveFlag = FALSE;
static int forceFlag = FALSE;
+3 -1
View File
@@ -3,7 +3,7 @@
* Mini rmdir implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -25,6 +25,8 @@
#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
extern int rmdir_main(int argc, char **argv)
{
+4 -4
View File
@@ -23,6 +23,8 @@
#include "busybox.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
extern int sleep_main(int argc, char **argv)
{
@@ -30,9 +32,7 @@ extern int sleep_main(int argc, char **argv)
usage(sleep_usage);
}
if (sleep(atoi(*(++argv))) != 0) {
perror("sleep");
return EXIT_FAILURE;
}
if (sleep(atoi(*(++argv))) != 0)
perror_msg_and_die("sleep");
return EXIT_SUCCESS;
}
+39 -239
View File
@@ -3,8 +3,7 @@
* Mini sort implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* 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
@@ -23,267 +22,68 @@
*/
#include "busybox.h"
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#ifdef BB_FEATURE_SORT_REVERSE
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
static int reverse = 0;
#else
#define APPLY_REVERSE(x) (x)
#endif
/* typedefs _______________________________________________________________ */
/* line node */
typedef struct Line {
char *data; /* line data */
struct Line *next; /* pointer to next line node */
} Line;
/* singly-linked list of lines */
typedef struct {
int len; /* number of Lines */
Line **sorted; /* array fed to qsort */
Line *head; /* head of List */
Line *current; /* current Line */
} List;
/* comparison function */
typedef int (Compare) (const void *, const void *);
/* methods ________________________________________________________________ */
static const int max = 1024;
/* mallocate Line */
static Line *line_alloc()
int compare_ascii(const void *x, const void *y)
{
Line *self;
self = xmalloc(1 * sizeof(Line));
return self;
return strcmp(*(char **)x, *(char **)y);
}
/* Construct Line from FILE* */
static Line *line_newFromFile(FILE * src)
int compare_numeric(const void *x, const void *y)
{
Line *self;
char *cstring = NULL;
if ((cstring = get_line_from_file(src))) {
self = line_alloc();
self->data = cstring;
self->next = NULL;
return self;
}
return NULL;
return atoi(*(char **)x) - atoi(*(char **)y);
}
/* Line destructor */
static Line *line_release(Line * self)
{
if (self->data) {
free(self->data);
free(self);
}
return self;
}
/* Comparison */
/* ascii order */
static int compare_ascii(const void *a, const void *b)
{
Line **val;
Line *x, *y;
val = (Line **) a;
x = *val;
val = (Line **) b;
y = *val;
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
return APPLY_REVERSE(strcmp(x->data, y->data));
}
/* numeric order */
static int compare_numeric(const void *a, const void *b)
{
Line **val;
Line *x, *y;
int xint, yint;
val = (Line **) a;
x = *val;
val = (Line **) b;
y = *val;
xint = strtoul(x->data, NULL, 10);
yint = strtoul(y->data, NULL, 10);
return APPLY_REVERSE(xint - yint);
}
/* List */
/* */
static List *list_init(List * self)
{
self->len = 0;
self->sorted = NULL;
self->head = NULL;
self->current = NULL;
return self;
}
/* for simplicity, the List gains ownership of the line */
static List *list_insert(List * self, Line * line)
{
if (line == NULL) {
return NULL;
}
/* first insertion */
if (self->head == NULL) {
self->head = line;
self->current = line;
/* all subsequent insertions */
} else {
self->current->next = line;
self->current = line;
}
self->len++;
return self;
}
/* order the list according to compare() */
static List *list_sort(List * self, Compare * compare)
{
int i;
Line *line;
/* mallocate array of Line*s */
self->sorted = (Line **) xmalloc(self->len * sizeof(Line *));
/* fill array w/ List's contents */
i = 0;
line = self->head;
while (line) {
self->sorted[i++] = line;
line = line->next;
}
/* apply qsort */
qsort(self->sorted, self->len, sizeof(Line *), compare);
return self;
}
/* precondition: list must be sorted */
static List *list_writeToFile(List * self, FILE * dst)
{
int i;
Line **line = self->sorted;
if (self->sorted == NULL) {
return NULL;
}
for (i = 0; i < self->len; i++) {
fprintf(dst, "%s", line[i]->data);
}
return self;
}
/* deallocate */
static void list_release(List * self)
{
Line *i;
Line *die;
i = self->head;
while (i) {
die = i;
i = die->next;
line_release(die);
}
}
int sort_main(int argc, char **argv)
{
int i;
char opt;
List list;
Line *l;
Compare *compare;
FILE *fp;
char *line, **lines = NULL;
int i, opt, nlines = 0;
int (*compare)(const void *, const void *) = compare_ascii;
#ifdef BB_FEATURE_SORT_REVERSE
int reverse = FALSE;
#endif
/* init */
compare = compare_ascii;
list_init(&list);
/* parse argv[] */
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
opt = argv[i][1];
switch (opt) {
case 'h':
usage(sort_usage);
break;
while ((opt = getopt(argc, argv, "nr")) != -1) {
switch (opt) {
case 'n':
/* numeric comparison */
compare = compare_numeric;
break;
#ifdef BB_FEATURE_SORT_REVERSE
case 'r':
/* reverse */
reverse = 1;
reverse = TRUE;
break;
#endif
default:
error_msg("invalid option -- %c\n", opt);
usage(sort_usage);
}
} else {
break;
}
}
if (i >= argc) {
/* read the input */
for (i = optind; i == optind || i < argc; i++) {
if (argv[i] == NULL)
fp = stdin;
else
fp = xfopen(argv[i], "r");
/* work w/ stdin */
while ((l = line_newFromFile(stdin))) {
list_insert(&list, l);
while ((line = get_line_from_file(fp)) != NULL) {
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
lines[nlines++] = line;
}
} else {
/* work w/ what's left in argv[] */
FILE *src;
for (; i < argc; i++) {
src = fopen(argv[i], "r");
if (src == NULL) {
break;
}
while ((l = line_newFromFile(src))) {
list_insert(&list, l);
}
fclose(src);
}
}
list_sort(&list, compare);
list_writeToFile(&list, stdout);
list_release(&list);
return(0);
/* sort it */
qsort(lines, nlines, sizeof(char *), compare);
/* print it */
#ifdef BB_FEATURE_SORT_REVERSE
if (reverse)
for (i = nlines - 1; 0 <= i; i--)
fputs(lines[i], stdout);
else
#endif
for (i = 0; i < nlines; i++)
fputs(lines[i], stdout);
return EXIT_SUCCESS;
}
/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
+1
View File
@@ -23,6 +23,7 @@
#include "busybox.h"
#include <stdio.h>
#include <unistd.h>
extern int sync_main(int argc, char **argv)
{
+222 -288
View File
@@ -1,319 +1,253 @@
/* vi: set sw=4 ts=4: */
/* tail -- output the last part of file(s)
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
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, 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 version by Paul Rubin <phr@ocf.berkeley.edu>.
Extensions by David MacKenzie <djm@gnu.ai.mit.edu>.
tail -f for multiple files by Ian Lance Taylor <ian@airs.com>.
Rewrote the option parser, removed locales support,
and generally busyboxed, Erik Andersen <andersen@lineo.com>
Removed superfluous options and associated code ("-c", "-n", "-q").
Removed "tail -f" support for multiple files.
Both changes by Friedrich Vedder <fwv@myrtle.lahn.de>.
Compleate Rewrite to correctly support "-NUM", "+NUM", and "-s" by
E.Allen Soard (esp@espsw.net).
/*
* Mini tail implementation for busybox
*
*
* Copyright (C) 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
* 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
#define STDIN "standard input"
#define LINES 0
#define BYTES 1
#include <fcntl.h>
#include <getopt.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
static int n_files = 0;
static char **files = NULL;
static char * buffer;
static ssize_t bytes_read=0;
static ssize_t bs;
static ssize_t filelocation=0;
static char pip;
static struct suffix_mult tail_suffixes[] = {
{ "b", 512 },
{ "k", 1024 },
{ "m", 1048576 },
{ NULL, 0 }
};
#ifdef BB_FEATURE_SIMPLE_TAIL
static const char unit_type=LINES;
#else
static char unit_type=LINES;
static char verbose = 0;
#endif
static off_t units=0;
static int tail_stream(int fd)
{
ssize_t startpoint;
ssize_t endpoint=0;
ssize_t count=0;
ssize_t filesize=0;
int direction=1;
filelocation=0;
startpoint=bs=BUFSIZ;
filesize=lseek(fd, -1, SEEK_END)+1;
pip=(filesize<=0);
if(units>=0)
lseek(fd,0,SEEK_SET);
else {
direction=-1;
count=1;
}
while(units != 0) {
if (pip) {
char * line;
ssize_t f_size=0;
bs=BUFSIZ;
line=xmalloc(bs);
while(1) {
bytes_read=read(fd,line,bs);
if(bytes_read<=0)
break;
buffer=xrealloc(buffer,f_size+bytes_read);
memcpy(&buffer[f_size],line,bytes_read);
filelocation=f_size+=bytes_read;
}
bs=f_size;
if(direction<0)
bs--;
if (line)
free(line);
} else {
filelocation = lseek(fd, 0, SEEK_CUR);
if(direction<0) {
if(filelocation<bs)
bs=filelocation;
filelocation = lseek(fd, -bs, SEEK_CUR);
}
bytes_read = read(fd, buffer, bs);
if (bytes_read <= 0)
break;
bs=bytes_read;
}
startpoint=bs;
if(direction>0) {
endpoint=startpoint;
startpoint=0;
}
for(;startpoint!=endpoint;startpoint+=direction) {
#ifndef BB_FEATURE_SIMPLE_TAIL
if(unit_type==BYTES)
count++;
else
static struct suffix_mult null_suffixes[] = {
{ NULL, 0 }
};
#endif
if(buffer[startpoint-1]=='\n')
count++;
if (!pip)
filelocation=lseek(fd,0,SEEK_CUR);
if(count==units*direction)
break;
}
if((count==units*direction) | pip)
break;
if(direction<0){
filelocation = lseek(fd, -bytes_read, SEEK_CUR);
if(filelocation==0)
break;
}
}
if(pip && (direction<0))
bs++;
bytes_read=bs-startpoint;
memcpy(&buffer[0],&buffer[startpoint],bytes_read);
return 0;
static const int BYTES = 0;
static const int LINES = 1;
static char *tailbuf;
static int taillen;
static int newline;
void tailbuf_append(char *buf, int len)
{
tailbuf = xrealloc(tailbuf, taillen + len);
memcpy(tailbuf + taillen, buf, len);
taillen += len;
}
void add_file(char *name)
void tailbuf_trunc()
{
++n_files;
files = xrealloc(files, n_files);
files[n_files - 1] = (char *) xmalloc(strlen(name) + 1);
strcpy(files[n_files - 1], name);
char *s;
s = memchr(tailbuf, '\n', taillen);
memmove(tailbuf, s + 1, taillen - ((s + 1) - tailbuf));
taillen -= (s + 1) - tailbuf;
newline = 0;
}
int tail_main(int argc, char **argv)
{
int show_headers = 1;
int test;
int opt;
char follow=0;
int sleep_int=1;
int *fd;
opterr = 0;
while ((opt=getopt(argc,argv,"c:fhn:s:q:v")) >0) {
int from_top = 0, units = LINES, count = 10, sleep_period = 1;
int show_headers = 0, hide_headers = 0, follow = 0;
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
char *s, *start, *end, buf[BUFSIZ];
int i, opt;
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
switch (opt) {
case 'f':
follow = 1;
break;
#ifndef BB_FEATURE_SIMPLE_TAIL
case 'c':
unit_type = BYTES;
test = atoi(optarg);
if(test==0)
usage(tail_usage);
if(optarg[strlen(optarg)-1]>'9') {
switch (optarg[strlen(optarg)-1]) {
case 'b':
test *= 512;
break;
case 'k':
test *= 1024;
break;
case 'm':
test *= (1024 * 1024);
break;
default:
fprintf(stderr,"Size must be b,k, or m.");
usage(tail_usage);
}
}
if(optarg[0]=='+')
units=test+1;
else
units=-(test+1);
break;
case 'q':
show_headers = 0;
break;
case 's':
sleep_int = atoi(optarg);
if(sleep_int<1)
sleep_int=1;
break;
case 'v':
verbose = 1;
break;
case 'c':
units = BYTES;
/* FALLS THROUGH */
#endif
case 'f':
follow = 1;
break;
case 'h':
usage(tail_usage);
break;
case 'n':
test = atoi(optarg);
if (test) {
case 'n':
count = parse_number(optarg, tail_suffixes);
if (count < 0)
count = -count;
if (optarg[0] == '+')
units = test;
else
units = -(test+1);
} else
usage(tail_usage);
break;
default:
error_msg("\nUnknown arg: %c.\n\n",optopt);
usage(tail_usage);
}
}
while (optind <= argc) {
if(optind==argc) {
if (n_files==0)
add_file(STDIN);
else
from_top = 1;
break;
}else {
if (!strcmp(argv[optind], "-")) {
add_file(STDIN);
} else {
add_file(argv[optind]);
}
optind++;
}
}
if(units==0)
units=-11;
if(units>0)
units--;
fd=xmalloc(sizeof(int)*n_files);
if (n_files == 1)
#ifndef BB_FEATURE_SIMPLE_TAIL
if (!verbose)
#endif
show_headers = 0;
buffer=xmalloc(BUFSIZ);
for (test = 0; test < n_files; test++) {
if (show_headers)
printf("==> %s <==\n", files[test]);
if (!strcmp(files[test], STDIN))
fd[test] = 0;
else
fd[test] = open(files[test], O_RDONLY);
if (fd[test] == -1)
error_msg_and_die("Unable to open file %s.\n", files[test]);
tail_stream(fd[test]);
bs=BUFSIZ;
while (1) {
if((filelocation>0 || pip)){
write(1,buffer,bytes_read);
}
bytes_read = read(fd[test], buffer, bs);
filelocation+=bytes_read;
if (bytes_read <= 0) {
case 'q':
hide_headers = 1;
break;
}
usleep(sleep_int * 1000);
case 's':
sleep_period = parse_number(optarg, null_suffixes);
break;
case 'v':
show_headers = 1;
break;
#endif
default:
usage(tail_usage);
}
if(n_files>1)
printf("\n");
}
while(1){
for (test = 0; test < n_files; test++) {
if(!follow){
close(fd[test]);
continue;
/* open all the files */
fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
if (argc == optind) {
fds[nfiles++] = STDIN_FILENO;
argv[optind] = "standard input";
} else {
for (i = optind; i < argc; i++) {
if (strcmp(argv[i], "-") == 0) {
fds[nfiles++] = STDIN_FILENO;
argv[i] = "standard input";
} else if ((fds[nfiles++] = open(argv[i], O_RDONLY)) < 0) {
perror_msg("%s", argv[i]);
status = EXIT_FAILURE;
}
}
}
#ifndef BB_FEATURE_SIMPLE_TAIL
/* tail the files */
if (!from_top && units == BYTES)
tailbuf = xmalloc(count);
#endif
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
continue;
seen = 0;
if (show_headers || (!hide_headers && nfiles > 1))
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (from_top) {
#ifndef BB_FEATURE_SIMPLE_TAIL
if (units == BYTES) {
if (count - 1 <= seen)
nwrite = nread;
else if (count - 1 <= seen + nread)
nwrite = nread + seen - (count - 1);
else
nwrite = 0;
seen += nread;
} else {
#else
{
#endif
if (count - 1 <= seen)
nwrite = nread;
else {
nwrite = 0;
for (s = memchr(buf, '\n', nread); s != NULL;
s = memchr(s+1, '\n', nread - (s + 1 - buf))) {
if (count - 1 <= ++seen) {
nwrite = nread - (s + 1 - buf);
break;
}
}
}
}
if (full_write(STDOUT_FILENO, buf + nread - nwrite,
nwrite) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
break;
}
} else {
sleep(sleep_int);
bytes_read = read(fd[test], buffer, bs);
if(bytes_read>0) {
if (show_headers)
printf("==> %s <==\n", files[test]);
write(1,buffer,bytes_read);
if(n_files>1)
printf("\n");
#ifndef BB_FEATURE_SIMPLE_TAIL
if (units == BYTES) {
if (nread < count) {
memmove(tailbuf, tailbuf + nread, count - nread);
memcpy(tailbuf + count - nread, buf, nread);
} else {
memcpy(tailbuf, buf + nread - count, count);
}
seen += nread;
} else {
#else
{
#endif
for (start = buf, end = memchr(buf, '\n', nread);
end != NULL; start = end+1,
end = memchr(start, '\n', nread - (start - buf))) {
if (newline && count <= seen)
tailbuf_trunc();
tailbuf_append(start, end - start + 1);
seen++;
newline = 1;
}
if (newline && count <= seen && nread - (start - buf) > 0)
tailbuf_trunc();
tailbuf_append(start, nread - (start - buf));
}
}
}
if(!follow)
break;
}
if (fd)
free(fd);
if (buffer)
free(buffer);
if(files)
free(files);
return 0;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
if (nread < 0) {
perror_msg("read");
status = EXIT_FAILURE;
}
#ifndef BB_FEATURE_SIMPLE_TAIL
if (!from_top && units == BYTES) {
if (count < seen)
seen = count;
if (full_write(STDOUT_FILENO, tailbuf + count - seen, seen) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
}
}
#endif
if (!from_top && units == LINES) {
if (full_write(STDOUT_FILENO, tailbuf, taillen) < 0) {
perror_msg("write");
status = EXIT_FAILURE;
}
}
taillen = 0;
}
while (follow) {
sleep(sleep_period);
for (i = 0; i < nfiles; i++) {
if (fds[i] == -1)
continue;
if ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
if (show_headers || (!hide_headers && nfiles > 1))
printf("\n==> %s <==\n", argv[optind + i]);
do {
full_write(STDOUT_FILENO, buf, nread);
} while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0);
}
if (nread < 0) {
perror_msg("read");
status = EXIT_FAILURE;
}
}
}
return status;
}
+2 -2
View File
@@ -2,7 +2,7 @@
/*
* Mini tee implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
while (optind < argc) {
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
nfiles--;
error_msg("%s: %s\n", argv[optind-1], strerror(errno));
perror_msg("%s", argv[optind-1]);
status = 1;
}
}
+2 -2
View File
@@ -156,8 +156,8 @@ struct t_op {
{0, 0, 0}
};
char **t_wp;
struct t_op const *t_wp_op;
static char **t_wp;
static struct t_op const *t_wp_op;
static gid_t *group_array = NULL;
static int ngroups;
+5 -3
View File
@@ -3,7 +3,7 @@
* Mini touch implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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
@@ -28,6 +28,8 @@
#include <fcntl.h>
#include <utime.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
extern int touch_main(int argc, char **argv)
{
@@ -58,12 +60,12 @@ extern int touch_main(int argc, char **argv)
if (create == FALSE && errno == ENOENT)
return EXIT_SUCCESS;
else {
error_msg_and_die("%s", strerror(errno));
perror_msg_and_die("%s", *argv);
}
}
close(fd);
if (utime(*argv, NULL)) {
error_msg_and_die("%s", strerror(errno));
perror_msg_and_die("%s", *argv);
}
argc--;
argv++;
+29 -16
View File
@@ -34,14 +34,15 @@
#define bb_need_write_error
#include "messages.c"
#define ASCII 0377
static const int ASCII = 0377;
/* some glabals shared across this file */
static char com_fl, del_fl, sq_fl;
static unsigned char output[BUFSIZ], input[BUFSIZ];
static unsigned char vector[ASCII + 1];
static char invec[ASCII + 1], outvec[ASCII + 1];
static short in_index, out_index;
/* these last are pointers to static buffers declared in tr_main */
static unsigned char *poutput, *pinput;
static unsigned char *pvector;
static char *pinvec, *poutvec;
static void convert()
@@ -52,22 +53,22 @@ static void convert()
for (;;) {
if (in_index == read_chars) {
if ((read_chars = read(0, (char *) input, BUFSIZ)) <= 0) {
if (write(1, (char *) output, out_index) != out_index)
if ((read_chars = read(0, (char *) pinput, BUFSIZ)) <= 0) {
if (write(1, (char *) poutput, out_index) != out_index)
write(2, write_error, strlen(write_error));
exit(0);
}
in_index = 0;
}
c = input[in_index++];
coded = vector[c];
if (del_fl && invec[c])
c = pinput[in_index++];
coded = pvector[c];
if (del_fl && pinvec[c])
continue;
if (sq_fl && last == coded && (invec[c] || outvec[coded]))
if (sq_fl && last == coded && (pinvec[c] || poutvec[coded]))
continue;
output[out_index++] = last = coded;
poutput[out_index++] = last = coded;
if (out_index == BUFSIZ) {
if (write(1, (char *) output, out_index) != out_index) {
if (write(1, (char *) poutput, out_index) != out_index) {
write(2, write_error, strlen(write_error));
exit(1);
}
@@ -86,9 +87,9 @@ static void map(register unsigned char *string1, unsigned int string1_len,
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
vector[string1[i]] = last;
pvector[string1[i]] = last;
else
vector[string1[i]] = last = string2[j++];
pvector[string1[i]] = last = string2[j++];
}
}
@@ -143,6 +144,18 @@ extern int tr_main(int argc, char **argv)
int output_length=0, input_length;
int index = 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);
/* ... but make them available globally */
poutput = output;
pinput = input;
pvector = vector;
pinvec = invec;
poutvec = outvec;
if (argc > 1 && argv[index][0] == '-') {
for (ptr = (unsigned char *) &argv[index][1]; *ptr; ptr++) {
@@ -178,9 +191,9 @@ extern int tr_main(int argc, char **argv)
map(input, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[input[i]] = TRUE;
invec[(int)input[i]] = TRUE;
for (i = 0; i < output_length; i++)
outvec[output[i]] = TRUE;
outvec[(int)output[i]] = TRUE;
}
convert();
return (0);
+2
View File
@@ -22,6 +22,8 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
extern int tty_main(int argc, char **argv)
+9 -8
View File
@@ -33,6 +33,7 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/utsname.h>
@@ -44,22 +45,22 @@ static void print_element(unsigned int mask, char *element);
/* Values that are bitwise or'd into `toprint'. */
/* Operating system name. */
#define PRINT_SYSNAME 1
static const int PRINT_SYSNAME = 1;
/* Node name on a communications network. */
#define PRINT_NODENAME 2
static const int PRINT_NODENAME = 2;
/* Operating system release. */
#define PRINT_RELEASE 4
static const int PRINT_RELEASE = 4;
/* Operating system version. */
#define PRINT_VERSION 8
static const int PRINT_VERSION = 8;
/* Machine hardware name. */
#define PRINT_MACHINE 16
static const int PRINT_MACHINE = 16;
/* Host processor type. */
#define PRINT_PROCESSOR 32
static const int PRINT_PROCESSOR = 32;
/* Mask indicating which elements of the name to print. */
static unsigned char toprint;
@@ -114,11 +115,11 @@ int uname_main(int argc, char **argv)
toprint = PRINT_SYSNAME;
if (uname(&name) == -1)
perror("cannot get system name");
perror_msg("cannot get system name");
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
perror("cannot get processor type");
perror_msg("cannot get processor type");
}
#else
+3 -1
View File
@@ -3,7 +3,7 @@
* Mini uniq implementation for busybox
*
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
* Rewritten by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
@@ -26,7 +26,9 @@
#include "busybox.h"
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <stdlib.h>
static int print_count;
static int print_uniq = 1;
+6 -3
View File
@@ -27,7 +27,10 @@
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
#include <string.h>
#include <stdlib.h>
#include "pwd_grp/pwd.h"
#include "pwd_grp/grp.h"
/*struct passwd *getpwnam();*/
@@ -257,7 +260,7 @@ static int decode (const char *inname,
&& (freopen (outname, "w", stdout) == NULL
|| chmod (outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO))
)) {
error_msg("%s: %s %s\n", outname, inname, strerror(errno)); /* */
perror_msg("%s", outname); /* */
return FALSE;
}
@@ -302,7 +305,7 @@ int uudecode_main (int argc,
if (decode (argv[optind], outname) != 0)
exit_status = FALSE;
} else {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
exit_status = EXIT_FAILURE;
}
optind++;
+3 -6
View File
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <errno.h>
#include <getopt.h>
#include <pwd.h>
#include <stdlib.h>
#define RW (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
@@ -160,15 +160,12 @@ int uuencode_main (int argc,
trans_ptr = uu_std; /* Standard encoding is old uu format */
/* Parse any options */
while ((opt = getopt (argc, argv, "m")) != EOF) {
while ((opt = getopt (argc, argv, "m")) > 0) {
switch (opt) {
case 'm':
trans_ptr = uu_base64;
break;
case 0:
break;
default:
usage(uuencode_usage);
}
@@ -178,7 +175,7 @@ int uuencode_main (int argc,
case 2:
/* Optional first argument is input file. */
if (!freopen (argv[optind], "r", stdin) || fstat (fileno (stdin), &sb)) {
error_msg("%s: %s\n", argv[optind], strerror(errno));
perror_msg("%s", argv[optind]);
return EXIT_FAILURE;
}
mode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+1
View File
@@ -23,6 +23,7 @@
#include "busybox.h"
#include <stdio.h>
#include <getopt.h>
#include <stdlib.h>
static int total_lines, total_words, total_chars, max_length;
static int print_lines, print_words, print_chars, print_length;
+2 -1
View File
@@ -22,7 +22,8 @@
#include "busybox.h"
#include <stdio.h>
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
extern int whoami_main(int argc, char **argv)
{
+1
View File
@@ -22,6 +22,7 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
extern int yes_main(int argc, char **argv)
{
+17 -15
View File
@@ -3,7 +3,7 @@
* Mini `cp' and `mv' implementation for BusyBox.
*
*
* Copyright (C) 1999 by Lineo, inc.
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Copyright (C) 2000 by BitterSweet Enterprises, LLC. (GPL)
@@ -42,9 +42,10 @@
#include <unistd.h>
#include <errno.h>
#include <getopt.h>
#include <stdlib.h>
#define is_cp 0
#define is_mv 1
static const int is_cp = 0;
static const int is_mv = 1;
static int dz_i; /* index into cp_mv_usage */
static const char *cp_mv_usage[] = /* .rodata */
@@ -62,7 +63,7 @@ static const char *baseSrcName;
static int srcDirFlag;
static struct stat srcStatBuf;
static char baseDestName[BUFSIZ + 1];
static char *pBaseDestName;
static size_t baseDestLen;
static int destDirFlag;
static struct stat destStatBuf;
@@ -104,7 +105,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
const char *srcBasename;
char *name;
strcpy(destName, baseDestName);
strcpy(destName, pBaseDestName);
destLen = strlen(destName);
if (srcDirFlag == TRUE) {
@@ -130,8 +131,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (mv_Action_first_time && (dz_i == is_mv)) {
mv_Action_first_time = errno = 0;
if (rename(fileName, destName) < 0 && errno != EXDEV) {
error_msg("rename(%s, %s): %s\n", fileName, destName,
strerror(errno));
perror_msg("rename(%s, %s)", fileName, destName);
goto do_copyFile; /* Try anyway... */
}
else if (errno == EXDEV)
@@ -143,7 +143,7 @@ cp_mv_Action(const char *fileName, struct stat *statbuf, void* junk)
if (preserveFlag == TRUE && statbuf->st_nlink > 1) {
if (is_in_ino_dev_hashtable(statbuf, &name)) {
if (link(name, destName) < 0) {
error_msg("link(%s, %s): %s\n", name, destName, strerror(errno));
perror_msg("link(%s, %s)", name, destName);
return FALSE;
}
return TRUE;
@@ -162,11 +162,11 @@ rm_Action(const char *fileName, struct stat *statbuf, void* junk)
if (S_ISDIR(statbuf->st_mode)) {
if (rmdir(fileName) < 0) {
error_msg("rmdir(%s): %s\n", fileName, strerror(errno));
perror_msg("rmdir(%s)", fileName);
status = FALSE;
}
} else if (unlink(fileName) < 0) {
error_msg("unlink(%s): %s\n", fileName, strerror(errno));
perror_msg("unlink(%s)", fileName);
status = FALSE;
}
return status;
@@ -176,6 +176,8 @@ extern int cp_mv_main(int argc, char **argv)
{
volatile int i;
int c;
RESERVE_BB_BUFFER(baseDestName,BUFSIZ + 1);
pBaseDestName = baseDestName; /* available globally */
if (*applet_name == 'c' && *(applet_name + 1) == 'p')
dz_i = is_cp;
@@ -260,20 +262,20 @@ extern int cp_mv_main(int argc, char **argv)
char *pushd, *d, *p;
if ((pushd = getcwd(NULL, BUFSIZ + 1)) == NULL) {
error_msg("getcwd(): %s\n", strerror(errno));
perror_msg("getcwd()");
continue;
}
if (chdir(baseDestName) < 0) {
error_msg("chdir(%s): %s\n", baseSrcName, strerror(errno));
perror_msg("chdir(%s)", baseSrcName);
continue;
}
if ((d = getcwd(NULL, BUFSIZ + 1)) == NULL) {
error_msg("getcwd(): %s\n", strerror(errno));
perror_msg("getcwd()");
continue;
}
while (!state && *d != '\0') {
if (stat(d, &sb) < 0) { /* stat not lstat - always dereference targets */
error_msg("stat(%s): %s\n", d, strerror(errno));
perror_msg("stat(%s)", d);
state = -1;
continue;
}
@@ -290,7 +292,7 @@ extern int cp_mv_main(int argc, char **argv)
}
}
if (chdir(pushd) < 0) {
error_msg("chdir(%s): %s\n", pushd, strerror(errno));
perror_msg("chdir(%s)", pushd);
free(pushd);
free(d);
continue;
+7 -6
View File
@@ -1,8 +1,8 @@
/*
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
* 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
@@ -188,7 +188,7 @@ extern int cut_main(int argc, char **argv)
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");
error_msg_and_die("only one type of list may be specified\n");
}
part = (char)opt;
decompose_list(optarg);
@@ -213,8 +213,9 @@ extern int cut_main(int argc, char **argv)
}
if (supress_non_delimited_lines && part != 'f') {
error_msg_and_die("suppressing non-delimited lines makes sense
only when operating on fields\n");
error_msg_and_die("suppressing non-delimited lines makes sense"
" only when operating on fields\n");
}
if (delim != '\t' && part != 'f') {
@@ -233,7 +234,7 @@ extern int cut_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (file == NULL) {
error_msg("%s: %s\n", argv[i], strerror(errno));
perror_msg("%s", argv[i]);
} else {
cut_file(file);
fclose(file);
+1
View File
@@ -31,6 +31,7 @@
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
+114 -137
View File
@@ -2,15 +2,8 @@
/*
* Mini dd implementation for busybox
*
* Copyright (C) 1999, 2000 by Lineo, inc.
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* Based in part on code taken from sash.
* Copyright (c) 1999 by David I. Bell
* Permission is granted to use, distribute, or modify this source,
* provided that this copyright notice remains intact.
*
* Permission to distribute this code under the GPL has been granted.
* 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
@@ -28,154 +21,138 @@
*
*/
#include "busybox.h"
#include <features.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
#include <inttypes.h>
#else
typedef unsigned long long int uintmax_t;
#endif
extern int dd_main(int argc, char **argv)
static 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)
{
char *inFile = NULL;
char *outFile = NULL;
int inFd;
int outFd;
int inCc = 0;
int outCc;
int trunc=TRUE;
int sync=FALSE;
long blockSize = 512,ibs;
uintmax_t skipBlocks = 0;
uintmax_t seekBlocks = 0;
uintmax_t count = (uintmax_t) - 1;
uintmax_t inTotal = 0;
uintmax_t outTotal = 0;
uintmax_t totalSize;
int i, ifd, ofd, oflag, sync = 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;
FILE *statusfp;
char *infile = NULL, *outfile = NULL, *buf;
unsigned char buf[BUFSIZ];
char *keyword = NULL;
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 = TRUE;
buf += 4;
} else {
error_msg_and_die("invalid conversion `%s'\n", argv[i]+5);
}
if (buf[0] == '\0')
break;
if (buf[0] == ',')
buf++;
}
} else
usage(dd_usage);
}
argc--;
argv++;
buf = xmalloc(bs);
/* Parse any options */
while (argc) {
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
inFile = ((strchr(*argv, '=')) + 1);
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
outFile = ((strchr(*argv, '=')) + 1);
else if (strncmp("count", *argv, 5) == 0) {
count = atoi_w_units((strchr(*argv, '=')) + 1);
if (count < 0) {
error_msg("Bad count value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "bs", 2) == 0) {
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
if (blockSize <= 0) {
error_msg("Bad block size value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "skip", 4) == 0) {
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (skipBlocks <= 0) {
error_msg("Bad skip value %s\n", *argv);
goto usage;
}
if (infile != NULL) {
if ((ifd = open(infile, O_RDONLY)) < 0)
perror_msg_and_die("%s", infile);
} else {
ifd = STDIN_FILENO;
infile = "standard input";
}
} else if (strncmp(*argv, "seek", 4) == 0) {
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
if (seekBlocks <= 0) {
error_msg("Bad seek value %s\n", *argv);
goto usage;
}
} else if (strncmp(*argv, "conv", 4) == 0) {
keyword = (strchr(*argv, '=') + 1);
if (strcmp(keyword, "notrunc") == 0)
trunc=FALSE;
if (strcmp(keyword, "sync") == 0)
sync=TRUE;
} else {
goto usage;
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);
}
argc--;
argv++;
statusfp = stdout;
} else {
ofd = STDOUT_FILENO;
outfile = "standard output";
statusfp = stderr;
}
if (inFile == NULL)
inFd = fileno(stdin);
else
inFd = open(inFile, 0);
if (inFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* free(buf); */
perror_msg_and_die("%s", inFile);
if (skip) {
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", infile);
}
if (outFile == NULL)
outFd = fileno(stdout);
else
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
if (outFd < 0) {
/* Note that we are not freeing buf or closing
* files here to save a few bytes. This exits
* here anyways... */
/* close(inFd);
free(buf); */
perror_msg_and_die("%s", outFile);
if (seek) {
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
perror_msg_and_die("%s", outfile);
}
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
totalSize=count*blockSize;
ibs=blockSize;
if (ibs > BUFSIZ)
ibs=BUFSIZ;
while (totalSize > outTotal) {
inCc = full_read(inFd, buf, ibs);
inTotal += inCc;
if ( (sync==TRUE) && (inCc>0) )
while (inCc<ibs)
buf[inCc++]='\0';
if ((outCc = full_write(outFd, buf, inCc)) < 1){
if (outCc < 0 ){
perror("Error during write");
}
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) {
memset(buf + n, '\0', bs - n);
n = bs;
}
outTotal += outCc;
}
if (trunc == TRUE) {
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
n = full_write(ofd, buf, n);
if (n < 0)
perror_msg_and_die("%s", outfile);
if (n == bs)
out_full++;
else
out_part++;
}
/* Note that we are not freeing memory or closing
* files here, to save a few bytes. */
#ifdef BB_FEATURE_CLEAN_UP
close(inFd);
close(outFd);
#endif
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
(inTotal % blockSize) != 0);
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
(outTotal % blockSize) != 0);
fprintf(statusfp, "%d+%d records in\n", in_full, in_part);
fprintf(statusfp, "%d+%d records out\n", out_full, out_part);
return EXIT_SUCCESS;
usage:
usage(dd_usage);
}
+8 -13
View File
@@ -11,7 +11,7 @@
#include <sys/ioctl.h>
/* From <linux/vt.h> */
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
@@ -24,25 +24,20 @@ int deallocvt_main(int argc, char *argv[])
fd = get_console_fd("/dev/console");
if (argc == 1) {
printf("erik: A\n");
/* deallocate all unused consoles */
if (ioctl(fd, VT_DISALLOCATE, 0)) {
perror("VT_DISALLOCATE");
return EXIT_FAILURE;
}
} else
printf("erik: B\n");
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\n");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
else if (ioctl(fd, VT_DISALLOCATE, num)) {
perror("VT_DISALLOCATE");
error_msg_and_die("could not deallocate console %d\n", num);
}
else if (ioctl(fd, VT_DISALLOCATE, num))
perror_msg_and_die("VT_DISALLOCATE");
}
printf("erik: C\n");
}
return EXIT_SUCCESS;
}
+16 -3
View File
@@ -25,6 +25,7 @@
#define BB_DIRNAME
#define BB_DMESG
#define BB_DOS2UNIX
#define BB_DPKG_DEB
#define BB_DUTMP
#define BB_DU
#define BB_DUMPKMAP
@@ -46,7 +47,7 @@
#define BB_HOSTNAME
#define BB_ID
#define BB_INIT
#define BB_INSMOD
//#define BB_INSMOD
#define BB_KILL
#define BB_KILLALL
#define BB_LENGTH
@@ -279,10 +280,10 @@
// 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 BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
//#define BB_FEATURE_STATUSBAR
#define BB_FEATURE_STATUSBAR
//
// Clean up all memory before exiting -- usually not needed
// as the OS can clean up... Don't enable this unless you
@@ -327,6 +328,18 @@
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
+41 -15
View File
@@ -25,11 +25,12 @@
#define BB_DIRNAME
#define BB_DMESG
//#define BB_DOS2UNIX
#define BB_DPKG_DEB
//#define BB_DUTMP
#define BB_DU
//#define BB_DUMPKMAP
#define BB_ECHO
//#define BB_EXPR
#define BB_EXPR
#define BB_FBSET
//#define BB_FDFLUSH
#define BB_FIND
@@ -70,8 +71,8 @@
#define BB_MORE
#define BB_MOUNT
//#define BB_MT
#define BB_NSLOOKUP
#define BB_PING
//#define BB_NSLOOKUP
//#define BB_PING
#define BB_POWEROFF
//#define BB_PRINTF
#define BB_PS
@@ -105,7 +106,7 @@
#define BB_UPTIME
//#define BB_USLEEP
//#define BB_WC
#define BB_WGET
//#define BB_WGET
#define BB_WHICH
#define BB_WHOAMI
//#define BB_UUENCODE
@@ -211,7 +212,8 @@
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
//
// Enable support for mounting remote NFS volumes.
// You may no -o nolock if no local portmapper is running.
// You may need to mount with "-o nolock" if you are
// not running a local portmapper daemon...
#define BB_FEATURE_NFSMOUNT
//
// Enable support forced filesystem unmounting
@@ -221,27 +223,30 @@
// Enable support for creation of tar files.
//#define BB_FEATURE_TAR_CREATE
//
// Enable support for "--exclude" for excluding files
// Enable support for "--exclude" and "-X" for excluding files
//#define BB_FEATURE_TAR_EXCLUDE
//
// Enable support for tar -z option (currently only works for inflating)
#define BB_FEATURE_TAR_GZIP
//
//// Enable reverse sort
//#define BB_FEATURE_SORT_REVERSE
#define BB_FEATURE_SORT_REVERSE
//
// Enable command line editing in the shell
//#define BB_FEATURE_SH_COMMAND_EDITING
#define BB_FEATURE_SH_COMMAND_EDITING
//
//Allow the shell to invoke all the compiled in BusyBox commands as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell
//among other thing.
//Allow the shell to invoke all the compiled in BusyBox applets as if they
//were shell builtins. Nice for staticly linking an emergency rescue shell,
//among other things.
//#define BB_FEATURE_SH_STANDALONE_SHELL
//
//When this is enabled, busybox shell builtins can be called using full path
//names. This causes builtins (i.e. every single busybox command) to override
//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.
//#define BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
//
// Enable tab completion in the shell (not yet
// working very well -- so don't turn this on)
@@ -271,10 +276,11 @@
// Support for Minix filesystem, version 2
//#define BB_FEATURE_MINIX2
//
//
// Enable busybox --install [-s]
// to create links (or symlinks) for all the commands that are
// compiled into the binary. (needs /proc filesystem)
//#define BB_FEATURE_INSTALLER
// #define BB_FEATURE_INSTALLER
//
// Enable a nifty progress meter in wget (adds just under 2k)
#define BB_FEATURE_STATUSBAR
@@ -322,6 +328,26 @@
#endif
#endif
//
#ifdef BB_DPKG_DEB
#ifndef BB_AR
#define BB_AR
#endif
#ifndef BB_TAR
#define BB_TAR
#endif
#ifndef BB_FEATURE_TAR_GZIP
#define BB_FEATURE_TAR_GZIP
#endif
#endif
//
#ifdef BB_TAR
#ifdef BB_FEATURE_TAR_GZIP
#ifndef BB_GUNZIP
#define BB_GUNZIP
#endif
#endif
#endif
//
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
#define BB_NFSMOUNT
#endif
+6
View File
@@ -1,3 +1,9 @@
busybox (0.49-1) unstable; urgency=low
* Lots more source updates and bug fixes. See changelog for details.
-- Erik Andersen <andersee@debian.org> Sat, 27 Jan 2001 01:45:53 -0700
busybox (0.48-1) unstable; urgency=low
* Lots more source updates and bug fixes. See changelog for details.
+1 -1
View File
@@ -82,7 +82,7 @@ do_static: half_clean build-static install-static
# Now for the .udeb stuff
PACKAGE=busybox
PACKAGE=busybox-udeb
VERSION=$(shell dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
ARCH=$(shell dpkg --print-architecture)
FILENAME=$(PACKAGE)_$(VERSION)_$(ARCH).udeb
-23
View File
@@ -1,23 +0,0 @@
#!/bin/sh
# define.sh - creates an include file full of #defines
#
# SYNOPSIS
#
# define.sh POSIX_ME_HARDER ...
#
# <GPL>
for i ; do
case $1 in
!!*!!)
echo "// #define" `echo $1 | sed 's/^!!\(.*\)!!$/\1/'`
shift
;;
*)
echo "#define $1"
shift
;;
esac
done
# </GPL>
+58 -14
View File
@@ -2,7 +2,7 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999,2000 by Lineo, inc.
* 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>.
*
@@ -24,10 +24,15 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <mntent.h>
#include <sys/vfs.h>
#include <getopt.h>
extern const char mtab_file[]; /* Defined in utility.c */
#ifdef BB_FEATURE_HUMAN_READABLE
unsigned long disp_hr = KILOBYTE;
#endif
static int df(char *device, const char *mountPoint)
{
@@ -42,19 +47,32 @@ static int df(char *device, const char *mountPoint)
if (s.f_blocks > 0) {
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
if(0 == blocks_used)
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 */
find_real_root_device_name( device);
}
#ifdef BB_FEATURE_HUMAN_READABLE
printf("%-20s %9s",
device,
format((s.f_blocks * s.f_bsize), disp_hr));
printf(" %9s", format((s.f_blocks - s.f_bfree) * s.f_bsize, disp_hr));
printf(" %9s %3ld%% %s\n",
format(s.f_bavail * s.f_bsize, disp_hr),
blocks_percent_used, mountPoint);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
blocks_percent_used, mountPoint);
#endif
}
@@ -64,24 +82,46 @@ static int df(char *device, const char *mountPoint)
extern int df_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
int opt = 0;
int i = 0;
while ((opt = getopt(argc, argv, "?"
#ifdef BB_FEATURE_HUMAN_READABLE
"hm"
#endif
"k"
)) > 0)
{
switch (opt) {
#ifdef BB_FEATURE_HUMAN_READABLE
case 'h': disp_hr = 0; break;
case 'm': disp_hr = MEGABYTE; break;
case 'k': disp_hr = KILOBYTE; break;
#else
case 'k': break;
#endif
case '?': goto print_df_usage; break;
}
}
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
#ifdef BB_FEATURE_HUMAN_READABLE
(KILOBYTE == disp_hr) ? "1k-blocks" : " Size",
#else
"1k-blocks",
#endif
"Used", "Available", "Use%", "Mounted on");
if (argc > 1) {
if(optind < argc) {
struct mntent *mountEntry;
if (**(argv + 1) == '-') {
usage(df_usage);
}
while (argc > 1) {
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[1]);
for(i = optind; i < argc; i++)
{
if ((mountEntry = find_mount_point(argv[i], mtab_file)) == 0) {
error_msg("%s: can't find mount point.\n", argv[i]);
status = EXIT_FAILURE;
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
status = EXIT_FAILURE;
argc--;
argv++;
}
} else {
FILE *mountTable;
@@ -101,6 +141,10 @@ extern int df_main(int argc, char **argv)
}
return status;
print_df_usage:
usage(df_usage);
return(FALSE);
}
/*
+3 -1
View File
@@ -2,7 +2,7 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 2000 by Lineo, inc.
* 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
@@ -22,6 +22,8 @@
*/
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern int dirname_main(int argc, char **argv)
{
+7 -12
View File
@@ -18,9 +18,11 @@
#include "busybox.h"
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#if __GNU_LIBRARY__ < 5
#include <sys/syscall.h>
#include <linux/unistd.h>
#ifndef __alpha__
# define __NR_klogctl __NR_syslog
static inline _syscall3(int, klogctl, int, type, char *, b, int, len);
@@ -69,20 +71,16 @@ int dmesg_main(int argc, char **argv)
}
if (cmd == 8) {
n = klogctl(cmd, NULL, level);
if (n < 0) {
goto klogctl_error;
}
if (klogctl(cmd, NULL, level) < 0)
perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
if (bufsize < 4096)
bufsize = 4096;
buf = (char *) xmalloc(bufsize);
n = klogctl(cmd, buf, bufsize);
if (n < 0) {
goto klogctl_error;
}
if ((n = klogctl(cmd, buf, bufsize)) < 0)
perror_msg_and_die("klogctl");
lastc = '\n';
for (i = 0; i < n; i++) {
@@ -102,7 +100,4 @@ int dmesg_main(int argc, char **argv)
end:
usage(dmesg_usage);
return EXIT_FAILURE;
klogctl_error:
perror("klogctl");
return EXIT_FAILURE;
}
+79 -63
View File
@@ -38,21 +38,21 @@
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 embedded system. The utilities in BusyBox generally have fewer options than
their full-featured GNU cousins; however, the options that are included provide
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
embedded system. The utilities in BusyBox generally have fewer options than
their full featured GNU cousins; however, the options that are included provide
the expected functionality and behave very much like their GNU counterparts.
<p>
BusyBox has been written with size-optimization and limited resources in mind.
It is also extremely modular so you can easily include or exclude commands (or
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add a kernel, a shell (such as ash),
and an editor (such as elvis-tiny or ae). For a really minimal system, just
the the busybox shell (not a POSIX shell, but very small and quite usable).
features) at compile time. This makes it easy to customize your embedded
systems. To create a working system, just add /dev, a kernel, and an editor,
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
the busybox shell (not Bourne compatible, but very small and quite usable).
<p>
BusyBox is now maintained by
<a href="http://www.xmission.com/~andersen/erik/erik.html">
<a href="http://codepoet.org/andersen/erik/erik.html">
Erik Andersen</a>, and its ongoing development is being sponsored by
<a href="http://www.lineo.com/">Lineo</a>.
<p>
@@ -60,8 +60,8 @@ BusyBox is licensed under the
<a href="http://www.gnu.org/copyleft/gpl.html">GNU GENERAL PUBLIC LICENSE</a>
<p>
<H3>NEW!</h3>
BusyBox now has a mailing list <a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>!
<H3>Mailing List Information</h3>
BusyBox now has a <a href="http://opensource.lineo.com/lists/busybox/">mailing list</a>!
To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo/busybox">this page</a>.
<!-- Begin Latest News section -->
@@ -77,6 +77,30 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
<ul>
<p> <li> <b>27 January 2001 -- BusyBox 0.49 released</b>
<br>
Several new applets, lots of bug fixes, cleanups, and many smaller
things made nicer. Several cleanups and improvements to the shell.
For a list of the most interesting changes
you might want to look at the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Special thanks go out to Matt Kraai and Larry Doolittle for all their
work on this release, and for keeping on top of things while I've been
out of town.
<p>
<em>Special Note</em><br>
BusyBox 0.49 was supposed to have replaced lash, the BusyBox
shell, with a new shell that understands full Bourne shell/Posix shell grammer.
Well, that simply didn't happen in time for this release. A new
shell that will eventually replace lash is already under
construction. This new shell is being developed by Larry
Doolittle, and could use all of our help. Please see the work in
progress on <a href="http://doolittle.faludi.com/~larry/parser.html">Larry's website</a>
and help out if you can. This shell will be included in the next
release of BusyBox.
<p> <li> <b>13 December 2000 -- BusyBox 0.48 released</b>
<br>
@@ -85,30 +109,17 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
update of course: tar no longer breaks hardlinks, tar -xzf is
optionally supported, and the LRP folks will be pleased to know
that 'tar -X' and 'tar --exclude' are both now in. Applets are
now looked up using a binary search makeing lash (the busybox
now looked up using a binary search making lash (the busybox
shell) much faster. For the new debian-installer (for Debian
woody) a .udeb can now be generated.
<p>
The curious can get a list of some of the more interesting chages by reading
The curious can get a list of some of the more interesting changes by reading
the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>.
<p>
Many thanks go out to the many many people that have contributed to
this release, especially Matt Kraai, Larry Doolittle, and Kent Robotti.
<p> <li> <b>26 September 2000 -- BusyBox 0.47 released</b>
<br>
This release fixes lots of bugs (including an ugly bug in 0.46
syslogd that could fork-bomb your system). Added several new
apps: rdate, wget, getopt, dos2unix, unix2dos, reset, unrpm,
renice, xargs, and expr. syslogd now supports network logging.
There are the usual tar updates. Most apps now use getopt for
more correct option parsing.
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
for complete details.
<p> <li> <b>Old News</b>
<br>
For the old news, visit <a href="http://busybox.lineo.com/oldnews.html">the old news page</a>.
@@ -124,14 +135,20 @@ To subscribe, go and visit <a href="http://opensource.lineo.com/mailman/listinfo
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<ul>
<li> Source for the latest release can always be downloaded from
<li> Source for the latest release can always be downloaded from
<a href="ftp://oss.lineo.com/busybox">ftp://oss.lineo.com/busybox</a>.
<li> BusyBox now has its own publically browsable
<li> A new snapshot of the source is made daily and is available as a GNU
gzipped tarball <a href="busybox.tar.gz"> right here</a>.
<li> BusyBox now has its own publically browsable
<a href="http://opensource.lineo.com/cgi-bin/cvsweb/busybox/">CVS tree</a>,
anonymous
<a href="http://opensource.lineo.com/cvs_anon.html">CVS access</a>, and
for those that are actively contributing there is even
<a href="http://opensource.lineo.com/cvs_write.html">CVS write access</a>.
</ul>
@@ -163,42 +180,6 @@ Current documentation for BusyBox includes:
</ul>
<!-- Begin Projects section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="projects"><BIG><B>
Products/Projects Using BusyBox
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<p> I know of the following products and/or projects that use BusyBox --
listed in the order I happen to add them to the web page:
<ul>
<li> <a href="http://www.lineo.com/products/embedix_linux/">Lineo Embedix Linux</a>
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian installer (boot floppies) project</a>
<li> <a href="http://www.linuxrouter.org/">Linux Router Project </a>
<li> <a href="http://linux-embedded.org/">LEM</a>
<li> <a href="http://www.toms.net/rb/">tomsrtbt</a>
<li> <a href="http://www.stormix.com/">Stormix Installer</a>
<li> <a href="http://www.emacinc.com/linux2_sbc.htm">EMAC Linux 2.0 SBC</a>
<li> <a href="http://www.trinux.org/">Trinux</a>
<li> <a href="http://oddas.sourceforge.net/">ODDAS project</a>
<li> <a href="http://www.kerbango.com/">The Kerbango Internet Radio</a>
<li> <a href="http://www.linuxmagic.com/vpn/">LinuxMagic VPN Firewall</a>
<li> <a href="http://byld.sourceforge.net/">Build Your Linux Disk</a>
<li> <a href="http://homepages.ihug.co.nz/~ichi/baslinux.html">BasicLinux</a>
<li> <a href="http://ibiblio.org/pub/Linux/system/recovery">Zdisk</a>
<li> <a href="http://www.adtran.com">AdTran - VPN/firewall VPN Linux Distribution</a>
</ul>
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to
you.
<!-- Begin Links section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
@@ -234,6 +215,41 @@ you.
</ul>
<!-- Begin Projects section -->
<TR><TD BGCOLOR="#ccccc0" ALIGN=center>
<A NAME="projects"><BIG><B>
Products/Projects Using BusyBox
</A></B></BIG>
</TD></TR>
<TR><TD BGCOLOR="#eeeee0">
<p> I know of the following products and/or projects that use BusyBox --
listed in the order I happen to add them to the web page:
<ul>
<li> <a href="http://www.lineo.com/products/embedix_linux/">Lineo Embedix Linux</a>
<li> <a href="http://cvs.debian.org/boot-floppies/">Debian installer (boot floppies) project</a>
<li> <a href="http://www.linuxrouter.org/">Linux Router Project </a>
<li> <a href="http://linux-embedded.org/">LEM</a>
<li> <a href="http://www.toms.net/rb/">tomsrtbt</a>
<li> <a href="http://www.stormix.com/">Stormix Installer</a>
<li> <a href="http://www.emacinc.com/linux2_sbc.htm">EMAC Linux 2.0 SBC</a>
<li> <a href="http://www.trinux.org/">Trinux</a>
<li> <a href="http://oddas.sourceforge.net/">ODDAS project</a>
<li> <a href="http://www.kerbango.com/">The Kerbango Internet Radio</a>
<li> <a href="http://www.linuxmagic.com/vpn/">LinuxMagic VPN Firewall</a>
<li> <a href="http://byld.sourceforge.net/">Build Your Linux Disk</a>
<li> <a href="http://homepages.ihug.co.nz/~ichi/baslinux.html">BasicLinux</a>
<li> <a href="http://ibiblio.org/pub/Linux/system/recovery">Zdisk</a>
<li> <a href="http://www.adtran.com">AdTran - VPN/firewall VPN Linux Distribution</a>
<li> <a href="http://mkcdrec.ota.be/">mkCDrec - make CD-ROM recovery</a>
<li> <a href="http://recycle.lbl.gov/~ldoolitt/bse/">Linux on nanoEngine</a>
</ul>
<p> Do you use BusyBox? I'd love to know about it and I'd be happy to link to
you.
<!-- End of Table -->
+13
View File
@@ -41,6 +41,19 @@
<p> <li> <b>Take me back to the <a href="http://busybox.lineo.com/">BusyBox</a> web site.</b>
<hr>
<p> <li> <b>26 September 2000 -- BusyBox 0.47 released</b>
<br>
This release fixes lots of bugs (including an ugly bug in 0.46
syslogd that could fork-bomb your system). Added several new
apps: rdate, wget, getopt, dos2unix, unix2dos, reset, unrpm,
renice, xargs, and expr. syslogd now supports network logging.
There are the usual tar updates. Most apps now use getopt for
more correct option parsing.
See the <a href="ftp://oss.lineo.com/busybox/Changelog">changelog</a>
for complete details.
<p> <li> <b>11 July 2000 -- BusyBox 0.46 released</b>
<br>
+53 -16
View File
@@ -56,16 +56,16 @@ terse runtime description of their behavior.
Currently defined functions include:
ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear, cp, cut, date, dc,
dd, deallocvt, df, dirname, dmesg, dos2unix, du, dumpkmap, dutmp, echo, false,
fbset, fdflush, find, free, freeramdisk, fsck.minix, getopt, grep, gunzip,
gzip, halt, head, hostid, hostname, id, init, insmod, kill, killall, length,
ln, loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs, mkdir,
mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc, nslookup,
ping, poweroff, printf, ps, pwd, rdate, reboot, renice, reset, rm, rmdir,
rmmod, sed, setkeycodes, sh, sleep, sort, swapoff, swapon, sync, syslogd, tail,
tar, tee, telnet, test, touch, tr, true, tty, umount, uname, uniq, unix2dos,
unrpm, update, uptime, usleep, uudecode, uuencode, wc, which, whoami, xargs,
yes, zcat, [
dd, deallocvt, df, dirname, dmesg, dos2unix, dpkg-deb, du, dumpkmap, dutmp,
echo, false, fbset, fdflush, find, free, freeramdisk, fsck.minix, getopt, grep,
gunzip, gzip, halt, head, hostid, hostname, id, init, insmod, kill, killall,
length, ln, loadacm, loadfont, loadkmap, logger, logname, ls, lsmod, makedevs,
mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nc,
nslookup, ping, poweroff, printf, ps, pwd, rdate, reboot, renice, reset, rm,
rmdir, rmmod, sed, setkeycodes, sh, sleep, sort, swapoff, swapon, sync,
syslogd, tail, tar, tee, telnet, test, touch, tr, true, tty, umount, uname,
uniq, unix2dos, unrpm, update, uptime, usleep, uudecode, uuencode, watchdog,
wc, which, whoami, xargs, yes, zcat, [
-------------------------------
@@ -421,6 +421,32 @@ Converts a text file from dos format to unix format.
-------------------------------
=item dpkg-deb
Usage: dpkg-deb [-cexX] archive-file [directory]
Debian package archive (.deb) manipulation tool
Options:
-c Lists the contents of the filesystem tree archive
portion of the package archive.
-e Extracts the control information files from a package
archive into the specified directory.
-x Silently extracts the filesystem tree from a package
archive into the specified directory.
-X Extracts the filesystem tree from a package archive
into the specified directory, list files as it goes.
Example:
dpkg-deb -X ./busybox_0.48-1_i386.deb /tmp
-------------------------------
=item du
Usage: du [OPTION]... [FILE]...
@@ -845,6 +871,7 @@ Options:
-g prints only the group ID
-u prints only the user ID
-n print a name instead of a number (with for -ug)
-r prints the real user ID instead of the effective ID (with -ug)
Example:
@@ -887,10 +914,11 @@ If you choose to use an /etc/inittab file, the inittab entry format is as follow
the specified process to run on. The contents of this field are
appended to "/dev/" and used as-is. There is no need for this field to
be unique, although if it isn't you may have strange results. If this
field is left blank, it is completely ignored. Also note that if
BusyBox detects that a serial console is in use, then all entries
containing non-empty id fields will _not_ be run. BusyBox init does
nothing with utmp. We don't need no stinkin' utmp.
field is left blank, the controlling tty is set to the console. Also
note that if BusyBox detects that a serial console is in use, then only
entries whose controlling tty is either the serial console or /dev/null
will be run. BusyBox init does nothing with utmp. We don't need no
stinkin' utmp.
<runlevels>:
@@ -985,6 +1013,7 @@ Options:
-k Make module autoclean-able.
-v verbose output
-x do not export externs
-L Prevent simultaneous loads of the same module
-------------------------------
@@ -1100,7 +1129,7 @@ Example:
Usage: logger [OPTION]... [MESSAGE]
Write MESSAGE to the system log. If MESSAGE is '-', log stdin.
Write MESSAGE to the system log. If MESSAGE is omitted, log stdin.
Options:
@@ -2066,6 +2095,14 @@ Example:
-------------------------------
=item watchdog
Usage: watchdog device
Periodically writes to watchdog device B<device>.
-------------------------------
=item wc
Usage: wc [OPTION]... [FILE]...
@@ -2293,4 +2330,4 @@ Enrique Zanardi <ezanardi@ull.es>
=cut
# $Id: busybox.pod,v 1.83 2000/12/13 17:59:37 andersen Exp $
# $Id: busybox.pod,v 1.89 2001/01/25 23:40:32 andersen Exp $
+67 -16
View File
@@ -137,8 +137,8 @@
<para>
ar, basename, cat, chgrp, chmod, chown, chroot, chvt, clear,
cp, cut, date, dc, dd, deallocvt, df, dirname, dmesg, du,
dumpkmap, dutmp, echo, false, fbset, fdflush, find, free,
cp, cut, date, dc, dd, deallocvt, df, dirname, dmesg, dpkg-deb,
du, dumpkmap, dutmp, echo, false, fbset, fdflush, find, free,
freeramdisk, fsck.minix, grep, gunzip, gzip, halt, head,
hostid, hostname, id, init, insmod, kill, killall, length, ln,
loadacm, loadfont, loadkmap, logger, logname, ls, lsmod,
@@ -758,6 +758,44 @@
</sect1>
<sect1 id="dpkg-deb">
<title>dpkg-deb</title>
<para>
Usage: dpkg-deb [OPTION] archive [directory]
</para>
<para>
Debian package archive (.deb) manipulation tool
</para>
<para>
Options:
</para>
<para>
<screen>
-c List the contents of the filesystem tree archive portion of the package
-e Extracts the control information files from a package archive into the specified directory.
If no directory is specified then a subdirectory DEBIAN in the current directory is used.
-x Silently extracts the filesystem tree from a package archive into the specified directory.
-X Extracts the filesystem tree from a package archive into the specified directory, listing the files as it goes.
If required the specified directory (but not its parents) will be created.
</screen>
<para>
<para>
Example:
</para>
<para>
<screen>
dpkg-deb -e ./busybox_0.48-1_i386.deb
dpkg-deb -x ./busybox_0.48-1_i386.deb ./unpack_dir
</screen>
</para>
</sect1>
<sect1 id="du">
<title>du</title>
@@ -1436,6 +1474,7 @@
<screen>
-g Print only the group ID
-u Print only the user ID
-n print a name instead of a number (with for -ug)
-r Print the real user ID instead of the effective ID (with -ug)
</screen>
</para>
@@ -1512,19 +1551,18 @@
<sect2>
<title>id</title>
<para>
WARNING: This field has a non-traditional
meaning for BusyBox init! The id field is used
by BusyBox init to specify the controlling tty
for the specified process to run on. The
contents of this field are appended to "/dev/"
and used as-is. There is no need for this field
to be unique, although if it isn't you may have
strange results. If this field is left blank,
it is completely ignored. Also note that if
BusyBox detects that a serial console is in use,
then all entries containing non-empty id fields
will _not_ be run. BusyBox init does nothing
with utmp. We don't need no stinkin' utmp.
WARNING: This field has a non-traditional meaning for BusyBox init!
The id field is used by BusyBox init to specify the controlling tty
for the specified process to run on. The contents of this field
are appended to "/dev/" and used as-is. There is no need for this
field to be unique, although if it isn't you may have strange
results. If this field is left blank, the controlling tty is set
to the console. Also note that if BusyBox detects that a serial
console is in use, then only entries whose controlling tty is
either the serial console or /dev/null will be run. BusyBox init
does nothing with utmp. We don't need no stinkin' utmp.
</para>
</sect2>
@@ -1660,6 +1698,7 @@
-k Make module autoclean-able.
-v Verbose output
-x Do not export externs
-L Prevent simultaneous loads of the same module
</screen>
</para>
</sect1>
@@ -1873,7 +1912,7 @@
</para>
<para>
Write MESSAGE to the system log. If MESSAGE is '-', log
Write MESSAGE to the system log. If MESSAGE is omitted, log
stdin.
</para>
@@ -3621,6 +3660,18 @@
</para>
</sect1>
<sect1 id="watchdog">
<title>watchdog</title>
<para>
Usage: watchdog device
</para>
<para>
Periodically writes to watchdog device B<device>.
</para>
</sect1>
<sect1 id="wc">
<title>wc</title>
Loaded 100 of 245 files, more files were not shown because too many files have changed in this diff. Show more