Index: Config.h =================================================================== RCS file: /usr/local/cvsroot/busybox/Config.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Config.h 2001/08/30 05:56:50 1.1.1.1 +++ Config.h 2001/08/30 06:34:48 1.2 @@ -7,29 +7,29 @@ // // // BusyBox Applications -#define BB_ADDGROUP -#define BB_ADDUSER +//#define BB_ADDGROUP +//#define BB_ADDUSER //#define BB_ADJTIMEX //#define BB_AR //#define BB_ASH #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_CHOWN +//#define BB_CHROOT +//#define BB_CHVT +//#define BB_CLEAR //#define BB_CMP #define BB_CP //#define BB_CPIO #define BB_CUT #define BB_DATE //#define BB_DC -#define BB_DD +//#define BB_DD //#define BB_DEALLOCVT -#define BB_DELGROUP -#define BB_DELUSER +//#define BB_DELGROUP +//#define BB_DELUSER #define BB_DF #define BB_DIRNAME #define BB_DMESG @@ -44,24 +44,24 @@ //#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_GETOPT -#define BB_GETTY +//#define BB_GETTY #define BB_GREP -#define BB_GUNZIP -#define BB_GZIP -#define BB_HALT -#define BB_HEAD +//#define BB_GUNZIP +//#define BB_GZIP +//#define BB_HALT +//#define BB_HEAD //#define BB_HOSTID -//#define BB_HOSTNAME +#define BB_HOSTNAME //#define BB_HUSH -#define BB_ID -//#define BB_IFCONFIG +//#define BB_ID +#define BB_IFCONFIG #define BB_INIT -//#define BB_INSMOD +#define BB_INSMOD #define BB_KILL #define BB_KILLALL #define BB_KLOGD @@ -78,10 +78,10 @@ //#define BB_MAKEDEVS //#define BB_MD5SUM #define BB_MKDIR -//#define BB_MKFIFO +#define BB_MKFIFO //#define BB_MKFS_MINIX #define BB_MKNOD -#define BB_MKSWAP +//#define BB_MKSWAP //#define BB_MKTEMP #define BB_MODPROBE #define BB_MORE @@ -91,10 +91,10 @@ #define BB_MV //#define BB_NC //#define BB_NSLOOKUP -#define BB_PIDOF -//#define BB_PING +//#define BB_PIDOF +#define BB_PING //#define BB_PIVOT_ROOT -#define BB_POWEROFF +//#define BB_POWEROFF //#define BB_PRINTF #define BB_PS #define BB_PWD @@ -102,48 +102,49 @@ //#define BB_READLINK #define BB_REBOOT //#define BB_RENICE -#define BB_RESET +//#define BB_RESET +#define BB_RESETPIN #define BB_RM -#define BB_RMDIR -//#define BB_RMMOD -//#define BB_ROUTE +//#define BB_RMDIR +#define BB_RMMOD +#define BB_ROUTE //#define BB_RPM2CPIO -#define BB_SED +//#define BB_SED //#define BB_SETKEYCODES #define BB_SLEEP -#define BB_SORT -//#define BB_STTY -#define BB_SWAPONOFF -#define BB_SYNC +//#define BB_SORT +#define BB_STTY +//#define BB_SWAPONOFF +//#define BB_SYNC #define BB_SYSLOGD -#define BB_TAIL -#define BB_TAR +//#define BB_TAIL +//#define BB_TAR //#define BB_TEE //#define BB_TEST //#define BB_TELNET //#define BB_TFTP -#define BB_TOUCH +//#define BB_TOUCH //#define BB_TR //#define BB_TRACEROUTE -#define BB_TRUE_FALSE +//#define BB_TRUE_FALSE #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_USLEEP -//#define BB_VI +#define BB_VI //#define BB_WATCHDOG -#define BB_WC +//#define BB_WC //#define BB_WGET #define BB_WHICH #define BB_WHOAMI -#define BB_XARGS -#define BB_YES +//#define BB_XARGS +//#define BB_YES // End of Applications List // // @@ -184,16 +185,16 @@ //#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 +#define BB_FEATURE_USE_TERMIOS // // calculate terminal & column widths (for more and ls) #define BB_FEATURE_AUTOWIDTH // // show username/groupnames for ls -#define BB_FEATURE_LS_USERNAME +//#define BB_FEATURE_LS_USERNAME // // show file timestamps in ls #define BB_FEATURE_LS_TIMESTAMPS @@ -233,7 +234,7 @@ // //Disable for a simple tail implementation (2.34k vs 3k for the full one). //Both provide 'tail -f', but this cuts out -c, -q, -s, and -v. -#define BB_FEATURE_FANCY_TAIL +//#define BB_FEATURE_FANCY_TAIL // // Enable support for loop devices in mount #define BB_FEATURE_MOUNT_LOOP @@ -254,19 +255,19 @@ #define BB_FEATURE_MOUNT_FORCE // // Enable support for creation of tar files. -#define BB_FEATURE_TAR_CREATE +//#define BB_FEATURE_TAR_CREATE // // Enable support for "--exclude" and "-X" for excluding files -#define BB_FEATURE_TAR_EXCLUDE +//#define BB_FEATURE_TAR_EXCLUDE // // Enable support for tar -z option (currently only works for inflating) -#define BB_FEATURE_TAR_GZIP +//#define BB_FEATURE_TAR_GZIP // // Enable reverse sort -#define BB_FEATURE_SORT_REVERSE +//#define BB_FEATURE_SORT_REVERSE // // Enable uniqe sort -#define BB_FEATURE_SORT_UNIQUE +//#define BB_FEATURE_SORT_UNIQUE // // Enable command line editing in the shell. // Only relevant if a shell is enabled. On by default. @@ -298,7 +299,7 @@ // current username and hostname. On systems that don't have usernames // or hostnames, this can look hideous. // Only relevant if a shell is enabled. -//#define BB_FEATURE_SH_FANCY_PROMPT +#define BB_FEATURE_SH_FANCY_PROMPT // //Turn on extra fbset options //#define BB_FEATURE_FBSET_FANCY @@ -307,13 +308,13 @@ //#define BB_FEATURE_FBSET_READMODE // // Support insmod/lsmod/rmmod for post 2.1 kernels -//#define BB_FEATURE_NEW_MODULE_INTERFACE +#define BB_FEATURE_NEW_MODULE_INTERFACE // // Support insmod/lsmod/rmmod for pre 2.1 kernels //#define BB_FEATURE_OLD_MODULE_INTERFACE // // Support module version checking -//#define BB_FEATURE_INSMOD_VERSION_CHECKING +#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. @@ -325,16 +326,16 @@ //#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 // // Enable ifconfig options "mem_start", "io_addr", and "irq". -//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ +#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). @@ -346,10 +347,10 @@ //#define BB_FEATURE_INSTALLER // // Enable a nifty progress meter in wget (adds just under 2k) -#define BB_FEATURE_WGET_STATUSBAR +//#define BB_FEATURE_WGET_STATUSBAR // // Enable HTTP authentication in wget -#define BB_FEATURE_WGET_AUTHENTICATION +//#define BB_FEATURE_WGET_AUTHENTICATION // // Clean up all memory before exiting -- usually not needed // as the OS can clean up... Don't enable this unless you @@ -357,16 +358,16 @@ //#define BB_FEATURE_CLEAN_UP // // Support for human readable output by ls, du, etc.(example 13k, 23M, 235G) -#define BB_FEATURE_HUMAN_READABLE +//#define BB_FEATURE_HUMAN_READABLE // // Support for the find -type option. -#define BB_FEATURE_FIND_TYPE +//#define BB_FEATURE_FIND_TYPE // // Support for the find -perm option. -#define BB_FEATURE_FIND_PERM +//#define BB_FEATURE_FIND_PERM // // Support for the find -mtine option. -#define BB_FEATURE_FIND_MTIME +//#define BB_FEATURE_FIND_MTIME // // Support for the -A -B and -C context flags in grep //#define BB_FEATURE_GREP_CONTEXT @@ -375,8 +376,8 @@ //#define BB_FEATURE_GREP_EGREP_ALIAS // // Tell tftp what commands that should be supported. -#define BB_FEATURE_TFTP_PUT -#define BB_FEATURE_TFTP_GET +//#define BB_FEATURE_TFTP_PUT +//#define BB_FEATURE_TFTP_GET // // features for vi #define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode @@ -393,7 +394,7 @@ //#define BB_LOCALE_SUPPORT // // Support for TELNET to pass TERM type to remote host. Adds 384 bytes. -#define BB_FEATURE_TELNET_TTYPE +//#define BB_FEATURE_TELNET_TTYPE // // Support for devfs. //#define BB_FEATURE_DEVFS @@ -413,13 +414,13 @@ #if defined __UCLIBC__ && ! defined __UCLIBC_HAS_MMU__ #undef BB_RPM2CPIO /* Uses gz_open(), which uses fork() */ #undef BB_DPKG_DEB /* Uses gz_open(), which uses fork() */ - #undef BB_ASH /* Uses fork() */ - #undef BB_HUSH /* Uses fork() */ - #undef BB_LASH /* Uses fork() */ - #undef BB_INIT /* Uses fork() */ +// #undef BB_ASH /* Uses fork() */ +// #undef BB_HUSH /* Uses fork() */ +// #undef BB_LASH /* Uses fork() */ +// #undef BB_INIT /* Uses fork() */ #undef BB_FEATURE_TAR_GZIP /* Uses fork() */ - #undef BB_SYSLOGD /* Uses daemon() */ - #undef BB_KLOGD /* Uses daemon() */ +// #undef BB_SYSLOGD /* Uses daemon() */ +// #undef BB_KLOGD /* Uses daemon() */ #undef BB_UPDATE /* Uses daemon() */ #endif #if defined BB_ASH || defined BB_HUSH || defined BB_LASH || defined BB_MSH Index: Makefile =================================================================== RCS file: /usr/local/cvsroot/busybox/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- Makefile 2001/08/30 05:56:50 1.1.1.1 +++ Makefile 2001/08/30 06:34:48 1.2 @@ -17,6 +17,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +.EXPORT_ALL_VARIABLES: + PROG := busybox VERSION := 0.60.0 BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z") @@ -33,11 +35,11 @@ CFLAGS_EXTRA = # If you want a static binary, turn this on. -DOSTATIC = false +# DOSTATIC = true # Set the following to `true' to make a debuggable build. # Leave this set to `false' for production use. -DODEBUG = false +DODEBUG = true # Setting this to `true' will cause busybox to directly use the system's # password and group functions. Assuming you use GNU libc, when this is @@ -49,7 +51,7 @@ # just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs). # Note that if you want hostname resolution to work with glibc, you still need # the libnss_* libraries. -USE_SYSTEM_PWD_GRP = true +USE_SYSTEM_PWD_GRP = false # This enables compiling with dmalloc ( http://dmalloc.com/ ) # which is an excellent public domain mem leak and malloc problem @@ -79,10 +81,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 -STRIPTOOL = $(CROSS)strip +# CROSS = +# CC = $(CROSS)gcc +# AR = $(CROSS)ar +# STRIPTOOL = $(CROSS)strip # To compile vs uClibc, just use the compiler wrapper built by uClibc... # Everything should compile and work as expected these days... Index: applets.h =================================================================== RCS file: /usr/local/cvsroot/busybox/applets.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- applets.h 2001/08/30 05:56:50 1.1.1.1 +++ applets.h 2001/08/30 06:34:48 1.2 @@ -347,6 +347,9 @@ #ifdef BB_RESET APPLET(reset, reset_main, _BB_DIR_USR_BIN) #endif +#ifdef BB_RESETPIN + APPLET(resetpin, resetpin_main, _BB_DIR_USR_BIN) +#endif #ifdef BB_RM APPLET(rm, rm_main, _BB_DIR_BIN) #endif Index: ash.c =================================================================== RCS file: /usr/local/cvsroot/busybox/ash.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- ash.c 2001/08/30 05:56:50 1.1.1.1 +++ ash.c 2001/08/30 06:34:48 1.2 @@ -6893,7 +6893,11 @@ TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n, mode)); INTOFF; +#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) pid = fork(); +#else + pid = vfork(); +#endif if (pid == -1) { TRACE(("Fork failed, errno=%d\n", errno)); INTON; Index: hush.c =================================================================== RCS file: /usr/local/cvsroot/busybox/hush.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- hush.c 2001/08/30 05:56:50 1.1.1.1 +++ hush.c 2001/08/30 06:34:48 1.2 @@ -1402,7 +1402,11 @@ } /* XXX test for failed fork()? */ +#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) if (!(child->pid = fork())) { +#else + if (!(child->pid = vfork())) { +#endif /* Set the handling for job control signals back to the default. */ signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); Index: ifconfig.c =================================================================== RCS file: /usr/local/cvsroot/busybox/ifconfig.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- ifconfig.c 2001/08/30 05:56:50 1.1.1.1 +++ ifconfig.c 2001/08/30 06:34:48 1.2 @@ -135,7 +135,7 @@ #define ARG_MTU (A_ARG_REQ /*| A_CAST_INT*/) #define ARG_TXQUEUELEN (A_ARG_REQ /*| A_CAST_INT*/) #define ARG_MEM_START (A_ARG_REQ | A_MAP_ULONG) -#define ARG_IO_ADDR (A_ARG_REQ | A_MAP_USHORT) +#define ARG_IO_ADDR (A_ARG_REQ | A_MAP_ULONG) #define ARG_IRQ (A_ARG_REQ | A_MAP_UCHAR) #define ARG_DSTADDR (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE) #define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK) Index: init.c =================================================================== RCS file: /usr/local/cvsroot/busybox/init.c,v retrieving revision 1.1.1.1 retrieving revision 1.3 diff -u -r1.1.1.1 -r1.3 --- init.c 2001/08/30 05:56:50 1.1.1.1 +++ init.c 2001/08/30 17:40:08 1.3 @@ -74,7 +74,12 @@ int reserved[4]; }; - +#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__) + #include + #define init_reboot(magic) reboot(magic) +#else + #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic) +#endif #ifndef RB_HALT_SYSTEM static const int RB_HALT_SYSTEM = 0xcdef0123; @@ -84,13 +89,6 @@ static const int RB_AUTOBOOT = 0x01234567; #endif -#if (__GNU_LIBRARY__ > 5) || defined(__dietlibc__) - #include - #define init_reboot(magic) reboot(magic) -#else - #define init_reboot(magic) reboot(0xfee1dead, 672274793, magic) -#endif - #ifndef _PATH_STDPATH #define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" #endif @@ -121,7 +119,11 @@ #define LOGIN_SHELL "-" SHELL /* Default login shell */ #define INITTAB "/etc/inittab" /* inittab file location */ #ifndef INIT_SCRIPT -#define INIT_SCRIPT "/etc/init.d/rcS" /* Default sysinit script. */ + #ifdef __UCLIBC_HAS_MMU__ + #define INIT_SCRIPT "/etc/rc" /* Default sysinit script. */ + #else + #define INIT_SCRIPT "/bin/sh /etc/rc" + #endif #endif #define MAXENV 16 /* Number of env. vars */ @@ -178,6 +180,7 @@ static char console[32] = _PATH_CONSOLE; static void delete_initAction(initAction * action); +static void set_term(int fd); static void loop_forever() { @@ -218,9 +221,9 @@ log_fd = -2; /* log to main console instead */ device = CONSOLE; - } else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) { + } else if ((log_fd = device_open(log, O_RDWR)) < 0) { log_fd = -2; - fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log); + fprintf(stderr, "Bummer, can't write to log on %s!\n", log); log = NULL; device = CONSOLE; } @@ -237,11 +240,14 @@ if ( (fd = device_open(_PATH_CONSOLE, - O_WRONLY | O_NOCTTY | O_NDELAY)) >= 0) { + O_WRONLY | O_NOCTTY)) >= 0) { va_start(arguments, fmt); + usleep(50000); + set_term(fd); vdprintf(fd, fmt, arguments); va_end(arguments); close(fd); + usleep(50000); } else { fprintf(stderr, "Bummer, can't print: "); va_start(arguments, fmt); @@ -256,6 +262,7 @@ { struct termios tty; + memset(&tty, 0, sizeof(tty)); tcgetattr(fd, &tty); /* set control chars */ @@ -273,7 +280,7 @@ /* Make it be sane */ tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; - tty.c_cflag |= CREAD|HUPCL|CLOCAL; + tty.c_cflag |= CREAD|CLOCAL; /* input modes */ @@ -284,9 +291,10 @@ /* local modes */ tty.c_lflag = - ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN; + ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | IEXTEN + | NOFLSH; - tcsetattr(fd, TCSANOW, &tty); + tcsetattr(fd, TCSADRAIN, &tty); } /* How much memory does this machine have? @@ -353,7 +361,7 @@ } } - while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0) { + while ((fd = open(console, O_RDONLY)) < 0) { /* Can't open selected console -- try /dev/console */ if (!tried_devcons) { tried_devcons++; @@ -384,7 +392,7 @@ if (strcmp( termType, "TERM=linux" ) == 0) safe_strncpy(termType, "TERM=vt102", sizeof(termType)); message(LOG | CONSOLE, - "serial console detected. Disabling virtual terminals.\r\n"); + "serial console detected. Disabling virtual terminals.\n"); } close(fd); } @@ -397,7 +405,7 @@ /* Fix up argv[0] to be certain we claim to be init */ len = strlen(argv[0]); memset(argv[0], 0, len); - strncpy(argv[0], new_argv0, len); + safe_strncpy(argv[0], new_argv0, len + 1); /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */ len = 1; @@ -427,7 +435,7 @@ char *environment[MAXENV+1] = { termType, "HOME=/", - "PATH=/usr/bin:/bin:/usr/sbin:/sbin", + "PATH=" _PATH_STDPATH, "SHELL=" SHELL, "USER=root", NULL @@ -446,7 +454,11 @@ } } +#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) if ((pid = fork()) == 0) { +#else + if ((pid = vfork()) == 0) { +#endif /* Clean up */ ioctl(0, TIOCNOTTY, 0); close(0); @@ -467,7 +479,7 @@ terminal); exit(1); } - message(LOG | CONSOLE, "Bummer, can't open %s\r\n", terminal); + message(LOG | CONSOLE, "Bummer, can't open %s\n", terminal); exit(1); } dup2(fd, 0); @@ -482,13 +494,16 @@ cmd[0] = SHELL; cmd[1] = "-c"; strcpy(buf, "exec "); - strncat(buf, command, sizeof(buf) - strlen(buf) - 1); + safe_strncpy(buf + sizeof("exec "), command, + sizeof(buf) - sizeof("exec ")); cmd[2] = buf; cmd[3] = NULL; } else { /* Convert command (char*) into cmd (char**, one word per string) */ - for (tmpCmd = command, i = 0; - (tmpCmd = strsep(&command, " \t")) != NULL;) { + safe_strncpy(buf, command, sizeof(buf)); + s = buf; + for (tmpCmd = buf, i = 0; + (tmpCmd = strsep(&s, " \t")) != NULL;) { if (*tmpCmd != '\0') { cmd[i] = tmpCmd; tmpCmd++; @@ -535,7 +550,7 @@ * specifies. */ #ifdef DEBUG_INIT - message(LOG, "Waiting for enter to start '%s' (pid %d, console %s)\r\n", + message(LOG, "Waiting for enter to start '%s' (pid %d, console %s)\n", cmd[0], getpid(), terminal); #endif write(fileno(stdout), press_enter, sizeof(press_enter) - 1); @@ -544,7 +559,7 @@ #ifdef DEBUG_INIT /* Log the process name and args */ - message(LOG, "Starting pid %d, console %s: '%s'\r\n", + message(LOG, "Starting pid %d, console %s: '%s'\n", getpid(), terminal, command); #endif @@ -597,8 +612,10 @@ if (stat("/etc/fstab", &statBuf) == 0) { /* swapon -a requires /proc typically */ waitfor("mount proc /proc -t proc", console, FALSE); +#ifndef __embedded__ /* Try to turn on swap */ waitfor("swapon -a", console, FALSE); +#endif if (check_free_memory() < 1000) goto goodnight; } else @@ -607,7 +624,7 @@ goodnight: message(CONSOLE, - "Sorry, your computer does not have enough memory.\r\n"); + "Sorry, your computer does not have enough memory.\n"); loop_forever(); } @@ -628,23 +645,31 @@ #ifndef DEBUG_INIT static void shutdown_system(void) { + sigset_t block_signals; /* first disable our SIGHUP signal */ - signal(SIGHUP, SIG_DFL); + sigemptyset(&block_signals); + sigaddset(&block_signals, SIGHUP); + sigaddset(&block_signals, SIGCHLD); + sigaddset(&block_signals, SIGUSR1); + sigaddset(&block_signals, SIGUSR2); + sigaddset(&block_signals, SIGINT); + sigaddset(&block_signals, SIGTERM); + sigprocmask(SIG_BLOCK, &block_signals, NULL); /* Allow Ctrl-Alt-Del to reboot system. */ init_reboot(RB_ENABLE_CAD); - message(CONSOLE|LOG, "\r\nThe system is going down NOW !!\r\n"); + message(CONSOLE|LOG, "\nThe system is going down NOW !!\n"); sync(); /* Send signals to every process _except_ pid 1 */ - message(CONSOLE|LOG, "Sending SIGTERM to all processes.\r\n"); + message(CONSOLE|LOG, "Sending SIGTERM to all processes.\n"); kill(-1, SIGTERM); sleep(1); sync(); - message(CONSOLE|LOG, "Sending SIGKILL to all processes.\r\n"); + message(CONSOLE|LOG, "Sending SIGKILL to all processes.\n"); kill(-1, SIGKILL); sleep(1); @@ -663,7 +688,7 @@ { shutdown_system(); message(CONSOLE|LOG, - "The system is halted. Press %s or turn off power\r\n", + "The system is halted. Press %s or turn off power\n", (secondConsole == NULL) /* serial console */ ? "Reset" : "CTRL-ALT-DEL"); sync(); @@ -682,7 +707,7 @@ static void reboot_signal(int sig) { shutdown_system(); - message(CONSOLE|LOG, "Please stand by while rebooting the system.\r\n"); + message(CONSOLE, "Please stand by while rebooting the system.\n"); sync(); /* allow time for last message to reach serial console */ @@ -722,9 +747,9 @@ } newAction->nextPtr = initActionList; initActionList = newAction; - strncpy(newAction->process, process, 255); + safe_strncpy(newAction->process, process, 255); newAction->action = action; - strncpy(newAction->console, cons, 255); + safe_strncpy(newAction->console, cons, 255); newAction->pid = 0; // message(LOG|CONSOLE, "process='%s' action='%d' console='%s'\n", // newAction->process, newAction->action, newAction->console); @@ -770,12 +795,14 @@ #endif /* Reboot on Ctrl-Alt-Del */ new_initAction(CTRLALTDEL, "/sbin/reboot", console); +#ifndef __embedded__ /* Swapoff on halt/reboot */ new_initAction(SHUTDOWN, "/sbin/swapoff -a", console); +#endif /* Umount all filesystems on halt/reboot */ new_initAction(SHUTDOWN, "/bin/umount -a -r", console); - /* Askfirst shell on tty1 */ - new_initAction(ASKFIRST, LOGIN_SHELL, console); + /* Spawn a shell on tty1 */ + new_initAction(RESPAWN, LOGIN_SHELL, console); /* Askfirst shell on tty2 */ if (secondConsole != NULL) new_initAction(ASKFIRST, LOGIN_SHELL, secondConsole); @@ -897,13 +924,14 @@ /* Figure out what kernel this is running */ kernelVersion = get_kernel_revision(); - /* Figure out where the default console should be */ - console_init(); - /* Close whatever files are open, and reset the console. */ close(0); close(1); close(2); + + /* Figure out where the default console should be */ + console_init(); + set_term(0); chdir("/"); setsid(); @@ -917,15 +945,15 @@ #if ! defined BB_FEATURE_EXTRA_QUIET CONSOLE| #endif - LOG, - "init started: %s\r\n", full_version); + 0, + "init started: %s\n", full_version); #else message( #if ! defined BB_FEATURE_EXTRA_QUIET CONSOLE| #endif LOG, - "init(%d) started: %s\r\n", getpid(), full_version); + "init(%d) started: %s\n", getpid(), full_version); #endif @@ -963,6 +991,7 @@ for (a = initActionList; a; a = tmp) { tmp = a->nextPtr; if (a->action == SYSINIT) { + // set_term(0); waitfor(a->process, a->console, FALSE); /* Now remove the "sysinit" entry from the list */ delete_initAction(a); Index: klogd.c =================================================================== RCS file: /usr/local/cvsroot/busybox/klogd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- klogd.c 2001/08/30 05:56:50 1.1.1.1 +++ klogd.c 2001/08/30 06:34:48 1.2 @@ -136,7 +136,9 @@ } if (doFork == TRUE) { +#ifdef __UCLIBC_HAS_MMU__ if (daemon(0, 1) < 0) +#endif perror_msg_and_die("daemon"); } doKlogd(); Index: lash.c =================================================================== RCS file: /usr/local/cvsroot/busybox/lash.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- lash.c 2001/08/30 05:56:50 1.1.1.1 +++ lash.c 2001/08/30 06:34:48 1.2 @@ -1345,7 +1345,11 @@ } } +#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) if (!(child->pid = fork())) { +#else + if (!(child->pid = vfork())) { +#endif /* Set the handling for job control signals back to the default. */ signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); Index: msh.c =================================================================== RCS file: /usr/local/cvsroot/busybox/msh.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- msh.c 2001/08/30 05:56:50 1.1.1.1 +++ msh.c 2001/08/30 06:34:48 1.2 @@ -66,7 +66,7 @@ /* * library and system defintions */ -typedef void xint; /* base type of jmp_buf, for not broken compilers */ +typedef jmp_buf xint; /* base type of jmp_buf, for not broken compilers */ /* * shell components @@ -662,7 +662,13 @@ static struct env e ={line, iostack, iostack-1, (xint *)NULL, FDBASE, (struct env *)NULL}; static void (*qflag)(int) = SIG_IGN; static char shellname[] = "/bin/sh"; -static char search[] = ":/bin:/usr/bin"; +static char search[] = +#ifdef __embedded__ + "/usr/bin:/bin:/usr/sbin:/sbin" +#else + ":/bin:/usr/bin" +#endif +; static int startl; static int peeksym; static int nlseen; @@ -898,8 +904,8 @@ inparse = 1; intr = 0; execflg = 0; - setjmp(failpt = m1); /* Bruce Evans' fix */ - if (setjmp(failpt = m1) || yyparse() || intr) { + setjmp(*(failpt = &m1)); /* Bruce Evans' fix */ + if (setjmp(*failpt) || yyparse() || intr) { while (e.oenv) quitenv(); scraphere(); @@ -928,7 +934,7 @@ static void fail() { - longjmp(failpt, 1); + longjmp(*(__jmp_buf *)failpt, 1); /* NOTREACHED */ } @@ -967,7 +973,7 @@ if (!interactive) leave(); if (e.errpt) - longjmp(e.errpt, 1); + longjmp(*(__jmp_buf *)e.errpt, 1); closeall(); e.iop = e.iobase = iostack; } @@ -2917,13 +2923,13 @@ otree = outtree; ofail = failpt; rv = -1; - if (newenv(setjmp(errpt = ev)) == 0) { + if (newenv(setjmp(*(errpt = &ev))) == 0) { wdlist = 0; iolist = 0; pushio(argp, f); e.iobase = e.iop; yynerrs = 0; - if (setjmp(failpt = rt) == 0 && yyparse() == 0) + if (setjmp(*(failpt = &rt)) == 0 && yyparse() == 0) rv = execute(outtree, NOPIPE, NOPIPE, 0); quitenv(); } @@ -3079,7 +3085,7 @@ return(1); execflg = 1; ofail = failpt; - if (setjmp(failpt = ex) == 0) + if (setjmp(*(failpt = &ex)) == 0) execute(t, NOPIPE, NOPIPE, FEXEC); failpt = ofail; execflg = 0; @@ -3289,7 +3295,7 @@ return(1); } isbreak = val; - longjmp(bc->brkpt, 1); + longjmp(*((__jmp_buf *)(bc->brkpt)), 1); /* NOTREACHED */ } @@ -3472,7 +3478,7 @@ wp = NULL; wb = NULL; wf = NULL; - if (newenv(setjmp(errpt = ev)) == 0) { + if (newenv(setjmp(*(errpt = &ev))) == 0) { while (*ap && isassign(*ap)) expand(*ap++, &wb, f & ~DOGLOB); if (flag['k']) { @@ -3551,7 +3557,7 @@ *wbp = addword(cp, *wbp); return(1); } - if (newenv(setjmp(errpt = ev)) == 0) { + if (newenv(setjmp(*(errpt = &ev))) == 0) { PUSHIO(aword, cp, strchar); e.iobase = e.iop; while ((cp = blank(f)) && gflg == 0) { @@ -4712,7 +4718,7 @@ if (tf < 0) return; *name = strsave(tname, areanum); - if (newenv(setjmp(errpt = ev)) != 0) + if (newenv(setjmp(*(errpt = &ev))) != 0) unlink(tname); else { pushio(e.iop->argp, e.iop->iofn); @@ -4778,7 +4784,7 @@ tf = mkstemp(tname); if (tf < 0) return (-1); - if (newenv(setjmp(errpt = ev)) == 0) { + if (newenv(setjmp(*(errpt = &ev))) == 0) { PUSHIO(afile, hf, herechar); setbase(e.iop); while ((c = subgetc(0, 0)) != 0) { Index: resetpin.c =================================================================== RCS file: resetpin.c diff -N resetpin.c --- /dev/null Tue May 5 16:32:27 1998 +++ resetpin.c Fri Oct 26 11:19:59 2001 @@ -0,0 +1,84 @@ +/* vi: set sw=4 ts=4: */ +/* + * SuperBT BTLAP reset pin implementation for busybox + * + * + * Copyright (C) 1999,2000,2001 by Lineo, inc. + * Written by Erik Andersen , + * and Kent Robotti + * + * 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 +#include +#include +#include "busybox.h" + +#include +#include +#include +#define COLDFIRE_ADDON_CHIP_RESET_PIN 0x0001 + +extern int resetpin_main(int argc, char **argv) +{ + u_int16_t paddr_orig, paddr; + u_int16_t padat; + unsigned long const reset_period = 150000; + unsigned long const reboot_period = 3000000; + + printf("Resetting the add-on chip on the BTLAP board...\n"); + fflush(stdout); + + // We don't have to go through the kernel on a MMU-less system + + // read the existing parallel port configuration + paddr_orig = *((volatile u_int16_t *) (MCF_MBAR + MCFSIM_PADDR)); + printf("PADDR value read: %04x\n", paddr_orig); + + // configure bit 0 as an output bit + paddr = paddr_orig | 0x0001; + *((volatile u_int16_t *) (MCF_MBAR + MCFSIM_PADDR)) = paddr; + printf("PADDR value stored: %04x\n", paddr); + + padat = *((volatile u_int16_t *) (MCF_MBAR + MCFSIM_PADAT)); + printf("PADAT value read: %04x\n", padat); + + // 0 in bit 0 activates the reset pin + padat &= ~COLDFIRE_ADDON_CHIP_RESET_PIN; + *((volatile u_int16_t *) (MCF_MBAR + MCFSIM_PADAT)) = padat; + printf("PADAT value stored: %04x\n", padat); + + printf("Waiting %ld ms...\n", reset_period / 1000); + fflush(stdout); + + usleep(reset_period); + + padat |= COLDFIRE_ADDON_CHIP_RESET_PIN; // de-activate reset pin + *((volatile unsigned short *) (MCF_MBAR + MCFSIM_PADAT)) = padat; + printf("PADAT value stored: %04x\n", padat); + + // restore bit 0 configuration + *((volatile u_int16_t *) (MCF_MBAR + MCFSIM_PADDR)) = paddr_orig; + printf("PADDR value stored: %04x\n", paddr_orig); + + printf("Waiting %ld ms...\n", reboot_period / 1000); + fflush(stdout); + usleep(reboot_period); + + return EXIT_SUCCESS; +} + Index: syslogd.c =================================================================== RCS file: /usr/local/cvsroot/busybox/syslogd.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- syslogd.c 2001/08/30 05:56:50 1.1.1.1 +++ syslogd.c 2001/08/30 06:34:48 1.2 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -280,8 +281,7 @@ }else #endif if ((fd = device_open (logFilePath, - O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND | - O_NONBLOCK)) >= 0) { + O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND)) >= 0) { fl.l_type = F_WRLCK; fcntl (fd, F_SETLKW, &fl); va_start (arguments, fmt); @@ -293,7 +293,7 @@ } else { /* Always send console messages to /dev/console so people will see them. */ if ((fd = device_open (_PATH_CONSOLE, - O_WRONLY | O_NOCTTY | O_NONBLOCK)) >= 0) { + O_WRONLY | O_NOCTTY)) >= 0) { va_start (arguments, fmt); vdprintf (fd, fmt, arguments); va_end (arguments); @@ -624,7 +624,9 @@ umask(0); if (doFork == TRUE) { +#if !defined(__UCLIBC__) || defined(__UCLIBC_HAS_MMU__) if (daemon(0, 1) < 0) +#endif perror_msg_and_die("daemon"); } doSyslogd(); Index: usage.h =================================================================== RCS file: /usr/local/cvsroot/busybox/usage.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- usage.h 2001/08/30 05:56:50 1.1.1.1 +++ usage.h 2001/08/30 06:34:48 1.2 @@ -1338,6 +1338,11 @@ #define reset_full_usage \ "Resets the screen." +#define resetpin_trivial_usage \ + "" +#define resetpin_full_usage \ + "Resets the PADAT pin 0 on a Coldfire board." + #define rm_trivial_usage \ "[OPTION]... FILE..." #define rm_full_usage \ Index: vi.c =================================================================== RCS file: /usr/local/cvsroot/busybox/vi.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- vi.c 2001/08/30 05:56:50 1.1.1.1 +++ vi.c 2001/08/30 06:34:48 1.2 @@ -875,7 +875,7 @@ break; #ifdef BB_FEATURE_VI_USE_SIGNALS case 0x03: // ctrl-C interrupt - longjmp(restart, 1); + longjmp(*(__jmp_buf *)&restart, 1); break; case 26: // ctrl-Z suspend suspend_sig(SIGTSTP); @@ -3235,13 +3235,13 @@ signal(SIGHUP, catch_sig); signal(SIGINT, catch_sig); signal(SIGTERM, catch_sig); - longjmp(restart, sig); + longjmp(*(__jmp_buf *)&restart, sig); } static void alarm_sig(int sig) { signal(SIGALRM, catch_sig); - longjmp(restart, sig); + longjmp(*(__jmp_buf *)&restart, sig); } //----- Come here when we get a core dump signal ----------------- @@ -3261,7 +3261,7 @@ dot = bound_dot(dot); // make sure "dot" is valid - longjmp(restart, sig); + longjmp(*(__jmp_buf *)&restart, sig); } #endif /* BB_FEATURE_VI_USE_SIGNALS */ Index: libbb/device_open.c =================================================================== RCS file: /usr/local/cvsroot/busybox/libbb/device_open.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- libbb/device_open.c 2001/08/30 05:56:50 1.1.1.1 +++ libbb/device_open.c 2001/08/30 06:34:48 1.2 @@ -35,7 +35,7 @@ { int m, f, fd = -1; - m = mode | O_NONBLOCK; + m = mode /* | O_NONBLOCK */; /* Retry up to 5 times */ for (f = 0; f < 5; f++) Index: libbb/interface.c =================================================================== RCS file: /usr/local/cvsroot/busybox/libbb/interface.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- libbb/interface.c 2001/08/30 05:56:50 1.1.1.1 +++ libbb/interface.c 2001/08/30 06:34:48 1.2 @@ -2099,7 +2099,7 @@ printf(_("Interrupt:%d "), ptr->map.irq); if (ptr->map.base_addr >= 0x100) /* Only print devices using it for I/O maps */ - printf(_("Base address:0x%x "), ptr->map.base_addr); + printf(_("Base address:0x%lx "), (unsigned long)ptr->map.base_addr); if (ptr->map.mem_start) { printf(_("Memory:%lx-%lx "), ptr->map.mem_start, ptr->map.mem_end); } Index: tests/Makefile =================================================================== RCS file: /usr/local/cvsroot/busybox/tests/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- tests/Makefile 2001/08/30 05:56:50 1.1.1.1 +++ tests/Makefile 2001/08/30 06:34:49 1.2 @@ -18,16 +18,13 @@ include $(wildcard *_tests.mk) -BBL := $(shell pushd .. >/dev/null && \ - ${MAKE} busybox.links >/dev/null && \ - popd >/dev/null && \ - cat ../busybox.links | \ - sed -e 's,.*/\(.*\)$$,\1,') +BBL := $(shell test -f ../busybox.links && \ + cat ../busybox.links | sed -e 's,.*/\(.*\)$$,\1,') ../busybox: cd .. && ${MAKE} busybox -${BBL}: ../busybox +${BBL}: ../busybox ../busybox.links rm -f $@ ln ../busybox $@