Index: Build
===================================================================
RCS file: Build
diff -N Build
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Build	28 Feb 2005 10:25:35 -0000	1.4
@@ -0,0 +1,14 @@
+#!/bin/sh 
+
+source ../../Config.sh
+
+pp_build_local () {
+    export LC_CTYPE=
+    rm -f applet_source_list
+    #jim
+    echo "$PREFIX"
+    make applet_source_list && make && make PREFIX="$DESTDIR" install
+    #make applet_source_list && make && make PREFIX="$DESTDIR" install-hardlinks
+}
+
+pp_do "$@"
Index: Config.h
===================================================================
RCS file: /srv/CVS/pplinux/busybox/Config.h,v
retrieving revision 1.1.304.1
retrieving revision 1.4
diff -u -r1.1.304.1 -r1.4
--- Config.h	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ Config.h	29 Apr 2005 08:43:27 -0000	1.4
@@ -10,14 +10,14 @@
 //#define BB_ADJTIMEX
 //#define BB_AR
 #define BB_ASH
-#define BB_BASENAME
+//#define BB_BASENAME
 #define BB_CAT
-#define BB_CHGRP
+//#define BB_CHGRP
 #define BB_CHMOD
 #define BB_CHOWN
-#define BB_CHROOT
-#define BB_CHVT
-#define BB_CLEAR
+//#define BB_CHROOT
+//#define BB_CHVT
+//#define BB_CLEAR
 //#define BB_CMP
 #define BB_CP
 //#define BB_CPIO
@@ -27,36 +27,36 @@
 #define BB_DD
 //#define BB_DEALLOCVT
 #define BB_DF
-#define BB_DIRNAME
+//#define BB_DIRNAME
 #define BB_DMESG
 //#define BB_DOS2UNIX
 //#define BB_DPKG
 //#define BB_DPKG_DEB
 //#define BB_DUTMP
-#define BB_DU
+//#define BB_DU
 //#define BB_DUMPKMAP
 #define BB_ECHO
-#define BB_ENV
+//#define BB_ENV
 //#define BB_EXPR
 //#define BB_FBSET
 //#define BB_FDFLUSH
-#define BB_FIND
+//#define BB_FIND
 #define BB_FREE
 //#define BB_FREERAMDISK
-//#define BB_FSCK_MINIX
+#define BB_FSCK_MINIX
 //#define BB_GETOPT
 #define BB_GREP
 #define BB_GUNZIP
 #define BB_GZIP
-#define BB_HALT
+//#define BB_HALT
 #define BB_HEAD
 //#define BB_HOSTID
-//#define BB_HOSTNAME
+#define BB_HOSTNAME
 //#define BB_HUSH
-#define BB_ID
+//#define BB_ID
 //#define BB_IFCONFIG
-#define BB_INIT
-//#define BB_INSMOD
+//#define BB_INIT
+#define BB_INSMOD
 #define BB_KILL
 #define BB_KILLALL
 #define BB_KLOGD
@@ -66,20 +66,20 @@
 //#define BB_LOADACM
 //#define BB_LOADFONT
 //#define BB_LOADKMAP
-#define BB_LOGGER
+//#define BB_LOGGER
 //#define BB_LOGNAME
 //#define BB_LOSETUP
 #define BB_LS
 #define BB_LSMOD
 //#define BB_MAKEDEVS
-//#define BB_MD5SUM
+#define BB_MD5SUM
 #define BB_MKDIR
 //#define BB_MKFIFO
-//#define BB_MKFS_MINIX
-#define BB_MKNOD
-#define BB_MKSWAP
+#define BB_MKFS_MINIX
+//#define BB_MKNOD
+//#define BB_MKSWAP
 //#define BB_MKTEMP
-#define BB_MODPROBE
+//#define BB_MODPROBE
 #define BB_MORE
 #define BB_MOUNT
 //#define BB_MSH
@@ -88,10 +88,10 @@
 //#define BB_NC
 //#define BB_NSLOOKUP
 #define BB_PIDOF
-//#define BB_PING
+#define BB_PING
 //#define BB_PIVOT_ROOT
-#define BB_POWEROFF
-//#define BB_PRINTF
+//#define BB_POWEROFF
+#define BB_PRINTF
 #define BB_PS
 #define BB_PWD
 //#define BB_RDATE
@@ -100,48 +100,49 @@
 //#define BB_RENICE
 #define BB_RESET
 #define BB_RM
-#define BB_RMDIR
-//#define BB_RMMOD
+//#define BB_RMDIR
+#define BB_RMMOD
 //#define BB_ROUTE
 //#define BB_RPM2CPIO
 #define BB_SED
 //#define BB_SETKEYCODES
 #define BB_SLEEP
