Compare commits

...
1142 Commits
Author SHA1 Message Date
Bernhard Reutner-Fischer e203ea59c7 - don't look at the address but rather on the value.
(r14748 from trunk)
2006-04-10 20:37:29 +00:00
Bernhard Reutner-Fischer addf86e3d3 - stable version 1.1.2 2006-04-10 20:17:34 +00:00
Rob Landley 8dc83c654d Bring this up to date with busybox-1.1.1.fixes.patch by importing
svn 14653, 14684, 14746, and 14749.
2006-04-05 03:10:42 +00:00
Bernhard Reutner-Fischer 7fe9dd5dd7 - fix one-argument mount in cases where fstab or mtab contain overlapping
entries.  (Such as "mount -o remount,rw /" where you're not on rootfs.).
  (r14723 from trunk)
2006-04-04 08:23:59 +00:00
Bernhard Reutner-Fischer 5e89953273 - make sure that we see all lib*/.c in IMA-mode even when not building the .so
(r14740 from trunk).
2006-04-04 08:21:36 +00:00
Paul Fox efbadf9f3f prevent find from ever descending into an xdev'ed directory.
(brought over from trunk r14665)
2006-03-30 20:06:46 +00:00
Bernhard Reutner-Fischer 2ebc69a4c6 - pull r14681 from trunk:
don't free foreign mem.
2006-03-30 13:03:28 +00:00
Bernhard Reutner-Fischer 59970faa39 - pull r14643 from trunk:
make sure that we see freeramdisk only once
2006-03-30 12:56:26 +00:00
Bernhard Reutner-Fischer fe802ee02c - pull r14628 from trunk:
Bug spotted by Stephane Billiart: losetup depends on loop.c.
2006-03-30 12:55:12 +00:00
Bernhard Reutner-Fischer 7ff69e3ab8 - upcoming stable version 1.1.2 2006-03-30 12:52:37 +00:00
Paul Fox 5139bd98a7 add public-domain release 2006-03-29 19:54:02 +00:00
Bernhard Reutner-Fischer e375e8c732 - we only need obj_gpl_license if ENABLE_FEATURE_CHECK_TAINTED_MODULE is set 2006-03-29 18:57:09 +00:00
Bernhard Reutner-Fischer 56dd0bff06 - shrink mkswap and make v0 support optional. Thanks also to Tito for his ideas.
http://busybox.net/lists/busybox/2006-March/019326.html

   2137	      8	     28	   2173	    87d	util-linux/mkswap.o.orig
   1890	      8	     28	   1926	    786	util-linux/mkswap.o.v0+v1
   1560	      4	     28	   1592	    638	util-linux/mkswap.o.v1
2006-03-29 17:32:24 +00:00
Bernhard Reutner-Fischer b256bd334f - shrink dmesg a bit.
http://busybox.net/lists/busybox/2006-March/019477.html
2006-03-29 17:26:14 +00:00
Rob Landley ca087713f2 More extern removal from Robert P. Day. 2006-03-29 16:52:56 +00:00
Bernhard Reutner-Fischer cb8d4319a3 find ./ -name .cvsignore | xargs svn rm 2006-03-29 15:51:19 +00:00
Rob Landley 24b0a9568d Documentation from Jan Kiszka 2006-03-29 15:35:23 +00:00
Rob Landley fe908fda28 Kumar Gala tracked down a problem with NFS mounting. This is a different fix
from his, but to the same problem.
2006-03-29 14:30:49 +00:00
Rob Landley dbd91af061 Mike Frysinger pointed out we can go
CFLAGS=-I/usr/some/funky/path/to/selinux \
  LDFLAGS=-L/usr/some/funky/path/to/selinux make
So Jan Kiszka reverted part of the selinux patch.
2006-03-28 19:40:15 +00:00
Rob Landley 92fff34de6 Bernhard Fischer spotted that we shouldn't free fstype if we didn't allocate
it.
2006-03-28 19:19:19 +00:00
Paul Fox f0305b7f75 fix behavior of ZZ, with respect to readonly mode(s). original
patch and report from Alexander Griesser.
2006-03-28 14:18:21 +00:00
Mike Frysinger 6850017a2f remove some more config code rob missed in rev 13701 cleanup as reported by Robert P. J. Day 2006-03-28 06:11:51 +00:00
Mike Frysinger f885513940 just whitespace fixes 2006-03-28 02:35:56 +00:00
Rob Landley 87848d91c7 setlogcons, from Jan Kaszka. 2006-03-27 23:23:43 +00:00
Rob Landley 28ff9668d9 Mention that 1.1.2 should be out Juneish. 2006-03-27 23:22:16 +00:00
Paul Fox 986ab525b8 ensure that corrupted file extraction causes both a message and
a failure exit code.  delay the error exit until all (good) files
have been extracted.

filesystem errors (nodes of wrong type, permission problems, etc)
still cause immediate failure.
2006-03-27 23:09:14 +00:00
Rob Landley b3ede5abe2 More from Jan Kiszka: this is a port of the latest sysv-init SELinux patch.
It makes busybox invoke the libselinux library function to load the binary
policy right at system start-up. It was successfully tested on a mini-SELinux
system.  Note: requires recent libselinux. I'm using 1.28.
2006-03-27 23:09:12 +00:00
Rob Landley d1f8c1c125 From Jan Kiszka: This patch fixes the security labelling of the login terminal
and process... There still remains some stuff to clean up (the whole
set_current_security_context() appears unnecessary complex to me), but this is
now at least working.
2006-03-27 23:04:42 +00:00
Rob Landley 164a5be04e Patch from Jan Kiszka: In case the libselinux development installation is not
located at its default location, this patch allows to override the path via
SELINUX_INC and SELINUX_LIB when invoking make.
2006-03-27 23:00:32 +00:00
Rob Landley 0949d30638 Software Freedom Law Center and the fixes.patch thing. 2006-03-27 22:43:40 +00:00
Paul Fox 9360f42d32 add support for :wn (initial patch from Alexander Griesser) 2006-03-27 21:51:16 +00:00
Paul Fox dbf935dae6 drop obsolete version string in favor of actual BB version (from
Bernhard Fischer)
2006-03-27 20:29:33 +00:00
Rob Landley c370ea89fa Turn #if 0 into a comment. 2006-03-27 17:00:11 +00:00
Paul Fox 8416a2d558 prevent find from ever descending into an xdev'ed directory. 2006-03-27 16:42:33 +00:00
Rob Landley 3570915769 More dead code removal. 2006-03-26 21:49:42 +00:00
Rob Landley 4789694372 Robert P Day removed some commented out code. 2006-03-26 21:42:40 +00:00
Rob Landley 90ece609e6 Define both big endian and little endian macros. 2006-03-25 03:01:59 +00:00
Rob Landley 0bafd47e84 Stephane Billiart found an endianness bug in insmod. 2006-03-25 02:49:28 +00:00
Bernhard Reutner-Fischer 771b186406 - commentary typos 2006-03-24 14:30:05 +00:00
Bernhard Reutner-Fischer 2dd13bd25a - make sure that we see freeramdisk only once 2006-03-24 09:48:18 +00:00
Rob Landley d1968672ef When cross-compiling, the install directory for shared libraries has to come
from gcc (target machine), not uname (host machine).
2006-03-24 02:42:58 +00:00
Mike Frysinger 787140df39 remove in place of external link 2006-03-23 23:44:29 +00:00
Bernhard Reutner-Fischer e0fe937593 - correct typo 2006-03-23 16:52:59 +00:00
Rob Landley 1bb31928d5 Bug spotted by Stephane Billiart: losetup depends on loop.c. 2006-03-23 16:49:22 +00:00
Rob Landley fb3a631310 Very nice patch from Rich Felker to portably set the stream error indicator and
thus remove a lot of nasty old code that didn't.
2006-03-23 15:30:26 +00:00
Mike Frysinger dce5809ebc make the makefile a little more flexible so we can store in either location 2006-03-23 03:47:19 +00:00
Rob Landley 5fba2505d4 News entry announcing 1.1.1. 2006-03-23 03:08:09 +00:00
Mike Frysinger 13c8327b79 sync busybox and udhcp trees 2006-03-23 03:05:05 +00:00
Mike Frysinger e1d41b3102 fixup style 2006-03-23 02:07:41 +00:00
Mike Frysinger 948a09d6f2 dont printf arguments given by user for security sanity 2006-03-23 02:07:20 +00:00
Mike Frysinger 64bef2ab9c fix typo 2006-03-23 02:06:29 +00:00
Rob Landley ca8d0b029b We make both busybox and busybox_unstripped all the time now, no need to
specify whether or not to strip the binary.
2006-03-22 21:03:21 +00:00
Rob Landley 2dd4279959 Patch from Rogelio Serrano to defer checking whether the tty exists until
we actually need to spawn something on it.
2006-03-22 17:39:13 +00:00
Rob Landley 2324a7c9e5 Fix "seq 1 1". 2006-03-22 17:11:44 +00:00
Rob Landley a35886c862 Fix from Glenn McGrath. 2006-03-22 16:59:12 +00:00
Rob Landley 786988faf7 Tweak allbareconfig not to pause. 2006-03-22 15:24:24 +00:00
Rob Landley 7328c8fdc1 Annoint 1.1.1. 2006-03-22 14:07:23 +00:00
Rob Landley cebea726e8 Another header suggestion from Shaun Jackman. 2006-03-22 00:46:36 +00:00
Mike Frysinger 06adf5fb47 2006-03-21 Shaun Jackman <sjackman@gmail.com>: Include signal.h instead of sys/signal.h. 2006-03-22 00:25:07 +00:00
Rob Landley 3ea05d3222 Fix missing copyright and license notice. 2006-03-21 18:20:40 +00:00
Rob Landley d049812571 Patch from Stuart Hughes upgrading depmod.pl 2006-03-21 16:35:50 +00:00
Rob Landley 8dd4ca787a Patch from Shaun Jackman to make loop.c build only when needed. 2006-03-21 16:22:19 +00:00
Rob Landley 6a776e9558 Temporarily disable shared library for the 1.1.1 release. 2006-03-21 16:07:39 +00:00
Bernhard Reutner-Fischer d1ba916167 - workaroung pr25795 in gcc-4.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
2006-03-21 11:06:43 +00:00
Rob Landley e3f4ab2bc4 Remove unneeded entries. 2006-03-20 18:40:07 +00:00
Rob Landley 8caffaa9a9 Cleanup: remove double quotes that don't seem to be needed. 2006-03-20 18:39:02 +00:00
Eric Andersen 9601a1c8c2 whitespace cleanup 2006-03-20 18:07:50 +00:00
Eric Andersen 19b5b8ff6a Fix some obvious compile problems. Make the -f' fakeIt option actually work. 2006-03-20 18:07:13 +00:00
Eric Andersen a6db0eef59 Willy Tarreau writes:
I encountered a little typo in 'make help' : the prefix was
noted "$prefix" instead of "$(PREFIX)".
2006-03-20 17:50:08 +00:00
Eric Andersen 28a6afe975 Roy Walker writes:
Here is a patch against the current subversion repository, that makes
udhcpc have an adjustable timeout.  Works for both foreground and before
it drops to the background.  This brings it more in-line with ISC dhcpc.

Use like so:
udhcpc --timeout=10 ...
or
udhcpc -T 10 ...

Still shooting for 1.1.1 this month?  Would really be great if you could
get this in that release.

Please give credit to Paul Pacheco - ppacheco@gmail.com.
2006-03-20 17:37:00 +00:00
Rob Landley c30f445b08 Patch from tito, acked by Bernhard Fischer. 2006-03-20 02:20:18 +00:00
Rob Landley e2b428cbb1 Use lstat() instead of stat so /init being a symlink doesn't screw people up.
(And use it consistently, for size reasons.)
2006-03-20 01:43:29 +00:00
Bernhard Reutner-Fischer 99a072d524 - tito writes: this patch fixes some comments in dos2unix that are wrong
or that reports non existent features (that i've ripped out...)
2006-03-18 23:05:37 +00:00
Bernhard Reutner-Fischer 2523da259c - explain what magic numbers we're using here. 2006-03-18 23:02:45 +00:00
Bernhard Reutner-Fischer 66753a3850 - whitespace cleanup (and also check against the const first and only then look
at bb_applet_name[1])
2006-03-18 15:59:29 +00:00
Bernhard Reutner-Fischer 263e75d051 - fix order of includes. 2006-03-18 11:59:55 +00:00
Mike Frysinger 9aa7f2005d declare const id argument const for probe_{ext2,ext3,cramfs} 2006-03-18 04:17:59 +00:00
Mike Frysinger 179f417788 need string.h as well as strings.h 2006-03-18 04:13:32 +00:00
Mike Frysinger 25f67d419d need EXT2FS_OBJS for fsck 2006-03-18 04:11:51 +00:00
Rob Landley 6bc10635f8 Make the new chroot environment creation infrastructure more flexible about
non-absolute paths.
2006-03-18 03:01:57 +00:00
Rob Landley dcb2122e85 My mount testsuite. Not automatically run at the moment, need to figure out
how to (optionally) supply User Mode Linux to runtests.
2006-03-18 03:00:22 +00:00
Rob Landley eaa34ca5b4 More fixes. Type "auto" should mean unspecified from fstab as well as the
command line, initialize singlemount's rc to an error value so it doesn't
think it succeeded when it didn't, use absolute path when associating a
loop device (and the previous FEATURE_CLEAN_UP logic related to that was
freeing the wrong thing), move reading of /proc/filesystems to where we can
re-read it (when it's empty) for every entry on a "mount -a" so that when
/proc is mounted as the first entry, the later filesystems can autodetect
filesystem type.
2006-03-18 02:58:11 +00:00
Rob Landley aae8b3405e Whitespace cleanup and minor tweak (return -ERRNO instead of ERRNO so
EPERM doesn't register as a successful read-only mount.
2006-03-18 02:38:10 +00:00
Rob Landley 5a57821565 Bug fix: umount wasn't detaching loop devices unless mtab support was enabled.
Made some whitespace cleanups while I was there.
2006-03-17 03:30:05 +00:00
Rob Landley 2824ded677 More test updates. 2006-03-16 16:02:06 +00:00
Rob Landley 4bb1b04fd1 Redo test suite to be able to test more than one command at a time. Eliminate
$COMMAND environment variable, instead put full command line (including
command to run) in second argument.  Modify $PATH to have test versions of
commands at start of path.  (Also more infrastructure for testing as root,
work in progress...)
2006-03-16 15:20:45 +00:00
Rob Landley ea9a471acd Random in-passing tweak. 2006-03-16 14:40:27 +00:00
Rob Landley 187e352b7f Update for bug 14. 2006-03-15 17:09:56 +00:00
Rob Landley 330ac853e3 Tito shrank dos2unix. 2006-03-14 21:49:18 +00:00
Rob Landley 31642d75e1 More "extern" removals from Robert P. Day 2006-03-14 21:45:38 +00:00
Rob Landley 386f85eadf Attempt to make a warning go away without increasing size. 2006-03-14 21:13:48 +00:00
Rob Landley d221d2137f Missed one. 2006-03-14 20:06:44 +00:00
Rob Landley dc0955b603 The new, new mount rewrite. (Mount double prime?) Still being debugged, but
the new infrastructure is reentrant so in theory it's capable of handling
mount -a sanely.  It can also re-use existing flags with remount, handle
-t auto, mount -a -t, and several smaller bugfixes.
2006-03-14 18:16:25 +00:00
Rob Landley 0b22c1c962 Tito unified fdflush and freeramdisk. I tweaked the result a bit. 2006-03-14 02:40:51 +00:00
Mike Frysinger 2f135fc6bf update comments as to what caused the defines to change 2006-03-13 23:48:18 +00:00
Bernhard Reutner-Fischer ef7ccac9da - add two comments 2006-03-13 20:32:48 +00:00
Bernhard Reutner-Fischer a25d83b282 - remove superfluous dependency which was fixed in r14527 2006-03-13 19:30:06 +00:00
Bernhard Reutner-Fischer df10094870 - revert back to r14406 2006-03-13 19:04:00 +00:00
Rob Landley c5b1d4d6b1 Patch from Denis Vlasenko to add xstat() and use it. 2006-03-13 15:45:16 +00:00
Rob Landley 965030e35a Update documentation. 2006-03-13 04:38:40 +00:00
Rob Landley 19808fea76 "make help" should not build the configurator first. 2006-03-13 03:19:46 +00:00
Rob Landley 9dc6913896 Fix "rm .config;make menuconfig" to work like "rm .config; make" (I.E. do
defconfig first), and group busybox administrative settings into a sub-menu.
2006-03-13 02:52:23 +00:00
Rob Landley e01d746fe9 Cleanup patch from tito. 2006-03-12 19:26:01 +00:00
Rob Landley 1c60d9762e Size reduction by Tito. 2006-03-11 18:22:35 +00:00
Mike Frysinger 9e094552c8 fix building with glibc-2.4 2006-03-10 23:41:29 +00:00
Mike Frysinger c70240cc1d add a sep option for stripping 2006-03-10 23:20:48 +00:00
Mike Frysinger 72d59dbd76 rearrange the menu a little to split general settings from applet selection 2006-03-10 23:17:17 +00:00
Rob Landley ead19306f5 Cleanup patches from tito. 2006-03-10 23:16:25 +00:00
Rob Landley bc68cd14cc Patch from Denis Vlasenko turning static const int (which gets emitted into
the busybox binary) into enums (which don't).
2006-03-10 19:22:06 +00:00
Rob Landley dae6aa2859 Fixup to the previous (portability) patch. Linux actually does need
arpa/inet.h rather than netinet/in.h, otherwise we get warnings.
2006-03-09 22:39:08 +00:00
Rob Landley 1f305dc0fd Portability patch from rfelker. The bb_asprintf.c thing needs an eventual
follow up in platform.h to set the #ifdef, but the workaround works for
everybody, so...
2006-03-09 22:21:20 +00:00
Rob Landley 3a324754f8 I'm about to introduce tests that need to run as root (like mount.tests),
meaning we want to run them in a chroot environment.  To help with this,
I worked out a utility function that makes it really easy to set up a chroot
environment.
2006-03-09 22:04:33 +00:00
Rob Landley 31e3610c4b Cleanup from Paul Fox. One find piped to xargs is faster/simpler than
lots of finds doing individual -exec rm.
2006-03-09 22:01:05 +00:00
Rob Landley ac664e07df Mention a few web browsers. 2006-03-09 18:20:43 +00:00
Rob Landley d48633fa6f They won't stop asking, but we can point them to the specific entry... 2006-03-09 18:03:21 +00:00
Rob Landley 49a5599ae9 Patch from Denis Vlasenko to make unlzma smaller. 2006-03-09 17:51:25 +00:00
Bernhard Reutner-Fischer 478a188e85 - remove check. Fixes e.g. buildroot 2006-03-09 16:49:46 +00:00
Bernhard Reutner-Fischer 39a9fddb53 - fix typo 2006-03-09 16:49:01 +00:00
Bernhard Reutner-Fischer 07a79e75f5 - backout using features which are not available with the previous stable
version of make (3.71.1).
2006-03-09 09:03:37 +00:00
Mike Frysinger 874af85d5e import most of e2fsprogs 1.38 updates 2006-03-08 07:03:27 +00:00
Paul Fox 0f2dd9f4eb vi-mode changes: eliminate warnings from out-of-range-for-type
case labels that are emitted by gcc4.  rearrange macros to
eliminate these extra case labels entirely (since the optimizer
may no longer do it for us).  eliminate static BUFSIZ character
deletion buffer -- malloc it, and make it much much smaller.
2006-03-07 20:26:11 +00:00
Rob Landley dfba741457 Robert P. Day removed 8 gazillion occurrences of "extern" on function
definitions.  (That should only be on prototypes.)
2006-03-06 20:47:33 +00:00
Rob Landley 1f5e25bf3e Walt Wimer noticed that mknod couldn't handle major or minor > 255. Now our
limit checking autodetects what the system supports (at compile time).
2006-03-06 19:31:39 +00:00
Bernhard Reutner-Fischer 2e9cf373a9 - workaround bug in make-3.81beta4:
- has to use
/top/obj/dir/*.o: /top/obj/dir/file.o: /top/src/file.c
instead of the proper
/top/obj/dir/*.o: /top/obj/dir/file.o: /top/src/dir/file.c
2006-03-06 14:20:43 +00:00
Bernhard Reutner-Fischer a59721166a - work around missing features and bugs in make-3.79.1:
- no order-only prerequisites; incomplete workaround (see comment in diff)
- no internal variable MAKEFILE_LIST; workaround
- define bar\nfoo:=<long-list>  doesn't work; workaround
also:
- reinstate clean, distclean as noconfig_target.
- unconditionally clean libbusybox.so*
2006-03-06 14:19:15 +00:00
Mike Frysinger 56ee779074 clean *.osm as pointed out by Robert P. J. Day 2006-03-05 18:04:23 +00:00
Mike Frysinger 33b45a09a1 clean busybox_unstripped as pointed out by Robert P. J. Day 2006-03-05 16:25:19 +00:00
Rob Landley 688ed0d760 Patch from Robert P. Day, moving byte order checks to use platform.h macros. 2006-03-04 22:40:25 +00:00
Bernhard Reutner-Fischer d9969ea175 - correct comment.
Should revisit gcc >= 4.1 with that =1 later on
2006-03-03 20:31:33 +00:00
Rob Landley 06ec8cff83 Typo fixes brought to you by the letters a, l, and Robert P. Day. 2006-03-03 19:02:50 +00:00
Eric Andersen cbd1c85744 Kill off some unused code that was wasting several k, as noticed by
Denis Vlasenko when building with  -ffunction-sections -fdata-sections
2006-03-03 18:37:39 +00:00
Rob Landley c05dda4b2d Denis Vlasenko noticed that falign=0 is meaningless, and that should probably
be falign=1.  Saves a little over 3k on an x86 "make defconfig" build.
2006-03-03 17:57:50 +00:00
Bernhard Reutner-Fischer 7ad83b4e2c - ar cruP doesn't replace ('r') but unconditionally _adds_ all objects.
landley, that one broke your tar-testing (see below).

To see the issue i was talking about in the comment to rev. 14431, remove the
'P' from ARFLAGS in Rules.mak, then recompile.

You will see undefined references to these symbols:
iplink_main
iproute_main
iptunnel_main
login_main
run_parts_main


These are due to the fact that these applets (named e.g. login.o) clash with
libbb/login.o, for example. So ar sees that we're going to add login.o
(the applet!) and does so. Later on, we add libbb/login.o (just the basename
is used, so login.o). and this libbb/login.o *replaces* the login.o (the
applet!).

I therefor want (you) to rename abovementioned files from libbb to have
a prefix bb_ (e.g. svn mv libbb/login.c libbb/bb_login.c) to avoid these
clashed.

ok?
TIA,
2006-03-03 14:19:15 +00:00
Bernhard Reutner-Fischer e3ec99de82 - remove unused lists *-m 2006-03-02 18:23:13 +00:00
Bernhard Reutner-Fischer c8e278f54b - make sure applets.o is rebuilt when the .config changes.
- don't overwrite objects in the archive. Affected applets with name-clash
  mostly vs. libbb:
iplink_main
iproute_main
iptunnel_main
login_main
run_parts_main
2006-03-02 18:13:05 +00:00
Bernhard Reutner-Fischer 9b6b894422 - allow for make /path/to/dir/file.o 2006-03-02 17:38:15 +00:00
Bernhard Reutner-Fischer 022eb311d5 - use absolute path for top_builddir and top_srcdir.
Fixes make trying to include the very same file in an endless loop.
2006-03-02 17:33:25 +00:00
Bernhard Reutner-Fischer c0bb308389 - silence warning about "'free_and_close_stuff' used but never defined" 2006-03-02 10:06:22 +00:00
Bernhard Reutner-Fischer cfc5d860e6 Denis Vlasenko writes: make sizes was rebuilding busybox - unstripped one! 2006-03-02 09:44:32 +00:00
Bernhard Reutner-Fischer 5d26126b9e - fixes parallel builds (make -j)
- use less resources for the buildsystem itself
2006-03-01 22:54:48 +00:00
Rob Landley 12c2429a42 Fixup to make warnings from the last patch go away. 2006-03-01 21:36:18 +00:00
Rob Landley 08abe64d91 Selinux fix from Jan Kiszka. 2006-03-01 20:48:44 +00:00
Bernhard Reutner-Fischer b7f39732f8 - fix compilation of sed.
error: static declaration of 'free_and_close_stuff' follows non-static declaration
  Tiny whitespace cleanup while at it,
  also make sure that we don't use CONFIG_ anymore.

Rob, hope this is ok w/ you..
2006-03-01 20:14:16 +00:00
Rob Landley e7c43b66d7 Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)
from before "if(x) free(x)".
2006-03-01 16:39:45 +00:00
Rob Landley 93f2286e6e When gnu fails this one we shouldn't let it _hang_... 2006-03-01 16:32:35 +00:00
Rob Landley e8e7811fb4 Yet more sed tests. Passing these is a to-do item for 1.1.2 or 1.2, not a
1.1.1 issue.
2006-03-01 16:32:01 +00:00
"Vladimir N. Oleynik" 325da7b509 use bb_xstrndup vs strndup. Thanks rfelker. 2006-03-01 05:39:41 +00:00
"Vladimir N. Oleynik" 5c2b238b3a more busybox's style: close bug 745 2006-02-28 10:15:42 +00:00
"Vladimir N. Oleynik" 716bbe96d4 make grep faster (close bug 758), reduce small memory leak in CONFIG_FEATURE_CLEANUP mode 2006-02-28 10:10:19 +00:00
"Vladimir N. Oleynik" 73804d6f7e more security: don't start shell code from argv 2006-02-28 08:23:27 +00:00
Rob Landley 8bbee85214 defconfig shouldn't enable CONFIG_INSTALL_NO_USR, and while we're at it
remove residue of old defconfig and tweak "make with no config" to run
defconfig before bringing up menuconfig.
2006-02-28 05:26:13 +00:00
Rob Landley 2fe4eac4ea Cosmetic cleanup from tito. 2006-02-28 04:45:24 +00:00
Rob Landley e813ddba18 Cleanup from Glenn McGrath. 2006-02-28 03:53:14 +00:00
Bernhard Reutner-Fischer 0817313255 - whitespace cleanup from Tito. 2006-02-27 22:34:41 +00:00
Rob Landley 4217bab02e Patch from Glenn McGrath to remove code that opens a file but does nothing
with it.
2006-02-26 04:42:05 +00:00
Mike Frysinger 5ba2fb2c9d remove duplicate license notice 2006-02-25 07:57:32 +00:00
Mike Frysinger 983e0ca89e strip out unneeded comments 2006-02-25 07:42:02 +00:00
"Vladimir N. Oleynik" 5c06b277ce fdisk unmaintained now :( 2006-02-25 07:20:15 +00:00
Rob Landley 5527b9117e Another clean-up patch from Garrett. 2006-02-25 03:46:10 +00:00
Rob Landley 736e52532e Minor cleanup from Garrett Kajmowicz. 2006-02-25 03:36:00 +00:00
Rob Landley b73451daee Cleanup from Denis Vlasenko. 2006-02-24 16:29:00 +00:00
Rob Landley 75cc0cace3 I was playing around with a dependency generator a couple weeks ago and I found
some #include files that aren't in the tree.  No biggie...
2006-02-24 03:15:34 +00:00
Rob Landley 883e0e83f2 Missed one in the get_line_from_file() update... 2006-02-24 03:12:03 +00:00
Rob Landley 3cb94d2eb3 Move FAQ under docs, add programming.html to docs list. 2006-02-24 02:55:24 +00:00
Rob Landley f6ddadc172 Mention patches directory as a read-only svn alternative. 2006-02-24 02:48:49 +00:00
Rob Landley 2b26fd5570 A few changes falling out from the effort to make sed handle embedded NUL bytes.
Checking in to reduce the diff between my tree and svn...
2006-02-24 02:30:39 +00:00
Rob Landley 5c22c11de2 Add a test suite for seq. 2006-02-24 01:45:58 +00:00
Mike Frysinger 0612b5fa68 add exception for uncuddling brackets 2006-02-24 01:18:24 +00:00
Rob Landley 6b6edf959d Lots of tests the fix to sed needs to pass... 2006-02-23 23:13:16 +00:00
Rob Landley b21837714a Documentation update: more detail on vfork. 2006-02-23 19:59:34 +00:00
Rob Landley 73a20f3551 "sed 2 -2 10" was very unhappy. Made the thing bigger fixing it,
fiddled a bit to get the size back down as much as I could...
2006-02-23 19:54:48 +00:00
Bernhard Reutner-Fischer ed7bb6278d - put NLS stuff in one central place to avoid redefines.
Fixes warnings about:
fdisk.c:45:1: warning: "_" redefined
nfsmount.c:121:1: warning: "_" redefined
nfsmount.c:122:1: warning: "N_" redefined
interface.c:84:1: warning: "_" redefined
2006-02-23 14:25:15 +00:00
Rob Landley 51be57e4df Convert all the applets from #include to USE(). Had to fix some nonstandard
naming along the way to get USE() macros for everything.
2006-02-23 00:42:25 +00:00
Mike Frysinger 0923063ebb add myself and Bernhard 2006-02-23 00:21:22 +00:00
Mike Frysinger 23ca7253be test to make sure applets are in alphabetical order 2006-02-22 23:38:57 +00:00
Mike Frysinger 73b4710974 fix applet order 2006-02-22 23:33:39 +00:00
Mike Frysinger 992a58c216 document leading + option 2006-02-22 22:56:30 +00:00
Rob Landley c6d09a6276 You don't need an #ifdef around #defines in usage. 2006-02-22 20:33:15 +00:00
Rob Landley 0a7c8ef6e2 Patch from Denis Vlasenko to constify things and fix a few typos. 2006-02-22 17:01:00 +00:00
Rob Landley fb16d5c6aa Tweak my entry. 2006-02-22 15:40:38 +00:00
Rob Landley e8f504e86d Bug 751: file handle leaks can add up until available filehandles for the
process are exhausted.
2006-02-22 02:10:34 +00:00
Rob Landley d6e14d8bee Don't build directory libraries unless we're building an applet that needs it.
Cherry-picked from Devin Bayer's big MacOS X patch.
2006-02-21 19:11:35 +00:00
Rob Landley 6f2a0b2275 Small tweak cherry-picked from Devin Bayer's monster MacOS X patch. 2006-02-21 18:34:54 +00:00
Rob Landley 87b9573ff8 Forgot to check this in last night, part of the hash_fd breakup. 2006-02-21 15:04:07 +00:00
Rob Landley 5cf7c2df66 Patch from Devin Bayer to split up hash_fd.c into md5.c and sha1.c. (I tweaked
md5_sha1_sum.c to convert some #ifdef CONFIG to if(ENABLE).)
2006-02-21 06:44:43 +00:00
Rob Landley a7e3d05208 Create /dev/root symlink pointing to real root device, if any. 2006-02-21 06:11:13 +00:00
Rob Landley c5789a6e23 Walter Harms added -D to date, and I did a code cleanup while I was in the
area.  Probably broke something...
2006-02-21 05:06:42 +00:00
Mike Frysinger bf28ed8834 eat extraneous newlines at the end of applet full usage 2006-02-21 04:32:03 +00:00
Mike Frysinger 0a6b0bfa7a add setarch/linux32/linux64 applet 2006-02-21 04:26:52 +00:00
Rob Landley ea6360e393 Missed a file in the last checkin, won't build without this... 2006-02-21 03:12:15 +00:00
Mike Frysinger 57f4cb2867 a few more comment touchups 2006-02-21 00:50:37 +00:00
Mike Frysinger e17c80e604 translate Russian-English to just plain English 2006-02-21 00:37:42 +00:00
Rob Landley a2841e6d4b Patch from Giuseppe Ciotta to specify retry count. 2006-02-20 23:26:38 +00:00
Rob Landley 0d8766a3b1 Rename UNUSE() to SKIP(). 2006-02-20 23:05:06 +00:00
Rob Landley 06249fee39 Bug 640: a filename of length exactly 100 could bleed into the next field on
display or extract.  (Only shows up when no gnu longname extension, either
because it's disabled or because tarball hasn't got it.)
2006-02-20 19:28:53 +00:00
Mike Frysinger dcbad607fc add s390x to the list 2006-02-20 19:28:34 +00:00
"Vladimir N. Oleynik" 7673ccad60 sync with mainstream, but check more 2006-02-20 16:57:36 +00:00
Rob Landley 081d6d4380 getdomainname() isn't guaranteed to null terminate the string if it was
truncated for length.  SVN 14135 made sure that the truncated version would
always be null terminated.  SVN 14144 broke this for no readily apparent
reason, and I have no idea what it was even trying to accomplish.  Reverted.
2006-02-20 16:31:44 +00:00
Rob Landley b4ec339ac2 Update comment. 2006-02-20 14:39:55 +00:00
"Vladimir N. Oleynik" 0c6ff43a0c remove #undef strlen, use #define strlen always but without xfunc/BB_STRLEN_IMPLEMENTATION 2006-02-20 12:15:10 +00:00
"Vladimir N. Oleynik" d24d083061 correction get(host/domain)name usage, revert 742 bug 2006-02-20 10:44:02 +00:00
Rob Landley 4e9deec8bf svn 14077 was completely broken and apparently never tested. 2006-02-20 02:44:30 +00:00
Rob Landley eb00afb2d5 The gentoo security guys found another way to segfault busybox's decompression
code: we can do a null dereference if one of our huffman tables has all zero
length codes.  This fixes it.  (Thanks solar.)
2006-02-20 02:18:03 +00:00
Mike Frysinger dce17c6268 rfelker writes in Bug 742: make sure string is null terminated after calling gethostname 2006-02-19 23:03:31 +00:00
Mike Frysinger 294254ce6b rfelker writes in Bug 740: s/u_char/unsigned char/ 2006-02-19 22:59:12 +00:00
Mike Frysinger da2a7d6b20 rfelker writes in Bug 738: sys/sysmacros.h is needed for makedev 2006-02-19 22:47:51 +00:00
Mike Frysinger dfd902b7ff rfelker writes in Bug 736: stty.c includes unneeded, obsolete header memory.h 2006-02-19 22:43:58 +00:00
Mike Frysinger 4b33f7aa41 rfelker writes in Bug 734: Nothing from err.h is used, but cal.c includes it, breaking compile on systems lacking this function. 2006-02-19 22:41:41 +00:00
Mike Frysinger 611e085c20 kill all .depend files 2006-02-18 20:13:22 +00:00
Mike Frysinger a568ef2343 hide bb_mkdep build 2006-02-18 20:12:39 +00:00
Mike Frysinger ebee0e7705 fix building on ppc64 2006-02-18 06:14:31 +00:00
"Vladimir N. Oleynik" 06776b3650 type typo. Thanks, Devin Bayer 2006-02-17 09:33:22 +00:00
"Vladimir N. Oleynik" b267f13c61 quick copy-paste typo 2006-02-17 09:05:41 +00:00
Rob Landley efae294b15 Fix for an integer overflow bug that could cause a segfault on certain
pathological archives.

(Unlikely to have security implications, the only way to trigger it basically
wound up doing memset(dbuf,x,2^31) and triggering an immediate segfault.  The
test basically gives us a more polite error message.)

Thanks to Ned Ludd and the Gentoo security guys for finding this.
2006-02-17 05:19:40 +00:00
Rob Landley 2c98c40ec8 The tendency of vi to auto-indent can be really annoying at times. 2006-02-17 05:12:03 +00:00
Rob Landley f856eabcde More whitespace than you can possibly imagine... 2006-02-17 03:43:49 +00:00
Rob Landley 27cd85b5be Update Rogues Gallery. 2006-02-17 02:38:00 +00:00
"Vladimir N. Oleynik" eaa3b29a6d forgoten new file for 14080 revison 2006-02-16 15:41:12 +00:00
"Vladimir N. Oleynik" dd1ccddf1b moved BB_BANNER to applets/version.c file: make kernel like version,
removed depend loop: busybox.h depend with BB_BT, and all sources depend with busybox.h
2006-02-16 15:40:24 +00:00
"Vladimir N. Oleynik" 21e68703ce removed #undef strlen, use builtins and prototuped strlen from xfunc file (only\!) 2006-02-16 14:38:41 +00:00
"Vladimir N. Oleynik" cb9b114d35 isolate and show busybox`s changes 2006-02-16 14:28:17 +00:00
Rob Landley 5c1cd5fdd3 Putting together OPTIONFLAGS, sed needs the global flag to handle multiple
options.
2006-02-16 09:25:31 +00:00
Rob Landley 006fa2d45b When setting an environment variable by piping something into grep, backquotes
can be useful.  Also tweak an if case to be more portable.
2006-02-16 09:00:57 +00:00
Rob Landley d1e38c07e6 Rogues gallery. 2006-02-16 03:21:44 +00:00
"Vladimir N. Oleynik" c218a29325 add last terminal line 2006-02-15 17:15:56 +00:00
"Vladimir N. Oleynik" 9a51540b15 demo (UN)USE_FEATURE... usage 2006-02-15 13:27:18 +00:00
"Vladimir N. Oleynik" 6732af2766 full removed config.h, use bb_config.h only 2006-02-15 12:29:37 +00:00
Rob Landley 02794e1516 Fix bug 674: sum's block count should always round up. 2006-02-14 17:47:05 +00:00
Rob Landley 46e351d478 Patch from awk maintainer (Dmitry Zakhrov) to fix bugs 642, 663, and 667. 2006-02-14 16:05:32 +00:00
Bernhard Reutner-Fischer 5ba53c05fc - commentary typos 2006-02-14 10:43:40 +00:00
"Vladimir N. Oleynik" 3afdfecf7e restore change by Denis Vlasenko: file_to_buf must vary fast, best if inline 2006-02-14 10:36:38 +00:00
"Vladimir N. Oleynik" 465300ced9 cleanups after changes by Denis Vlasenko. Size optimization 2006-02-14 10:17:09 +00:00
"Vladimir N. Oleynik" 63ca3bfe9d commentary typos. Thank by aldot 2006-02-14 09:23:25 +00:00
Rob Landley a253e7361f Rob Landley is busybox maintainer now. Eeek. 2006-02-14 08:29:48 +00:00
Rob Landley d05981eaf1 Fix off by one error. (I know I had a reason for doing that, but I have _no_
idea what it was...)
2006-02-14 07:33:45 +00:00
Rob Landley b2804551a0 Cleanups from Denis Vlasenko. 2006-02-13 22:04:27 +00:00
Rob Landley 90632d021c Bug fix from Kim B. Heino, manifested via:
echo > foo && zip foo.zip foo && ./busybox unzip foo.zip
2006-02-13 19:40:43 +00:00
Rob Landley 7bfa88f315 New USE() macros
For each CONFIG_SYMBOL, include/bb_config.h now has both ENABLE_SYMBOL
and USE_SYMBOL(x).  ENABLE_SYMBOL is still always defined (1 or 0) so that
if(ENABLE) should optimize out when it's zero.  The USE_SYMBOL(X) will only
splice in X if the symbol is defined, otherwise it'll be empty.

Thus we can convert this:

#ifdef CONFIG_ARGS
    opt = bb_getopt_ulflags(argc, argv, "ab:c"
#ifdef CONFIG_THINGY
        "d:"
#endif
        , &bvalue
#ifdef CONFIG_THINGY
        , &thingy
#endif
    );
#endif

into this:
    if (ENABLE_ARGS) {
        opt = bb_getopt_ulflags(argc, argv, "ab:c" USE_THINGY("d:"), &bvalue
                USE_THINGY(, &thingy));
    }

And it should produce the same code.

Unlike the old versions in include/_usage.h, the new USE_SYMBOL(x) can handle
commas in its arguments (as shown above).  (The _usage.h file is obsolete and
no longer generated.)

Nobody should need to include config.h directly anymore, bb_config.h should
define all the configuration stuff we need.  Someday, the CONFIG_SYMBOL
versions should go away in favor of ENABLE_SYMBOL and USE_SYMBOL().

Thanks to vodz for the new version of bb_mkdep.c that works with function
macros.
2006-02-13 19:16:41 +00:00
Bernhard Reutner-Fischer f251ec6847 - commentary typos 2006-02-12 11:25:32 +00:00
Rob Landley c29a0f371a More random documentation. 2006-02-12 00:45:39 +00:00
Rob Landley 4926d643ea Missed this in svn 13701. 2006-02-10 21:38:20 +00:00
Rob Landley 4a1d874e1d Another item. 2006-02-10 21:36:53 +00:00
Rob Landley cc6d8d30ec Fix umount so it works if there's no /etc/mtab or /proc/mounts, make
umount -a into a CONFIG_FEATURE (why not?), and zap the now obsolete
defconfig file (which was supposed to be part of the previous checkin).
2006-02-08 20:06:57 +00:00
Rob Landley 1ab4c3dc25 Help text update and tweak to defconfig to remove two more things that
the "maximum sane configuration" shouldn't have.  (Explicit MTAB support in
mount, which you should only need if you have no /proc, and FEATURE_CLEAN_UP,
which exists to humor valgrind and otherwise just bloats the code).
2006-02-08 18:50:17 +00:00
Rob Landley 32251b4825 Convert some help text to english. 2006-02-08 18:34:21 +00:00
Mike Frysinger 271aa40a15 add back in path nulling after calling find_dev() since it is needed for now ... 2006-02-07 06:10:45 +00:00
Mike Frysinger 27a74e8017 Cristian Ionescu-Idbohrn writes:
force enough space padding so that applet names always end up on their own line
2006-02-07 00:58:11 +00:00
Mike Frysinger 0380166916 space out supported applet names so the config list doesnt wrap on an 80col terminal 2006-02-07 00:51:07 +00:00
Mike Frysinger 4fcefb9e90 fixup whitespace in awk help output 2006-02-06 23:38:59 +00:00
Rob Landley 30a6bba65f Bug 677: there are apparently still people using telnet. 2006-02-06 02:49:45 +00:00
Mike Frysinger ba9c4d1f89 get rid of warnings with applets that have no usage and get rid of pointless --- separator between applets 2006-02-06 01:11:34 +00:00
Mike Frysinger f37529d6b6 if the .pl script gets updated, force doc regen 2006-02-05 22:15:39 +00:00
Mike Frysinger b0ed3d7cc0 Rob Sullivan writes: Here's a patch to autogenerate the list of applets in the Busybox documentation 2006-02-05 22:10:40 +00:00
Rob Landley bec26527a1 Save a few bytes in error message. 2006-02-05 03:31:44 +00:00
Mike Frysinger a421ba8203 cleanup style ... just because you use less spaces doesnt mean the resulting code is smaller 2006-02-03 00:25:37 +00:00
Mike Frysinger 248d2220f9 shrink the code a bit 2006-02-03 00:19:42 +00:00
Mike Frysinger 53d57dbe6b gavinl writes in Bug 661:
if read() file return less than 1, we should close the fd and then goto end.
2006-02-03 00:16:53 +00:00
Mike Frysinger 5509228a7b alphabetical order and fix mdev comments about echo>/sys vs echo>/proc/sys 2006-02-02 23:14:57 +00:00
Mike Frysinger 35cf19d741 fix mdev help output 2006-02-02 22:52:59 +00:00
"Vladimir N. Oleynik" 4fc92206ed destroy bug 679, use getopt_ulflags with new feature: usage option. Removed two strdup 2006-02-02 14:48:54 +00:00
Mike Frysinger b38673fb9f make the build system puuuuuuuuuuurty 2006-02-02 01:41:53 +00:00
"Vladimir N. Oleynik" 1f04c9d29c removed anoinig `unused' warnings 2006-02-01 14:47:52 +00:00
"Vladimir N. Oleynik" 73ffd762ca removed anoinig warnings 2006-02-01 12:56:19 +00:00
"Vladimir N. Oleynik" b399a96343 remode warning: const static mix 2006-02-01 12:41:35 +00:00
Bernhard Reutner-Fischer 3038557649 - bzero -> memset
text    data     bss     dec     hex filename
1652855   14444 1215616 2882915  2bfd63 busybox.oorig.gcc-3.3
1652823   14444 1215616 2882883  2bfd43 busybox.gcc-3.3
1603655   14412 1215552 2833619  2b3cd3 busybox.oorig.gcc-3.4
1603655   14412 1215552 2833619  2b3cd3 busybox.gcc-3.4
1609755   14508 1215744 2840007  2b55c7 busybox.oorig.gcc-4.0
1609755   14508 1215744 2840007  2b55c7 busybox.gcc-4.0
1590495   13516 1215392 2819403  2b054b busybox.oorig.gcc-4.1-HEAD
1590495   13516 1215392 2819403  2b054b busybox.gcc-4.1-HEAD
1589079   13036 1213248 2815363  2af583 busybox.oorig.gcc-4.2-HEAD
1589079   13036 1213248 2815363  2af583 busybox.gcc-4.2-HEAD
2006-01-31 17:57:48 +00:00
"Vladimir N. Oleynik" 87be316149 more better for me signed<->unsigned and the const keyword usage 2006-01-31 14:25:52 +00:00
"Vladimir N. Oleynik" 4333a09d65 add feature: support for running scripts through an interpreter. Thanks Florian Schirmer <jolt@tuxbox.org> 2006-01-31 13:53:30 +00:00
"Vladimir N. Oleynik" 1f17d3287a more obscure 2006-01-31 12:36:51 +00:00
"Vladimir N. Oleynik" 7600eec732 avoid signed<->unsigned warning 2006-01-31 12:12:15 +00:00
"Vladimir N. Oleynik" 57545c810a avoid signed<->unsigned warning 2006-01-31 12:06:57 +00:00
"Vladimir N. Oleynik" 4d57926bd3 removed unneed signed, avoid warning 2006-01-31 11:57:06 +00:00
Bernhard Reutner-Fischer 81b94960a2 - pass -static via CC rather than LD 2006-01-31 11:29:22 +00:00
"Vladimir N. Oleynik" 39e7510664 more destroy potential overflow for x86_64. 2006-01-31 11:19:12 +00:00
"Vladimir N. Oleynik" 77bb33c474 destroy potential overflow for x86_64. Added ATTRIBUTE_UNUSED 2006-01-31 11:16:40 +00:00
Bernhard Reutner-Fischer 9f4a1e1c75 - add and use ATTRIBUTE_ALIGNED(num_bytes)
- remove unused parameter pindex from fdisk.c, xbsd_initlabel()
2006-01-31 09:53:53 +00:00
"Vladimir N. Oleynik" dfe6e74157 changed strange mix signed<->unsigned 2006-01-31 09:44:04 +00:00
"Vladimir N. Oleynik" dd14ca082a protect potential overflow for x86_64 2006-01-31 09:35:45 +00:00
"Vladimir N. Oleynik" 4ccd2b4697 quick analize signed->unsigned: protect overflow of map[char], getchar->EOF. Use ATTRIBUTE_UNUSE. 2006-01-31 09:27:48 +00:00
Bernhard Reutner-Fischer cd98555dfa - fix typo i introduced yesterday. 2006-01-31 08:17:13 +00:00
Rob Landley 9e275e3450 Not on libbusybox.so: it's GPL, no API barrier, no stability promise. 2006-01-31 03:45:26 +00:00
Rob Landley a167ec5e63 Turn defconfig into what make allyesconfig is today. Turn allyesconfig
back into allyesconfig.  (Memo: apparently SELINUX doesn't compile anymore.)

Make defconfig shouldn't switch on libbusybox.so, but allyesconfig does.
2006-01-31 02:42:50 +00:00
Eric Andersen 3496fdc9a5 hopefully the last of the annoying signed/unsigned and mixed type errors 2006-01-30 23:09:20 +00:00
Eric Andersen a68ea1cb93 fix up yet more annoying signed/unsigned and mixed type errors 2006-01-30 22:48:39 +00:00
Eric Andersen 9a58b02ec7 make certain we dereference the pointer as a time_t, esp on x86_64
where it might otherwise not be dereferenced as such by default
2006-01-30 22:33:31 +00:00
Eric Andersen 0cb6f35c33 fix up annoying signed/unsigned and mixed type errors 2006-01-30 22:30:41 +00:00
Eric Andersen 5e678873f9 clean up yet more annoying signed/unsigned mismatches and fixup
yet more incorrect types
2006-01-30 19:48:23 +00:00
Eric Andersen 2cdd4d56ff passing around an int as a void* is a very bad idea 2006-01-30 18:33:12 +00:00
Eric Andersen d78aea8b8e sort out yet more type issues 2006-01-30 18:00:02 +00:00
Bernhard Reutner-Fischer 4bf31272ff - very minor tweak: save 1 byte.
statistics:
   text    data     bss     dec     hex filename
    867       0      12     879     36f fold.o.oorig.gcc-3.3
    843       0      12     855     357 fold.o.oorig.gcc-3.4
    780       0      12     792     318 fold.o.oorig.gcc-4.0
    761       0      12     773     305 fold.o.oorig.gcc-4.1-HEAD
    761       0      12     773     305 fold.o.oorig.gcc-4.2-HEAD
    866       0      12     878     36e fold.o.gcc-3.3
    842       0      12     854     356 fold.o.gcc-3.4
    779       0      12     791     317 fold.o.gcc-4.0
    760       0      12     772     304 fold.o.gcc-4.1-HEAD
    760       0      12     772     304 fold.o.gcc-4.2-HEAD
2006-01-30 17:41:06 +00:00
Eric Andersen 76b24270d4 with 2.4 kernel headers, lo_file_name is char, but with 2.6
headers we get a u8 for lo_file_name, so always cast to (char *)
when treating it as such.
2006-01-30 17:30:22 +00:00
Eric Andersen f55289f4b9 fixup a few types to prevent gcc (rightfully) whining about mixing
signed and unsigned, unmatches pointer target types, etc
2006-01-30 17:27:00 +00:00
Bernhard Reutner-Fischer 20f4000086 - add some ATTRIBUTE_UNUSED.
- use shorter boilerplate while at it.
2006-01-30 17:17:14 +00:00
Bernhard Reutner-Fischer 0e8727d93b - make linking against libcrypt optional by looking if pw_encrypt() or
correct_password() is configured. Fixes allnoconfig pulling in -lcrypt.
2006-01-30 15:29:55 +00:00
"Vladimir N. Oleynik" 2d604581ef removed warning "comparison between signed and unsigned". 2006-01-30 14:02:06 +00:00
"Vladimir N. Oleynik" 51bfa54e46 removed warning "comparison between signed and unsigned". Added ATTRIBUTE_UNUSED. My whitespace 2006-01-30 13:58:34 +00:00
"Vladimir N. Oleynik" 59c4e5cf92 removed warning "comparison between signed and unsigned". Added ATTRIBUTE_UNUSED. My whitespace 2006-01-30 13:51:50 +00:00
"Vladimir N. Oleynik" 676b15e067 removed warning "comparison between signed and unsigned". 2006-01-30 13:47:19 +00:00
"Vladimir N. Oleynik" cd473dd0c1 removed warning "comparison between signed and unsigned". Added ATTRIBUTE_UNUSED. Whitespace 2006-01-30 13:41:53 +00:00
"Vladimir N. Oleynik" cd5c15d287 removed warning "comparison between signed and unsigned". Change very very old code: use int instead short 2006-01-30 13:36:03 +00:00
"Vladimir N. Oleynik" 9b9a920eef removed warning "comparison between signed and unsigned". Reduced size 2006-01-30 12:23:46 +00:00
"Vladimir N. Oleynik" e75b41d990 support GNU suffixes for fancy mode: b(512), k(1024) and m(1024*1024) 2006-01-30 11:15:11 +00:00
"Vladimir N. Oleynik" b1fd52e0b7 remove outdated and do not corected comment. Use bb_xasprintf instead xmalloc+set+set+strcpy. 2006-01-30 10:49:14 +00:00
Rob Landley 646129163a Re-add initrd support, unify halt/reboot/poweroff, add -n and -f options. 2006-01-30 08:31:37 +00:00
Rob Landley 49576c0018 Note on SVN 13424: Don't mix "default y" and select of something earlier
in the menu hierarchy or else make allnoconfig winds up leaving whatever the
select  points to as "y".  (In this case, "make allnoconfig" is leaving 
CONFIG_TEST as "y".)
2006-01-30 06:11:42 +00:00
Rob Landley f8fd4db92f Move SUSv2 obsolete feature disabling to debug menu, invert meaning of
symbol (switched on to remove now: test your apps to make sure they _don't_
do this, because as some point we should just yank it), fixup head/tail/fold.

Also tweak "make allyesconfig" so anything starting with CONFIG_DEBUG gets
left switched off.  Possibly other things we want to put in the debug menu?
2006-01-30 01:30:39 +00:00
Rob Landley dd53c24d41 Remove foo.txt and reenable -funsigned-char now that ash is fixed. 2006-01-30 01:27:08 +00:00
Rob Landley 03628c8f75 Remind me to implement bb_fork_exec()... 2006-01-29 06:45:38 +00:00
Rob Landley b1b3cee831 Add explanations of encrypted passwords, and fork vs vfork. 2006-01-29 06:29:01 +00:00
Bernhard Reutner-Fischer 08a1b5095d - add a macro to check for ld and as flags
Very unreliable as e.g the ld check will see the flags supported by each emulation, not just the active one.
  good enough for now..
  Fix would be to crate one or more dummy .c files and accually try if a flag
  works.
2006-01-27 15:45:56 +00:00
"Vladimir N. Oleynik" 79af7d5deb for change previous log: close bug 186 2006-01-26 10:58:12 +00:00
"Vladimir N. Oleynik" 2e33daaed5 close bug 190 2006-01-26 10:46:14 +00:00
Mike Frysinger 546a99db1d use LC_ALL, not LANG, for forcing C 2006-01-25 22:46:25 +00:00
"Vladimir N. Oleynik" 84005af7ef C99 say: "char" declaration may be signed or unsigned default 2006-01-25 17:53:04 +00:00
"Vladimir N. Oleynik" 5775aa2ef6 added support /prefix for IPV4 form IPV6 code. Close bug 461 2006-01-25 16:17:58 +00:00
Bernhard Reutner-Fischer 08c5a1789b - Simplify the prereq and add more documentation.
- Fix regex for allyesconfig.
2006-01-25 15:58:04 +00:00
"Vladimir N. Oleynik" 2e5ee8ed93 +#include <sys/socket.h>
remove unused 'int i' form main
whitespacing only
2006-01-25 14:40:24 +00:00
"Vladimir N. Oleynik" 7b4aa6ffc6 new applet. Thanks Roberto A. Foglietta 2006-01-25 14:19:11 +00:00
"Vladimir N. Oleynik" 8aa9e57149 support 64 arith. Close bug 136 2006-01-25 13:56:03 +00:00
"Vladimir N. Oleynik" 1e98a0705b close bug 638 2006-01-25 13:21:08 +00:00
"Vladimir N. Oleynik" fdb871c498 Add more bash-like dot-dirs cmdedit feature
Close bug 648.
Restore my whitespace
2006-01-25 11:53:47 +00:00
Tim Riker 7d501a8673 ignore whitespace 2006-01-25 00:25:37 +00:00
Tim Riker 7dd4cbf2bf LANG=C should help 2006-01-25 00:17:47 +00:00
Tim Riker c1ef7bdd8d just whitespace 2006-01-25 00:08:53 +00:00
Bernhard Reutner-Fischer f64ff682a3 - correct flag for gcc-3.x 2006-01-24 18:25:51 +00:00
Bernhard Reutner-Fischer 9ed6ac2bea - Turn off combine for allyesconfig and allbareconfig.
The user ought to explicitely request this.
2006-01-24 18:15:20 +00:00
Bernhard Reutner-Fischer 2aba3953d4 - readd config option for libbusybox and ima-mode which were accidentally
dropped by landley in rev13542.
2006-01-24 16:14:14 +00:00
"Vladimir N. Oleynik" ab90b9f427 close bug 657 2006-01-24 12:02:27 +00:00
Rob Landley 8b6063490d Once more, with fewer inappropriate semicolons. 2006-01-24 02:38:28 +00:00
Rob Landley 391a904f46 Ken McGuire's patch to make mke2fs and e2fsck work on big endian systems like
PPC, with an obligatory couple of swipes from me.
2006-01-23 21:38:06 +00:00
Rob Landley 6130b9b160 Testing CONFIG_SORT_BIG to display the help for the big version of sort isn't
much use when the symbol is CONFIG_FEATURE_SORT_BIG.
2006-01-23 21:10:38 +00:00
"Vladimir N. Oleynik" e0ae702b0e ash with -funsigned-char don`t work! 2006-01-23 13:47:36 +00:00
"Vladimir N. Oleynik" b757699164 Oops, restore tabs 2006-01-23 11:39:05 +00:00
"Vladimir N. Oleynik" 9394b232ef cleanup (dist)clean logic 2006-01-23 11:24:58 +00:00
Rob Landley b70ccd9509 Close bug 644: loop incrementing twice, skipping ever other device. 2006-01-22 23:17:18 +00:00
Rob Landley e927743bb0 There was a missing ! on strcmp (despite the fact it worked in my testing,
I have no idea _how_), and a simpler fix for the extra \n problem.  I tested
this and it worked for me, for what that's worth...
2006-01-22 23:14:16 +00:00
Bernhard Reutner-Fischer 86f5c9906b - add platform.h.
- use shorter boilerplate while at it.
2006-01-22 22:55:11 +00:00
Rob Landley 2edf52643d The whole "init is sometimes pid 3" thing is silly. Init is pid 1, anything
else is a kernel bug.  Both 2.4 and 2.6 should get this right now.  This
should fix the bug IraquiGeek is seeing (although killall still needs to
be fixed.)
2006-01-22 02:41:51 +00:00
Rob Landley aaffef4d33 Start of developer documentation for busybox. 2006-01-22 01:44:29 +00:00
Paul Fox f9d40d6815 compile on 2.96 for a while longer -- no floating declarations. 2006-01-20 21:48:06 +00:00
Rob Landley c1d69906a0 Patch from Aurelien Jacobs to add unlzma. (A new decompression type,
see www.7-zip.org)
2006-01-20 18:28:50 +00:00
Rob Landley 7a43bd07e6 Zap sysdeps directory, moving Config.in and defconfig to top of tree.
(Busybox should not be system dependent enough to have different default
configurations for different platforms.  We're not a kernel.)
2006-01-20 17:47:09 +00:00
Rob Landley c8e41157a2 Update readme and install.sh usage message. 2006-01-19 21:22:37 +00:00
Bernhard Reutner-Fischer 5a620ea220 - Document -m, -c, -s and provide a default shell for standalone build.
- Wrap overlong lines plus a few whitespace fixes.
- add GPL header.
2006-01-19 18:04:15 +00:00
Bernhard Reutner-Fischer a901b40464 - missing bits of patch attached to bug #249 (constify). 2006-01-19 14:51:17 +00:00
Bernhard Reutner-Fischer f771d88443 - need to have config MODULE in order to make tristate work..
Thanks to Robert Schwebel for pointing this out. I must be blind..
2006-01-19 14:45:16 +00:00
Bernhard Reutner-Fischer 96002bba67 - cleanup Config.in. Use "select CONFIG_FOO" and add the corresponding
"depends on CONFIG_BAR" instead of the if !CONFIG_FOO ...default y stanza.
2006-01-19 14:42:23 +00:00
"Vladimir N. Oleynik" cfc8f59649 restore 8-bit syntax works, last debian patch is broken. Noticed by Vladimir Dronnikov 2006-01-19 11:23:34 +00:00
Bernhard Reutner-Fischer b565a12cf8 - bump version to 1.1.1 nonrelease series (let's say -pre0). 2006-01-19 09:22:39 +00:00
Bernhard Reutner-Fischer d9679e3af1 - remove debian/ 2006-01-17 15:56:59 +00:00
Bernhard Reutner-Fischer 37dec0e9e9 - make CONFIG_MD5SUM_SIZE_VS_SPEED configurable via menuconfig.
- use shorter boilerplate.
2006-01-17 12:07:03 +00:00
"Vladimir N. Oleynik" 0f9ae1a0d7 setgid and setuid have changes effective id too 2006-01-15 14:55:48 +00:00
"Vladimir N. Oleynik" fb29b46201 sync with dash_0.5.3-1 2006-01-15 14:21:01 +00:00
Bernhard Reutner-Fischer 7ca61b6f33 - shared libbusybox.
- IMA compilation option (aka IPO, IPA,..)
Please holler if i broke something..
2006-01-15 14:04:57 +00:00
"Vladimir N. Oleynik" 8c9daa12dc restore erronyous 'cleanups' by Rob Sullivan and landley 2006-01-15 09:29:41 +00:00
Rob Landley 855f1e1320 Cleanup patch from Rob Sullivan. 2006-01-15 02:20:06 +00:00
Rob Landley 734a779a42 1.1.0 is out. 2006-01-14 07:43:22 +00:00
Paul Fox 72d1a2357d add find's "-mmin" option. configurable. 2006-01-13 21:05:41 +00:00
Bernhard Reutner-Fischer 4a1865ca5e - revert last change for now.. 2006-01-13 18:11:59 +00:00
Bernhard Reutner-Fischer 5a62284972 this applet needlessly big! TODO: bb_getopt_ulflags()
- use atol for the offset, which is always in bytes. Small step in eventually dropping bb_xparse_number().
2006-01-13 17:29:46 +00:00
Bernhard Reutner-Fischer 26ea0b7f16 - turn off "nc gaping hole" and devfsd in allbareconfig, the latter doesn't
use the FEATURE notation and noone will update it to use it.
2006-01-13 16:25:03 +00:00
Bernhard Reutner-Fischer 853c44b798 - correct definitions. 2006-01-13 12:03:26 +00:00
Bernhard Reutner-Fischer 2677cf1b0a - Mention code-cleanup possibilities in TODO. 2006-01-13 08:46:39 +00:00
Bernhard Reutner-Fischer dd9dce104d - shrink simple obscure stuff a tiny bit:
text    data     bss     dec     hex filename
    789       0       0     789     315 obscure.o.oorig
    771       0       0     771     303 obscure.o
- replace bzero by memset while at it.
2006-01-12 15:38:12 +00:00
Bernhard Reutner-Fischer eedd1be730 - remove warning about redeclaration of __constant_htons
- remove warning about format '%ld' expects type 'long int *', but argument #num
  has type 'long unsigned int *'
2006-01-12 13:15:49 +00:00
Bernhard Reutner-Fischer d1d23a6e67 - mark argument who of print_route as unused. 2006-01-12 12:08:46 +00:00
Rob Landley 29e08ffcdf Frank Sorenson added hotplug support to mdev. (I tweaked it a bit. Need
to come up with a test suite for all the stuff that requires root access.
Something involving User Mode Linux or QEMU, probably...)
2006-01-12 06:13:50 +00:00
Rob Landley 1c19deed17 The major:minor read from dev ends with \n, need to trim that. 2006-01-12 03:07:49 +00:00
Rob Landley bbf4e167f2 Ok, ping needs a rewrite from the ground up. (This is not a busybox app.)
Fix bug 309, where ping -s 1 localhost would give an elapsed time 9 digits
long due to a stack overflow.  Apparently, iputils also does this.
2006-01-11 03:44:11 +00:00
Rob Landley 009765d2ca And lo, we hath reached Release Candidate 1. 1.1.0 should happen this week. 2006-01-10 19:48:53 +00:00
"Vladimir N. Oleynik" 24f819fd74 can use TMPDIR if user's HOMEDIR do not found. Noticed by Bernhard 2006-01-10 12:35:43 +00:00
Rob Landley bc059bc7fa The brain-dead FTP servers on Solaris don't support the size command. 2006-01-10 06:36:00 +00:00
Rob Landley 9e4100bf95 Don't return 0 when there's an error. 2006-01-10 06:19:56 +00:00
Rob Landley 71d6ccd801 With -a, the jump to mount_it_now can skip the initialization of f, and
if we don't zero it after closing it we re-close a filehandle that isn't
open, and since this is a file _pointer_ it segfaults on a double free.

Yeah, subtle bug.  I need to break this out into separate functions if I can
figure out how to avoid making the code larger while doing so.  Part of
the general -a and -o remount work I need to do, but that's after 1.1.0...
2006-01-10 05:30:28 +00:00
Rob Landley 8b0efdb1a1 Both atime and diratime should switch _off_ the corresponding no* flag. 2006-01-10 02:37:20 +00:00
Mike Frysinger bd67e8074a upgrade ZyXEL from hall of shame to hall of [product] fame 2006-01-10 01:43:40 +00:00
"Vladimir N. Oleynik" f01e1784e5 removed a warning about an unused pargv in bb_getopt_ulflags. Noticed by Tito 2006-01-09 13:28:31 +00:00
Rob Landley 5184336647 Bug 112, return value of awk should be /256. In reality, we should probably
be using WEXITSTATUS(), but until I can figure out why the heck that would
want to do (*(int *) &(status)) on the value, I'm happy just fixing the bug we
actually see.
2006-01-09 05:26:58 +00:00
Rob Landley fb8c4983a6 Fix bug 603: "chown :root thingy" should work now. 2006-01-09 03:45:43 +00:00
Rob Landley e569553aa0 Bug 547: writing out the tar file header before we confirm we can actually
open and read from the file isn't something we can recover from after the
fact.  Resequence things to check first, write second.
2006-01-09 03:07:44 +00:00
Rob Landley 3d1bbf0a5f Minor cosmetic fix from Tito. 2006-01-09 01:07:24 +00:00
Rob Landley 8bcc6e964b Why we didn't take a watchdog.c suggestion this time 'round, in case anybody
comes up with a fix...
2006-01-09 00:54:46 +00:00
Mike Frysinger e87ae0bd4f declare const for fun 2006-01-08 11:15:53 +00:00
Mike Frysinger e885d5300a Tito writes:
Somehow while applying the bb_do_delay patch a change slipped
in libbb.h that broke compilation.

libbb.h Line 355 
  extern char bb_path_mtab_file[];

This conflicts with mtab_file.c
#if defined(CONFIG_FEATURE_MTAB_SUPPORT)
const char bb_path_mtab_file[] = "/etc/mtab";
#else
const char bb_path_mtab_file[] = "/proc/mounts";
#endif
2006-01-08 11:15:34 +00:00
Rob Landley 84cb76733f patch from tito: consolidate delay functions as bb_do_delay() 2006-01-06 20:59:09 +00:00
Rob Landley 251161f75c Bug 624 wants quoted char support for printf, so you can do something like:
printf '%d\n' '"x"'
and have it print out 120.  This is the smallest implementation I can think
of at the moment.
2006-01-06 20:28:05 +00:00
Rob Landley f8ec1b51f3 No, we _want_ the suid and sgid bits reverted by chown, for security reasons.
They mean something different when the user they're switching to is different,
so if you still want suid you reset it afterwards.  This is a safety feature.
2006-01-06 18:22:05 +00:00
Bernhard Reutner-Fischer c00411a16a - better wording 2006-01-04 13:35:09 +00:00
Mike Frysinger 5990efb795 use MAP_PRIVATE instead of MAP_SHARED for uClinux systems (see Bug 550) 2006-01-04 07:31:19 +00:00
Mike Frysinger b92405552f Jason Schoon writes:
Here is a patch for kill that I posted long ago, but forgot about
until today.  This allows kill to specify a negative process/group
(such as -1).  The shell already had this fix applied by Vodz some
time ago.
2006-01-04 00:13:22 +00:00
Mike Frysinger f982d86ba7 import nios2 support from microtronix 2006-01-04 00:11:26 +00:00
Mike Frysinger 29ed59ee11 make mount usage a bit more terse 2006-01-04 00:04:08 +00:00
Mike Frysinger 705fad2964 just use bb_xfopen() 2006-01-03 23:59:17 +00:00
Mike Frysinger bb12d6f728 fix comment documentation 2006-01-03 23:59:01 +00:00
Bernhard Reutner-Fischer 823f80f5ad - silence warning about unused param
needs revisit later on like many others to use ATTRIBUTE_UNUSED from platform.h
2005-12-29 21:17:05 +00:00
Bernhard Reutner-Fischer f00680eb59 - use HOSTCC instead of a hardcoded cc 2005-12-29 16:53:47 +00:00
"Vladimir N. Oleynik" 0bf67e849a remove buffer overflow by Erik and decodeString problem by Glenn, add error check of decodeString as Apache 2005-12-26 17:26:59 +00:00
Rob Landley ce88793698 When you went "losetup -d /dev/loop0 /dev/loop1" the error message was strange. 2005-12-21 17:00:25 +00:00
Rob Landley 9085467970 Trying to losetup a device as a regular user shouldn't result in an endless
loop, and the error messages should display correctly now.
2005-12-21 16:53:57 +00:00
Rob Landley beb665a376 Second attempt to simplify the login menu. Shadow password stuff at the top,
with no dependencies (since depending on 9 of the 13 apps in the menu gets
a bit silly).  And fix my attempt to make internal shadow password support
automatically depend on internal password support plus shadow password
support.
2005-12-21 16:33:41 +00:00
Bernhard Reutner-Fischer 17329745fc - fix check for group and user, remove some whitespace while at it. 2005-12-21 15:07:30 +00:00
Rob Landley 5d84c2398e Fix chroot, leave console alone if -c not specified, and yank debug code.
(I still haven't set up a test environment to confirm this works...)
2005-12-20 17:25:51 +00:00
Rob Landley 7b363fd3c9 Some minor cleanups/bugfixes split off from the big remount work:
Shorten GPL boilerplate.
  Enabling FEATURE_CLEAN_UP broke things in two places.
  Move the NFS with uClibc check to nfsmount.c
2005-12-20 17:18:01 +00:00
Rob Landley b9620414c1 Shadow password support went beyond the dependency event horizon, just make
it an independent menu.  And make internal shadow password support a subset
of the other internal password function support.
2005-12-20 15:25:25 +00:00
Rob Landley 6a24976ceb Actually, static buffers look like _this_... 2005-12-20 15:23:20 +00:00
"Vladimir N. Oleynik" 6b903a2d8a remove debug feature for production 2005-12-20 11:02:54 +00:00
Rob Landley 9a1e25d994 Make a few warnings go away. 2005-12-19 16:30:33 +00:00
Rob Landley c90c8b50e4 Do an svn log -v, the information in this changelog is stunningly
obsolete.
2005-12-19 16:29:19 +00:00
Rob Landley b3f05a467a Shadow password support involves vlock too. 2005-12-19 02:52:48 +00:00
Rob Landley 68eb9dd371 Patch from Tito to make vlock much smaller. 2005-12-19 02:50:10 +00:00
Rob Landley 553d83d427 strncmp isn't automatically superior to strcmp. Especially when it isn't
used right.
2005-12-18 20:34:41 +00:00
Rob Landley 9bdd742dd2 Sigh. Left the debug path in. Fixed. 2005-12-17 10:54:17 +00:00
Rob Landley b56c285da5 Added /etc/mdev.conf support. Adds about 1.9k to mdev. 2005-12-17 10:52:30 +00:00
Rob Landley 1a78103306 Bug 601: When we fork an archiver and feed stuff to it through a pipe, if
we don't close the pipe the child process won't exit, and we'll hang in
waitpid().
2005-12-16 21:33:10 +00:00
Rob Landley ef1f7b5058 Ahem. Vladimir checked in a different fix bug didn't close out the bug.
Reverting...
2005-12-16 08:03:34 +00:00
Rob Landley 4b91b88fcb Less would segfault if it had no tty. (Bug 600.) 2005-12-16 08:02:11 +00:00
Rob Landley 199501f2a0 I screwed up the last commit: if dt is null when ENABLE_MULTIPLE_OPTIONS is
off, we'd dereference the null.  Oops.
2005-12-16 06:18:06 +00:00
Rob Landley a930bd3332 Stephane Billiart said:
the attached patch makes applet list in busybox.links
correctly include tr and watchdog.
Currently, they don't appear because they are prefixed
with ENABLE_ in include/applets.h
2005-12-16 06:12:46 +00:00
"Vladimir N. Oleynik" ddc280ec43 sync license from mainstream 2005-12-15 12:01:49 +00:00
"Vladimir N. Oleynik" 8315cd527f fopen(TTY...) to bb_xfopen(), close bug 600 2005-12-15 11:53:22 +00:00
Bernhard Reutner-Fischer 9a14bd04f8 - Stephane Billiart writes:
Fix the compilation of head and tail.

  thanks!
2005-12-15 11:47:16 +00:00
Bernhard Reutner-Fischer 73bffd4d96 - remove duplicate entry for switch_root 2005-12-15 11:44:31 +00:00
Rob Landley 42eddbafe7 Add a fflush(stdout). 2005-12-15 08:04:17 +00:00
Rob Landley ae50c6d8ee Better use of the ENABLE guards. 2005-12-15 07:42:13 +00:00
Rob Landley e0c418e13b The rest of Yann E. Morin's install revamp. 2005-12-15 07:25:54 +00:00
Rob Landley 164c5c80ba Eliminate unnecessary allocation from md5sum that was leaked without ever being used. 2005-12-15 06:51:52 +00:00
Rob Landley 5aabf4e415 Fix -g and -p options. Patch from Traceman. (I don't know who that is,
it's the darn bug generator again.)
2005-12-15 05:42:55 +00:00
Rob Landley 483027f166 Patch from dlively (whoever that is, see bug 591) to fix
"ip link set <dev> addr".
2005-12-15 05:29:48 +00:00
Bernhard Reutner-Fischer d42ef28b98 - several functions depend on IPv4 or IPv6 od IPX support.
removes warning about unused code for allbareconfig.
2005-12-14 14:13:15 +00:00
Bernhard Reutner-Fischer 17d355cb3c - remove warning (thanks Yann E. MORIN) and switch to ENABLE_
- typo: s/begining/beginning/g
2005-12-14 08:32:44 +00:00
"Vladimir N. Oleynik" e6d88ea2a1 remove sigsetmask, noticed by Bernhard 2005-12-13 13:24:23 +00:00
Bernhard Reutner-Fischer e0b8778506 - check if CC supports -funsigned-char
- add CC_MAJOR and CC_MINOR variables. (gcc centric for now)
2005-12-13 11:52:46 +00:00
Bernhard Reutner-Fischer 5816ccb190 - wrap label GET_COUNT in #if ENABLE_FEATURE_FANCY_applet to avoid warning
about unused label.
2005-12-13 10:48:45 +00:00
Bernhard Reutner-Fischer ec351c32e3 - do away with superfluous keyword. 2005-12-13 10:28:25 +00:00
"Vladimir N. Oleynik" 4a9d6d1fe9 remove strange bloat dup2() usage, sync this code with mainstream login-utils, size reduce 2005-12-13 08:44:41 +00:00
Rob Landley 70f7ef7be3 Nothing to see here. Move along.
Not buying it, eh?

I know I said new features before 1.1, but, well...  (I was weak!)

The config file and hotplug modes aren't implemented yet.  Might take a stab at
those tomorrow.  (I _should_ go back to focusing on the bug triage list.)
2005-12-13 08:21:33 +00:00
Rob Landley 3858bf18d5 Minor fix: if(CONFIG) breaks the build when that CONFIG is disabled, it has
to be if(ENABLE).  (Make allbareconfig is a good testing thing.)
2005-12-13 04:06:22 +00:00
Rob Landley e919096271 Patch from Yann E. Morin, something to do with bugs 276 and 272. 2005-12-12 19:38:44 +00:00
Bernhard Reutner-Fischer 126da9ec2d - typo: s/sucess/success/g
What's up with loginutils/su.c line 42: "SYSLOG_SUCESS" ? Please have a look..
2005-12-12 11:20:39 +00:00
Bernhard Reutner-Fischer b7d5342003 - fix zcip for IMA compile mode.
rename usage() to zcip_usage, make struct arp_packet static. This applet is
  not ISO C89 compatible due to the use of C99-style comments ("c++ comments).
2005-12-12 10:21:35 +00:00
Rob Landley 10fb2b71f3 Flush output to log promptly (bug 389). 2005-12-12 07:04:59 +00:00
Rob Landley e422af6bcb Flush input when prompting for a password (bug 373). 2005-12-12 07:02:15 +00:00
Rob Landley a75c180e53 Bug 310: be consistent about stat/lstat and chown/lchown to avoid accidentally
modifying permissions or ownership when twiddling symlinks.
2005-12-12 06:58:53 +00:00
Rob Landley 032e2cbf20 Uninitialized variable causing intermittent syntax errors (bug 449). 2005-12-12 06:52:45 +00:00
Rob Landley cdbae77823 printf() arguments shouldn't be passed straight from user supplied data.
(Security thingy.)
2005-12-12 06:49:33 +00:00
Rob Landley 37310ea057 Change CONFIG_MODPROBE_MULTIPOLE_OPTIONS to
CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS.
2005-12-12 04:28:17 +00:00
Rob Landley 762bb626c7 Patch from Yann E. Morin to reorganize module config options. 2005-12-11 20:20:05 +00:00
Rob Landley 999af20d3e Make insmod quiet by default (patch from Yann E. Morin). 2005-12-11 20:14:12 +00:00
Rob Landley 9c32a15220 Yann E. Morin's update to modprobe usage. 2005-12-11 20:12:24 +00:00
Rob Landley 82327f4be4 Patch from Yann E. Morin to make rmmod report failure properly. 2005-12-11 19:46:50 +00:00
Glenn L McGrath 0bd0257fe0 Add build options to control SuS compatability, allows numeric
option handling to be disabled.
Defaults to enabled, so no changes in default behaviour
2005-12-11 03:09:05 +00:00
Bernhard Reutner-Fischer d77b781c1f - remove unused variable have_read_stdin
- use FLAG_WIDTH
2005-12-10 20:13:54 +00:00
Paul Fox 377bdaff3b avoid mixed declarations, to support older compilers just a little longer. 2005-12-08 18:48:20 +00:00
Rob Landley cc59aae65f Macro was wrong, name(void) vs name(x), and apparently gcc 2.95 cares about
matching up macro arguments even when the macro substitutes to nothing...
2005-12-07 23:17:28 +00:00
Rob Landley 07fffc5add uClibc can't handle anonymous MAP_SHARED. Since we're treating it as
read only data anyway, MAP_PRIVATE shouldn't make a major difference.
2005-12-07 22:45:28 +00:00
Rob Landley 02bab6869e Tito is using broken kernel headers that pollute the namespace with every
CONFIG_ symbol in the kernel, and this clashes with busybox's CONFIG_TR
and CONFIG_WATCHDOG, causing applets.h to barf if they're not switched
on (since the broken headers don't affect kconfig or the makefiles).

Since such broken kernel headers are common enough to crop up every few
months, a simple work around is to move TR and WATCHDOG from CONFIG_
to ENABLE_ early.
2005-12-06 22:48:29 +00:00
"Vladimir N. Oleynik" a62b0e7459 reduce 3 warning if compile with -W 2005-12-06 12:20:57 +00:00
"Vladimir N. Oleynik" 2f0a5f947a restore compare_string_array new interface (make broken by landley) 2005-12-06 12:00:39 +00:00
Rob Landley d4f15e95d6 Install links patch from Yann E. Morin. (Another thing hanging around in my
tree forever.  Tweaked the docs a bit.)
2005-12-02 18:27:39 +00:00
Rob Landley d1569c215c If we really _need_ an #ifdef like this, then we should be using the libbb
getopt infrastructure instead.
2005-12-02 17:57:23 +00:00
Rob Landley 746cfc8bf0 Another cleanup patch that's been in my tree for a while. Again I think it's
originally from Bernhard Fischer...
2005-12-02 17:55:45 +00:00
Rob Landley b5ca9e0c4e A cleanup patch I've had lying around in my tree for a while, I think it
was from Bernhard Fischer?
2005-12-02 17:54:01 +00:00
"Vladimir N. Oleynik" bf968f71f1 reduce signedness warning 2005-12-02 10:10:28 +00:00
"Vladimir N. Oleynik" a972c870a8 reduce signedness warning 2005-12-02 10:06:04 +00:00
"Vladimir N. Oleynik" 27d42a08c8 remove warnings if compile with -W, use ENABLE_FEATURE vs CONFIG_FEATURE 2005-12-02 09:46:04 +00:00
Rob Landley 4a070d1460 Make char default to "unsigned" on all platforms so we have a consistent base
to deal with all the new gcc 4.0.2 warnings from.
2005-12-01 17:01:43 +00:00
Rob Landley 1d589b2e2d Fix losetup so that it A) actually works again, B) has much better error
messages, C) can show the current association (if any) when called
with only one argument.  Update the documentation a lot too.

Remind me to add a test suite for this thing.  I think I've figured out
how to handle root-only testsuites...
2005-11-29 23:47:10 +00:00
"Vladimir N. Oleynik" 70678bc5b6 getopt -> getopt_ulflags. noticed by Rob Sullivan 2005-11-29 12:32:33 +00:00
Mike Frysinger 5a5d0fa044 update license 2005-11-29 02:53:52 +00:00
Mike Frysinger 004ad11337 ShaneAnderson writes in Bug 565:
need to include .config file before setting CROSS otherwise
TARGET_ARCH isnt set properly
2005-11-29 02:52:25 +00:00
Paul Fox 969af89797 add "-C" format to hexdump
fixes bug #113 and satisfies a personal need at the same time.

output compares identically to util-linux version.  (with
exception of whitespace differences on last lines of output with
non-uniform length, which are neither fixed nor worsened by this
change.)
2005-11-28 21:06:00 +00:00
Paul Fox d957b9537e fix bug #474:
0000474: vi crashes often

problem was that the buffer used for "." command ("last_modifying_cmd")
wasn't being maintined correctly -- the recording code was walking back
over the front of that buffer when a repeatable insert command
included backspacing (e.g. "i\b\b\bfoo").  the fix is to simply
record the backspaces along with the rest of the command.
    
also, cleaned up start_new_cmd_q() slightly.
2005-11-28 18:07:53 +00:00
Paul Fox 5a16a89427 eliminate mixed declaration, to support older compilers a little longer. 2005-11-28 16:29:45 +00:00
"Vladimir N. Oleynik" 8c44f0179d use libbb/get_kernel_revision(), reduce stack usage, add loses -w -f option for getopt, convert to bb_getopt_ulflags(), reduce memory usage - xmalloc to bb_common_bufsiz1, size reduce over 200 bytes 2005-11-28 15:54:22 +00:00
Rob Landley 52219874fe Patch from Cristian Ionescu-Idbohrn to deal with _ vs - better. 2005-11-27 19:01:53 +00:00
"Vladimir N. Oleynik" 350865e339 remove bug: fsck do not know path 2005-11-26 11:01:23 +00:00
"Vladimir N. Oleynik" cc34344d91 change the interface of libbb/compare_string_array (unsigned short to int), usaging for e2fsprogs/fsck 2005-11-26 10:45:26 +00:00
"Vladimir N. Oleynik" 61ff4b3973 more use const for interface of libbb/compare_string_array, example usage for e2fsprogs/fsck 2005-11-26 10:33:55 +00:00
"Vladimir N. Oleynik" 4eb2fd6826 more use libbb/bb_msg_read_error 2005-11-25 11:36:36 +00:00
"Vladimir N. Oleynik" 65bb10f253 reduce bss 2005-11-24 12:10:13 +00:00
Rob Landley fe25715792 Update to modprobe usage from Yann E. Morin 2005-11-23 04:55:02 +00:00
Rob Landley c819ca98ee Can't store a pointer in an int on 64 bit platforms. 2005-11-22 17:09:14 +00:00
Rob Landley b4c823211d Move interface.c to networking directory since it's only used by ifconfig. 2005-11-22 07:52:54 +00:00
Rob Landley fae1dc8620 Support # comments after s/// option list. 2005-11-20 07:44:35 +00:00
Mike Frysinger 4ee2eee2fc Quote the user we pass to addgroup so funky chars are preserved. Fix by dragan_marinkovic in Bug 544 2005-11-15 05:53:00 +00:00
Rob Landley 79e1cab0d1 Yann Morin's modprobe multiple options patch. There's more work to be done,
but let's ship 1.1 first...
2005-11-15 00:08:29 +00:00
Rob Landley 9033453c18 My last change to this file broke tar x. Sigh. (Trying to make sure we work
on file sizes between 2 and 4 gigs on 32 bit machines.  For supporting >4 gigs,
just use a 64 bit machine already...)
2005-11-12 11:04:11 +00:00
Rob Landley 5412843e79 I noticed that "tar tvjf file.tbz" was segfaulting. This fixed it. 2005-11-12 02:54:06 +00:00
Rob Landley 64a5f96780 telnetd -b (bind to specific address) support from Iuri Gomes Diniz. 2005-11-10 22:37:40 +00:00
Rob Landley 990025a7d9 Ok, I've converted the contents of the "testing/sed" directory into a
sed.tests file.  My brain hurts now.  (Lots of boggling at sed minutiae and 
corner cases and going "why is gnu giving that output".  The behavior of N 
and n with regard to EOF are only understandable if you read the Open Group 
spec, not if you read the sed info page, by the way...)

Some of the existing sed tests are just nuts.  For example, sed-next-line is 
testing for our behavior (which is wrong), and would fail if run against gnu 
sed (which was getting it right.  Again, this was a spec-boggling moment, 
with much head scratching.  I've got to add a debug mode where the stuff 
output by the p command is a different color from the stuff output by normal 
end of script printing (when not suppressed by -n).)

As for sed-handles-unsatisifed-backrefs: what is this test trying to _do_?  I 
ran it against gnu sed and got an error message, and this behavior sounds 
perfectly reasonable.  (It _is_ an unsatisfied backref.)  The fact we 
currently ignore this case (and treat \1 as an empty string) isn't really 
behavior we should have a test depend on for success.

The remaining one is sed-aic-commands, which is long and complicated.  I'm
trying to figure out if I should chop this into a number of smaller tests, or
if having one big "does-many-things" test is a good idea.

In any case, the _next_ step is to go through the Open Group standard and
make tests for every case not yet covered.  (And there are plenty.  There
are few comments in the file already.)  Plus I have notes about corner
cases from development that I need to collate and put into here.  This file
is maybe the first 1/3 of a truly comprehensive sed test.

Rob
2005-11-10 06:26:40 +00:00
"Vladimir N. Oleynik" ecfd1f6a35 change osbolete sigpause() to sigsuspend() 2005-11-09 09:19:29 +00:00
Rob Landley 6f03722448 Patch from Tomasz Mateja: don't try to CWD to a _filename_, just send the full
path to the STOR command.
2005-11-08 00:52:31 +00:00
Rob Landley c98a359a16 It was a bit out of date. 2005-11-07 09:06:34 +00:00
Rob Landley 48c6157eb9 Fix the test suite so that individual *.tests files can be run ala
COMMAND=sort ./sort.tests
So we can compare against non-busybox versions, and possibly our testsuite
will be useful to somebody like the Linux Test Project someday.

Redid testing.sh to add new command, "optional", to skip tests that require
certain features.  (use: `optional FEATURE_SORT_BIG`, or `optional ""` to
stop skipping.)  Note that optional is a NOP if the environment variable
"OPTIONFLAGS" is blank, so although we're marking up the tests with busybox
specific knowledge, it doesn't interfere with running the tests without
busybox.

Moved setting the "OPTIONFLAGS" environment variable to runtest.  Philosophy:
busybox-specific stuff belongs in runtest; both testing.sh and the tests
themselves should be as busybox-agnostic as possible.

Moved detecting that a command isn't in busybox at all (hence skipping the
entire command.tests file) to runtests.  Rationale: optional can't currently
test for more than one feature at a time, so if we clear anything with
optional "" we might perform tests we don't want to.

Marked up busybox.tests to know which tests need CAT enabled.  Fixed up other
tests to be happy with new notation.

I suspect egrep should be appended to grep.  It's a sub-feature, really...
2005-11-07 08:50:53 +00:00
Rob Landley 7ad4b30ed4 Yann E. Morin pointed out that rpcsvc/nfs_prot.h isn't needed with any
reasonably recent glibc, and breaks with uClibc.  So yank it.
2005-11-06 23:37:47 +00:00
Rob Landley 7b7c99ca33 Size I zapped the bb_close() error, might as well make a TODO item. 2005-11-04 20:45:54 +00:00
Rob Landley 3fc4ad1478 Fix bug 424: doing full_read breaks things like cat which should return a
chunk of data when they get it and not block until they've buffered 4k.

The use case was cat /proc/psaux, but you can also reproduce this by
running non-busybox cat by itself and typing things at the command line.
Then run busybox cat.  Notice how cat is _supposed_ to echo each line back
to us as we hit enter?
2005-11-04 01:54:15 +00:00
Rob Landley 21ccbb6c0e When cp ran out of space it didn't return a nonzero error code. Fixes bug 493. 2005-11-04 01:20:46 +00:00
Rob Landley c2ce2c5b4b It's no longer a temporary location. Smooth out the text a bit. 2005-11-04 00:50:48 +00:00
Eric Andersen fc94638330 point to the official links 2005-11-03 23:32:14 +00:00
Rob Landley 3d283ddecd Announce 1.1.0-pre1 already. Erik, please move links to the downloads directory
once you've got the signed tarballs up.
2005-11-03 22:11:00 +00:00
Rob Landley 2f30932eca Fix cp /dev/null filename, and a few in-passing cleanups. 2005-11-01 21:55:14 +00:00
Rob Landley dbc608b568 We've got fuser, fix some typos, and move Vodz's comment about UTF8 into
a new "internationalization" section, with some related concerns.
2005-10-31 23:52:02 +00:00
Rob Landley c63fe9137f \0 is a synonym for &. Our own "make allbaseconfig" breaks without this. 2005-10-30 10:08:13 +00:00
Mike Frysinger 7790cd5fad add ZyXEL to the shame list 2005-10-29 08:14:34 +00:00
Mike Frysinger d505e3ee67 fix <p> and <a> tags 2005-10-29 08:03:54 +00:00
Mike Frysinger 46b77c203e update doctype and add a charset encoding 2005-10-29 07:57:51 +00:00
Bernhard Reutner-Fischer 62d7acc97e - add BB_APPLET_RUNLEVEL used by emdebian via /etc/init.d/rc.
Note that we leave the buggy CONFIG_* namespace now, so please fix any applet you thouch.
2005-10-28 20:37:03 +00:00
"Vladimir N. Oleynik" 4922f2a06f update 2005-10-28 16:17:09 +00:00
"Vladimir N. Oleynik" 7eb8e45348 Please don't use if(asprintf(&t)<0) free(t); Use concat_subpath_file() for scan dir. Added losed chdir(".."). Removed warnings for 64-bit inode size. Why use memcpy and do not let? Very strange code for me 2005-10-28 16:08:47 +00:00
"Vladimir N. Oleynik" ea97282af1 bb_opt_complementally for rdate applet. Add losed record to util-linux/Makefile.in for switch_root applet 2005-10-28 15:43:41 +00:00
Rob Landley aa87276bed New applet, fuser, from Tony J. White. (Needs some cleanup.) 2005-10-28 13:05:12 +00:00
Bernhard Reutner-Fischer 30c7de068b - move GETXXKEY_R_FUNC into an internal helper file to allow for compiling
with IMA.
2005-10-28 11:21:40 +00:00
Bernhard Reutner-Fischer 6973abcfa8 - remove warning about "'static' is not at beginning of declaration". 2005-10-28 09:45:07 +00:00
Rob Landley 1b751c894b Rob Sullivan sent in some cleanups, which I beat on slightly. 2005-10-28 09:24:33 +00:00
Rob Landley 0f34a821ab Add a switch_root utility (like kconfig's utils/run_init.c, although not
actuall using any of that code).  This is needed because pivot_root doesn't
work right under initramfs.  (See the menuconfig help.)
2005-10-27 22:55:50 +00:00
Rob Landley 2454ebd85d Somebody suggested this, but I've forgotten who. 2005-10-27 22:50:04 +00:00
Rob Landley f3d6c94c7f Add --no-same-owner and --no-same-permissions options to tar. 2005-10-27 22:49:08 +00:00
Bernhard Reutner-Fischer 47ea7b7f96 - Matthias Wenzel writes:
without the fix below md5sum will always report a correct md5 on _any_
wrongly formattet input files.
- use short boilerplate and remove superfluous keyword extern.
2005-10-27 14:43:27 +00:00
Bernhard Reutner-Fischer ee9cf48620 - correct boilerplate
- use bb_xgetlarg for the patch_level to catch invalid arguments.
2005-10-27 06:59:05 +00:00
Rob Landley c9c959cc7c Reference for new patch feature we'll need to be compatible with... 2005-10-27 00:57:50 +00:00
Bernhard Reutner-Fischer ab1878245c * uniq.c: remove unneeded include and use short boilerplate.
* coreutils.h: remove prototype of non-existing xgetoptfile_sort_uniq
	and add boilerplate.
	* networking/{ipaddr,ip,iplink,iproute,iptunnel}.c: touch includes
	and use short boilerplate.
	* libiproute/iproute.c: rename round to avoid clashes with older
	SuSE gcc and use short boilerplate.
2005-10-26 10:47:26 +00:00
Rob Landley c58fd15db5 Update the TODO list to reflect stuff we've already done. 2005-10-25 20:22:50 +00:00
Rob Landley 3c6bfe3e33 Shaun Jackman noted that limits.h defines path_max and isn't included from
find_root_device.c.  (We #include it in busybox.h but not libbb.h, it seems.
Someday, someone's going to have to clarify for me the difference between
those two...)
2005-10-25 02:22:13 +00:00
Rob Landley 2d5d88ebc0 Two changes. One from Shaun Jackman makes libbb/interface.c compile only if
it's going to be used.  (I'm guessing it doesn't work with newlib.)

The other one is from me: allyesconfig shouldn't enable devfs because that
changes all sorts of unrelated stuff (like /dev/loop0->dev/loop/0), which
can come as a bit of a surprise.  (It's still there, but you have to go into
menuconfig and select it manually.)
2005-10-25 02:19:55 +00:00
Bernhard Reutner-Fischer 38d6615ed2 - fix bug to avoid aliasing busybox' main to zcip_main in IMA mode. 2005-10-21 10:43:11 +00:00
"Vladimir N. Oleynik" 1f0262bcdb another more const 2005-10-20 11:17:48 +00:00
"Vladimir N. Oleynik" 0fa9deda17 more const 2005-10-20 09:48:28 +00:00
"Vladimir N. Oleynik" 5cf9a03b3f more const, attribute_noreturn saved 200 bytes 2005-10-19 09:21:51 +00:00
Bernhard Reutner-Fischer bb20462cb3 - consume space between functionname and opening brackets
Fixes Rob's issue using busybox awk for building gcc-4_0 optionlist (http://busybox.net/lists/busybox/2005-October/016659.html)
2005-10-17 14:21:06 +00:00
"Vladimir N. Oleynik" 86ac072b44 more const, use bb_getopt_ulflags, insert XXX for show place of problems 2005-10-17 10:47:19 +00:00
"Vladimir N. Oleynik" 485d7cbdf1 data --> text 2005-10-17 09:48:57 +00:00
Rob Landley a4d45d423f The fact "tar tvjf thing.tbz" didn't work was due to the "-1" in -r11859,
which was apparently never tested.  That meant that there always had
to be at least one unparsed argument left over, which is not the case for
tar.
2005-10-16 08:42:18 +00:00
Rob Landley 60fe7bfa41 Whitespace and curly bracket cleanup (our tabstop is 4 in busybox),
and switch more stuff from CONFIG to ENABLE.
2005-10-16 03:54:49 +00:00
Bernhard Reutner-Fischer 7547a6e2f6 - don't update copyright years. He might release it, but apparently will have
to update the year himself.
2005-10-15 20:56:31 +00:00
"Vladimir N. Oleynik" c961a44e0b more const, all data to text 2005-10-15 14:41:08 +00:00
"Vladimir N. Oleynik" d3d829aaf0 20 bytes data to bss 2005-10-15 14:24:01 +00:00
Bernhard Reutner-Fischer 94c3331d47 - an empty middle term in ?: violates ISO C
- use shorter boilerplate and use C89 style comments
2005-10-15 14:13:09 +00:00
"Vladimir N. Oleynik" b4b6d26287 data --> code 2005-10-15 14:10:36 +00:00
"Vladimir N. Oleynik" 1f2dc40ede data --> bss 2005-10-15 13:56:17 +00:00
"Vladimir N. Oleynik" b32b1db9d8 complex RESERVE_CONFIG_BUFFER --> bb_common_bufsiz1 2005-10-15 13:49:21 +00:00
"Vladimir N. Oleynik" a2eec6051f RESERVE_CONFIG_BUFFER --> bb_common_bufsiz1 2005-10-15 13:45:32 +00:00
"Vladimir N. Oleynik" 6f347ef9dc common BUFSIZ BSS buffer, small reduce code, data and bss 2005-10-15 10:23:55 +00:00
"Vladimir N. Oleynik" 84e7511607 llist must initialize, add loses ifdef, small indent correction 2005-10-15 06:32:38 +00:00
Rob Landley 3ee6c24ea2 Add --exclude option (to make uClibc-0.9.28 headers install using busybox tar).
I have no idea how to apply bb_getopt_complementally to a --longopt that
has no short option.  The documentation from vodz has a bad case of
babelfish poisoning, and I can't understand it.  It sort of seems to
suggest there is a way, but what it is I have no idea.  So I used \n as
the short option, which is fairly unlikely to be used for something else. :)
2005-10-15 03:06:21 +00:00
"Vladimir N. Oleynik" f704b27b5b - new bb_opt_complementally syntax, use [-:?] only - 'free' chars
- new bb_getopt_ulflags features: check max and min args, convert first argv to options special for ar and tar applets
- use bb_default_error_retval for env applet
2005-10-14 09:56:52 +00:00
Bernhard Reutner-Fischer 8c7a7e6e63 - split VERSION into parts
- add some filesystem operation wrapper variables for use in the makefiles and
  pull them in early in the toplevel makefile
- use the cross-toolchain for "make sizes"
2005-10-13 10:40:18 +00:00
Bernhard Reutner-Fischer bb66a6c94e - initialize the correct variables 2005-10-13 10:24:44 +00:00
Bernhard Reutner-Fischer 309dc2d642 - typo in makefile variable: s/archvial/archival/ 2005-10-13 10:19:35 +00:00
Rob Landley 046d6e7a95 show_usage should use bb_default_error_retval. 2005-10-12 21:50:02 +00:00
Rob Landley e4164b5666 Did you know the uclibc IRC channel has daily logs on the web going back to
2002?
2005-10-12 19:10:34 +00:00
"Vladimir N. Oleynik" 368f66492e perror correction 2005-10-12 16:45:21 +00:00
"Vladimir N. Oleynik" d20cfbd303 create e2fs_set_sbin_path(), noticed by Tito, Thanks 2005-10-12 16:22:19 +00:00
"Vladimir N. Oleynik" 6c35c7c976 usage bb_dev_null 2005-10-12 15:34:25 +00:00
"Vladimir N. Oleynik" 86a1073e0b bb_dev_null 2005-10-12 15:21:32 +00:00
"Vladimir N. Oleynik" 3ade65fc04 remove 1 CR, correct strange bb_opt_complementally, add #if 0 and XXX-comment: pleace examine this\! 2005-10-12 14:36:42 +00:00
"Vladimir N. Oleynik" 3ebb895218 make fsck.h as common, e2fsck: includes correct 2005-10-12 12:24:01 +00:00
"Vladimir N. Oleynik" ab57f76e13 more busyboxes, remove 1 extern function (mainstream also have for one fsck) 2005-10-12 12:11:42 +00:00
"Vladimir N. Oleynik" 1c275de6a2 more busyboxes 2005-10-12 11:38:09 +00:00
"Vladimir N. Oleynik" 87210b5f4b trivial generate exit code 2005-10-12 08:43:00 +00:00
"Vladimir N. Oleynik" ffe17b51b4 correct strange *3 isatty(0) code 2005-10-12 08:38:28 +00:00
"Vladimir N. Oleynik" f1ab127077 Prepend '-' to the first argument if required, more const, indent 2005-10-12 08:34:27 +00:00
"Vladimir N. Oleynik" f588869696 new featured bb_opt_complementally, correct argc checking 2005-10-12 08:17:29 +00:00
Rob Landley 161aae7273 There doesn't seem to be a standard header for makedev(), but this is close. 2005-10-11 20:17:30 +00:00
"Vladimir N. Oleynik" 064f04e7e2 - use complementally '!' to '?' - 'ask' is best 'free' char for this.
- more long opt compatibility, can set flag for long opt struct now
- more logic: check opt-depend requires and global requires, special for 'id' and 'start-stop-daemon' applets.
2005-10-11 14:38:01 +00:00
Rob Landley ff567f7943 The check for EROFS was wrong. For example, if you try to mount a filesystem
appended to an executable that's being run (yes, I'm doing this) you get
EPERM, but mounting readonly fixes it.  Doing the fallback all the time
shouldn't hurt, and is one less test.
2005-10-11 07:26:15 +00:00
Bernhard Reutner-Fischer 554a9ff7ea - do not use bb_xgetularg10_bnd as a lower value of -1 doesn't work due to lowe
being unsigned.
- minor correction: use stdin only when no file was given via -i.
- use shorter boilerplate.
2005-10-10 13:34:19 +00:00
"Vladimir N. Oleynik" 54cb5c6af3 better check usage with options, correct show problem error message, indent 2005-10-10 12:17:33 +00:00
"Vladimir N. Oleynik" 083d3f49c2 bb_mkdep: Rewroted. removed problem "include name must uniq", speed up * 3.
e2fsprogs: remove confuse bb_mkdep. Use internal e2fsprogs includes only.
other: remove confuse bb_mkdep.
2005-10-10 11:35:17 +00:00
Rob Landley ff9f2f6fba Fluff out INSTALL a bit. 2005-10-09 20:18:32 +00:00
Bernhard Reutner-Fischer 332fc1006c - remove passing PREFIX and CROSS to make which was added for bug #94.
My recent Makefile touch-up assures that make O=/tmp/o PREFIX=/tmp/i install
  works as expected without this ugly workaround.
2005-10-09 19:12:34 +00:00
Rob Landley d27d3be6cd The readme in 1.0 is more up to date than the 1.1 version... 2005-10-09 18:20:54 +00:00
Paul Fox 61e45dbb2f catch and report errors from file_write() 2005-10-09 14:43:22 +00:00
Paul Fox 90372ed51a make Hit_Return() available when CONFIG_FEATURE_VI_COLON is off. it's
needed elsewhere as well now.
2005-10-09 14:26:26 +00:00
Rob Landley ae907f38f0 When lstat returns an error (such as file not found), the value of
st_mode is random garbage (under uClibc), leading to random triggering
of the S_ISDIR() case when the destination will be a normal file which
doesn't exist yet.  I.E. checking the return value of lstat is not optional.
2005-10-09 11:16:01 +00:00
Rob Landley f1048143ee Rob Sullivan added character and equivalence classes to tr. I changed some
comments.
2005-10-08 21:21:08 +00:00
Bernhard Reutner-Fischer 1d62d3b7b9 - make libiproute compile.. 2005-10-08 20:47:15 +00:00
Rob Landley 4a7252babd Rename CONFIG_NFSMOUNT to CONFIG_FEATURE_MOUNT_NFS so allbaseconfig can
find it (and tweak defconfig to catch up).
2005-10-08 18:49:45 +00:00
Rob Landley 45ad0e87d6 Rename CONFIG_SORT_BIG to CONFIG_FEATURE_SORT_BIG so allbareconfig can find it. 2005-10-08 17:48:25 +00:00
Rob Landley 1ba19d6bf7 Coprolith polishing time: Tito switched devfsd over from CONFIG_ to ENABLE_. 2005-10-08 17:42:35 +00:00
Bernhard Reutner-Fischer be5c10314d - rename bareconfig to allbareconfig and emit "is not set" strings needed for
oldconfig.
2005-10-08 11:08:28 +00:00
Rob Landley 25413bfe00 Shaun Jackman pointed out that fgets_unlocked() and friends are gnu extensions
not in newlib, and also that all the _unlocked variants are kind of pointless
in this context.
2005-10-08 02:23:22 +00:00
Bernhard Reutner-Fischer a9d8913bc7 - add config target bareconfig. Enables all applets but without any features.
Rob wanted to have regression tests if a bug crops up. Here you are wrt find :)
2005-10-07 18:45:03 +00:00
Bernhard Reutner-Fischer b8faa7ea60 - Note that directories for make have to be given as absolute paths. 2005-10-07 17:44:14 +00:00
"Vladimir N. Oleynik" dfd1eb0387 trim dep lines 2005-10-07 15:53:21 +00:00
Bernhard Reutner-Fischer ab52db8d5e - size reduction of pidof
- fix typo in reverse_pidlist
2005-10-07 15:44:37 +00:00
"Vladimir N. Oleynik" 6c0642d772 fast replace if src outside 2005-10-07 15:36:26 +00:00
Bernhard Reutner-Fischer 0b42a6a8cf - remove superfluous C statements ";;" in decompress_unzip.c, dpkg_deb.c ifconfig.c
- gzip.c: see if O_NOFOLLOW is defined before using it, else take alternate path
closes bug #221 (partially; The rest will follow later).
2005-10-07 11:34:50 +00:00
Bernhard Reutner-Fischer 4d63525f76 - fix bug #94: 'make install' does not respect PREFIX nor CROSS when using O=
- other minor cosmetic tweaks while at it
2005-10-07 10:53:15 +00:00
Rob Landley cee605c525 The supposedly trivial CONFIG->ENABLE conversion wasn't so trivial. The
-exec feature shouldn't be tangled up with this, so revert everything but
the new exec feature for the moment.
2005-10-06 16:39:17 +00:00
Bernhard Reutner-Fischer 81c3a518d3 - pidof(8): make -s optional and optional -o; closes #168
first cut.
2005-10-06 15:37:02 +00:00
"Vladimir N. Oleynik" b31cb87fdc to bb_getopt_ulflags() 2005-10-06 15:30:17 +00:00
"Vladimir N. Oleynik" ba248206fe change strange depend to libbb.h, but require busybox.h 2005-10-06 15:18:09 +00:00
"Vladimir N. Oleynik" 664c6e7ea0 update documentation 2005-10-06 14:53:43 +00:00
"Vladimir N. Oleynik" d5f2a18e19 bb_mkdep can use src outside now 2005-10-06 14:47:16 +00:00
Bernhard Reutner-Fischer 82338d8460 - add a few basic tests for pidof(8) 2005-10-06 12:50:11 +00:00
Bernhard Reutner-Fischer e34e8782a9 - support make check V=1 to run the checks in verbose mode
- pass verbose from runtest to testing.sh
2005-10-06 12:48:03 +00:00
Bernhard Reutner-Fischer cf95e0b2d5 - add llist_free_one() and llist_free() to libbb 2005-10-06 12:12:51 +00:00
Bernhard Reutner-Fischer 56b217117a - add llist_free_one() and llist_free() to libbb; Add a bit of documentation.
- change llist_add_to_end as proposed by vodz in http://busybox.net/lists/busybox/2005-September/016411.html
- remove unneeded includes, add short boilerplate and copyright to llist.c
- move COMM_LEN from find_pid_by_name to libbb.h and use it in procps_status_t
- add reverse_pidlist() to find_pid_by_name. Will be needed for pidof.
2005-10-06 12:10:48 +00:00
Bernhard Reutner-Fischer 14b1c1da9a - remove explicit dependency of busybox.o and applets.o and usage.h from the
Makefile. Instead fix the invocation of bb_mkdep.
2005-10-05 14:52:21 +00:00
"Vladimir N. Oleynik" c06e80e1e7 more lost changes BSD signals -> SysV signals. Noticed by Bernhard 2005-10-05 14:14:55 +00:00
"Vladimir N. Oleynik" f382c0236e BSD signals -> SysV signals, int->socklet_t. Noticed by Bernhard 2005-10-05 14:01:13 +00:00
"Vladimir N. Oleynik" 4a5ce08688 another more correction for getopt_ulflags() documentation (examples) 2005-10-05 13:58:40 +00:00
Bernhard Reutner-Fischer b48bfe795e - fix generation of .depend when building out of tree.
point bb_mkdep to the source directory and not the build-directory.
2005-10-05 13:55:45 +00:00
Bernhard Reutner-Fischer 83e1884d0c - busybox.o and applets.o depend on usage.h 2005-10-05 13:53:46 +00:00
"Vladimir N. Oleynik" d1b6078e5d more correction for getopt_ulflags() documentation by author of this fuck logic 2005-10-05 12:44:52 +00:00
Bernhard Reutner-Fischer 120513c29f - add proper separators. sorry for the noise.. 2005-10-05 12:28:55 +00:00
Bernhard Reutner-Fischer 43fb3fcb2f - add a bit more documentation to vodz' recent additions. 2005-10-05 12:23:13 +00:00
"Vladimir N. Oleynik" 35939d9378 update bb_getopt_ulflags special for 'ps' applet, usaging '-' as first group char from bb_opt_complementally is new feature: set argv is options;
use new bb_getopt_ulflags for ps
# define terminal_width 80->79 for unwide
use stdout file descriptor for get_terminal_width_height. (its must)
2005-10-05 10:52:47 +00:00
Bernhard Reutner-Fischer 7abe709867 - Fix spurious rebuilds for (parallel) out-of-tree builds.
Make sure that the directories are order-only prerequisites. Otherwise we
  may have object files created after the timestamp of the directory was
  updated which would lead to spurious rebuilds (as some of the dentries
  may be older than the dir itself).
2005-10-05 10:06:11 +00:00
Bernhard Reutner-Fischer 5c071bcf2f - fix building out-of-tree;
to test, checkout the source (let's assume /scratch/src/busybox), then
  mkdir /tmp/bb ; cd /tmp/bb
  make top_srcdir=/scratch/src/busybox O="$(pwd)" -f /scratch/src/busybox/Makefile allyesconfig check
- default to O=$(pwd) if no O was specified. Now you can just specify
  the top_srcdir (without O=/somewhere) to create the obj-tree in pwd.
- make "make configtarget buildtarget" work. Previously this didn't
  work due to how HAVE_DOT_CONFIG was evaluated. Two separate steps were
  needed before, e.g. make config ; make busybox.
- remove some unneeded variables from Rules.mak (BB_SRC_DIR from Mr.
  ldoolitt@recycle.lbl) which suggest that the stuff fixed above
  didn't work before.
- move selinux libraries to where they belong (from Makefile to Rules.mak)
- update the docs to mention svn instead of cvs and provide an example
  for building out-of-tree in INSTALL.
2005-10-05 07:40:46 +00:00
Mike Frysinger dc2510327b as Tito points out, e2fsck and fsck need more dependencies 2005-10-05 00:52:37 +00:00
Mike Frysinger 23fedb3ad4 dont typecast lvalue since gcc hates that 2005-10-05 00:50:03 +00:00
"Vladimir N. Oleynik" 9c44dce304 ps selinux logic correction, but do not tested too 2005-10-04 17:09:50 +00:00
"Vladimir N. Oleynik" be0ed3d0b9 use updated bb_getopt_ulflags() for ps applet 2005-10-04 16:48:26 +00:00
Bernhard Reutner-Fischer 6d6a40cc4b - add option 'w' to ps (wide output, optional feature defaults to off).
- move to ENABLE_ and use shorter boilerplate.

sizes without selinux-support:
   text	   data	    bss	    dec	    hex	filename
    356	      0	      0	    356	    164	procps/ps.o.with-w
    300	      0	      0	    300	    12c	procps/ps.o.no-w
    302	      0	      0	    302	    12e	procps/ps.o.oorig
2005-10-04 14:31:18 +00:00
Bernhard Reutner-Fischer 5209e18ba7 - add prototype for llist_add_to_end to libbb.h 2005-10-04 13:39:06 +00:00
Rob Landley 5d3a0e8ed3 Add find -exec support from Rob Sullivan, and convert CONFIG_ to ENABLE_
while we're in the area.
2005-10-04 03:34:39 +00:00
"Vladimir N. Oleynik" d128b71820 speed up * 2 2005-10-03 10:08:46 +00:00
"Vladimir N. Oleynik" 1a2f4d9af7 sync inetd with slackware-10.2 inetd (OpenBSD-1.79), have destroy bug 455 2005-10-03 08:08:58 +00:00
Mike Frysinger 7f782da048 excellent shrinkage patch by Tito 2005-10-02 08:10:31 +00:00
Mike Frysinger 9134dff078 clean out unneeded E2FSCK variables 2005-10-02 08:09:50 +00:00
Mike Frysinger c31fcbbaf3 remove debug warning 2005-10-02 07:54:07 +00:00
Mike Frysinger cb1ce7b974 reorder arches into alphabetical order 2005-10-02 07:50:49 +00:00
Mike Frysinger fa17c4b949 fixup whitespace 2005-10-02 07:14:06 +00:00
Mike Frysinger 86a4bfb30a remove all Elf32 hardcodes to make sure the elf handling is 64bit clean 2005-10-02 07:02:16 +00:00
Mike Frysinger 91fbdac6ab svdavidson writes in Bug 459: add support for x86_64 relocations from modutils 2.4.27 2005-10-02 06:44:39 +00:00
Bernhard Reutner-Fischer e6d5539ebb typo 2005-09-30 09:46:27 +00:00
Bernhard Reutner-Fischer f24e0f5e6f - remove duplicate entry of resolve.c in BLKID_SRC
- use the sourcedir to look for includes rather than the builddir
2005-09-30 08:25:50 +00:00
"Vladimir N. Oleynik" 39a841cecf change interface to bb_xasprintf() - more perfect for me.
ln.c: error_msg(str)->error_msg(%s, str) - remove standart "feature" for hackers
reduce 100 bytes don't care in sum
2005-09-29 16:18:57 +00:00
"Vladimir N. Oleynik" 6a60c821a8 forgotten putenv 2005-09-29 15:53:34 +00:00
"Vladimir N. Oleynik" 8e1bd4a05b don't out \r to syslog 2005-09-29 12:55:21 +00:00
Bernhard Reutner-Fischer bee9eb1a9d - rename llist_add_to.c to llist.c
- move llist_add_to_end() from ifupdown.c to libbb/llist.c
2005-09-29 12:55:10 +00:00
"Vladimir N. Oleynik" 3e245c9e21 getty must chdir(/). Use bb_getopt_ulflags. Indent. error() perfect 2005-09-29 11:31:26 +00:00
"Vladimir N. Oleynik" 6160d45e05 more busybox's style for fsck.c, size reduce 2005-09-29 09:45:22 +00:00
"Vladimir N. Oleynik" 74078685e6 busybox.c: ENABLE_LOCALE logic correct. 2005-09-29 08:19:04 +00:00
"Vladimir N. Oleynik" 843c5ef0f9 reorder include <sys/types.h> and <sys/types.h>. 2005-09-29 07:55:51 +00:00
"Vladimir N. Oleynik" 69d728be18 more const, inline, forward declaration usage, strip 20k source size ;-) 2005-09-28 15:16:22 +00:00
Mike Frysinger 747fc5d5fd allow people to adjtime location 2005-09-28 03:21:21 +00:00
"Vladimir N. Oleynik" 3978e5576e move e2fsck/* to e2fsck.c, one e2fsck_main and jornal exported, small automatic size reduction 2005-09-27 11:43:29 +00:00
Mike Frysinger 16ce8aa412 fix building w/out et headers and w/out debug 2005-09-27 04:21:48 +00:00
Mike Frysinger f87b3e30a7 as pointed out in Bug 17, use uint32_t instead of unsigned long since the code expects the size of the info variables to be 32bits and sizeof(long) on 64bit hosts is not 32bits 2005-09-27 04:16:22 +00:00
Mike Frysinger 67451849de pass EXTRA_CFLAGS to final link since it may contain things that affect linking (such as -m32) 2005-09-27 04:06:39 +00:00
Mike Frysinger de2b93859c eat misappropriated whitespace 2005-09-27 03:18:00 +00:00
Mike Frysinger 10a11e23ba uncuddle function scope brackets 2005-09-27 02:23:02 +00:00
Bernhard Reutner-Fischer 1c943eb88a - remove unused variable TOPDIR 2005-09-26 16:01:43 +00:00
Rob Landley d24eaac9e6 add "make help" 2005-09-26 15:49:41 +00:00
"Vladimir N. Oleynik" 7090800870 revert wait zombie, it have as linux-specific signal(SIG_CHLD,SIG_IGN) already, do not confuse me\! 2005-09-26 13:55:43 +00:00
"Vladimir N. Oleynik" 11d7c52912 correct set prompt if CONFIG_ASH_EXPAND_PRMT enabled, small automatic space->tabs convert by my personal editor 2005-09-26 13:24:45 +00:00
"Vladimir N. Oleynik" 5f46010ab7 spwd bulid now, (typo) 2005-09-26 12:58:24 +00:00
Rob Landley 5246063a7b Patch from Amir Shalem to make busybox compile on a uClibc that has no shadow
password support.
2005-09-25 23:36:12 +00:00
Mike Frysinger 95544f78cb whitespace sucks 2005-09-25 05:23:58 +00:00
Mike Frysinger 7ad978045d fix building with debugging enabled #413 2005-09-25 05:18:04 +00:00
Mike Frysinger de242f6d5f this should fix parallel building with .depend/bb_config.h 2005-09-25 04:53:35 +00:00
Rob Landley 1ff789c567 Stop gcc4 from nit-picking about signedness of char *. 2005-09-25 03:12:26 +00:00
Mike Frysinger 3978abd05b Cristian Ionescu-Idbohrn writes to fix a warning: networking/ifconfig.c uses an uchar ptr to work with a char ptr so change the uchar to char 2005-09-24 23:52:09 +00:00
Mike Frysinger 036f299137 Cristian Ionescu-Idbohrn says: touchup whitespace/display 2005-09-24 23:50:14 +00:00
Mike Frysinger b7f88e01a4 touchup argc/argv handling to shrink a bit and fix a segfault when given wrong number of parameters as noted and fixed by Cristian Ionescu-Idbohrn 2005-09-24 23:48:18 +00:00
Mike Frysinger a630cb15b1 re-order a little for alphabetical 2005-09-24 23:15:53 +00:00
Mike Frysinger 7f8797c8ee re-order a little for alphabetical 2005-09-24 23:15:28 +00:00
Mike Frysinger f51d2069ff re-order a little for alphabetical 2005-09-24 23:14:11 +00:00
Mike Frysinger d1c8ae5dc9 re-order a little for alphabetical 2005-09-24 23:13:22 +00:00
Mike Frysinger 75aa1928ac re-order a little for alphabetical 2005-09-24 23:12:38 +00:00
Rob Landley 16722554bf Tito switched option parsing over to switch umount over to bb_getopt_ulflags(). 2005-09-24 22:41:08 +00:00
Mike Frysinger 5423df9ebc force nodebug by default 2005-09-24 07:20:59 +00:00
Mike Frysinger 62f18e1f20 use the shorter license header 2005-09-24 07:16:29 +00:00
Mike Frysinger 51a43b47fe import the very fat e2fsck/fsck applets 2005-09-24 07:11:16 +00:00
Mike Frysinger bfe773f471 make sure we include local header files 2005-09-24 07:10:37 +00:00
Mike Frysinger 016d6289a1 fix parallel building again 2005-09-24 06:15:23 +00:00
Mike Frysinger 0f8a63896e err, fix stupid mistake in previous do_findfs() change 2005-09-24 06:07:34 +00:00
Mike Frysinger 0d65565210 add a attribute_noreturn macro 2005-09-24 06:07:15 +00:00
Mike Frysinger 0d4ee68be5 use brief license line 2005-09-24 06:01:57 +00:00
Mike Frysinger 97b43a7999 fix broken whitespace and remove pointless mkdir 2005-09-24 05:58:39 +00:00
Mike Frysinger a1c6a57fea make e2label and findfs optional 2005-09-24 05:55:03 +00:00
Mike Frysinger 9ac178ab40 rename menu and touchup whitespace 2005-09-24 05:49:36 +00:00
Mike Frysinger ce0cf1d44b make test an alias for check 2005-09-24 05:47:52 +00:00
Mike Frysinger 3f91d7a9f6 cleanup option parsing 2005-09-24 00:52:58 +00:00
Bernhard Reutner-Fischer 30b17863bd - ifupdown needs run-parts. Thanks Derosnec for pointing this out. 2005-09-23 19:37:13 +00:00
Bernhard Reutner-Fischer 23bc647b35 - remove dangling symlinks after the runs
- check if the temporary directory containing the links exists rather
  than unconditionally creating it for every single applet.
2005-09-23 17:42:33 +00:00
Rob Landley 380ad123ac We've gotten enough questions that are related to building systems rather
than anything about busybox that I'm deeming it a FAQ, and answering it.

I gave a quick swipe to a couple of other slightly stale questions along
the way.  The busybox 1.01 README has much more detailed versions of these
answers, that should probably be propogated to the 1.1 line and perhaps bits
of it transplanted to the FAQ?  (Or just have the README visible on the
web page someplace?)
2005-09-23 16:52:09 +00:00
Bernhard Reutner-Fischer 1eb645d8d7 - set executable bit 2005-09-23 15:56:39 +00:00
Bernhard Reutner-Fischer b47a74f4e7 - introduce variable _BB_CONFIG_DEP to the new test harness.
This is used to see if given tests should be run (are available) or not.
  Print "UNTESTED: descr" if the applet or feature is not available.
- add _BB_CONFIG_DEP to existing new.tests
- move old grep test to new test infrastructure and add a few more test for
  grep.
2005-09-23 15:44:46 +00:00
Bernhard Reutner-Fischer 0a44c17771 - add missing descriptions of supported arguments 2005-09-23 15:40:15 +00:00
Bernhard Reutner-Fischer aaf0e23330 - replace variables by defines to save space
- rename string denoting stdin from "-" to "(standard input)" to match
  GNU grep.
2005-09-23 15:38:49 +00:00
"Vladimir N. Oleynik" bf4497406f SUSv3 -q compatibily exit status correction for grep again 2005-09-23 13:50:24 +00:00
"Vladimir N. Oleynik" c96b703ab0 SUSv3 -q compatibily exit status correction for grep 2005-09-23 13:44:03 +00:00
"Vladimir N. Oleynik" cf40d8175b grep must have exit code >1 if input file not found. Small indent correcion also. 2005-09-23 13:23:15 +00:00
"Vladimir N. Oleynik" b628409b1e more make safe the exported namespace for udhcp. Move to bb-specific file for reduce change into udhcp-CVS 2005-09-23 11:25:29 +00:00
"Vladimir N. Oleynik" 53ad366fe7 remove 1 exported 2005-09-23 10:44:02 +00:00
Paul Fox b6f71645f4 move a couple of functions from common code (options.c) to udhcpd private
code (files.c) to make udhcpc a little smaller.
2005-09-22 19:03:24 +00:00
Paul Fox 28de951b02 add support for setting the dhcp vendor class option (option 60).
udhcpc now has a -V (--vendorclass), which will replace the default
"udhcpRELEASE" string in this option.
2005-09-22 18:59:13 +00:00
"Vladimir N. Oleynik" 2f9c30a2d5 safe exported namespace for udhcp. Not full, bore :-( 2005-09-22 15:07:33 +00:00
"Vladimir N. Oleynik" ac9731704a Reduce exported from msh applet 2005-09-22 14:38:17 +00:00
"Vladimir N. Oleynik" 264e771b8b Reduce exported from lash applet 2005-09-22 14:35:29 +00:00
"Vladimir N. Oleynik" 19c370167a Reduce exported from hush applet 2005-09-22 14:33:15 +00:00
"Vladimir N. Oleynik" b8fa7e88f2 quick patch - have removed stranges for me 2005-09-22 14:19:34 +00:00
"Vladimir N. Oleynik" 1f0ac23c20 very small size reduce for nohup applet 2005-09-22 13:26:23 +00:00
"Vladimir N. Oleynik" 24cca8d958 Reduce exported from ipcs applet 2005-09-22 13:13:23 +00:00
"Vladimir N. Oleynik" e4baaa2d27 more remove lost exported 2005-09-22 12:59:26 +00:00
"Vladimir N. Oleynik" 007a011647 network "default" --> bb_INET_default. Reduce 2 exported from find applet 2005-09-22 11:11:11 +00:00
Bernhard Reutner-Fischer 9d7010ca86 - add applet nohup(1) 2005-09-21 18:25:05 +00:00
Bernhard Reutner-Fischer d4cffd1cc3 - make sure to include dmalloc.h at the very end of busybox.h or libbb.h. 2005-09-21 17:38:30 +00:00
"Vladimir N. Oleynik" cef737f038 moved include/bbconfigopts.h from miscutils to to top Makefile before generate .depend. Remove allyesconfig build problem, noticed by Bernhard Fischer 2005-09-21 07:49:34 +00:00
Bernhard Reutner-Fischer c5280e8885 - consolidated password helpers 2005-09-20 21:09:31 +00:00
Bernhard Reutner-Fischer f56b8e4b00 - consolidated password helpers into bb_pwd.c 2005-09-20 21:08:10 +00:00
Bernhard Reutner-Fischer d5bd137a24 - rename libbb's password helpers as suggested in libbb.h
my_getpwnam -> bb_xgetpwnam  /* dies on error */
  my_getgrnam -> bb_xgetgrnam  /* dies on error */
  my_getgrgid -> bb_getgrgid
  my_getpwuid -> bb_getpwuid
  my_getug    -> bb_getug
2005-09-20 21:06:17 +00:00
Bernhard Reutner-Fischer f912ebb740 - Remove unnecessary warning from libbb and move bb_wfopen_input near bb_wfopen 2005-09-20 20:58:11 +00:00
Bernhard Reutner-Fischer 6ab402ce27 - typo in documentation 2005-09-20 20:32:02 +00:00
Rob Landley 52d2f4bd90 Get "make check" ($srcdir) to work with the new testsuite. 2005-09-20 18:19:34 +00:00
Rob Landley 90252bb4c9 The testsuite/links directory wasn't being created. 2005-09-20 14:09:57 +00:00
"Vladimir N. Oleynik" 7fe6520e75 This is strange typically modern mistake. Learn please: stat(2) used sys/types.h and not reverse 2005-09-20 10:02:36 +00:00
Mike Frysinger 6d5aa4539a Bernhard Fischer writes:
Attachet patchlet updates the screenshot of busybox perusing the stable branch.
2005-09-20 03:01:29 +00:00
"Vladimir N. Oleynik" 8cbaa45030 remove duplicate depend, its work for bb_mkdepend 2005-09-19 16:31:25 +00:00
"Vladimir N. Oleynik" 2f01eb161a correct build bbconfig applet, correct previous change 2005-09-19 16:25:19 +00:00
"Vladimir N. Oleynik" 4a5d95d3fb corect build bbconfig applet, Thanks, Bernhard Fischer 2005-09-19 16:18:46 +00:00
"Vladimir N. Oleynik" 9bfb2fc922 hmm, forgoten remove llseek? 2005-09-19 14:25:55 +00:00
"Vladimir N. Oleynik" bc37480e9c 1) read from stdin work now
2) destroy segfault in number_process
3) removes dead code

complex patch my and Tito
2005-09-19 14:23:46 +00:00
"Vladimir N. Oleynik" b71e6024f9 mke2fs.c can compiled for me, more bb_xstrdup and bb_xasprintf usage, remove 1 exporing, ext2fs_llseek/blkid_llseek->llseek 2005-09-19 13:48:39 +00:00
"Vladimir N. Oleynik" 54deebf4e4 destroy bug #421 2005-09-19 10:46:44 +00:00
"Vladimir N. Oleynik" a0ae6de848 quick patchs: drop founded memory leak, more libbb, more C-compatibility, size reduction 2005-09-19 10:28:43 +00:00
"Vladimir N. Oleynik" 4cbe45934e small bug found after strength test 2005-09-19 10:26:45 +00:00
Mike Frysinger 9ed109429b Bernhard Fischer writes:
Attached patch moves bbconfig's entry in Config.in in the alphabetically
correct place.
2005-09-18 04:43:32 +00:00
Rob Landley d57ae8b796 First cleanup pass, from Rob Sullivan. More to be done... 2005-09-18 00:58:49 +00:00
Rob Landley 07e42dc056 Tito pointed out that if readlink doesn't have -f, there's no need to call
the option parsing code at all.
2005-09-17 11:13:25 +00:00
Rob Landley a882126fee Update TODO with mention of the CONFIG->ENABLE migration and ruminations
about FEATURE_CLEAN_UP.
2005-09-16 14:58:55 +00:00
"Vladimir N. Oleynik" af0dd596a8 speed up +10%, update (c), make CONFIG_FEATURE_MOD2_4 as config/feature/mod_2_4 2005-09-16 13:57:33 +00:00
"Vladimir N. Oleynik" 8d3c40d492 more C-compatibily, Thanks Bernhard Fischer 2005-09-16 13:16:01 +00:00
"Vladimir N. Oleynik" 38013e394f removed 'less' section from TODO 2005-09-16 13:03:21 +00:00
"Vladimir N. Oleynik" f246dc7f57 ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE->CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE 2005-09-16 12:55:29 +00:00
Paul Fox c350485b18 initialize a couple of vars whose warnings were suppressed because
i was building w/ debug on before, which suppresses optimization.
2005-09-16 12:48:18 +00:00
"Vladimir N. Oleynik" 2b306e906f small change for highlihting flags, more busyboxes: indent, forward declaration, paste BSS 2005-09-16 12:32:22 +00:00
Paul Fox 8552aec7fd some combinations of status line and screen refresh don't give a
correct screen, and bug 215 reports trouble with the status line
on small screens.

with this change a) the status line should always be refreshed
properly, b) the status line is a little shorter than it used to
be ("I" instead of "--INSERT--"), c) the status line will be
truncated if it doesn't fit on the screen, and d) if the screen
is too narrow for an error or transient status message (from
psb() or psbs()), then that message will be followed by a "Hit
Return" prompt.  (it wasn't until i did this last bit that the
size grew.  with this, these changes add about 150 bytes.)

- pgf
2005-09-16 12:20:05 +00:00
Mike Frysinger 2d5e4f6b05 accept unlimited number of swap arguments like the real swap{on,off} and shrink do_em_all a little 2005-09-16 04:41:20 +00:00
Mike Frysinger 0ec71bf4b8 update for newer build system 2005-09-16 04:21:25 +00:00
Rob Landley 9200e79d21 New applet "less", from Rob Sullivan. 2005-09-15 19:26:59 +00:00
Rob Landley bfd94c4331 Whitespace patch (and removal of gratuitous use of cat) by Berhnard Fischer. 2005-09-15 18:33:30 +00:00
Rob Landley 6a65d2f8cc Amir Shalem observed that telnetd doesn't really require login, so forcing
it is wrong.
2005-09-15 18:22:43 +00:00
Manuel Novoa III 84b93f7ef1 Get rid of warnings, remove compat with older gnu uniq to truly conform to susv3, and cut size a bit. 2005-09-15 08:06:42 +00:00
Mike Frysinger 86097b3f31 Bernhard Fischer:
[busybox][patch][janitorial] correct typo in news.html and make site html compliant
2005-09-15 01:37:36 +00:00
Mike Frysinger 887a1ad57f BsAtHome writes in Bug 433:
Ping packets sent by busybox have wrong endian on f.x. mips32 (openwrt). Attatched is a patch that 
uses htons() and ntohs() to be platform independent.
2005-09-15 01:32:48 +00:00
"Vladimir N. Oleynik" 23f62fc6f3 split libbb: moved xregcomp separatelly for speed up recompile 2005-09-14 16:59:11 +00:00
"Vladimir N. Oleynik" b4f3cff6f5 removed strange extern void xregcomp(... from some applets, but declared from libbb.h 2005-09-14 16:22:50 +00:00
"Vladimir N. Oleynik" 1e07f852e0 FEATURE->ENABLE_FEATURE loses one for 'top' applet 2005-09-14 16:08:06 +00:00
Rob Landley 2d2c868aab Patch from Berhnard Fischer to keep duplicate objects out of the library. 2005-09-14 15:41:18 +00:00
"Vladimir N. Oleynik" 0c520e03b9 remove unrequired dependences 2005-09-14 15:36:56 +00:00
Rob Landley 570f655ee4 Cleanup patch from tito: migrate option parsing to the bb_ functions and fix
types.
2005-09-14 15:36:52 +00:00
Rob Landley b7285001c9 Cleanup patch from Tito. 2005-09-14 15:28:15 +00:00
"Vladimir N. Oleynik" 7573ac6edf bb_mkdep version 2.0. speed up *2, remove problem of find e2fsprogs/uu*.h, spelling corrections by Bernhard Fischer 2005-09-14 15:09:06 +00:00
Rob Landley 2ee82723a8 Our config should write out each symbol once and only once, but still write
out all symbols in all sub-menus.  I think this finally does it right.
2005-09-14 14:40:01 +00:00
Rob Landley 1e51925684 Test full susv3 spec for uniq (except internationalization).
I think this covers it.  We fail two corner cases, both of which are explicit
violations of the spec, and both of which gnu passes.
2005-09-14 14:36:40 +00:00
Paul Fox db485cf7bc committing bug #7:
0000007: which and wd-located files
	     which doesn't search $PATH when there's a file in the WD with
	     the same name of the 'filename' parameter...
2005-09-14 14:08:38 +00:00
Mike Frysinger bc48ebd86a initial ppc64 support 2005-09-14 00:07:26 +00:00
Paul Fox f2de0b7ae4 allow either backspace or DEL, in addition to the user's erase
char, to be used in get_input_line()
2005-09-13 22:20:37 +00:00
"Vladimir N. Oleynik" 676e95ea3d bb_mkdep release. speed up *3, clearing, more comments 2005-09-13 16:50:53 +00:00
Mike Frysinger 6943a9489e whitespace/syntax cleanups, dont mind me :p 2005-09-13 02:29:39 +00:00
Mike Frysinger 68071e46b1 touch up usage for swap utils 2005-09-13 02:26:24 +00:00
Rob Landley bc3d4a175f Cleanup patch from Tito. 2005-09-13 01:30:19 +00:00
Eric Andersen 5d38f5ba89 sysctl was seriously broken. And since in some cases 'CONFIG_SYSCTL'
could be included into application space via the kernel config option
of the same name, nasty compilation problems could result.
2005-09-12 21:42:48 +00:00
Eric Andersen 2c6b41812f Kunihiko IMAI writes:
We're using busybox and thank the authors.

I found a short buffer allocation at busybox/sysklod/syslod.c.  It
mis-declares length of filenames, seems to forget for '\0' or two
column numbered suffix of backup files (ex. messages.10).

Here is a patch for the problem.

Thanks.
2005-09-12 19:16:11 +00:00
"Vladimir N. Oleynik" b1fe462116 bb_mkdep speed up * 10! 2005-09-12 16:39:47 +00:00
"Vladimir N. Oleynik" 5e60dc4a20 new my scripts/mm_mkdep, dependences work now 2005-09-12 12:33:27 +00:00
Rob Landley ba50217281 Clean up memory allocation. 2005-09-11 23:45:28 +00:00
Rob Landley a7e14db495 This combines a patch from Bernhard Fischer (moving the clean of
scripts/config from distclean to clean) with a sed consolidation that's
been in my tree for a bit, and switching the GPL boilerplate to just point
at LICENSE.
2005-09-11 01:16:47 +00:00
Rob Landley b7128c6236 Cleanup patch by Bernhard Fischer, removing unnecessary includes of
getopt.h, whitespace changes, typos, etc.
2005-09-11 01:05:30 +00:00
Mike Frysinger db289b258d use CONFIG_BUFFER macros like cow suggested and shrink code size some more by using less variables and more gotos ;) 2005-09-10 04:10:18 +00:00
Rob Landley 98ea849623 Patch from Dirk Clemens so df doesn't run numbers together on drives >100gig. 2005-09-10 02:59:35 +00:00
Mike Frysinger a80b290e30 some tweaks by cow to shrink a little 2005-09-10 02:47:19 +00:00
Rob Landley 6b00d0d3ca Put the menu_is_visible test back because it avoids printing spurious
(albeit commented out) garbage.
2005-09-08 11:50:48 +00:00
Manuel Novoa III 415f6c9628 Rob, I don't know why you feel some unexplainable compulsion to get rid of
a meaningless warning.  But I do expect you preserve the coding style
and variable names when all you're doing is tweaking some of my code.

I repeat... do NOT change whitespace, variable names, or coding style in
any of my code simply to conform to your coding style.
2005-09-08 06:02:49 +00:00
Rob Landley ae32016fc9 A bit overdue... 2005-09-08 03:48:47 +00:00
Rob Landley 9f0e00fc61 Tito sent more size tweaks. 2005-09-08 03:27:06 +00:00
Rob Landley 230b411de8 Fix the warning by rewriting the function to be smaller and simpler.
I'd appreciate somebody on a __BIG_ENDIAN platform testing this out; I haven't
got the hardware...
2005-09-08 03:22:09 +00:00
Rob Landley 658d2cf986 Tito sent in a few patches converting instances of CONFIG_FEATURE_CLEAN_UP to
ENABLE_FEATURE_CLEAN_UP.
2005-09-08 03:11:58 +00:00
Paul Fox 02eb934b0f committing:
Summary      0000242: ash: read -t broken
this also implements -n and -s options to read.  (they're configured
together because most of their code is in common, and separating them
seemed silly.
2005-09-07 16:56:02 +00:00
Rob Landley a70aa86e25 Yeah, Linus is the original author of three of our apps, but A) he doesn't
work at transmeta anymore so that email's bogus, B) hands up everybody who
thinks emailing him about a problem in the busybox version of those apps
would be productive?
2005-09-07 07:12:19 +00:00
Rob Landley 20a825aed8 Fix warnings. 2005-09-07 07:04:56 +00:00
Rob Landley 90ca6b2878 This code exists to compensate for ancient broken build environments which,
as far as I can tell, are no longer relevant.  Modern busybox refuses to
build under libc5 (there's a specific test and #error for that), and
I'm not sure building against 2.1 kernel headers on Alpha was ever relevant.

I'm happy to put any of this back if anybody can point to a real need for it,
but if so we need to specifically document what environment is being
compensated for.  (And we should quarrantine the build environment code
into one place, anyway.  Maybe "quirks.h" for known compiler and
libc quirks?)
2005-09-07 06:39:02 +00:00
Rob Landley 14efdc58ce Don't comment warnings. Don't put #warnings about warnings. _FIX_ warnings.
This fixes the warning, and makes the binary smaller out of sheer pique.
(Yes, since Manuel did this one it's nice tight code that took several
attempts to shrink, but I was ticked.)

Add the start of a test for uniq; this is about the first 1/3 of the
tests we need for full susv3 coverage of uniq.
2005-09-07 04:18:36 +00:00
Mike Frysinger 99f61719cb Amir Shalem writes:
this patch fix syscall names mix-up in libb/syscalls.c
2005-09-06 21:53:21 +00:00
"Vladimir N. Oleynik" 45a8ed89c6 - sync traceroute with Slackware-10.1
(support -FIl -g gw -i if -z pt now).
- libbb/getopt_ulflags.c support bb_opt_complementally="x-x" as trigger now
2005-09-06 16:08:33 +00:00
"Vladimir N. Oleynik" 1443487c92 typo, thanks, Bernhard Fischer 2005-09-06 13:21:39 +00:00
Rob Landley 1283a150ae Whitespace-level changes. Replace s0,s1,e0,e1 with real variable names and
clean up whitespace and curly brackets a bit.  Resulting binary should be
identical.
2005-09-06 01:57:11 +00:00
Rob Landley 9955c45907 get_terminal_width_height.c was in there twice. 2005-09-05 18:42:18 +00:00
Rob Landley ecce943e25 Bernhard Fischer pointed out that CONFIG_FEATURE_MOUNT_FORCE no longer exists. 2005-09-05 17:52:47 +00:00
Rob Landley f6acb660ea Regarding 11330: when you fix a bug that the testsuite doesn't catch, add
a test case to the test suite.
2005-09-05 16:27:19 +00:00
"Vladimir N. Oleynik" d0c41a8519 destroy bug [0000381] 2005-09-05 15:50:56 +00:00
"Vladimir N. Oleynik" f087480da1 destroy bug [0000404] 2005-09-05 15:46:26 +00:00
"Vladimir N. Oleynik" a8c23aa795 - usage fresh bb_getopt_ulflags for ls -- very size reduce.
- small indent corrections
- remove unecessary malloc and free
2005-09-05 15:06:57 +00:00
"Vladimir N. Oleynik" 27421a1878 1) bb_opt_complementaly -> bb_opt_complementally
2) better support long options
3) new flag '!' for bb_opt_complementally: produce bb_show_usage() if BB_GETOPT_ERROR internally
2005-09-05 14:46:07 +00:00
"Vladimir N. Oleynik" bef14d7a87 1) sync with dash_0.5.2-7
2) but expand PS# as config option
3) correct kill error message again
4) remove show "line number" for interactive run (patch pending for dash)
2005-09-05 13:25:11 +00:00
"Vladimir N. Oleynik" 10a1fe6169 remove infinity loop ./busybox --help busybox 2005-09-05 11:25:27 +00:00
Rob Landley 8f99104362 The previous commit left confdata writing out:
CONFIG_NUMERIC_CONSTANT=

And on reading it back in, it would complain that '' was an invalid value for
that field.  I.E. "make allnoconfig && make" worked fine, but
"make allnoconfig && make menuconfig" barfed reading in the config file.

So now I have it write out "0" as the blank value.  (It's initialized to the
default value when the menu becomes visible anyway; I checked.)  That seems
to work.
2005-09-05 11:04:30 +00:00
Rob Landley d1fa5859d6 Now that "make sizes" is in, the faq should mention it... 2005-09-05 10:25:51 +00:00
Rob Landley dbaf97e463 Fix the warnings, and fix the following two obvious segfaults:
./busybox getopt -n one -n two woot
	./busybox getopt -o one -o two woot

This entire applet is still an enormous pile of garbage, which I can't clean
up because I really have no idea what it's for.  (Both "man getopt" and trying
it out on the command line a bit fail to enlighten me.  Reading the code, the
fact half of it seems to be special cases for bash vs tcsh does not fill me
with confidence.)
2005-09-05 06:16:53 +00:00
Rob Landley cc1669bcde Actually returning ret might be good. 2005-09-05 05:36:15 +00:00
Rob Landley 8a7a678b03 Fixes so "make allnoconfig" works again.
The configure system's save function edited out sub-menus that wouldn't be
displayed in the current configuration, meaning config.h wouldn't have #udef
entries for those symbols, meaning bb_config.h would have the relevant
ENABLE_ missing instead of defined to 0.  This broke the build.

So I fixed it, and then reorganized the applets.c and busybox.c to take
away the warnings this revealed (code that would be optimized out was making
calls to functions that hadn't been prototyped.  So I added an #else case
to those #ifdefs to #define the relevant functions to empty macros to
placate the warnings.

I also reorganized the applets.c code to make adding such an #else case less
of a pain (and make the need for prototyping go away by moving the functions
up before they were used, and generally wind up with fewer #ifdefs in
the code by putting all the logic in one place).  This resulted in a huge
seeming patch, when most if it just moves code from one place to another
without touching it...

Upside: make allyesconfig and make allnoconfig should both work now.
2005-09-05 04:13:33 +00:00
Rob Landley a1a1a9fa2c Remove trailing crud from busybox.tests. (Sleep deprivation strikes again...) 2005-09-04 11:13:10 +00:00
Rob Landley b766c39456 General cleanup of command line parsing to allow "busybox" to work as a prefix.
(I.E. any argv[0] that starts with "busybox" winds up in busybox_main().)

Added testing/busybox.tests which tests the following permutations:

./busybox
./busybox-suffix
./busybox cat
./busybox-suffix cat
./busybox --help
./busybox-suffix --help
./busybox --help cat
./busybox-suffix --help cat
./busybox --help unknown
./busybox-suffix --help unknown
./unknown

Also repair the test suite so ./runtest calls the ".tests" scripts properly.

Note: you can now go "busybox busybox busbox ls -l" and it'll take it.  The
new code is pretty generic.  I can block that if anybody can come up with a
good reason to...
2005-09-04 11:10:37 +00:00
Mike Frysinger 9754b91c16 touchup some grammar, formatting, and remove some outdated notes 2005-09-02 23:06:30 +00:00
Eric Andersen f46f1b4d8a update the verbage describing what is needed for developer access 2005-09-02 14:10:47 +00:00
Rob Landley 7f90ae436f This goes along with the new testsuite code... 2005-09-02 01:55:58 +00:00
Rob Landley 1689075c99 Working on a new test harness. Moved the sort tests into it. 2005-09-02 00:41:53 +00:00
Rob Landley babd3fbba6 Missing break was screwing up 'y//' command. Bug #248. 2005-09-02 00:10:06 +00:00
Rob Landley 92255d60b8 Fix for bug 383: attempting to "tar c /" would error out because stripping
trailing / turns that into an empty string.
2005-09-01 11:36:21 +00:00
Rob Landley 828548ab56 According to bug #63, crond is unhappy with crontab lines that don't end in a
newline, or lines that have trailing spaces.
2005-09-01 10:23:57 +00:00
Rob Landley 344ea471ef Tracking system but #4: php needs the environment variable SCRIPT_FILENAME. 2005-09-01 09:38:32 +00:00
Rob Landley f815469a76 Bernhard Fischer trimmed down dos2unix a bit. 2005-09-01 03:11:19 +00:00
Rob Landley 078bacf1e9 Patch -i support from Berhnard Fischer. 2005-09-01 03:02:23 +00:00
Rob Landley e0537f6194 Bernhard Fischer suggested that get_terminal_width_height() should return
the result of the ioctl so callers can tell if we have a tty.  (0 means
we have a tty, nonzero means the ioctl couldn't find size info and we
fake 80x24.  Really we should fake 80x25, but oh well...)
2005-09-01 02:57:45 +00:00
Rob Landley 37adefc670 Off by one error in max_leases sanity check. Bug 349, apparently. 2005-09-01 02:43:39 +00:00
Rob Landley ac692b2cf7 Bernhard Fischer sent a patch to make "make sizes" work when building in
another output directory.
2005-09-01 02:40:21 +00:00
Rob Landley 9139770764 Busybox should only multiplex based on argv[1] when it's called as "busybox".
Otherwise if you build busybox without a given applet you get the wrong error
message when you call it via a symlink to that applet.

(You also get the wrong behavior; it tries to use argv[1] as the command
name just like busybox does for _any_ unknown, and although I doubt
"echo rm -rf *" is common usage there's no upside and enough downside to
make me nervous.)

This fixes it.
2005-09-01 00:02:56 +00:00
Rob Landley 29ee76cb2b Anand Avati hit an integer overflow problem in our unzip code. 2005-08-31 22:03:15 +00:00
Rob Landley c8b8a2d0cf Don't comment warnings, _FIX_ warnings. (And putting in #warnings about
other warnings is just gross.)

On a side note, while I was there, I made the code slightly smaller.
2005-08-30 20:26:17 +00:00
Rob Landley c3386a4304 Why have a separate CONFIG_INIT_SWAPON when we already have CONFIG_SWAPONOFF? 2005-08-30 18:50:37 +00:00
Rob Landley 7a8f6792f3 Bug system entry #1 says that when busybox doesn't have swapoff,
init shouldn't call swapoff.
2005-08-30 18:17:05 +00:00
Rob Landley 9a643149de Amir Shalem found some bugs in the new mount code; unknown options didn't get
added to the list, and my assumption that nfsmount() actually called
mount() was incorrect (and I coded it wrong anyway; I hate having to touch
codepaths I can't personally test).
2005-08-30 17:07:49 +00:00
Rob Landley cc8885f6f3 Dirk Clemens pointed out how easy it is to support bzip2 compression, since we
shell out to an external program to handle gzip anyway...
2005-08-30 03:40:03 +00:00
Eric Andersen de55987667 point to busybox.net 2005-08-28 12:47:39 +00:00
Rob Landley d9f7165de1 Dumb little hack, "make sizes". Try it. 2005-08-28 08:24:21 +00:00
Mike Frysinger ddddb94f05 make sure __NF_sysfs exists before trying to use it 2005-08-27 18:19:01 +00:00
Mike Frysinger 038b076e55 some portability fixes by rmh in Bug 395 2005-08-27 18:18:06 +00:00
Rob Landley e1d9633e20 Bernhard Fischer submitted a couple of Makefile patches:
- Fix building out-of-tree
- remove duplicate rule in toplevel Makefile
- peruse make's builtin notion of `dirname $@'
2005-08-24 00:41:52 +00:00
Rob Landley a937640bff Remove something we did, not that I'm doing something, and add something we
haven't done.  Woo.
2005-08-23 23:08:17 +00:00
Rob Landley f4c684a1ef When compiling with FEATURE_MTAB_SUPPORT disabled, the call to erase_mtab()
can never be made because useMtab is initialized to 0, and all the other
assignments of that variable assign 0 to it.  Any compiler that can perform
simple constant propogation on local variables will optimize away if statements
testing against that variable, thus the call to erase_mtab() will never be
made.

When compiling for arm using gcc 3.3.3 with FEATURE_MTAB_SUPPORT disabled,
the linker complains that it can't find erase_mtab().  The arm optimizer isn't
exactly the brightest member of the family, and apparently needs to be hit over
the head with a hammer to get its' attention...
2005-08-23 20:03:17 +00:00
Rob Landley 6417564eeb Two FEATURE_CLEAN_UP patches from Shaun Jackman, closing filehandles. 2005-08-22 15:57:50 +00:00
Rob Landley d00b3a5e94 Bernhard Fischer provided a mountpoint(1) applet. This is apparently something
sysvinit provides, and which is used by the debian init scripts.
2005-08-20 05:07:08 +00:00
Rob Landley fc3f048f8f Announce busybox 1.01. 2005-08-17 01:55:58 +00:00
Mike Frysinger b8d004631a Tito (among others) writes: previous patch was wrong, please stop screwing things up 2005-08-17 01:20:10 +00:00
Eric Andersen 4306bb13f6 When doing 'make release' nuke the .svn directories, not the
CVS dirs (since they are no longer present)
2005-08-17 00:03:23 +00:00
Mike Frysinger 6ebbc7414e the () around isspace actually matters 2005-08-16 05:39:07 +00:00
Mike Frysinger 1eef0c4571 Bernhard Fischer says: use xmalloc() instead of malloc() 2005-08-16 05:32:42 +00:00
Mike Frysinger 71224980e1 Bernhard Fischer says: fix comment typo 2005-08-16 05:27:51 +00:00
Mike Frysinger c8e2de6e1b Bernhard Fischer writes: fix devfsd usage 2005-08-15 22:13:21 +00:00
Rob Landley de5fd23f25 If we goto singlemount, do _not_ try to continue through the loop we jumped
into.  (That means "mount -t ext2 /dev/thingy thingy" would segfault if
it failed instead of giving us an error message.)
2005-08-14 19:26:14 +00:00
Rob Landley 23246f39ed Patch from Stephane Billiart to improve ash error message. 2005-08-14 19:16:51 +00:00
Rob Landley 6e98521d68 Stephane Billiart noticed that the return code of the new mount was horked.
(Cleaned up the return code path to consistently use numbers so I don't keep
confusing EXIT_SUCCESS with TRUE and EXIT_FAILURE with FALSE...)
2005-08-14 18:46:34 +00:00
Rob Landley 58a651b2e5 Very minor tweak to tail. 2005-08-13 00:35:00 +00:00
Mike Frysinger f9bd87b0a7 make sure distclean punts include/bbconfigopts.h 2005-08-11 21:59:52 +00:00
Rob Landley 6a6798b8e4 Major rewrite of mount, umount, losetup. Untangled lots of code, shrunk
things down a bit, fixed a number of funky corner cases, added support for
several new features (things like mount --move, mount --bind, lazy unounts,
automatic detection of loop mounts, and so on).  Probably broke several
other things, but it's fixable.  (Bang on it, tell me what doesn't work for
you...)

Note: you no longer need to say "-o loop".  It does that for you when
necessary.

Still need to add "user mount" support, which involves making mount suid.  Not
too hard to do under the new infrastructure, just haven't done it yet...

The previous code had the following notes, that belong in the version
control comments:

- * 3/21/1999   Charles P. Wright <cpwright@cpwright.com>
- *             searches through fstab when -a is passed
- *             will try mounting stuff with all fses when passed -t auto
- *
- * 1999-04-17  Dave Cinege...Rewrote -t auto. Fixed ro mtab.
- *
- * 1999-10-07  Erik Andersen <andersen@codepoet.org>.
- *              Rewrite of a lot of code. Removed mtab usage (I plan on
- *              putting it back as a compile-time option some time),
- *              major adjustments to option parsing, and some serious
- *              dieting all around.
- *
- * 1999-11-06  mtab support is back - andersee
- *
- * 2000-01-12   Ben Collins <bcollins@debian.org>, Borrowed utils-linux's
- *              mount to add loop support.
- *
- * 2000-04-30  Dave Cinege <dcinege@psychosis.com>
- *             Rewrote fstab while loop and lower mount section. Can now do
- *             single mounts from fstab. Can override fstab options for single
- *             mount. Common mount_one call for single mounts and 'all'. Fixed
- *             mtab updating and stale entries. Removed 'remount' default.
- *
2005-08-10 20:35:54 +00:00
Paul Fox 0b62158475 implemented a builtin echo command in ash. moved the guts of the
echo applet into libbb, and now call bb_echo() from both echo.c
and ash.c
2005-08-09 19:38:05 +00:00
Paul Fox 3f11b1bf63 commiting:
0000025: vi-editing mode for ash
2005-08-04 19:04:46 +00:00
Paul Fox 8eeb655661 applying jim bauer's patch to eliminate modprobe's dependency
on /bin/sh.  bug #8.
     0000008: modprobe applet is dependent on having a shell
2005-08-04 18:33:36 +00:00
Rob Landley 157e8071be In bb_config.h, replace AUTOCONF_INCLUDED guard with the more reasonable and
obvious (and less side-effect prone in strange build environments) BB_CONFIG_H.

Yeah, I know Erik ripped it out of our copy of menuconfig (which is a good
thing), but that doesn't fix people whose headers have it inherited from
linux-kernel headers or old versions of uclibc, and Erik's fix could easily
get forgotten and reverted the next time we update menuconfig anyway...
2005-08-02 10:02:23 +00:00
Eric Andersen ff3a61b71d Do not define 'AUTOCONF_INCLUDED' 2005-08-02 00:59:44 +00:00
Paul Fox 4240364098 commiting:
0000028 03-16-05 patch: new setsid applet
2005-08-01 22:52:09 +00:00
Mike Frysinger f1dbd4a6f7 fix bbconfigopts.h depend 2005-08-01 20:49:32 +00:00
Mike Frysinger fcafa4bfc1 screw around with whitespace 2005-08-01 20:48:00 +00:00
Paul Fox b831753676 commiting:
0000073: Add option to inetd applet to run in foreground
this option was already there for uclinux -- this just exposes
it in the normal case as well.
2005-08-01 19:39:47 +00:00
Paul Fox 156dc41cbc commiting patch from bug 71:
0000071: patch: implement "--color" option for ls coloring control
2005-08-01 19:33:30 +00:00
Paul Fox fc2256a6ca applying patch for bug 72:
0000072: Add applet to redirect console output via ioctl(..., TIOCCONS)  
applet name changed to setconsole, since suse has a very similar
utility.  better to treat differences as bugs than invent a new command.
2005-08-01 18:12:30 +00:00
Paul Fox 41a72ecd19 applying patch from bug 24:
0000024 03-16-05 patch: allow init to set controlling tty
2005-08-01 16:43:13 +00:00
Paul Fox 79c142d938 new config display applet, from bug 46. i've changed the name
of the applet from "config" to "bbconfig", and renamed the
source filenames and symbols to match appropriately.
2005-08-01 16:04:40 +00:00
Paul Fox a39bba33c8 allow suppression of default client-id. fixes bug 000037. allows
busybox to match kernel and u-boot behavior with respect to client-id.
2005-08-01 14:31:13 +00:00
Mike Frysinger 9d6e0833bc patch by pkj in Bug 3 to not export all make variables 2005-07-31 22:50:17 +00:00
Mike Frysinger d84a35f649 patch by apgo in Bug 345 to not use ether_hostton() with uClibc 2005-07-31 22:49:12 +00:00
Mike Frysinger 15ca58648a patch by srowe in Bug 359 to fix fgrep aliasing 2005-07-31 22:41:05 +00:00
Mike Frysinger 66c37d1390 typecast to int 2005-07-31 22:22:20 +00:00
Mike Frysinger 2e3054f413 use socklen_t instead of size_t with socket related functions 2005-07-31 22:20:02 +00:00
Mike Frysinger 1c1655a301 move -s from LDFLAGS to STRIPCMD 2005-07-31 22:11:33 +00:00
Mike Frysinger 7e64db23d0 use defines instead of const integers 2005-07-31 22:09:33 +00:00
Mike Frysinger e11ff718ac shrink the flag setting by reversing the operation 2005-07-31 22:06:38 +00:00
Mike Frysinger 6f978dbacd eat leading whitespace with preprocessor 2005-07-31 21:05:19 +00:00
Mike Frysinger 08c20362f5 replace for loops with one function call 2005-07-31 20:51:58 +00:00
Rob Landley de7f9b7332 Ahem: add new faq entry to list at top of FAQ.html 2005-07-31 04:27:19 +00:00
Rob Landley c7a3e1be8f Fix "nm --size-sort" on the busybox binary and document how to make it work. 2005-07-31 04:25:00 +00:00
Mike Frysinger e70aa9de7e only declare do_swap if we need it 2005-07-30 09:43:58 +00:00
Mike Frysinger 223b887960 touchup syntax 2005-07-30 09:42:05 +00:00
Mike Frysinger 198ea3c86a cleanup the error message so we dont use glibcism of %m and cast a pointer to an int (bad on 64bit arches) 2005-07-30 09:29:10 +00:00
Mike Frysinger f28c7ec7e5 cleanup syntax 2005-07-30 09:24:49 +00:00
Mike Frysinger 0d3ca7289e tell people to ignore the dups/e0 warnings 2005-07-30 08:59:38 +00:00
Mike Frysinger cc428da83f punt unused variable 2005-07-30 08:58:19 +00:00
Mike Frysinger d6a2d41db2 tell people to ignore the save_name warning 2005-07-30 08:57:35 +00:00
Mike Frysinger 14445fd9a1 in order to make sure the INET6 prototypes are exported, we would have to include the libbb.h header file ... but then we have to worry about including too early/etc...
since simply defining the prototype in an internal header file doesnt hurt anyone, lets not worry about the header file crap and just always prototype the inet6 functions
2005-07-30 08:54:43 +00:00
Mike Frysinger b953134bba apgo in Bug 322 writes: kill off CONFIG_FEATURE_MTAB_FILENAME 2005-07-30 08:48:10 +00:00
Mike Frysinger 69024551bf rename the accept/reject names since accept overrides the accept() socket function 2005-07-30 07:30:26 +00:00
Mike Frysinger f7eaf5a012 apgo in Bug 351 says: punt parse_version_number since it is no longer used 2005-07-30 07:29:22 +00:00
Paul Fox bb9a0ad95a commiting fix from:
0000353: [PATCH] start-stop-daemon -q is not quiet
2005-07-29 14:58:09 +00:00
Mike Frysinger b3b756dab3 further refine check_gcc usage so it is only called the bare min number of times 2005-07-28 22:26:25 +00:00
Mike Frysinger c99e2c5f4c dont output anything when running in silent mode 2005-07-28 22:14:35 +00:00
Rob Landley 088ee4134b From Rich Paul:
I've noticed that when I compile busybox on my laptop, it compiles more
slowly than one would expect, and although it's a (more-or-less)
multiprocessor system and I use -j5, make never seems to run more than 
one job at a time.

I believe I have found the culprit:  each time a file is compiled, gcc
runs about 5 times.  This is because the $(check_gcc) macros and the
TARGET_ARCH macros are late binding.

The attached patch cuts the compilation time by 66%, from 1.5 minutes to
30 seconds.  Your mileage may very.  These statements have not been
evaluated by the FDA.
2005-07-28 19:38:52 +00:00
Rob Landley ef8f423e90 Erik pointed out that in the last try at the #ifdef cleanup
infrastructure, the compiler isn't smart enough to replace const static 
int with the constant, and allocates space for each set of them, 
bloating the executable something fierce.  Oops.

So now, we #define ENABLE_XXX to 0 or 1 for each CONFIG_XXX (which
is still there so the 1000+ #ifdef/#ifndef tests don't have to be
replaced wholesale).  Changed the test instance in networking/ifconfig.c 
to use this.
2005-07-28 19:36:33 +00:00
Paul Fox e5ba382b99 move the ifdef to after libbb.h include, so it can do some good. 2005-07-27 14:20:52 +00:00
Rob Landley 193c8c7383 #ifdef reduction infrastructure, based on an argument between Shaun Jackman,
Rob Landley, and others.

Currently CONFIG options are defined or undefined, so we chop out code with
#ifdefs, ala:
#ifdef CONFIG_THING
  stuff();
#endif

This creates a new header file, bb_config.h, which sets the CONFIG entry to 1
or 0, and lets us do:

  if(CONFIG_THING) stuff();

And let the compiler do dead code elimination to get rid of it.  (Note: #ifdef
will still work because for the 1 case it's a static const int, not a #define.)
2005-07-27 06:55:36 +00:00
Eric Andersen 77804ce53d The change in getty.c in Busybox 1.01 caused the /etc/issue file to not
be displayed unless CONFIG_FEATURE_UTMP is set.  This was not the intended
result.
2005-07-27 06:05:38 +00:00
Mike Frysinger 4d00896d05 use toplevel ARFLAGS and update default ARFLAGS to be quiet 2005-07-27 01:09:24 +00:00
Mike Frysinger 6fafa5aa9f 2005-04-05 Shaun Jackman <sjackman@gmail.com>
* libbb/printf.c: Check for __NEWLIB_H__ before __GLIBC__.
2005-07-26 23:05:03 +00:00
Mike Frysinger 03e827a422 2005-03-19 Shaun Jackman <sjackman@gmail.com>
* networking/ping.c (ping): Change the type of fromlen to socklen_t.
2005-07-26 23:00:59 +00:00
Mike Frysinger dbc049fda4 remove unused variable ret as reported by apgo in Bug 350 and touchup syntax along the way 2005-07-26 22:57:51 +00:00
Mike Frysinger 6e05312ba9 no longer used as reported by apgo in Bug 348 2005-07-26 22:51:57 +00:00
Mike Frysinger 726b2cb5da just punt all the f_frsize crap since not all linux headers support it Bug 346 2005-07-26 22:39:56 +00:00
Paul Fox 1429017968 ifdef all of loop.c with CONFIG_FEATURE_MOUNT_LOOP. won't
compile due to CONFIG_FEATURE_MOUNT_LOOP_MAX otherwise.  reported
by Stephane Billiart.
2005-07-22 19:58:32 +00:00
Paul Fox 37dd6247dd applying fix for:
0000093: Patch for dpkg - can't handle scripts
	      Attached patch is needed to fix dpkg's support for preinst,
	       postinst etc script files.
2005-07-22 13:17:41 +00:00
Paul Fox 7b86134032 remove duplicate check against chaddr. 2005-07-21 20:23:56 +00:00
Paul Fox 8de331def0 revert 10881, and refix by changing "if (vallen)" to "if (val)". this
is per the upstream fix for dash, in dash_0.5.2-6.diff.  thanks vodz, for
catching this.
2005-07-21 12:03:05 +00:00
Paul Fox 0840b76602 applying fixes from:
0000142: unzip enhancements
2005-07-20 20:26:49 +00:00
Paul Fox f2ddc05ee7 applying fix for:
0000026: poor man's "scriptable" telnet
2005-07-20 19:55:19 +00:00
Paul Fox 1d4c88c8a5 applying fix for:
0000271: [PATCH] tftp -g fails if a TFTP_ACK is lost
2005-07-20 19:49:15 +00:00
Paul Fox 4905434b8a applying fix for:
0000265: tail -f should keep following files even if they
                    were truncated
2005-07-20 19:46:32 +00:00
Paul Fox 982d35ffa2 applying fix for:
0000263: nc cannot use -e when initiating a tcp connection
    	to something else
2005-07-20 19:40:30 +00:00
Paul Fox 94ff9f1010 applying fix for:
0000262: tar -x doesn't believe it has reached the end of archive
2005-07-20 19:24:13 +00:00
Paul Fox 6f267f022f applying fix for:
0000261: Unsafe empty env var export in ash
2005-07-20 19:18:45 +00:00
Paul Fox 01f67987e0 applying fix for:
0000260: udhcpc doesn't validate client hardware address
2005-07-20 19:13:21 +00:00
Paul Fox 379ac89c30 applying patch from:
0000227: sort use wrong type for getopt return variable
2005-07-20 19:07:27 +00:00
Paul Fox 5dc0ceeb9e applying fix for:
0000203: 'ip route flush cache' not implemented
2005-07-20 19:01:05 +00:00
Paul Fox 77ee52333c applying fix for:
0000185: httpd infinite loop when piping to CGI script
2005-07-20 18:42:52 +00:00
Paul Fox 54690dc0b2 applyinf fix for:
0000155: variable expansion with braces in backticks in msh
2005-07-20 18:33:12 +00:00
Paul Fox c3850c83d9 applying fix from:
0000152: ash: quoting rules for local variables different to globals
2005-07-20 18:23:39 +00:00
Paul Fox 27cbffddd8 applying fix for:
0000143: sysklogd remote logging adds a space between facility and tag
2005-07-20 18:02:11 +00:00
Paul Fox 18433aadf6 applying fix for:
0000118: vi join command does not mark file as modified for certain lines.
2005-07-20 17:39:52 +00:00
Paul Fox 28069404a4 much more concise fix for bug #45. just align the packet... 2005-07-20 11:55:08 +00:00
Rob Landley 3c12ff7c89 If /tmp and /home were different partitions, then "mv /tmp/file /home/file"
would delete /home/file even if /tmp/file didn't exist.

This fixes that, although the logic of both mv and cp is a bit tangled and
should probably be untangled.
2005-07-20 00:45:40 +00:00
Paul Fox c337d29550 applying fix for:
0000117: Remove linefeed after overwrite prompt using cp -i
	  User input not on the same line as the prompt when about to
	  overwrite a file.
2005-07-19 21:31:05 +00:00
Paul Fox 146e83a60e applying fix from:
0000108: busyboxy/networking/ftpgetput.c not conforming to
                    RFC 959.  ftpget and ftpput send <LF> as EOL.
2005-07-19 21:26:57 +00:00
Paul Fox 127adc559f applying fix from;
0000092: looks like the initializer for .need_suid was missing.
2005-07-19 21:21:58 +00:00
Paul Fox deac371690 applying fix from:
0000088: inetd chargen stream does not generate the
	    characters as recommended in RFC 864
	    Chragen service is generating garbage characters.
2005-07-19 21:19:20 +00:00
Paul Fox 3f6f3174e9 applying fix from:
0000068: mount limited to max 8 loop devices (patch provided)  

(made minor wording change for config help message)
2005-07-19 20:55:37 +00:00
Paul Fox 0a92bbf349 applying fix from:
0000067: cp -p produces misleading error message
2005-07-19 20:47:33 +00:00
Paul Fox 574fee4f99 applying:
0000054: Tab completing filenames in ash causes SEGV
	Simple tab completion operations cause busybox (ash) to
	access illegal addresses.
2005-07-19 20:41:06 +00:00
Paul Fox b270315b21 applying fix for:
0000045: traceroute causes an alignment trap due to unaligned buffer on arm
2005-07-19 20:37:15 +00:00
Eric Andersen 90161c9213 Fixup makedevs to handle regular files, and also fix
it to properly update file permissions as specified.
2005-07-18 22:40:59 +00:00
Paul Fox 7b71d740b9 fix for "0000027: patch: nc will spin if stdin closed" 2005-07-18 22:23:16 +00:00
Paul Fox d13b90b9e8 allow both ^H and DEL to backspace in insert mode (bug #23) 2005-07-18 22:17:25 +00:00
Eric Andersen 0ef24c672a Fix vi so that error messages, insert mode messages, etc are
all actually displayed in the status line as expected
2005-07-18 10:32:59 +00:00
Eric Andersen 2ada89b60f a bit more polish 2005-07-18 09:45:35 +00:00
Eric Andersen 54e57da96a a bit of polish on makedevs 2005-07-18 09:42:37 +00:00
Eric Andersen 1b7058c653 the makedevs config option was pretty much totally broken 2005-07-18 09:36:49 +00:00
Eric Andersen e8614dbcd7 Fixup device table based makedevs so it actually works 2005-07-18 09:28:36 +00:00
Mike Frysinger 10427ab528 move var decls around a little to help gcc make smaller code 2005-07-06 05:00:48 +00:00
Mike Frysinger e548bdff96 2005-07-04 Shaun Jackman <sjackman@gmail.com>
* init/init.c: Do not include sys/mount.h.
        (message): Use O_NONBLOCK instead of O_NDELAY.
        (console_init): Ditto.
2005-07-06 04:46:14 +00:00
Mike Frysinger 95ef16528c 2005-07-05 Shaun Jackman <sjackman@gmail.com>
* init/Config.in (CONFIG_FEATURE_INIT_SWAPON): New option.
        * init/init.c (check_memory): Disable the swapon feature unless
        CONFIG_FEATURE_INIT_SWAPON is defined.
2005-07-06 04:39:08 +00:00
Mike Frysinger 72a4c33568 rename log var to log_console so we dont override internal gcc/glibc log func 2005-07-05 02:19:20 +00:00
Mike Frysinger b381009740 2005-06-30 Shaun Jackman <sjackman@gmail.com>
* loginutils/getty.c: (open_tty): Use dup2 instead of close/dup.
2005-07-01 01:29:44 +00:00
Mike Frysinger f413e241ba 2005-06-30 Shaun Jackman <sjackman@gmail.com>
* loginutils/getty.c: Include utmp.h only if
        CONFIG_FEATURE_U_W_TMP is defined.
        (getty_main): Use ISSUE only if it is defined.
2005-07-01 01:07:16 +00:00
Mike Frysinger 8deb686d2e Patch by jonlar in Bug 312 to split the U_W_TMP feature into sep UTMP and WTMP options 2005-07-01 01:04:32 +00:00
Mike Frysinger a87bb60809 patch by Shaun Jackman to combine dup/close funcs into dup2 2005-06-30 03:43:14 +00:00
Mike Frysinger 8804c6a3b7 dont use f_frsize unless linux-2.6.0 or better 2005-06-29 01:07:04 +00:00
Mike Frysinger fc379ba077 rip out all the non-linux code and ugly workarounds 2005-06-28 23:50:18 +00:00
Mike Frysinger 9e164578f2 tweak signed/unsigned char usage to avoid mismatches 2005-06-24 21:37:59 +00:00
Ned Ludd 778ee6da60 - remove extra/unneeded function call. testing svn 2005-06-24 03:47:57 +00:00
Eric Andersen 5043ea1986 Enabling runtime SUID/SGID configuration via /etc/busybox.conf
is not a very good default.  Better to default to having it off
and let people get the default behavior.  If they want to enable
/etc/busybox.conf they should explicitly ask for it.
2005-06-23 19:15:40 +00:00
Eric Andersen 576db48ef0 applets specified as _BB_SUID_ALWAYS in applets.h should also select
CONFIG_FEATURE_SUID to ensure proper behavior when installed.
2005-06-23 18:58:57 +00:00
Eric Andersen 3efa51d943 characters encoded as html should have a trailing semicolon
to be interpreted properly
2005-06-23 05:51:48 +00:00
Rob Landley 6eb1e41674 Rodney Radford submitted ipcs and ipcrm (system V IPC stuff). They could use
some more work to shrink them down.
2005-06-20 04:30:36 +00:00
Mike Frysinger df1eda82b9 Tito says: unify verbose/quiet flags 2005-06-17 02:13:57 +00:00
Mike Frysinger d0615ae73a Tito says: strip unused program_name
Vladimir N. Oleynik says: uname() can be replaced with get_kernel_revision()
2005-06-17 01:35:52 +00:00
Mike Frysinger d5826903c1 use xmalloc instead of malloc 2005-06-12 00:45:09 +00:00
Mike Frysinger 7fde8debc4 use malloc instead of xmalloc 2005-06-11 22:37:25 +00:00
Mike Frysinger d1a9d57bd6 use xmalloc() instead of malloc() 2005-06-11 22:25:27 +00:00
Mike Frysinger 2401ce5343 use xmalloc() and bb_perror_msg_and_die() 2005-06-11 22:24:15 +00:00
Rob Landley 958fa2a9cc Note that memory allocaiton needs to be cleaned up too. 2005-06-11 22:10:42 +00:00
Mike Frysinger 0b3fc1a9ac remove com_err.h includes 2005-06-11 20:29:02 +00:00
Mike Frysinger 16bc6159f3 DOS only crap 2005-06-11 20:28:47 +00:00
Mike Frysinger 6447ac0ef4 import initial fat mke2fs 2005-06-11 05:29:40 +00:00
Mike Frysinger 174808cedb import tune2fs support 2005-06-11 01:14:09 +00:00
Mike Frysinger a34f99930d fix signed/unsigned char pointers 2005-06-11 00:50:59 +00:00
Mike Frysinger 7ffce0c119 oops, we only want to affect local CFLAGS 2005-06-11 00:45:50 +00:00
Mike Frysinger d5624dcc0d initial fat tune2fs/findfs/e2label source 2005-06-11 00:40:20 +00:00
Mike Frysinger cae717e1f6 replace simple is_null func with a memcmp define 2005-06-11 00:36:04 +00:00
Mike Frysinger f3d28845f8 force including of e2fsbb.h and move the HAVE_* defines to it 2005-06-11 00:27:50 +00:00
Mike Frysinger e9903cfa0f move config.h requirement to the actual .depend target rather than the depend alias 2005-06-11 00:13:58 +00:00
Mike Frysinger e037622641 make sure clean removes objects in subdirs 2005-06-11 00:12:12 +00:00
Mike Frysinger f98f5e37cd need strings.h for ffs() 2005-06-11 00:11:46 +00:00
Mike Frysinger 0301ffab3d only define some variables if legacy EXT2FS_ENABLE_SWAPFS is enabled 2005-06-11 00:11:37 +00:00
Mike Frysinger 1f96c97984 replace simple functions with defines 2005-06-11 00:10:44 +00:00
Mike Frysinger 68497c0bd3 whitespace updates 2005-06-11 00:10:29 +00:00
Mike Frysinger 3968082df4 replace functions with defines 2005-06-11 00:09:46 +00:00
Mike Frysinger a1c9c66ac0 whitespace updates 2005-06-11 00:09:39 +00:00
Mike Frysinger e2c51a8dc6 whitespace updates 2005-06-11 00:09:24 +00:00
Mike Frysinger 85cffcc83d recode functions to shrink size 2005-06-11 00:08:50 +00:00
Mike Frysinger 942e137679 setup the HAVE_* defines 2005-06-11 00:03:13 +00:00
Eric Andersen 3d9256225f About time to just apply this and kill off the patches 2005-06-09 10:16:02 +00:00
Rob Landley 06813d066b Tito posted a devfsd error message fix. It's highly deprecated and will
presumably be removed eventually (use udev), but as long as it's in there.

Tito says:

The sense of this patch is to call:
read_config_file_err:
#ifdef CONFIG_DEVFSD_VERBOSE
    msg_logger(((optional ==  0 ) && (errno == ENOENT))? DIE : NO_DIE, LOG_ERR, "read config file: %s: %m\n", path);
#else
    if(optional ==  0  && errno == ENOENT)
        exit(EXIT_FAILURE);
#endif

just after the failure of the  call that set errno ( stat and fopen)
to avoid false error messages.
2005-06-07 03:47:00 +00:00
Rob Landley 16cd02e01e Clean up strings.c to use busybox's option processing. Bug 006, apparently. 2005-06-07 03:21:20 +00:00
Rob Landley ed830e8693 Patch from Dmitry Zakharov:
Charlie Brady wrote:
> Here's another awk parsing problem - unary post increment - pre is fine:
>
>bash-2.05a$ echo 2,3 | gawk -F , '{ $2++ }'
>bash-2.05a$ echo 2,3 | /tmp/busybox/busybox awk -F , '{ $2++ }'
>awk: cmd. line:1: Unexpected token
>
Here's a fix for this. There is another problem with constructions like 
"print (A+B) ++C", I don't
know whether somebody uses such constructions (fixing both these 
problems would require very
serious change in awk code).
2005-06-07 02:43:52 +00:00
Rob Landley f3133c4149 Thus spake Brenda J. Butler:
We were seeing some timeouts when getting files with the busybox tftp
client.

With tcpdump, we saw that the tftp client was receiving blocks and
ack'ing them, but the server was failing to receive the occasional
ack.

When that happened, the server would send the last block over again,
but the tftp client was expecting the next block.

This patch allows the client to recover from this situation
(it sends an ack for the repeat block but does not write it
to the local file).

I hope it meets your approval, please don't hesitate to send
me comments for improvement.

The patch is against "head" in svn, I tested it on an older version
of busybox in our environment.  It applied cleanly to the older
version.

Credit for this goes to my co-worker John McCarthy for finding
it and me for fixing it (assuming it works for everyone else too).

cheerio,
bjb
2005-06-07 02:40:39 +00:00
Rob Landley f7662da2af Shaun Jackman submitted a patch converting an allocation to use
CONFIG_RESERVE_BUFFER.  (Rob Landley removed an #ifdef, per discussion on
the list.)
2005-05-28 23:55:26 +00:00
Rob Landley 47bc802e9e Patch from Shaun Jackman to save a few bytes. 2005-05-28 23:36:38 +00:00
Rob Landley 0b1ff5a606 Tobias Krawutschke found a bug where the DHCP client would accept packets
with the wrong ARP address, meaning we could easily get somebody else's IP.
That is a bad thing, and this is the minimal two-line fix.
2005-05-26 05:25:12 +00:00
Paul Mundt 8b2d02ed34 Add readprofile applet support. 2005-05-20 17:22:18 +00:00
Rob Landley 93850a56b2 Patch from Colin Watson (mangled slightly by Rob Landley):
This patch implements the 'T' command in sed. This is a GNU extension,
but one of the udev hotplug scripts uses it, so I need it in busybox
anyway.

Includes a test; 'svn add testsuite/sed/sed-branch-conditional-inverted'
after applying.
2005-05-18 06:34:37 +00:00
Rob Landley 5797c7f0ef Doug Swarin pointed out a security bug in the -i option of sed.
While the permissions on the temp file are correct to prevent it from being 
maliciously mangled by passing strangers, (created with 600, opened O_EXCL, 
etc), the permissions on the _directory_ might not be, and we re-open the 
file to convert the filehandle to a FILE * (and automatically get an error 
message and exit if the directory's read-only or out of space or some such).

This opens a potential race condition if somebody's using dnotify on the 
directory, deletes/renames the tempfile, and drops a symlink or something 
there.  Somebody running sed -i as root in a world writeable directory could 
do damage.

I dug up notes on an earlier discussion where we looked at the security 
implications of this (unfortunately on the #uclibc channel rather than email; 
I don't have a transcript, just notes-to-self) which pointed out that if the 
permissions on the directory allow other people's files to be deleted/renamed 
then the original file is vulnerable to sabotage anyway.  However, there are 
two cases that discussion apparently didn't take into account:

1) Using another user's permissions to damage files in other directories you 
can't access (standard symlink attack).

2) Reading data another user couldn't otherwise access by having the new file 
belong to that other user.

This patch uses fdopen to convert the filehandle into a FILE *, rather than
reopening the file.
2005-05-18 05:56:16 +00:00
Mike Frysinger 1fb7961e08 use more busybox functions and remove redundant code 2005-05-16 22:35:59 +00:00
Mike Frysinger b2312e9901 make sure we add the local dir to the include path 2005-05-16 22:05:07 +00:00
Rob Landley 4079b00119 Tito pointed out I'd broken -t (argv[optind] can't be before getulflags),
and replaced the use of system() (and resulting security implications).
2005-05-15 01:32:47 +00:00
Rob Landley 9ea8836357 Add automatic umount support to eject command. Patch from Tito,
with tweaks from Mike Frysinger and Rob Landley.

Note: this will still fail to umount a path that contains an ' or \ character.
Is it worth the extra size to filter for that?
2005-05-14 00:46:18 +00:00
Mike Frysinger 1ece21bddd as Rob Landley pointed out, need to fix the 1 versus i typo in indexing 2005-05-13 03:09:20 +00:00
Mike Frysinger 0fb397e617 blah, forgot to save last time to fix whitespacing 2005-05-13 00:58:18 +00:00
Mike Frysinger 867a6080fe remove duplicated code and rework algorithms to end up with smaller code 2005-05-13 00:57:30 +00:00
Mike Frysinger dad4cf7e63 use a bunch of if statements since it is a few bytes smaller than a switch; also use bb_xfopen() instead of fopen() so comm doesnt segfault when given non-existant files :( 2005-05-12 22:50:12 +00:00
Mike Frysinger b3a6ec3e62 err, added 2 to the wrong var :) also touchup the option detection to shrink size 2005-05-12 22:41:13 +00:00
Mike Frysinger 3ba93c0438 fix segfault if user only specifies 1 file 2005-05-12 22:36:32 +00:00
Mike Frysinger 4d149205c3 update usage to match actual behavior 2005-05-12 22:36:07 +00:00
Mike Frysinger 0d605e98b2 fix whitespace/coding style 2005-05-12 22:25:41 +00:00
Mike Frysinger a84a512700 add missing comm.o rule 2005-05-12 22:23:15 +00:00
Mike Frysinger 5b300dd3a9 whitespace touchups 2005-05-12 22:22:50 +00:00
Eric Andersen 9cc7f3230a This makefile was a mess. Fix it to work as intended.
-Erik
2005-05-11 23:20:09 +00:00
Rob Landley 2acfd7bd26 Small comm implementatin from Rob Sullivan. Needed to build perl. 2005-05-11 23:12:49 +00:00
Mike Frysinger b662f0d58b import ether-wake applet by haveaniceday Bug 252 2005-05-11 03:59:53 +00:00
Mike Frysinger 348e84c202 change the hardcoded error constant (0x80000000UL) to a nice flexible define (BB_GETOPT_ERROR) 2005-05-11 00:39:03 +00:00
Mike Frysinger 55e2cf6533 import eject by Peter Willis / Tito Ragusa 2005-05-11 00:25:47 +00:00
Mike Frysinger fb6d22c96c now that mjn3 explained it to me, add documentation for the 3rd field in long opts 2005-05-11 00:02:39 +00:00
Rob Landley 00e76cb6b9 Patch from Jason Schoon to add IPV6 support to telnetd. Reworked by Rob
Landley to remove an #ifdef and move another one out of the flow of code.
2005-05-10 23:53:33 +00:00
Mike Frysinger e5d0bde697 add documentation for long options and touch up the current docs now that i actually understand how to use the function myself :) 2005-05-10 23:48:35 +00:00
Mike Frysinger 38a33f91c0 import more libs to prep for new e2fsprogs 2005-05-09 22:13:22 +00:00
Mike Frysinger 1fd98e039d import ext2fs lib to prep for new e2fsprogs 2005-05-09 22:10:42 +00:00
Mike Frysinger b32011943a no longer applies 2005-05-09 22:10:10 +00:00
Mike Frysinger 7a121e92eb import base_device.c for fsck 2005-05-09 22:09:00 +00:00
Mike Frysinger 8d929dab60 remove unused files 2005-05-09 21:58:36 +00:00
Mike Frysinger a88d52237b trim out useless defines and use some busybox funcs 2005-05-09 21:57:44 +00:00
Mike Frysinger 507d1f76e5 override nls P_() macro 2005-05-09 21:53:25 +00:00
Mike Frysinger ae38d65e95 abort if user passes -r or if they dont pass anything 2005-05-09 21:51:41 +00:00
Mike Frysinger 9dc93ac561 syntax/whitespace touchup 2005-05-09 21:51:15 +00:00
Rob Landley 540d3f60f3 Patch from Shaun Jackman:
> This patch modfies expr to use portable POSIX regex rather than BSD
> regex.
...
> This updated patch implements an anchored regex by checking that the
> match starts at offset 0.

More to the point, this patch uses the same regex that sed.c is already using
(opportunity to suck in less library code), and even building a dynamically
linked busybox with just expr the result is a slightly smaller binary (by 94
bytes, I dunno what nm --size-sort has to say about it because I didn't build
with debug info, since that changes the binary size a lot by disabling
optimization...)

Your mileage may vary.  Handle with caution.  Do not taunt happy fun ball.
2005-05-09 21:42:42 +00:00
Rob Landley b9dfb8c03f Manuel points out that if printf needs a flush to act like dprintf, the result
is bigger.  Revert last patch.
2005-05-07 17:45:38 +00:00
Rob Landley 0fcd9430ce This one's from me. Fix ash "standalone shell".
If we exec /proc/self/exe and only fall back to /bin/busybox if /proc isn't
there, then we have a reasonable chance of having the standalone shell work
even if busybox isn't installed in /bin on the system in question.

Still won't work in a chroot environment, but it's an improvement.
2005-05-07 08:27:34 +00:00
Rob Landley cce1ae2ce5 Shaun Jackman pointed out that dprintf(STDOUT_FILENO,...) is just a printf. 2005-05-07 07:53:16 +00:00
Mike Frysinger ea338fffb5 patch by Tito which uses a lot more busybox functions to reduce size nicely 2005-05-07 07:17:43 +00:00
Mike Frysinger 6adfd349e9 update e2p target to match condensed files 2005-05-07 07:16:54 +00:00
Mike Frysinger 548ffd49a3 patch by Tito which unifies common get/set functions into 1 get/set function and cuts down on the size used significantly :) 2005-05-07 07:14:41 +00:00
Mike Frysinger ba3a01f5e0 add/remove defines to handle more e2fsprogs 2005-05-07 06:49:54 +00:00
Mike Frysinger 9c85ecdef4 use shared busybox error messages to save a few bytes 2005-05-07 06:45:29 +00:00
Mike Frysinger 7dc7f402a7 make the exec (-e) an optional feature of netcat 2005-05-06 05:00:34 +00:00
Mike Frysinger 60a5c38a4b In bug 247, haveaniceday writes:
The option "-w secs" adds a timeout for writing.
2005-05-06 04:45:38 +00:00
Rob Landley 4f65360a5f Tweak the "pretty lsmod for 2.6" patch to be seperately selectable.
Patch from Takeharu Kato.
2005-05-04 23:55:06 +00:00
Rob Landley 918f2ab3d7 Revert the uptime() removal. Let the list sort it out... 2005-05-04 02:15:23 +00:00
Rob Landley 8b80c71d70 Patch from Shaun Jackman:
Replace uptime with time(NULL). time is more portable than uptime and
eliminates the need to define uptime, reducing code size slightly.
2005-05-04 00:38:15 +00:00
Rob Landley 15d3f7f143 Takeharu Kato's patch added 2.6 support to lsmod; this changes menuconfig
dependencies so 2.6 support depends on insmod or lsmod...
2005-05-04 00:25:49 +00:00
Rob Landley 627814bdc3 Takeharu Kato said:
I found that lsmod in busybox does not support linux-2.6.
I fix this issue(it is caused by changes of /proc/modules format).
If you use lsmod in busybox with kernel-2.6, please use this patch.
2005-05-03 22:34:03 +00:00
Rob Landley 0d38301d85 From: Shaun Jackman <sjackman@gmail.com>
To: busybox@mail.codepoet.org
  
Wrap sockaddr_in6 in a ifdef CONFIG_FEATURE_IPV6.
Include sys/types.h instead of asm/types.h.
Include netinet/if_ether.h instead of linux/if_ether.h
The ioctl request argument is an int, not an unsigned short.
2005-05-03 22:30:08 +00:00
Rob Landley 93983040c5 Shaun Jackman said:
This patch adds a CONFIG_FEATURE_CLEAN_UP stanza, and also adds an
ifdef around the SIOCGIFMAP call.
2005-05-03 21:30:26 +00:00
Rob Landley 60158cb93e A patch from Takeharu KATO to update/fix SE-Linux support. 2005-05-03 06:25:50 +00:00
Rob Landley 988a78c61c Add David Brownell as zcip maintainer. 2005-05-03 03:33:23 +00:00
Rob Landley e3752e56a4 Revert Tito's patch to zcip. My bad, David Brownell had objected and I missed
it...
2005-05-03 03:28:55 +00:00
Rob Landley 8445a9ff99 On Tuesday 19 April 2005 21:10, Tito wrote and today added:
> Hi,
> this is a first attempt of size optimization for zcip taking into account all
> the hints given so far on the list.
> I've applied just the more obvious busyboxifications so maybe it could be
> optimized more.
BTW: I've ripped out  a lot of debug code and changed c++ // comments to /* */
as both were rather confusing for a newbie like me. ;-) 
Sorry to the author for that.
I know that this makes mantaining the code easier, but I'm simple minded....
2005-05-01 00:22:03 +00:00
Rob Landley 6624daeb4d On Wednesday 13 April 2005 09:12 pm, Shaun Jackman wrote:
> This patch fixes a memory leak in hash_file by using the BUFFER macros
> instead of xmalloc. Please apply.
2005-04-30 05:11:57 +00:00
Rob Landley ad8071f582 David Brownell submitted a new applet, zcip, based on RFC 3927. This is
version 0418b.  It compiled.
2005-04-30 03:49:37 +00:00
Rob Landley 55b1efc6de New help text for Matthew S. Wood's "ln" update adding -b and -d. 2005-04-29 22:14:28 +00:00
Rob Landley 3071e2fda3 Patch from Matthew S. Wood:
> The following patch adds support for the -S and -b flags to `ln'.  These
> flags [especially -b] are used extensively in Debian pre and post
> installation scripts.

Comments from Vladimir Oleynik influenced the final patch, and I also ripped
out the in-file changelog since it belongs here.  At the time, it said:

/* Apr 15, 2004      Matthew S. Wood    (mwood@realmsys.com)
 *
 * Implement '-b' (backup) flag.
 * Implement '-S' (backup suffix) flag.
 *
 *
 * Mar 16, 2003      Manuel Novoa III   (mjn3@codepoet.org)
 *
 * Fixed bug involving -n option.  Essentially, -n was always in effect.
 */
2005-04-29 22:13:04 +00:00
Rob Landley fdc4c203e5 On Wednesday 27 April 2005 05:23 am, Patrick Huesmann wrote:
> This is really confusing for users who don't know all details of the
> *nix file permission system.
> Today, I changed my busybox system to use CONFIG_FEATURE_SUID_CONFIG.
> After fighting with the file permissions for hours, I decided that
> updating the documentation might be a good idea.
2005-04-29 19:48:29 +00:00
Eric Andersen 70a5a1abde Do not attempt to free() the application's environment, which is was
not dynamically allocated.  Instead, use a private variable to store
the environment array, which is used when we exec applications.
2005-04-27 11:44:11 +00:00
Eric Andersen fef32b570b Correct errors preventing busybox tar from working properly,
fixing bug http://bugs.uclibc.org/view.php?id=231
2005-04-27 10:51:38 +00:00
Mike Frysinger edb3fbc305 fix stupid build mistake i made earlier as pointed out by psm 2005-04-26 00:43:19 +00:00
Mike Frysinger d6a8f5f0d0 use a generic error message 2005-04-25 05:27:12 +00:00
Mike Frysinger c238a97a9e use asprintf in place of malloc/sprintf as suggested by solar 2005-04-25 05:24:35 +00:00
Mike Frysinger 7eb6457c4c moved to e2fsprogs too 2005-04-25 05:00:33 +00:00
Mike Frysinger d2a64d2fc2 bbify to shrink size 2005-04-25 04:10:35 +00:00
Mike Frysinger 560047ce86 use busybox funcs to make smaller 2005-04-24 05:39:52 +00:00
Mike Frysinger cf131bb328 new version of ed taken from sash 2005-04-24 05:18:00 +00:00
Mike Frysinger d89e5e6450 svn didnt auto add these ... 2005-04-24 05:15:12 +00:00
Mike Frysinger d89e629e52 add new subdir for e2fsprogs 2005-04-24 05:07:59 +00:00
Mike Frysinger 408ae211ce rework human_fstype to cut down size 2005-04-24 04:11:44 +00:00
Mike Frysinger f06c494636 rework options to get rid of extra variables 2005-04-24 03:53:12 +00:00
Mike Frysinger 058e740d1e fix whitespace usage, fix un-escaped quotes in a bunch of examples, and standardize a bunch of trivial/full usage statements (no trailing newline in either, and when listing options, dont append a . each time) 2005-04-23 07:00:33 +00:00
Mike Frysinger 82e6c0b3db fix inconsistent whitespace 2005-04-23 06:35:06 +00:00
Mike Frysinger 964a368e5c remove extra whitespace 2005-04-23 06:28:42 +00:00
Mike Frysinger 9b5f71ec02 stat implementation based upon coreutils 2005-04-23 06:26:38 +00:00
Mike Frysinger 84ab267e22 patch for a very alpha busybox ed 2005-04-23 01:50:55 +00:00
Mike Frysinger 6b05b0ce93 whitespace fix 2005-04-23 01:46:55 +00:00
Mike Frysinger 3b59821cbd remove lsattr/chattr to prepare for a top level e2fsprogs dir with more stuff in it 2005-04-23 01:45:08 +00:00
Mike Frysinger 0ea3a6f660 update example to use bb_ prefixed names and remove old note about config.h (since the header is generated automatically now) 2005-04-23 01:43:45 +00:00
Mike Frysinger 19d7021d99 add comments about ignoring some warnings which are OK 2005-04-23 01:43:07 +00:00
Mike Frysinger 7202e00b4c remove unused variable and declare writepid inline 2005-04-23 01:42:29 +00:00
Mike Frysinger 5b2e27137d cast the time pointer so gcc stops warning over nothing 2005-04-23 01:42:03 +00:00
Mike Frysinger 5cfa5ef6f3 use bb_fflush_stdout_and_exit instead of exit 2005-04-23 01:41:51 +00:00
Mike Frysinger de9f1f757a import lsattr and chattr from e2fsprogs 2005-04-22 02:33:37 +00:00
Mike Frysinger 2c12d435e5 output busybox help to stdout, not stderr 2005-04-22 02:19:01 +00:00
Mike Frysinger 95d3c4503f printenv / sum defines 2005-04-21 23:29:24 +00:00
Mike Frysinger 4a2117027f grab sum from coreutils, clean it up, and make it busybox happy 2005-04-21 23:24:46 +00:00
Mike Frysinger 6d1d2e59bf add a printenv implementation 2005-04-21 23:23:13 +00:00
Mike Frysinger c0bc9652fd fix whitespace 2005-04-21 23:19:57 +00:00
Mike Frysinger 78333d0452 fix typos 2005-04-21 23:17:57 +00:00
Mike Frysinger f547d672cf fix typoe (buildddir -> builddir) 2005-04-21 01:49:05 +00:00
Mike Frysinger 5c9ed9f41a fix printf warning 2005-04-20 00:28:44 +00:00
Mike Frysinger 618d62f593 fix whitespace 2005-04-19 23:50:22 +00:00
Peter Kjellerstedt bae38db8e4 Updated to match trunk/uClibc/extra/config as of r10132, and thus
Linux 2.6.11.
2005-04-19 09:55:06 +00:00
Mike Frysinger 2bf88a891f In Bug 5, Tito writes:
This is a first attempt to improve the comments of getopt_ulflags.c.
Maybe under some aspects the text could be refined, but so
far it is already usable and should help people who "avoided getopt_ulflags as the pest" to understand how it works.

This patch was created with the help of
Vodz, the author of the code, who explained me patiently
how getopt_ulflags works
and with the help of
Paul Fox, who corrected my broken english.

So thanks and merits should go to them also.
2005-04-18 22:42:58 +00:00
Mike Frysinger 91d8f0e892 touchups as suggested by Vladimir N. Oleynik 2005-04-18 18:52:15 +00:00
Mike Frysinger ef614ecca6 err, use name attr of a tag, not href 2005-04-17 07:25:32 +00:00
Mike Frysinger fa69f110d9 import fakeidentd module started by Thomas Lundquist 2005-04-17 07:24:19 +00:00
Mike Frysinger 77dbe738d2 add a new list of external tiny utilities 2005-04-17 04:32:22 +00:00
Eric Andersen 14f5c8d764 Patch from Bernhard Fischer to make a bunch of symbols static
which were otherwise cluttering the global namespace.
2005-04-16 19:39:00 +00:00
Mike Frysinger a77b4f3970 jfb2 writes in Bug 119:
The init applet will restart (re-exec) itsself when it
receives a SIGHUP. However, just before it enters its
main loop, it resets SIGHUP to either re-load the inittab
(or ignore it if no inittab is used). Thus preventing
the re-exec option from being triggerable.

This patch adds a signal handler for SIGQUIT for init that
always causes init to re-exec itsself (along with killing
anything else that might be still running).
2005-04-16 08:21:34 +00:00
Eric Andersen 63e5e7bf0e Fix broken macro 2005-04-16 08:04:31 +00:00
Eric Andersen 42e3b00ae5 Only define a local environ when not using the prototype from unistd.h 2005-04-16 08:02:15 +00:00
Eric Andersen 451c0d2828 Rework to fix http://bugs.uclibc.org/view.php?id=107 2005-04-16 07:46:53 +00:00
Eric Andersen 3cd1986195 Add bb_msg_read_error 2005-04-16 07:42:35 +00:00
Mike Frysinger 5ba5f4d2e7 In Bug 78, shortkey points out:
If you run `grep -h . file1 file2 file3 ...`, the output is not prefixed 
with the filename.  If you run `grep -h . file1` however, the filename 
will incorrectly prefix the output.
2005-04-16 04:56:11 +00:00
Mike Frysinger b31566ef32 minor style touchups 2005-04-16 04:48:48 +00:00
Mike Frysinger 4e5936ef95 In Bug 208, bernhardf writes:
On machines with only ANSI compliant compilers, not explitily delcaring
an empty parameter list 'void' causes failure.
2005-04-16 04:30:38 +00:00
Mike Frysinger 5c63a72968 In Bug 207, bernhardf writes:
proper escape strings in usage.h
2005-04-16 04:23:58 +00:00
Mike Frysinger 3cc01a80a3 In Bug 209, bernhardf writes:
struct named {
    named_field: init,
};
appear to be depraced by now; rather use C{99} format as in
struct named {
    .named_field = init,
};
2005-04-16 04:17:39 +00:00
Mike Frysinger a9ae74d25b bernhardf reports with Bug 210:
For certain non-gcc compilers, alloca_h is defined (included) but there, 
no alloca() is declared.  Fallback to malloc if _ALLOCA_H is defined but 
still, there is no alloca() in the included _ALLOCA_H.
2005-04-16 04:06:14 +00:00
Eric Andersen afe023d136 Use a sane VEOL setting 2005-04-14 20:48:58 +00:00
Mike Frysinger 2ed05ab146 fake out support for POSIX -H and -L options since busybox cp dereferences everything by default 2005-04-14 02:52:50 +00:00
Mike Frysinger 75ac42b1ae add aliases == and [[ for = and [ to support more bash scripts 2005-04-14 02:49:22 +00:00
Peter Kjellerstedt c089ccdb44 Removed the incorrect and confusing facility argument specified with
openlog() as the correct facility will be specified with syslog()
anyway.
2005-04-06 10:56:57 +00:00
Eric Andersen 3603f79ce5 Point to osuosl 2005-03-31 18:15:42 +00:00
Peter Kjellerstedt 540769d566 Corrected the list of section names in add_ksymoops_symbols() so
that the bss and sbss sections can be correctly identified.
2005-03-30 16:36:40 +00:00
Mike Frysinger 354b527e03 amd64 is rela, not rel 2005-03-30 06:29:41 +00:00
Mike Frysinger a36ac0db67 Shaun Jackman writes: Fix typo. Use __NR_umount2 instead of __NR_pivot_root. 2005-03-04 01:34:23 +00:00
Mike Frysinger dcc40b7ecc Shaun Jackman writes: Newlib uses both __getopt_initialized and optind to track initialization of getopt() 2005-03-04 01:33:17 +00:00
Mike Frysinger 9b9e5479e8 add some more comments 2005-03-04 01:27:18 +00:00
Mike Frysinger 3b05b80cd7 newlib fixe from Shaun Jackman 2005-03-04 01:10:56 +00:00
Mike Frysinger ca1b6fc745 newlib fixe from Shaun Jackman 2005-03-04 01:09:43 +00:00
Manuel Novoa III df7bfb433e Bandaid to make "gzip file1 file2 ..." set the decompression lengths correctly
in the 2nd and later headers.  But this and gunzip really need to be rewritten.
2005-03-02 04:10:46 +00:00
Manuel Novoa III 0d8c652c46 When filling the bit buffer, gzip decompression apparently never checked for end of file, causing it to hang on corrupted input. 2005-03-01 19:29:29 +00:00
Eric Andersen 6ddc0d7f6b Update buildroot pointers 2005-02-21 22:04:21 +00:00
Eric Andersen b413a7009e remove whitespace 2005-02-13 22:20:35 +00:00
Eric Andersen 5bf4658dea remove whitespace 2005-02-13 22:17:44 +00:00
Eric Andersen bcf27247d1 Remove whitespace 2005-02-13 22:15:59 +00:00
Manuel Novoa III 2c511609c4 Add 'nice' and replace 'renice' with a new implementation. 2005-02-13 20:14:05 +00:00
Eric Andersen d2fe81706c Takeharu KATO writes:
Hi,

I found that gcc in cvs (HEAD in 2005/02/11) reject the gzip source
in the busybox.

This is caused by changing gcc's error handling behavior(
The gcc check the function prototype more strictly).

I show the compilation log as follow:
-- compilation log

-- compilation log
To fix the problem, apply the patch which is attached with this
mail.

Please take a look the patch and apply the patch into svn repository.
2005-02-11 19:06:51 +00:00
Ned Ludd d1e3cbdb5a - no need to check if JOBS is defined. Config.in ensures it. 2005-02-10 00:44:31 +00:00
Ned Ludd 2123b7cded - add ash read -t timeout support. initial code provided by Tim Yamin on Oct/21/2004 on the busybox mailing list. Edited his code a little to keep syntax highlighers happy and make it optional when CONFIG_ASH_TIMEOUT is defined 2005-02-09 21:07:23 +00:00
Eric Andersen 8063d5ca25 fix typo 2005-02-09 18:25:10 +00:00
Eric Andersen fdab4b1917 update 2005-02-09 06:44:36 +00:00
Eric Andersen 0762364c59 Cut-n-paste strikes again 2005-02-09 06:41:13 +00:00
Eric Andersen 6047ae3379 Remove mention of CVS and instead point to Subversion 2005-02-09 03:52:46 +00:00
Eric Andersen ff4b924d20 Update the bug submission stuff to point to bugs.busybox.net 2005-01-31 13:05:02 +00:00
Rob Landley 16b8579f53 Add me as sort maintainer. 2005-01-24 07:03:37 +00:00
Rob Landley c0dedd05e8 Sort rewrite to be SUSv3 compliant. New config option, updated help, and
a couple of infrastructure bits.
2005-01-24 07:00:02 +00:00
Rob Landley f4bb212d6c Much bigger to-do list. 2005-01-24 06:56:24 +00:00
Eric Andersen bc321653d1 fix spelling 2005-01-14 17:08:13 +00:00
Eric Andersen 75a7e195ff minor doc cleanup 2005-01-13 17:23:28 +00:00
Eric Andersen 7d1b3d8685 Mention the new bug tracking system 2005-01-13 17:15:34 +00:00
Mike Frysinger 6077d90c26 cp: make -P a synonym for -d 2005-01-07 00:56:47 +00:00
Eric Andersen 1e4dc96d61 Dear andersen:
Is the change on libbb/loop.c which you commited in 2005/1/3 effective
really?

The __GLIBC__ macro and __UCLIBC__ macro are defined in
feature.h in glibc source, so the change may not be effective.
If you want to check this with __GLIBC__, feature.h header is needed.

Some architectures(e.g. PPC series) need to include linux/posix_types.h
in stead of asm/posix_types.h, so the patch which is attached with
this mail include <linux/posix_types.h>.
2005-01-04 20:37:55 +00:00
Eric Andersen 1271dbb860 perhaps a better fix 2005-01-03 05:50:01 +00:00
Mike Frysinger 63654c1b08 alpha/parisc support 2004-12-26 09:13:32 +00:00
Eric Andersen 6feb2002f0 fix typo 2004-12-20 18:10:03 +00:00
Rob Landley ec4f3d95e7 Minor in-passing crapectomy. 2004-12-17 05:23:36 +00:00
Rob Landley 861f0145d3 Workaround for uClibc-specific header problem described here:
http://www.busybox.net/lists/busybox/2004-December/013276.html

Rob
2004-12-09 23:12:00 +00:00
Ned Ludd c6fbed5dba - CONFIG_FEATURE_READLINK_FOLLOW readlink -f patch from Colin Watson <cjwatson@debian.org> on busybox mailing list 08/11/04 2004-12-08 16:47:28 +00:00
Mike Frysinger d824853de3 merge from udhcp module 2004-12-06 14:59:45 +00:00
Rob Landley dcc286607c Hiroshi found another bug. Currently sed's $ triggers at end of every file,
and with multiple files SuSv3 says it should only trigger at the end of the
LAST file.

The trivial fix I tried first broke if the last file is empty.  Fixing this
properly required restructuring things to create a file list (actually a
FILE * list), and then processing it all in one go.  (There's probably a
smaller way to do this, merging with append_list perhaps.  But let's get
the behavior correct first.)

Note that editing files in place (-i) needs the _old_ behavior, with $
triggering at the end of each file.

Here's a test of all the things this patch fixed.  gnu and busybox seds produce
the same results with this patch, and different without it.

echo -n -e "1one\n1two\n1three" > ../test1
echo -n > ../test2
echo -e "3one\n3two\n3three" > ../test3
sed -n "$ p" ../test1 ../test2 ../test3
sed -n "$ p" ../test1 ../test2
sed -i -n "$ p" ../test1 ../test2 ../test3
2004-11-25 07:21:47 +00:00
Rob Landley a8b98d63e7 Don't document compiler warnings. _FIX_ compiler warnings. 2004-11-16 12:07:04 +00:00
Peter Kjellerstedt 88da3ef506 Correct the install-hardlinks target the same way as was already done
for the install target.
2004-11-02 09:05:22 +00:00
Rob Landley 92271e5a0d Alright, I guess I should be in this too... 2004-10-30 07:04:10 +00:00
Rob Landley ce4f0e982b Hiroshi Ito found some bugs. The 'c' command (cut and paste) was hardwired
to not put a newline at the end (which was backwards, it should have been
hardwired _to_ put a newline at the end, whether or not the input line
ended with a newline).  Test case for that:

echo | sed -e '$ctest'

And then this would segfault:

echo | sed -e 'g'

Because pattern_space got freed but the dead pointer was only overwritten
in an if statement that didn't trigger if the hold space was empty.  Oops.

While debugging it, I found out that the hold space is persistent between
multiple input files, so I promoted it to a global and added it to the
memory cleanup.  The relevant test case (to compare with That Other Sed) is:

echo -n woo > woo
sed -e h -e g woo
echo "fish" | sed -e '/woo/h' -e "izap" -e 's/woo/thingy/' -e '/fish/g' woo -

And somebody gratuitously stuck in a c99 int8_t type for something that's just
a flag, so I grouped the darn ints.
2004-10-30 06:54:19 +00:00
Eric Andersen 332c472865 1.00 is stable 2004-10-27 02:39:46 +00:00
Eric Andersen 5f9a422cfa mention scratchbox and openembedded 2004-10-18 06:31:18 +00:00
Eric Andersen 6302486ce6 egor duda writes:
egor duda wrote:
>Ok, here's an updated patch.
>'make check' should work now, and one make creates Makefile in build
>directory, so one can run 'make' in build directory after that.

ahem. It looks like i'm slightly late with it but... Here's a little
addition to make 'make O=/some/where PREFIX=/some/where/else install'
work. Sorry for delay :(

egor
2004-10-13 17:45:57 +00:00
725 changed files with 76834 additions and 29232 deletions

No files matched your search

-7
View File
@@ -1,7 +0,0 @@
busybox
busybox.links
_install
.config
.menuconfig.log
.config.cmd
.config.old
+49 -9
View File
@@ -2,12 +2,15 @@ List of the authors of code contained in BusyBox.
If you have code in BusyBox, you should be listed here. If you should be
listed, or the description of what you have done needs more detail, or is
incorect, _please_ let me know.
incorrect, _please_ let me know.
-Erik
-----------
Peter Willis <psyphreak@phreaker.net>
eject
Emanuele Aina <emanuele.aina@tiscali.it>
run-parts
@@ -23,12 +26,21 @@ Laurence Anderson <l.d.anderson@warwick.ac.uk>
Jeff Angielski <jeff@theptrgroup.com>
ftpput, ftpget
Enrik Berkhan <Enrik.Berkhan@inka.de>
setconsole
Jim Bauer <jfbauer@nfr.com>
modprobe shell dependency
Edward Betts <edward@debian.org>
expr, hostid, logname, whoami
John Beppu <beppu@codepoet.org>
du, nslookup, sort
David Brownell <dbrownell@users.sourceforge.net>
zcip
Brian Candler <B.Candler@pobox.com>
tiny-ls(ls)
@@ -69,6 +81,14 @@ Daniel Jacobowitz <dan@debian.org>
Matt Kraai <kraai@alumni.cmu.edu>
documentation, bugfixes, test suite
Rob Landley <rob@landley.net>
Became busybox maintainer in 2006.
sed (major rewrite in 2003, and I now maintain the thing)
bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result)
sort (more or less from scratch rewrite in 2004, I now maintain it)
mount (rewrite in 2005, I maintain the new one)
Stephan Linz <linz@li-pro.net>
ipcalc, Red Hat equivalence
@@ -76,13 +96,14 @@ John Lombardo <john@deltanet.com>
tr
Glenn McGrath <bug1@iinet.net.au>
Common unarchving code and unarchiving applets, ifupdown, ftpgetput,
nameif, sed, patch, fold, install, uudecode.
Various bugfixes, review and apply numerous patches.
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
nameif, sed, patch, fold, install, uudecode.
Various bugfixes, review and apply numerous patches.
Manuel Novoa III <mjn3@codepoet.org>
cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes,
mesg, vconfig, make_directory, parse_mode, dirname, mode_string,
mesg, vconfig, nice, renice,
make_directory, parse_mode, dirname, mode_string,
get_last_path_component, simplify_path, and a number trivial libbb routines
also bug fixes, partial rewrites, and size optimizations in
@@ -91,8 +112,9 @@ Manuel Novoa III <mjn3@codepoet.org>
interface, dutmp, ifconfig, route
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit; xargs(current), httpd(current);
ports: ash, crond, fdisk, inetd, stty, traceroute, top;
cmdedit; bb_mkdep, xargs(current), httpd(current);
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
top;
locale, various fixes
and irreconcilable critic of everything not perfect.
@@ -100,6 +122,9 @@ Bruce Perens <bruce@pixar.com>
Original author of BusyBox in 1995, 1996. Some of his code can
still be found hiding here and there...
Rodney Radford <rradford@mindspring.com>
ipcs, ipcrm
Tim Riker <Tim@Rikers.org>
bug fixes, member of fan club
@@ -115,7 +140,10 @@ Pavel Roskin <proski@gnu.org>
Gyepi Sam <gyepi@praxis-sw.com>
Remote logging feature for syslogd
Linus Torvalds <torvalds@transmeta.com>
Rob Sullivan <cogito.ergo.cogito@gmail.com>
comm
Linus Torvalds
mkswap, fsck.minix, mkfs.minix
Mark Whitley <markw@codepoet.org>
@@ -129,5 +157,17 @@ Enrique Zanardi <ezanardi@ull.es>
tarcat (since removed), loadkmap, various fixes, Debian maintenance
Tito Ragusa <farmatito@tiscali.it>
devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm and fdformat.
devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm,
fdformat, lsattr, chattr, id and eject.
Paul Fox <pgf@foxharp.boston.ma.us>
vi editing mode for ash, various other patches/fixes
Roberto A. Foglietta <me@roberto.foglietta.name>
port: dnsd
Bernhard Fischer <rep.nop@aon.at>
misc
Mike Frysinger <vapier@gentoo.org>
initial e2fsprogs, printenv, setarch, sum, misc
-1381
View File
File diff suppressed because it is too large. Load diff
+159 -41
View File
@@ -9,6 +9,8 @@ config HAVE_DOT_CONFIG
bool
default y
menu "Busybox Settings"
menu "General Configuration"
choice
@@ -80,10 +82,12 @@ config CONFIG_FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
help
As a size optimization, busybox by default does not cleanup memory
that is dynamically allocated or close files before exiting. This
saves space and is usually not needed since the OS will clean up for
us. Don't enable this unless you have a really good reason to clean
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
space since the OS will clean up for us, but it can confuse debuggers
like valgrind, which report tons of memory and resource leaks.
Don't enable this unless you have a really good reason to clean
things up manually.
config CONFIG_FEATURE_SUID
@@ -94,14 +98,14 @@ config CONFIG_FEATURE_SUID
config CONFIG_FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default y if CONFIG_FEATURE_SUID
default n if CONFIG_FEATURE_SUID
depends on CONFIG_FEATURE_SUID
help
Allow the SUID / SGID state of an applet to be determined runtime by
checking /etc/busybox.conf. The format of this file is as follows:
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
An example might help:
[SUID]
@@ -113,6 +117,13 @@ config CONFIG_FEATURE_SUID_CONFIG
cp = --- # disable applet cp for everyone
The file has to be owned by user root, group root and has to be
writeable only by root:
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
The busybox executable has to be owned by user root, group
root and has to be setuid root for this to work:
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
Robert 'sandman' Griebl has more information here:
<url: http://www.softforge.de/bb/suid.html >.
@@ -128,14 +139,19 @@ config CONFIG_SELINUX
bool "Support NSA Security Enhanced Linux"
default n
help
Enable support for SE Linux in applets ls, ps, and id. Also provide
the option of compiling in SE Linux applets.
Enable support for SELinux in applets ls, ps, and id. Also provide
the option of compiling in SELinux applets.
If you do not have a complete SE Linux Full Userland installed, this
stuff will not compile. Go visit
If you do not have a complete SELinux userland installed, this stuff
will not compile. Go visit
http://www.nsa.gov/selinux/index.html
to download the necessary stuff to allow busybox to compile with this
option enabled.
to download the necessary stuff to allow busybox to compile with
this option enabled. Specifially, libselinux 1.28 or better is
directly required by busybox. If the installation is located in a
non-standard directory, provide it by invoking make as follows:
CFLAGS=-I<libselinux-include-path> \
LDFLAGS=-L<libselinux-lib-path> \
make
Most people will leave this set to 'N'.
@@ -157,6 +173,48 @@ config CONFIG_STATIC
Most people will leave this set to 'N'.
# The busybox shared library feature is there so make standalone can produce
# smaller applets. Since make standalone isn't in yet, there's nothing using
# this yet, and so it's disabled.
config CONFIG_DISABLE_SHARED
bool
default n
config CONFIG_BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on CONFIG_DISABLE_SHARED
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
config CONFIG_FEATURE_FULL_LIBBUSYBOX
bool "Feature-complete libbusybox"
default n if !CONFIG_FEATURE_SHARED_BUSYBOX
depends on CONFIG_BUILD_LIBBUSYBOX
help
Build a libbusybox with the complete feature-set, disregarding
the actually selected config.
Normally, libbusybox will only contain the features which are
used by busybox itself. If you plan to write a separate
standalone application which uses libbusybox say 'Y'.
Note: libbusybox is GPL, not LGPL, and exports no stable API that
might act as a copyright barrier. We can and will modify the
exported function set between releases (even minor version number
changes), and happily break out-of-tree features.
Say 'N' if in doubt.
config CONFIG_FEATURE_SHARED_BUSYBOX
bool "Use shared libbusybox for busybox"
default y if CONFIG_BUILD_LIBBUSYBOX
depends on !CONFIG_STATIC && CONFIG_BUILD_LIBBUSYBOX
help
Use libbusybox.so also for busybox itself.
You need to have a working dynamic linker to use this variant.
config CONFIG_LFS
bool "Build with Large File Support (for accessing files > 2 GB)"
default n
@@ -196,43 +254,27 @@ config EXTRA_CFLAGS_OPTIONS
if you want to add some simple compiler switches (like -march=i686),
or check for warnings using -Werror, just those options here.
endmenu
menu 'Installation Options'
config CONFIG_INSTALL_NO_USR
bool "Don't use /usr"
config CONFIG_BUILD_AT_ONCE
bool "Compile all sources at once"
default n
help
Disable use of /usr. Don't activate this option if you don't know
that you really want this behaviour.
Normally each source-file is compiled with one invocation of
the compiler.
If you set this option, all sources are compiled at once.
This gives the compiler more opportunities to optimize which can
result in smaller and/or faster binaries.
config PREFIX
string "BusyBox installation prefix"
default "./_install"
help
Define your directory to install BusyBox files/subdirs in.
Setting this option will consume alot of memory, e.g. if you
enable all applets with all features, gcc uses more than 300MB
RAM during compilation of busybox.
This option is most likely only beneficial for newer compilers
such as gcc-4.1 and above.
Say 'N' unless you know what you are doing.
endmenu
source archival/Config.in
source coreutils/Config.in
source console-tools/Config.in
source debianutils/Config.in
source editors/Config.in
source findutils/Config.in
source init/Config.in
source loginutils/Config.in
source miscutils/Config.in
source modutils/Config.in
source networking/Config.in
source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
source util-linux/Config.in
menu 'Debugging Options'
config CONFIG_DEBUG
@@ -289,6 +331,82 @@ config CONFIG_EFENCE
endchoice
config CONFIG_DEBUG_YANK_SUSv2
bool "Disable obsolete features removed before SUSv3?"
default y
help
This option will disable backwards compatability with SuSv2,
specifically, old-style numeric options ('command -1 <file>')
will not be supported in head, tail, and fold. (Note: should
yank from renice too.)
endmenu
menu 'Installation Options'
config CONFIG_INSTALL_NO_USR
bool "Don't use /usr"
default n
help
Disable use of /usr. Don't activate this option if you don't know
that you really want this behaviour.
choice
prompt "Applets links"
default CONFIG_INSTALL_APPLET_SYMLINKS
help
Choose how you install applets links.
config CONFIG_INSTALL_APPLET_SYMLINKS
bool "as soft-links"
help
Install applets as soft-links to the busybox binary. This needs some
free inodes on the filesystem, but might help with filesystem
generators that can't cope with hard-links.
config CONFIG_INSTALL_APPLET_HARDLINKS
bool "as hard-links"
help
Install applets as hard-links to the busybox binary. This might count
on a filesystem with few inodes.
config CONFIG_INSTALL_APPLET_DONT
bool
prompt "not installed"
depends on CONFIG_FEATURE_INSTALLER || CONFIG_FEATURE_SH_STANDALONE_SHELL
help
Do not install applets links. Usefull when using the -install feature
or a standalone shell for rescue pruposes.
endchoice
config PREFIX
string "BusyBox installation prefix"
default "./_install"
help
Define your directory to install BusyBox files/subdirs in.
endmenu
source libbb/Config.in
endmenu
comment "Applets"
source archival/Config.in
source coreutils/Config.in
source console-tools/Config.in
source debianutils/Config.in
source editors/Config.in
source findutils/Config.in
source init/Config.in
source loginutils/Config.in
source e2fsprogs/Config.in
source modutils/Config.in
source util-linux/Config.in
source miscutils/Config.in
source networking/Config.in
source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
+118 -15
View File
@@ -1,20 +1,123 @@
1) Run 'make config' or 'make menuconfig' and select the
functionality that you wish to enable.
Building:
=========
2) Run 'make dep'
The BusyBox build process is similar to the Linux kernel build:
3) Check the Makefile for any Makefile setting you wish
to adjust for your system (things like like setting
your cross compiler, adjusting optimizations, etc)
make menuconfig # This creates a file called ".config"
make # This creates the "busybox" executable
make install # or make PREFIX=/path/from/root install
4) Run 'make'
The full list of configuration and install options is available by typing:
5) Go get a drink of water, drink a soda, visit the bathroom,
or whatever while it compiles. It doesn't take very
long to compile, so you don't really need to waste too
much time waiting...
make help
6) Run 'make install' or 'make PREFIX=/target install' to
install busybox and all the needed links. Some people
will prefer to install using hardlinks and will instead
want to run 'make install-hardlinks'....
Quick Start:
============
The easy way to try out BusyBox for the first time, without having to install
it, is to enable all features and then use "standalone shell" mode with a
blank command $PATH.
To enable all features, use "make defconfig", which produces the largest
general-purpose configuration. (It's allyesconfig minus debugging options,
optional packaging choices, and a few special-purpose features requiring
extra configuration to use.)
make defconfig
make
PATH= ./busybox ash
Standalone shell mode causes busybox's built-in command shell to run
any built-in busybox applets directly, without looking for external
programs by that name. Supplying an empty command path (as above) means
the only commands busybox can find are the built-in ones.
(Note that the standalone shell currently requires /proc/self/exe to
launch new applets.)
Configuring Busybox:
====================
Busybox is optimized for size, but enabling the full set of functionality
still results in a fairly large executable -- more than 1 megabyte when
statically linked. To save space, busybox can be configured with only the
set of applets needed for each environment. The minimal configuration, with
all applets disabled, produces a 4k executable. (It's useless, but very small.)
The manual configurator "make menuconfig" modifies the existing configuration.
(For systems without ncurses, try "make config" instead.) The two most
interesting starting configurations are "make allnoconfig" (to start with
everything disabled and add just what you need), and "make defconfig" (to
start with everything enabled and remove what you don't need). If menuconfig
is run without an existing configuration, make defconfig will run first to
create a known starting point.
Other starting configurations (mostly used for testing purposes) include
"make allbaseconfig" (enables all applets but disables all optional features),
"make allyesconfig" (enables absolutely everything including debug features),
and "make randconfig" (produce a random configuration).
Configuring BusyBox produces a file ".config", which can be saved for future
use. Run "make oldconfig" to bring a .config file from an older version of
busybox up to date.
Installing Busybox:
===================
Busybox is a single executable that can behave like many different commands,
and BusyBox uses the name it was invoked under to determine the desired
behavior. (Try "mv busybox ls" and then "./ls -l".)
Installing busybox consists of creating symlinks (or hardlinks) to the busybox
binary for each applet enabled in busybox, and making sure these symlinks are
in the shell's command $PATH. Running "make install" creates these symlinks,
or "make install-hardlinks" creates hardlinks instead (useful on systems with
a limited number of inodes). This install process uses the file
"busybox.links" (created by make), which contains the list of enabled applets
and the path at which to install them.
Installing links to busybox is not always necessary. The special applet name
"busybox" (or with any optional suffix, such as "busybox-static") uses the
first argument to determine which applet to behave as, for example
"./busybox cat LICENSE". (Running the busybox applet with no arguments gives
a list of all enabled applets.) The standalone shell can also call busybox
applets without links to busybox under other names in the filesystem. You can
also configure a standaone install capability into the busybox base applet,
and then install such links at runtime with one of "busybox --install" (for
hardlinks) or "busybox --install -s" (for symlinks).
If you enabled the busybox shared library feature (libbusybox.so) and want
to run tests without installing, set your LD_LIBRARY_PATH accordingly when
running the executable:
LD_LIBRARY_PATH=`pwd` ./busybox
Building out-of-tree:
=====================
By default, the BusyBox build puts its temporary files in the source tree.
Building from a read-only source tree, or building multiple configurations from
the same source directory, requires the ability to put the temporary files
somewhere else.
To build out of tree, cd to an empty directory and configure busybox from there:
make -f /path/to/source/Makefile defconfig
make
make install
Alternately, use the O=$BUILDPATH option (with an absolute path) during the
configuration step, as in:
make O=/some/empty/directory allyesconfig
cd /some/empty/directory
make
make PREFIX=. install
More Information:
=================
Se also the busybox FAQ, under the questions "How can I get started using
BusyBox" and "How do I build a BusyBox-based system?" The BusyBox FAQ is
available from http://www.busybox.net/FAQ.html or as the file
docs/busybox.net/FAQ.html in this tarball.
+318 -177
View File
@@ -2,76 +2,71 @@
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
#
#--------------------------------------------------------------
# You shouldn't need to mess with anything beyond this point...
#--------------------------------------------------------------
noconfig_targets := menuconfig config oldconfig randconfig \
defconfig allyesconfig allnoconfig clean distclean \
release tags
defconfig allyesconfig allnoconfig allbareconfig \
clean distclean help \
release tags
ifndef TOPDIR
TOPDIR=$(CURDIR)/
endif
# the toplevel sourcedir
ifndef top_srcdir
top_srcdir=$(CURDIR)
endif
# toplevel directory of the object-tree
ifndef top_builddir
top_builddir=$(CURDIR)
endif
srctree=$(top_srcdir)
export srctree=$(top_srcdir)
vpath %/Config.in $(srctree)
include $(top_builddir)/Rules.mak
DIRS:=applets archival archival/libunarchive coreutils console-tools \
debianutils editors findutils init miscutils modutils networking \
networking/libiproute networking/udhcp procps loginutils shell \
sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
sysklogd util-linux e2fsprogs libpwdgrp coreutils/libcoreutils libbb
SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
ifeq ($(strip $(CONFIG_SELINUX)),y)
CFLAGS += -I/usr/include/selinux
LIBRARIES += -lsecure
endif
# That's our default target when none is given on the command line
.PHONY: _all
_all:
CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
ALL_DIRS:= $(DIRS) scripts/config
ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
CONFIG_CONFIG_IN = $(top_srcdir)/Config.in
ifeq ($(KBUILD_SRC),)
ifdef O
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
top_builddir := $(O)
endif
else
# If no alternate output-dir was specified, we build in cwd
# We are using KBUILD_OUTPUT nevertheless to make sure that we create
# Rules.mak and the toplevel Makefile, in case they don't exist.
KBUILD_OUTPUT := $(top_builddir)
endif
# That's our default target when none is given on the command line
.PHONY: _all
_all:
ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
# pull in OS specific commands like cp, mkdir, etc. early
-include $(top_srcdir)/Rules.mak
endif
# All object directories.
OBJ_DIRS := $(DIRS)
all_tree := $(patsubst %,$(top_builddir)/%,$(OBJ_DIRS) scripts scripts/config include)
all_tree: $(all_tree)
$(all_tree):
@mkdir -p "$@"
ifneq ($(KBUILD_OUTPUT),)
# Invoke a second make in the output directory, passing relevant variables
# check that the output directory actually exists
# Check that the output directory actually exists
saved-output := $(KBUILD_OUTPUT)
KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
$(if $(wildcard $(KBUILD_OUTPUT)),, \
@@ -79,23 +74,22 @@ $(if $(wildcard $(KBUILD_OUTPUT)),, \
.PHONY: $(MAKECMDGOALS)
$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile
$(MAKE) -C $(KBUILD_OUTPUT) \
top_srcdir=$(CURDIR) \
top_builddir=$(KBUILD_OUTPUT) \
TOPDIR=$(KBUILD_OUTPUT) \
KBUILD_SRC=$(CURDIR) \
$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile all_tree
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) \
top_srcdir=$(top_srcdir) \
top_builddir=$(top_builddir) \
KBUILD_SRC=$(top_srcdir) \
-f $(CURDIR)/Makefile $@
$(KBUILD_OUTPUT)/Rules.mak:
@echo > $@
@echo top_srcdir=$(CURDIR) >> $@
@echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
@echo include $(top_srcdir)/Rules.mak >> $@
$(KBUILD_OUTPUT)/Makefile:
@echo > $@
@echo top_srcdir=$(CURDIR) >> $@
@echo top_srcdir=$(top_srcdir) >> $@
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
@echo KBUILD_SRC='$$(top_srcdir)' >> $@
@echo include '$$(KBUILD_SRC)'/Makefile >> $@
@@ -107,31 +101,216 @@ endif # ifeq ($(KBUILD_SRC),)
ifeq ($(skip-makefile),)
# We only need a copy of the Makefile for the config targets and reuse
# the rest from the source directory, i.e. we do not cp ALL_MAKEFILES.
scripts/config/Makefile: $(top_srcdir)/scripts/config/Makefile
cp $< $@
_all: all
ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
help:
@echo 'Cleaning:'
@echo ' clean - delete temporary files created by build'
@echo ' distclean - delete all non-source files (including .config)'
@echo
@echo 'Build:'
@echo ' all - Executable and documentation'
@echo ' busybox - the swiss-army executable'
@echo ' doc - docs/BusyBox.{txt,html,1}'
@echo
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
@echo ' allbareconfig - enable all applets without any sub-features'
@echo ' config - text based configurator (of last resort)'
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@echo ' oldconfig - resolve any unresolved symbols in .config'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(PREFIX)'
@echo ' uninstall'
@echo
@echo 'Development:'
@echo ' check - run the test suite for all applets'
@echo ' randconfig - generate a random configuration'
@echo ' release - create a distribution tarball'
@echo ' sizes - show size of all enabled busybox symbols'
@echo
include $(top_srcdir)/Rules.mak
ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
# Default target if none was requested explicitly
all: menuconfig
# warn if no configuration exists and we are asked to build a non-config target
.config:
@echo ""
@echo "No $(top_builddir)/$@ found!"
@echo "Please refer to 'make help', section Configuration."
@echo ""
@exit 1
# configuration
# ---------------------------------------------------------------------------
scripts/config/conf: scripts/config/Makefile
$(Q)$(MAKE) -C scripts/config conf
-@if [ ! -f .config ] ; then \
touch .config; \
fi
scripts/config/mconf: scripts/config/Makefile
$(Q)$(MAKE) -C scripts/config ncurses conf mconf
-@if [ ! -f .config ] ; then \
touch .config; \
fi
menuconfig: scripts/config/mconf
@[ -f .config ] || make $(MAKEFLAGS) defconfig
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
config: scripts/config/conf
@./scripts/config/conf $(CONFIG_CONFIG_IN)
oldconfig: scripts/config/conf
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
randconfig: scripts/config/conf
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
allyesconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER)=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allnoconfig: scripts/config/conf
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
# defconfig is allyesconfig minus any features that are specialized enough
# or cause enough behavior change that the user really should switch them on
# manually if that's what they want. Sort of "maximum sane config".
defconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG.*|STATIC|SELINUX|BUILD_(AT_ONCE|LIBBUSYBOX)|FEATURE_(DEVFS|FULL_LIBBUSYBOX|SHARED_BUSYBOX|MTAB_SUPPORT|CLEAN_UP|UDHCP_DEBUG)|INSTALL_NO_USR))=.*/# \1 is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allbareconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
@$(SED) -i -r -e "s/^(USING_CROSS_COMPILER|CONFIG_(DEBUG|STATIC|SELINUX|DEVFSD|NC_GAPING_SECURITY_HOLE|BUILD_AT_ONCE)).*/# \1 is not set/" .config
@$(SED) -i -e "/FEATURE/s/=.*//;/^[^#]/s/.*FEATURE.*/# \0 is not set/;" .config
@echo "CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y" >> .config
@yes n | ./scripts/config/conf -o $(CONFIG_CONFIG_IN)
else # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
all: busybox busybox.links doc
all_tree: $(ALL_MAKEFILES)
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
# In this section, we need .config
-include $(top_builddir)/.config.cmd
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
-include $(top_builddir)/.config
-include $(top_builddir)/.depend
busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
$(STRIPCMD) $@
busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h
- $(SHELL) $^ >$@
ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
libraries-y:=
# Which parts of the internal libs are requested?
# Per default we only want what was actually selected.
# -a denotes all while -y denotes the selected ones.
ifeq ($(strip $(CONFIG_FEATURE_FULL_LIBBUSYBOX)),y)
LIBRARY_DEFINE:=$(LIBRARY_DEFINE-a)
LIBRARY_SRC :=$(LIBRARY_SRC-a)
else # CONFIG_FEATURE_FULL_LIBBUSYBOX
LIBRARY_DEFINE:=$(LIBRARY_DEFINE-y)
LIBRARY_SRC :=$(LIBRARY_SRC-y)
endif # CONFIG_FEATURE_FULL_LIBBUSYBOX
APPLET_SRC:=$(APPLET_SRC-y)
APPLETS_DEFINE:=$(APPLETS_DEFINE-y)
else # CONFIG_BUILD_AT_ONCE
# no --combine, build archives out of the individual .o
# This was the old way the binary was built.
libbusybox-obj:=archival/libunarchive/libunarchive.a \
networking/libiproute/libiproute.a \
libpwdgrp/libpwdgrp.a \
coreutils/libcoreutils/libcoreutils.a \
libbb/libbb.a
libbusybox-obj:=$(patsubst %,$(top_builddir)/%,$(libbusybox-obj))
install: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX)
ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
# linking against libbusybox, so don't build the .a already contained in the .so
libraries-y:=$(filter-out $(libbusybox-obj),$(libraries-y))
endif # CONFIG_FEATURE_SHARED_BUSYBOX
endif # CONFIG_BUILD_AT_ONCE
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
LD_LIBBUSYBOX:=libbusybox.so
LIBBUSYBOX_SONAME:=$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)
DO_INSTALL_LIBS:=$(LD_LIBBUSYBOX) \
$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
$(LD_LIBBUSYBOX).$(MAJOR_VERSION).$(MINOR_VERSION)
endif # CONFIG_BUILD_LIBBUSYBOX
ifeq ($(strip $(CONFIG_BUILD_AT_ONCE)),y)
ifneq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
# --combine but not linking against libbusybox, so compile all
BUSYBOX_SRC := $(LIBRARY_SRC)
BUSYBOX_DEFINE:= $(LIBRARY_DEFINE)
endif # !CONFIG_FEATURE_SHARED_BUSYBOX
$(LIBBUSYBOX_SONAME): $(LIBRARY_SRC)
else # CONFIG_BUILD_AT_ONCE
$(LIBBUSYBOX_SONAME): $(libbusybox-obj)
endif # CONFIG_BUILD_AT_ONCE
ifeq ($(strip $(CONFIG_FEATURE_SHARED_BUSYBOX)),y)
LDBUSYBOX:=-L$(top_builddir) -lbusybox
endif
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
$(LIBBUSYBOX_SONAME):
ifndef MAJOR_VERSION
$(error MAJOR_VERSION needed for $@ is not defined)
endif
$(do_link) $(LIB_CFLAGS) $(CFLAGS_COMBINE) \
-Wl,-soname=$(LD_LIBBUSYBOX).$(MAJOR_VERSION) \
-Wl,-z,combreloc $(LIB_LDFLAGS) \
-o $(@) \
-Wl,--start-group -Wl,--whole-archive \
$(LIBRARY_DEFINE) $(^) \
-Wl,--no-whole-archive -Wl,--end-group
@rm -f $(DO_INSTALL_LIBS)
@for i in $(DO_INSTALL_LIBS); do ln -s $(@) $$i ; done
$(do_strip)
endif # ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
busybox_unstripped: .depend $(LIBBUSYBOX_SONAME) $(BUSYBOX_SRC) $(libraries-y)
$(do_link) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
-o $@ -Wl,--start-group \
$(APPLETS_DEFINE) $(APPLET_SRC) \
$(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
$(LDBUSYBOX) $(LIBRARIES) \
-Wl,--end-group
busybox: busybox_unstripped
$(Q)cp busybox_unstripped busybox
$(do_strip)
busybox.links: $(top_srcdir)/applets/busybox.mkll include/bb_config.h $(top_srcdir)/include/applets.h
$(Q)-$(SHELL) $^ >$@
install: $(top_srcdir)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(PREFIX) $(INSTALL_OPTS)
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
@echo
@echo
@@ -146,170 +325,132 @@ endif
uninstall: busybox.links
rm -f $(PREFIX)/bin/busybox
for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
ifneq ($(strip $(DO_INSTALL_LIBS)),n)
for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
rm -f $(PREFIX)$$i; \
done
endif
install-hardlinks: applets/install.sh busybox busybox.links
$(SHELL) $< $(PREFIX) --hardlinks
check: busybox
# see if we are in verbose mode
KBUILD_VERBOSE :=
ifdef V
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE := $(V)
endif
endif
ifneq ($(strip $(KBUILD_VERBOSE)),)
CHECK_VERBOSE := -v
# ARFLAGS+=v
endif
check test: busybox
bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
$(top_srcdir)/testsuite/runtest
$(top_srcdir)/testsuite/runtest $(CHECK_VERBOSE)
sizes: busybox_unstripped
$(NM) --size-sort $(<)
# Documentation Targets
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod
-mkdir -p docs
- ( cat $(top_srcdir)/docs/busybox_header.pod; \
$(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \
cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod
docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod $(top_srcdir)/docs/autodocifier.pl
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-( cat $(top_srcdir)/docs/busybox_header.pod ; \
$(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h ; \
cat $(top_srcdir)/docs/busybox_footer.pod ; ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
@echo
@echo BusyBox Documentation
@echo
-mkdir -p docs
-pod2text $< > $@
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2text $< > $@
docs/BusyBox.1: docs/busybox.pod
- mkdir -p docs
- pod2man --center=BusyBox --release="version $(VERSION)" \
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
$< > $@
docs/BusyBox.html: docs/busybox.net/BusyBox.html
- mkdir -p docs
-@ rm -f docs/BusyBox.html
-@ cp docs/busybox.net/BusyBox.html docs/BusyBox.html
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-rm -f docs/BusyBox.html
$(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
docs/busybox.net/BusyBox.html: docs/busybox.pod
-@ mkdir -p docs/busybox.net
- pod2html --noindex $< > \
$(Q)-mkdir -p docs/busybox.net
$(Q)-pod2html --noindex $< > \
docs/busybox.net/BusyBox.html
-@ rm -f pod2htm*
$(Q)-rm -f pod2htm*
# The nifty new buildsystem stuff
scripts/mkdep: $(top_srcdir)/scripts/mkdep.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
# The nifty new dependency stuff
scripts/bb_mkdep: $(top_srcdir)/scripts/bb_mkdep.c
$(Q)$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
scripts/split-include: $(top_srcdir)/scripts/split-include.c
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
DEP_INCLUDES := include/bb_config.h
.depend: scripts/mkdep
rm -f .depend .hdepend;
mkdir -p include/config;
scripts/mkdep -I include -- \
`find $(top_srcdir) -name \*.c -print | sed -e "s,^./,,"` >> .depend;
scripts/mkdep -I include -- \
`find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
ifeq ($(strip $(CONFIG_BBCONFIG)),y)
DEP_INCLUDES += include/bbconfigopts.h
depend dep: include/config.h .depend
include/bbconfigopts.h: .config
$(disp_gen)
$(Q)$(top_srcdir)/scripts/config/mkconfigs > $@
endif
include/config/MARKER: depend scripts/split-include
scripts/split-include include/config.h include/config
@ touch include/config/MARKER
depend dep: .depend
.depend: scripts/bb_mkdep $(DEP_INCLUDES)
$(disp_gen)
$(Q)rm -f .depend
$(Q)mkdir -p include/config
$(Q)scripts/bb_mkdep -I $(top_srcdir)/include $(top_srcdir) > $@.tmp
$(Q)mv $@.tmp $@
include/config.h: .config
include/bb_config.h: .config
@if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
$(MAKE) -C scripts/config conf; \
fi;
@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
finished2:
@echo
@echo Finished installing...
@echo
else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
all: menuconfig
# configuration
# ---------------------------------------------------------------------------
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
scripts/config/conf: scripts/config/Makefile Rules.mak
$(MAKE) -C scripts/config conf
-@if [ ! -f .config ] ; then \
cp $(CONFIG_DEFCONFIG) .config; \
fi
scripts/config/mconf: scripts/config/Makefile Rules.mak
$(MAKE) -C scripts/config ncurses conf mconf
-@if [ ! -f .config ] ; then \
cp $(CONFIG_DEFCONFIG) .config; \
fi
menuconfig: scripts/config/mconf
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
config: scripts/config/conf
@./scripts/config/conf $(CONFIG_CONFIG_IN)
oldconfig: scripts/config/conf
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
randconfig: scripts/config/conf
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
allyesconfig: scripts/config/conf
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
allnoconfig: scripts/config/conf
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
defconfig: scripts/config/conf
@./scripts/config/conf -d $(CONFIG_CONFIG_IN)
clean:
- $(MAKE) -C scripts/config $@
- rm -f docs/busybox.dvi docs/busybox.ps \
docs/busybox.pod docs/busybox.net/busybox.html \
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
.config.old .hdepend busybox
- rm -rf _install
- find . -name .\*.flags -exec rm -f {} \;
- find . -name \*.o -exec rm -f {} \;
- find . -name \*.a -exec rm -f {} \;
docs/busybox.net/BusyBox.html busybox.links \
libbusybox.so* \
.config.old busybox busybox_unstripped
- rm -r -f _install testsuite/links
- find . -name .\*.flags -o -name \*.o -o -name \*.om \
-o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
distclean: clean
- rm -f scripts/split-include scripts/mkdep
- rm -rf include/config include/config.h
- find . -name .depend -exec rm -f {} \;
- rm -f scripts/bb_mkdep
- rm -r -f include/config $(DEP_INCLUDES)
- find . -name .depend'*' | xargs rm -f
rm -f .config .config.old .config.cmd
- $(MAKE) -C scripts/config clean
release: distclean #doc
cd ..; \
rm -rf $(PROG)-$(VERSION); \
cp -a busybox $(PROG)-$(VERSION); \
\
find $(PROG)-$(VERSION)/ -type d \
-name CVS \
-print \
-exec rm -rf {} \; ; \
\
find $(PROG)-$(VERSION)/ -type f \
-name .\#* \
-print \
-exec rm -f {} \; ; \
\
cd ..; \
rm -r -f $(PROG)-$(VERSION); \
cp -a busybox $(PROG)-$(VERSION); \
\
find $(PROG)-$(VERSION)/ -type d \
-name .svn \
-print \
-exec rm -r -f {} \; ; \
\
find $(PROG)-$(VERSION)/ -type f \
-name .\#* \
-print \
-exec rm -f {} \; ; \
\
tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
tags:
ctags -R .
endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
endif # ifeq ($(skip-makefile),)
.PHONY: dummy subdirs release distclean clean config oldconfig \
menuconfig tags check test depend buildtree
menuconfig tags check test depend dep buildtree
+162 -86
View File
@@ -1,127 +1,203 @@
Please see the LICENSE file for details on copying and usage.
Please refer to the INSTALL file for instructions on how to build.
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 GNU coreutils, util-linux, etc. The utilities in BusyBox
generally have fewer options than their full-featured GNU cousins; however, the
options that are included provide the expected functionality and behave very
much like their GNU counterparts.
What is busybox:
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 /dev, /etc, and a Linux kernel.
BusyBox provides a fairly complete POSIX environment for any small or embedded
system.
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 bzip2, coreutils, e2fsprogs, file, findutils,
gawk, grep, inetutils, less, modutils, net-tools, procps, sed, shadow,
sysklogd, sysvinit, tar, util-linux, and vim. The utilities in BusyBox
often have fewer options than their full-featured cousins; however, the
options that are included provide the expected functionality and behave
very much like their larger counterparts.
BusyBox is extremely configurable. This allows you to include only the
components you need, thereby reducing binary size. Run 'make config' or
'make menuconfig' to select the functionality that you wish to enable.
BusyBox has been written with size-optimization and limited resources in
mind, both to produce small binaries and to reduce run-time memory usage.
Busybox is also extremely modular so you can easily include or exclude
commands (or features) at compile time. This makes it easy to customize
embedded systems; to create a working system, just add /dev, /etc, and a
Linux kernel. Busybox (usually together with uClibc) has also been used as
a component of "thin client" desktop systems, live-CD distributions, rescue
disks, installers, and so on.
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')
If you wish to install hard links, rather than symlinks, you can use
'make PREFIX=/tmp/foo install-hardlinks' instead.
BusyBox provides a fairly complete POSIX environment for any small system,
both embedded environments and more full featured systems concerned about
space. Busybox is slowly working towards implementing the full Single Unix
Specification V3 (http://www.opengroup.org/onlinepubs/009695399/), but isn't
there yet (and for size reasons will probably support at most UTF-8 for
internationalization). We are also interested in passing the Linux Test
Project (http://ltp.sourceforge.net).
----------------
Supported architectures:
Using busybox:
BusyBox in general will build on any architecture supported by gcc.
Kernel module loading for 2.2 and 2.4 Linux kernels is currently
limited to ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC,
S390, SH3/4/5, Sparc, v850e, and x86_64 for 2.4.x kernels. For 2.6.x
kernels, kernel module loading support should work on all architectures.
BusyBox is extremely configurable. This allows you to include only the
components and options you need, thereby reducing binary size. Run 'make
config' or 'make menuconfig' to select the functionality that you wish to
enable. (See 'make help' for more commands.)
The behavior of busybox is determined by the name it's called under: as
"cp" it behaves like cp, as "sed" it behaves like sed, and so on. Called
as "busybox" it takes the second argument as the name of the applet to
run (I.E. "./busybox ls -l /proc").
Supported C Libraries:
The "standalone shell" mode is an easy way to try out busybox; this is a
command shell that calls the builtin applets without needing them to be
installed in the path. (Note that this requires /proc to be mounted, if
testing from a boot floppy or in a chroot environment.)
uClibc and glibc are supported. People have been looking at newlib and
dietlibc, but they are currently considered unsupported, untested, or
worse. Linux-libc5 is no longer supported -- you should probably use uClibc
instead if you want a small C library.
Supported kernels:
Full functionality requires Linux 2.2.x or better. A large fraction of the
code should run on just about anything. While the current code is fairly
Linux specific, it should be fairly easy to port the majority of the code
to support, say, FreeBSD or Solaris, or Mac OS X, or even Windows (if you
are into that sort of thing).
The build automatically generates a file "busybox.links", which is used by
'make install' to create symlinks to the BusyBox binary for all compiled in
commands. This uses the PREFIX environment variable to specify where to
install, and installs hardlinks or symlinks depending on the configuration
preferences. (You can also manually run the install script at
"applets/install.sh").
----------------
Getting help:
Downloading the current source code:
When you find you need help, you can check out the BusyBox mailing list
archives at http://busybox.net/lists/busybox/ or even join
the mailing list if you are interested.
Source for the latest released version, as well as daily snapshots, can always
be downloaded from
http://busybox.net/downloads/
You can browse the up to the minute source code and change history online.
The "stable" series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_00_stable/busybox/
And the development series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
Anonymous SVN access is available. For instructions, check out:
http://busybox.net/subversion.html
For those that are actively contributing and would like to check files in,
see:
http://busybox.net/developer.html
The developers also have a bug and patch tracking system
(http://bugs.busybox.net) although posting a bug/patch to the mailing list
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
----------------
Bugs:
getting help:
If you find bugs, please submit a detailed bug report to the BusyBox mailing
list at busybox@mail.busybox.net. A well-written bug report should include a
transcript of a shell session that demonstrates the bad behavior and enables
anyone else to duplicate the bug on their own machine. The following is such
an example:
when you find you need help, you can check out the busybox mailing list
archives at http://busybox.net/lists/busybox/ or even join
the mailing list if you are interested.
To: busybox@mail.busybox.net
From: diligent@testing.linux.org
Subject: /bin/date doesn't work
----------------
Package: BusyBox
Version: 1.00
bugs:
When I execute BusyBox 'date' it produces unexpected results.
With GNU date I get the following output:
if you find bugs, please submit a detailed bug report to the busybox mailing
list at busybox@busybox.net. a well-written bug report should include a
transcript of a shell session that demonstrates the bad behavior and enables
anyone else to duplicate the bug on their own machine. the following is such
an example:
to: busybox@busybox.net
from: diligent@testing.linux.org
subject: /bin/date doesn't work
package: busybox
version: 1.00
when i execute busybox 'date' it produces unexpected results.
with gnu date i get the following output:
$ date
Fri Oct 8 14:19:41 MDT 2004
fri oct 8 14:19:41 mdt 2004
But when I use BusyBox date I get this instead:
but when i use busybox date i get this instead:
$ date
illegal instruction
I am using Debian unstable, kernel version 2.4.25-vrs2 on a Netwinder,
and the latest uClibc from CVS. Thanks for the wonderful program!
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
and the latest uclibc from cvs. thanks for the wonderful program!
-Diligent
-diligent
Note the careful description and use of examples showing not only what BusyBox
does, but also a counter example showing what an equivalent GNU app does. Bug
reports lacking such detail may never be fixed... Thanks for understanding.
note the careful description and use of examples showing not only what
busybox does, but also a counter example showing what an equivalent app
does (or pointing to the text of a relevant standard). Bug reports lacking
such detail may never be fixed... Thanks for understanding.
----------------
Downloads:
Portability:
Source for the latest released version, as well as daily snapshots, can always
be downloaded from
http://busybox.net/downloads/
Busybox is developed and tested on Linux 2.4 and 2.6 kernels, compiled
with gcc (the unit-at-a-time optimizations in version 3.4 and later are
worth upgrading to get, but older versions should work), and linked against
uClibc (0.9.27 or greater) or glibc (2.2 or greater). In such an
environment, the full set of busybox features should work, and if
anything doesn't we want to know about it so we can fix it.
There are many other environments out there, in which busybox may build
and run just fine. We just don't test them. Since busybox consists of a
large number of more or less independent applets, portability is a question
of which features work where. Some busybox applets (such as cat and rm) are
highly portable and likely to work just about anywhere, while others (such as
insmod and losetup) require recent Linux kernels with recent C libraries.
Earlier versions of Linux and glibc may or may not work, for any given
configuration. Linux 2.2 or earlier should mostly work (there's still
some support code in things like mount.c) but this is no longer regularly
tested, and inherently won't support certain features (such as long files
and --bind mounts). The same is true for glibc 2.0 and 2.1: expect a higher
testing and debugging burden using such old infrastructure. (The busybox
developers are not very interested in supporting these older versions, but
will probably accept small self-contained patches to fix simple problems.)
Some environments are not recommended. Early versions of uClibc were buggy
and missing many features: upgrade. Linking against libc5 or dietlibc is
not supported and not interesting to the busybox developers. (The first is
obsolete and has no known size or feature advantages over uClibc, the second
has known bugs that its developers have actively refused to fix.) Ancient
Linux kernels (2.0.x and earlier) are similarly uninteresting.
In theory it's possible to use Busybox under other operating systems (such as
MacOS X, Solaris, Cygwin, or the BSD Fork Du Jour). This generally involves
a different kernel and a different C library at the same time. While it
should be possible to port the majority of the code to work in one of
these environments, don't be suprised if it doesn't work out of the box. If
you're into that sort of thing, start small (selecting just a few applets)
and work your way up.
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
and libgloss, and some of his patches have been integrated. This platform
may join glibc/uclibc and Linux as a supported combination with the 1.1
release, but is not supported in 1.0.
Supported hardware:
BusyBox in general will build on any architecture supported by gcc. We
support both 32 and 64 bit platforms, and both big and little endian
systems.
Under 2.4 Linux kernels, kernel module loading was implemented in a
platform-specific manner. Busybox's insmod utility has been reported to
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
The module loading mechanism for the 2.6 kernel is much more generic, and
we believe 2.6.x kernel module loading support should work on all
architectures supported by the kernel.
----------------
CVS:
BusyBox now has its own publicly browsable CVS tree at:
http://busybox.net/cgi-bin/cvsweb/busybox/
Anonymous CVS access is available. For instructions, check out:
http://busybox.net/cvs_anon.html
For those that are actively contributing there is even CVS write access:
http://busybox.net/cvs_write.html
----------------
Please feed suggestions, bug reports, insults, and bribes back to:
Please feed suggestions, bug reports, insults, and bribes back to the busybox
maintainer:
Erik Andersen
<andersen@codepoet.org>
+160 -52
View File
@@ -1,25 +1,22 @@
# Rules.make for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
#
# Pull in the user's busybox configuration
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
-include $(top_builddir)/.config
endif
#--------------------------------------------------------
PROG := busybox
VERSION := 1.00
MAJOR_VERSION :=1
MINOR_VERSION :=1
SUBLEVEL_VERSION:=2
EXTRAVERSION :=
VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
@@ -27,7 +24,7 @@ BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
#--------------------------------------------------------
# If you are running a cross compiler, you will want to set 'CROSS'
@@ -42,7 +39,8 @@ LD = $(CROSS)ld
NM = $(CROSS)nm
STRIP = $(CROSS)strip
CPP = $(CC) -E
# MAKEFILES = $(top_builddir)/.config
SED ?= sed
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
@@ -60,11 +58,6 @@ LC_ALL:= C
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
# Experimental and incomplete; tell the mailing list
# <busybox@busybox.net> if you do or don't like it so far.
BB_SRC_DIR=
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
@@ -76,17 +69,24 @@ BB_SRC_DIR=
# For other libraries, you are on your own. But these may (or may not) help...
#LDFLAGS+=-nostdlib
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
ARFLAGS=-r
CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
ARFLAGS=cru
# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
# get the CC MAJOR/MINOR version
CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
#--------------------------------------------------------
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
ifeq ($(strip $(TARGET_ARCH)),)
TARGET_ARCH=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
-e 's/sparc.*/sparc/' \
-e 's/arm.*/arm/g' \
@@ -100,14 +100,22 @@ TARGET_ARCH=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
)
endif
# Pull in the user's busybox configuration
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
-include $(top_builddir)/.config
endif
# A nifty macro to make testing gcc features easier
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi)
check_gcc=$(shell \
if [ "$(1)" != "" ]; then \
if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi \
fi)
# A not very robust macro to check for available ld flags
check_ld=$(shell \
if [ "x$(1)" != "x" ]; then \
$(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \
fi)
CFLAGS+=$(call check_gcc,-funsigned-char,)
CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
#--------------------------------------------------------
# Arch specific compiler optimization stuff should go here.
@@ -115,8 +123,23 @@ check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1;
# for OPTIMIZATION...
# use '-Os' optimization if available, else use -O2
OPTIMIZATION=
OPTIMIZATION=${call check_gcc,-Os,-O2}
OPTIMIZATION:=$(call check_gcc,-Os,-O2)
ifeq ($(CONFIG_BUILD_AT_ONCE),y)
# gcc 2.95 exits with 0 for "unrecognized option"
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
CFLAGS_COMBINE:=$(call check_gcc,--combine,)
endif
OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
#PROG_CFLAGS+=$(call check_gcc,-fwhole-program,)
endif # CONFIG_BUILD_AT_ONCE
LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,)
#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,)
#LIB_LDFLAGS+=$(call check_ld,--as-needed,)
#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,)
# Some nice architecture specific optimizations
ifeq ($(strip $(TARGET_ARCH)),arm)
@@ -124,11 +147,24 @@ ifeq ($(strip $(TARGET_ARCH)),arm)
endif
ifeq ($(strip $(TARGET_ARCH)),i386)
OPTIMIZATION+=$(call check_gcc,-march=i386,)
# gcc-4.0 and older seem to benefit from these
#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\
OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
#endif # gcc-4.0 and older
# gcc-4.1 and beyond seem to benefit from these
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
# turn off flags which hurt -Os
OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,)
endif # gcc-4.1 and beyond
endif
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer
OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,)
#
#--------------------------------------------------------
@@ -154,15 +190,27 @@ else
endif
ifeq ($(strip $(CONFIG_DEBUG)),y)
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS +=-Wl,-warn-common
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
LDFLAGS += $(call check_ld,--warn-common,)
else
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
LDFLAGS += -s -Wl,-warn-common
STRIPCMD:=$(STRIP) --remove-section=.note --remove-section=.comment
LDFLAGS += $(call check_ld,--warn-common,)
LDFLAGS += $(call check_ld,--sort-common,)
endif
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
ifeq ($(strip $(CONFIG_STATIC)),y)
LDFLAGS += --static
PROG_CFLAGS += $(call check_gcc,-static,)
endif
CFLAGS_SHARED += $(call check_gcc,-shared,)
LIB_CFLAGS+=$(CFLAGS_SHARED)
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
CFLAGS_PIC:= $(call check_gcc,-fPIC,)
LIB_CFLAGS+=$(CFLAGS_PIC)
endif
ifeq ($(strip $(CONFIG_SELINUX)),y)
LIBRARIES += -lselinux
endif
ifeq ($(strip $(PREFIX)),)
@@ -171,13 +219,10 @@ endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in BB_SRC_DIR, both during the compilation phase and the
# the copy in top_srcdir, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt@recycle.lbl.gov>.
#
ifneq ($(strip $(BB_SRC_DIR)),)
VPATH:=$(BB_SRC_DIR)
endif
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
@@ -189,8 +234,71 @@ endif
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
#------------------------------------------------------------
# Installation options
ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
INSTALL_OPTS=--hardlinks
endif
ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
INSTALL_OPTS=--symlinks
endif
ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
INSTALL_OPTS=
endif
#------------------------------------------------------------
# Make the output nice and tight
MAKEFLAGS += --no-print-directory
export MAKE_IS_SILENT=n
ifneq ($(findstring s,$(MAKEFLAGS)),)
export MAKE_IS_SILENT=y
SECHO := @-false
DISP := sil
Q := @
else
ifneq ($(V)$(VERBOSE),)
SECHO := @-false
DISP := ver
Q :=
else
SECHO := @echo
DISP := pur
Q := @
endif
endif
show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
pur_disp_compile.c = echo " "CC $(show_objs)
pur_disp_compile.h = echo " "HOSTCC $(show_objs)
pur_disp_strip = echo " "STRIP $(show_objs)
pur_disp_link = echo " "LINK $(show_objs)
pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs)
sil_disp_compile.c = true
sil_disp_compile.h = true
sil_disp_strip = true
sil_disp_link = true
sil_disp_ar = true
ver_disp_compile.c = echo $(cmd_compile.c)
ver_disp_compile.h = echo $(cmd_compile.h)
ver_disp_strip = echo $(cmd_strip)
ver_disp_link = echo $(cmd_link)
ver_disp_ar = echo $(cmd_ar)
disp_compile.c = $($(DISP)_disp_compile.c)
disp_compile.h = $($(DISP)_disp_compile.h)
disp_strip = $($(DISP)_disp_strip)
disp_link = $($(DISP)_disp_link)
disp_ar = $($(DISP)_disp_ar)
disp_gen = $(SECHO) " "GEN $@ ; true
disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
cmd_strip = $(STRIPCMD) $@
cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
cmd_ar = $(AR) $(ARFLAGS) $@ $^
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_link = @$(disp_link) ; $(cmd_link)
do_ar = @$(disp_ar) ; $(cmd_ar)
.PHONY: dummy
.EXPORT_ALL_VARIABLES:
+255 -6
View File
@@ -1,11 +1,260 @@
Busybox TODO
Stuff that needs to be done
Stuff that needs to be done. All of this is fair game for 1.2.
build system
make -j is broken, -j1 is forced atm
Make sure that the flags get pinned in e.g. Rules.mak so when expanding them
later on you get the cached result without the need to re-evaluate them.
----
tr - missing SuS3 features in busybox 1.0pre10
find
doesn't understand (), lots of susv3 stuff.
----
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. Unifying the various shells and figuring out a configurable
way of adding the minimal set of bash features a given script uses is a big
job, but it would be a big improvement.
Note: Rob Landley (rob@landley.net) is working on a new unified shell called
bbsh, but it's a low priority...
---
diff
We should have a diff -u command. We have patch, we should have diff
(we only need to support unified diffs though).
Also, make sure we handle empty files properly:
From the patch man page:
   you can remove a file by sending out a context diff that compares
   the file to be deleted with an empty file dated the Epoch.  The
   file will be removed unless patch is conforming to POSIX and the
   -E or --remove-empty-files option is not given.
---
patch
Should have simple fuzz factor support to apply patches at an offset which
shouldn't take up too much space.
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
man
It would be nice to have a man command. Not one that handles troff or
anything, just one that can handle preformatted ascii man pages, possibly
compressed. This could probably be a script in the extras directory that
calls cat/zcat/bzcat | less
(How doclifter might work into this is anybody's guess.)
---
bzip2
Compression-side support.
---
init
General cleanup.
---
ar
Write support?
---
mdev
Micro-udev.
Architectural issues:
bb_close() with fsync()
We should have a bb_close() in place of normal close, with a CONFIG_ option
to not just check the return value of close() for an error, but fsync().
Close can't reliably report anything useful because if write() accepted the
data then it either went out to the network or it's in cache or a pipe
buffer. Either way, there's no guarantee it'll make it to its final
destination before close() gets called, so there's no guarantee that any
error will be reported.
You need to call fsync() if you care about errors that occur after write(),
but that can have a big performance impact. So make it a config option.
---
Unify base64 handling.
There's base64 encoding and decoding going on in:
networking/wget.c:base64enc()
coreutils/uudecode.c:read_base64()
coreutils/uuencode.c:tbl_base64[]
networking/httpd.c:decodeBase64()
And probably elsewhere. That needs to be unified into libbb functions.
---
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
---
Internationalization
How much internationalization should we do?
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we can
cleanly export it from our underlying C library without having to concern
ourselves with it directly. Perhaps a few specific things like a config
option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
---
Unify archivers
Lots of archivers have the same general infrastructure. The directory
traversal code should be factored out, and the guts of each archiver could
be some setup code and a series of callbacks for "add this file",
"add this directory", "add this symlink" and so on.
This could clean up tar and zip, and make it cheaper to add cpio and ar
write support, and possibly even cheaply add things like mkisofs or
mksquashfs someday, if they become relevant.
---
Text buffer support.
Several existing applets (sort, vi, less...) read
a whole file into memory and act on it. There might be an opportunity
for shared code in there that could be moved into libbb...
---
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
---
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world use,
such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source code).
This means it would need (at least) binutils, gcc, and make, or equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
---
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
allocation on the stack or the heap. Unfortunately, we're not using it much.
We need to audit our memory allocations and turn a lot of malloc/free calls
into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
For a start, see e.g. make CFLAGS_EXTRA=-Wlarger-than-64
And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be
optimized out by the compiler in the stack allocation case (since there's no
free for an alloca()), and this means that various cleanup loops that just
call free might also be optimized out by the compiler if written right, so
we can yank those #ifdefs too, and generally clean up the code.
---
Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
In busybox 1.0 and earlier, configuration was done by CONFIG_SYMBOLS
that were either defined or undefined to indicate whether the symbol was
selected in the .config file. They were used with #ifdefs, ala:
#ifdef CONFIG_SYMBOL
if (other_test) {
do_code();
}
#endif
In 1.1, we have new ENABLE_SYMBOLS which are always defined (as 0 or 1),
meaning you can still use them for preprocessor tests by replacing
"#ifdef CONFIG_SYMBOL" with "#if ENABLE_SYMBOL". But more importantly, we
can use them as a true or false test in normal C code:
if (ENABLE_SYMBOL && other_test) {
do_code();
}
(Optimizing away if() statements that resolve to a constant value
is known as "dead code elimination", an optimization so old and simple that
Turbo Pascal for DOS did it twenty years ago. Even modern mini-compilers
like the Tiny C Compiler (tcc) and the Small Device C Compiler (SDCC)
perform dead code elimination.)
Right now, busybox.h is #including both "config.h" (defining the
CONFIG_SYMBOLS) and "bb_config.h" (defining the ENABLE_SYMBOLS). At some
point in the future, it would be nice to wean ourselves off of the
CONFIG versions. (Among other things, some defective build environments
leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include
files. We've experienced collisions before.)
---
FEATURE_CLEAN_UP
This is more an unresolved issue than a to-do item. More thought is needed.
Normally we rely on exit() to free memory, close files, and unmap segments
for us. This makes most calls to free(), close(), and unmap() optional in
busybox applets that don't intend to run for very long, and optional stuff
can be omitted to save size.
The idea was raised that we could simulate fork/exit with setjmp/longjmp
for _really_ brainless embedded systems, or speed up the standalone shell
by not forking. Doing so would require a reliable FEATURE_CLEAN_UP.
Unfortunately, this isn't as easy as it sounds.
The problem is, lots of things exit(), sometimes unexpectedly (xmalloc())
and sometimes reliably (bb_perror_msg_and_die() or show_usage()). This
jumps out of the normal flow control and bypasses any cleanup code we
put at the end of our applets.
It's possible to add hooks to libbb functions like xmalloc() and bb_xopen()
to add their entries to a linked list, which could be traversed and
freed/closed automatically. (This would need to be able to free just the
entries after a checkpoint to be usable for a forkless standalone shell.
You don't want to free the shell's own resources.)
Right now, FEATURE_CLEAN_UP is more or less a debugging aid, to make things
like valgrind happy. It's also documentation of _what_ we're trusting
exit() to clean up for us. But new infrastructure to auto-free stuff would
render the existing FEATURE_CLEAN_UP code redundant.
For right now, exit() handles it just fine.
Minor stuff:
watchdog.c could autodetect the timer duration via:
if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
Unfortunately, that needs linux/watchdog.h and that contains unfiltered
kernel types on some distros, which breaks the build.
Code cleanup:
Replace deprecated functions.
bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
tr doesnt support [:blank:], [:digit:] or other predefined classes, [=equiv=]
support is also missing.
----
+6 -15
View File
@@ -1,24 +1,15 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/applets
APPLETS_DIR:=./
include $(top_builddir)/Rules.mak
+10 -21
View File
@@ -1,21 +1,8 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
APPLETS_AR:=applets.a
ifndef $(APPLETS_DIR)
@@ -23,15 +10,17 @@ APPLETS_DIR:=$(top_builddir)/applets/
endif
srcdir=$(top_srcdir)/applets
APPLET_SRC:=applets.c busybox.c
APPLET_OBJ:= $(patsubst %.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c version.c)
APPLET_OBJ:= $(patsubst $(srcdir)/%.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
APPLET_SRC-y+=$(APPLET_SRC)
APPLET_SRC-a+=$(APPLET_SRC)
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
$(AR) -ro $@ $(APPLET_OBJ)
$(do_ar)
$(APPLET_OBJ): $(top_builddir)/.config
$(APPLET_OBJ): $(top_builddir)/.config
$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
$(compile.c)
+130 -174
View File
@@ -54,10 +54,6 @@ static struct BB_applet *applet_using;
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
#ifdef CONFIG_FEATURE_SUID
static void check_suid (struct BB_applet *app);
#ifdef CONFIG_FEATURE_SUID_CONFIG
#include <sys/stat.h>
@@ -65,12 +61,10 @@ static void check_suid (struct BB_applet *app);
#include "pwd_.h"
#include "grp_.h"
static void parse_config_file (void);
#define CONFIG_FILE "/etc/busybox.conf"
/* applets [] is const, so we have to define this "override" structure */
struct BB_suid_config
static struct BB_suid_config
{
struct BB_applet *m_applet;
@@ -79,105 +73,12 @@ struct BB_suid_config
mode_t m_mode;
struct BB_suid_config *m_next;
};
} *suid_config;
static struct BB_suid_config *suid_config;
static int suid_cfg_readable;
#endif /* CONFIG_FEATURE_SUID_CONFIG */
#endif /* CONFIG_FEATURE_SUID */
extern void
bb_show_usage (void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
for (i = applet_using - applets; i > 0;) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
usage_string);
exit (EXIT_FAILURE);
}
static int
applet_name_compare (const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp (name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *
find_applet_by_name (const char *name)
{
return bsearch (name, applets, NUM_APPLETS, sizeof (struct BB_applet),
applet_name_compare);
}
void
run_applet_by_name (const char *name, int argc, char **argv)
{
static int recurse_level = 0;
extern int been_there_done_that; /* From busybox.c */
#ifdef CONFIG_FEATURE_SUID_CONFIG
if (recurse_level == 0)
parse_config_file ();
#endif
recurse_level++;
/* Do a binary search to find the applet entry given the name. */
if ((applet_using = find_applet_by_name (name)) != NULL) {
bb_applet_name = applet_using->name;
if (argv[1] && strcmp (argv[1], "--help") == 0) {
if (strcmp (applet_using->name, "busybox") == 0) {
if (argv[2])
applet_using = find_applet_by_name (argv[2]);
else
applet_using = NULL;
}
if (applet_using)
bb_show_usage ();
been_there_done_that = 1;
busybox_main (0, NULL);
}
#ifdef CONFIG_FEATURE_SUID
check_suid (applet_using);
#endif
exit ((*(applet_using->main)) (argc, argv));
}
/* Just in case they have renamed busybox - Check argv[1] */
if (recurse_level == 1) {
run_applet_by_name ("busybox", argc, argv);
}
recurse_level--;
}
#ifdef CONFIG_FEATURE_SUID
#ifdef CONFIG_FEATURE_SUID_CONFIG
/* check if u is member of group g */
static int
ingroup (uid_t u, gid_t g)
static int ingroup (uid_t u, gid_t g)
{
struct group *grp = getgrgid (g);
@@ -194,76 +95,6 @@ ingroup (uid_t u, gid_t g)
return 0;
}
#endif
void
check_suid (struct BB_applet *applet)
{
uid_t ruid = getuid (); /* real [ug]id */
uid_t rgid = getgid ();
#ifdef CONFIG_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
struct BB_suid_config *sct;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
break;
}
if (sct) {
mode_t m = sct->m_mode;
if (sct->m_uid == ruid) /* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid)) /* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die ("You have no permission to run this applet!");
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
if (setegid (sct->m_gid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper GID for applet!");
} else
setgid (rgid); /* no sgid -> drop */
if (sct->m_mode & S_ISUID) {
if (seteuid (sct->m_uid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper UID for applet!");
} else
setuid (ruid); /* no suid -> drop */
} else {
/* default: drop all priviledges */
setgid (rgid);
setuid (ruid);
}
return;
} else {
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
static int onetime = 0;
if (!onetime) {
onetime = 1;
fprintf (stderr, "Using fallback suid method\n");
}
#endif
}
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid () != 0)
bb_error_msg_and_die ("This applet requires root priviledges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
setgid (rgid); /* drop all priviledges */
setuid (ruid);
}
}
#ifdef CONFIG_FEATURE_SUID_CONFIG
/* This should probably be a libbb routine. In that case,
* I'd probably rename it to something like bb_trimmed_slice.
*/
@@ -434,7 +265,7 @@ static void parse_config_file(void)
}
/* Now get the the user/group info. */
s = (char *) bb_skip_whitespace(e);
/* Note: We require whitespace between the mode and the
@@ -498,9 +329,134 @@ static void parse_config_file(void)
return;
}
#else
#define parse_config_file()
#endif /* CONFIG_FEATURE_SUID_CONFIG */
#ifdef CONFIG_FEATURE_SUID
static void check_suid (struct BB_applet *applet)
{
uid_t ruid = getuid (); /* real [ug]id */
uid_t rgid = getgid ();
#ifdef CONFIG_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
struct BB_suid_config *sct;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
break;
}
if (sct) {
mode_t m = sct->m_mode;
if (sct->m_uid == ruid) /* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid)) /* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die ("You have no permission to run this applet!");
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
if (setegid (sct->m_gid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper GID for applet!");
} else
setgid (rgid); /* no sgid -> drop */
if (sct->m_mode & S_ISUID) {
if (seteuid (sct->m_uid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper UID for applet!");
} else
setuid (ruid); /* no suid -> drop */
} else {
/* default: drop all privileges */
setgid (rgid);
setuid (ruid);
}
return;
} else {
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
static int onetime = 0;
if (!onetime) {
onetime = 1;
fprintf (stderr, "Using fallback suid method\n");
}
#endif
}
#endif
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid () != 0)
bb_error_msg_and_die ("This applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
setgid (rgid); /* drop all privileges */
setuid (ruid);
}
}
#else
#define check_suid(x)
#endif /* CONFIG_FEATURE_SUID */
void bb_show_usage (void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
for (i = applet_using - applets; i > 0;) {
if (!*usage_string++) {
--i;
}
}
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
usage_string);
exit (bb_default_error_retval);
}
static int applet_name_compare (const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp (name, applet->name);
}
extern const size_t NUM_APPLETS;
struct BB_applet *find_applet_by_name (const char *name)
{
return bsearch (name, applets, NUM_APPLETS, sizeof (struct BB_applet),
applet_name_compare);
}
void run_applet_by_name (const char *name, int argc, char **argv)
{
if(ENABLE_FEATURE_SUID_CONFIG) parse_config_file ();
if(!strncmp(name, "busybox", 7)) busybox_main(argc, argv);
/* Do a binary search to find the applet entry given the name. */
applet_using = find_applet_by_name(name);
if(applet_using) {
bb_applet_name = applet_using->name;
if(argc==2 && !strcmp(argv[1], "--help")) bb_show_usage ();
if(ENABLE_FEATURE_SUID) check_suid (applet_using);
exit ((*(applet_using->main)) (argc, argv));
}
}
/* END CODE */
/*
+46 -82
View File
@@ -5,12 +5,13 @@
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#ifdef CONFIG_LOCALE_SUPPORT
#if ENABLE_LOCALE_SUPPORT
#include <locale.h>
#else
#define setlocale(x,y)
#endif
int been_there_done_that = 0; /* Also used in applets.c */
const char *bb_applet_name;
const char *bb_applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
#ifdef CONFIG_FEATURE_INSTALLER
/*
@@ -32,17 +33,6 @@ static const char* const install_dir[] = {
/* abstract link() */
typedef int (*__link_f)(const char *, const char *);
/*
* Where in the filesystem is this busybox?
* [return]
* malloc'd string w/ full pathname of busybox's location
* NULL on failure
*/
static inline char *busybox_fullpath(void)
{
return xreadlink("/proc/self/exe");
}
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
@@ -66,47 +56,35 @@ static void install_links(const char *busybox, int use_symbolic_links)
}
}
#else
#define install_links(x,y)
#endif /* CONFIG_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
bb_applet_name = argv[0];
bb_applet_name=argv[0];
if (*bb_applet_name == '-') bb_applet_name++;
for (s = bb_applet_name; *s ;)
if (*(s++) == '/') bb_applet_name = s;
if (bb_applet_name[0] == '-')
bb_applet_name++;
for (s = bb_applet_name; *s != '\0';) {
if (*s++ == '/')
bb_applet_name = s;
}
#ifdef CONFIG_LOCALE_SUPPORT
#ifdef CONFIG_INIT
if(getpid()!=1) /* Do not set locale for `init' */
#endif
{
/* Set locale for everybody except `init' */
if(ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
}
#endif
run_applet_by_name(bb_applet_name, argc, argv);
bb_error_msg_and_die("applet not found");
}
int busybox_main(int argc, char **argv)
{
int col = 0, len, i;
#ifdef CONFIG_FEATURE_INSTALLER
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
int use_symbolic_links = 0;
int rc = 0;
char *busybox;
@@ -119,7 +97,7 @@ int busybox_main(int argc, char **argv)
}
/* link */
busybox = busybox_fullpath();
busybox = xreadlink("/proc/self/exe");
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
@@ -128,60 +106,46 @@ int busybox_main(int argc, char **argv)
}
return rc;
}
#endif /* CONFIG_FEATURE_INSTALLER */
argc--;
/* Deal with --help. (Also print help when called with no arguments) */
/* If we've already been here once, exit now */
if (been_there_done_that == 1 || argc < 1) {
const struct BB_applet *a = applets;
int output_width = 60;
if (argc==1 || !strcmp(argv[1],"--help") ) {
if (argc>2) {
run_applet_by_name(bb_applet_name=argv[2], 2, argv);
} else {
const struct BB_applet *a;
int col, output_width;
#ifdef CONFIG_FEATURE_AUTOWIDTH
/* Obtain the terminal width. */
get_terminal_width_height(0, &output_width, NULL);
/* leading tab and room to wrap */
output_width -= 20;
#endif
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width. */
get_terminal_width_height(0, &output_width, NULL);
/* leading tab and room to wrap */
output_width -= 20;
} else output_width = 60;
fprintf(stderr, "%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use, and BusyBox\n"
"\twill act like whatever it was invoked as.\n"
"\nCurrently defined functions:\n", bb_msg_full_version);
printf("%s\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use and BusyBox\n"
"\twill act like whatever it was invoked as!\n"
"\nCurrently defined functions:\n", bb_msg_full_version);
while (a->name != 0) {
col +=
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
(a++)->name);
if (col > output_width && a->name != 0) {
fprintf(stderr, ",\n");
col = 0;
col=0;
for(a = applets; a->name;) {
col += printf("%s%s", (col ? ", " : "\t"), (a++)->name);
if (col > output_width && a->name) {
printf(",\n");
col = 0;
}
}
printf("\n\n");
exit(0);
}
fprintf(stderr, "\n\n");
exit(0);
}
} else run_applet_by_name(bb_applet_name=argv[1], argc-1, argv+1);
/* Flag that we've been here already */
been_there_done_that = 1;
/* Move the command line down a notch */
/* Preserve pointers so setproctitle() works consistently */
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));
bb_error_msg_and_die("applet not found");
}
/*
+2 -2
View File
@@ -10,9 +10,9 @@
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-include/config.h}
CONFIG_H=${1:-include/bb_config.h}
APPLETS_H=${2:-include/applets.h}
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
dir=substr($2,8)
gsub("_","/",dir)
+26 -8
View File
@@ -3,19 +3,37 @@
export LC_ALL=POSIX
export LC_CTYPE=POSIX
prefix=$1
if [ "$prefix" = "" ]; then
echo "No installation directory, aborting."
prefix=${1}
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
fi
if [ "$2" = "--hardlinks" ]; then
linkopts="-f"
else
linkopts="-fs"
fi
h=`sort busybox.links | uniq`
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
esac
if [ "$DO_INSTALL_LIBS" != "n" ]; then
# get the target dir for the libs
# assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \
sed -n 's%^.*\(/lib[^\/]*\)/libc.so%\1%p')
if test -z "$libdir"; then
libdir=/lib
fi
mkdir -p $prefix/$libdir || exit 1
for i in $DO_INSTALL_LIBS; do
rm -f $prefix/$libdir/$i || exit 1
if [ -f $i ]; then
cp -a $i $prefix/$libdir/ || exit 1
chmod 0644 $prefix/$libdir/$i || exit 1
fi
done
fi
rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
+10
View File
@@ -0,0 +1,10 @@
#include "busybox.h"
#ifndef BB_EXTRA_VERSION
#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#else
#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
#endif
const char BB_BANNER[]=BANNER;
const char * const bb_msg_full_version = BANNER " multi-call binary";
+49 -7
View File
@@ -47,10 +47,10 @@ config CONFIG_BUNZIP2
is generally considerably better than that achieved by more
conventional LZ77/LZ78-based compressors, and approaches the
performance of the PPM family of statistical compressors.
The BusyBox bunzip2 applet is limited to de-compression only.
On an x86 system, this applet adds about 11K.
Unless you have a specific application which requires bunzip2, you
should probably say N here.
@@ -73,7 +73,7 @@ config CONFIG_DPKG
default n
help
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
This implementation of dpkg has a number of limitations, you should use the
official dpkg if possible.
@@ -82,9 +82,9 @@ config CONFIG_DPKG_DEB
default n
help
dpkg-deb packs, unpacks and provides information about Debian archives.
This implementation of dpkg-deb cannot pack archives.
Unless you have a specific application which requires dpkg-deb, you should
probably say N here.
@@ -157,6 +157,14 @@ config CONFIG_FEATURE_TAR_BZIP2
If you enable this option you'll be able to extract
archives compressed with bzip2.
config CONFIG_FEATURE_TAR_LZMA
bool " Enable -a option to handle .tar.lzma files"
default n
depends on CONFIG_TAR
help
If you enable this option you'll be able to extract
archives compressed with lzma.
config CONFIG_FEATURE_TAR_FROM
bool " Enable -X (exclude from) and -T (include from) options)"
default n
@@ -212,6 +220,29 @@ config CONFIG_UNCOMPRESS
uncompress is used to decompress archives created by compress.
Not much used anymore, replaced by gzip/gunzip.
config CONFIG_UNLZMA
bool "unlzma"
default n
help
unlzma is a compression utility using the Lempel-Ziv-Markov chain
compression algorithm, and range coding. Compression
is generally considerably better than that achieved by the bzip2
compressors.
The BusyBox unlzma applet is limited to de-compression only.
On an x86 system, this applet adds about 4K.
Unless you have a specific application which requires unlzma, you
should probably say N here.
config CONFIG_FEATURE_LZMA_FAST
bool " Optimze unlzma for speed"
default n
depends on CONFIG_UNLZMA
help
This option reduce decompression time by about 33% at the cost of
a 2K bigger binary.
config CONFIG_UNZIP
bool "unzip"
default n
@@ -241,7 +272,7 @@ config CONFIG_FEATURE_DEB_TAR_GZ
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
help
This is the default compression method inside the debian ar file.
If you want compatibility with standard .deb's you should say yes here.
config CONFIG_FEATURE_DEB_TAR_BZ2
@@ -251,8 +282,19 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
help
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
with bzip2 instead of gzip.
You only want this if you are creating your own custom debian packages that
use an internal control.tar.bz2 or data.tar.bz2.
config CONFIG_FEATURE_DEB_TAR_LZMA
bool " lzma debian packages"
default n
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed
internally with lzma instead of gzip.
You only want this if you are creating your own custom debian
packages that use an internal control.tar.lzma or data.tar.lzma.
endmenu
+6 -15
View File
@@ -1,24 +1,15 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
ARCHIVAL_DIR:=./
srcdir=$(top_srcdir)/archival
include $(top_builddir)/Rules.mak
+12 -18
View File
@@ -1,21 +1,8 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ARCHIVAL_AR:=archival.a
ifndef $(ARCHIVAL_DIR)
@@ -27,6 +14,7 @@ ARCHIVAL-y:=
ARCHIVAL-$(CONFIG_APT_GET) +=
ARCHIVAL-$(CONFIG_AR) += ar.o
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
ARCHIVAL-$(CONFIG_UNLZMA) += unlzma.o
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
@@ -38,11 +26,17 @@ ARCHIVAL-$(CONFIG_TAR) += tar.o
ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
ifneq ($(strip $(ARCHIVAL-y)),)
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
endif
ARCHIVAL_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(ARCHIVAL-y))
ARCHIVAL_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(ARCHIVAL_SRC-y)
APPLET_SRC-a+=$(ARCHIVAL_SRC-a)
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
$(AR) -ro $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
$(do_ar)
$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
$(compile.c)
+16 -14
View File
@@ -27,7 +27,6 @@
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,27 +49,27 @@ static void header_verbose_list_ar(const file_header_t *file_header)
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name);
}
#define AR_CTX_PRINT 0x01
#define AR_CTX_LIST 0x02
#define AR_CTX_EXTRACT 0x04
#define AR_CTX_PRINT 0x01
#define AR_CTX_LIST 0x02
#define AR_CTX_EXTRACT 0x04
#define AR_OPT_PRESERVE_DATE 0x08
#define AR_OPT_VERBOSE 0x10
#define AR_OPT_CREATE 0x20
#define AR_OPT_VERBOSE 0x10
#define AR_OPT_CREATE 0x20
#define AR_OPT_INSERT 0x40
extern int ar_main(int argc, char **argv)
int ar_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
unsigned long opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
archive_handle = init_handle();
bb_opt_complementaly = "p~tx:t~px:x~pt";
opt = bb_getopt_ulflags(argc, argv, "ptxovc");
if ((opt & 0x80000000UL) || (optind == argc)) {
bb_show_usage();
}
/* Prepend '-' to the first argument if required */
bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
@@ -88,7 +87,10 @@ extern int ar_main(int argc, char **argv)
archive_handle->action_header = header_verbose_list_ar;
}
if (opt & AR_OPT_CREATE) {
bb_error_msg_and_die("Archive creation not supported. Install binutils 'ar'.");
bb_error_msg_and_die(msg_unsupported_err, "creation");
}
if (opt & AR_OPT_INSERT) {
bb_error_msg_and_die(msg_unsupported_err, "insertion");
}
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
+22 -48
View File
@@ -2,23 +2,10 @@
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* 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.
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -32,60 +19,47 @@
int bunzip2_main(int argc, char **argv)
{
char *compressed_name;
/* Note: Ignore the warning about save_name being used uninitialized.
* That is not the case, but gcc has trouble working that out... */
char *save_name;
char *filename;
unsigned long opt;
int status;
int src_fd;
int dst_fd;
int status, src_fd, dst_fd;
opt = bb_getopt_ulflags(argc, argv, "cf");
/* if called as bzcat force the stdout flag */
if (bb_applet_name[2] == 'c') {
opt |= BUNZIP2_OPT_STDOUT;
}
/* Set input filename and number */
compressed_name = argv[optind];
if ((compressed_name) && (compressed_name[0] != '-') && (compressed_name[1] != '\0')) {
filename = argv[optind];
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = bb_xopen(compressed_name, O_RDONLY);
src_fd = bb_xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
opt |= BUNZIP2_OPT_STDOUT;
filename = 0;
}
/* if called as bzcat force the stdout flag */
if ((opt & BUNZIP2_OPT_STDOUT) || bb_applet_name[2] == 'c')
filename = 0;
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
}
if (opt & BUNZIP2_OPT_STDOUT) {
dst_fd = STDOUT_FILENO;
} else {
int len = strlen(compressed_name) - 4;
if (strcmp(compressed_name + len, ".bz2") != 0) {
if (filename) {
char *extension=filename+strlen(filename)-4;
if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
save_name = bb_xstrndup(compressed_name, len);
dst_fd = bb_xopen(save_name, O_WRONLY | O_CREAT);
}
*extension=0;
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if(!(opt & BUNZIP2_OPT_STDOUT)) {
char *delete_name;
if (status) {
delete_name = save_name;
} else {
delete_name = compressed_name;
}
if (unlink(delete_name) < 0) {
bb_error_msg_and_die("Couldn't remove %s", delete_name);
if(filename) {
if (!status) filename[strlen(filename)]='.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("Couldn't remove %s", filename);
}
}
return status;
}
/* vi:set ts=4: */
+9 -10
View File
@@ -24,22 +24,21 @@
*
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "unarchive.h"
#include "busybox.h"
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
#define CPIO_OPT_PRESERVE_MTIME 0x40
#define CPIO_OPT_PRESERVE_MTIME 0x40
extern int cpio_main(int argc, char **argv)
int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
@@ -59,7 +58,7 @@ extern int cpio_main(int argc, char **argv)
}
if (opt & CPIO_OPT_TEST) {
/* if both extract and test option are given, ignore extract option */
/* if both extract and test options are given, ignore extract option */
if (opt & CPIO_OPT_EXTRACT) {
opt &= ~CPIO_OPT_EXTRACT;
}
@@ -79,7 +78,7 @@ extern int cpio_main(int argc, char **argv)
archive_handle->action_header = header_list;
}
}
if (cpio_filename) { /* CPIO_OPT_FILE */
if (cpio_filename) { /* CPIO_OPT_FILE */
archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
+52 -48
View File
@@ -58,7 +58,7 @@
* I estimate it should be at least 50% bigger than PACKAGE_HASH_PRIME,
* as there a lot of duplicate version numbers */
#define NAME_HASH_PRIME 16381
char *name_hashtable[NAME_HASH_PRIME + 1];
static char *name_hashtable[NAME_HASH_PRIME + 1];
/* PACKAGE_HASH_PRIME, Maximum number of unique packages,
* It must not be smaller than STATUS_HASH_PRIME,
@@ -82,7 +82,7 @@ typedef struct common_node_s {
unsigned int num_of_edges:14;
edge_t **edge;
} common_node_t;
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
static common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
/* Currently it doesnt store packages that have state-status of not-installed
* So it only really has to be the size of the maximum number of packages
@@ -92,7 +92,7 @@ typedef struct status_node_s {
unsigned int package:14; /* has to fit PACKAGE_HASH_PRIME */
unsigned int status:14; /* has to fit STATUS_HASH_PRIME */
} status_node_t;
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
static status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
/* Even numbers are for 'extras', like ored dependencies or null */
enum edge_type_e {
@@ -137,7 +137,7 @@ typedef struct deb_file_s {
} deb_file_t;
void make_hash(const char *key, unsigned int *start, unsigned int *decrement, const int hash_prime)
static void make_hash(const char *key, unsigned int *start, unsigned int *decrement, const int hash_prime)
{
unsigned long int hash_num = key[0];
int len = strlen(key);
@@ -157,7 +157,7 @@ void make_hash(const char *key, unsigned int *start, unsigned int *decrement, co
}
/* this adds the key to the hash table */
int search_name_hashtable(const char *key)
static int search_name_hashtable(const char *key)
{
unsigned int probe_address = 0;
unsigned int probe_decrement = 0;
@@ -181,7 +181,7 @@ int search_name_hashtable(const char *key)
/* this DOESNT add the key to the hashtable
* TODO make it consistent with search_name_hashtable
*/
unsigned int search_status_hashtable(const char *key)
static unsigned int search_status_hashtable(const char *key)
{
unsigned int probe_address = 0;
unsigned int probe_decrement = 0;
@@ -201,7 +201,7 @@ unsigned int search_status_hashtable(const char *key)
}
/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */
int version_compare_part(const char *version1, const char *version2)
static int version_compare_part(const char *version1, const char *version2)
{
int upstream_len1 = 0;
int upstream_len2 = 0;
@@ -268,7 +268,7 @@ cleanup_version_compare_part:
* if ver1 = ver2 return 0,
* if ver1 > ver2 return 1,
*/
int version_compare(const unsigned int ver1, const unsigned int ver2)
static int version_compare(const unsigned int ver1, const unsigned int ver2)
{
char *ch_ver1 = name_hashtable[ver1];
char *ch_ver2 = name_hashtable[ver2];
@@ -330,7 +330,7 @@ int version_compare(const unsigned int ver1, const unsigned int ver2)
return(version_compare_part(deb_ver1, deb_ver2));
}
int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator)
static int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator)
{
const int version_result = version_compare(version1, version2);
switch(operator) {
@@ -366,7 +366,7 @@ int test_version(const unsigned int version1, const unsigned int version2, const
}
int search_package_hashtable(const unsigned int name, const unsigned int version, const unsigned int operator)
static int search_package_hashtable(const unsigned int name, const unsigned int version, const unsigned int operator)
{
unsigned int probe_address = 0;
unsigned int probe_decrement = 0;
@@ -405,7 +405,7 @@ int search_package_hashtable(const unsigned int name, const unsigned int version
* FIXME: I don't think this is very efficient, but I thought I'd keep
* it simple for now until it proves to be a problem.
*/
int search_for_provides(int needle, int start_at) {
static int search_for_provides(int needle, int start_at) {
int i, j;
common_node_t *p;
for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) {
@@ -421,7 +421,7 @@ int search_for_provides(int needle, int start_at) {
/*
* Add an edge to a node
*/
void add_edge_to_node(common_node_t *node, edge_t *edge)
static void add_edge_to_node(common_node_t *node, edge_t *edge)
{
node->num_of_edges++;
node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1));
@@ -438,7 +438,7 @@ void add_edge_to_node(common_node_t *node, edge_t *edge)
* field contains the number of EDGE nodes which follow as part of
* this alternative.
*/
void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type)
static void add_split_dependencies(common_node_t *parent_node, const char *whole_line, unsigned int edge_type)
{
char *line = bb_xstrdup(whole_line);
char *line2;
@@ -537,24 +537,26 @@ void add_split_dependencies(common_node_t *parent_node, const char *whole_line,
return;
}
void free_package(common_node_t *node)
static void free_package(common_node_t *node)
{
unsigned short i;
if (node) {
for (i = 0; i < node->num_of_edges; i++) {
free(node->edge[i]);
}
if ( node->edge )
free(node->edge);
free(node->edge);
free(node);
}
}
unsigned int fill_package_struct(char *control_buffer)
static unsigned int fill_package_struct(char *control_buffer)
{
static const char *const field_names[] = { "Package", "Version",
"Pre-Depends", "Depends","Replaces", "Provides",
"Conflicts", "Suggests", "Recommends", "Enhances", 0
};
common_node_t *new_node = (common_node_t *) xcalloc(1, sizeof(common_node_t));
const char *field_names[] = { "Package", "Version", "Pre-Depends", "Depends",
"Replaces", "Provides", "Conflicts", "Suggests", "Recommends", "Enhances", 0};
char *field_name;
char *field_value;
int field_start = 0;
@@ -624,7 +626,7 @@ fill_package_struct_cleanup:
}
/* if num = 1, it returns the want status, 2 returns flag, 3 returns status */
unsigned int get_status(const unsigned int status_node, const int num)
static unsigned int get_status(const unsigned int status_node, const int num)
{
char *status_string = name_hashtable[status_hashtable[status_node]->status];
char *state_sub_string;
@@ -646,7 +648,7 @@ unsigned int get_status(const unsigned int status_node, const int num)
return(state_sub_num);
}
void set_status(const unsigned int status_node_num, const char *new_value, const int position)
static void set_status(const unsigned int status_node_num, const char *new_value, const int position)
{
const unsigned int new_value_len = strlen(new_value);
const unsigned int new_value_num = search_name_hashtable(new_value);
@@ -682,7 +684,7 @@ void set_status(const unsigned int status_node_num, const char *new_value, const
return;
}
const char *describe_status(int status_num) {
static const char *describe_status(int status_num) {
int status_want, status_state ;
if ( status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0 )
return "is not installed or flagged to be installed\n";
@@ -707,7 +709,7 @@ const char *describe_status(int status_num) {
}
void index_status_file(const char *filename)
static void index_status_file(const char *filename)
{
FILE *status_file;
char *control_buffer;
@@ -812,7 +814,7 @@ char *get_depends_field(common_node_t *package, const int depends_type)
}
#endif
void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
static void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
{
char *name;
char *value;
@@ -830,7 +832,7 @@ void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
}
/* This could do with a cleanup */
void write_status_file(deb_file_t **deb_file)
static void write_status_file(deb_file_t **deb_file)
{
FILE *old_status_file = bb_xfopen("/var/lib/dpkg/status", "r");
FILE *new_status_file = bb_xfopen("/var/lib/dpkg/status.udeb", "w");
@@ -850,7 +852,7 @@ void write_status_file(deb_file_t **deb_file)
}
tmp_string += 8;
tmp_string += strspn(tmp_string, " \n\t");
tmp_string += strspn(tmp_string, " \n\t");
package_name = bb_xstrndup(tmp_string, strcspn(tmp_string, "\n\0"));
write_flag = FALSE;
tmp_string = strstr(control_buffer, "Status:");
@@ -978,7 +980,7 @@ void write_status_file(deb_file_t **deb_file)
* which a regular depends can be satisfied by a package which we want
* to install.
*/
int package_satisfies_dependency(int package, int depend_type)
static int package_satisfies_dependency(int package, int depend_type)
{
int status_num = search_status_hashtable(name_hashtable[package_hashtable[package]->name]);
@@ -989,13 +991,13 @@ int package_satisfies_dependency(int package, int depend_type)
return 0;
switch (depend_type) {
case EDGE_PRE_DEPENDS: return get_status(status_num, 3) == search_name_hashtable("installed");
case EDGE_DEPENDS: return get_status(status_num, 1) == search_name_hashtable("install");
case EDGE_PRE_DEPENDS: return get_status(status_num, 3) == search_name_hashtable("installed");
case EDGE_DEPENDS: return get_status(status_num, 1) == search_name_hashtable("install");
}
return 0;
}
int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
{
int *conflicts = NULL;
int conflicts_num = 0;
@@ -1078,7 +1080,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
}
}
i++;
}
}
/* Check dependendcies */
@@ -1114,8 +1116,8 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
* things which are broken but unrelated to the
* packages that are currently being installed
*/
if (state_status == search_name_hashtable("installed"))
continue;
if (state_status == search_name_hashtable("installed"))
continue;
#endif
/* This code is tested only for EDGE_DEPENDS, since I
@@ -1125,13 +1127,13 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
for (j = 0; j < package_node->num_of_edges; j++) {
const edge_t *package_edge = package_node->edge[j];
unsigned int package_num;
if ( package_edge->type == EDGE_OR_PRE_DEPENDS ||
package_edge->type == EDGE_OR_DEPENDS ) { /* start an EDGE_OR_ list */
package_edge->type == EDGE_OR_DEPENDS ) { /* start an EDGE_OR_ list */
number_of_alternatives = package_edge->version;
root_of_alternatives = package_edge;
continue;
} else if ( number_of_alternatives == 0 ) { /* not in the middle of an EDGE_OR_ list */
} else if ( number_of_alternatives == 0 ) { /* not in the middle of an EDGE_OR_ list */
number_of_alternatives = 1;
root_of_alternatives = NULL;
}
@@ -1204,7 +1206,7 @@ int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
return(TRUE);
}
char **create_list(const char *filename)
static char **create_list(const char *filename)
{
FILE *list_stream;
char **file_list = NULL;
@@ -1233,7 +1235,7 @@ char **create_list(const char *filename)
}
/* maybe i should try and hook this into remove_file.c somehow */
int remove_file_array(char **remove_names, char **exclude_names)
static int remove_file_array(char **remove_names, char **exclude_names)
{
struct stat path_stat;
int match_flag;
@@ -1271,7 +1273,7 @@ int remove_file_array(char **remove_names, char **exclude_names)
return(remove_flag);
}
int run_package_script(const char *package_name, const char *script_type)
static int run_package_script(const char *package_name, const char *script_type)
{
struct stat path_stat;
char *script_path;
@@ -1290,16 +1292,16 @@ int run_package_script(const char *package_name, const char *script_type)
return(result);
}
const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL };
char **all_control_list(const char *package_name)
static char **all_control_list(const char *package_name)
{
unsigned short i = 0;
char **remove_files;
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = malloc(sizeof(all_control_files));
remove_files = xmalloc(sizeof(all_control_files));
while (all_control_files[i]) {
remove_files[i] = xmalloc(strlen(package_name) + strlen(all_control_files[i]) + 21);
sprintf(remove_files[i], "/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
@@ -1310,7 +1312,7 @@ char **all_control_list(const char *package_name)
return(remove_files);
}
void free_array(char **array)
static void free_array(char **array)
{
if (array) {
@@ -1327,9 +1329,9 @@ void free_array(char **array)
* the status_hashtable to retrieve the info. This results in smaller code than
* scanning the status file. The resulting list, however, is unsorted.
*/
void list_packages(void)
static void list_packages(void)
{
int i;
int i;
printf(" Name Version\n");
printf("+++-==============-==============\n");
@@ -1364,7 +1366,7 @@ void list_packages(void)
}
}
void remove_package(const unsigned int package_num, int noisy)
static void remove_package(const unsigned int package_num, int noisy)
{
const char *package_name = name_hashtable[package_hashtable[package_num]->name];
const char *package_version = name_hashtable[package_hashtable[package_num]->version];
@@ -1418,7 +1420,7 @@ void remove_package(const unsigned int package_num, int noisy)
set_status(status_num, "config-files", 3);
}
void purge_package(const unsigned int package_num)
static void purge_package(const unsigned int package_num)
{
const char *package_name = name_hashtable[package_hashtable[package_num]->name];
const char *package_version = name_hashtable[package_hashtable[package_num]->version];
@@ -1520,6 +1522,7 @@ static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, lli
{
ar_handle->sub_archive->action_data = data_extract_to_buffer;
ar_handle->sub_archive->accept = myaccept;
ar_handle->sub_archive->filter = filter_accept_list;
unpack_ar_archive(ar_handle);
close(ar_handle->src_fd);
@@ -1614,7 +1617,7 @@ static void unpack_package(deb_file_t *deb_file)
free(info_prefix);
}
void configure_package(deb_file_t *deb_file)
static void configure_package(deb_file_t *deb_file)
{
const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name];
const char *package_version = name_hashtable[package_hashtable[deb_file->package]->version];
@@ -1714,6 +1717,7 @@ int dpkg_main(int argc, char **argv)
if (package_num == -1) {
bb_error_msg("Invalid control file in %s", argv[optind]);
optind++;
continue;
}
deb_file[deb_count]->package = (unsigned int) package_num;
+4 -5
View File
@@ -18,7 +18,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "unarchive.h"
#include "busybox.h"
@@ -29,7 +28,7 @@
#define DPKG_DEB_OPT_EXTRACT 8
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
extern int dpkg_deb_main(int argc, char **argv)
int dpkg_deb_main(int argc, char **argv)
{
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
@@ -56,7 +55,7 @@ extern int dpkg_deb_main(int argc, char **argv)
control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
#endif
bb_opt_complementaly = "c~efXx:e~cfXx:f~ceXx:X~cefx:x~cefX";
bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = bb_getopt_ulflags(argc, argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
@@ -76,7 +75,7 @@ extern int dpkg_deb_main(int argc, char **argv)
* it should accept a second argument which specifies a
* specific field to print */
ar_archive->accept = control_tar_llist;
tar_archive->accept = llist_add_to(NULL, "./control");;
tar_archive->accept = llist_add_to(NULL, "./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
@@ -88,7 +87,7 @@ extern int dpkg_deb_main(int argc, char **argv)
argcount = 2;
}
if ((optind + argcount != argc) || (opt & 0x80000000UL)) {
if ((optind + argcount) != argc) {
bb_show_usage();
}
+3 -6
View File
@@ -63,7 +63,6 @@ static char *license_msg[] = {
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -76,7 +75,7 @@ static char *license_msg[] = {
#define GUNZIP_OPT_TEST 4
#define GUNZIP_OPT_DECOMPRESS 8
extern int gunzip_main(int argc, char **argv)
int gunzip_main(int argc, char **argv)
{
char status = EXIT_SUCCESS;
unsigned long opt;
@@ -104,9 +103,7 @@ extern int gunzip_main(int argc, char **argv)
src_fd = bb_xopen(old_path, O_RDONLY);
/* Get the time stamp on the input file. */
if (stat(old_path, &stat_buf) < 0) {
bb_error_msg_and_die("Couldn't stat file %s", old_path);
}
xstat(old_path, &stat_buf);
}
/* Check that the input is sane. */
@@ -117,7 +114,7 @@ extern int gunzip_main(int argc, char **argv)
/* Set output filename and number */
if (opt & GUNZIP_OPT_TEST) {
dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
dst_fd = bb_xopen(bb_dev_null, O_WRONLY); /* why does test use filenum 2 ? */
} else if (opt & GUNZIP_OPT_STDOUT) {
dst_fd = STDOUT_FILENO;
} else {
+24 -58
View File
@@ -13,20 +13,7 @@
* files as well as stdin/stdout, and to generally behave itself wrt
* command line handling.
*
* 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
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* These defines are very important for BusyBox. Without these,
@@ -51,12 +38,6 @@
#include <time.h>
#include "busybox.h"
#define memzero(s, n) memset ((void *)(s), 0, (n))
#ifndef RETSIGTYPE
# define RETSIGTYPE void
#endif
typedef unsigned char uch;
typedef unsigned short ush;
typedef unsigned long ulg;
@@ -214,9 +195,6 @@ typedef int file_t; /* Do not use stdio */
static int zip(int in, int out);
static int file_read(char *buf, unsigned size);
/* from gzip.c */
static RETSIGTYPE abort_gzip(void);
/* from deflate.c */
static void lm_init(ush * flags);
static ulg deflate(void);
@@ -243,10 +221,6 @@ static void flush_outbuf(void);
* terms of the GNU General Public License, see the file COPYING.
*/
#if !defined(OF) && defined(lint)
# include "gzip.h"
#endif
#ifndef BITS
# define BITS 16
#endif
@@ -335,7 +309,7 @@ static void put_short(ush w)
/* ========================================================================
* Signal and error handler.
*/
static void abort_gzip()
static void abort_gzip(int ATTRIBUTE_UNUSED ignored)
{
exit(ERROR);
}
@@ -350,13 +324,6 @@ static void clear_bufs(void)
bytes_in = 0L;
}
static void write_bb_error_msg(void)
{
fputc('\n', stderr);
bb_perror_nomsg();
abort_gzip();
}
/* ===========================================================================
* Does the same as write(), but also handles partial pipe writes and checks
* for error return.
@@ -366,9 +333,7 @@ static void write_buf(int fd, void *buf, unsigned cnt)
unsigned n;
while ((n = write(fd, buf, cnt)) != cnt) {
if (n == (unsigned) (-1)) {
write_bb_error_msg();
}
if (n == (unsigned) (-1)) bb_error_msg_and_die("can't write");
cnt -= n;
buf = (void *) ((char *) buf + n);
}
@@ -559,7 +524,7 @@ static unsigned bi_reverse(unsigned code, int len)
/* ===========================================================================
* Write out any remaining bits in an incomplete byte.
*/
static void bi_windup()
static void bi_windup(void)
{
if (bi_valid > 8) {
put_short(bi_buf);
@@ -767,25 +732,26 @@ static unsigned match_start; /* start of matching string */
static int eofile; /* flag set at end of input file */
static unsigned lookahead; /* number of valid bytes ahead in window */
static const unsigned max_chain_length = 4096;
enum {
max_chain_length = 4096,
/* To speed up deflation, hash chains are never searched beyond this length.
* A higher limit improves compression ratio but degrades the speed.
*/
static const unsigned int max_lazy_match = 258;
max_lazy_match = 258,
/* Attempt to find a better match only when the current match is strictly
* smaller than this value. This mechanism is used only for compression
* levels >= 4.
*/
#define max_insert_length max_lazy_match
max_insert_length = max_lazy_match,
/* Insert new strings in the hash table only if the match length
* is not greater than this length. This saves time but degrades compression.
* max_insert_length is used only for compression levels <= 3.
*/
static const unsigned good_match = 32;
good_match = 32,
/* Use a faster search when the previous match is longer than this */
@@ -796,12 +762,13 @@ static const unsigned good_match = 32;
* found for specific files.
*/
static const int nice_match = 258; /* Stop searching when current match exceeds this */
nice_match = 258 /* Stop searching when current match exceeds this */
/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
* For deflate_fast() (levels <= 3) good is ignored and lazy has a different
* meaning.
*/
};
#define EQUAL 0
/* result of memcmp for equal strings */
@@ -846,7 +813,7 @@ static void lm_init(ush * flags)
register unsigned j;
/* Initialize the hash table. */
memzero((char *) head, HASH_SIZE * sizeof(*head));
memset(head, 0, HASH_SIZE * sizeof(*head));
/* prev will be initialized on the fly */
*flags |= SLOW;
@@ -996,7 +963,7 @@ static void check_match(IPos start, IPos match, int length)
* file reads are performed for at least two bytes (required for the
* translate_eol option).
*/
static void fill_window()
static void fill_window(void)
{
register unsigned n, m;
unsigned more =
@@ -1053,14 +1020,14 @@ static void fill_window()
*/
#define FLUSH_BLOCK(eof) \
flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
(char*)NULL, (long)strstart - block_start, (eof))
(char*)NULL, (long)strstart - block_start, (eof))
/* ===========================================================================
* Same as above, but achieves better compression. We use a lazy
* evaluation for matches: a match is finally adopted only if there is
* no better match at the next window position.
*/
static ulg deflate()
static ulg deflate(void)
{
IPos hash_head; /* head of hash chain */
IPos prev_match; /* previous match */
@@ -1188,8 +1155,6 @@ static ulg deflate()
typedef struct dirent dir_type;
typedef RETSIGTYPE(*sig_type) (int);
/* ======================================================================== */
int gzip_main(int argc, char **argv)
{
@@ -1235,16 +1200,16 @@ int gzip_main(int argc, char **argv)
foreground = signal(SIGINT, SIG_IGN) != SIG_IGN;
if (foreground) {
(void) signal(SIGINT, (sig_type) abort_gzip);
(void) signal(SIGINT, abort_gzip);
}
#ifdef SIGTERM
if (signal(SIGTERM, SIG_IGN) != SIG_IGN) {
(void) signal(SIGTERM, (sig_type) abort_gzip);
(void) signal(SIGTERM, abort_gzip);
}
#endif
#ifdef SIGHUP
if (signal(SIGHUP, SIG_IGN) != SIG_IGN) {
(void) signal(SIGHUP, (sig_type) abort_gzip);
(void) signal(SIGHUP, abort_gzip);
}
#endif
@@ -1271,6 +1236,7 @@ int gzip_main(int argc, char **argv)
for (i = optind; i < argc; i++) {
char *path = NULL;
clear_bufs();
if (strcmp(argv[i], "-") == 0) {
time_stamp = 0;
ifile_size = -1L;
@@ -1289,7 +1255,7 @@ int gzip_main(int argc, char **argv)
strcat(path, ".gz");
/* Open output file */
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) && defined O_NOFOLLOW
outFileNum =
open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW);
#else
@@ -1749,7 +1715,7 @@ static void ct_init(ush * attr, int *methodp)
/* ===========================================================================
* Initialize a new block.
*/
static void init_block()
static void init_block(void)
{
int n; /* iterates over tree elements */
@@ -2162,7 +2128,7 @@ static void send_tree(ct_data * tree, int max_code)
* Construct the Huffman tree for the bit lengths and return the index in
* bl_order of the last bit length code to send.
*/
static const int build_bl_tree()
static int build_bl_tree(void)
{
int max_blindex; /* index of last bit length code of non zero freq */
@@ -2425,7 +2391,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree)
* IN assertion: the fields freq of dyn_ltree are set and the total of all
* frequencies does not exceed 64K (to fit in an int on 16 bit machines).
*/
static void set_file_type()
static void set_file_type(void)
{
int n = 0;
unsigned ascii_freq = 0;
@@ -2538,7 +2504,7 @@ static int file_read(char *buf, unsigned size)
* Write the output buffer outbuf[0..outcnt-1] and update bytes_out.
* (used for the compressed data only)
*/
static void flush_outbuf()
static void flush_outbuf(void)
{
if (outcnt == 0)
return;
+4
View File
@@ -17,8 +17,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
ifndef top_srcdir
top_srcdir=../..
endif
ifndef top_builddir
top_builddir=../..
endif
srcdir=$(top_srcdir)/archival/libunarchive
LIBUNARCHIVE_DIR:=./
include $(top_builddir)/Rules.mak
+20 -21
View File
@@ -2,26 +2,17 @@
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
LIBUNARCHIVE_AR:=libunarchive.a
ifndef $(LIBUNARCHIVE_DIR)
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive/
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive
endif
srcdir=$(top_srcdir)/archvial/libunarchive
srcdir=$(top_srcdir)/archival/libunarchive
LIBUNARCHIVE-obj:=$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR)
libraries-y+=$(LIBUNARCHIVE-obj)
LIBUNARCHIVE-y:= \
\
@@ -58,27 +49,35 @@ DPKG_FILES:= \
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
LIBUNARCHIVE-$(CONFIG_UNLZMA) += decompress_unlzma.o
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
libraries-y+=$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR)
$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
$(AR) -ro $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
LIBUNARCHIVE-y:=$(sort $(LIBUNARCHIVE-y))
$(LIBUNARCHIVA_DIR)%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
LIBUNARCHIVE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBUNARCHIVE-y)))
LIBUNARCHIVE_SRC-a:=$(wildcard $(srcdir)/*.c)
LIBRARY_SRC-y+=$(LIBUNARCHIVE_SRC-y)
LIBRARY_SRC-a+=$(LIBUNARCHIVE_SRC-a)
$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)/%,$(LIBUNARCHIVE-y))
$(do_ar)
$(LIBUNARCHIVE_DIR)/%.o: $(srcdir)/%.c
$(compile.c)
+1 -1
View File
@@ -20,7 +20,7 @@
#include "unarchive.h"
#include "libbb.h"
extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
{
ssize_t size;
@@ -20,13 +20,13 @@
#include "unarchive.h"
#include "libbb.h"
extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count)
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count)
{
ssize_t size;
size = bb_full_read(archive_handle->src_fd, buf, count);
if ((size != 0) && (size != count)) {
bb_perror_msg_and_die("Short read, read %d of %d", size, count);
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
}
return(size);
}
+2 -1
View File
@@ -1,8 +1,9 @@
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip */
extern void check_header_gzip(int src_fd)
void check_header_gzip(int src_fd)
{
union {
unsigned char raw[8];
+1 -1
View File
@@ -22,7 +22,7 @@
#include "libbb.h"
#include "unarchive.h"
extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
{
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
+7 -3
View File
@@ -27,7 +27,7 @@
#include "libbb.h"
#include "unarchive.h"
extern void data_extract_all(archive_handle_t *archive_handle)
void data_extract_all(archive_handle_t *archive_handle)
{
file_header_t *file_header = archive_handle->file_header;
int dst_fd;
@@ -111,8 +111,12 @@ extern void data_extract_all(archive_handle_t *archive_handle)
}
}
lchown(file_header->name, file_header->uid, file_header->gid);
if ((file_header->mode & S_IFMT) != S_IFLNK) {
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
lchown(file_header->name, file_header->uid, file_header->gid);
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM) &&
(file_header->mode & S_IFMT) != S_IFLNK)
{
chmod(file_header->name, file_header->mode);
}
@@ -17,7 +17,7 @@
#include "libbb.h"
#include "unarchive.h"
extern void data_extract_to_buffer(archive_handle_t *archive_handle)
void data_extract_to_buffer(archive_handle_t *archive_handle)
{
const unsigned int size = archive_handle->file_header->size;
@@ -17,7 +17,7 @@
#include "unarchive.h"
#include <unistd.h>
extern void data_extract_to_stdout(archive_handle_t *archive_handle)
void data_extract_to_stdout(archive_handle_t *archive_handle)
{
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
}
+1 -1
View File
@@ -21,7 +21,7 @@
#include "unarchive.h"
#include "libbb.h"
extern void data_skip(archive_handle_t *archive_handle)
void data_skip(archive_handle_t *archive_handle)
{
archive_handle->seek(archive_handle, archive_handle->file_header->size);
}
+164 -35
View File
@@ -7,7 +7,7 @@
Robert Sedgewick, and Jon L. Bentley.
This code is licensed under the LGPLv2:
LGPL (http://www.gnu.org/copyleft/lgpl.html
LGPL http://www.gnu.org/copyleft/lgpl.html
*/
/*
@@ -23,19 +23,8 @@
I would ask that anyone benefiting from this work, especially those
using it in commercial products, consider making a donation to my local
non-profit hospice organization in the name of the woman I loved, who
passed away Feb. 12, 2003.
In memory of Toni W. Hagan
Hospice of Acadiana, Inc.
2600 Johnston St., Suite 200
Lafayette, LA 70503-3240
Phone (337) 232-1234 or 1-800-738-2226
Fax (337) 232-1297
http://www.hospiceacadiana.com/
non-profit hospice organization (www.hospiceacadiana.com) in the name of
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
Manuel
*/
@@ -51,9 +40,9 @@
/* Constants for Huffman coding */
#define MAX_GROUPS 6
#define GROUP_SIZE 50 /* 64 would have been more efficient */
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
#define GROUP_SIZE 50 /* 64 would have been more efficient */
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
#define SYMBOL_RUNA 0
#define SYMBOL_RUNB 1
@@ -79,51 +68,73 @@ struct group_data {
/* Structure holding all the housekeeping data, including IO buffers and
memory that persists between calls to bunzip */
typedef struct {
/* State for interrupting output loop */
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
/* I/O tracking data (file handles, buffers, positions, etc.) */
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
unsigned char *inbuf /*,*outbuf*/;
unsigned int inbufBitCount, inbufBits;
/* The CRC values stored in the block header and calculated from the data */
unsigned int crc32Table[256],headerCRC, totalCRC, writeCRC;
/* Intermediate buffer and its size (in bytes) */
unsigned int *dbuf, dbufSize;
/* These things are a bit too big to go on the stack */
unsigned char selectors[32768]; /* nSelectors=15 bits */
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
/* For I/O error handling */
jmp_buf jmpbuf;
} bunzip_data;
/* Return the next nnn bits of input. All reads from the compressed input
are done through this function. All reads are big endian */
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
{
unsigned int bits=0;
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while (bd->inbufBitCount<bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if(bd->inbufPos==bd->inbufCount) {
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
bd->inbufPos=0;
}
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
if(bd->inbufBitCount>=24) {
bits=bd->inbufBits&((1<<bd->inbufBitCount)-1);
bits_wanted-=bd->inbufBitCount;
bits<<=bits_wanted;
bd->inbufBitCount=0;
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
bd->inbufBitCount+=8;
}
/* Calculate result */
bd->inbufBitCount-=bits_wanted;
bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<<bits_wanted)-1);
@@ -134,8 +145,6 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
static int get_next_block(bunzip_data *bd)
{
/* Note: Ignore the warning about hufGroup, base and limit being used uninitialized.
* They will be initialized on the fist pass of the loop. */
struct group_data *hufGroup;
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
@@ -145,26 +154,34 @@ static int get_next_block(bunzip_data *bd)
dbuf=bd->dbuf;
dbufSize=bd->dbufSize;
selectors=bd->selectors;
/* Reset longjmp I/O error handling */
i=setjmp(bd->jmpbuf);
if(i) return i;
/* Read in header signature and CRC, then validate signature.
(last block signature means CRC is for whole file, return now) */
i = get_bits(bd,24);
j = get_bits(bd,24);
bd->headerCRC=get_bits(bd,32);
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
/* We can add support for blockRandomised if anybody complains. There was
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
it didn't actually work. */
if(get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
if((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
symbols to deal with, and writes a sparse bitfield indicating which
values were present. We make a translation table to convert the symbols
back to the corresponding bytes. */
t=get_bits(bd, 16);
symTotal=0;
for (i=0;i<16;i++) {
@@ -174,60 +191,81 @@ static int get_next_block(bunzip_data *bd)
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
}
}
/* How many different Huffman coding groups does this block use? */
groupCount=get_bits(bd,3);
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
group. Read in the group selector list, which is stored as MTF encoded
bit runs. (MTF=Move To Front, as each value is used it's moved to the
start of the list.) */
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
for(i=0; i<groupCount; i++) mtfSymbol[i] = i;
for(i=0; i<nSelectors; i++) {
/* Get next value */
for(j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
/* Decode MTF to get the next selector */
uc = mtfSymbol[j];
for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
mtfSymbol[0]=selectors[i]=uc;
}
/* Read the Huffman coding tables for each group, which code for symTotal
literal symbols, plus two run symbols (RUNA, RUNB) */
symCount=symTotal+2;
for (j=0; j<groupCount; j++) {
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
a way similar to mtf; record a starting value for the first symbol,
and an offset from the previous value for everys symbol after that.
(Subtracting 1 before the loop and then adding it back at the end is
an optimization that makes the test inside the loop simpler: symbol
length 0 becomes negative, so an unsigned inequality catches it.) */
t=get_bits(bd, 5)-1;
for (i = 0; i < symCount; i++) {
for(;;) {
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
return RETVAL_DATA_ERROR;
/* If first bit is 0, stop. Else second bit indicates whether
to increment or decrement the value. Optimization: grab 2
bits and unget the second if the first was 0. */
k = get_bits(bd,2);
if (k < 2) {
bd->inbufBitCount++;
break;
}
/* Add one if second bit 1, else subtract 1. Avoids if/else */
t+=(((k+1)&2)-1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i]=t+1;
}
/* Find largest and smallest lengths in this group */
minLen=maxLen=length[0];
for(i = 1; i < symCount; i++) {
if(length[i] > maxLen) maxLen = length[i];
else if(length[i] < minLen) minLen = length[i];
}
/* Calculate permute[], base[], and limit[] tables from length[].
*
* permute[] is the lookup table for converting Huffman coded symbols
@@ -238,36 +276,47 @@ static int get_next_block(bunzip_data *bd)
* number of bits can have. This is how the Huffman codes can vary in
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup=bd->groups+j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
/* Note that minLen can't be smaller than 1, so we adjust the base
and limit array pointers so we're not always wasting the first
entry. We do this again when using them (during symbol decoding).*/
base=hufGroup->base-1;
limit=hufGroup->limit-1;
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
pp=0;
for(i=minLen;i<=maxLen;i++) {
temp[i]=limit[i]=0;
for(t=0;t<symCount;t++)
if(length[t]==i) hufGroup->permute[pp++] = t;
}
/* Count symbols coded for at each bit length */
for (i=0;i<symCount;i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
* limit minus the cumulative count of symbols coded for already). */
pp=t=0;
for (i=minLen; i<maxLen; i++) {
pp+=temp[i];
/* We read the largest possible symbol size and then unget bits
after determining how many we need, and those extra bits could
be set to anything. (They're noise from future symbols.) At
each level we're really only interested in the first few bits,
so here we set all the trailing to-be-ignored bits to 1 so they
don't affect the value>limit[length] comparison. */
limit[i]= (pp << (maxLen - i)) - 1;
pp<<=1;
base[i+1]=pp-(t+=temp[i]);
@@ -276,27 +325,34 @@ static int get_next_block(bunzip_data *bd)
limit[maxLen]=pp+temp[maxLen]-1;
base[minLen]=0;
}
/* We've finished reading and digesting the block header. Now read this
block's Huffman coded symbols from the file and undo the Huffman coding
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
/* Initialize symbol occurrence counters and symbol Move To Front table */
for(i=0;i<256;i++) {
byteCount[i] = 0;
mtfSymbol[i]=(unsigned char)i;
}
/* Loop through compressed symbols. */
runPos=dbufCount=symCount=selector=0;
runPos=dbufCount=selector=0;
for(;;) {
/* Determine which Huffman coding group to use. */
if(!(symCount--)) {
symCount=GROUP_SIZE-1;
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
hufGroup=bd->groups+selectors[selector++];
base=hufGroup->base-1;
limit=hufGroup->limit-1;
}
/* fetch next Huffman coding group from list. */
symCount=GROUP_SIZE-1;
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
hufGroup=bd->groups+selectors[selector++];
base=hufGroup->base-1;
limit=hufGroup->limit-1;
continue_this_group:
/* Read next Huffman-coded symbol. */
/* Note: It is far cheaper to read maxLen bits and back up than it is
to read minLen bits and then an additional bit at a time, testing
as we go. Because there is a trailing last block (with file CRC),
@@ -306,6 +362,7 @@ static int get_next_block(bunzip_data *bd)
dry). The following (up to got_huff_bits:) is equivalent to
j=get_bits(bd,hufGroup->maxLen);
*/
while (bd->inbufBitCount<hufGroup->maxLen) {
if(bd->inbufPos==bd->inbufCount) {
j = get_bits(bd,hufGroup->maxLen);
@@ -316,27 +373,37 @@ static int get_next_block(bunzip_data *bd)
};
bd->inbufBitCount-=hufGroup->maxLen;
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i=hufGroup->minLen;
while(j>limit[i]) ++i;
bd->inbufBitCount += (hufGroup->maxLen - i);
/* Huffman decode value to get nextSym (with bounds checking) */
if ((i > hufGroup->maxLen)
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
>= MAX_SYMBOLS))
return RETVAL_DATA_ERROR;
nextSym = hufGroup->permute[j];
/* We have now decoded the symbol, which indicates either a new literal
byte, or a repeated run of the most recent literal byte. First,
check if nextSym indicates a repeated run, and if so loop collecting
how many times to repeat the last literal. */
if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if(!runPos) {
runPos = 1;
t = 0;
}
/* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at
each bit position, add 1 or 2 instead. For example,
1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2.
@@ -344,14 +411,17 @@ got_huff_bits:
the basic or 0/1 method (except all bits 0, which would use no
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
runPos <<= 1;
continue;
if(runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
}
/* When we hit the first non-run symbol after a run, we now know
how many times to repeat the last literal, so append that many
copies to our buffer of decoded symbols (dbuf) now. (The last
literal used is the one at the head of the mtfSymbol array.) */
if(runPos) {
runPos=0;
if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR;
@@ -360,8 +430,11 @@ got_huff_bits:
byteCount[uc] += t;
while(t--) dbuf[dbufCount++]=uc;
}
/* Is this the terminating symbol? */
if(nextSym>symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
one to get the position in the MTF array at which this literal is
currently to be found. (Note that the result can't be -1 or 0,
@@ -369,44 +442,62 @@ got_huff_bits:
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
/* Adjust the MTF array. Since we typically expect to move only a
* small number of symbols, and are bound by 256 in any case, using
* memmove here would typically be bigger and slower due to function
* call overhead and other assorted setup costs. */
do {
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
mtfSymbol[0] = uc;
uc=symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned int)uc;
/* Skip group initialization if we're not done with this group. Done
* this way to avoid compiler warning. */
end_of_huffman_loop:
if(symCount--) goto continue_this_group;
}
/* At this point, we've read all the Huffman-coded symbols (and repeated
runs) for this block from the input stream, and decoded them into the
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
Now undo the Burrows-Wheeler transform on dbuf.
See http://dogma.net/markn/articles/bwt/bwt.htm
*/
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j=0;
for(i=0;i<256;i++) {
k=j+byteCount[i];
byteCount[i] = j;
j=k;
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i=0;i<dbufCount;i++) {
uc=(unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
byteCount[uc]++;
}
/* Decode first byte by hand to initialize "previous" byte. Note that it
doesn't get output, and if the first three characters are identical
it doesn't qualify as a run (hence writeRunCountdown=5). */
if(dbufCount) {
if(origPtr>=dbufCount) return RETVAL_DATA_ERROR;
bd->writePos=dbuf[origPtr];
@@ -444,22 +535,32 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
Huffman-decoded a block into the intermediate buffer yet). */
if (bd->writeCopies) {
/* Inside the loop, writeCopies means extra copies (beyond 1) */
--bd->writeCopies;
/* Loop outputting bytes */
for(;;) {
/* If the output buffer is full, snapshot state and return */
if(gotcount >= len) {
bd->writePos=pos;
bd->writeCurrent=current;
bd->writeCopies++;
return len;
}
/* Write next byte into output buffer, updating CRC */
outbuf[gotcount++] = current;
bd->writeCRC=(((bd->writeCRC)<<8)
^bd->crc32Table[((bd->writeCRC)>>24)^current]);
/* Loop now if we're outputting multiple copies of this byte */
if (bd->writeCopies) {
--bd->writeCopies;
continue;
@@ -471,26 +572,38 @@ decode_next_byte:
pos=dbuf[pos];
current=pos&0xff;
pos>>=8;
/* After 3 consecutive copies of the same byte, the 4th is a repeat
count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if(--bd->writeRunCountdown) {
if(current!=previous) bd->writeRunCountdown=4;
} else {
/* We have a repeated run, this byte indicates the count */
bd->writeCopies=current;
current=previous;
bd->writeRunCountdown=5;
/* Sometimes there are just 3 bytes (run length 0) */
if(!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
--bd->writeCopies;
}
}
/* Decompression of this block completed successfully */
bd->writeCRC=~bd->writeCRC;
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
/* If this block had a CRC error, force file level CRC error. */
if(bd->writeCRC!=bd->headerCRC) {
bd->totalCRC=bd->headerCRC+1;
return RETVAL_LAST_BLOCK;
@@ -499,6 +612,7 @@ decode_next_byte:
/* Refill the intermediate buffer by Huffman-decoding next block of input */
/* (previous is just a convenient unused temp variable here) */
previous=get_next_block(bd);
if(previous) {
bd->writeCount=previous;
@@ -513,7 +627,9 @@ decode_next_byte:
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
static int start_bunzip(bunzip_data **bdp, int in_fd, char *inbuf, int len)
static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
int len)
{
bunzip_data *bd;
unsigned int i,j,c;
@@ -521,33 +637,44 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, char *inbuf, int len)
+(((unsigned int)'h')<<8)+(unsigned int)'0';
/* Figure out how much data to allocate */
i=sizeof(bunzip_data);
if(in_fd!=-1) i+=IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd=*bdp=xmalloc(i);
memset(bd,0,sizeof(bunzip_data));
/* Setup input buffer */
if(-1==(bd->in_fd=in_fd)) {
bd->inbuf=inbuf;
bd->inbufCount=len;
} else bd->inbuf=(unsigned char *)(bd+1);
/* Init the CRC32 table (big endian) */
for(i=0;i<256;i++) {
c=i<<24;
for(j=8;j;j--)
c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
bd->crc32Table[i]=c;
}
/* Setup for I/O error handling via longjmp */
i=setjmp(bd->jmpbuf);
if(i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
i = get_bits(bd,32);
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize=100000*(i-BZh0);
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
@@ -556,7 +683,8 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, char *inbuf, int len)
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
not end of file.) */
extern int uncompressStream(int src_fd, int dst_fd)
int uncompressStream(int src_fd, int dst_fd)
{
char *outbuf;
bunzip_data *bd;
@@ -572,20 +700,21 @@ extern int uncompressStream(int src_fd, int dst_fd)
}
}
}
/* Check CRC and release memory */
if(i==RETVAL_LAST_BLOCK) {
if (bd->headerCRC!=bd->totalCRC) {
bb_error_msg("Data integrity error when decompressing.");
} else {
i=RETVAL_OK;
}
}
else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
bb_error_msg("Compressed file ends unexpectedly");
} else {
bb_error_msg("Decompression failed");
}
if(bd->dbuf) free(bd->dbuf);
free(bd->dbuf);
free(bd);
free(outbuf);
+7 -11
View File
@@ -1,4 +1,3 @@
#include "config.h"
#include "libbb.h"
/* uncompress for busybox -- (c) 2002 Robert Griebl
@@ -65,23 +64,20 @@
#define MAXCODE(n) (1L << (n))
/* Block compress mode -C compatible with 2.0 */
int block_mode = BLOCK_MODE;
static int block_mode = BLOCK_MODE;
/* user settable max # bits/code */
int maxbits = BITS;
/* Exitcode of compress (-1 no file compressed) */
int exit_code = -1;
static int maxbits = BITS;
/* Input buffer */
unsigned char inbuf[IBUFSIZ + 64];
static unsigned char inbuf[IBUFSIZ + 64];
/* Output buffer */
unsigned char outbuf[OBUFSIZ + 2048];
static unsigned char outbuf[OBUFSIZ + 2048];
long int htab[HSIZE];
unsigned short codetab[HSIZE];
static long int htab[HSIZE];
static unsigned short codetab[HSIZE];
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
@@ -99,7 +95,7 @@ unsigned short codetab[HSIZE];
* with those of the compress() routine. See the definitions above.
*/
extern int uncompress(int fd_in, int fd_out)
int uncompress(int fd_in, int fd_out)
{
unsigned char *stackp;
long int code;
+347
View File
@@ -0,0 +1,347 @@
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (C) 1999-2005 Igor Pavlov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <byteswap.h>
#include "libbb.h"
#include "rangecoder.h"
typedef struct {
uint8_t pos;
uint32_t dict_size;
uint64_t dst_size;
} __attribute__ ((packed)) lzma_header_t;
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
#define LZMA_NUM_POS_BITS_MAX 4
#define LZMA_LEN_NUM_LOW_BITS 3
#define LZMA_LEN_NUM_MID_BITS 3
#define LZMA_LEN_NUM_HIGH_BITS 8
#define LZMA_LEN_CHOICE 0
#define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)
#define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)
#define LZMA_LEN_MID (LZMA_LEN_LOW \
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))
#define LZMA_LEN_HIGH (LZMA_LEN_MID \
+(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))
#define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))
#define LZMA_NUM_STATES 12
#define LZMA_NUM_LIT_STATES 7
#define LZMA_START_POS_MODEL_INDEX 4
#define LZMA_END_POS_MODEL_INDEX 14
#define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))
#define LZMA_NUM_POS_SLOT_BITS 6
#define LZMA_NUM_LEN_TO_POS_STATES 4
#define LZMA_NUM_ALIGN_BITS 4
#define LZMA_MATCH_MIN_LEN 2
#define LZMA_IS_MATCH 0
#define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES <<LZMA_NUM_POS_BITS_MAX))
#define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)
#define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)
#define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)
#define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)
#define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))
#define LZMA_SPEC_POS (LZMA_POS_SLOT \
+(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))
#define LZMA_ALIGN (LZMA_SPEC_POS \
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)
#define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))
#define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)
#define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
int unlzma(int src_fd, int dst_fd)
{
lzma_header_t header;
int lc, pb, lp;
uint32_t pos_state_mask;
uint32_t literal_pos_mask;
uint32_t pos;
uint16_t *p;
uint16_t *prob;
uint16_t *prob_lit;
int num_bits;
int num_probs;
rc_t rc;
int i, mi;
uint8_t *buffer;
uint8_t previous_byte = 0;
size_t buffer_pos = 0, global_pos = 0;
int len = 0;
int state = 0;
uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
if (read(src_fd, &header, sizeof(header)) != sizeof(header))
bb_error_msg_and_die("can't read header");
if (header.pos >= (9 * 5 * 5))
bb_error_msg_and_die("bad header");
mi = header.pos / 9;
lc = header.pos % 9;
pb = mi / 5;
lp = mi % 5;
pos_state_mask = (1 << pb) - 1;
literal_pos_mask = (1 << lp) - 1;
#if BB_BIG_ENDIAN
header.dict_size = bswap_32(header.dict_size);
header.dst_size = bswap_64(header.dst_size);
#endif
if (header.dict_size == 0)
header.dict_size = 1;
buffer = xmalloc(MIN(header.dst_size, header.dict_size));
num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
p = xmalloc(num_probs * sizeof(*p));
num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));
for (i = 0; i < num_probs; i++)
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
rc_init(&rc, src_fd, 0x10000);
while (global_pos + buffer_pos < header.dst_size) {
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
prob =
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
if (rc_is_bit_0(&rc, prob)) {
mi = 1;
rc_update_bit_0(&rc, prob);
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc)))));
if (state >= LZMA_NUM_LIT_STATES) {
int match_byte;
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
match_byte = buffer[pos];
do {
int bit;
match_byte <<= 1;
bit = match_byte & 0x100;
prob_lit = prob + 0x100 + bit + mi;
if (rc_get_bit(&rc, prob_lit, &mi)) {
if (!bit)
break;
} else {
if (bit)
break;
}
} while (mi < 0x100);
}
while (mi < 0x100) {
prob_lit = prob + mi;
rc_get_bit(&rc, prob_lit, &mi);
}
previous_byte = (uint8_t) mi;
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
}
if (state < 4)
state = 0;
else if (state < 10)
state -= 3;
else
state -= 6;
} else {
int offset;
uint16_t *prob_len;
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
state = state < LZMA_NUM_LIT_STATES ? 0 : 3;
prob = p + LZMA_LEN_CODER;
} else {
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G0 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
prob = (p + LZMA_IS_REP_0_LONG
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
}
continue;
} else {
rc_update_bit_1(&rc, prob);
}
} else {
uint32_t distance;
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G1 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
distance = rep1;
} else {
rc_update_bit_1(&rc, prob);
prob = p + LZMA_IS_REP_G2 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
distance = rep2;
} else {
rc_update_bit_1(&rc, prob);
distance = rep3;
rep3 = rep2;
}
rep2 = rep1;
}
rep1 = rep0;
rep0 = distance;
}
state = state < LZMA_NUM_LIT_STATES ? 8 : 11;
prob = p + LZMA_REP_LEN_CODER;
}
prob_len = prob + LZMA_LEN_CHOICE;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
prob_len = (prob + LZMA_LEN_LOW
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
offset = 0;
num_bits = LZMA_LEN_NUM_LOW_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
prob_len = prob + LZMA_LEN_CHOICE_2;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
prob_len = (prob + LZMA_LEN_MID
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
num_bits = LZMA_LEN_NUM_MID_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
prob_len = prob + LZMA_LEN_HIGH;
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
+ (1 << LZMA_LEN_NUM_MID_BITS));
num_bits = LZMA_LEN_NUM_HIGH_BITS;
}
}
rc_bit_tree_decode(&rc, prob_len, num_bits, &len);
len += offset;
if (state < 4) {
int pos_slot;
state += LZMA_NUM_LIT_STATES;
prob =
p + LZMA_POS_SLOT +
((len <
LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
rc_bit_tree_decode(&rc, prob, LZMA_NUM_POS_SLOT_BITS,
&pos_slot);
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
num_bits = (pos_slot >> 1) - 1;
rep0 = 2 | (pos_slot & 1);
if (pos_slot < LZMA_END_POS_MODEL_INDEX) {
rep0 <<= num_bits;
prob = p + LZMA_SPEC_POS + rep0 - pos_slot - 1;
} else {
num_bits -= LZMA_NUM_ALIGN_BITS;
while (num_bits--)
rep0 = (rep0 << 1) | rc_direct_bit(&rc);
prob = p + LZMA_ALIGN;
rep0 <<= LZMA_NUM_ALIGN_BITS;
num_bits = LZMA_NUM_ALIGN_BITS;
}
i = 1;
mi = 1;
while (num_bits--) {
if (rc_get_bit(&rc, prob + mi, &mi))
rep0 |= i;
i <<= 1;
}
} else
rep0 = pos_slot;
if (++rep0 == 0)
break;
}
len += LZMA_MATCH_MIN_LEN;
do {
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
}
len--;
} while (len != 0 && buffer_pos < header.dst_size);
}
}
write(dst_fd, buffer, buffer_pos);
rc_free(&rc);
return 0;
}
/* vi:set ts=4: */
+98 -92
View File
@@ -16,6 +16,11 @@
*
* read_gz interface + associated hacking by Laurence Anderson
*
* Fixed huft_build() so decoding end-of-block code does not grab more bits
* than necessary (this is required by unzip applet), added inflate_cleanup()
* to free leaked bytebuffer memory (used in unzip.c), and some minor style
* guide cleanups by Ed Clark
*
* 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
@@ -69,8 +74,7 @@ static char *license_msg[] = {
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include "config.h"
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
typedef struct huft_s {
@@ -88,7 +92,7 @@ static unsigned int gunzip_outbuf_count; /* bytes in output buffer */
/* gunzip_window size--must be a power of two, and
* at least 32K for zip's deflate method */
static const int gunzip_wsize = 0x8000;
enum { gunzip_wsize = 0x8000 };
static unsigned char *gunzip_window;
static unsigned int *gunzip_crc_table;
@@ -116,26 +120,26 @@ static const unsigned short mask_bits[] = {
/* Copy lengths for literal codes 257..285 */
static const unsigned short cplens[] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};
/* note: see note #13 above about the 258 in this list. */
/* Extra bits for literal codes 257..285 */
static const unsigned char cplext[] = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5,
5, 5, 5, 0, 99, 99
5, 5, 5, 0, 99, 99
}; /* 99==invalid */
/* Copy offsets for distance codes 0..29 */
static const unsigned short cpdist[] = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
};
/* Extra bits for distance codes */
static const unsigned char cpdext[] = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 11, 12, 12, 13, 13
11, 11, 12, 12, 13, 13
};
/* Tables for deflate from PKZIP's appnote.txt. */
@@ -151,7 +155,10 @@ static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
* to the front of the bytebuffer, leave 4 bytes free at end of tail
* so we can easily top up buffer in check_trailer_gzip() */
bytebuffer_size = 4 + bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8);
if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) {
bb_error_msg_and_die("unexpected end of file");
}
bytebuffer_size += 4;
bytebuffer_offset = 4;
}
bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current;
@@ -168,7 +175,7 @@ static void make_gunzip_crc_table(void)
/* initial shift register value */
gunzip_crc = 0xffffffffL;
gunzip_crc_table = (unsigned int *) malloc(256 * sizeof(unsigned int));
gunzip_crc_table = (unsigned int *) xmalloc(256 * sizeof(unsigned int));
/* Compute and print table of CRC's, five per line */
for (i = 0; i < 256; i++) {
@@ -184,8 +191,8 @@ static void make_gunzip_crc_table(void)
table_entry = (table_entry >> 1) ^ poly;
} else {
table_entry >>= 1;
}
}
}
}
gunzip_crc_table[i] = table_entry;
}
}
@@ -225,70 +232,59 @@ static int huft_free(huft_t * t)
* t: result: starting table
* m: maximum lookup bits, returns actual
*/
static int huft_build(unsigned int *b, const unsigned int n,
const unsigned int s, const unsigned short *d,
const unsigned char *e, huft_t ** t, int *m)
int huft_build(unsigned int *b, const unsigned int n,
const unsigned int s, const unsigned short *d,
const unsigned char *e, huft_t ** t, unsigned int *m)
{
unsigned a; /* counter for codes of length k */
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
unsigned f; /* i repeats in table every f entries */
int g; /* maximum code length */
int h; /* table level */
unsigned eob_len; /* length of end-of-block code (value 256) */
unsigned f; /* i repeats in table every f entries */
int g; /* maximum code length */
int h; /* table level */
register unsigned i; /* counter, current code */
register unsigned j; /* counter */
register int k; /* number of bits in current code */
int l; /* bits per table (returned in m) */
register int k; /* number of bits in current code */
register unsigned *p; /* pointer into c[], b[], or v[] */
register huft_t *q; /* points to current table */
huft_t r; /* table entry for structure assignment */
huft_t *u[BMAX]; /* table stack */
unsigned v[N_MAX]; /* values in order of bit length */
register int w; /* bits before this table == (l * h) */
register huft_t *q; /* points to current table */
huft_t r; /* table entry for structure assignment */
huft_t *u[BMAX]; /* table stack */
unsigned v[N_MAX]; /* values in order of bit length */
int ws[BMAX+1]; /* bits decoded stack */
register int w; /* bits decoded */
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
unsigned *xp; /* pointer into x */
int y; /* number of dummy codes added */
unsigned z; /* number of entries in current table */
unsigned *xp; /* pointer into x */
int y; /* number of dummy codes added */
unsigned z; /* number of entries in current table */
/* Length of EOB code, if any */
eob_len = n > 256 ? b[256] : BMAX;
/* Generate counts for each bit length */
memset((void *) (c), 0, sizeof(c));
memset((void *)c, 0, sizeof(c));
p = b;
i = n;
do {
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
c[*p]++; /* assume all entries <= BMAX */
p++; /* Can't combine with above line (Solaris bug) */
} while (--i);
if (c[0] == n) { /* null input--all zero length codes */
if (c[0] == n) { /* null input--all zero length codes */
*t = (huft_t *) NULL;
*m = 0;
return 0;
return 2;
}
/* Find minimum and maximum length, bound *m by those */
l = *m;
for (j = 1; j <= BMAX; j++) {
if (c[j]) {
break;
}
}
k = j; /* minimum code length */
if ((unsigned) l < j) {
l = j;
}
for (i = BMAX; i; i--) {
if (c[i]) {
break;
}
}
g = i; /* maximum code length */
if ((unsigned) l > i) {
l = i;
}
*m = l;
for (j = 1; (c[j] == 0) && (j <= BMAX); j++);
k = j; /* minimum code length */
for (i = BMAX; (c[i] == 0) && i; i--);
g = i; /* maximum code length */
*m = (*m < j) ? j : ((*m > i) ? i : *m);
/* Adjust last length count to fill out codes, if needed */
for (y = 1 << j; j < i; j++, y <<= 1) {
if ((y -= c[j]) < 0) {
return 2; /* bad input: more codes than bits */
return 2; /* bad input: more codes than bits */
}
}
if ((y -= c[i]) < 0) {
@@ -300,7 +296,7 @@ static int huft_build(unsigned int *b, const unsigned int n,
x[1] = j = 0;
p = c + 1;
xp = x + 2;
while (--i) { /* note that i == g from above */
while (--i) { /* note that i == g from above */
*xp++ = (j += *p++);
}
@@ -314,13 +310,13 @@ static int huft_build(unsigned int *b, const unsigned int n,
} while (++i < n);
/* Generate the Huffman codes and for each, make the table entries */
x[0] = i = 0; /* first Huffman code is zero */
p = v; /* grab values in bit order */
h = -1; /* no tables yet--level -1 */
w = -l; /* bits decoded == (l * h) */
x[0] = i = 0; /* first Huffman code is zero */
p = v; /* grab values in bit order */
h = -1; /* no tables yet--level -1 */
w = ws[0] = 0; /* bits decoded */
u[0] = (huft_t *) NULL; /* just to keep compilers happy */
q = (huft_t *) NULL; /* ditto */
z = 0; /* ditto */
z = 0; /* ditto */
/* go through the bit lengths (k already is bits in shortest code) */
for (; k <= g; k++) {
@@ -328,52 +324,52 @@ static int huft_build(unsigned int *b, const unsigned int n,
while (a--) {
/* here i is the Huffman code of length k bits for value *p */
/* make tables up to required level */
while (k > w + l) {
h++;
w += l; /* previous table always l bits */
while (k > ws[h + 1]) {
w = ws[++h];
/* compute minimum size table less than or equal to l bits */
z = (z = g - w) > (unsigned) l ? l : z; /* upper limit on table size */
if ((f = 1 << (j = k - w)) > a + 1) { /* try a k-w bit table *//* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */
/* compute minimum size table less than or equal to *m bits */
z = (z = g - w) > *m ? *m : z; /* upper limit on table size */
if ((f = 1 << (j = k - w)) > a + 1) { /* try a k-w bit table */
/* too few codes for k-w bit table */
f -= a + 1; /* deduct codes from patterns left */
xp = c + k;
while (++j < z) { /* try smaller tables up to z bits */
while (++j < z) { /* try smaller tables up to z bits */
if ((f <<= 1) <= *++xp) {
break; /* enough codes to use up j bits */
break; /* enough codes to use up j bits */
}
f -= *xp; /* else deduct codes from patterns */
f -= *xp; /* else deduct codes from patterns */
}
}
j = (w + j > eob_len && w < eob_len) ? eob_len - w : j; /* make EOB code end at table */
z = 1 << j; /* table entries for j-bit table */
ws[h+1] = w + j; /* set bits decoded in stack */
/* allocate and link in new table */
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
*t = q + 1; /* link to list for huft_free() */
*(t = &(q->v.t)) = NULL;
u[h] = ++q; /* table starts after link */
/* connect to last table, if there is one */
if (h) {
x[h] = i; /* save pattern for backing up */
r.b = (unsigned char) l; /* bits to dump before this table */
r.e = (unsigned char) (16 + j); /* bits in this table */
r.v.t = q; /* pointer to this table */
j = i >> (w - l); /* (get around Turbo C bug) */
u[h - 1][j] = r; /* connect to last table */
x[h] = i; /* save pattern for backing up */
r.b = (unsigned char) (w - ws[h - 1]); /* bits to dump before this table */
r.e = (unsigned char) (16 + j); /* bits in this table */
r.v.t = q; /* pointer to this table */
j = (i & ((1 << w) - 1)) >> ws[h - 1];
u[h - 1][j] = r; /* connect to last table */
}
}
/* set up table entry in r */
r.b = (unsigned char) (k - w);
if (p >= v + n) {
r.e = 99; /* out of values--invalid code */
r.e = 99; /* out of values--invalid code */
} else if (*p < s) {
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is end-of-block code */
r.v.n = (unsigned short) (*p); /* simple code is just the value */
p++; /* one compiler does not like *p++ */
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is EOB code */
r.v.n = (unsigned short) (*p++); /* simple code is just the value */
} else {
r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */
r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */
r.v.n = d[*p++ - s];
}
@@ -391,11 +387,14 @@ static int huft_build(unsigned int *b, const unsigned int n,
/* backup over finished tables */
while ((i & ((1 << w) - 1)) != x[h]) {
h--; /* don't need to update q */
w -= l;
w = ws[--h];
}
}
}
/* return actual size of base table */
*m = ws[1];
/* Return true (1) if we were given an incomplete table */
return y != 0 && g != 1;
}
@@ -443,7 +442,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
do {
if (e == 99) {
bb_error_msg_and_die("inflate_codes error 1");;
bb_error_msg_and_die("inflate_codes error 1");
}
b >>= t->b;
k -= t->b;
@@ -479,7 +478,7 @@ static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_b
if ((e = (t = td + ((unsigned) b & md))->e) > 16)
do {
if (e == 99)
bb_error_msg_and_die("inflate_codes error 2");;
bb_error_msg_and_die("inflate_codes error 2");
b >>= t->b;
k -= t->b;
e -= 16;
@@ -540,7 +539,7 @@ do_copy: do {
static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
{
static int n, b_stored, k_stored, w;
static unsigned int n, b_stored, k_stored, w;
if (setup) {
n = my_n;
b_stored = my_b_stored;
@@ -553,7 +552,7 @@ static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
while (n--) {
b_stored = fill_bitbuffer(b_stored, &k_stored, 8);
gunzip_window[w++] = (unsigned char) b_stored;
if (w == (unsigned int) gunzip_wsize) {
if (w == gunzip_wsize) {
gunzip_outbuf_count = (w);
//flush_gunzip_window();
w = 0;
@@ -893,7 +892,7 @@ static int inflate_get_next_window(void)
}
/* Initialise bytebuffer, be careful not to overfill the buffer */
extern void inflate_init(unsigned int bufsize)
void inflate_init(unsigned int bufsize)
{
/* Set the bytebuffer size, default is same as gunzip_wsize */
bytebuffer_max = bufsize + 8;
@@ -901,7 +900,12 @@ extern void inflate_init(unsigned int bufsize)
bytebuffer_size = 0;
}
extern int inflate_unzip(int in, int out)
void inflate_cleanup(void)
{
free(bytebuffer);
}
int inflate_unzip(int in, int out)
{
ssize_t nwrote;
typedef void (*sig_type) (int);
@@ -948,10 +952,10 @@ extern int inflate_unzip(int in, int out)
return 0;
}
extern int inflate_gunzip(int in, int out)
int inflate_gunzip(int in, int out)
{
unsigned int stored_crc = 0;
unsigned char count;
unsigned int count;
inflate_unzip(in, out);
@@ -969,6 +973,7 @@ extern int inflate_gunzip(int in, int out)
/* Validate decompression - crc */
if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("crc error");
return -1;
}
/* Validate decompression - size */
@@ -976,6 +981,7 @@ extern int inflate_gunzip(int in, int out)
(bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
(bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
bb_error_msg("Incorrect length");
return -1;
}
return 0;
+1 -1
View File
@@ -22,7 +22,7 @@
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
extern char filter_accept_all(archive_handle_t *archive_handle)
char filter_accept_all(archive_handle_t *archive_handle)
{
if (archive_handle->file_header->name) {
return(EXIT_SUCCESS);
+1 -1
View File
@@ -24,7 +24,7 @@
/*
* Accept names that are in the accept list, ignoring reject list.
*/
extern char filter_accept_list(archive_handle_t *archive_handle)
char filter_accept_list(archive_handle_t *archive_handle)
{
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
return(EXIT_SUCCESS);
@@ -28,7 +28,7 @@
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
*/
extern char filter_accept_list_reassign(archive_handle_t *archive_handle)
char filter_accept_list_reassign(archive_handle_t *archive_handle)
{
/* Check the file entry is in the accept list */
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
@@ -50,6 +50,10 @@ extern char filter_accept_list_reassign(archive_handle_t *archive_handle)
return(EXIT_SUCCESS);
}
#endif
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
archive_handle->action_data_subarchive = get_header_tar_lzma;
return(EXIT_SUCCESS);
}
}
return(EXIT_FAILURE);
}
@@ -24,7 +24,7 @@
/*
* Accept names that are in the accept list and not in the reject list
*/
extern char filter_accept_reject_list(archive_handle_t *archive_handle)
char filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
+1 -1
View File
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include "unarchive.h"
extern const llist_t *find_list_entry(const llist_t *list, const char *filename)
const llist_t *find_list_entry(const llist_t *list, const char *filename)
{
while (list) {
if (fnmatch(list->data, filename, 0) == 0) {
+11 -11
View File
@@ -21,20 +21,20 @@
#include "unarchive.h"
#include "libbb.h"
extern char get_header_ar(archive_handle_t *archive_handle)
char get_header_ar(archive_handle_t *archive_handle)
{
file_header_t *typed = archive_handle->file_header;
union {
char raw[60];
struct {
char name[16];
char date[12];
char uid[6];
char gid[6];
char mode[8];
char size[10];
char magic[2];
} formated;
struct {
char name[16];
char date[12];
char uid[6];
char gid[6];
char mode[8];
char size[10];
char magic[2];
} formated;
} ar;
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
static char *ar_long_names;
@@ -102,7 +102,7 @@ extern char get_header_ar(archive_handle_t *archive_handle)
#endif
} else {
/* short filenames */
typed->name = bb_xstrndup(ar.formated.name, 16);
typed->name = bb_xstrndup(ar.formated.name, 16);
}
typed->name[strcspn(typed->name, " /")] = '\0';
+2 -2
View File
@@ -28,7 +28,7 @@ typedef struct hardlinks_s {
struct hardlinks_s *next;
} hardlinks_t;
extern char get_header_cpio(archive_handle_t *archive_handle)
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned short pending_hardlinks = 0;
@@ -66,7 +66,7 @@ extern char get_header_cpio(archive_handle_t *archive_handle)
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, cpio_header, 110) == 0) {
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
return(EXIT_FAILURE);
}
archive_handle->offset += 110;
+24 -21
View File
@@ -1,17 +1,4 @@
/*
* 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.
/* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* FIXME:
* In privileged mode if uname and gname map to a uid and gid then use the
@@ -20,12 +7,13 @@
* References:
* GNU tar and star man pages,
* Opengroup's ustar interchange format,
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysmacros.h> /* For makedev */
#include "unarchive.h"
#include "libbb.h"
@@ -34,7 +22,7 @@ static char *longname = NULL;
static char *linkname = NULL;
#endif
extern char get_header_tar(archive_handle_t *archive_handle)
char get_header_tar(archive_handle_t *archive_handle)
{
file_header_t *file_header = archive_handle->file_header;
union {
@@ -62,20 +50,31 @@ extern char get_header_tar(archive_handle_t *archive_handle)
} tar;
long sum = 0;
long i;
static int end = 0;
/* Align header */
data_align(archive_handle, 512);
if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) {
/* Assume end of file */
return(EXIT_FAILURE);
bb_error_msg_and_die("Short header");
//return(EXIT_FAILURE);
}
archive_handle->offset += 512;
/* If there is no filename its an empty header */
if (tar.formated.name[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
*/
while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512);
return(EXIT_FAILURE);
}
end = 1;
return(EXIT_SUCCESS);
}
end = 0;
/* Check header has valid magic, "ustar" is for the proper tar
* 0's are for the old tar format
@@ -109,10 +108,14 @@ extern char get_header_tar(archive_handle_t *archive_handle)
linkname = NULL;
} else
#endif
if (tar.formated.prefix[0] == 0) {
file_header->name = strdup(tar.formated.name);
} else {
file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
{
file_header->name = bb_xstrndup(tar.formated.name,100);
if (tar.formated.prefix[0]) {
char *temp = file_header->name;
file_header->name = concat_path_file(tar.formated.prefix, temp);
free(temp);
}
}
file_header->uid = strtol(tar.formated.uid, NULL, 8);
+1 -1
View File
@@ -24,7 +24,7 @@
#include "libbb.h"
#include "unarchive.h"
extern char get_header_tar_bz2(archive_handle_t *archive_handle)
char get_header_tar_bz2(archive_handle_t *archive_handle)
{
/* Cant lseek over pipe's */
archive_handle->seek = seek_by_char;
+1 -1
View File
@@ -19,7 +19,7 @@
#include "libbb.h"
#include "unarchive.h"
extern char get_header_tar_gz(archive_handle_t *archive_handle)
char get_header_tar_gz(archive_handle_t *archive_handle)
{
unsigned char magic[2];
@@ -0,0 +1,23 @@
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include "unarchive.h"
char get_header_tar_lzma(archive_handle_t * archive_handle)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_char;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
/* Can only do one file at a time */
return EXIT_FAILURE;
}
/* vi:set ts=4: */
+1 -1
View File
@@ -1,7 +1,7 @@
#include <stdio.h>
#include "unarchive.h"
extern void header_list(const file_header_t *file_header)
void header_list(const file_header_t *file_header)
{
puts(file_header->name);
}
+1 -2
View File
@@ -1,7 +1,6 @@
#include <stdio.h>
#include "unarchive.h"
extern void header_skip(const file_header_t *file_header)
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
{
return;
}
+2 -2
View File
@@ -4,9 +4,9 @@
#include "libbb.h"
#include "unarchive.h"
extern void header_verbose_list(const file_header_t *file_header)
void header_verbose_list(const file_header_t *file_header)
{
struct tm *mtime = localtime(&file_header->mtime);
struct tm *mtime = localtime(&(file_header->mtime));
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
+1 -1
View File
@@ -20,7 +20,7 @@
#include "libbb.h"
/* transformer(), more than meets the eye */
extern int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
{
int fd_pipe[2];
int pid;
+178
View File
@@ -0,0 +1,178 @@
/*
* Small range coder implementation for lzma.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (c) 1999-2005 Igor Pavlov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libbb.h"
#ifndef always_inline
# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >0)
# define always_inline __attribute__((always_inline)) inline
# else
# define always_inline inline
# endif
#endif
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline always_inline
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
uint8_t *buffer;
uint8_t *buffer_end;
int buffer_size;
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
if (rc->buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = rc->buffer;
rc->buffer_end = rc->buffer + rc->buffer_size;
}
/* Called once */
static always_inline void rc_init(rc_t * rc, int fd, int buffer_size)
{
int i;
rc->fd = fd;
rc->buffer = malloc(buffer_size);
rc->buffer_size = buffer_size;
rc->buffer_end = rc->buffer + rc->buffer_size;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
}
/* Called once. TODO: bb_maybe_free() */
static always_inline void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc->buffer);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static always_inline void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static always_inline int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static always_inline int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
/* vi:set ts=4: */
+1 -1
View File
@@ -24,7 +24,7 @@
*
* TODO: rename to seek_by_read
*/
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
if (jump_size) {
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
+1 -1
View File
@@ -22,7 +22,7 @@
#include "libbb.h"
#include "unarchive.h"
extern void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
+1 -2
View File
@@ -16,11 +16,10 @@
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "unarchive.h"
#include "busybox.h"
extern void unpack_ar_archive(archive_handle_t *ar_archive)
void unpack_ar_archive(archive_handle_t *ar_archive)
{
char magic[7];
+14 -23
View File
@@ -4,19 +4,7 @@
*
* Copyright (C) 2001,2002 by Laurence Anderson
*
* 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
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
@@ -43,7 +31,7 @@
#define RPM_STRING_ARRAY_TYPE 8
#define RPM_I18NSTRING_TYPE 9
#define RPMTAG_NAME 1000
#define RPMTAG_NAME 1000
#define RPMTAG_VERSION 1001
#define RPMTAG_RELEASE 1002
#define RPMTAG_SUMMARY 1004
@@ -143,7 +131,7 @@ int rpm_main(int argc, char **argv)
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
offset = lseek(rpm_fd, 0, SEEK_CUR);
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_SHARED, rpm_fd, 0); // Mimimum is one page
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_PRIVATE, rpm_fd, 0); // Mimimum is one page
if (func & rpm_install) {
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
extract_cpio_gz(rpm_fd); // Extact the archive
@@ -243,7 +231,7 @@ rpm_index **rpm_gettags(int fd, int *num_tags)
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
while (header.entries--) {
tmpindex = tags[tagindex++] = malloc(sizeof(rpm_index));
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
read(fd, tmpindex, sizeof(rpm_index));
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
tmpindex->offset = storepos + ntohl(tmpindex->offset);
@@ -259,14 +247,15 @@ rpm_index **rpm_gettags(int fd, int *num_tags)
int bsearch_rpmtag(const void *key, const void *item)
{
int *tag = (int *)key;
rpm_index **tmp = (rpm_index **) item;
return ((int) key - tmp[0]->tag);
return (*tag - tmp[0]->tag);
}
int rpm_getcount(int tag)
{
rpm_index **found;
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found) return 0;
else return found[0]->count;
}
@@ -274,7 +263,7 @@ int rpm_getcount(int tag)
char *rpm_getstring(int tag, int itemindex)
{
rpm_index **found;
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return NULL;
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
int n;
@@ -288,7 +277,9 @@ int rpm_getint(int tag, int itemindex)
{
rpm_index **found;
int n, *tmpint;
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
* it's ok to ignore it because tag won't be used as a pointer */
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return -1;
tmpint = (int *) (map + found[0]->offset);
if (found[0]->type == RPM_INT32_TYPE) {
@@ -323,12 +314,12 @@ void fileaction_dobackup(char *filename, int fileref)
void fileaction_setowngrp(char *filename, int fileref)
{
int uid, gid;
uid = my_getpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
gid = my_getgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
uid = bb_xgetpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
gid = bb_xgetgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
chown (filename, uid, gid);
}
void fileaction_list(char *filename, int fileref)
void fileaction_list(char *filename, int ATTRIBUTE_UNUSED fileref)
{
printf("%s\n", filename);
}
+2 -2
View File
@@ -48,7 +48,7 @@ struct rpm_header {
uint32_t size; /* Size of store (4 bytes) */
};
void skip_header(int rpm_fd)
static void skip_header(int rpm_fd)
{
struct rpm_header header;
@@ -66,7 +66,7 @@ void skip_header(int rpm_fd)
}
/* No getopt required */
extern int rpm2cpio_main(int argc, char **argv)
int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
int rpm_fd;
+227 -243
View File
@@ -21,20 +21,7 @@
* Copyright (C) 1995 Bruce Perens
* This is free software under the GNU General Public License.
*
* 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
*
* Licensed under GPL v2 (or later), see file LICENSE in this tarball.
*/
#include <fcntl.h>
@@ -59,12 +46,12 @@
# define TAR_MAGIC "ustar" /* ustar and a null */
# define TAR_VERSION " " /* Be compatable with GNU tar format */
static const int TAR_BLOCK_SIZE = 512;
static const int TAR_MAGIC_LEN = 6;
static const int TAR_VERSION_LEN = 2;
#define TAR_BLOCK_SIZE 512
#define TAR_MAGIC_LEN 6
#define TAR_VERSION_LEN 2
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
#define NAME_SIZE 100
struct TarHeader { /* byte offset */
char name[NAME_SIZE]; /* 0-99 */
char mode[8]; /* 100-107 */
@@ -102,14 +89,14 @@ struct HardLinkInfo {
/* Some info to be carried along when creating a new tarball */
struct TarBallInfo {
char *fileName; /* File name of the tarball */
int tarFd; /* Open-for-write file descriptor
for the tarball */
char *fileName; /* File name of the tarball */
int tarFd; /* Open-for-write file descriptor
for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
us know the inode and device that the
tarball lives, so we can avoid trying
to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
@@ -213,8 +200,7 @@ static int putOctal(char *cp, int len, long value)
/* Write out a tar header for the specified file/directory/whatever */
static inline int writeTarHeader(struct TarBallInfo *tbInfo,
const char *header_name,
const char *real_name, struct stat *statbuf)
const char *header_name, const char *real_name, struct stat *statbuf)
{
long chksum = 0;
struct TarHeader header;
@@ -234,9 +220,9 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo,
TAR_MAGIC_LEN + TAR_VERSION_LEN);
/* Enter the user and group names (default to root if it fails) */
if (my_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL)
if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL)
strcpy(header.uname, "root");
if (my_getgrgid(header.gname, statbuf->st_gid, sizeof(header.gname)) == NULL)
if (bb_getgrgid(header.gname, statbuf->st_gid, sizeof(header.gname)) == NULL)
strcpy(header.gname, "root");
if (tbInfo->hlInfo) {
@@ -336,6 +322,8 @@ static inline int exclude_file(const llist_t *excluded_files, const char *file)
return 0;
}
# else
#define exclude_file(excluded_files, file) 0
# endif
static int writeFileToTarball(const char *fileName, struct stat *statbuf,
@@ -343,6 +331,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
{
struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
const char *header_name;
int inputFileFd = -1;
/*
** Check to see if we are dealing with a hard link.
@@ -392,36 +381,37 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
if (header_name[0] == '\0')
return TRUE;
# ifdef CONFIG_FEATURE_TAR_FROM
if (exclude_file(tbInfo->excludeList, header_name)) {
if (ENABLE_FEATURE_TAR_FROM &&
exclude_file(tbInfo->excludeList, header_name)) {
return SKIP;
}
# endif /* CONFIG_FEATURE_TAR_FROM */
if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) {
return (FALSE);
}
/* Now, if the file is a regular file, copy it out to the tarball */
if ((tbInfo->hlInfo == NULL)
&& (S_ISREG(statbuf->st_mode))) {
int inputFileFd;
ssize_t readSize = 0;
/* Is this a regular file? */
if ((tbInfo->hlInfo == NULL) && (S_ISREG(statbuf->st_mode))) {
/* open the file we want to archive, and make sure all is well */
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
bb_perror_msg("%s: Cannot open", fileName);
return (FALSE);
}
}
/* Add an entry to the tarball */
if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) {
return (FALSE);
}
/* If it was a regular file, write out the body */
if (inputFileFd >= 0 ) {
ssize_t readSize = 0;
/* write the file to the archive */
readSize = bb_copyfd_eof(inputFileFd, tbInfo->tarFd);
close(inputFileFd);
/* Pad the file up to the tar block size */
for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++) {
for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++)
write(tbInfo->tarFd, "\0", 1);
}
close(inputFileFd);
}
return (TRUE);
@@ -431,12 +421,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip)
{
#ifdef CONFIG_FEATURE_TAR_GZIP
int gzipDataPipe[2] = { -1, -1 };
int gzipStatusPipe[2] = { -1, -1 };
pid_t gzipPid = 0;
volatile int vfork_exec_errno = 0;
#endif
int errorFlag = FALSE;
ssize_t size;
@@ -453,11 +438,15 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
bb_perror_msg_and_die("Couldnt stat tar file");
#ifdef CONFIG_FEATURE_TAR_GZIP
if (gzip) {
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) {
bb_perror_msg_and_die("Failed to create gzip pipe");
}
if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) {
int gzipDataPipe[2] = { -1, -1 };
int gzipStatusPipe[2] = { -1, -1 };
volatile int vfork_exec_errno = 0;
char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
bb_perror_msg_and_die("create pipe");
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
@@ -465,6 +454,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
/* Avoid vfork clobbering */
(void) &include;
(void) &errorFlag;
(void) &zip_exec;
# endif
gzipPid = vfork();
@@ -477,9 +467,9 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
dup2(tbInfo.tarFd, 1);
close(gzipStatusPipe[0]);
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */
execl("/bin/gzip", "gzip", "-f", 0);
execlp(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
close(gzipStatusPipe[1]);
@@ -495,7 +485,7 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
if (n == 0 && vfork_exec_errno != 0) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("Could not exec gzip process");
bb_perror_msg_and_die("Could not exec %s", zip_exec);
} else if ((n < 0) && (errno == EAGAIN || errno == EINTR))
continue; /* try it again */
break;
@@ -503,50 +493,49 @@ static inline int writeTarFile(const int tar_fd, const int verboseFlag,
close(gzipStatusPipe[0]);
tbInfo.tarFd = gzipDataPipe[1];
} else {
bb_perror_msg_and_die("Failed to vfork gzip process");
}
} else bb_perror_msg_and_die("vfork gzip");
}
#endif
tbInfo.excludeList = exclude;
/* Read the directory/files and iterate over them one at a time */
while (include) {
if (!recursive_action(include->data, TRUE, dereferenceFlag, FALSE,
writeFileToTarball, writeFileToTarball,
(void *) &tbInfo)) {
if (!recursive_action(include->data, TRUE, dereferenceFlag,
FALSE, writeFileToTarball, writeFileToTarball, &tbInfo))
{
errorFlag = TRUE;
}
include = include->link;
}
/* Write two empty blocks to the end of the archive */
for (size = 0; size < (2 * TAR_BLOCK_SIZE); size++) {
for (size = 0; size < (2 * TAR_BLOCK_SIZE); size++)
write(tbInfo.tarFd, "\0", 1);
}
/* To be pedantically correct, we would check if the tarball
* is smaller than 20 tar blocks, and pad it if it was smaller,
* but that isn't necessary for GNU tar interoperability, and
* so is considered a waste of space */
/* Hang up the tools, close up shop, head home */
/* Close so the child process (if any) will exit */
close(tbInfo.tarFd);
/* Hang up the tools, close up shop, head home */
if (ENABLE_FEATURE_CLEAN_UP)
freeHardLinkInfo(&tbInfo.hlInfoHead);
if (errorFlag)
bb_error_msg("Error exit delayed from previous errors");
freeHardLinkInfo(&tbInfo.hlInfoHead);
#ifdef CONFIG_FEATURE_TAR_GZIP
if (gzip && gzipPid) {
if (waitpid(gzipPid, NULL, 0) == -1)
printf("Couldnt wait ?");
}
#endif
if (gzipPid && waitpid(gzipPid, NULL, 0)==-1)
bb_error_msg("Couldnt wait");
return !errorFlag;
}
#endif /* tar_create */
#else
int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip);
#endif /* tar_create */
#ifdef CONFIG_FEATURE_TAR_FROM
static llist_t *append_file_list_to_list(llist_t *list)
@@ -557,18 +546,19 @@ static llist_t *append_file_list_to_list(llist_t *list)
char *line;
llist_t *newlist = NULL;
while(cur) {
while (cur) {
src_stream = bb_xfopen(cur->data, "r");
tmp = cur;
cur = cur->link;
free(tmp);
while((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
newlist = llist_add_to(newlist, line);
}
fclose(src_stream);
while ((line = bb_get_chomped_line_from_file(src_stream)) != NULL)
newlist = llist_add_to(newlist, line);
fclose(src_stream);
}
return newlist;
}
#else
#define append_file_list_to_list(x) 0
#endif
#ifdef CONFIG_FEATURE_TAR_COMPRESS
@@ -578,7 +568,9 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
archive_handle->seek = seek_by_char;
/* do the decompression, and cleanup */
if ((bb_xread_char(archive_handle->src_fd) != 0x1f) || (bb_xread_char(archive_handle->src_fd) != 0x9d)) {
if (bb_xread_char(archive_handle->src_fd) != 0x1f ||
bb_xread_char(archive_handle->src_fd) != 0x9d)
{
bb_error_msg_and_die("Invalid magic");
}
@@ -589,99 +581,128 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
/* Can only do one file at a time */
return(EXIT_FAILURE);
}
#else
#define get_header_tar_Z 0
#endif
#define CTX_TEST (1 << 0)
#define CTX_EXTRACT (1 << 1)
#define TAR_OPT_BASEDIR (1 << 2)
#define TAR_OPT_TARNAME (1 << 3)
#define TAR_OPT_2STDOUT (1 << 4)
#define TAR_OPT_P (1 << 5)
#define TAR_OPT_VERBOSE (1 << 6)
#define TAR_OPT_KEEP_OLD (1 << 7)
#define CTX_TEST (1 << 0)
#define CTX_EXTRACT (1 << 1)
#define TAR_OPT_BASEDIR (1 << 2)
#define TAR_OPT_TARNAME (1 << 3)
#define TAR_OPT_2STDOUT (1 << 4)
#define TAR_OPT_P (1 << 5)
#define TAR_OPT_VERBOSE (1 << 6)
#define TAR_OPT_KEEP_OLD (1 << 7)
#define TAR_OPT_AFTER_START 8
#define CTX_CREATE (1 << (TAR_OPT_AFTER_START))
#define TAR_OPT_DEREFERNCE (1 << (TAR_OPT_AFTER_START + 1))
#ifdef CONFIG_FEATURE_TAR_CREATE
# define CTX_CREATE (1 << 8)
# define TAR_OPT_DEREFERNCE (1 << 9)
# define TAR_OPT_STR_CREATE "ch"
# define TAR_OPT_FLAG_CREATE 2
# define TAR_OPT_STR_CREATE "ch"
# define TAR_OPT_AFTER_CREATE TAR_OPT_AFTER_START + 2
#else
//# define CTX_CREATE 0
# define TAR_OPT_STR_CREATE ""
# define TAR_OPT_FLAG_CREATE 0
# define TAR_OPT_STR_CREATE ""
# define TAR_OPT_AFTER_CREATE TAR_OPT_AFTER_START
#endif
#define TAR_OPT_BZIP2 (1 << (TAR_OPT_AFTER_CREATE))
#ifdef CONFIG_FEATURE_TAR_BZIP2
# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
# define TAR_OPT_STR_BZIP2 "j"
# define TAR_OPT_FLAG_BZIP2 1
# define TAR_OPT_STR_BZIP2 "j"
# define TAR_OPT_AFTER_BZIP2 TAR_OPT_AFTER_CREATE + 1
#else
# define TAR_OPT_STR_BZIP2 ""
# define TAR_OPT_FLAG_BZIP2 0
# define TAR_OPT_STR_BZIP2 ""
# define TAR_OPT_AFTER_BZIP2 TAR_OPT_AFTER_CREATE
#endif
#define TAR_OPT_LZMA (1 << (TAR_OPT_AFTER_BZIP2))
#ifdef CONFIG_FEATURE_TAR_LZMA
# define TAR_OPT_STR_LZMA "a"
# define TAR_OPT_AFTER_LZMA TAR_OPT_AFTER_BZIP2 + 1
#else
# define TAR_OPT_STR_LZMA ""
# define TAR_OPT_AFTER_LZMA TAR_OPT_AFTER_BZIP2
#endif
#define TAR_OPT_INCLUDE_FROM (1 << (TAR_OPT_AFTER_LZMA))
#define TAR_OPT_EXCLUDE_FROM (1 << (TAR_OPT_AFTER_LZMA + 1))
#ifdef CONFIG_FEATURE_TAR_FROM
# define TAR_OPT_INCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2))
# define TAR_OPT_EXCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + 1))
# define TAR_OPT_STR_FROM "T:X:"
# define TAR_OPT_FLAG_FROM 2
# define TAR_OPT_STR_FROM "T:X:"
# define TAR_OPT_AFTER_FROM TAR_OPT_AFTER_LZMA + 2
#else
# define TAR_OPT_STR_FROM ""
# define TAR_OPT_FLAG_FROM 0
# define TAR_OPT_STR_FROM ""
# define TAR_OPT_AFTER_FROM TAR_OPT_AFTER_LZMA
#endif
#define TAR_OPT_GZIP (1 << (TAR_OPT_AFTER_FROM))
#ifdef CONFIG_FEATURE_TAR_GZIP
# define TAR_OPT_GZIP (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + TAR_OPT_FLAG_FROM))
# define TAR_OPT_STR_GZIP "z"
# define TAR_OPT_FLAG_GZIP 1
# define TAR_OPT_STR_GZIP "z"
# define TAR_OPT_AFTER_GZIP TAR_OPT_AFTER_FROM + 1
#else
# define TAR_OPT_STR_GZIP ""
# define TAR_OPT_FLAG_GZIP 0
# define TAR_OPT_STR_GZIP ""
# define TAR_OPT_AFTER_GZIP TAR_OPT_AFTER_FROM
#endif
#define TAR_OPT_UNCOMPRESS (1 << (TAR_OPT_AFTER_GZIP))
#ifdef CONFIG_FEATURE_TAR_COMPRESS
# define TAR_OPT_UNCOMPRESS (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + TAR_OPT_FLAG_FROM + TAR_OPT_FLAG_GZIP))
# define TAR_OPT_STR_COMPRESS "Z"
# define TAR_OPT_STR_COMPRESS "Z"
# define TAR_OPT_AFTER_COMPRESS TAR_OPT_AFTER_GZIP + 1
#else
# define TAR_OPT_STR_COMPRESS ""
# define TAR_OPT_STR_COMPRESS ""
# define TAR_OPT_AFTER_COMPRESS TAR_OPT_AFTER_GZIP
#endif
#define TAR_OPT_NOPRESERVE_OWN (1 << (TAR_OPT_AFTER_COMPRESS))
#define TAR_OPT_NOPRESERVE_PERM (1 << (TAR_OPT_AFTER_COMPRESS + 1))
#define TAR_OPT_STR_NOPRESERVE "\203\213"
#define TAR_OPT_AFTER_NOPRESERVE TAR_OPT_AFTER_COMPRESS + 2
static const char tar_options[]="txC:f:Opvk" \
TAR_OPT_STR_CREATE \
TAR_OPT_STR_BZIP2 \
TAR_OPT_STR_LZMA \
TAR_OPT_STR_FROM \
TAR_OPT_STR_GZIP \
TAR_OPT_STR_COMPRESS;
TAR_OPT_STR_COMPRESS \
TAR_OPT_STR_NOPRESERVE;
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
static const struct option tar_long_options[] = {
{ "list", 0, NULL, 't' },
{ "extract", 0, NULL, 'x' },
{ "directory", 1, NULL, 'C' },
{ "file", 1, NULL, 'f' },
{ "to-stdout", 0, NULL, 'O' },
{ "list", 0, NULL, 't' },
{ "extract", 0, NULL, 'x' },
{ "directory", 1, NULL, 'C' },
{ "file", 1, NULL, 'f' },
{ "to-stdout", 0, NULL, 'O' },
{ "same-permissions", 0, NULL, 'p' },
{ "verbose", 0, NULL, 'v' },
{ "keep-old", 0, NULL, 'k' },
{ "verbose", 0, NULL, 'v' },
{ "keep-old", 0, NULL, 'k' },
{ "no-same-owner", 0, NULL, '\203' },
{ "no-same-permissions",0, NULL, '\213' },
# ifdef CONFIG_FEATURE_TAR_CREATE
{ "create", 0, NULL, 'c' },
{ "dereference", 0, NULL, 'h' },
{ "create", 0, NULL, 'c' },
{ "dereference", 0, NULL, 'h' },
# endif
# ifdef CONFIG_FEATURE_TAR_BZIP2
{ "bzip2", 0, NULL, 'j' },
{ "bzip2", 0, NULL, 'j' },
# endif
# ifdef CONFIG_FEATURE_TAR_LZMA
{ "lzma", 0, NULL, 'a' },
# endif
# ifdef CONFIG_FEATURE_TAR_FROM
{ "files-from", 1, NULL, 'T' },
{ "exclude-from", 1, NULL, 'X' },
{ "files-from", 1, NULL, 'T' },
{ "exclude-from", 1, NULL, 'X' },
{ "exclude", 1, NULL, '\n' },
# endif
# ifdef CONFIG_FEATURE_TAR_GZIP
{ "gzip", 0, NULL, 'z' },
{ "gzip", 0, NULL, 'z' },
# endif
# ifdef CONFIG_FEATURE_TAR_COMPRESS
{ "compress", 0, NULL, 'Z' },
{ "compress", 0, NULL, 'Z' },
# endif
{ 0, 0, 0, 0 }
{ 0, 0, 0, 0 }
};
#else
#define tar_long_options 0
#endif
int tar_main(int argc, char **argv)
@@ -691,105 +712,84 @@ int tar_main(int argc, char **argv)
char *base_dir = NULL;
const char *tar_filename = "-";
unsigned long opt;
unsigned long ctx_flag = 0;
if (argc < 2) {
bb_show_usage();
}
/* Prepend '-' to the first argument if required */
if (argv[1][0] != '-') {
char *tmp;
bb_xasprintf(&tmp, "-%s", argv[1]);
argv[1] = tmp;
}
llist_t *excludes = NULL;
/* Initialise default values */
tar_handle = init_handle();
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
bb_opt_complementaly = "c~tx:t~cx:x~ct:X*:T*";
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
bb_applet_long_options = tar_long_options;
#endif
/* Prepend '-' to the first argument if required */
bb_opt_complementally = ENABLE_FEATURE_TAR_CREATE ?
"--:X::T::\n::c:t:x:?:c--tx:t--cx:x--ct" :
"--:X::T::\n::t:x:?:t--x:x--t";
if (ENABLE_FEATURE_TAR_LONG_OPTIONS)
bb_applet_long_options = tar_long_options;
opt = bb_getopt_ulflags(argc, argv, tar_options,
&base_dir, /* Change to dir <optarg> */
&tar_filename /* archive filename */
#ifdef CONFIG_FEATURE_TAR_FROM
, &(tar_handle->accept),
&(tar_handle->reject)
&(tar_handle->reject),
&excludes
#endif
);
/* Check one and only one context option was given */
if(opt & 0x80000000UL) {
bb_show_usage();
}
#ifdef CONFIG_FEATURE_TAR_CREATE
ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT);
#else
ctx_flag = opt & (CTX_TEST | CTX_EXTRACT);
#endif
if (ctx_flag == 0) {
bb_show_usage();
}
if(ctx_flag & CTX_TEST) {
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list)) {
tar_handle->action_header = header_verbose_list;
} else {
tar_handle->action_header = header_list;
}
}
if(ctx_flag & CTX_EXTRACT) {
if (tar_handle->action_data != data_extract_to_stdout)
tar_handle->action_data = data_extract_all;
}
if(opt & TAR_OPT_2STDOUT) {
/* To stdout */
tar_handle->action_data = data_extract_to_stdout;
}
if(opt & TAR_OPT_VERBOSE) {
if (opt & CTX_TEST) {
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list))
{
tar_handle->action_header = header_verbose_list;
} else {
tar_handle->action_header = header_list;
}
}
if (opt & TAR_OPT_KEEP_OLD) {
tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
tar_handle->action_header = header_verbose_list;
} else tar_handle->action_header = header_list;
}
if((opt & CTX_EXTRACT) && tar_handle->action_data != data_extract_to_stdout)
tar_handle->action_data = data_extract_all;
#ifdef CONFIG_FEATURE_TAR_GZIP
if(opt & TAR_OPT_GZIP) {
if (opt & TAR_OPT_2STDOUT)
tar_handle->action_data = data_extract_to_stdout;
if (opt & TAR_OPT_VERBOSE) {
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list))
{
tar_handle->action_header = header_verbose_list;
} else
tar_handle->action_header = header_list;
}
if (opt & TAR_OPT_KEEP_OLD)
tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
if (opt & TAR_OPT_NOPRESERVE_OWN)
tar_handle->flags |= ARCHIVE_NOPRESERVE_OWN;
if (opt & TAR_OPT_NOPRESERVE_PERM)
tar_handle->flags |= ARCHIVE_NOPRESERVE_PERM;
if (ENABLE_FEATURE_TAR_GZIP && (opt & TAR_OPT_GZIP))
get_header_ptr = get_header_tar_gz;
}
#endif
#ifdef CONFIG_FEATURE_TAR_BZIP2
if(opt & TAR_OPT_BZIP2) {
if (ENABLE_FEATURE_TAR_BZIP2 && (opt & TAR_OPT_BZIP2))
get_header_ptr = get_header_tar_bz2;
}
#endif
#ifdef CONFIG_FEATURE_TAR_COMPRESS
if(opt & TAR_OPT_UNCOMPRESS) {
if (ENABLE_FEATURE_TAR_LZMA && (opt & TAR_OPT_LZMA))
get_header_ptr = get_header_tar_lzma;
if (ENABLE_FEATURE_TAR_COMPRESS && (opt & TAR_OPT_UNCOMPRESS))
get_header_ptr = get_header_tar_Z;
}
#endif
#ifdef CONFIG_FEATURE_TAR_FROM
if(opt & TAR_OPT_EXCLUDE_FROM) {
if (ENABLE_FEATURE_TAR_FROM) {
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
}
if(opt & TAR_OPT_INCLUDE_FROM) {
/* Append excludes to reject */
while (excludes) {
llist_t *temp = excludes->link;
excludes->link = tar_handle->reject;
tar_handle->reject = excludes;
excludes = temp;
}
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
}
#endif
/* Check if we are reading from stdin */
if ((argv[optind]) && (*argv[optind] == '-')) {
if (argv[optind] && *argv[optind] == '-') {
/* Default is to read from stdin, so just skip to next arg */
optind++;
}
@@ -798,34 +798,30 @@ int tar_main(int argc, char **argv)
/* TODO: This is the same as in ar, separate function ? */
while (optind < argc) {
char *filename_ptr = last_char_is(argv[optind], '/');
if (filename_ptr) {
if (filename_ptr > argv[optind])
*filename_ptr = '\0';
}
tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]);
optind++;
}
if ((tar_handle->accept) || (tar_handle->reject)) {
if ((tar_handle->accept) || (tar_handle->reject))
tar_handle->filter = filter_accept_reject_list;
}
/* Open the tar file */
{
FILE *tar_stream;
int flags;
#ifdef CONFIG_FEATURE_TAR_CREATE
if (opt & CTX_CREATE) {
if (ENABLE_FEATURE_TAR_CREATE && (opt & CTX_CREATE)) {
/* Make sure there is at least one file to tar up. */
if (tar_handle->accept == NULL) {
bb_error_msg_and_die("Cowardly refusing to create an empty archive");
}
if (tar_handle->accept == NULL)
bb_error_msg_and_die("empty archive");
tar_stream = stdout;
flags = O_WRONLY | O_CREAT | O_EXCL;
unlink(tar_filename);
} else
#endif
{
} else {
tar_stream = stdin;
flags = O_RDONLY;
}
@@ -838,54 +834,42 @@ int tar_main(int argc, char **argv)
}
}
if ((base_dir) && (chdir(base_dir))) {
if ((base_dir) && (chdir(base_dir)))
bb_perror_msg_and_die("Couldnt chdir to %s", base_dir);
}
#ifdef CONFIG_FEATURE_TAR_CREATE
/* create an archive */
if (opt & CTX_CREATE) {
if (ENABLE_FEATURE_TAR_CREATE && (opt & CTX_CREATE)) {
int verboseFlag = FALSE;
int gzipFlag = FALSE;
int zipMode = 0;
# ifdef CONFIG_FEATURE_TAR_GZIP
if (get_header_ptr == get_header_tar_gz) {
gzipFlag = TRUE;
}
# endif /* CONFIG_FEATURE_TAR_GZIP */
# ifdef CONFIG_FEATURE_TAR_BZIP2
if (get_header_ptr == get_header_tar_bz2) {
bb_error_msg_and_die("Creating bzip2 compressed archives is not currently supported.");
}
# endif /* CONFIG_FEATURE_TAR_BZIP2 */
if (ENABLE_FEATURE_TAR_GZIP && get_header_ptr == get_header_tar_gz)
zipMode = 1;
if (ENABLE_FEATURE_TAR_BZIP2 && get_header_ptr == get_header_tar_bz2)
zipMode = 2;
if ((tar_handle->action_header == header_list) ||
(tar_handle->action_header == header_verbose_list)) {
(tar_handle->action_header == header_verbose_list))
{
verboseFlag = TRUE;
}
writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
tar_handle->reject, gzipFlag);
} else
#endif /* CONFIG_FEATURE_TAR_CREATE */
{
tar_handle->reject, zipMode);
} else {
while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
/* Ckeck that every file that should have been extracted was */
/* Check that every file that should have been extracted was */
while (tar_handle->accept) {
if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) {
if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) {
bb_error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data);
}
if (!find_list_entry(tar_handle->reject, tar_handle->accept->data)
&& !find_list_entry(tar_handle->passed, tar_handle->accept->data))
{
bb_error_msg_and_die("%s: Not found in archive", tar_handle->accept->data);
}
tar_handle->accept = tar_handle->accept->link;
}
}
#ifdef CONFIG_FEATURE_CLEAN_UP
if (tar_handle->src_fd != STDIN_FILENO) {
if (ENABLE_FEATURE_CLEAN_UP && tar_handle->src_fd != STDIN_FILENO)
close(tar_handle->src_fd);
}
#endif /* CONFIG_FEATURE_CLEAN_UP */
return(EXIT_SUCCESS);
}
+1 -2
View File
@@ -20,7 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -31,7 +30,7 @@
#define GUNZIP_TO_STDOUT 1
#define GUNZIP_FORCE 2
extern int uncompress_main(int argc, char **argv)
int uncompress_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
unsigned long flags;
+65
View File
@@ -0,0 +1,65 @@
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on bunzip.c from busybox
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#include "unarchive.h"
#define UNLZMA_OPT_STDOUT 1
int unlzma_main(int argc, char **argv)
{
char *filename;
unsigned long opt;
int status, src_fd, dst_fd;
opt = bb_getopt_ulflags(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = bb_xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as lzmacat force the stdout flag */
if ((opt & UNLZMA_OPT_STDOUT) || bb_applet_name[4] == 'c')
filename = 0;
if (filename) {
char *extension = filename + strlen(filename) - 5;
if (strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("Invalid extension");
}
*extension = 0;
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
if (filename) {
if (!status)
filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("Couldn't remove %s", filename);
}
}
return status;
}
/* vi:set ts=4: */
+343 -161
View File
@@ -2,246 +2,428 @@
/*
* Mini unzip implementation for busybox
*
* Copyright (C) 2001 by Laurence Anderson
* Copyright (C) 2004 by Ed Clark
*
* 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
* Loosely based on original busybox unzip applet by Laurence Anderson.
* All options and features should work in this version.
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
/* For reference see
* http://www.pkware.com/products/enterprise/white_papers/appnote.txt
* http://www.pkware.com/company/standards/appnote/
* http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
*/
/* TODO Endian issues, exclude, should we accept input from stdin ? */
/* TODO
* Endian issues
* Zip64 + other methods
* Improve handling of zip format, ie.
* - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3)
* - unix file permissions, etc.
* - central directory
*/
#include <fcntl.h>
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "unarchive.h"
#include "busybox.h"
#define ZIP_FILEHEADER_MAGIC 0x04034b50
#define ZIP_CDS_MAGIC 0x02014b50
#define ZIP_CDS_END_MAGIC 0x06054b50
#define ZIP_DD_MAGIC 0x08074b50
#if BB_BIG_ENDIAN
static inline unsigned short
__swap16(unsigned short x) {
return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
}
static inline uint32_t
__swap32(uint32_t x) {
return (((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) |
((x & 0xFF000000) >> 24));
}
#else /* it's little-endian */
# define __swap16(x) (x)
# define __swap32(x) (x)
#endif /* BB_BIG_ENDIAN */
#define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50)
#define ZIP_CDS_MAGIC __swap32(0x02014b50)
#define ZIP_CDS_END_MAGIC __swap32(0x06054b50)
#define ZIP_DD_MAGIC __swap32(0x08074b50)
extern unsigned int gunzip_crc;
extern unsigned int gunzip_bytes_out;
static void header_list_unzip(const file_header_t *file_header)
{
printf(" inflating: %s\n", file_header->name);
}
typedef union {
unsigned char raw[26];
struct {
unsigned short version; /* 0-1 */
unsigned short flags; /* 2-3 */
unsigned short method; /* 4-5 */
unsigned short modtime; /* 6-7 */
unsigned short moddate; /* 8-9 */
unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */
unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
unsigned short filename_len; /* 22-23 */
unsigned short extra_len; /* 24-25 */
} formated ATTRIBUTE_PACKED;
} zip_header_t;
static void header_verbose_list_unzip(const file_header_t *file_header)
static void unzip_skip(int fd, off_t skip)
{
unsigned int dostime = (unsigned int) file_header->mtime;
/* can printf arguments cut of the decade component ? */
unsigned short year = 1980 + ((dostime & 0xfe000000) >> 25);
while (year >= 100) {
year -= 100;
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) {
bb_error_msg_and_die("Seek failure");
}
}
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
(unsigned int) file_header->size,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
year,
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
file_header->name);
}
extern int unzip_main(int argc, char **argv)
static void unzip_read(int fd, void *buf, size_t count)
{
union {
unsigned char raw[26];
struct {
unsigned short version; /* 0-1 */
unsigned short flags; /* 2-3 */
unsigned short method; /* 4-5 */
unsigned short modtime; /* 6-7 */
unsigned short moddate; /* 8-9 */
unsigned int crc32 __attribute__ ((packed)); /* 10-13 */
unsigned int cmpsize __attribute__ ((packed));; /* 14-17 */
unsigned int ucmpsize __attribute__ ((packed));; /* 18-21 */
unsigned short filename_len; /* 22-23 */
unsigned short extra_len; /* 24-25 */
} formated __attribute__ ((packed));
} zip_header;
if (bb_xread(fd, buf, count) != count) {
bb_error_msg_and_die("Read failure");
}
}
archive_handle_t *archive_handle;
static void unzip_create_leading_dirs(char *fn)
{
/* Create all leading directories */
char *name = bb_xstrdup(fn);
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
bb_error_msg_and_die("Failed to create directory");
}
free(name);
}
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
{
if (zip_header->formated.method == 0) {
/* Method 0 - stored (not compressed) */
int size = zip_header->formated.ucmpsize;
if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) {
bb_error_msg_and_die("Cannot complete extraction");
}
} else {
/* Method 8 - inflate */
inflate_init(zip_header->formated.cmpsize);
inflate_unzip(src_fd, dst_fd);
inflate_cleanup();
/* Validate decompression - crc */
if (zip_header->formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("Invalid compressed data--crc error");
return 1;
}
/* Validate decompression - size */
if (zip_header->formated.ucmpsize != gunzip_bytes_out) {
bb_error_msg("Invalid compressed data--length error");
return 1;
}
}
return 0;
}
int unzip_main(int argc, char **argv)
{
zip_header_t zip_header;
enum {v_silent, v_normal, v_list} verbosity = v_normal;
enum {o_prompt, o_never, o_always} overwrite = o_prompt;
unsigned int total_size = 0;
unsigned int total_entries = 0;
int src_fd = -1, dst_fd = -1;
char *src_fn = NULL, *dst_fn = NULL;
llist_t *zaccept = NULL;
llist_t *zreject = NULL;
char *base_dir = NULL;
int opt = 0;
int failed, i, opt, opt_range = 0, list_header_done = 0;
char key_buf[512];
struct stat stat_buf;
/* Initialise */
archive_handle = init_handle();
archive_handle->action_data = NULL;
archive_handle->action_header = header_list_unzip;
while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
switch(opt_range) {
case 0: /* Options */
switch(opt) {
case 'l': /* List */
verbosity = v_list;
break;
while ((opt = getopt(argc, argv, "lnopqd:")) != -1) {
switch (opt) {
case 'l': /* list */
archive_handle->action_header = header_verbose_list_unzip;
archive_handle->action_data = data_skip;
case 'n': /* Never overwrite existing files */
overwrite = o_never;
break;
case 'n': /* never overwright existing files */
case 'o': /* Always overwrite existing files */
overwrite = o_always;
break;
case 'o':
archive_handle->flags = ARCHIVE_EXTRACT_UNCONDITIONAL;
case 'p': /* Extract files to stdout and fall through to set verbosity */
dst_fd = STDOUT_FILENO;
case 'q': /* Be quiet */
verbosity = (verbosity == v_normal) ? v_silent : verbosity;
break;
case 'p': /* extract files to stdout */
archive_handle->action_data = data_extract_to_stdout;
case 1 : /* The zip file */
src_fn = bb_xstrndup(optarg, strlen(optarg)+4);
opt_range++;
break;
case 'q': /* Extract files quietly */
archive_handle->action_header = header_skip;
break;
case 'd': /* Extract files to specified base directory*/
base_dir = optarg;
break;
#if 0
case 'x': /* Exclude the specified files */
archive_handle->filter = filter_accept_reject_list;
break;
#endif
default:
bb_show_usage();
}
break;
case 1: /* Include files */
if (opt == 1) {
zaccept = llist_add_to(zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
opt_range += 2;
} else if (opt == 'x') {
opt_range++;
} else {
bb_show_usage();
}
break;
case 2 : /* Exclude files */
if (opt == 1) {
zreject = llist_add_to(zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
opt_range++;
} else {
bb_show_usage();
}
break;
default:
bb_show_usage();
}
}
if (argc == optind) {
if (src_fn == NULL) {
bb_show_usage();
}
printf("Archive: %s\n", argv[optind]);
if (archive_handle->action_header == header_verbose_list_unzip) {
printf(" Length Date Time Name\n");
printf(" -------- ---- ---- ----\n");
}
/* Open input file */
if (strcmp("-", src_fn) == 0) {
src_fd = STDIN_FILENO;
/* Cannot use prompt mode since zip data is arriving on STDIN */
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
if (*argv[optind] == '-') {
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_char;
} else {
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
static const char *const extn[] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
for(i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = 0;
bb_error_msg_and_die("Cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
}
if ((base_dir) && (chdir(base_dir))) {
bb_perror_msg_and_die("Couldnt chdir");
/* Change dir if necessary */
if (base_dir && chdir(base_dir)) {
bb_perror_msg_and_die("Cannot chdir");
}
while (optind < argc) {
archive_handle->filter = filter_accept_list;
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
optind++;
}
if (verbosity != v_silent)
printf("Archive: %s\n", src_fn);
failed = 0;
while (1) {
unsigned int magic;
int dst_fd;
/* TODO Endian issues */
archive_xread_all(archive_handle, &magic, 4);
archive_handle->offset += 4;
/* Check magic number */
unzip_read(src_fd, &magic, 4);
if (magic == ZIP_CDS_MAGIC) {
break;
}
else if (magic != ZIP_FILEHEADER_MAGIC) {
bb_error_msg_and_die("Invlaide zip magic");
} else if (magic != ZIP_FILEHEADER_MAGIC) {
bb_error_msg_and_die("Invalid zip magic %08X", magic);
}
/* Read the file header */
archive_xread_all(archive_handle, zip_header.raw, 26);
archive_handle->offset += 26;
archive_handle->file_header->mode = S_IFREG | 0777;
if (zip_header.formated.method != 8) {
bb_error_msg_and_die("Unsupported compression method %d\n", zip_header.formated.method);
unzip_read(src_fd, zip_header.raw, 26);
#if BB_BIG_ENDIAN
zip_header.formated.version = __swap16(zip_header.formated.version);
zip_header.formated.flags = __swap16(zip_header.formated.flags);
zip_header.formated.method = __swap16(zip_header.formated.method);
zip_header.formated.modtime = __swap16(zip_header.formated.modtime);
zip_header.formated.moddate = __swap16(zip_header.formated.moddate);
zip_header.formated.crc32 = __swap32(zip_header.formated.crc32);
zip_header.formated.cmpsize = __swap32(zip_header.formated.cmpsize);
zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize);
zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len);
zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len);
#endif /* BB_BIG_ENDIAN */
if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) {
bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method);
}
/* Read filename */
archive_handle->file_header->name = xmalloc(zip_header.formated.filename_len + 1);
archive_xread_all(archive_handle, archive_handle->file_header->name, zip_header.formated.filename_len);
archive_handle->offset += zip_header.formated.filename_len;
archive_handle->file_header->name[zip_header.formated.filename_len] = '\0';
free(dst_fn);
dst_fn = xmalloc(zip_header.formated.filename_len + 1);
unzip_read(src_fd, dst_fn, zip_header.formated.filename_len);
dst_fn[zip_header.formated.filename_len] = 0;
/* Skip extra header bits */
archive_handle->file_header->size = zip_header.formated.extra_len;
data_skip(archive_handle);
archive_handle->offset += zip_header.formated.extra_len;
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formated.extra_len);
/* Handle directories */
archive_handle->file_header->mode = S_IFREG | 0777;
if (last_char_is(archive_handle->file_header->name, '/')) {
archive_handle->file_header->mode ^= S_IFREG;
archive_handle->file_header->mode |= S_IFDIR;
if ((verbosity == v_list) && !list_header_done){
printf(" Length Date Time Name\n");
printf(" -------- ---- ---- ----\n");
list_header_done = 1;
}
/* Data section */
archive_handle->file_header->size = zip_header.formated.cmpsize;
if (archive_handle->action_data) {
archive_handle->action_data(archive_handle);
} else {
dst_fd = bb_xopen(archive_handle->file_header->name, O_WRONLY | O_CREAT);
inflate_init(zip_header.formated.cmpsize);
inflate_unzip(archive_handle->src_fd, dst_fd);
close(dst_fd);
chmod(archive_handle->file_header->name, archive_handle->file_header->mode);
/* Filter zip entries */
if (find_list_entry(zreject, dst_fn) ||
(zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */
i = 'n';
/* Validate decompression - crc */
if (zip_header.formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("Invalid compressed data--crc error");
}
} else { /* Extract entry */
total_size += zip_header.formated.ucmpsize;
/* Validate decompression - size */
if (gunzip_bytes_out != zip_header.formated.ucmpsize) {
bb_error_msg("Invalid compressed data--length error");
if (verbosity == v_list) { /* List entry */
unsigned int dostime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
zip_header.formated.ucmpsize,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
(dostime & 0x0000f800) >> 11,
(dostime & 0x000007e0) >> 5,
dst_fn);
total_entries++;
i = 'n';
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
i = -1;
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
if (stat(dst_fn, &stat_buf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
}
if (verbosity == v_normal) {
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, 0777, 0)) {
bb_error_msg_and_die("Failed to create directory");
}
} else {
if (!S_ISDIR(stat_buf.st_mode)) {
bb_error_msg_and_die("'%s' exists but is not directory", dst_fn);
}
}
i = 'n';
} else { /* Extract file */
_check_file:
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
if (errno != ENOENT) {
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
}
i = 'y';
} else { /* File already exists */
if (overwrite == o_never) {
i = 'n';
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
if (overwrite == o_always) {
i = 'y';
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("Cannot read input");
}
i = key_buf[0];
}
} else { /* File is not regular file */
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
}
}
}
}
/* local file descriptor section */
archive_handle->offset += zip_header.formated.cmpsize;
/* This ISNT unix time */
archive_handle->file_header->mtime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
archive_handle->file_header->size = zip_header.formated.ucmpsize;
total_size += archive_handle->file_header->size;
total_entries++;
switch (i) {
case 'A':
overwrite = o_always;
case 'y': /* Open file and fall into unzip */
unzip_create_leading_dirs(dst_fn);
dst_fd = bb_xopen(dst_fn, O_WRONLY | O_CREAT);
case -1: /* Unzip */
if (verbosity == v_normal) {
printf(" inflating: %s\n", dst_fn);
}
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
failed = 1;
}
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */
close(dst_fd);
}
break;
archive_handle->action_header(archive_handle->file_header);
case 'N':
overwrite = o_never;
case 'n':
/* Skip entry data */
unzip_skip(src_fd, zip_header.formated.cmpsize);
break;
case 'r':
/* Prompt for new name */
printf("new name: ");
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("Cannot read input");
}
free(dst_fn);
dst_fn = bb_xstrdup(key_buf);
chomp(dst_fn);
goto _check_file;
default:
printf("error: invalid response [%c]\n",(char)i);
goto _check_file;
}
/* Data descriptor section */
if (zip_header.formated.flags & 4) {
/* skip over duplicate crc, compressed size and uncompressed size */
unsigned char data_description[12];
archive_xread_all(archive_handle, data_description, 12);
archive_handle->offset += 12;
unzip_skip(src_fd, 12);
}
}
/* Central directory section */
if (archive_handle->action_header == header_verbose_list_unzip) {
printf(" -------- -------\n");
printf("%9d %d files\n", total_size, total_entries);
if (verbosity == v_list) {
printf(" -------- -------\n"
"%9d %d files\n", total_size, total_entries);
}
return(EXIT_SUCCESS);
return failed;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+13
View File
@@ -58,6 +58,13 @@ config CONFIG_RESET
This program is used to reset the terminal screen, if it
gets messed up.
config CONFIG_SETCONSOLE
bool "setconsole"
default n
help
This program redirects the system console to another device,
like the current tty while logged in via telnet.
config CONFIG_SETKEYCODES
bool "setkeycodes"
default n
@@ -65,4 +72,10 @@ config CONFIG_SETKEYCODES
This program loads entries into the kernel's scancode-to-keycode
map, allowing unusual keyboards to generate usable keycodes.
config CONFIG_SETLOGCONS
bool "setlogcons"
default n
help
This program redirects the output console of kernel messages.
endmenu
+6 -15
View File
@@ -1,24 +1,15 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/console/tools
CONSOLETOOLS_DIR:=./
include $(top_builddir)/Rules.mak
+23 -29
View File
@@ -1,21 +1,8 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
CONSOLETOOLS_AR:=console-tools.a
ifndef $(CONSOLETOOLS_DIR)
@@ -23,22 +10,29 @@ CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
endif
srcdir=$(top_srcdir)/console-tools
CONSOLETOOLS_DIR-y:=
CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o
CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o
CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o
CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o
CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o
CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o
CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o
CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o
CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
CONSOLETOOLS-y:=
CONSOLETOOLS-$(CONFIG_CHVT) += chvt.o
CONSOLETOOLS-$(CONFIG_CLEAR) += clear.o
CONSOLETOOLS-$(CONFIG_DEALLOCVT) += deallocvt.o
CONSOLETOOLS-$(CONFIG_DUMPKMAP) += dumpkmap.o
CONSOLETOOLS-$(CONFIG_SETCONSOLE) += setconsole.o
CONSOLETOOLS-$(CONFIG_LOADFONT) += loadfont.o
CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o
CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o
CONSOLETOOLS-$(CONFIG_RESET) += reset.o
CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o
CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o
ifneq ($(strip $(CONSOLETOOLS-y)),)
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
endif
CONSOLETOOLS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(CONSOLETOOLS-y))
CONSOLETOOLS_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(CONSOLETOOLS_SRC-y)
APPLET_SRC-a+=$(CONSOLETOOLS_SRC-a)
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
$(AR) -ro $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS-y))
$(do_ar)
$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
$(compile.c)
+7 -7
View File
@@ -29,8 +29,10 @@
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_ACTIVATE = 0x5606; /* make vt active */
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
enum {
VT_ACTIVATE = 0x5606, /* make vt active */
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
int chvt_main(int argc, char **argv)
{
@@ -42,11 +44,9 @@ int chvt_main(int argc, char **argv)
fd = get_console_fd();
num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
if (ioctl(fd, VT_ACTIVATE, num)) {
bb_perror_msg_and_die("VT_ACTIVATE");
}
if (ioctl(fd, VT_WAITACTIVE, num)) {
bb_perror_msg_and_die("VT_WAITACTIVE");
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
bb_perror_msg_and_die("ioctl");
}
return EXIT_SUCCESS;
}
+2 -3
View File
@@ -27,8 +27,7 @@
#include "busybox.h"
extern int clear_main(int argc, char **argv)
int clear_main(int argc, char **argv)
{
printf("\033[H\033[J");
return EXIT_SUCCESS;
return printf("\033[H\033[J") != 6;
}
+6 -6
View File
@@ -30,26 +30,26 @@
#include "busybox.h"
/* From <linux/vt.h> */
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
{
/* num = 0 deallocate all unused consoles */
int num = 0;
switch(argc)
{
switch (argc) {
case 2:
if((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0)
if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
bb_error_msg_and_die("0: illegal VT number");
/* Falltrough */
}
/* Fallthrough */
case 1:
break;
default:
bb_show_usage();
}
if (ioctl( get_console_fd(), VT_DISALLOCATE, num )) {
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
bb_perror_msg_and_die("VT_DISALLOCATE");
}
return EXIT_SUCCESS;
+18 -25
View File
@@ -35,11 +35,11 @@ struct kbentry {
unsigned char kb_index;
unsigned short kb_value;
};
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
/* From <linux/keyboard.h> */
static const int NR_KEYS = 128;
static const int MAX_NR_KEYMAPS = 256;
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv)
{
@@ -47,28 +47,21 @@ int dumpkmap_main(int argc, char **argv)
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
if (argc>=2 && *argv[1]=='-') {
if (argc >= 2 && *argv[1] == '-')
bb_show_usage();
}
fd=bb_xopen(CURRENT_VC, O_RDWR);
fd = bb_xopen(CURRENT_VC, O_RDWR);
write(1, magic, 7);
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
flags[0]=1;
flags[1]=1;
flags[2]=1;
flags[4]=1;
flags[5]=1;
flags[6]=1;
flags[8]=1;
flags[9]=1;
flags[10]=1;
flags[12]=1;
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
memset(flags, 0x00, MAX_NR_KEYMAPS);
memset(flags, 0x01, 13);
flags[3] = flags[7] = flags[11] = 0;
/* dump flags */
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
write(1, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
@@ -76,13 +69,13 @@ int dumpkmap_main(int argc, char **argv)
ke.kb_index = j;
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
bb_error_msg("ioctl returned: %m, %s, %s, %xqq", (char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
}
else {
write(1,(void*)&ke.kb_value,2);
}
bb_perror_msg("ioctl failed with %s, %s, %p",
(char *)&ke.kb_index,
(char *)&ke.kb_table,
&ke.kb_value);
} else {
write(1, (void*)&ke.kb_value, 2);
}
}
}
}
+11 -9
View File
@@ -21,13 +21,15 @@
#include <endian.h>
#include "busybox.h"
static const int PSF_MAGIC1 = 0x36;
static const int PSF_MAGIC2 = 0x04;
enum{
PSF_MAGIC1 = 0x36,
PSF_MAGIC2 = 0x04,
static const int PSF_MODE512 = 0x01;
static const int PSF_MODEHASTAB = 0x02;
static const int PSF_MAXMODE = 0x03;
static const int PSF_SEPARATOR = 0xFFFF;
PSF_MODE512 = 0x01,
PSF_MODEHASTAB = 0x02,
PSF_MAXMODE = 0x03,
PSF_SEPARATOR = 0xFFFF
};
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
@@ -39,7 +41,7 @@ struct psf_header {
static void loadnewfont(int fd);
extern int loadfont_main(int argc, char **argv)
int loadfont_main(int argc, char **argv)
{
int fd;
@@ -52,7 +54,7 @@ extern int loadfont_main(int argc, char **argv)
return EXIT_SUCCESS;
}
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
{
char buf[16384];
int i;
@@ -138,7 +140,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
static void loadnewfont(int fd)
{
int unit;
char inbuf[32768]; /* primitive */
unsigned char inbuf[32768]; /* primitive */
unsigned int inputlth, offset;
/*
+10 -21
View File
@@ -35,28 +35,19 @@
int openvt_main(int argc, char **argv)
{
int fd;
char vtname[sizeof VC_FORMAT + 2];
char vtname[sizeof(VC_FORMAT) + 2];
if (argc < 3)
bb_show_usage();
if (argc < 3) {
bb_show_usage();
}
/* check for Illegal vt number: < 1 or > 12 */
sprintf(vtname, VC_FORMAT,(int)bb_xgetlarg(argv[1], 10, 1, 12));
sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
argv+=2;
argc-=2;
if(fork() == 0) {
if (fork() == 0) {
/* leave current vt */
#ifdef ESIX_5_3_2_D
if (setpgrp() < 0) {
#else
if (setsid() < 0) {
#endif
bb_perror_msg_and_die("Unable to set new session");
bb_perror_msg_and_die("setsid");
}
close(0); /* so that new vt becomes stdin */
@@ -64,12 +55,10 @@ int openvt_main(int argc, char **argv)
fd = bb_xopen(vtname, O_RDWR);
/* Reassign stdout and sterr */
close(1);
close(2);
dup(fd);
dup(fd);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
execvp(argv[0], argv);
execvp(argv[2], &argv[2]);
_exit(1);
}
return EXIT_SUCCESS;
+3 -3
View File
@@ -28,14 +28,14 @@
#include <unistd.h>
#include "busybox.h"
extern int reset_main(int argc, char **argv)
int reset_main(int argc, char **argv)
{
if (isatty(0) || isatty(0) || isatty(0)) {
if (isatty(1)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
* "ESC [ J" -- Erase display
* "ESC [ 0 m" -- Reset all Graphics Rendition display attributes
* "ESC [ 0 m" -- Reset all display attributes
* "ESC [ ? 25 h" -- Make cursor visible.
*/
printf("\033c\033(K\033[J\033[0m\033[?25h");
+70
View File
@@ -0,0 +1,70 @@
/* vi: set sw=4 ts=4: */
/*
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
*
* 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/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <getopt.h> /* struct option */
#include "busybox.h"
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
bb_applet_long_options = setconsole_long_options;
flags = bb_getopt_ulflags(argc, argv, "r");
if (argc - optind > 1)
bb_show_usage();
if (argc - optind == 1) {
if (flags & OPT_SETCONS_RESET)
bb_show_usage();
device = argv[optind];
} else {
if (flags & OPT_SETCONS_RESET)
device = CONSOLE_DEV;
}
if (-1 == ioctl(bb_xopen(device, O_RDONLY), TIOCCONS)) {
bb_perror_msg_and_die("TIOCCONS");
}
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+4 -2
View File
@@ -33,7 +33,9 @@
struct kbkeycode {
unsigned int scancode, keycode;
};
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
enum {
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
};
extern int
setkeycodes_main(int argc, char** argv)
@@ -45,7 +47,7 @@ setkeycodes_main(int argc, char** argv)
if (argc % 2 != 1 || argc < 2) {
bb_show_usage();
}
fd = get_console_fd();
while (argc > 2) {
+34
View File
@@ -0,0 +1,34 @@
/*
* setlogcons: Send kernel messages to the current console or to console N
*
* Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
*
* Based on setlogcons (kbd-1.12) by Andries E. Brouwer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "busybox.h"
extern int setlogcons_main(int argc, char **argv)
{
struct {
char fn;
char subarg;
} arg;
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
arg.subarg = atoi(argv[1]);
if (ioctl(bb_xopen("/dev/tty1", O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");;
return 0;
}
+134 -68
View File
@@ -59,6 +59,13 @@ config CONFIG_CMP
cmp is used to compare two files and returns the result
to standard output.
config CONFIG_COMM
bool "comm"
default n
help
comm is used to compare two files line by line and return
a three-column output.
config CONFIG_CP
bool "cp"
default n
@@ -72,20 +79,12 @@ config CONFIG_CUT
cut is used to print selected parts of lines from
each file to stdout.
if CONFIG_WATCH
config CONFIG_DATE
default y
comment "date (forced enabled for use with watch)"
endif
if !CONFIG_WATCH
config CONFIG_DATE
bool "date"
default n
help
date is used to set the system date or display the
current time in the given format.
endif
config CONFIG_DATE
bool "date"
default n
help
date is used to set the system date or display the
current time in the given format.
config CONFIG_FEATURE_DATE_ISOFMT
bool " Enable ISO date format output (-I)"
@@ -144,11 +143,12 @@ config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
Use a blocksize of (1K) instead of the default 512b.
config CONFIG_ECHO
bool "echo (basic SUSv3 version taking no options)"
bool "echo (basic SuSv3 version taking no options)"
default n
help
echo is used to print a specified string to stdout.
# this entry also appears in shell/Config.in, next to the echo builtin
config CONFIG_FEATURE_FANCY_ECHO
bool " Enable echo options (-n and -e)"
default y
@@ -171,19 +171,20 @@ config CONFIG_EXPR
expr is used to calculate numbers and print the result
to standard output.
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
config CONFIG_FALSE
default y
comment "false (forced enabled for use with shell)"
endif
config CONFIG_EXPR_MATH_SUPPORT_64
bool " Extend Posix numbers support to 64 bit"
default n
depends on CONFIG_EXPR
help
Enable 64-bit math support in the expr applet. This will make
the applet slightly larger, but will allow computation with very
large numbers.
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
config CONFIG_FALSE
bool "false"
default n
help
false returns an exit code of FALSE (1).
endif
config CONFIG_FALSE
bool "false"
default n
help
false returns an exit code of FALSE (1).
config CONFIG_FOLD
bool "fold"
@@ -291,11 +292,22 @@ config CONFIG_FEATURE_LS_USERNAME
Allow ls to display username/groupname for files.
config CONFIG_FEATURE_LS_COLOR
bool " Use color to identify file types"
bool " Allow use of color to identify file types"
default y
depends on CONFIG_LS
help
Allow ls to use color when displaying files.
This enables the --color option to ls.
config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
bool " Produce colored ls output by default"
default n
depends on CONFIG_FEATURE_LS_COLOR
help
Saying yes here will turn coloring on by default,
even if no "--color" option is given to the ls command.
This is not recommended, since the colors are not
configurable, and the output may not be legible on
many output screens.
config CONFIG_MD5SUM
bool "md5sum"
@@ -329,12 +341,30 @@ config CONFIG_MV
help
mv is used to move or rename files or directories.
config CONFIG_NICE
bool "nice"
default n
help
nice runs a program with modified scheduling priority.
config CONFIG_NOHUP
bool "nohup"
default n
help
run a command immune to hangups, with output to a non-tty.
config CONFIG_OD
bool "od"
default n
help
od is used to dump binary files in octal and other formats.
config CONFIG_PRINTENV
bool "printenv"
default n
help
printenv is used to print all or part of environment.
config CONFIG_PRINTF
bool "printf"
default n
@@ -398,12 +428,45 @@ config CONFIG_SORT
help
sort is used to sort lines of text in specified files.
config CONFIG_FEATURE_SORT_BIG
bool " full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
default y
depends on CONFIG_SORT
help
Without this, sort only supports -r, -u, and an integer version
of -n. Selecting this adds sort keys, floating point support, and
more. This adds a little over 3k to a nonstatic build on x86.
The SuSv3 sort standard is available at:
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
config CONFIG_STAT
bool "stat"
default n
help
display file or filesystem status.
config CONFIG_FEATURE_STAT_FORMAT
bool " Enable custom formats (-c)"
default n
depends on CONFIG_STAT
help
Without this, stat will not support the '-c format' option where
users can pass a custom format string for output. This adds about
7k to a nonstatic build on amd64.
config CONFIG_STTY
bool "stty"
default n
help
stty is used to change and print terminal line settings.
config CONFIG_SUM
bool "sum"
default n
help
checksum and count the blocks in a file
config CONFIG_SYNC
bool "sync"
default n
@@ -439,21 +502,13 @@ config CONFIG_FEATURE_TEE_USE_BLOCK_IO
help
Enable this option for a faster tee, at expense of size.
if CONFIG_ASH || CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
config CONFIG_TEST
default y
comment "test (forced enabled for use with shell)"
endif
if !CONFIG_ASH && !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
config CONFIG_TEST
bool "test"
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The shells (ash
and bash) have test builtin.
endif
config CONFIG_TEST
bool "test"
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The shells (ash
and bash) have test builtin.
config CONFIG_FEATURE_TEST_64
bool " Extend test to 64 bit"
@@ -476,20 +531,30 @@ config CONFIG_TR
tr is used to squeeze, and/or delete characters from standard
input, writing to standard output.
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
config CONFIG_TRUE
default y
comment "true (forced enabled for use with shell)"
endif
config CONFIG_FEATURE_TR_CLASSES
bool " Enable character classes (such as [:upper:])"
default n
depends on CONFIG_TR
help
Enable character classes, enabling commands such as:
tr [:upper:] [:lower:] to convert input into lowercase.
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
config CONFIG_TRUE
bool "true"
default n
help
true returns an exit code of TRUE (0).
config CONFIG_FEATURE_TR_EQUIV
bool " Enable equivalence classes"
default n
depends on CONFIG_TR
help
Enable equivalence classes, which essentially add the enclosed
character to the current set. For instance, tr [=a=] xyz would
replace all instances of 'a' with 'xyz'. This option is mainly
useful for cases when no other way of expressing a character
is possible.
endif
config CONFIG_TRUE
bool "true"
default n
help
true returns an exit code of TRUE (0).
config CONFIG_TTY
bool "tty"
@@ -531,6 +596,7 @@ config CONFIG_UUENCODE
config CONFIG_WATCH
bool "watch"
default n
select CONFIG_DATE
help
watch is used to execute a program periodically, showing
output to the screen.
@@ -545,7 +611,7 @@ config CONFIG_WC
config CONFIG_WHO
bool "who"
default n
select CONFIG_FEATURE_U_W_TMP
select CONFIG_FEATURE_UTMP
help
who is used to show who is logged on.
@@ -564,7 +630,7 @@ config CONFIG_YES
the default string `y'.
comment "Common options for cp and mv"
depends on CONFIG_CP || CONFIG_MV
depends on CONFIG_CP || CONFIG_MV
config CONFIG_FEATURE_PRESERVE_HARDLINKS
bool " Preserve hard links"
@@ -573,22 +639,22 @@ config CONFIG_FEATURE_PRESERVE_HARDLINKS
help
Allow cp and mv to preserve hard links.
comment "Common options for ls and more"
depends on CONFIG_LS || CONFIG_MORE
comment "Common options for ls, more and telnet"
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
config CONFIG_FEATURE_AUTOWIDTH
bool " Calculate terminal & column widths"
default y
depends on CONFIG_LS || CONFIG_MORE
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
help
This option allows utilities such as 'ls' and 'more' to determine the
width of the screen, which can allow them to display additional text
or avoid wrapping text onto the next line. If you leave this
disabled, your utilities will be especially primitive and will be
unable to determine the current screen width.
This option allows utilities such as 'ls', 'more' and 'telnet'
to determine the width of the screen, which can allow them to
display additional text or avoid wrapping text onto the next line.
If you leave this disabled, your utilities will be especially
primitive and will be unable to determine the current screen width.
comment "Common options for df, du, ls"
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
config CONFIG_FEATURE_HUMAN_READABLE
bool " Support for human readable output (example 13k, 23M, 235G)"
@@ -598,7 +664,7 @@ config CONFIG_FEATURE_HUMAN_READABLE
Allow df, du, and ls to have human readable output.
comment "Common options for md5sum, sha1sum"
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
bool " Enable -c, -s and -w options"
+6 -15
View File
@@ -1,24 +1,15 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/coreutils
SHELLUTILS_DIR:=./
include $(top_builddir)/Rules.mak
+82 -81
View File
@@ -1,21 +1,8 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
COREUTILS_AR:=coreutils.a
ifndef $(COREUTILS_DIR)
@@ -24,75 +11,89 @@ endif
srcdir=$(top_srcdir)/coreutils
COREUTILS-y:=
COREUTILS-$(CONFIG_BASENAME) += basename.o
COREUTILS-$(CONFIG_CAL) += cal.o
COREUTILS-$(CONFIG_CAT) += cat.o
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
COREUTILS-$(CONFIG_CHMOD) += chmod.o
COREUTILS-$(CONFIG_CHOWN) += chown.o
COREUTILS-$(CONFIG_CHROOT) += chroot.o
COREUTILS-$(CONFIG_CMP) += cmp.o
COREUTILS-$(CONFIG_CP) += cp.o
COREUTILS-$(CONFIG_CUT) += cut.o
COREUTILS-$(CONFIG_DATE) += date.o
COREUTILS-$(CONFIG_DD) += dd.o
COREUTILS-$(CONFIG_DF) += df.o
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
COREUTILS-$(CONFIG_DU) += du.o
COREUTILS-$(CONFIG_ECHO) += echo.o
COREUTILS-$(CONFIG_ENV) += env.o
COREUTILS-$(CONFIG_EXPR) += expr.o
COREUTILS-$(CONFIG_FALSE) += false.o
COREUTILS-$(CONFIG_FOLD) += fold.o
COREUTILS-$(CONFIG_HEAD) += head.o
COREUTILS-$(CONFIG_HOSTID) += hostid.o
COREUTILS-$(CONFIG_ID) += id.o
COREUTILS-$(CONFIG_INSTALL) += install.o
COREUTILS-$(CONFIG_LENGTH) += length.o
COREUTILS-$(CONFIG_LN) += ln.o
COREUTILS-$(CONFIG_LOGNAME) += logname.o
COREUTILS-$(CONFIG_LS) += ls.o
COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
COREUTILS-$(CONFIG_MKNOD) += mknod.o
COREUTILS-$(CONFIG_MV) += mv.o
COREUTILS-$(CONFIG_OD) += od.o
COREUTILS-$(CONFIG_PRINTF) += printf.o
COREUTILS-$(CONFIG_PWD) += pwd.o
COREUTILS-$(CONFIG_REALPATH) += realpath.o
COREUTILS-$(CONFIG_RM) += rm.o
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
COREUTILS-$(CONFIG_SEQ) += seq.o
COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_SLEEP) += sleep.o
COREUTILS-$(CONFIG_SORT) += sort.o
COREUTILS-$(CONFIG_STTY) += stty.o
COREUTILS-$(CONFIG_SYNC) += sync.o
COREUTILS-$(CONFIG_TAIL) += tail.o
COREUTILS-$(CONFIG_TEE) += tee.o
COREUTILS-$(CONFIG_TEST) += test.o
COREUTILS-$(CONFIG_TOUCH) += touch.o
COREUTILS-$(CONFIG_TR) += tr.o
COREUTILS-$(CONFIG_TRUE) += true.o
COREUTILS-$(CONFIG_TTY) += tty.o
COREUTILS-$(CONFIG_UNAME) += uname.o
COREUTILS-$(CONFIG_UNIQ) += uniq.o
COREUTILS-$(CONFIG_USLEEP) += usleep.o
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
COREUTILS-$(CONFIG_WATCH) += watch.o
COREUTILS-$(CONFIG_WC) += wc.o
COREUTILS-$(CONFIG_WHO) += who.o
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
COREUTILS-$(CONFIG_YES) += yes.o
COREUTILS-$(CONFIG_BASENAME) += basename.o
COREUTILS-$(CONFIG_CAL) += cal.o
COREUTILS-$(CONFIG_CAT) += cat.o
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
COREUTILS-$(CONFIG_CHMOD) += chmod.o
COREUTILS-$(CONFIG_CHOWN) += chown.o
COREUTILS-$(CONFIG_CHROOT) += chroot.o
COREUTILS-$(CONFIG_CMP) += cmp.o
COREUTILS-$(CONFIG_COMM) += comm.o
COREUTILS-$(CONFIG_CP) += cp.o
COREUTILS-$(CONFIG_CUT) += cut.o
COREUTILS-$(CONFIG_DATE) += date.o
COREUTILS-$(CONFIG_DD) += dd.o
COREUTILS-$(CONFIG_DF) += df.o
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
COREUTILS-$(CONFIG_DU) += du.o
COREUTILS-$(CONFIG_ECHO) += echo.o
COREUTILS-$(CONFIG_ENV) += env.o
COREUTILS-$(CONFIG_EXPR) += expr.o
COREUTILS-$(CONFIG_FALSE) += false.o
COREUTILS-$(CONFIG_FOLD) += fold.o
COREUTILS-$(CONFIG_HEAD) += head.o
COREUTILS-$(CONFIG_HOSTID) += hostid.o
COREUTILS-$(CONFIG_ID) += id.o
COREUTILS-$(CONFIG_INSTALL) += install.o
COREUTILS-$(CONFIG_LENGTH) += length.o
COREUTILS-$(CONFIG_LN) += ln.o
COREUTILS-$(CONFIG_LOGNAME) += logname.o
COREUTILS-$(CONFIG_LS) += ls.o
COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
COREUTILS-$(CONFIG_MKNOD) += mknod.o
COREUTILS-$(CONFIG_MV) += mv.o
COREUTILS-$(CONFIG_NICE) += nice.o
COREUTILS-$(CONFIG_NOHUP) += nohup.o
COREUTILS-$(CONFIG_OD) += od.o
COREUTILS-$(CONFIG_PRINTENV) += printenv.o
COREUTILS-$(CONFIG_PRINTF) += printf.o
COREUTILS-$(CONFIG_PWD) += pwd.o
COREUTILS-$(CONFIG_REALPATH) += realpath.o
COREUTILS-$(CONFIG_RM) += rm.o
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
COREUTILS-$(CONFIG_SEQ) += seq.o
COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_SLEEP) += sleep.o
COREUTILS-$(CONFIG_SORT) += sort.o
COREUTILS-$(CONFIG_STAT) += stat.o
COREUTILS-$(CONFIG_STTY) += stty.o
COREUTILS-$(CONFIG_SUM) += sum.o
COREUTILS-$(CONFIG_SYNC) += sync.o
COREUTILS-$(CONFIG_TAIL) += tail.o
COREUTILS-$(CONFIG_TEE) += tee.o
COREUTILS-$(CONFIG_TEST) += test.o
COREUTILS-$(CONFIG_TOUCH) += touch.o
COREUTILS-$(CONFIG_TR) += tr.o
COREUTILS-$(CONFIG_TRUE) += true.o
COREUTILS-$(CONFIG_TTY) += tty.o
COREUTILS-$(CONFIG_UNAME) += uname.o
COREUTILS-$(CONFIG_UNIQ) += uniq.o
COREUTILS-$(CONFIG_USLEEP) += usleep.o
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
COREUTILS-$(CONFIG_WATCH) += watch.o
COREUTILS-$(CONFIG_WC) += wc.o
COREUTILS-$(CONFIG_WHO) += who.o
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
COREUTILS-$(CONFIG_YES) += yes.o
COREUTILS-y:=$(sort $(COREUTILS-y))
ifneq ($(strip $(COREUTILS-y)),)
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
endif
COREUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(COREUTILS-y))
COREUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(COREUTILS_SRC-y)
APPLET_SRC-a+=$(COREUTILS_SRC-a)
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
$(AR) -ro $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
$(do_ar)
$(COREUTILS_DIR)%.o: $(srcdir)/%.c
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
$(compile.c)
+1 -1
View File
@@ -37,7 +37,7 @@
#include <string.h>
#include "busybox.h"
extern int basename_main(int argc, char **argv)
int basename_main(int argc, char **argv)
{
size_t m, n;
char *s;
+10 -10
View File
@@ -31,7 +31,6 @@
#include <sys/types.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -45,10 +44,10 @@
#endif
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */
#define NUMBER_MISSING_DAYS 11 /* 11 day correction */
#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */
#define NUMBER_MISSING_DAYS 11 /* 11 day correction */
#define MAXDAYS 42 /* max slots in a month array */
#define SPACE -1 /* used in day array */
@@ -89,9 +88,9 @@ static int is_leap_year(int year)
#define leap_years_since_year_1(yr) \
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
static void center __P((char *, int, int));
static void day_array __P((int, int, int *));
static void trim_trailing_spaces_and_print __P((char *));
static void center (char *, int, int);
static void day_array (int, int, int *);
static void trim_trailing_spaces_and_print (char *);
static void blank_string(char *buf, size_t buflen);
static char *build_row(char *p, int *dp);
@@ -231,11 +230,12 @@ static void day_array(int month, int year, int *days)
memset(days, SPACE, MAXDAYS * sizeof(int));
if ((month == 9) && (year == 1752)) {
size_t oday = 0;
j_offset = julian * 244;
i = 0;
do {
days[i+2] = sep1752[i] + j_offset;
} while (++i < sizeof(sep1752));
days[oday+2] = sep1752[oday] + j_offset;
} while (++oday < sizeof(sep1752));
return;
}
+1 -1
View File
@@ -40,7 +40,7 @@
#include <unistd.h>
#include "busybox.h"
extern int cat_main(int argc, char **argv)
int cat_main(int argc, char **argv)
{
FILE *f;
int retval = EXIT_SUCCESS;
+1 -1
View File
@@ -58,7 +58,7 @@ int chgrp_main(int argc, char **argv)
argv += optind;
/* Find the selected group */
gid = get_ug_id(*argv, my_getgrnam);
gid = get_ug_id(*argv, bb_xgetgrnam);
++argv;
/* Ok, ready to do the deed now */
+3 -16
View File
@@ -7,20 +7,7 @@
* Reworked by (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
* to correctly parse '-rwxgoa'
*
* 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
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 compliant */
@@ -44,7 +31,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
return (FALSE);
}
int chmod_main(int argc, char **argv)
int chmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
{
int retval = EXIT_SUCCESS;
int recursiveFlag = FALSE;
@@ -94,7 +81,7 @@ int chmod_main(int argc, char **argv)
/* Ok, ready to do the deed now */
do {
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
if (! recursive_action (*argv, recursiveFlag, TRUE, FALSE,
fileAction, fileAction, smode)) {
retval = EXIT_FAILURE;
}
+14 -33
View File
@@ -4,20 +4,7 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
@@ -30,24 +17,21 @@
#include <string.h>
#include "busybox.h"
/* Don't use lchown for glibc older then 2.1.x */
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
#define lchown chown
#endif
static long uid;
static long gid;
static uid_t uid = -1;
static gid_t gid = -1;
static int (*chown_func)(const char *, uid_t, gid_t) = chown;
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
static int fileAction(const char *fileName, struct stat *statbuf,
void ATTRIBUTE_UNUSED *junk)
{
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
chmod(fileName, statbuf->st_mode);
return (TRUE);
if (!chown_func(fileName,
(uid == (uid_t)-1) ? statbuf->st_uid : uid,
(gid == (gid_t)-1) ? statbuf->st_gid : gid)) {
return TRUE;
}
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
return (FALSE);
bb_perror_msg("%s", fileName); /* A filename could have % in it... */
return FALSE;
}
#define FLAG_R 1
@@ -74,15 +58,12 @@ int chown_main(int argc, char **argv)
groupName = strchr(*argv, ':');
}
gid = -1;
/* Check for the username and groupname */
if (groupName) {
*groupName++ = '\0';
gid = get_ug_id(groupName, my_getgrnam);
gid = get_ug_id(groupName, bb_xgetgrnam);
}
/* Now check for the username */
uid = get_ug_id(*argv, my_getpwnam);
if (--groupName != *argv) uid = get_ug_id(*argv, bb_xgetpwnam);
++argv;
/* Ok, ready to do the deed now */
+2 -5
View File
@@ -52,11 +52,8 @@ static FILE *cmp_xfopen_input(const char *filename)
static const char fmt_eof[] = "cmp: EOF on %s\n";
static const char fmt_differ[] = "%s %s differ: char %d, line %d\n";
#if 0
static const char fmt_l_opt[] = "%.0s%.0s%d %o %o\n"; /* SUSv3 format */
#else
static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n"; /* nicer gnu format */
#endif
// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%d %o %o\n"
static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n";
static const char opt_chars[] = "sl";
+130
View File
@@ -0,0 +1,130 @@
/* vi: set sw=4 ts=4: */
/*
* Mini comm implementation for busybox
*
* Copyright (C) 2005 by Robert Sullivan <cogito.ergo.cogito@gmail.com>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#define COMM_OPT_1 0x01
#define COMM_OPT_2 0x02
#define COMM_OPT_3 0x04
/* These three variables control behaviour if non-zero */
static int only_file_1;
static int only_file_2;
static int both;
/* writeline outputs the input given, appropriately aligned according to class */
static void writeline(char *line, int class)
{
if (class == 0) {
if (!only_file_1)
return;
} else if (class == 1) {
if (!only_file_2)
return;
if (only_file_1)
putchar('\t');
}
else /*if (class == 2)*/ {
if (!both)
return;
if (only_file_1)
putchar('\t');
if (only_file_2)
putchar('\t');
}
fputs(line, stdout);
}
/* This is the real core of the program - lines are compared here */
static void cmp_files(char **infiles)
{
#define LINE_LEN 100
#define BB_EOF_0 0x1
#define BB_EOF_1 0x2
char thisline[2][LINE_LEN];
FILE *streams[2];
int i;
for (i = 0; i < 2; ++i) {
streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : bb_xfopen(infiles[i], "r"));
fgets(thisline[i], LINE_LEN, streams[i]);
}
while (*thisline[0] || *thisline[1]) {
int order = 0;
i = 0;
if (feof(streams[0])) i |= BB_EOF_0;
if (feof(streams[1])) i |= BB_EOF_1;
if (!*thisline[0])
order = 1;
else if (!*thisline[1])
order = -1;
else {
int tl0_len, tl1_len;
tl0_len = strlen(thisline[0]);
tl1_len = strlen(thisline[1]);
order = memcmp(thisline[0], thisline[1], tl0_len < tl1_len ? tl0_len : tl1_len);
if (!order)
order = tl0_len < tl1_len ? -1 : tl0_len != tl1_len;
}
if (order == 0 && !i)
writeline(thisline[1], 2);
else if (order > 0 && !(i & BB_EOF_1))
writeline(thisline[1], 1);
else if (order < 0 && !(i & BB_EOF_0))
writeline(thisline[0], 0);
if (i & BB_EOF_0 & BB_EOF_1) {
break;
} else if (i) {
i = (i & BB_EOF_0 ? 1 : 0);
while (!feof(streams[i])) {
if ((order < 0 && i) || (order > 0 && !i))
writeline(thisline[i], i);
fgets(thisline[i], LINE_LEN, streams[i]);
}
break;
} else {
if (order >= 0)
fgets(thisline[1], LINE_LEN, streams[1]);
if (order <= 0)
fgets(thisline[0], LINE_LEN, streams[0]);
}
}
fclose(streams[0]);
fclose(streams[1]);
}
int comm_main(int argc, char **argv)
{
unsigned long flags;
flags = bb_getopt_ulflags(argc, argv, "123");
if (optind + 2 != argc)
bb_show_usage();
only_file_1 = !(flags & COMM_OPT_1);
only_file_2 = !(flags & COMM_OPT_2);
both = !(flags & COMM_OPT_3);
cmp_files(argv + optind);
exit(EXIT_SUCCESS);
}
+21 -30
View File
@@ -4,20 +4,7 @@
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
@@ -41,10 +28,7 @@
#include "busybox.h"
#include "libcoreutils/coreutils.h"
/* WARNING!! ORDER IS IMPORTANT!! */
static const char cp_opts[] = "pdRfiar";
extern int cp_main(int argc, char **argv)
int cp_main(int argc, char **argv)
{
struct stat source_stat;
struct stat dest_stat;
@@ -55,14 +39,7 @@ extern int cp_main(int argc, char **argv)
int flags;
int status = 0;
/* Since these are enums, #if tests will not work. So use assert()s. */
assert(FILEUTILS_PRESERVE_STATUS == 1);
assert(FILEUTILS_DEREFERENCE == 2);
assert(FILEUTILS_RECUR == 4);
assert(FILEUTILS_FORCE == 8);
assert(FILEUTILS_INTERACTIVE == 16);
flags = bb_getopt_ulflags(argc, argv, cp_opts);
flags = bb_getopt_ulflags(argc, argv, "pdRfiarPHL");
if (flags & 32) {
flags |= (FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR | FILEUTILS_DEREFERENCE);
@@ -70,9 +47,23 @@ extern int cp_main(int argc, char **argv)
if (flags & 64) {
/* Make -r a synonym for -R,
* -r was marked as obsolete in SUSv3, but is included for compatability
*/
*/
flags |= FILEUTILS_RECUR;
}
if (flags & 128) {
/* Make -P a synonym for -d,
* -d is the GNU option while -P is the POSIX 2003 option
*/
flags |= FILEUTILS_DEREFERENCE;
}
/* Default behavior of cp is to dereference, so we don't have to do
* anything special when we are given -L.
* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun.
if (flags & 256 || flags & 512) {
;
}
*/
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
@@ -86,7 +77,7 @@ extern int cp_main(int argc, char **argv)
/* If there are only two arguments and... */
if (optind + 2 == argc) {
s_flags = cp_mv_stat2(*argv, &source_stat,
(flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
(flags & FILEUTILS_DEREFERENCE) ? stat : lstat);
if ((s_flags < 0) || ((d_flags = cp_mv_stat(last, &dest_stat)) < 0)) {
exit(EXIT_FAILURE);
}
@@ -98,8 +89,8 @@ extern int cp_main(int argc, char **argv)
((((flags & FILEUTILS_RECUR) >> 1) & s_flags) && !d_flags)
) {
/* ...do a simple copy. */
dest = last;
goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */
dest = last;
goto DO_COPY; /* Note: optind+2==argc implies argv[1]==last below. */
}
}
+8 -7
View File
@@ -23,7 +23,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
@@ -46,9 +45,11 @@ struct cut_list {
int endpos;
};
static const int BOL = 0;
static const int EOL = INT_MAX;
static const int NON_RANGE = -1;
enum {
BOL = 0,
EOL = INT_MAX,
NON_RANGE = -1
};
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
static unsigned int nlists = 0; /* number of elements in above list */
@@ -290,17 +291,17 @@ static void cut_file(FILE *file)
}
extern int cut_main(int argc, char **argv)
int cut_main(int argc, char **argv)
{
unsigned long opt;
char *sopt, *sdopt;
bb_opt_complementaly = "b~bcf:c~bcf:f~bcf";
bb_opt_complementally = "b--bcf:c--bcf:f--bcf";
opt = bb_getopt_ulflags(argc, argv, optstring, &sopt, &sopt, &sopt, &sdopt);
part = opt & (OPT_BYTE_FLGS|OPT_CHAR_FLGS|OPT_FIELDS_FLGS);
if(part == 0)
bb_error_msg_and_die("you must specify a list of bytes, characters, or fields");
if(opt & 0x80000000UL)
if(opt & BB_GETOPT_ERROR)
bb_error_msg_and_die("only one type of list may be specified");
parse_lists(sopt);
if((opt & (OPT_DELIM_FLGS))) {
+67 -114
View File
@@ -6,20 +6,7 @@
*
* iso-format handling added by Robert Griebl <griebl@gmx.de>
*
* 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
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
@@ -29,10 +16,8 @@
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying int, as well as
@@ -85,35 +70,31 @@ static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
/* Parse input and assign appropriately to tm_time */
if (t =
*tm_time, sscanf(t_string, "%d:%d:%d", &t.tm_hour, &t.tm_min,
if (t = *tm_time, sscanf(t_string, "%d:%d:%d", &t.tm_hour, &t.tm_min,
&t.tm_sec) == 3) {
/* no adjustments needed */
} else if (t =
*tm_time, sscanf(t_string, "%d:%d", &t.tm_hour,
} else if (t = *tm_time, sscanf(t_string, "%d:%d", &t.tm_hour,
&t.tm_min) == 2) {
/* no adjustments needed */
} else if (t =
*tm_time, sscanf(t_string, "%d.%d-%d:%d:%d", &t.tm_mon,
&t.tm_mday, &t.tm_hour, &t.tm_min,
&t.tm_sec) == 5) {
} else if (t = *tm_time, sscanf(t_string, "%d.%d-%d:%d:%d", &t.tm_mon,
&t.tm_mday, &t.tm_hour,
&t.tm_min, &t.tm_sec) == 5) {
/* Adjust dates from 1-12 to 0-11 */
t.tm_mon -= 1;
} else if (t =
*tm_time, sscanf(t_string, "%d.%d-%d:%d", &t.tm_mon,
&t.tm_mday, &t.tm_hour, &t.tm_min) == 4) {
} else if (t = *tm_time, sscanf(t_string, "%d.%d-%d:%d", &t.tm_mon,
&t.tm_mday,
&t.tm_hour, &t.tm_min) == 4) {
/* Adjust dates from 1-12 to 0-11 */
t.tm_mon -= 1;
} else if (t =
*tm_time, sscanf(t_string, "%d.%d.%d-%d:%d:%d", &t.tm_year,
&t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min,
&t.tm_sec) == 6) {
} else if (t = *tm_time, sscanf(t_string, "%d.%d.%d-%d:%d:%d", &t.tm_year,
&t.tm_mon, &t.tm_mday,
&t.tm_hour, &t.tm_min,
&t.tm_sec) == 6) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (t =
*tm_time, sscanf(t_string, "%d.%d.%d-%d:%d", &t.tm_year,
&t.tm_mon, &t.tm_mday, &t.tm_hour,
&t.tm_min) == 5) {
} else if (t = *tm_time, sscanf(t_string, "%d.%d.%d-%d:%d", &t.tm_year,
&t.tm_mon, &t.tm_mday,
&t.tm_hour, &t.tm_min) == 5) {
t.tm_year -= 1900; /* Adjust years */
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
@@ -124,77 +105,54 @@ static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
}
#define DATE_OPT_RFC2822 0x01
#define DATE_OPT_SET 0x02
#define DATE_OPT_UTC 0x04
#define DATE_OPT_DATE 0x08
#define DATE_OPT_SET 0x02
#define DATE_OPT_UTC 0x04
#define DATE_OPT_DATE 0x08
#define DATE_OPT_REFERENCE 0x10
#ifdef CONFIG_FEATURE_DATE_ISOFMT
# define DATE_OPT_TIMESPEC 0x20
#endif
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
int date_main(int argc, char **argv)
{
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
int set_time;
int utc;
int use_arg = 0;
time_t tm;
unsigned long opt;
struct tm tm_time;
char *filename = NULL;
#ifdef CONFIG_FEATURE_DATE_ISOFMT
int ifmt = 0;
char *isofmt_arg;
char *hintfmt_arg;
# define GETOPT_ISOFMT "I::"
#else
# define GETOPT_ISOFMT
#endif
bb_opt_complementaly = "d~ds:s~ds";
opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:" GETOPT_ISOFMT,
bb_opt_complementally = "?:d--s:s--d";
opt = bb_getopt_ulflags(argc, argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
#ifdef CONFIG_FEATURE_DATE_ISOFMT
, &isofmt_arg
#endif
);
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
set_time = opt & DATE_OPT_SET;
utc = opt & DATE_OPT_UTC;
if ((utc) && (putenv("TZ=UTC0") != 0)) {
if (utc && putenv("TZ=UTC0") != 0) {
bb_error_msg_and_die(bb_msg_memory_exhausted);
}
use_arg = opt & DATE_OPT_DATE;
if(opt & 0x80000000UL)
bb_show_usage();
#ifdef CONFIG_FEATURE_DATE_ISOFMT
if(opt & DATE_OPT_TIMESPEC) {
if(ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
if (!isofmt_arg) {
ifmt = 1;
} else {
int ifmt_len = bb_strlen(isofmt_arg);
if ((ifmt_len <= 4)
&& (strncmp(isofmt_arg, "date", ifmt_len) == 0)) {
ifmt = 1;
} else if ((ifmt_len <= 5)
&& (strncmp(isofmt_arg, "hours", ifmt_len) == 0)) {
ifmt = 2;
} else if ((ifmt_len <= 7)
&& (strncmp(isofmt_arg, "minutes", ifmt_len) == 0)) {
ifmt = 3;
} else if ((ifmt_len <= 7)
&& (strncmp(isofmt_arg, "seconds", ifmt_len) == 0)) {
ifmt = 4;
}
char *isoformats[]={"date","hours","minutes","seconds"};
for(ifmt = 4; ifmt;)
if(!strcmp(isofmt_arg,isoformats[--ifmt]))
break;
}
if (!ifmt) {
bb_show_usage();
}
}
#endif
/* XXX, date_fmt == NULL from this always */
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
date_fmt = &argv[optind][1]; /* Skip over the '+' */
} else if (date_str == NULL) {
@@ -207,8 +165,7 @@ int date_main(int argc, char **argv)
if(filename) {
struct stat statbuf;
if(stat(filename,&statbuf))
bb_perror_msg_and_die("File '%s' not found.\n",filename);
xstat(filename,&statbuf);
tm=statbuf.st_mtime;
} else time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
@@ -219,7 +176,9 @@ int date_main(int argc, char **argv)
tm_time.tm_hour = 0;
/* Process any date input to UNIX time since 1 Jan 1970 */
if (strchr(date_str, ':') != NULL) {
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
strptime(date_str, hintfmt_arg, &tm_time);
} else if (strchr(date_str, ':') != NULL) {
date_conv_ftime(&tm_time, date_str);
} else {
date_conv_time(&tm_time, date_str);
@@ -231,12 +190,12 @@ int date_main(int argc, char **argv)
if (tm < 0) {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
if (utc && (putenv("TZ=UTC0") != 0)) {
if (utc && putenv("TZ=UTC0") != 0) {
bb_error_msg_and_die(bb_msg_memory_exhausted);
}
/* if setting time, set it */
if (set_time && (stime(&tm) < 0)) {
if (set_time && stime(&tm) < 0) {
bb_perror_msg("cannot set date");
}
}
@@ -245,48 +204,42 @@ int date_main(int argc, char **argv)
/* Deal with format string */
if (date_fmt == NULL) {
#ifdef CONFIG_FEATURE_DATE_ISOFMT
switch (ifmt) {
case 4:
date_fmt = utc ? "%Y-%m-%dT%H:%M:%SZ" : "%Y-%m-%dT%H:%M:%S%z";
break;
case 3:
date_fmt = utc ? "%Y-%m-%dT%H:%MZ" : "%Y-%m-%dT%H:%M%z";
break;
case 2:
date_fmt = utc ? "%Y-%m-%dT%HZ" : "%Y-%m-%dT%H%z";
break;
case 1:
date_fmt = "%Y-%m-%d";
break;
case 0:
default:
#endif
date_fmt = (opt & DATE_OPT_RFC2822 ?
/* Start with the default case */
date_fmt = (opt & DATE_OPT_RFC2822 ?
(utc ? "%a, %d %b %Y %H:%M:%S GMT" :
"%a, %d %b %Y %H:%M:%S %z") :
"%a %b %e %H:%M:%S %Z %Y");
#ifdef CONFIG_FEATURE_DATE_ISOFMT
break;
if (ENABLE_FEATURE_DATE_ISOFMT) {
if (ifmt == 4)
date_fmt = utc ? "%Y-%m-%dT%H:%M:%SZ" : "%Y-%m-%dT%H:%M:%S%z";
else if (ifmt == 3)
date_fmt = utc ? "%Y-%m-%dT%H:%MZ" : "%Y-%m-%dT%H:%M%z";
else if (ifmt == 2)
date_fmt = utc ? "%Y-%m-%dT%HZ" : "%Y-%m-%dT%H%z";
else if (ifmt == 1)
date_fmt = "%Y-%m-%d";
}
#endif
} else if (*date_fmt == '\0') {
/* Imitate what GNU 'date' does with NO format string! */
printf("\n");
return EXIT_SUCCESS;
}
if (*date_fmt == '\0') {
/* Handle special conversions */
/* With no format string, just print a blank line */
*bb_common_bufsiz1=0;
} else {
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = "%Y.%m.%d-%H:%M:%S";
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = "%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
strftime(bb_common_bufsiz1, 200, date_fmt, &tm_time);
}
/* Print OUTPUT (after ALL that!) */
t_buff = xmalloc(201);
strftime(t_buff, 200, date_fmt, &tm_time);
puts(t_buff);
puts(bb_common_bufsiz1);
return EXIT_SUCCESS;
}
+2 -2
View File
@@ -167,7 +167,7 @@ int dd_main(int argc, char **argv)
if (n == 0) {
break;
}
if (n == bs) {
if ((size_t)n == bs) {
in_full++;
} else {
in_part++;
@@ -180,7 +180,7 @@ int dd_main(int argc, char **argv)
if (n < 0) {
bb_perror_msg_and_die("%s", outfile);
}
if (n == bs) {
if ((size_t)n == bs) {
out_full++;
} else {
out_part++;
+5 -5
View File
@@ -46,7 +46,7 @@ static long kscale(long b, long bs)
}
#endif
extern int df_main(int argc, char **argv)
int df_main(int argc, char **argv)
{
long blocks_used;
long blocks_percent_used;
@@ -62,7 +62,7 @@ extern int df_main(int argc, char **argv)
const char *disp_units_hdr = hdr_1k;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_opt_complementaly = "h-km:k-hm:m-hk";
bb_opt_complementally = "h-km:k-hm:m-hk";
opt = bb_getopt_ulflags(argc, argv, "hmk");
if(opt & 1) {
df_disp_hr = 0;
@@ -130,13 +130,13 @@ extern int df_main(int argc, char **argv)
} else if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
if ((device = find_real_root_device_name()) == NULL) {
if ((device = find_block_device("/")) == NULL) {
goto SET_ERROR;
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_printf("%-21s%9s ", device,
bb_printf("%-20s %9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
bb_printf("%9s ",
@@ -147,7 +147,7 @@ extern int df_main(int argc, char **argv)
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
bb_printf("%-21s%9ld %9ld %9ld %3ld%% %s\n",
bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
+1 -1
View File
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include "busybox.h"
extern int dirname_main(int argc, char **argv)
int dirname_main(int argc, char **argv)
{
if (argc != 2) {
bb_show_usage();
+55 -133
View File
@@ -2,156 +2,83 @@
* dos2unix for BusyBox
*
* dos2unix '\n' convertor 0.5.0
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
* All rights reserved.
*
* dos2unix filters reading input from stdin and writing output to stdout.
* Without arguments it reverts the format (e.i. if source is in UNIX format,
* output is in DOS format and vice versa).
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* See the COPYING file for license information.
*/
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#include <string.h>
#include <getopt.h>
#include <unistd.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/time.h>
#include "busybox.h"
#define CT_AUTO 0
#define CT_UNIX2DOS 1
#define CT_DOS2UNIX 2
#define tempFn bb_common_bufsiz1
/* We are making a lame pseudo-random string generator here. in
* convert(), each pass through the while loop will add more and more
* stuff into value, which is _supposed_ to wrap. We don't care about
* it being accurate. We care about it being messy, since we then mod
* it by the sizeof(letters) and then use that as an index into letters
* to pick a random letter to add to out temporary file. */
typedef unsigned long int bb_uint64_t;
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// if fn is NULL then input is stdin and output is stdout
/* if fn is NULL then input is stdin and output is stdout */
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
char tempFn[BUFSIZ];
static bb_uint64_t value=0;
FILE *in = stdin, *out = stdout;
FILE *in, *out;
if (fn != NULL) {
in = bb_xfopen(fn, "rw");
safe_strncpy(tempFn, fn, sizeof(tempFn));
c = strlen(tempFn);
tempFn[c] = '.';
while(1) {
/* tempFn is BUFSIZ so the last addressable spot it BUFSIZ-1.
* The loop increments by 2. So this must check for BUFSIZ-3. */
if (c >=BUFSIZ-3)
bb_error_msg_and_die("unique name not found");
/* Get some semi random stuff to try and make a
* random filename based (and in the same dir as)
* the input file... */
gettimeofday (&tv, NULL);
value += ((bb_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
tempFn[++c] = letters[value % 62];
tempFn[c+1] = '\0';
value /= 62;
if ((fd = open(tempFn, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0 ) {
continue;
}
out = fdopen(fd, "w+");
if (!out) {
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
snprintf(tempFn, sizeof(tempFn), "%sXXXXXX", fn);
/*
sizeof tempFn is 4096, so it should be big enough to hold the full
path. however if the output is truncated the subsequent call to
mkstemp would fail.
*/
if ((fd = mkstemp(&tempFn[0])) == -1 || chmod(tempFn, 0600) == -1) {
bb_perror_nomsg_and_die();
}
out = fdopen(fd, "w+");
if (!out) {
close(fd);
remove(tempFn);
continue;
}
break;
}
} else {
in = stdin;
out = stdout;
}
while ((c = fgetc(in)) != EOF) {
if (c == '\r') {
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
// file is alredy in DOS format so it is not necessery to touch it
remove(tempFn);
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
return -2;
}
return 0;
}
if (!ConvType)
ConvType = CT_DOS2UNIX;
break;
}
if (c == '\r')
continue;
if (c == '\n') {
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
// file is alredy in UNIX format so it is not necessery to touch it
remove(tempFn);
if ((fclose(in) < 0) || (fclose(out) < 0)) {
bb_perror_nomsg();
return -2;
}
return 0;
}
if (!ConvType) {
ConvType = CT_UNIX2DOS;
}
if (ConvType == CT_UNIX2DOS) {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
}
fputc('\n', out);
break;
continue;
}
fputc(c, out);
}
if (c != EOF)
while ((c = fgetc(in)) != EOF) {
if (c == '\r')
continue;
if (c == '\n') {
if (ConvType == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(c, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
remove(tempFn);
return -2;
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
remove(tempFn);
return -2;
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
bb_perror_msg("unable to rename '%s' as '%s'", tempFn, fn);
return -1;
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(tempFn, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", tempFn, fn);
return -1;
}
}
@@ -160,30 +87,26 @@ static int convert(char *fn, int ConvType)
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int ConvType;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
/* See if we are supposed to be doing dos2unix or unix2dos */
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}
if (argv[0][0]=='u') {
ConvType = CT_UNIX2DOS;
ConvType = CT_DOS2UNIX; /*2*/
} else {
ConvType = CT_UNIX2DOS; /*1*/
}
/* -u and -d are mutally exclusive */
bb_opt_complementally = "?:u--d:d--u";
/* process parameters */
/* -u convert to unix */
/* -d convert to dos */
o = bb_getopt_ulflags(argc, argv, "du");
// process parameters
while ((o = getopt(argc, argv, "du")) != EOF) {
switch (o) {
case 'd':
ConvType = CT_UNIX2DOS;
break;
case 'u':
ConvType = CT_DOS2UNIX;
break;
default:
bb_show_usage();
}
}
/* Do the conversion requested by an argument else do the default
* conversion depending on our name. */
if (o)
ConvType = o;
if (optind < argc) {
while(optind < argc)
@@ -195,4 +118,3 @@ int dos2unix_main(int argc, char *argv[])
return o;
}
+3 -3
View File
@@ -56,7 +56,7 @@ static unsigned int disp_k; /* bss inits to 0 */
#endif
static int max_print_depth = INT_MAX;
static int count_hardlinks = 1;
static nlink_t count_hardlinks = 1;
static int status
#if EXIT_SUCCESS == 0
@@ -191,7 +191,7 @@ int du_main(int argc, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_opt_complementaly = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
bb_opt_complementally = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
if((opt & (1 << 9))) {
/* -h opt */
@@ -206,7 +206,7 @@ int du_main(int argc, char **argv)
disp_hr = KILOBYTE;
}
#else
bb_opt_complementaly = "H-L:L-H:s-d:d-s";
bb_opt_complementally = "H-L:L-H:s-d:d-s";
opt = bb_getopt_ulflags(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !defined CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
if((opt & (1 << 2))) {
+3 -139
View File
@@ -1,9 +1,5 @@
/* vi: set sw=4 ts=4: */
/*
* echo implementation for busybox
*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* echo applet implementation for busybox
*
* 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,20 +15,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Original copyright notice is retained at the end of this file.
*/
/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Because of behavioral differences, implemented configurable SUSv3
* or 'fancy' gnu-ish behaviors. Also, reduced size and fixed bugs.
* 1) In handling '\c' escape, the previous version only suppressed the
* trailing newline. SUSv3 specifies _no_ output after '\c'.
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
* The previous version version did not allow 4-digit octals.
*/
#include <stdio.h>
@@ -40,126 +22,8 @@
#include <stdlib.h>
#include "busybox.h"
extern int echo_main(int argc, char** argv)
int echo_main(int argc, char** argv)
{
#ifndef CONFIG_FEATURE_FANCY_ECHO
#define eflag '\\'
++argv;
#else
const char *p;
int nflag = 1;
int eflag = 0;
while (*++argv && (**argv == '-')) {
/* If it appears that we are handling options, then make sure
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
goto just_echo;
}
do {
if (strrchr("neE", *p) == 0) {
goto just_echo;
}
} while (*++p);
/* All of the options in this arg are valid, so handle them. */
p = *argv + 1;
do {
if (*p == 'n') {
nflag = 0;
} else if (*p == 'e') {
eflag = '\\';
} else {
eflag = 0;
}
} while (*++p);
}
just_echo:
#endif
while (*argv) {
register int c;
while ((c = *(*argv)++)) {
if (c == eflag) { /* Check for escape seq. */
if (**argv == 'c') {
/* '\c' means cancel newline and
* ignore all subsequent chars. */
goto DONE;
}
#ifndef CONFIG_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if (((unsigned int)(**argv - '1')) >= 7)
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if ((**argv == '0') && (((unsigned int)(argv[0][1] - '0')) < 8)) {
(*argv)++;
}
/* bb_process_escape_sequence can handle nul correctly */
c = bb_process_escape_sequence((const char **) argv);
}
}
putchar(c);
}
if (*++argv) {
putchar(' ');
}
}
#ifdef CONFIG_FEATURE_FANCY_ECHO
if (nflag) {
putchar('\n');
}
#else
putchar('\n');
#endif
DONE:
(void)bb_echo(argc, argv);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)echo.c 8.1 (Berkeley) 5/31/93
*/
+9 -10
View File
@@ -38,7 +38,7 @@
* - correct "-" option usage
* - multiple "-u unsetenv" support
* - GNU long option support
* - save errno after exec failed before bb_perror_msg()
* - use bb_default_error_retval
*/
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <getopt.h>
#include <getopt.h> /* struct option */
#include "busybox.h"
@@ -57,15 +57,16 @@ static const struct option env_long_options[] = {
{ 0, 0, 0, 0 }
};
extern int env_main(int argc, char** argv)
int env_main(int argc, char** argv)
{
static char *cleanenv[1] = { NULL };
char **ep, *p;
char *cleanenv[1] = { NULL };
unsigned long opt;
llist_t *unset_env = NULL;
extern char **environ;
bb_opt_complementaly = "u*";
bb_opt_complementally = "u::";
bb_applet_long_options = env_long_options;
opt = bb_getopt_ulflags(argc, argv, "+iu:", &unset_env);
@@ -93,12 +94,10 @@ extern int env_main(int argc, char** argv)
}
if (*argv) {
int er;
execvp(*argv, argv);
er = errno;
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
return (er == ENOENT) ? 127 : 126; /* SUSv3-mandated exit codes. */
/* SUSv3-mandated exit codes. */
bb_default_error_retval = (errno == ENOENT) ? 127 : 126;
bb_perror_msg_and_die("%s", *argv);
}
for (ep = environ; *ep; ep++) {
+49 -39
View File
@@ -7,7 +7,9 @@
*
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
* Aug 2003 Vladimir Oleynik - reduced 464 bytes.
* Copyright (C) 2003-2005 Vladimir Oleynik <dzo@simtreas.ru>
* - reduced 464 bytes.
* - 64 math support
*
* 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
@@ -52,11 +54,23 @@ enum valtype {
};
typedef enum valtype TYPE;
#if ENABLE_EXPR_MATH_SUPPORT_64
typedef int64_t arith_t;
#define PF_REZ "ll"
#define PF_REZ_TYPE (long long)
#define STRTOL(s, e, b) strtoll(s, e, b)
#else
typedef long arith_t;
#define PF_REZ "l"
#define PF_REZ_TYPE (long)
#define STRTOL(s, e, b) strtol(s, e, b)
#endif
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
int i;
TYPE type; /* Which kind. */
union { /* The value itself. */
arith_t i;
char *s;
} u;
};
@@ -67,7 +81,7 @@ static char **args;
static VALUE *docolon (VALUE *sv, VALUE *pv);
static VALUE *eval (void);
static VALUE *int_value (int i);
static VALUE *int_value (arith_t i);
static VALUE *str_value (char *s);
static int nextarg (char *str);
static int null (VALUE *v);
@@ -90,7 +104,7 @@ int expr_main (int argc, char **argv)
bb_error_msg_and_die ("syntax error");
if (v->type == integer)
printf ("%d\n", v->u.i);
printf ("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts (v->u.s);
@@ -99,7 +113,7 @@ int expr_main (int argc, char **argv)
/* Return a VALUE for I. */
static VALUE *int_value (int i)
static VALUE *int_value (arith_t i)
{
VALUE *v;
@@ -147,7 +161,7 @@ static int null (VALUE *v)
static void tostring (VALUE *v)
{
if (v->type == integer) {
bb_xasprintf (&(v->u.s), "%d", v->u.i);
v->u.s = bb_xasprintf ("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
v->type = string;
}
}
@@ -157,12 +171,12 @@ static void tostring (VALUE *v)
static int toarith (VALUE *v)
{
if(v->type == string) {
int i;
arith_t i;
char *e;
/* Don't interpret the empty string as an integer. */
/* Currently does not worry about overflow or int/long differences. */
i = (int) strtol(v->u.s, &e, 10);
i = STRTOL(v->u.s, &e, 10);
if ((v->u.s == e) || *e)
return 0;
free (v->u.s);
@@ -214,9 +228,9 @@ static int cmp_common (VALUE *l, VALUE *r, int op)
/* The arithmetic operator handling functions. */
static int arithmetic_common (VALUE *l, VALUE *r, int op)
static arith_t arithmetic_common (VALUE *l, VALUE *r, int op)
{
int li, ri;
arith_t li, ri;
if (!toarith (l) || !toarith (r))
bb_error_msg_and_die ("non-numeric argument");
@@ -245,10 +259,9 @@ static int arithmetic_common (VALUE *l, VALUE *r, int op)
static VALUE *docolon (VALUE *sv, VALUE *pv)
{
VALUE *v;
const char *errmsg;
struct re_pattern_buffer re_buffer;
struct re_registers re_regs;
int len;
regex_t re_buffer;
const int NMATCH = 2;
regmatch_t re_regs[NMATCH];
tostring (sv);
tostring (pv);
@@ -260,27 +273,22 @@ of a basic regular expression is not portable; it is being ignored",
pv->u.s);
}
len = strlen (pv->u.s);
memset (&re_buffer, 0, sizeof (re_buffer));
memset (&re_regs, 0, sizeof (re_regs));
re_buffer.allocated = 2 * len;
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
re_buffer.translate = 0;
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg) {
bb_error_msg_and_die("%s", errmsg);
}
memset (re_regs, 0, sizeof (*re_regs));
if( regcomp (&re_buffer, pv->u.s, 0) != 0 )
bb_error_msg_and_die("Invalid regular expression");
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (len >= 0) {
/* expr uses an anchored pattern match, so check that there was a
* match and that the match starts at offset 0. */
if (regexec (&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH &&
re_regs[0].rm_so == 0) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
sv->u.s[re_regs.end[1]] = '\0';
v = str_value (sv->u.s + re_regs.start[1]);
if (re_buffer.re_nsub > 0) {
sv->u.s[re_regs[1].rm_eo] = '\0';
v = str_value (sv->u.s + re_regs[1].rm_so);
}
else
v = int_value (len);
v = int_value (re_regs[0].rm_eo);
}
else {
/* Match failed -- return the right kind of null. */
@@ -289,7 +297,6 @@ of a basic regular expression is not portable; it is being ignored",
else
v = int_value (0);
}
free (re_buffer.buffer);
return v;
}
@@ -353,7 +360,7 @@ static VALUE *eval6 (void)
tostring (l);
tostring (r);
v = int_value (strcspn (l->u.s, r->u.s) + 1);
if (v->u.i == (int) strlen (l->u.s) + 1)
if (v->u.i == (arith_t) strlen (l->u.s) + 1)
v->u.i = 0;
freev (l);
freev (r);
@@ -366,13 +373,13 @@ static VALUE *eval6 (void)
i2 = eval6 ();
tostring (l);
if (!toarith (i1) || !toarith (i2)
|| i1->u.i > (int) strlen (l->u.s)
|| i1->u.i > (arith_t) strlen (l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value ("");
else {
v = xmalloc (sizeof(VALUE));
v->type = string;
v->u.s = bb_xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
v->u.s = bb_xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
}
freev (l);
freev (i1);
@@ -407,7 +414,8 @@ static VALUE *eval5 (void)
static VALUE *eval4 (void)
{
VALUE *l, *r;
int op, val;
int op;
arith_t val;
l = eval5 ();
while (1) {
@@ -433,7 +441,8 @@ static VALUE *eval4 (void)
static VALUE *eval3 (void)
{
VALUE *l, *r;
int op, val;
int op;
arith_t val;
l = eval4 ();
while (1) {
@@ -457,7 +466,8 @@ static VALUE *eval3 (void)
static VALUE *eval2 (void)
{
VALUE *l, *r;
int op, val;
int op;
arith_t val;
l = eval3 ();
while (1) {
Loaded 100 of 725 files, more files were not shown because too many files have changed in this diff. Show more