diff options
-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 @@ | |||
9 | * Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!). | 9 | * Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!). |
10 | * Fixed a stupid seg-fault in sync | 10 | * Fixed a stupid seg-fault in sync |
11 | * Fixed mount -- mount -a failed to parse and apply mount options | 11 | * Fixed mount -- mount -a failed to parse and apply mount options |
12 | * Fixed umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>) | ||
13 | * umount -a no longer umounts /proc | ||
12 | * Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc) | 14 | * Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc) |
13 | folks to use a real /etc/mtab file instead of a symlink to /proc/mounts. | 15 | folks to use a real /etc/mtab file instead of a symlink to /proc/mounts. |
14 | mount, and umount will add/remove entries and df will now use /etc/mtab | 16 | mount, and umount will add/remove entries and df will now use /etc/mtab |
15 | if BB_MTAB is defined. | 17 | if BB_MTAB is defined. |
18 | * Fixed a nice bug in recursiveAction() which caused it to infinitely | ||
19 | hunt through /proc/../fd/* creating new file descriptors if it | ||
20 | followed the /dev/fd link over to /proc. recursiveAction() now | ||
21 | lstat's the file when followLinks==FALSE so it won't follow links | ||
22 | as the name suggests. Fix thanks to Matt Porter <porter@debian.org>. | ||
23 | |||
16 | 24 | ||
17 | -Erik Andersen | 25 | -Erik Andersen |
18 | 26 | ||
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 @@ | |||
38 | #define BB_MORE | 38 | #define BB_MORE |
39 | #define BB_MOUNT | 39 | #define BB_MOUNT |
40 | //#define BB_MT | 40 | //#define BB_MT |
41 | #define BB_MTAB | 41 | //#define BB_MTAB |
42 | #define BB_MV | 42 | #define BB_MV |
43 | //#define BB_PRINTF | 43 | //#define BB_PRINTF |
44 | #define BB_PS | 44 | #define BB_PS |
@@ -123,13 +123,6 @@ void message(int device, char *fmt, ...) | |||
123 | void set_term( int fd) | 123 | void set_term( int fd) |
124 | { | 124 | { |
125 | struct termios tty; | 125 | struct termios tty; |
126 | #if 0 | ||
127 | static const char control_characters[] = { | ||
128 | '\003', '\034', '\177', '\025', '\004', '\0', | ||
129 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | ||
130 | '\017', '\027', '\026', '\0' | ||
131 | }; | ||
132 | #endif | ||
133 | static const char control_characters[] = { | 126 | static const char control_characters[] = { |
134 | '\003', '\034', '\177', '\030', '\004', '\0', | 127 | '\003', '\034', '\177', '\030', '\004', '\0', |
135 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | 128 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', |
@@ -160,44 +153,6 @@ void set_term( int fd) | |||
160 | tcsetattr(fd, TCSANOW, &tty); | 153 | tcsetattr(fd, TCSANOW, &tty); |
161 | } | 154 | } |
162 | 155 | ||
163 | /* Set terminal settings to reasonable defaults */ | ||
164 | void set_term_old( int fd) | ||
165 | { | ||
166 | struct termios tty; | ||
167 | |||
168 | ioctl(fd, TCGETA, &tty); | ||
169 | |||
170 | tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | ||
171 | tty.c_cflag |= HUPCL|CLOCAL; | ||
172 | |||
173 | tty.c_cc[VINTR] = 3; | ||
174 | tty.c_cc[VQUIT] = 28; | ||
175 | tty.c_cc[VERASE] = 127; | ||
176 | //tty.c_cc[VKILL] = 21; | ||
177 | tty.c_cc[VKILL] = 24; | ||
178 | tty.c_cc[VEOF] = 4; | ||
179 | tty.c_cc[VTIME] = 0; | ||
180 | tty.c_cc[VMIN] = 1; | ||
181 | tty.c_cc[VSWTC] = 0; | ||
182 | tty.c_cc[VSTART] = 17; | ||
183 | tty.c_cc[VSTOP] = 19; | ||
184 | tty.c_cc[VSUSP] = 26; | ||
185 | tty.c_cc[VEOL] = 0; | ||
186 | tty.c_cc[VREPRINT] = 18; | ||
187 | tty.c_cc[VDISCARD] = 15; | ||
188 | tty.c_cc[VWERASE] = 23; | ||
189 | tty.c_cc[VLNEXT] = 22; | ||
190 | tty.c_cc[VEOL2] = 0; | ||
191 | |||
192 | |||
193 | tty.c_line = 0; | ||
194 | tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; | ||
195 | tty.c_oflag = OPOST|ONLCR; | ||
196 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; | ||
197 | |||
198 | ioctl(fd, TCSETA, &tty); | ||
199 | } | ||
200 | |||
201 | /* How much memory does this machine have? */ | 156 | /* How much memory does this machine have? */ |
202 | static int mem_total() | 157 | static int mem_total() |
203 | { | 158 | { |
@@ -395,7 +350,12 @@ static void shutdown_system(void) | |||
395 | waitfor(run( swap_off_cmd, console, FALSE)); | 350 | waitfor(run( swap_off_cmd, console, FALSE)); |
396 | waitfor(run( umount_cmd, console, FALSE)); | 351 | waitfor(run( umount_cmd, console, FALSE)); |
397 | sync(); | 352 | sync(); |
398 | bdflush(1, 0); | 353 | message(CONSOLE, "Skipping bdflush\r\n"); |
354 | if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) { | ||
355 | /* bdflush, kupdate not needed for kernels >2.2.11 */ | ||
356 | bdflush(1, 0); | ||
357 | sync(); | ||
358 | } | ||
399 | } | 359 | } |
400 | 360 | ||
401 | static void halt_signal(int sig) | 361 | static void halt_signal(int sig) |
@@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv) | |||
518 | if (wpid > 0 ) { | 478 | if (wpid > 0 ) { |
519 | message(LOG, "pid %d exited, status=%x.\n", wpid, status); | 479 | message(LOG, "pid %d exited, status=%x.\n", wpid, status); |
520 | } | 480 | } |
481 | /* Don't respawn init script if it exits */ | ||
521 | if (wpid == pid1) { | 482 | if (wpid == pid1) { |
522 | pid1 = 0; | 483 | if (run_rc == FALSE) { |
523 | if (run_rc == TRUE) { | 484 | pid1 = 0; |
524 | /* Don't respawn init script if it exits, | 485 | } |
525 | * Start a shell instead. */ | 486 | #if 0 |
487 | /* Turn this on to start a shell on the console if the init script exits.... */ | ||
488 | else { | ||
526 | run_rc=FALSE; | 489 | run_rc=FALSE; |
527 | wait_for_enter=TRUE; | 490 | wait_for_enter=TRUE; |
528 | tty0_commands=shell_commands; | 491 | tty0_commands=shell_commands; |
529 | } | 492 | } |
493 | #endif | ||
530 | } | 494 | } |
531 | if (wpid == pid2) { | 495 | if (wpid == pid2) { |
532 | pid2 = 0; | 496 | 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, ...) | |||
123 | void set_term( int fd) | 123 | void set_term( int fd) |
124 | { | 124 | { |
125 | struct termios tty; | 125 | struct termios tty; |
126 | #if 0 | ||
127 | static const char control_characters[] = { | ||
128 | '\003', '\034', '\177', '\025', '\004', '\0', | ||
129 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | ||
130 | '\017', '\027', '\026', '\0' | ||
131 | }; | ||
132 | #endif | ||
133 | static const char control_characters[] = { | 126 | static const char control_characters[] = { |
134 | '\003', '\034', '\177', '\030', '\004', '\0', | 127 | '\003', '\034', '\177', '\030', '\004', '\0', |
135 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | 128 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', |
@@ -160,44 +153,6 @@ void set_term( int fd) | |||
160 | tcsetattr(fd, TCSANOW, &tty); | 153 | tcsetattr(fd, TCSANOW, &tty); |
161 | } | 154 | } |
162 | 155 | ||
163 | /* Set terminal settings to reasonable defaults */ | ||
164 | void set_term_old( int fd) | ||
165 | { | ||
166 | struct termios tty; | ||
167 | |||
168 | ioctl(fd, TCGETA, &tty); | ||
169 | |||
170 | tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | ||
171 | tty.c_cflag |= HUPCL|CLOCAL; | ||
172 | |||
173 | tty.c_cc[VINTR] = 3; | ||
174 | tty.c_cc[VQUIT] = 28; | ||
175 | tty.c_cc[VERASE] = 127; | ||
176 | //tty.c_cc[VKILL] = 21; | ||
177 | tty.c_cc[VKILL] = 24; | ||
178 | tty.c_cc[VEOF] = 4; | ||
179 | tty.c_cc[VTIME] = 0; | ||
180 | tty.c_cc[VMIN] = 1; | ||
181 | tty.c_cc[VSWTC] = 0; | ||
182 | tty.c_cc[VSTART] = 17; | ||
183 | tty.c_cc[VSTOP] = 19; | ||
184 | tty.c_cc[VSUSP] = 26; | ||
185 | tty.c_cc[VEOL] = 0; | ||
186 | tty.c_cc[VREPRINT] = 18; | ||
187 | tty.c_cc[VDISCARD] = 15; | ||
188 | tty.c_cc[VWERASE] = 23; | ||
189 | tty.c_cc[VLNEXT] = 22; | ||
190 | tty.c_cc[VEOL2] = 0; | ||
191 | |||
192 | |||
193 | tty.c_line = 0; | ||
194 | tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; | ||
195 | tty.c_oflag = OPOST|ONLCR; | ||
196 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; | ||
197 | |||
198 | ioctl(fd, TCSETA, &tty); | ||
199 | } | ||
200 | |||
201 | /* How much memory does this machine have? */ | 156 | /* How much memory does this machine have? */ |
202 | static int mem_total() | 157 | static int mem_total() |
203 | { | 158 | { |
@@ -395,7 +350,12 @@ static void shutdown_system(void) | |||
395 | waitfor(run( swap_off_cmd, console, FALSE)); | 350 | waitfor(run( swap_off_cmd, console, FALSE)); |
396 | waitfor(run( umount_cmd, console, FALSE)); | 351 | waitfor(run( umount_cmd, console, FALSE)); |
397 | sync(); | 352 | sync(); |
398 | bdflush(1, 0); | 353 | message(CONSOLE, "Skipping bdflush\r\n"); |
354 | if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) { | ||
355 | /* bdflush, kupdate not needed for kernels >2.2.11 */ | ||
356 | bdflush(1, 0); | ||
357 | sync(); | ||
358 | } | ||
399 | } | 359 | } |
400 | 360 | ||
401 | static void halt_signal(int sig) | 361 | static void halt_signal(int sig) |
@@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv) | |||
518 | if (wpid > 0 ) { | 478 | if (wpid > 0 ) { |
519 | message(LOG, "pid %d exited, status=%x.\n", wpid, status); | 479 | message(LOG, "pid %d exited, status=%x.\n", wpid, status); |
520 | } | 480 | } |
481 | /* Don't respawn init script if it exits */ | ||
521 | if (wpid == pid1) { | 482 | if (wpid == pid1) { |
522 | pid1 = 0; | 483 | if (run_rc == FALSE) { |
523 | if (run_rc == TRUE) { | 484 | pid1 = 0; |
524 | /* Don't respawn init script if it exits, | 485 | } |
525 | * Start a shell instead. */ | 486 | #if 0 |
487 | /* Turn this on to start a shell on the console if the init script exits.... */ | ||
488 | else { | ||
526 | run_rc=FALSE; | 489 | run_rc=FALSE; |
527 | wait_for_enter=TRUE; | 490 | wait_for_enter=TRUE; |
528 | tty0_commands=shell_commands; | 491 | tty0_commands=shell_commands; |
529 | } | 492 | } |
493 | #endif | ||
530 | } | 494 | } |
531 | if (wpid == pid2) { | 495 | if (wpid == pid2) { |
532 | pid2 = 0; | 496 | pid2 = 0; |
@@ -76,6 +76,10 @@ umount_all(int useMtab) | |||
76 | if (strcmp (blockDevice, "/dev/root") == 0) | 76 | if (strcmp (blockDevice, "/dev/root") == 0) |
77 | blockDevice = (getfsfile ("/"))->fs_spec; | 77 | blockDevice = (getfsfile ("/"))->fs_spec; |
78 | #endif | 78 | #endif |
79 | /* Don't umount /proc when doing umount -a */ | ||
80 | if (strcmp (blockDevice, "proc") == 0) | ||
81 | continue; | ||
82 | |||
79 | status=do_umount (m->mnt_dir, useMtab); | 83 | status=do_umount (m->mnt_dir, useMtab); |
80 | if (status!=0) { | 84 | if (status!=0) { |
81 | /* Don't bother retrying the umount on busy devices */ | 85 | /* Don't bother retrying the umount on busy devices */ |
@@ -83,9 +87,6 @@ umount_all(int useMtab) | |||
83 | perror(m->mnt_dir); | 87 | perror(m->mnt_dir); |
84 | continue; | 88 | continue; |
85 | } | 89 | } |
86 | printf ("Trying to umount %s failed: %s\n", | ||
87 | m->mnt_dir, strerror(errno)); | ||
88 | printf ("Instead trying to umount %s\n", blockDevice); | ||
89 | status=do_umount (blockDevice, useMtab); | 90 | status=do_umount (blockDevice, useMtab); |
90 | if (status!=0) { | 91 | if (status!=0) { |
91 | printf ("Couldn't umount %s on %s (type %s): %s\n", | 92 | printf ("Couldn't umount %s on %s (type %s): %s\n", |
@@ -107,7 +108,7 @@ umount_main(int argc, char** argv) | |||
107 | } | 108 | } |
108 | 109 | ||
109 | /* Parse any options */ | 110 | /* Parse any options */ |
110 | while (argc-- > 0 && **(++argv) == '-') { | 111 | while (argc-- > 0 && **(argv++) == '-') { |
111 | while (*++(*argv)) switch (**argv) { | 112 | while (*++(*argv)) switch (**argv) { |
112 | case 'a': | 113 | case 'a': |
113 | umountAll = TRUE; | 114 | 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) | |||
76 | if (strcmp (blockDevice, "/dev/root") == 0) | 76 | if (strcmp (blockDevice, "/dev/root") == 0) |
77 | blockDevice = (getfsfile ("/"))->fs_spec; | 77 | blockDevice = (getfsfile ("/"))->fs_spec; |
78 | #endif | 78 | #endif |
79 | /* Don't umount /proc when doing umount -a */ | ||
80 | if (strcmp (blockDevice, "proc") == 0) | ||
81 | continue; | ||
82 | |||
79 | status=do_umount (m->mnt_dir, useMtab); | 83 | status=do_umount (m->mnt_dir, useMtab); |
80 | if (status!=0) { | 84 | if (status!=0) { |
81 | /* Don't bother retrying the umount on busy devices */ | 85 | /* Don't bother retrying the umount on busy devices */ |
@@ -83,9 +87,6 @@ umount_all(int useMtab) | |||
83 | perror(m->mnt_dir); | 87 | perror(m->mnt_dir); |
84 | continue; | 88 | continue; |
85 | } | 89 | } |
86 | printf ("Trying to umount %s failed: %s\n", | ||
87 | m->mnt_dir, strerror(errno)); | ||
88 | printf ("Instead trying to umount %s\n", blockDevice); | ||
89 | status=do_umount (blockDevice, useMtab); | 90 | status=do_umount (blockDevice, useMtab); |
90 | if (status!=0) { | 91 | if (status!=0) { |
91 | printf ("Couldn't umount %s on %s (type %s): %s\n", | 92 | printf ("Couldn't umount %s on %s (type %s): %s\n", |
@@ -107,7 +108,7 @@ umount_main(int argc, char** argv) | |||
107 | } | 108 | } |
108 | 109 | ||
109 | /* Parse any options */ | 110 | /* Parse any options */ |
110 | while (argc-- > 0 && **(++argv) == '-') { | 111 | while (argc-- > 0 && **(argv++) == '-') { |
111 | while (*++(*argv)) switch (**argv) { | 112 | while (*++(*argv)) switch (**argv) { |
112 | case 'a': | 113 | case 'a': |
113 | umountAll = TRUE; | 114 | umountAll = TRUE; |
@@ -393,7 +393,8 @@ int fullRead(int fd, char *buf, int len) | |||
393 | * | 393 | * |
394 | * Unfortunatly, while nftw(3) could replace this and reduce | 394 | * Unfortunatly, while nftw(3) could replace this and reduce |
395 | * code size a bit, nftw() wasn't supported before GNU libc 2.1, | 395 | * code size a bit, nftw() wasn't supported before GNU libc 2.1, |
396 | * and so isn't sufficiently portable to take over... | 396 | * and so isn't sufficiently portable to take over since glibc2.1 |
397 | * is so stinking huge. | ||
397 | */ | 398 | */ |
398 | int | 399 | int |
399 | recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, | 400 | recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst, |
@@ -404,7 +405,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
404 | struct stat statbuf; | 405 | struct stat statbuf; |
405 | struct dirent *next; | 406 | struct dirent *next; |
406 | 407 | ||
407 | if (followLinks == FALSE) | 408 | if (followLinks == TRUE) |
408 | status = stat(fileName, &statbuf); | 409 | status = stat(fileName, &statbuf); |
409 | else | 410 | else |
410 | status = lstat(fileName, &statbuf); | 411 | status = lstat(fileName, &statbuf); |
@@ -414,6 +415,9 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir | |||
414 | return (FALSE); | 415 | return (FALSE); |
415 | } | 416 | } |
416 | 417 | ||
418 | if ( (followLinks == FALSE) && (S_ISLNK(statbuf.st_mode)) ) | ||
419 | return (TRUE); | ||
420 | |||
417 | if (recurse == FALSE) { | 421 | if (recurse == FALSE) { |
418 | if (S_ISDIR(statbuf.st_mode)) { | 422 | if (S_ISDIR(statbuf.st_mode)) { |
419 | if (dirAction != NULL) | 423 | if (dirAction != NULL) |