-#define BB_SORT
+//#define BB_SORT
+#define BB_START_STOP_DAEMON
 //#define BB_STTY
-#define BB_SWAPONOFF
+//#define BB_SWAPONOFF
 #define BB_SYNC
 #define BB_SYSLOGD
 #define BB_TAIL
 #define BB_TAR
 //#define BB_TEE
-//#define BB_TEST
-//#define BB_TELNET
+#define BB_TEST
+#define BB_TELNET
 //#define BB_TFTP
-//#define BB_TIME
-//#define BB_TOP
-#define BB_TOUCH
-//#define BB_TR
+#define BB_TIME
+#define BB_TOP
+//#define BB_TOUCH
+#define BB_TR
 //#define BB_TRACEROUTE
 #define BB_TRUE_FALSE
-#define BB_TTY
+//#define BB_TTY
 //#define BB_UNIX2DOS
 //#define BB_UUENCODE
 //#define BB_UUDECODE
 #define BB_UMOUNT
-#define BB_UNIQ
+//#define BB_UNIQ
 #define BB_UNAME
 //#define BB_UPDATE
-#define BB_UPTIME
+//#define BB_UPTIME
 //#define BB_USLEEP
-//#define BB_VI
-//#define BB_WATCHDOG
-#define BB_WC
+#define BB_VI
+#define BB_WATCHDOG
+//#define BB_WC
 //#define BB_WGET
-#define BB_WHICH
-#define BB_WHOAMI
+//#define BB_WHICH
+//#define BB_WHOAMI
 #define BB_XARGS
-#define BB_YES
+//#define BB_YES
 // End of Applications List
 //
 //
@@ -182,7 +183,7 @@
 //#define BB_FEATURE_USE_DEVPS_PATCH
 //
 // show verbose usage messages
-#define BB_FEATURE_VERBOSE_USAGE
+//#define BB_FEATURE_VERBOSE_USAGE
 //
 // Use termios to manipulate the screen ('more' is prettier with this on)
 //#define BB_FEATURE_USE_TERMIOS
@@ -209,10 +210,10 @@
 #define BB_FEATURE_LS_FOLLOWLINKS
 //
 // Use color to identify different file types
-#define BB_FEATURE_LS_COLOR
+//#define BB_FEATURE_LS_COLOR
 //
 // Disable for a smaller (but less functional) ping
-#define BB_FEATURE_FANCY_PING
+//#define BB_FEATURE_FANCY_PING
 //
 // Make init use a simplified /etc/inittab file (recommended).
 #define BB_FEATURE_USE_INITTAB
@@ -227,7 +228,7 @@
 //#define BB_FEATURE_EXTRA_QUIET
 //
 // enable syslogd -R remotehost
-#define BB_FEATURE_REMOTE_LOG
+//#define BB_FEATURE_REMOTE_LOG
 //
 // enable syslogd -C
 //#define BB_FEATURE_IPC_SYSLOG
@@ -237,7 +238,7 @@
 #define BB_FEATURE_FANCY_TAIL
 //
 // Enable support for loop devices in mount
-#define BB_FEATURE_MOUNT_LOOP
+//#define BB_FEATURE_MOUNT_LOOP
 //
 // Enable support for a real /etc/mtab file instead of /proc/mounts
 //#define BB_FEATURE_MTAB_SUPPORT
@@ -248,7 +249,7 @@
 //
 // If you are using uClibc, be sure that you've already compiled
 // uClibc with INCLUDE_RPC=true (contained in the Config file)
-//#define BB_FEATURE_NFSMOUNT
+#define BB_FEATURE_NFSMOUNT
 //
 // Enable support forced filesystem unmounting 
 // (i.e., in case of an unreachable NFS system).
@@ -321,7 +322,7 @@
 //#define BB_FEATURE_OLD_MODULE_INTERFACE
 //
 // Support module version checking
-//#define BB_FEATURE_INSMOD_VERSION_CHECKING
+#define BB_FEATURE_INSMOD_VERSION_CHECKING
 //
 // Support for uClinux memory usage optimization, which will load the image
 // directly into the kernel memory.  This divides memory requrements by three.
@@ -330,10 +331,10 @@
 //#define BB_FEATURE_INSMOD_LOADINKMEM
 //
 // Support for Minix filesystem, version 2
-//#define BB_FEATURE_MINIX2
+#define BB_FEATURE_MINIX2
 //
 // Enable ifconfig status reporting output -- this feature adds 7k.
-//#define BB_FEATURE_IFCONFIG_STATUS
+#define BB_FEATURE_IFCONFIG_STATUS
 //
 // Enable ifconfig slip-specific options "keepalive" and "outfill"
 //#define BB_FEATURE_IFCONFIG_SLIP
