summaryrefslogtreecommitdiff
path: root/busybox
diff options
context:
space:
mode:
Diffstat (limited to 'busybox')
-rw-r--r--busybox/busybox-1.00/hdparm_M.patch47
-rw-r--r--busybox/busybox-1.00/openslug/defconfig474
-rw-r--r--busybox/busybox-1.00/udhcppidfile.patch276
-rw-r--r--busybox/switchbox-1.00/switchbox.patch38
4 files changed, 835 insertions, 0 deletions
diff --git a/busybox/busybox-1.00/hdparm_M.patch b/busybox/busybox-1.00/hdparm_M.patch
index e69de29bb2..170906535e 100644
--- a/busybox/busybox-1.00/hdparm_M.patch
+++ b/busybox/busybox-1.00/hdparm_M.patch
@@ -0,0 +1,47 @@
+diff -Naur busybox-1.00/miscutils/hdparm.c busybox-1.00-patched/miscutils/hdparm.c
+--- busybox-1.00/miscutils/hdparm.c 2004-07-21 00:53:59.000000000 +0200
++++ busybox-1.00-patched/miscutils/hdparm.c 2004-10-21 15:17:13.000000000 +0200
+@@ -1254,6 +1254,7 @@
+ static unsigned long set_sleepnow = 0, get_sleepnow = 0;
+ static unsigned long get_powermode = 0;
+ static unsigned long set_apmmode = 0, get_apmmode= 0, apmmode = 0;
++static unsigned long set_acoustic = 0, get_acoustic = 0, acoustic = 0;
+ #endif
+ #ifdef CONFIG_FEATURE_HDPARM_GET_IDENTITY
+ static int get_IDentity = 0;
+@@ -2123,6 +2124,20 @@
+ }
+ bb_ioctl(fd, HDIO_DRIVE_CMD, &args,"HDIO_DRIVE_CMD");
+ }
++ if (set_acoustic)
++ {
++ no_scsi();
++ acoustic=check_if_min_and_set_val(acoustic,0);
++ acoustic=check_if_maj_and_set_val(acoustic,254);
++ if_printf(get_acoustic," setting AAM level to 0x%02lX (%ld)\n", acoustic, acoustic);
++ bb_ioctl(fd, HDIO_SET_ACOUSTIC, (int*)acoustic,"HDIO_SET_ACOUSTIC");
++ }
++ if (get_acoustic)
++ {
++ no_scsi();
++ bb_ioctl(fd, HDIO_GET_ACOUSTIC, (unsigned long*)&parm,"HDIO_GET_ACOUSTIC");
++ printf(" acoustic = %2ld (128=quiet ... 254=fast)\n", parm);
++ }
+ if (set_wcache)
+ {
+ #ifdef DO_FLUSHCACHE
+@@ -2831,6 +2846,13 @@
+ p = *argv++, --argc;
+ p=GET_NUMBER(p,&set_readahead,&Xreadahead);
+ break;
++ case 'M':
++ get_acoustic = noisy;
++ noisy = 1;
++ if (!*p && argc && isalnum(**argv))
++ p = *argv++, --argc;
++ p=GET_NUMBER(p,&set_acoustic,&acoustic);
++ break;
+ case 'B':
+ get_apmmode = noisy;
+ noisy = 1;
+
diff --git a/busybox/busybox-1.00/openslug/defconfig b/busybox/busybox-1.00/openslug/defconfig
index e69de29bb2..881184593b 100644
--- a/busybox/busybox-1.00/openslug/defconfig
+++ b/busybox/busybox-1.00/openslug/defconfig
@@ -0,0 +1,474 @@
+#
+# Automatically generated make config: don't edit
+#
+HAVE_DOT_CONFIG=y
+
+#
+# General Configuration
+#
+# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
+CONFIG_FEATURE_BUFFERS_GO_ON_STACK=y
+# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
+CONFIG_FEATURE_VERBOSE_USAGE=y
+# CONFIG_FEATURE_INSTALLER is not set
+# CONFIG_LOCALE_SUPPORT is not set
+CONFIG_FEATURE_DEVFS=y
+CONFIG_FEATURE_DEVPTS=y
+# CONFIG_FEATURE_CLEAN_UP is not set
+# CONFIG_FEATURE_SUID is not set
+# CONFIG_SELINUX is not set
+
+#
+# Build Options
+#
+# CONFIG_STATIC is not set
+CONFIG_LFS=y
+# USING_CROSS_COMPILER is not set
+EXTRA_CFLAGS_OPTIONS=""
+
+#
+# Installation Options
+#
+# CONFIG_INSTALL_NO_USR is not set
+PREFIX="./_install"
+
+#
+# Archival Utilities
+#
+CONFIG_AR=y
+# CONFIG_FEATURE_AR_LONG_FILENAMES is not set
+CONFIG_BUNZIP2=y
+CONFIG_CPIO=y
+# CONFIG_DPKG is not set
+# CONFIG_DPKG_DEB is not set
+CONFIG_GUNZIP=y
+# CONFIG_FEATURE_GUNZIP_UNCOMPRESS is not set
+CONFIG_GZIP=y
+# CONFIG_RPM2CPIO is not set
+# CONFIG_RPM is not set
+CONFIG_TAR=y
+CONFIG_FEATURE_TAR_CREATE=y
+CONFIG_FEATURE_TAR_BZIP2=y
+CONFIG_FEATURE_TAR_FROM=y
+CONFIG_FEATURE_TAR_GZIP=y
+# CONFIG_FEATURE_TAR_COMPRESS is not set
+CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY=y
+CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
+# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set
+# CONFIG_UNCOMPRESS is not set
+CONFIG_UNZIP=y
+
+#
+# Common options for cpio and tar
+#
+# CONFIG_FEATURE_UNARCHIVE_TAPE is not set
+
+#
+# Coreutils
+#
+CONFIG_BASENAME=y
+# CONFIG_CAL is not set
+CONFIG_CAT=y
+CONFIG_CHGRP=y
+CONFIG_CHMOD=y
+CONFIG_CHOWN=y
+CONFIG_CHROOT=y
+# CONFIG_CMP is not set
+CONFIG_CP=y
+CONFIG_CUT=y
+CONFIG_DATE=y
+
+#
+# date (forced enabled for use with watch)
+#
+# CONFIG_FEATURE_DATE_ISOFMT is not set
+CONFIG_DD=y
+CONFIG_DF=y
+CONFIG_DIRNAME=y
+# CONFIG_DOS2UNIX is not set
+CONFIG_DU=y
+CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K=y
+CONFIG_ECHO=y
+CONFIG_FEATURE_FANCY_ECHO=y
+CONFIG_ENV=y
+CONFIG_EXPR=y
+CONFIG_FALSE=y
+# CONFIG_FOLD is not set
+CONFIG_HEAD=y
+# CONFIG_FEATURE_FANCY_HEAD is not set
+# CONFIG_HOSTID is not set
+CONFIG_ID=y
+# CONFIG_INSTALL is not set
+# CONFIG_LENGTH is not set
+CONFIG_LN=y
+CONFIG_LOGNAME=y
+CONFIG_LS=y
+CONFIG_FEATURE_LS_FILETYPES=y
+CONFIG_FEATURE_LS_FOLLOWLINKS=y
+CONFIG_FEATURE_LS_RECURSIVE=y
+CONFIG_FEATURE_LS_SORTFILES=y
+CONFIG_FEATURE_LS_TIMESTAMPS=y
+CONFIG_FEATURE_LS_USERNAME=y
+CONFIG_FEATURE_LS_COLOR=y
+CONFIG_MD5SUM=y
+CONFIG_MKDIR=y
+CONFIG_MKFIFO=y
+CONFIG_MKNOD=y
+CONFIG_MV=y
+CONFIG_OD=y
+CONFIG_PRINTF=y
+CONFIG_PWD=y
+# CONFIG_REALPATH is not set
+CONFIG_RM=y
+CONFIG_RMDIR=y
+CONFIG_SEQ=y
+# CONFIG_SHA1SUM is not set
+CONFIG_SLEEP=y
+# CONFIG_FEATURE_FANCY_SLEEP is not set
+CONFIG_SORT=y
+CONFIG_STTY=y
+CONFIG_SYNC=y
+CONFIG_TAIL=y
+CONFIG_FEATURE_FANCY_TAIL=y
+CONFIG_TEE=y
+# CONFIG_FEATURE_TEE_USE_BLOCK_IO is not set
+CONFIG_TEST=y
+
+#
+# test (forced enabled for use with shell)
+#
+# CONFIG_FEATURE_TEST_64 is not set
+CONFIG_TOUCH=y
+CONFIG_TR=y
+CONFIG_TRUE=y
+CONFIG_TTY=y
+CONFIG_UNAME=y
+CONFIG_UNIQ=y
+# CONFIG_USLEEP is not set
+# CONFIG_UUDECODE is not set
+# CONFIG_UUENCODE is not set
+CONFIG_WATCH=y
+CONFIG_WC=y
+CONFIG_WHO=y
+CONFIG_WHOAMI=y
+CONFIG_YES=y
+
+#
+# Common options for cp and mv
+#
+# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set
+
+#
+# Common options for ls and more
+#
+CONFIG_FEATURE_AUTOWIDTH=y
+
+#
+# Common options for df, du, ls
+#
+CONFIG_FEATURE_HUMAN_READABLE=y
+
+#
+# Common options for md5sum, sha1sum
+#
+# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set
+
+#
+# Console Utilities
+#
+CONFIG_CHVT=y
+CONFIG_CLEAR=y
+CONFIG_DEALLOCVT=y
+CONFIG_DUMPKMAP=y
+CONFIG_GETKEY=y
+CONFIG_LOADFONT=y
+CONFIG_LOADKMAP=y
+CONFIG_OPENVT=y
+CONFIG_RESET=y
+# CONFIG_SETKEYCODES is not set
+
+#
+# Debian Utilities
+#
+CONFIG_MKTEMP=y
+# CONFIG_PIPE_PROGRESS is not set
+CONFIG_READLINK=y
+CONFIG_RUN_PARTS=y
+CONFIG_START_STOP_DAEMON=y
+CONFIG_WHICH=y
+
+#
+# Editors
+#
+CONFIG_AWK=y
+CONFIG_FEATURE_AWK_MATH=y
+# CONFIG_PATCH is not set
+CONFIG_SED=y
+CONFIG_VI=y
+CONFIG_FEATURE_VI_COLON=y
+CONFIG_FEATURE_VI_YANKMARK=y
+CONFIG_FEATURE_VI_SEARCH=y
+CONFIG_FEATURE_VI_USE_SIGNALS=y
+# CONFIG_FEATURE_VI_DOT_CMD is not set
+# CONFIG_FEATURE_VI_READONLY is not set
+# CONFIG_FEATURE_VI_SETOPTS is not set
+# CONFIG_FEATURE_VI_SET is not set
+CONFIG_FEATURE_VI_WIN_RESIZE=y
+CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
+
+#
+# Finding Utilities
+#
+CONFIG_FIND=y
+CONFIG_FEATURE_FIND_MTIME=y
+CONFIG_FEATURE_FIND_PERM=y
+CONFIG_FEATURE_FIND_TYPE=y
+CONFIG_FEATURE_FIND_XDEV=y
+CONFIG_FEATURE_FIND_NEWER=y
+# CONFIG_FEATURE_FIND_INUM is not set
+CONFIG_GREP=y
+CONFIG_FEATURE_GREP_EGREP_ALIAS=y
+CONFIG_FEATURE_GREP_FGREP_ALIAS=y
+CONFIG_FEATURE_GREP_CONTEXT=y
+CONFIG_XARGS=y
+# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_QUOTES is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT is not set
+# CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM is not set
+
+#
+# Init Utilities
+#
+# CONFIG_INIT is not set
+# CONFIG_HALT is not set
+# CONFIG_POWEROFF is not set
+# CONFIG_REBOOT is not set
+# CONFIG_MESG is not set
+
+#
+# Login/Password Management Utilities
+#
+# CONFIG_USE_BB_PWD_GRP is not set
+# CONFIG_ADDGROUP is not set
+# CONFIG_DELGROUP is not set
+# CONFIG_ADDUSER is not set
+# CONFIG_DELUSER is not set
+# CONFIG_GETTY is not set
+CONFIG_FEATURE_U_W_TMP=y
+# CONFIG_LOGIN is not set
+# CONFIG_PASSWD is not set
+# CONFIG_SU is not set
+# CONFIG_SULOGIN is not set
+# CONFIG_VLOCK is not set
+
+#
+# Miscellaneous Utilities
+#
+# CONFIG_ADJTIMEX is not set
+# CONFIG_CROND is not set
+# CONFIG_CRONTAB is not set
+CONFIG_DC=y
+# CONFIG_DEVFSD is not set
+# CONFIG_LAST is not set
+# CONFIG_HDPARM is not set
+# CONFIG_MAKEDEVS is not set
+# CONFIG_MT is not set
+# CONFIG_RX is not set
+CONFIG_STRINGS=y
+CONFIG_TIME=y
+# CONFIG_WATCHDOG is not set
+
+#
+# Linux Module Utilities
+#
+CONFIG_INSMOD=y
+CONFIG_FEATURE_2_4_MODULES=y
+CONFIG_FEATURE_2_6_MODULES=y
+# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
+CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y
+# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
+CONFIG_FEATURE_INSMOD_LOAD_MAP=y
+CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL=y
+CONFIG_LSMOD=y
+CONFIG_MODPROBE=y
+CONFIG_RMMOD=y
+CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
+
+#
+# Networking Utilities
+#
+CONFIG_FEATURE_IPV6=y
+# CONFIG_ARPING is not set
+# CONFIG_FTPGET is not set
+# CONFIG_FTPPUT is not set
+CONFIG_HOSTNAME=y
+# CONFIG_HTTPD is not set
+CONFIG_IFCONFIG=y
+CONFIG_FEATURE_IFCONFIG_STATUS=y
+# CONFIG_FEATURE_IFCONFIG_SLIP is not set
+# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
+CONFIG_FEATURE_IFCONFIG_HW=y
+# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
+CONFIG_IFUPDOWN=y
+# CONFIG_FEATURE_IFUPDOWN_IP is not set
+CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN=y
+CONFIG_FEATURE_IFUPDOWN_IPV4=y
+CONFIG_FEATURE_IFUPDOWN_IPV6=y
+# CONFIG_FEATURE_IFUPDOWN_IPX is not set
+# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
+# CONFIG_INETD is not set
+CONFIG_IP=y
+CONFIG_FEATURE_IP_ADDRESS=y
+CONFIG_FEATURE_IP_LINK=y
+CONFIG_FEATURE_IP_ROUTE=y
+CONFIG_FEATURE_IP_TUNNEL=y
+# CONFIG_IPCALC is not set
+# CONFIG_IPADDR is not set
+# CONFIG_IPLINK is not set
+# CONFIG_IPROUTE is not set
+# CONFIG_IPTUNNEL is not set
+# CONFIG_NAMEIF is not set
+CONFIG_NC=y
+CONFIG_NETSTAT=y
+CONFIG_NSLOOKUP=y
+CONFIG_PING=y
+CONFIG_FEATURE_FANCY_PING=y
+CONFIG_PING6=y
+CONFIG_FEATURE_FANCY_PING6=y
+CONFIG_ROUTE=y
+CONFIG_TELNET=y
+# CONFIG_FEATURE_TELNET_TTYPE is not set
+CONFIG_FEATURE_TELNET_AUTOLOGIN=y
+# CONFIG_TELNETD is not set
+CONFIG_TFTP=y
+CONFIG_FEATURE_TFTP_GET=y
+CONFIG_FEATURE_TFTP_PUT=y
+# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set
+# CONFIG_FEATURE_TFTP_DEBUG is not set
+CONFIG_TRACEROUTE=y
+# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
+# CONFIG_VCONFIG is not set
+CONFIG_WGET=y
+CONFIG_FEATURE_WGET_STATUSBAR=y
+CONFIG_FEATURE_WGET_AUTHENTICATION=y
+CONFIG_FEATURE_WGET_IP6_LITERAL=y
+
+#
+# udhcp Server/Client
+#
+# CONFIG_UDHCPD is not set
+CONFIG_UDHCPC=y
+CONFIG_FEATURE_UDHCP_SYSLOG=y
+# CONFIG_FEATURE_UDHCP_DEBUG is not set
+
+#
+# Process Utilities
+#
+CONFIG_FREE=y
+CONFIG_KILL=y
+CONFIG_KILLALL=y
+CONFIG_PIDOF=y
+CONFIG_PS=y
+CONFIG_RENICE=y
+CONFIG_TOP=y
+FEATURE_CPU_USAGE_PERCENTAGE=y
+CONFIG_UPTIME=y
+# CONFIG_SYSCTL is not set
+
+#
+# Another Bourne-like Shell
+#
+CONFIG_FEATURE_SH_IS_ASH=y
+# CONFIG_FEATURE_SH_IS_HUSH is not set
+# CONFIG_FEATURE_SH_IS_LASH is not set
+# CONFIG_FEATURE_SH_IS_MSH is not set
+# CONFIG_FEATURE_SH_IS_NONE is not set
+CONFIG_ASH=y
+
+#
+# Ash Shell Options
+#
+CONFIG_ASH_JOB_CONTROL=y
+CONFIG_ASH_ALIAS=y
+CONFIG_ASH_MATH_SUPPORT=y
+# CONFIG_ASH_MATH_SUPPORT_64 is not set
+CONFIG_ASH_GETOPTS=y
+# CONFIG_ASH_CMDCMD is not set
+# CONFIG_ASH_MAIL is not set
+CONFIG_ASH_OPTIMIZE_FOR_SIZE=y
+# CONFIG_ASH_RANDOM_SUPPORT is not set
+# CONFIG_HUSH is not set
+# CONFIG_LASH is not set
+# CONFIG_MSH is not set
+
+#
+# Bourne Shell Options
+#
+CONFIG_FEATURE_SH_EXTRA_QUIET=y
+# CONFIG_FEATURE_SH_STANDALONE_SHELL is not set
+CONFIG_FEATURE_COMMAND_EDITING=y
+CONFIG_FEATURE_COMMAND_HISTORY=63
+# CONFIG_FEATURE_COMMAND_SAVEHISTORY is not set
+CONFIG_FEATURE_COMMAND_TAB_COMPLETION=y
+# CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION is not set
+CONFIG_FEATURE_SH_FANCY_PROMPT=y
+
+#
+# System Logging Utilities
+#
+CONFIG_SYSLOGD=y
+# CONFIG_FEATURE_ROTATE_LOGFILE is not set
+CONFIG_FEATURE_REMOTE_LOG=y
+CONFIG_FEATURE_IPC_SYSLOG=y
+CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
+CONFIG_LOGREAD=y
+# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
+CONFIG_KLOGD=y
+CONFIG_LOGGER=y
+
+#
+# Linux System Utilities
+#
+CONFIG_DMESG=y
+CONFIG_FBSET=y
+CONFIG_FEATURE_FBSET_FANCY=y
+# CONFIG_FEATURE_FBSET_READMODE is not set
+# CONFIG_FDFLUSH is not set
+# CONFIG_FDFORMAT is not set
+CONFIG_FDISK=y
+FDISK_SUPPORT_LARGE_DISKS=y
+CONFIG_FEATURE_FDISK_WRITABLE=y
+# CONFIG_FEATURE_AIX_LABEL is not set
+# CONFIG_FEATURE_SGI_LABEL is not set
+# CONFIG_FEATURE_SUN_LABEL is not set
+# CONFIG_FEATURE_OSF_LABEL is not set
+# CONFIG_FEATURE_FDISK_ADVANCED is not set
+# CONFIG_FREERAMDISK is not set
+# CONFIG_FSCK_MINIX is not set
+# CONFIG_MKFS_MINIX is not set
+# CONFIG_GETOPT is not set
+CONFIG_HEXDUMP=y
+CONFIG_HWCLOCK=y
+CONFIG_FEATURE_HWCLOCK_LONGOPTIONS=y
+CONFIG_LOSETUP=y
+CONFIG_MKSWAP=y
+CONFIG_MORE=y
+CONFIG_FEATURE_USE_TERMIOS=y
+CONFIG_PIVOT_ROOT=y
+# CONFIG_RDATE is not set
+CONFIG_SWAPONOFF=y
+CONFIG_MOUNT=y
+CONFIG_NFSMOUNT=y
+CONFIG_UMOUNT=y
+CONFIG_FEATURE_MOUNT_FORCE=y
+
+#
+# Common options for mount/umount
+#
+CONFIG_FEATURE_MOUNT_LOOP=y
+# CONFIG_FEATURE_MTAB_SUPPORT is not set
+
+#
+# Debugging Options
+#
+# CONFIG_DEBUG is not set
diff --git a/busybox/busybox-1.00/udhcppidfile.patch b/busybox/busybox-1.00/udhcppidfile.patch
index e69de29bb2..fb2b2ec19a 100644
--- a/busybox/busybox-1.00/udhcppidfile.patch
+++ b/busybox/busybox-1.00/udhcppidfile.patch
@@ -0,0 +1,276 @@
+--- busybox-1.00/networking/udhcp/pidfile.h-dist 2004-04-15 03:51:26.000000000 +1000
++++ busybox-1.00/networking/udhcp/pidfile.h 2004-10-27 15:46:38.000000000 +1000
+@@ -21,5 +21,5 @@
+
+
+ int pidfile_acquire(const char *pidfile);
+-void pidfile_write_release(int pid_fd);
++int pidfile_reassign(const char *pidfile, int newpid);
+
+--- busybox-1.00/networking/udhcp/pidfile.c-dist 2004-04-15 03:51:25.000000000 +1000
++++ busybox-1.00/networking/udhcp/pidfile.c 2004-10-27 19:43:40.000000000 +1000
+@@ -25,6 +25,7 @@
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <errno.h>
+
+ #include "pidfile.h"
+ #include "common.h"
+@@ -37,39 +38,146 @@
+ }
+
+
+-int pidfile_acquire(const char *pidfile)
++static int pidfile_open(const char *pidfile)
+ {
+- int pid_fd;
+- if (!pidfile) return -1;
++ int fd;
+
+- pid_fd = open(pidfile, O_CREAT | O_WRONLY, 0644);
+- if (pid_fd < 0) {
+- LOG(LOG_ERR, "Unable to open pidfile %s: %m\n", pidfile);
+- } else {
+- lockf(pid_fd, F_LOCK, 0);
+- if (!saved_pidfile)
+- atexit(pidfile_delete);
+- saved_pidfile = (char *) pidfile;
++ if ((fd = open(pidfile, O_CREAT | O_RDWR, 0644)) < 0) {
++ LOG(LOG_ERR, "pidfile_open: open %s failed: %m\n", pidfile);
++ return (-1);
++ }
++
++ /* NOTE: lockf is not inherited by child after fork */
++ if (lockf(fd, F_LOCK, 0) < 0) {
++ LOG(LOG_ERR, "pidfile_open: lock %s failed: %m\n", pidfile);
++ close(fd);
++ return (-1);
++ }
++
++ return (fd);
++}
++
++
++static int pidfile_check(int fd, const char *pidfile)
++{
++ int len, pid;
++ char buf[20];
++
++ if (lseek(fd, 0L, SEEK_SET) < 0) {
++ LOG(LOG_ERR, "pidfile_check: lseek %s failed: %m\n", pidfile);
++ return (-1);
++ }
++
++ if ((len = read(fd, buf, sizeof buf - 1)) < 0) {
++ LOG(LOG_ERR, "pidfile_check: read %s failed: %m\n", pidfile);
++ return (-1);
++ }
++
++ if (len == 0)
++ return (0);
++
++ buf[len] = '\0';
++
++ if ((pid = atoi(buf)) <= 1) {
++ LOG(LOG_WARNING,
++ "pidfile_check: ignoring bogus pid (%s) in %s\n",
++ buf, pidfile);
++ return (0);
++ }
++
++ if (kill((pid_t)pid, 0) == 0) {
++ LOG(LOG_ERR, "pidfile_check: process %d exists (%s)\n",
++ pid, pidfile);
++ return (-1);
++ }
++
++ if (errno != ESRCH) {
++ LOG(LOG_ERR, "pidfile_check: kill %d failed (%s): %m\n",
++ pid, pidfile);
++ return (-1);
++ }
++
++ return (0);
++}
++
++
++static int pidfile_store(int fd, const char *pidfile, int pid)
++{
++ int len;
++ char buf[20];
++
++ if (lseek(fd, 0L, SEEK_SET) < 0) {
++ LOG(LOG_ERR, "pidfile_store: lseek %s failed: %m\n", pidfile);
++ return (-1);
++ }
++
++ len = snprintf(buf, sizeof buf - 1, "%d\n", pid);
++ buf[len] = '\0';
++
++ if (write(fd, buf, len) < 0) {
++ LOG(LOG_ERR, "pidfile_store: write %s failed: %m\n",
++ pidfile);
++ return (-1);
++ }
++
++ if (ftruncate(fd, len) < 0) {
++ LOG(LOG_ERR, "pidfile_store: ftruncate %d failed (%s): %m\n",
++ len, pidfile);
++ return (-1);
+ }
+
+- return pid_fd;
++ return (0);
+ }
+
+
+-void pidfile_write_release(int pid_fd)
++static void pidfile_close(int fd)
+ {
+- FILE *out;
++ (void)lseek(fd, 0L, SEEK_SET);
++ (void)lockf(fd, F_ULOCK, 0);
++ (void)close(fd);
++}
+
+- if (pid_fd < 0) return;
+
+- if ((out = fdopen(pid_fd, "w")) != NULL) {
+- fprintf(out, "%d\n", getpid());
+- fclose(out);
++int pidfile_acquire(const char *pidfile)
++{
++ int fd, result;
++ if (!pidfile) return (-1);
++
++ if ((fd = pidfile_open(pidfile)) < 0)
++ return (-1);
++
++ if ((result = pidfile_check(fd, pidfile)) == 0)
++ result = pidfile_store(fd, pidfile, getpid());
++
++ pidfile_close(fd);
++
++ if (result == 0) {
++ saved_pidfile = (char *) pidfile;
++ atexit(pidfile_delete);
+ }
+- lockf(pid_fd, F_UNLCK, 0);
+- close(pid_fd);
++
++ return (result);
+ }
+
+
++/*
++ * reassign the pid in a pidfile - used just after a fork so a parent
++ * can store the pid of its child into the file without any window
++ * where the pid in the file is a dead process (which might let another
++ * instance of the program start). Note the parent must use _exit() to
++ * avoid triggering the unlink scheduled above in pidfile_acquire()
++ */
++int pidfile_reassign(const char *pidfile, int pid)
++{
++ int fd, result;
++ if (!pidfile) return (-1);
++
++ if ((fd = pidfile_open(pidfile)) < 0)
++ return (-1);
+
++ result = pidfile_store(fd, pidfile, pid);
+
++ pidfile_close(fd);
++
++ return (result);
++}
+--- busybox-1.00/networking/udhcp/common.c-dist 2004-05-19 19:18:04.000000000 +1000
++++ busybox-1.00/networking/udhcp/common.c 2004-10-27 19:58:10.000000000 +1000
+@@ -64,16 +64,34 @@
+ #ifdef __uClinux__
+ LOG(LOG_ERR, "Cannot background in uclinux (yet)");
+ #else /* __uClinux__ */
+- int pid_fd;
++ int pid, fd;
+
+- /* hold lock during fork. */
+- pid_fd = pidfile_acquire(pidfile);
+- if (daemon(0, 0) == -1) {
++ /* NOTE: lockf is not inherited by the child after fork */
++ if ((pid = fork()) < 0) {
+ perror("fork");
+ exit(1);
+ }
++
++ if (pid > 0) {
++ /* parent */
++ if (pidfile_reassign(pidfile, pid) < 0) {
++ (void)kill(pid, SIGKILL);
++ exit(1);
++ } else
++ _exit(0);
++ }
++
++ /* child */
++ (void)chdir("/");
++ if ((fd = open("/dev/null", O_RDWR)) >= 0) {
++ (void)dup2(fd, 0);
++ (void)dup2(fd, 1);
++ (void)dup2(fd, 2);
++ (void)close(fd);
++ }
++ (void)setsid();
++
+ daemonized++;
+- pidfile_write_release(pid_fd);
+ #endif /* __uClinux__ */
+ }
+
+@@ -97,14 +115,12 @@
+
+ void start_log_and_pid(const char *client_server, const char *pidfile)
+ {
+- int pid_fd;
+-
+ /* Make sure our syslog fd isn't overwritten */
+ sanitize_fds();
+
+ /* do some other misc startup stuff while we are here to save bytes */
+- pid_fd = pidfile_acquire(pidfile);
+- pidfile_write_release(pid_fd);
++ if (pidfile_acquire(pidfile) < 0)
++ exit(1);
+
+ /* equivelent of doing a fflush after every \n */
+ setlinebuf(stdout);
+@@ -150,8 +166,8 @@
+ sanitize_fds();
+
+ /* do some other misc startup stuff while we are here to save bytes */
+- pid_fd = pidfile_acquire(pidfile);
+- pidfile_write_release(pid_fd);
++ if (pidfile_acquire(pidfile) < 0)
++ exit(1);
+
+ /* equivelent of doing a fflush after every \n */
+ setlinebuf(stdout);
+--- busybox-1.00/networking/udhcp/common.h-dist 2004-05-19 18:29:05.000000000 +1000
++++ busybox-1.00/networking/udhcp/common.h 2004-10-27 15:10:16.000000000 +1000
+@@ -42,7 +42,6 @@
+ long uptime(void);
+ void background(const char *pidfile);
+ void start_log_and_pid(const char *client_server, const char *pidfile);
+-void background(const char *pidfile);
+ void udhcp_logging(int level, const char *fmt, ...);
+
+ #define LOG(level, str, args...) udhcp_logging(level, str, ## args)
+--- busybox-1.00/networking/udhcp/script.c-dist 2004-05-19 17:45:47.000000000 +1000
++++ busybox-1.00/networking/udhcp/script.c 2004-10-27 15:54:04.000000000 +1000
+@@ -228,6 +228,6 @@
+ execle(client_config.script, client_config.script,
+ name, NULL, envp);
+ LOG(LOG_ERR, "script %s failed: %m", client_config.script);
+- exit(1);
++ _exit(1);
+ }
+ }
diff --git a/busybox/switchbox-1.00/switchbox.patch b/busybox/switchbox-1.00/switchbox.patch
index e69de29bb2..c600c5d007 100644
--- a/busybox/switchbox-1.00/switchbox.patch
+++ b/busybox/switchbox-1.00/switchbox.patch
@@ -0,0 +1,38 @@
+--- busybox-1.00-rc3/applets/install.sh 2001-03-09 08:12:11.000000000 +1030
++++ switchbox/applets/install.sh 2004-08-31 11:27:23.000000000 +0930
+@@ -16,28 +16,28 @@
+ h=`sort busybox.links | uniq`
+
+
+-rm -f $prefix/bin/busybox || exit 1
++rm -f $prefix/bin/switchbox || exit 1
+ mkdir -p $prefix/bin || exit 1
+-install -m 755 busybox $prefix/bin/busybox || exit 1
++install -m 755 busybox $prefix/bin/switchbox || exit 1
+
+ for i in $h ; do
+ appdir=`dirname $i`
+ mkdir -p $prefix/$appdir || exit 1
+ if [ "$2" = "--hardlinks" ]; then
+- bb_path="$prefix/bin/busybox"
++ bb_path="$prefix/bin/switchbox"
+ else
+ case "$appdir" in
+ /)
+- bb_path="bin/busybox"
++ bb_path="bin/switchbox"
+ ;;
+ /bin)
+- bb_path="busybox"
++ bb_path="switchbox"
+ ;;
+ /sbin)
+- bb_path="../bin/busybox"
++ bb_path="../bin/switchbox"
+ ;;
+ /usr/bin|/usr/sbin)
+- bb_path="../../bin/busybox"
++ bb_path="../../bin/switchbox"
+ ;;
+ *)
+ echo "Unknown installation directory: $appdir"