diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-05 00:31:46 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-05 00:31:46 +0000 |
commit | cf8c9cf7b9792e9cef3d790c46763712c390c7ed (patch) | |
tree | 980d8b0e71170aeb61c1e7ea871c7233ca31cbb6 | |
parent | d0246fb72b40320a74376af1bb944fef2c9b734f (diff) | |
download | busybox-cf8c9cf7b9792e9cef3d790c46763712c390c7ed.tar.gz |
More stuff -- ready for release.
-Erik
-rw-r--r-- | Changelog | 8 | ||||
-rw-r--r-- | busybox.def.h | 2 | ||||
-rw-r--r-- | init.c | 64 | ||||
-rw-r--r-- | init/init.c | 64 | ||||
-rw-r--r-- | umount.c | 9 | ||||
-rw-r--r-- | util-linux/umount.c | 9 | ||||
-rw-r--r-- | utility.c | 8 |
7 files changed, 53 insertions, 111 deletions
@@ -9,10 +9,18 @@ * Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!). * Fixed a stupid seg-fault in sync * Fixed mount -- mount -a failed to parse and apply mount options + * Fixed umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>) + * umount -a no longer umounts /proc * Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc) folks to use a real /etc/mtab file instead of a symlink to /proc/mounts. mount, and umount will add/remove entries and df will now use /etc/mtab if BB_MTAB is defined. + * Fixed a nice bug in recursiveAction() which caused it to infinitely + hunt through /proc/../fd/* creating new file descriptors if it + followed the /dev/fd link over to /proc. recursiveAction() now + lstat's the file when followLinks==FALSE so it won't follow links + as the name suggests. Fix thanks to Matt Porter <porter@debian.org>. + -Erik Andersen diff --git a/busybox.def.h b/busybox.def.h index 880046318..59c1df188 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -38,7 +38,7 @@ #define BB_MORE #define BB_MOUNT //#define BB_MT -#define BB_MTAB +//#define BB_MTAB #define BB_MV //#define BB_PRINTF #define BB_PS @@ -123,13 +123,6 @@ void message(int device, char *fmt, ...) void set_term( int fd) { struct termios tty; -#if 0 - static const char control_characters[] = { - '\003', '\034', '\177', '\025', '\004', '\0', - '\1', '\0', '\021', '\023', '\032', '\0', '\022', - '\017', '\027', '\026', '\0' - }; -#endif static const char control_characters[] = { '\003', '\034', '\177', '\030', '\004', '\0', '\1', '\0', '\021', '\023', '\032', '\0', '\022', @@ -160,44 +153,6 @@ void set_term( int fd) tcsetattr(fd, TCSANOW, &tty); } -/* Set terminal settings to reasonable defaults */ -void set_term_old( int fd) -{ - struct termios tty; - - ioctl(fd, TCGETA, &tty); - - tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; - tty.c_cflag |= HUPCL|CLOCAL; - - tty.c_cc[VINTR] = 3; - tty.c_cc[VQUIT] = 28; - tty.c_cc[VERASE] = 127; - //tty.c_cc[VKILL] = 21; - tty.c_cc[VKILL] = 24; - tty.c_cc[VEOF] = 4; - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 1; - tty.c_cc[VSWTC] = 0; - tty.c_cc[VSTART] = 17; - tty.c_cc[VSTOP] = 19; - tty.c_cc[VSUSP] = 26; - tty.c_cc[VEOL] = 0; - tty.c_cc[VREPRINT] = 18; - tty.c_cc[VDISCARD] = 15; - tty.c_cc[VWERASE] = 23; - tty.c_cc[VLNEXT] = 22; - tty.c_cc[VEOL2] = 0; - - - tty.c_line = 0; - tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; - tty.c_oflag = OPOST|ONLCR; - tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; - - ioctl(fd, TCSETA, &tty); -} - /* How much memory does this machine have? */ static int mem_total() { @@ -395,7 +350,12 @@ static void shutdown_system(void) waitfor(run( swap_off_cmd, console, FALSE)); waitfor(run( umount_cmd, console, FALSE)); sync(); - bdflush(1, 0); + message(CONSOLE, "Skipping bdflush\r\n"); + if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) { + /* bdflush, kupdate not needed for kernels >2.2.11 */ + bdflush(1, 0); + sync(); + } } static void halt_signal(int sig) @@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv) if (wpid > 0 ) { message(LOG, "pid %d exited, status=%x.\n", wpid, status); } + /* Don't respawn init script if it exits */ if (wpid == pid1) { - pid1 = 0; - if (run_rc == TRUE) { - /* Don't respawn init script if it exits, - * Start a shell instead. */ + if (run_rc == FALSE) { + pid1 = 0; + } +#if 0 +/* Turn this on to start a shell on the console if the init script exits.... */ + else { run_rc=FALSE; wait_for_enter=TRUE; tty0_commands=shell_commands; } +#endif } if (wpid == pid2) { pid2 = 0; diff --git a/init/init.c b/init/init.c index 55c5c7318..87746ef86 100644 --- a/init/init.c +++ b/init/init.c @@ -123,13 +123,6 @@ void message(int device, char *fmt, ...) void set_term( int fd) { struct termios tty; -#if 0 - static const char control_characters[] = { - '\003', '\034', '\177', '\025', '\004', '\0', - '\1', '\0', '\021', '\023', '\032', '\0', '\022', - '\017', '\027', '\026', '\0' - }; -#endif static const char control_characters[] = { '\003', '\034', '\177', '\030', '\004', '\0', '\1', '\0', '\021', '\023', '\032', '\0', '\022', @@ -160,44 +153,6 @@ void set_term( int fd) tcsetattr(fd, TCSANOW, &tty); } -/* Set terminal settings to reasonable defaults */ -void set_term_old( int fd) -{ - struct termios tty; - - ioctl(fd, TCGETA, &tty); - - tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; - tty.c_cflag |= HUPCL|CLOCAL; - - tty.c_cc[VINTR] = 3; - tty.c_cc[VQUIT] = 28; - tty.c_cc[VERASE] = 127; - //tty.c_cc[VKILL] = 21; - tty.c_cc[VKILL] = 24; - tty.c_cc[VEOF] = 4; - tty.c_cc[VTIME] = 0; - tty.c_cc[VMIN] = 1; - tty.c_cc[VSWTC] = 0; - tty.c_cc[VSTART] = 17; - tty.c_cc[VSTOP] = 19; - tty.c_cc[VSUSP] = 26; - tty.c_cc[VEOL] = 0; - tty.c_cc[VREPRINT] = 18; - tty.c_cc[VDISCARD] = 15; - tty.c_cc[VWERASE] = 23; - tty.c_cc[VLNEXT] = 22; - tty.c_cc[VEOL2] = 0; - - - tty.c_line = 0; - tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; - tty.c_oflag = OPOST|ONLCR; - tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; - - ioctl(fd, TCSETA, &tty); -} - /* How much memory does this machine have? */ static int mem_total() { @@ -395,7 +350,12 @@ static void shutdown_system(void) waitfor(run( swap_off_cmd, console, FALSE)); waitfor(run( umount_cmd, console, FALSE)); sync(); - bdflush(1, 0); + message(CONSOLE, "Skipping bdflush\r\n"); + if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) { + /* bdflush, kupdate not needed for kernels >2.2.11 */ + bdflush(1, 0); + sync(); + } } static void halt_signal(int sig) @@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv) if (wpid > 0 ) { message(LOG, "pid %d exited, status=%x.\n", wpid, status); } + /* Don't respawn init script if it exits */ if (wpid == pid1) { - pid1 = 0; - if (run_rc == TRUE) { - /* Don't respawn init script if it exits, - * Start a shell instead. */ + if (run_rc == FALSE) { + pid1 = 0; + } +#if 0 +/* Turn this on to start a shell on the console if the init script exits.... */ + else { run_rc=FALSE; wait_for_enter=TRUE; tty0_commands=shell_commands; } +#endif } if (wpid == pid2) { pid2 = 0; @@ -76,6 +76,10 @@ umount_all(int useMtab) if (strcmp (blockDevice, "/dev/root") == 0) blockDevice = (getfsfile ("/"))->fs_spec; #endif + /* Don't umount /proc when doing umount -a */ + if (strcmp (blockDevice, "proc") == 0) + continue; + status=do_umount (m->mnt_dir, useMtab); if (status!=0) { /* Don't bother retrying the umount on busy devices */ @@ -83,9 +87,6 @@ umount_all(int useMtab) perror(m->mnt_dir); continue; } - printf ("Trying to umount %s failed: %s\n", - m->mnt_dir, strerror(errno)); - printf ("Instead trying to umount %s\n", blockDevice); status=do_umount (blockDevice, useMtab); if (status!=0) { printf ("Couldn't umount %s on %s (type %s): %s\n", @@ -107,7 +108,7 @@ umount_main(int argc, char** argv) } /* Parse any options */ - while (argc-- > 0 && **(++argv) == '-') { + while (argc-- > 0 && **(argv++) == '-') { while (*++(*argv)) switch (**argv) { case 'a': umountAll = TRUE; diff --git a/util-linux/umount.c b/util-linux/umount.c index e749c5f0f..89c59f9ee 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -76,6 +76,10 @@ umount_all(int useMtab) if (strcmp (blockDevice, "/dev/root") == 0) blockDevice = (getfsfile ("/"))->fs_spec; #endif + /* Don't umount /proc when doing umount -a */ + if (strcmp (blockDevice, "proc") == 0) + continue; + status=do_umount (m->mnt_dir, useMtab); if (status!=0) { /* Don't bother retrying the umount on busy devices */ @@ -83,9 +87,6 @@ umount_all(int useMtab) perror(m->mnt_dir); continue; } - printf ("Trying to umount %s failed: %s\n", - m->mnt_dir, strerror(errno)); - printf ("Instead trying to umount %s\n", blockDevice); status=do_umount (blockDevice, useMtab); if (status!=0) { printf ("Couldn't umount %s on %s (type %s): %s\n", @@ -107,7 +108,7 @@ umount_main(int argc, char** argv) } /* Parse any options */ - while (argc-- > 0 && **(++argv) == '-') { + while (argc-- > 0 && **(argv++) == '-') { while (*++(*argv)) switch (**argv) { case 'a': umountAll = TRUE; @@ -393,7 +393,8 @@ int fullRead(int fd, char *buf, int len) * * Unfortunatly, while nftw(3) could replace this and reduce * code size a bit, nftw() wasn't supported before GNU libc 2.1, - * and so isn't sufficiently portable to take over... + * and so isn't sufficiently portable to take over since glibc2.1 + * is so stinking huge. */ int recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, @@ -404,7 +405,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir struct stat statbuf; struct dirent *next; - if (followLinks == FALSE) + if (followLinks == TRUE) status = stat(fileName, &statbuf); else status = lstat(fileName, &statbuf); @@ -414,6 +415,9 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir return (FALSE); } + if ( (followLinks == FALSE) && (S_ISLNK(statbuf.st_mode)) ) + return (TRUE); + if (recurse == FALSE) { if (S_ISDIR(statbuf.st_mode)) { if (dirAction != NULL) |