@@ -342,7 +343,7 @@
 //#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
 //
 // Enable ifconfig option "hw".  Currently works for only with "ether".
-//#define BB_FEATURE_IFCONFIG_HW
+#define BB_FEATURE_IFCONFIG_HW
 //
 // Allows "broadcast +" to set broadcast automatically based on hostaddr
 // and netmask, at a cost of about 100 bytes of code (i386).
@@ -411,8 +412,14 @@
 //
 // End of Features List
 //
-//
-//
+
+// Enable additional features used for production firmware
+#ifdef PP_PRODUCTION
+#define BB_EXPR
+#define BB_DD
+#define BB_LOSETUP
+#define BB_FEATURE_MOUNT_LOOP
+#endif
 //
 //
 //
Index: Makefile
===================================================================
RCS file: /srv/CVS/pplinux/busybox/Makefile,v
retrieving revision 1.1.304.1
retrieving revision 1.5
diff -u -r1.1.304.1 -r1.5
--- Makefile	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ Makefile	4 May 2005 12:35:41 -0000	1.5
@@ -17,11 +17,25 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
+include ../../Config.mk
+
 PROG      := busybox
 VERSION   := 0.60.5
 BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
 export VERSION
 
+TARGET_ARCH:=${shell $(CC) -dumpmachine | sed -e s'/-.*//' \
+		-e 's/i.86/i386/' \
+		-e 's/sparc.*/sparc/' \
+		-e 's/arm.*/arm/g' \
+		-e 's/m68k.*/m68k/' \
+		-e 's/ppc/powerpc/g' \
+		-e 's/v850.*/v850/g' \
+		-e 's/sh[234]/sh/' \
+		-e 's/mips.*/mips/' \
+		}
+
+
 # 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:
@@ -30,7 +44,13 @@
 # If you want to add some simple compiler switches (like -march=i686),
 # especially from the command line, use this instead of CFLAGS directly.
 # For optimization overrides, it's better still to set OPTIMIZATION.
-CFLAGS_EXTRA =
+#CFLAGS_EXTRA = -Os -fomit-frame-pointer
+ifeq ($(strip $(TARGET_ARCH)),arm)
+CFLAGS_EXTRA = $(FW_CFLAGS_3RDPARTY) 
+else
+CFLAGS_EXTRA = $(FW_CFLAGS_3RDPARTY) -ffunction-sections -fdata-sections
+LDFLAGS += -Wl,-gc-sections
+endif
  
 # If you want a static binary, turn this on.
 DOSTATIC = false
@@ -83,10 +103,10 @@
 
 # If you are running a cross compiler, you may want to set this
 # to something more interesting, like "powerpc-linux-".
-CROSS =
-CC = $(CROSS)gcc
-AR = $(CROSS)ar
-STRIP = $(CROSS)strip
+#CROSS = powerpc-uclibc-
+#CC = $(CROSS)gcc
+#AR = $(CROSS)ar
+#STRIP = $(CROSS)strip
 
 # To compile vs uClibc, just use the compiler wrapper built by uClibc...
 # Everything should compile and work as expected these days...
@@ -115,24 +135,13 @@
 ARFLAGS = -r
 
 
-TARGET_ARCH:=${shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-		-e 's/i.86/i386/' \
-		-e 's/sparc.*/sparc/' \
-		-e 's/arm.*/arm/g' \
-		-e 's/m68k.*/m68k/' \
-		-e 's/ppc/powerpc/g' \
-		-e 's/v850.*/v850/g' \
-		-e 's/sh[234]/sh/' \
-		-e 's/mips.*/mips/' \
-		}
-
 #--------------------------------------------------------
 # Arch specific compiler optimization stuff should go here.
 # Unless you want to override the defaults, do not set anything
 # for OPTIMIZATION...
 
 # use '-Os' optimization if available, else use -O2
-OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+#OPTIMIZATION := ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
 	then echo "-Os"; else echo "-O2" ; fi}
 
 # Some nice architecture specific optimizations
@@ -149,7 +158,7 @@
 		if $(CC) -malign-functions=0 -malign-jumps=0 -S -o /dev/null -xc \
 		/dev/null >/dev/null 2>&1; then echo "-malign-functions=0 -malign-jumps=0"; fi; fi}
 endif
-OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer
+#OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-frame-pointer
 
 
 #--------------------------------------------------------
@@ -181,7 +190,7 @@
     LDFLAGS += -Wl,-warn-common
     STRIPCMD    = /bin/true -Since_we_are_debugging
 else
