diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-19 02:38:58 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-19 02:38:58 +0000 |
commit | 08b1034f4f0b910660a8b1a537f86462fa41ebad (patch) | |
tree | 4a39b721f4654120bff47fcd7cd95906172ec16f | |
parent | ab746abfc05c28824b25e12b86a538b09fb9275d (diff) | |
download | busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.tar.gz busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.tar.bz2 busybox-w32-08b1034f4f0b910660a8b1a537f86462fa41ebad.zip |
Stuf
-rw-r--r-- | Changelog | 5 | ||||
-rw-r--r-- | archival/tar.c | 7 | ||||
-rw-r--r-- | coreutils/dd.c | 15 | ||||
-rw-r--r-- | coreutils/ls.c | 2 | ||||
-rw-r--r-- | coreutils/mkdir.c | 3 | ||||
-rw-r--r-- | coreutils/rm.c | 5 | ||||
-rw-r--r-- | dd.c | 15 | ||||
-rw-r--r-- | init.c | 35 | ||||
-rw-r--r-- | init/init.c | 35 | ||||
-rw-r--r-- | internal.h | 2 | ||||
-rw-r--r-- | ls.c | 2 | ||||
-rw-r--r-- | mkdir.c | 3 | ||||
-rw-r--r-- | more.c | 2 | ||||
-rw-r--r-- | rm.c | 5 | ||||
-rw-r--r-- | tar.c | 7 | ||||
-rw-r--r-- | util-linux/more.c | 2 | ||||
-rw-r--r-- | utility.c | 4 |
17 files changed, 101 insertions, 48 deletions
@@ -1,3 +1,8 @@ | |||
1 | 0.37 | ||
2 | * Now 'rm -R' and 'rm -r' both work. | ||
3 | |||
4 | -Erik Andrsen | ||
5 | |||
1 | 0.36 | 6 | 0.36 |
2 | * fixed dd so it properly defaults to stdin and stdout when no | 7 | * fixed dd so it properly defaults to stdin and stdout when no |
3 | if= and of= are set (fix thanks to Eric Delaunay). | 8 | if= and of= are set (fix thanks to Eric Delaunay). |
diff --git a/archival/tar.c b/archival/tar.c index 1fdbf8c1c..bbd86628a 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <signal.h> | 38 | #include <signal.h> |
39 | #include <time.h> | 39 | #include <time.h> |
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | #include <sys/sysmacros.h> | ||
41 | 42 | ||
42 | 43 | ||
43 | static const char tar_usage[] = | 44 | static const char tar_usage[] = |
@@ -276,7 +277,7 @@ static void readTarFile (int fileCount, char **fileTable) | |||
276 | * Open the tar file for reading. | 277 | * Open the tar file for reading. |
277 | */ | 278 | */ |
278 | if ((tarName == NULL) || !strcmp (tarName, "-")) { | 279 | if ((tarName == NULL) || !strcmp (tarName, "-")) { |
279 | tarFd = STDIN; | 280 | tarFd = fileno(stdin); |
280 | } else | 281 | } else |
281 | tarFd = open (tarName, O_RDONLY); | 282 | tarFd = open (tarName, O_RDONLY); |
282 | 283 | ||
@@ -552,7 +553,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) | |||
552 | * Start the output file. | 553 | * Start the output file. |
553 | */ | 554 | */ |
554 | if (tostdoutFlag == TRUE) | 555 | if (tostdoutFlag == TRUE) |
555 | outFd = STDOUT; | 556 | outFd = fileno(stdout); |
556 | else { | 557 | else { |
557 | if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) { | 558 | if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) { |
558 | devFileFlag = TRUE; | 559 | devFileFlag = TRUE; |
@@ -650,7 +651,7 @@ static void writeTarFile (int fileCount, char **fileTable) | |||
650 | */ | 651 | */ |
651 | if ((tarName == NULL) || !strcmp (tarName, "-")) { | 652 | if ((tarName == NULL) || !strcmp (tarName, "-")) { |
652 | tostdoutFlag = TRUE; | 653 | tostdoutFlag = TRUE; |
653 | tarFd = STDOUT; | 654 | tarFd = fileno(stdout); |
654 | } else | 655 | } else |
655 | tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666); | 656 | tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
656 | 657 | ||
diff --git a/coreutils/dd.c b/coreutils/dd.c index 9468cddfc..39c6a6263 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv) | |||
162 | intotal = 0; | 162 | intotal = 0; |
163 | outTotal = 0; | 163 | outTotal = 0; |
164 | 164 | ||
165 | if (inFile == NULL) | 165 | if (inFile == NULL) { |
166 | inFd = STDIN; | 166 | struct stat statBuf; |
167 | inFd = fileno(stdin); | ||
168 | if (fstat(inFd, &statBuf) < 0) | ||
169 | exit( FALSE); | ||
170 | count = statBuf.st_size; | ||
171 | } | ||
167 | else | 172 | else |
168 | inFd = open (inFile, 0); | 173 | inFd = open (inFile, 0); |
169 | 174 | ||
@@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv) | |||
174 | } | 179 | } |
175 | 180 | ||
176 | if (outFile == NULL) | 181 | if (outFile == NULL) |
177 | outFd = STDOUT; | 182 | outFd = fileno(stdout); |
178 | else | 183 | else |
179 | outFd = creat (outFile, 0666); | 184 | outFd = creat (outFile, 0666); |
180 | 185 | ||
@@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv) | |||
191 | if (inCc < 0) { | 196 | if (inCc < 0) { |
192 | perror (inFile); | 197 | perror (inFile); |
193 | goto cleanup; | 198 | goto cleanup; |
199 | } else if (inCc == 0) { | ||
200 | goto cleanup; | ||
194 | } | 201 | } |
195 | intotal += inCc; | 202 | intotal += inCc; |
196 | cp = buf; | 203 | cp = buf; |
@@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv) | |||
202 | if (outCc < 0) { | 209 | if (outCc < 0) { |
203 | perror (outFile); | 210 | perror (outFile); |
204 | goto cleanup; | 211 | goto cleanup; |
212 | } else if (outCc == 0) { | ||
213 | goto cleanup; | ||
205 | } | 214 | } |
206 | 215 | ||
207 | inCc -= outCc; | 216 | inCc -= outCc; |
diff --git a/coreutils/ls.c b/coreutils/ls.c index f09cbbc22..0558bb227 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -475,7 +475,7 @@ ls_main(int argc, char * * argv) | |||
475 | 475 | ||
476 | /* choose a display format */ | 476 | /* choose a display format */ |
477 | if (display_fmt == FMT_AUTO) | 477 | if (display_fmt == FMT_AUTO) |
478 | display_fmt = isatty(STDOUT_FILENO) ? FMT_COLUMNS : FMT_SINGLE; | 478 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; |
479 | if (argi < argc - 1) | 479 | if (argi < argc - 1) |
480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ | 480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ |
481 | #ifdef FEATURE_AUTOWIDTH | 481 | #ifdef FEATURE_AUTOWIDTH |
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c index 28315cad6..2cd178805 100644 --- a/coreutils/mkdir.c +++ b/coreutils/mkdir.c | |||
@@ -85,8 +85,9 @@ extern int mkdir_main(int argc, char **argv) | |||
85 | fprintf(stderr, "%s: File exists\n", *argv); | 85 | fprintf(stderr, "%s: File exists\n", *argv); |
86 | exit( FALSE); | 86 | exit( FALSE); |
87 | } | 87 | } |
88 | if (parentFlag == TRUE) | 88 | if (parentFlag == TRUE) { |
89 | createPath(*argv, mode); | 89 | createPath(*argv, mode); |
90 | } | ||
90 | else { | 91 | else { |
91 | if (mkdir (*argv, mode) != 0) { | 92 | if (mkdir (*argv, mode) != 0) { |
92 | perror(*argv); | 93 | perror(*argv); |
diff --git a/coreutils/rm.c b/coreutils/rm.c index ba5d30e92..ee434fb39 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c | |||
@@ -31,8 +31,8 @@ | |||
31 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" | 31 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" |
32 | "Remove (unlink) the FILE(s).\n\n" | 32 | "Remove (unlink) the FILE(s).\n\n" |
33 | "Options:\n" | 33 | "Options:\n" |
34 | "\t-f\tremove existing destinations, never prompt\n" | 34 | "\t-f\t\tremove existing destinations, never prompt\n" |
35 | "\t-r\tremove the contents of directories recursively\n"; | 35 | "\t-r or -R\tremove the contents of directories recursively\n"; |
36 | 36 | ||
37 | 37 | ||
38 | static int recursiveFlag = FALSE; | 38 | static int recursiveFlag = FALSE; |
@@ -72,6 +72,7 @@ extern int rm_main(int argc, char **argv) | |||
72 | while (**argv == '-') { | 72 | while (**argv == '-') { |
73 | while (*++(*argv)) | 73 | while (*++(*argv)) |
74 | switch (**argv) { | 74 | switch (**argv) { |
75 | case 'R': | ||
75 | case 'r': | 76 | case 'r': |
76 | recursiveFlag = TRUE; | 77 | recursiveFlag = TRUE; |
77 | break; | 78 | break; |
@@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv) | |||
162 | intotal = 0; | 162 | intotal = 0; |
163 | outTotal = 0; | 163 | outTotal = 0; |
164 | 164 | ||
165 | if (inFile == NULL) | 165 | if (inFile == NULL) { |
166 | inFd = STDIN; | 166 | struct stat statBuf; |
167 | inFd = fileno(stdin); | ||
168 | if (fstat(inFd, &statBuf) < 0) | ||
169 | exit( FALSE); | ||
170 | count = statBuf.st_size; | ||
171 | } | ||
167 | else | 172 | else |
168 | inFd = open (inFile, 0); | 173 | inFd = open (inFile, 0); |
169 | 174 | ||
@@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv) | |||
174 | } | 179 | } |
175 | 180 | ||
176 | if (outFile == NULL) | 181 | if (outFile == NULL) |
177 | outFd = STDOUT; | 182 | outFd = fileno(stdout); |
178 | else | 183 | else |
179 | outFd = creat (outFile, 0666); | 184 | outFd = creat (outFile, 0666); |
180 | 185 | ||
@@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv) | |||
191 | if (inCc < 0) { | 196 | if (inCc < 0) { |
192 | perror (inFile); | 197 | perror (inFile); |
193 | goto cleanup; | 198 | goto cleanup; |
199 | } else if (inCc == 0) { | ||
200 | goto cleanup; | ||
194 | } | 201 | } |
195 | intotal += inCc; | 202 | intotal += inCc; |
196 | cp = buf; | 203 | cp = buf; |
@@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv) | |||
202 | if (outCc < 0) { | 209 | if (outCc < 0) { |
203 | perror (outFile); | 210 | perror (outFile); |
204 | goto cleanup; | 211 | goto cleanup; |
212 | } else if (outCc == 0) { | ||
213 | goto cleanup; | ||
205 | } | 214 | } |
206 | 215 | ||
207 | inCc -= outCc; | 216 | inCc -= outCc; |
@@ -130,32 +130,40 @@ void message(int device, char *fmt, ...) | |||
130 | void set_term( int fd) | 130 | void set_term( int fd) |
131 | { | 131 | { |
132 | struct termios tty; | 132 | struct termios tty; |
133 | #if 0 | ||
133 | static const char control_characters[] = { | 134 | static const char control_characters[] = { |
134 | '\003', '\034', '\177', '\030', '\004', '\0', | 135 | '\003', '\034', '\177', '\030', '\004', '\0', |
135 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | 136 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', |
136 | '\017', '\027', '\026', '\0' | 137 | '\017', '\027', '\026', '\0' |
137 | }; | 138 | }; |
139 | #else | ||
140 | static const char control_characters[] = { | ||
141 | '\003', '\034', '\177', '\025', '\004', '\0', | ||
142 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | ||
143 | '\017', '\027', '\026', '\0' | ||
144 | }; | ||
145 | #endif | ||
138 | 146 | ||
139 | tcgetattr(fd, &tty); | 147 | tcgetattr(fd, &tty); |
140 | 148 | ||
141 | /* Make it be sane */ | 149 | /* set control chars */ |
142 | tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | 150 | memcpy(tty.c_cc, control_characters, sizeof(control_characters)); |
143 | tty.c_cflag |= HUPCL|CLOCAL; | ||
144 | |||
145 | /* input modes */ | ||
146 | tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; | ||
147 | 151 | ||
148 | /* use line dicipline 0 */ | 152 | /* use line dicipline 0 */ |
149 | tty.c_line = 0; | 153 | tty.c_line = 0; |
150 | 154 | ||
155 | /* Make it be sane */ | ||
156 | //tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | ||
157 | //tty.c_cflag |= HUPCL|CLOCAL; | ||
158 | |||
159 | /* input modes */ | ||
160 | tty.c_iflag = ICRNL|IXON|IXOFF; | ||
161 | |||
151 | /* output modes */ | 162 | /* output modes */ |
152 | tty.c_oflag = OPOST|ONLCR; | 163 | tty.c_oflag = OPOST|ONLCR; |
153 | 164 | ||
154 | /* local modes */ | 165 | /* local modes */ |
155 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; | 166 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN; |
156 | |||
157 | /* control chars */ | ||
158 | memcpy(tty.c_cc, control_characters, sizeof(control_characters)); | ||
159 | 167 | ||
160 | tcsetattr(fd, TCSANOW, &tty); | 168 | tcsetattr(fd, TCSANOW, &tty); |
161 | } | 169 | } |
@@ -210,7 +218,7 @@ static void console_init() | |||
210 | 218 | ||
211 | console = the_console; | 219 | console = the_console; |
212 | /* 2.2 kernels: identify the real console backend and try to use it */ | 220 | /* 2.2 kernels: identify the real console backend and try to use it */ |
213 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 221 | if (ioctl(0, TIOCGSERIAL, &sr) == 0) { |
214 | /* this is a serial console */ | 222 | /* this is a serial console */ |
215 | snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); | 223 | snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); |
216 | } | 224 | } |
@@ -245,6 +253,7 @@ static void console_init() | |||
245 | /* check for serial console and disable logging to tty3 & running a | 253 | /* check for serial console and disable logging to tty3 & running a |
246 | * shell to tty2 */ | 254 | * shell to tty2 */ |
247 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 255 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { |
256 | message(LOG|CONSOLE, "serial console detected. Disabling 2nd virtual terminal.\r\n", console ); | ||
248 | log = NULL; | 257 | log = NULL; |
249 | second_console = NULL; | 258 | second_console = NULL; |
250 | } | 259 | } |
@@ -362,7 +371,7 @@ static void shutdown_system(void) | |||
362 | /* Allow Ctrl-Alt-Del to reboot system. */ | 371 | /* Allow Ctrl-Alt-Del to reboot system. */ |
363 | reboot(RB_ENABLE_CAD); | 372 | reboot(RB_ENABLE_CAD); |
364 | #endif | 373 | #endif |
365 | message(CONSOLE, "The system is going down NOW !!\r\n"); | 374 | message(CONSOLE, "\r\nThe system is going down NOW !!\r\n"); |
366 | sync(); | 375 | sync(); |
367 | /* Send signals to every process _except_ pid 1 */ | 376 | /* Send signals to every process _except_ pid 1 */ |
368 | message(CONSOLE, "Sending SIGHUP to all processes.\r\n"); | 377 | message(CONSOLE, "Sending SIGHUP to all processes.\r\n"); |
@@ -376,7 +385,9 @@ static void shutdown_system(void) | |||
376 | kill(-1, SIGKILL); | 385 | kill(-1, SIGKILL); |
377 | #endif | 386 | #endif |
378 | sleep(1); | 387 | sleep(1); |
388 | message(CONSOLE, "Disabling swap.\r\n"); | ||
379 | waitfor(run( swap_off_cmd, console, FALSE)); | 389 | waitfor(run( swap_off_cmd, console, FALSE)); |
390 | message(CONSOLE, "Unmounting filesystems.\r\n"); | ||
380 | waitfor(run( umount_cmd, console, FALSE)); | 391 | waitfor(run( umount_cmd, console, FALSE)); |
381 | sync(); | 392 | sync(); |
382 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { | 393 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { |
diff --git a/init/init.c b/init/init.c index f6e9eff97..ce2f237c7 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -130,32 +130,40 @@ void message(int device, char *fmt, ...) | |||
130 | void set_term( int fd) | 130 | void set_term( int fd) |
131 | { | 131 | { |
132 | struct termios tty; | 132 | struct termios tty; |
133 | #if 0 | ||
133 | static const char control_characters[] = { | 134 | static const char control_characters[] = { |
134 | '\003', '\034', '\177', '\030', '\004', '\0', | 135 | '\003', '\034', '\177', '\030', '\004', '\0', |
135 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | 136 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', |
136 | '\017', '\027', '\026', '\0' | 137 | '\017', '\027', '\026', '\0' |
137 | }; | 138 | }; |
139 | #else | ||
140 | static const char control_characters[] = { | ||
141 | '\003', '\034', '\177', '\025', '\004', '\0', | ||
142 | '\1', '\0', '\021', '\023', '\032', '\0', '\022', | ||
143 | '\017', '\027', '\026', '\0' | ||
144 | }; | ||
145 | #endif | ||
138 | 146 | ||
139 | tcgetattr(fd, &tty); | 147 | tcgetattr(fd, &tty); |
140 | 148 | ||
141 | /* Make it be sane */ | 149 | /* set control chars */ |
142 | tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | 150 | memcpy(tty.c_cc, control_characters, sizeof(control_characters)); |
143 | tty.c_cflag |= HUPCL|CLOCAL; | ||
144 | |||
145 | /* input modes */ | ||
146 | tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY; | ||
147 | 151 | ||
148 | /* use line dicipline 0 */ | 152 | /* use line dicipline 0 */ |
149 | tty.c_line = 0; | 153 | tty.c_line = 0; |
150 | 154 | ||
155 | /* Make it be sane */ | ||
156 | //tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD; | ||
157 | //tty.c_cflag |= HUPCL|CLOCAL; | ||
158 | |||
159 | /* input modes */ | ||
160 | tty.c_iflag = ICRNL|IXON|IXOFF; | ||
161 | |||
151 | /* output modes */ | 162 | /* output modes */ |
152 | tty.c_oflag = OPOST|ONLCR; | 163 | tty.c_oflag = OPOST|ONLCR; |
153 | 164 | ||
154 | /* local modes */ | 165 | /* local modes */ |
155 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN; | 166 | tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN; |
156 | |||
157 | /* control chars */ | ||
158 | memcpy(tty.c_cc, control_characters, sizeof(control_characters)); | ||
159 | 167 | ||
160 | tcsetattr(fd, TCSANOW, &tty); | 168 | tcsetattr(fd, TCSANOW, &tty); |
161 | } | 169 | } |
@@ -210,7 +218,7 @@ static void console_init() | |||
210 | 218 | ||
211 | console = the_console; | 219 | console = the_console; |
212 | /* 2.2 kernels: identify the real console backend and try to use it */ | 220 | /* 2.2 kernels: identify the real console backend and try to use it */ |
213 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 221 | if (ioctl(0, TIOCGSERIAL, &sr) == 0) { |
214 | /* this is a serial console */ | 222 | /* this is a serial console */ |
215 | snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); | 223 | snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line ); |
216 | } | 224 | } |
@@ -245,6 +253,7 @@ static void console_init() | |||
245 | /* check for serial console and disable logging to tty3 & running a | 253 | /* check for serial console and disable logging to tty3 & running a |
246 | * shell to tty2 */ | 254 | * shell to tty2 */ |
247 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { | 255 | if (ioctl(0,TIOCGSERIAL,&sr) == 0) { |
256 | message(LOG|CONSOLE, "serial console detected. Disabling 2nd virtual terminal.\r\n", console ); | ||
248 | log = NULL; | 257 | log = NULL; |
249 | second_console = NULL; | 258 | second_console = NULL; |
250 | } | 259 | } |
@@ -362,7 +371,7 @@ static void shutdown_system(void) | |||
362 | /* Allow Ctrl-Alt-Del to reboot system. */ | 371 | /* Allow Ctrl-Alt-Del to reboot system. */ |
363 | reboot(RB_ENABLE_CAD); | 372 | reboot(RB_ENABLE_CAD); |
364 | #endif | 373 | #endif |
365 | message(CONSOLE, "The system is going down NOW !!\r\n"); | 374 | message(CONSOLE, "\r\nThe system is going down NOW !!\r\n"); |
366 | sync(); | 375 | sync(); |
367 | /* Send signals to every process _except_ pid 1 */ | 376 | /* Send signals to every process _except_ pid 1 */ |
368 | message(CONSOLE, "Sending SIGHUP to all processes.\r\n"); | 377 | message(CONSOLE, "Sending SIGHUP to all processes.\r\n"); |
@@ -376,7 +385,9 @@ static void shutdown_system(void) | |||
376 | kill(-1, SIGKILL); | 385 | kill(-1, SIGKILL); |
377 | #endif | 386 | #endif |
378 | sleep(1); | 387 | sleep(1); |
388 | message(CONSOLE, "Disabling swap.\r\n"); | ||
379 | waitfor(run( swap_off_cmd, console, FALSE)); | 389 | waitfor(run( swap_off_cmd, console, FALSE)); |
390 | message(CONSOLE, "Unmounting filesystems.\r\n"); | ||
380 | waitfor(run( umount_cmd, console, FALSE)); | 391 | waitfor(run( umount_cmd, console, FALSE)); |
381 | sync(); | 392 | sync(); |
382 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { | 393 | if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) { |
diff --git a/internal.h b/internal.h index 0317ed919..feaea6339 100644 --- a/internal.h +++ b/internal.h | |||
@@ -33,8 +33,6 @@ | |||
33 | 33 | ||
34 | 34 | ||
35 | /* Some useful definitions */ | 35 | /* Some useful definitions */ |
36 | #define STDIN 0 | ||
37 | #define STDOUT 1 | ||
38 | #define FALSE ((int) 1) | 36 | #define FALSE ((int) 1) |
39 | #define TRUE ((int) 0) | 37 | #define TRUE ((int) 0) |
40 | 38 | ||
@@ -475,7 +475,7 @@ ls_main(int argc, char * * argv) | |||
475 | 475 | ||
476 | /* choose a display format */ | 476 | /* choose a display format */ |
477 | if (display_fmt == FMT_AUTO) | 477 | if (display_fmt == FMT_AUTO) |
478 | display_fmt = isatty(STDOUT_FILENO) ? FMT_COLUMNS : FMT_SINGLE; | 478 | display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE; |
479 | if (argi < argc - 1) | 479 | if (argi < argc - 1) |
480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ | 480 | opts |= DISP_DIRNAME; /* 2 or more items? label directories */ |
481 | #ifdef FEATURE_AUTOWIDTH | 481 | #ifdef FEATURE_AUTOWIDTH |
@@ -85,8 +85,9 @@ extern int mkdir_main(int argc, char **argv) | |||
85 | fprintf(stderr, "%s: File exists\n", *argv); | 85 | fprintf(stderr, "%s: File exists\n", *argv); |
86 | exit( FALSE); | 86 | exit( FALSE); |
87 | } | 87 | } |
88 | if (parentFlag == TRUE) | 88 | if (parentFlag == TRUE) { |
89 | createPath(*argv, mode); | 89 | createPath(*argv, mode); |
90 | } | ||
90 | else { | 91 | else { |
91 | if (mkdir (*argv, mode) != 0) { | 92 | if (mkdir (*argv, mode) != 0) { |
92 | perror(*argv); | 93 | perror(*argv); |
@@ -122,7 +122,7 @@ extern int more_main(int argc, char **argv) | |||
122 | stty(fileno(cin), &new_settings); | 122 | stty(fileno(cin), &new_settings); |
123 | 123 | ||
124 | #ifdef BB_FEATURE_AUTOWIDTH | 124 | #ifdef BB_FEATURE_AUTOWIDTH |
125 | ioctl(STDOUT_FILENO, TIOCGWINSZ, &win); | 125 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |
126 | if (win.ws_row > 4) | 126 | if (win.ws_row > 4) |
127 | terminal_height = win.ws_row - 2; | 127 | terminal_height = win.ws_row - 2; |
128 | if (win.ws_col > 0) | 128 | if (win.ws_col > 0) |
@@ -31,8 +31,8 @@ | |||
31 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" | 31 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" |
32 | "Remove (unlink) the FILE(s).\n\n" | 32 | "Remove (unlink) the FILE(s).\n\n" |
33 | "Options:\n" | 33 | "Options:\n" |
34 | "\t-f\tremove existing destinations, never prompt\n" | 34 | "\t-f\t\tremove existing destinations, never prompt\n" |
35 | "\t-r\tremove the contents of directories recursively\n"; | 35 | "\t-r or -R\tremove the contents of directories recursively\n"; |
36 | 36 | ||
37 | 37 | ||
38 | static int recursiveFlag = FALSE; | 38 | static int recursiveFlag = FALSE; |
@@ -72,6 +72,7 @@ extern int rm_main(int argc, char **argv) | |||
72 | while (**argv == '-') { | 72 | while (**argv == '-') { |
73 | while (*++(*argv)) | 73 | while (*++(*argv)) |
74 | switch (**argv) { | 74 | switch (**argv) { |
75 | case 'R': | ||
75 | case 'r': | 76 | case 'r': |
76 | recursiveFlag = TRUE; | 77 | recursiveFlag = TRUE; |
77 | break; | 78 | break; |
@@ -38,6 +38,7 @@ | |||
38 | #include <signal.h> | 38 | #include <signal.h> |
39 | #include <time.h> | 39 | #include <time.h> |
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | #include <sys/sysmacros.h> | ||
41 | 42 | ||
42 | 43 | ||
43 | static const char tar_usage[] = | 44 | static const char tar_usage[] = |
@@ -276,7 +277,7 @@ static void readTarFile (int fileCount, char **fileTable) | |||
276 | * Open the tar file for reading. | 277 | * Open the tar file for reading. |
277 | */ | 278 | */ |
278 | if ((tarName == NULL) || !strcmp (tarName, "-")) { | 279 | if ((tarName == NULL) || !strcmp (tarName, "-")) { |
279 | tarFd = STDIN; | 280 | tarFd = fileno(stdin); |
280 | } else | 281 | } else |
281 | tarFd = open (tarName, O_RDONLY); | 282 | tarFd = open (tarName, O_RDONLY); |
282 | 283 | ||
@@ -552,7 +553,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable) | |||
552 | * Start the output file. | 553 | * Start the output file. |
553 | */ | 554 | */ |
554 | if (tostdoutFlag == TRUE) | 555 | if (tostdoutFlag == TRUE) |
555 | outFd = STDOUT; | 556 | outFd = fileno(stdout); |
556 | else { | 557 | else { |
557 | if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) { | 558 | if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) { |
558 | devFileFlag = TRUE; | 559 | devFileFlag = TRUE; |
@@ -650,7 +651,7 @@ static void writeTarFile (int fileCount, char **fileTable) | |||
650 | */ | 651 | */ |
651 | if ((tarName == NULL) || !strcmp (tarName, "-")) { | 652 | if ((tarName == NULL) || !strcmp (tarName, "-")) { |
652 | tostdoutFlag = TRUE; | 653 | tostdoutFlag = TRUE; |
653 | tarFd = STDOUT; | 654 | tarFd = fileno(stdout); |
654 | } else | 655 | } else |
655 | tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666); | 656 | tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666); |
656 | 657 | ||
diff --git a/util-linux/more.c b/util-linux/more.c index 7d0ddb8ec..7fbca2317 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -122,7 +122,7 @@ extern int more_main(int argc, char **argv) | |||
122 | stty(fileno(cin), &new_settings); | 122 | stty(fileno(cin), &new_settings); |
123 | 123 | ||
124 | #ifdef BB_FEATURE_AUTOWIDTH | 124 | #ifdef BB_FEATURE_AUTOWIDTH |
125 | ioctl(STDOUT_FILENO, TIOCGWINSZ, &win); | 125 | ioctl(fileno(stdout), TIOCGWINSZ, &win); |
126 | if (win.ws_row > 4) | 126 | if (win.ws_row > 4) |
127 | terminal_height = win.ws_row - 2; | 127 | terminal_height = win.ws_row - 2; |
128 | if (win.ws_col > 0) | 128 | if (win.ws_col > 0) |
@@ -482,6 +482,10 @@ extern void createPath (const char *name, int mode) | |||
482 | char buf[NAME_MAX]; | 482 | char buf[NAME_MAX]; |
483 | 483 | ||
484 | strcpy (buf, name); | 484 | strcpy (buf, name); |
485 | if (buf[strlen(buf)]!='/') { | ||
486 | buf[strlen(buf)] = '/'; | ||
487 | buf[strlen(buf)+1] = '\0'; | ||
488 | } | ||
485 | 489 | ||
486 | cp = strchr (buf, '/'); | 490 | cp = strchr (buf, '/'); |
487 | 491 | ||