-    CFLAGS  += $(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE
+    CFLAGS  += $(WARNINGS) -D_GNU_SOURCE
     LDFLAGS += -s -Wl,-warn-common
     STRIPCMD    = $(STRIP) -s --remove-section=.note --remove-section=.comment
 endif
@@ -315,7 +324,7 @@
 all: applet_source_list busybox busybox.links doc
 
 applet_source_list: busybox.sh Config.h
-	(echo -n "APPLET_SOURCES := "; CC="$(CC)" BB_SRC_DIR="$(BB_SRC_DIR)" $(SHELL) $^) > $@
+	(echo -n "APPLET_SOURCES := "; CC="$(CC) $(FW_CFLAGS)" BB_SRC_DIR="$(BB_SRC_DIR)" $(SHELL) $^) > $@
 
 doc: olddoc
 
Index: applets.h
===================================================================
RCS file: /srv/CVS/pplinux/busybox/applets.h,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- applets.h	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ applets.h	3 Feb 2005 08:40:42 -0000	1.2
@@ -371,6 +371,9 @@
 #ifdef BB_SORT
 	APPLET(sort, sort_main, _BB_DIR_USR_BIN)
 #endif
+#ifdef BB_START_STOP_DAEMON
+	APPLET_ODDNAME("start-stop-daemon", start_stop_daemon_main, _BB_DIR_SBIN, start_stop_daemon)
+#endif
 #ifdef BB_STTY
 	APPLET(stty, stty_main, _BB_DIR_BIN)
 #endif
Index: ash.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/ash.c,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- ash.c	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ ash.c	3 Feb 2005 08:40:42 -0000	1.2
@@ -36,7 +36,7 @@
 /* This enables alias support in ash.  If you want to support things
  * like "alias ls='ls -l'" with ash, enable this.  This is only useful
  * when ash is used as an intractive shell.   This adds about 1.5k */
-#define CONFIG_ASH_ALIAS
+#undef CONFIG_ASH_ALIAS
 
 /* If you need ash to act as a full Posix shell, with full math
  * support, enable this.   This adds a bit over 2k an x86 system. */
Index: busybox.mkll
===================================================================
RCS file: /srv/CVS/pplinux/busybox/busybox.mkll,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- busybox.mkll	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ busybox.mkll	28 Feb 2005 09:09:16 -0000	1.3
@@ -7,14 +7,16 @@
 
 # Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
 
+source ../../Config.sh
+
 export LC_ALL=POSIX
 export LC_CTYPE=POSIX
 
 CONFIG_H=${1:-Config.h}
 APPLETS_H=${2:-applets.h}
-gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
+gcc -E $FW_CPPFLAGS_3RDPARTY -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
   awk '/^[ \t]*LINK/{
-	dir=substr($2,8)
+	dir="_BIN"
 	gsub("_","/",dir)
 	if(dir=="/ROOT") dir=""
 	file=$3
Index: busybox.sh
===================================================================
RCS file: /srv/CVS/pplinux/busybox/busybox.sh,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- busybox.sh	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ busybox.sh	23 Feb 2005 17:03:36 -0000	1.3
@@ -1,10 +1,12 @@
 #!/bin/sh
 
+source ../../Config.sh
+
 export LC_ALL=POSIX
 export LC_CTYPE=POSIX
 
 RAW=` \
-    $CC -E -dM ${1:-Config.h} | \
+    $CC $FW_CPPFLAGS_3RDPARTY -E -dM ${1:-Config.h} | \
     sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
     | tr A-Z a-z | sort
 `
@@ -13,4 +15,3 @@
 # By running $RAW through "ls", we avoid listing
 # source files that don't exist.
 ls $RAW 2>/dev/null | tr '\n' ' '
-
Index: insmod.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/insmod.c,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- insmod.c	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ insmod.c	29 Apr 2005 08:43:27 -0000	1.3
@@ -606,6 +606,7 @@
 				      ElfW(RelM) *rel, ElfW(Addr) value);
 
 static void arch_create_got (struct obj_file *f);
+static int obj_gpl_license(struct obj_file *f, const char **license);
 
 #ifdef BB_FEATURE_NEW_MODULE_INTERFACE
 static int arch_init_module (struct obj_file *f, struct new_module *);
@@ -1709,7 +1710,10 @@
 	struct new_module_symbol *s;
 	size_t i;
 	int used = 0;
+	int gpl;
 
+	gpl = obj_gpl_license(f, NULL) == 0;
+	
 	for (i = 0, s = syms; i < nsyms; ++i, ++s) {
 
 		/* Only add symbols that are already marked external.  If we
@@ -1717,6 +1721,19 @@
 		   We will also create a false dependency on the module.  */
 		struct obj_symbol *sym;
 
+		/* GPL licensed modules can use symbols exported with
+		 * EXPORT_SYMBOL_GPL, so ignore any GPLONLY_ prefix on the
+		 * exported names. Non-GPL modules never see any GPLONLY_
+		 * symbols so they cannot fudge it by adding the prefix on
+		 * their references.
+		 */
+  	  	if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) {
+		    if (gpl)
+			((char *)s->name) += 8;
+		    else
+ 	  	  	continue;
+		}
+		
 		sym = obj_find_symbol(f, (char *) s->name);
 		if (sym && !ELFW(ST_BIND) (sym->info) == STB_LOCAL) {
 			sym = obj_add_symbol(f, (char *) s->name, -1,
@@ -3367,15 +3384,19 @@
 {
 	char buf[80];
 	int oldval;
+#if 0
 	static int first = 1;
+#endif
 	if (fd < 0 && !kernel_has_tainted)
 		return;		/* New modutils on old kernel */
+#if 0
 	printf("Warning: loading %s will taint the kernel: %s%s\n",
 			m_name, text1, text2);
 	if (first) {
 		printf("  See %s for information about tainted modules\n", TAINT_URL);
 		first = 0;
 	}
+#endif
 	if (fd >= 0) {
 		read(fd, buf, sizeof(buf)-1);
 		buf[sizeof(buf)-1] = '\0';
Index: install.sh
===================================================================
RCS file: /srv/CVS/pplinux/busybox/install.sh,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- install.sh	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ install.sh	28 Feb 2005 10:25:35 -0000	1.3
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh 
 
 export LC_ALL=POSIX
 export LC_CTYPE=POSIX
Index: reboot.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/reboot.c,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- reboot.c	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ reboot.c	3 Feb 2005 08:40:42 -0000	1.2
@@ -102,7 +102,10 @@
 		return(kill(*pid, SIGTERM));
 	}
 #else
-	return(kill(1, SIGTERM));
+	sync();
+	init_reboot(RB_AUTOBOOT);
+	exit(0);
+	//return(kill(1, SIGTERM));
 #endif
 #endif
 }
Index: start_stop_daemon.c
===================================================================
RCS file: start_stop_daemon.c
diff -N start_stop_daemon.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ start_stop_daemon.c	3 Feb 2005 08:40:42 -0000	1.1
@@ -0,0 +1,270 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini start-stop-daemon implementation(s) for busybox
+ *
+ * Written by Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>,
+ * public domain.
+ * Adapted for busybox David Kimdon <dwhedon@gordian.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <signal.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+#include "busybox.h"
+
+static int start = 0;
+static int stop = 0;
+static int fork_before_exec = 0;
+static int signal_nr = 15;
+static int user_id = -1;
+static const char *userspec = NULL;
+static const char *cmdname = NULL;
+static char *execname = NULL;
+static char *startas = NULL;
+
+typedef struct pid_list {
+	struct pid_list *next;
+	int pid;
+} pid_list;
+
+static pid_list *found = NULL;
+
+static inline void
+push(int pid)
+{
+	pid_list *p;
+
+	p = xmalloc(sizeof(*p));
+	p->next = found;
+	p->pid = pid;
+	found = p;
+}
+
+
+static void
+parse_options(int argc, char * const *argv)
+{
+	
+	int c;
+
+	for (;;) {
+	    c = getopt (argc, argv, "a:n:s:u:x:KSb");
+		if (c == EOF)
+			break;
+		switch (c) {
+		case 'K':
+			stop = 1;
+			break;
+		case 'S':
+			start = 1;
+			break;
+		case 'a':
+			startas = optarg;
+			break;
+		case 'n':
+			cmdname = optarg;
+			break;
+		case 's':
+			if (sscanf(optarg, "%d", &signal_nr) != 1)
+				error_msg_and_die ("-s takes a numeric argument");
+			break;
+		case 'u':
+			userspec = optarg;
+			break;
+		case 'x':
+			execname = optarg;
+			break;
+		case 'b':
+			fork_before_exec = 1;
+			break;
+		default:
+			show_usage();
+		}
+	}
+
+	if (start == stop)
+		error_msg_and_die ("need one of -S or -K");
+
+	if (!execname && !userspec)
+		error_msg_and_die ("need at least one of -x or -u");
+
+	if (!startas)
+		startas = execname;
+
+	if (start && !startas)
+		error_msg_and_die ("-S needs -x or -a");
+}
+
+
+static int
+pid_is_exec(int pid, const char *exec)
+{
+	char buf[PATH_MAX];
+	FILE *fp;
+
+	sprintf(buf, "/proc/%d/cmdline", pid);
+	fp = fopen(buf, "r");
+	if (fp && fgets (buf, sizeof (buf), fp) ) {
+		fclose(fp);
+	    if (strncmp (buf, exec, strlen(exec)) == 0)
+		return 1;
+	}
+	return 0;
+}
+
+
+static int
+pid_is_user(int pid, int uid)
+{
+	struct stat sb;
+	char buf[32];
+
+	sprintf(buf, "/proc/%d", pid);
+	if (stat(buf, &sb) != 0)
+		return 0;
+	return (sb.st_uid == uid);
+}
+
+
+static int
+pid_is_cmd(int pid, const char *name)
+{
+	char buf[32];
+	FILE *f;
+	int c;
+
+	sprintf(buf, "/proc/%d/stat", pid);
+	f = fopen(buf, "r");
+	if (!f)
+		return 0;
+	while ((c = getc(f)) != EOF && c != '(')
+		;
+	if (c != '(') {
+		fclose(f);
+		return 0;
+	}
+	/* this hopefully handles command names containing ')' */
+	while ((c = getc(f)) != EOF && c == *name)
+		name++;
+	fclose(f);
+	return (c == ')' && *name == '\0');
+}
+
+
+static void
+check(int pid)
+{
+	if (execname && !pid_is_exec(pid, execname)) {
+		return;
+	}
+	if (userspec && !pid_is_user(pid, user_id)) {
+		return;
+	}
+	if (cmdname && !pid_is_cmd(pid, cmdname)) {
+		return;
+	}
+	push(pid);
+}
+
+
+
+static void
+do_procfs(void)
+{
+	DIR *procdir;
+	struct dirent *entry;
+	int foundany, pid;
+
+	procdir = opendir("/proc");
+	if (!procdir)
+		perror_msg_and_die ("opendir /proc");
+
+	foundany = 0;
+	while ((entry = readdir(procdir)) != NULL) {
+		if (sscanf(entry->d_name, "%d", &pid) != 1)
+			continue;
+		foundany++;
+		check(pid);
+	}
+	closedir(procdir);
+	if (!foundany)
+		error_msg_and_die ("nothing in /proc - not mounted?");
+}
+
+
+static void
+do_stop(void)
+{
+	char what[1024];
+	pid_list *p;
+	int killed = 0;
+
+	if (cmdname)
+		strcpy(what, cmdname);
+	else if (execname)
+		strcpy(what, execname);
+	else if (userspec)
+		sprintf(what, "process(es) owned by `%s'", userspec);
+	else
+		error_msg_and_die ("internal error, please report");
+
+	if (!found) {
+		printf("no %s found; none killed.\n", what);
+		return;
+	}
+	for (p = found; p; p = p->next) {
+		if (kill(p->pid, signal_nr) == 0) {
+			p->pid = -p->pid;
+			killed++;
+		} else {
+			perror_msg("warning: failed to kill %d:", p->pid);
+		}
+	}
+	if (killed) {
+		printf("stopped %s (pid", what);
+		for (p = found; p; p = p->next)
+			if(p->pid < 0)
+				printf(" %d", -p->pid);
+		printf(").\n");
+	}
+}
+
+
+int
+start_stop_daemon_main(int argc, char **argv)
+{
+	parse_options(argc, argv);
+	argc -= optind;
+	argv += optind;
+
+	if (userspec && sscanf(userspec, "%d", &user_id) != 1)
+		user_id = my_getpwnam(userspec);
+
+	do_procfs();
+
+	if (stop) {
+		do_stop();
+		return EXIT_SUCCESS;
+	}
+
+	if (found) {
+		printf("%s already running.\n%d\n", execname ,found->pid);
+		return EXIT_SUCCESS;
+	}
+	*--argv = startas;
+	if (fork_before_exec) {
+		if (daemon(0, 0) == -1)
+			perror_msg_and_die ("unable to fork");
+	}
+	setsid();
+	execv(startas, argv);
+	perror_msg_and_die ("unable to start %s", startas);
+}
+
Index: tar.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/tar.c,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- tar.c	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ tar.c	3 Feb 2005 08:40:42 -0000	1.2
@@ -129,7 +129,7 @@
 typedef struct TarInfo TarInfo;
 
 /* Local procedures to restore files from a tar file.  */
-static int readTarFile(int tarFd, int extractFlag, int listFlag, 
+static int readTarFile(int tarFd, int extractFlag, int listFlag, int sizeFlag, 
 		int tostdoutFlag, int verboseFlag, char** extractList,
 		char** excludeList);
 
@@ -162,6 +162,7 @@
 	int unzipFlag    = FALSE;
 #endif
 	int listFlag     = FALSE;
+	int sizeFlag     = FALSE;
 	int extractFlag  = FALSE;
 	int createFlag   = FALSE;
 	int verboseFlag  = FALSE;
@@ -184,9 +185,9 @@
 
 	while (
 #ifndef BB_FEATURE_TAR_EXCLUDE
-			(opt = getopt(argc, argv, "cxtzvOf:pC:"))
+			(opt = getopt(argc, argv, "cxtzvOf:pC:s"))
 #else
-			(opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
+			(opt = getopt_long(argc, argv, "cxtzvOf:X:pC:s", longopts, NULL))
 #endif
 			> 0) {
 		switch (opt) {
@@ -205,6 +206,11 @@
 					goto flagError;
 				listFlag = TRUE;
 				break;
+			case 's':
+				if (extractFlag == TRUE || createFlag == TRUE)
+					goto flagError;
+				sizeFlag = TRUE;
+				break;
 #ifdef BB_FEATURE_TAR_GZIP
 			case 'z':
 				unzipFlag = TRUE;
@@ -270,7 +276,7 @@
 		status = writeTarFile(tarName, verboseFlag, argv + optind, excludeList);
 #endif
 	}
-	if (listFlag == TRUE || extractFlag == TRUE) {
+	if (listFlag == TRUE || sizeFlag == TRUE || extractFlag == TRUE) {
 		int tarFd;
 		if (argv[optind])
 			extractList = argv + optind;
@@ -295,7 +301,7 @@
 			}
 		}
 #endif			
-		status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
+		status = readTarFile(tarFd, extractFlag, listFlag, sizeFlag, tostdoutFlag,
 					verboseFlag, extractList, excludeList);
 		close(tarFd);
 #ifdef BB_FEATURE_TAR_GZIP	
@@ -581,13 +587,14 @@
  * Read a tar file and extract or list the specified files within it.
  * If the list is empty than all files are extracted or listed.
  */
-static int readTarFile(int tarFd, int extractFlag, int listFlag, 
+static int readTarFile(int tarFd, int extractFlag, int listFlag, int sizeFlag,
 		int tostdoutFlag, int verboseFlag, char** extractList,
 		char** excludeList)
 {
 	int status;
 	int errorFlag=FALSE;
 	int skipNextHeaderFlag=FALSE;
+	int size = 0;
 	TarHeader rawHeader;
 	TarInfo header;
 
@@ -696,6 +703,10 @@
 			printf("\n");
 		}
 
+		if (sizeFlag == TRUE) {
+		    size += (long)header.size;
+		}
+
 		/* List contents if we are supposed to do that */
 		if (verboseFlag == TRUE && extractFlag == TRUE) {
 			/* Now the normal listing */
@@ -767,6 +778,9 @@
 	/* Stuff to do when we are done */
 endgame:
 	close( tarFd);
+	if (sizeFlag == TRUE) {
+	    printf("%u\n", size);
+	}
 	if ( *(header.name) == '\0' ) {
 		if (errorFlag==TRUE)
 			error_msg( "Error exit delayed from previous errors");
Index: usage.h
===================================================================
RCS file: /srv/CVS/pplinux/busybox/usage.h,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- usage.h	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ usage.h	3 Feb 2005 08:40:42 -0000	1.2
@@ -1510,6 +1510,20 @@
 	"e\n" \
 	"f\n"
 
+#define start_stop_daemon_trivial_usage \
+	"[OPTIONS]"
+#define start_stop_daemon_full_usage \
+	"Program to start and stop services.\n"\
+	"Options:\n" \
+	"-S\t\t\tstart\n"\
+	"-K\t\t\tstop\n"\
+	"-b\t\t\tforce process into background (daemonize)\n"\
+	"-x <executable>\t\tprogram to start/check if it is running\n"\
+	"-u <username>|<uid>\tstop this user's processes\n"\
+	"-n <process-name>\tstop processes with this name\n"\
+	"-s <signal>\t\tsignal to send (default 15)\n"\
+	"-a <pathname>\t\tprogram to start (default <executable>)\n"
+
 #define stty_trivial_usage \
 	"[-a|g] [-F DEVICE] [SETTING]..."
 #define stty_full_usage \
@@ -1599,7 +1613,7 @@
   #define USAGE_TAR_EXCLUDE(a)
 #endif
 #define tar_trivial_usage \
-	"-[" USAGE_TAR_CREATE("c") "xtvO] " \
+	"-[" USAGE_TAR_CREATE("c") "xtsvO] " \
 	USAGE_TAR_EXCLUDE("[--exclude FILE] [-X FILE]") \
 	"[-f TARFILE] [-C DIR] [FILE(s)] ..."
 #define tar_full_usage \
@@ -1608,6 +1622,7 @@
 	USAGE_TAR_CREATE("\tc\t\tcreate\n") \
 	"\tx\t\textract\n" \
 	"\tt\t\tlist\n" \
+	"\ts\t\tuncompressed size\n" \
 	"\nFile selection:\n" \
 	"\tf\t\tname of TARFILE or \"-\" for stdin\n" \
 	"\tO\t\textract to stdout\n" \
Index: watchdog.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/watchdog.c,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- watchdog.c	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ watchdog.c	23 Feb 2005 17:03:36 -0000	1.3
@@ -26,22 +26,37 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <stdlib.h>
+#include <sys/ioctl.h>
+#include <linux/types.h>
+#include <linux/watchdog.h>
 #include "busybox.h"
 
 extern int watchdog_main(int argc, char **argv)
 {
 	int fd;
+	unsigned long wdt_timeout;
 
 	if (argc != 2) {
 		show_usage();
 	}
 
+	if (nice(-19) == -1) {
+		/* just report - we do not exit since it's not so critical */
+		perror_msg(argv[1]);
+	}
+
 	if ((fd=open(argv[1], O_WRONLY)) == -1) {
 		perror_msg_and_die(argv[1]);
 	}
 
+	wdt_timeout = 6000000; /* set watchdog timeout to 6 seconds */
+	if (ioctl(fd, WDIOC_SETTIMEOUT, &wdt_timeout) == -1) {
+		printf("settimeout (%x) failed\n", WDIOC_SETTIMEOUT);
+		perror_msg_and_die(argv[1]);
+	}
+
 	while (1) {
-		sleep(30);
+		sleep(1);
 		write(fd, "\0", 1);
 	}
 
Index: libbb/Makefile
===================================================================
RCS file: /srv/CVS/pplinux/busybox/libbb/Makefile,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- libbb/Makefile	3 Feb 2005 08:22:47 -0000	1.1.304.1
+++ libbb/Makefile	23 Feb 2005 17:03:36 -0000	1.3
@@ -2,6 +2,8 @@
 # busybox, it is just to make working on libbb more conveinient.
 #  -Erik Andersen
 
+include ../../../Config.mk
+
 all:
 	make -C .. libbb.a
 
Index: libbb/find_pid_by_name.c
===================================================================
RCS file: /srv/CVS/pplinux/busybox/libbb/find_pid_by_name.c,v
retrieving revision 1.1.304.1
retrieving revision 1.2
diff -u -r1.1.304.1 -r1.2
--- libbb/find_pid_by_name.c	3 Feb 2005 08:22:47 -0000	1.1.304.1
+++ libbb/find_pid_by_name.c	7 Apr 2005 07:17:00 -0000	1.2
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include "libbb.h"
 
-#define READ_BUF_SIZE	50
+#define READ_BUF_SIZE	128
 
 
 /* For Erik's nifty devps device driver */
@@ -130,10 +130,9 @@
 		perror_msg_and_die("Cannot open /proc");
 	
 	while ((next = readdir(dir)) != NULL) {
-		FILE *status;
+		FILE *cmdline;
 		char filename[READ_BUF_SIZE];
 		char buffer[READ_BUF_SIZE];
-		char name[READ_BUF_SIZE];
 
 		/* Must skip ".." since that is outside /proc */
 		if (strcmp(next->d_name, "..") == 0)
@@ -143,19 +142,17 @@
 		if (!isdigit(*next->d_name))
 			continue;
 
-		sprintf(filename, "/proc/%s/status", next->d_name);
-		if (! (status = fopen(filename, "r")) ) {
+		sprintf(filename, "/proc/%s/cmdline", next->d_name);
+		if (! (cmdline = fopen(filename, "r")) ) {
 			continue;
 		}
-		if (fgets(buffer, READ_BUF_SIZE-1, status) == NULL) {
-			fclose(status);
+		if (fgets(buffer, READ_BUF_SIZE-1, cmdline) == NULL) {
+			fclose(cmdline);
 			continue;
 		}
-		fclose(status);
+		fclose(cmdline);
 
-		/* Buffer should contain a string like "Name:   binary_name" */
-		sscanf(buffer, "%*s %s", name);
-		if (strcmp(name, pidName) == 0) {
+		if ((!strchr(pidName, '/') && !strcmp(basename(buffer), basename(pidName))) || !strcmp(buffer, pidName)) {
 			pidList=xrealloc( pidList, sizeof(long) * (i+2));
 			pidList[i++]=strtol(next->d_name, NULL, 0);
 		}
Index: tests/Makefile
===================================================================
RCS file: /srv/CVS/pplinux/busybox/tests/Makefile,v
retrieving revision 1.1.304.1
retrieving revision 1.3
diff -u -r1.1.304.1 -r1.3
--- tests/Makefile	3 Feb 2005 08:22:46 -0000	1.1.304.1
+++ tests/Makefile	23 Feb 2005 17:03:36 -0000	1.3
@@ -2,6 +2,8 @@
 # ------------------------
 # Copyright (C) 2000  Karl M. Hegbloom <karlheg@debian.org>  GPL
 
+include ../../../Config.mk
+
 all:: message_header
 
 message_header:
