aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Andersen <andersen@codepoet.org>2000-01-23 18:19:02 +0000
committerErik Andersen <andersen@codepoet.org>2000-01-23 18:19:02 +0000
commit5509af7073ffff75d86ff8c67a2075169a859efd (patch)
tree2728cbb296484026cb657f92f78e1bb0806ba6f4
parent9bc7e89fc1eb493c06494ad86781ab49fc28c509 (diff)
downloadbusybox-w32-5509af7073ffff75d86ff8c67a2075169a859efd.tar.gz
busybox-w32-5509af7073ffff75d86ff8c67a2075169a859efd.tar.bz2
busybox-w32-5509af7073ffff75d86ff8c67a2075169a859efd.zip
* added (and documented) "-n" option for head -
contributed Friedrich Vedder <fwv@myrtle.lahn.de> * Cleanup for a number of usage messages -- also contributed Friedrich Vedder <fwv@myrtle.lahn.de> -Erik
-rw-r--r--Changelog4
-rw-r--r--archival/tar.c2
-rw-r--r--coreutils/du.c4
-rw-r--r--coreutils/head.c28
-rw-r--r--coreutils/mkdir.c3
-rw-r--r--coreutils/sort.c4
-rw-r--r--coreutils/uniq.c4
-rw-r--r--coreutils/wc.c1
-rw-r--r--du.c4
-rw-r--r--head.c28
-rw-r--r--internal.h3
-rw-r--r--mkdir.c3
-rw-r--r--mount.c54
-rw-r--r--sfdisk.c8
-rw-r--r--sort.c4
-rw-r--r--tar.c2
-rw-r--r--umount.c2
-rw-r--r--uniq.c4
-rw-r--r--util-linux/mount.c54
-rw-r--r--util-linux/umount.c2
-rw-r--r--wc.c1
21 files changed, 112 insertions, 107 deletions
diff --git a/Changelog b/Changelog
index 493c9c2f8..673d1aafd 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,10 @@
15 * Optional support contributed by Ben Collins <bcollins@debian.org> 15 * Optional support contributed by Ben Collins <bcollins@debian.org>
16 for the kernel init chroot patch by Werner Almesberger, which 16 for the kernel init chroot patch by Werner Almesberger, which
17 allows init to chroot to a new device, and umount the old one. 17 allows init to chroot to a new device, and umount the old one.
18 * added (and documented) "-n" option for head -
19 contributed Friedrich Vedder <fwv@myrtle.lahn.de>
20 * Cleanup for a number of usage messages -- also
21 contributed Friedrich Vedder <fwv@myrtle.lahn.de>
18 * Fixed bug that wouldn't let one chown a symlink -- it would 22 * Fixed bug that wouldn't let one chown a symlink -- it would
19 always dereference before. -beppu 23 always dereference before. -beppu
20 24
diff --git a/archival/tar.c b/archival/tar.c
index 21ef24dcb..aedb36a23 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -54,7 +54,7 @@ static const char tar_usage[] =
54#else 54#else
55 55
56static const char tar_usage[] = 56static const char tar_usage[] =
57"tar -[cxtvOf] [tarFileName] [FILE] ...\n\n" 57"tar -[xtvOf] [tarFileName] [FILE] ...\n\n"
58"Extract, or list files stored in a tar file. This\n" 58"Extract, or list files stored in a tar file. This\n"
59"version of tar does not support creation of tar files.\n\n" 59"version of tar does not support creation of tar files.\n\n"
60"Options:\n" 60"Options:\n"
diff --git a/coreutils/du.c b/coreutils/du.c
index ec03afd95..79b553643 100644
--- a/coreutils/du.c
+++ b/coreutils/du.c
@@ -35,7 +35,7 @@
35typedef void (Display)(size_t, char *); 35typedef void (Display)(size_t, char *);
36 36
37static const char du_usage[] = 37static const char du_usage[] =
38"Usage: du [OPTION]... [FILE]...\n\n" 38"du [OPTION]... [FILE]...\n\n"
39"\t-s\tdisplay only a total for each argument\n" 39"\t-s\tdisplay only a total for each argument\n"
40; 40;
41 41
@@ -140,4 +140,4 @@ du_main(int argc, char **argv)
140 exit(0); 140 exit(0);
141} 141}
142 142
143/* $Id: du.c,v 1.8 1999/12/17 18:44:15 erik Exp $ */ 143/* $Id: du.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/head.c b/coreutils/head.c
index 7f08a8041..4e58bdcd7 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -26,10 +26,12 @@
26#include <stdio.h> 26#include <stdio.h>
27 27
28const char head_usage[] = 28const char head_usage[] =
29"Usage: head [FILE]...\n\n" 29"head [OPTION] [FILE]...\n\n"
30"Print first 10 lines of each FILE to standard output.\n" 30"Print first 10 lines of each FILE to standard output.\n"
31"With more than one FILE, precede each with a header giving the\n" 31"With more than one FILE, precede each with a header giving the\n"
32"file name. With no FILE, or when FILE is -, read standard input.\n"; 32"file name. With no FILE, or when FILE is -, read standard input.\n\n"
33"Options:\n"
34"\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
33 35
34int 36int
35head(int len, FILE *src) 37head(int len, FILE *src)
@@ -49,22 +51,22 @@ head(int len, FILE *src)
49int 51int
50head_main(int argc, char **argv) 52head_main(int argc, char **argv)
51{ 53{
52 int i = 1;
53 char opt; 54 char opt;
54 int len = 10; 55 int len = 10, tmplen, i;
55
56 /* 1st option is potentially special */
57 if ((argc > 1) && (argv[1][0] == '-') && isDecimal(argv[1][1])) {
58 int tmplen = atoi(&argv[1][1]);
59 if (tmplen) { len = tmplen; }
60 i = 2;
61 }
62 56
63 /* parse argv[] */ 57 /* parse argv[] */
64 for ( ; i < argc; i++) { 58 for (i = 1; i < argc; i++) {
65 if (argv[i][0] == '-') { 59 if (argv[i][0] == '-') {
66 opt = argv[i][1]; 60 opt = argv[i][1];
67 switch (opt) { 61 switch (opt) {
62 case 'n':
63 tmplen = 0;
64 if (i++ < argc)
65 tmplen = atoi(argv[i]);
66 if (tmplen < 1)
67 usage(head_usage);
68 len = tmplen;
69 break;
68 case '-': 70 case '-':
69 case 'h': 71 case 'h':
70 usage(head_usage); 72 usage(head_usage);
@@ -103,4 +105,4 @@ head_main(int argc, char **argv)
103 exit(0); 105 exit(0);
104} 106}
105 107
106/* $Id: head.c,v 1.4 1999/12/17 18:52:06 erik Exp $ */ 108/* $Id: head.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index dc245a18e..017ef9b08 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -26,7 +26,8 @@
26#include <errno.h> 26#include <errno.h>
27#include <sys/param.h> 27#include <sys/param.h>
28 28
29static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n" 29static const char mkdir_usage[] =
30"mkdir [OPTION] DIRECTORY...\n\n"
30"Create the DIRECTORY(ies), if they do not already exist\n\n" 31"Create the DIRECTORY(ies), if they do not already exist\n\n"
31"Options:\n" 32"Options:\n"
32"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" 33"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
diff --git a/coreutils/sort.c b/coreutils/sort.c
index 0fe7bf99b..4df5627ac 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -29,7 +29,7 @@
29#include <errno.h> 29#include <errno.h>
30 30
31static const char sort_usage[] = 31static const char sort_usage[] =
32"Usage: sort [OPTION]... [FILE]...\n\n" 32"sort [OPTION]... [FILE]...\n\n"
33; 33;
34 34
35/* typedefs _______________________________________________________________ */ 35/* typedefs _______________________________________________________________ */
@@ -309,4 +309,4 @@ sort_main(int argc, char **argv)
309 exit(0); 309 exit(0);
310} 310}
311 311
312/* $Id: sort.c,v 1.8 1999/12/23 22:46:10 beppu Exp $ */ 312/* $Id: sort.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/uniq.c b/coreutils/uniq.c
index 034ea316e..a7bff54ec 100644
--- a/coreutils/uniq.c
+++ b/coreutils/uniq.c
@@ -27,7 +27,7 @@
27#include <errno.h> 27#include <errno.h>
28 28
29static const char uniq_usage[] = 29static const char uniq_usage[] =
30"Usage: uniq [OPTION]... [INPUT [OUTPUT]]\n" 30"uniq [OPTION]... [INPUT [OUTPUT]]\n"
31"Discard all but one of successive identical lines from INPUT (or\n" 31"Discard all but one of successive identical lines from INPUT (or\n"
32"standard input), writing to OUTPUT (or standard output).\n" 32"standard input), writing to OUTPUT (or standard output).\n"
33"\n" 33"\n"
@@ -193,4 +193,4 @@ uniq_main(int argc, char **argv)
193 exit(0); 193 exit(0);
194} 194}
195 195
196/* $Id: uniq.c,v 1.4 2000/01/07 01:57:32 beppu Exp $ */ 196/* $Id: uniq.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/coreutils/wc.c b/coreutils/wc.c
index a1e2fca56..e69f0d899 100644
--- a/coreutils/wc.c
+++ b/coreutils/wc.c
@@ -28,7 +28,6 @@ static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
28"\t-c\tprint the byte counts\n" 28"\t-c\tprint the byte counts\n"
29"\t-l\tprint the newline counts\n" 29"\t-l\tprint the newline counts\n"
30"\t-L\tprint the length of the longest line\n" 30"\t-L\tprint the length of the longest line\n"
31"\t-L\tprint the length of the longest line\n"
32"\t-w\tprint the word counts\n"; 31"\t-w\tprint the word counts\n";
33 32
34static int total_lines, total_words, total_chars, max_length; 33static int total_lines, total_words, total_chars, max_length;
diff --git a/du.c b/du.c
index ec03afd95..79b553643 100644
--- a/du.c
+++ b/du.c
@@ -35,7 +35,7 @@
35typedef void (Display)(size_t, char *); 35typedef void (Display)(size_t, char *);
36 36
37static const char du_usage[] = 37static const char du_usage[] =
38"Usage: du [OPTION]... [FILE]...\n\n" 38"du [OPTION]... [FILE]...\n\n"
39"\t-s\tdisplay only a total for each argument\n" 39"\t-s\tdisplay only a total for each argument\n"
40; 40;
41 41
@@ -140,4 +140,4 @@ du_main(int argc, char **argv)
140 exit(0); 140 exit(0);
141} 141}
142 142
143/* $Id: du.c,v 1.8 1999/12/17 18:44:15 erik Exp $ */ 143/* $Id: du.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/head.c b/head.c
index 7f08a8041..4e58bdcd7 100644
--- a/head.c
+++ b/head.c
@@ -26,10 +26,12 @@
26#include <stdio.h> 26#include <stdio.h>
27 27
28const char head_usage[] = 28const char head_usage[] =
29"Usage: head [FILE]...\n\n" 29"head [OPTION] [FILE]...\n\n"
30"Print first 10 lines of each FILE to standard output.\n" 30"Print first 10 lines of each FILE to standard output.\n"
31"With more than one FILE, precede each with a header giving the\n" 31"With more than one FILE, precede each with a header giving the\n"
32"file name. With no FILE, or when FILE is -, read standard input.\n"; 32"file name. With no FILE, or when FILE is -, read standard input.\n\n"
33"Options:\n"
34"\t-n NUM\t\tPrint first NUM lines instead of first 10\n";
33 35
34int 36int
35head(int len, FILE *src) 37head(int len, FILE *src)
@@ -49,22 +51,22 @@ head(int len, FILE *src)
49int 51int
50head_main(int argc, char **argv) 52head_main(int argc, char **argv)
51{ 53{
52 int i = 1;
53 char opt; 54 char opt;
54 int len = 10; 55 int len = 10, tmplen, i;
55
56 /* 1st option is potentially special */
57 if ((argc > 1) && (argv[1][0] == '-') && isDecimal(argv[1][1])) {
58 int tmplen = atoi(&argv[1][1]);
59 if (tmplen) { len = tmplen; }
60 i = 2;
61 }
62 56
63 /* parse argv[] */ 57 /* parse argv[] */
64 for ( ; i < argc; i++) { 58 for (i = 1; i < argc; i++) {
65 if (argv[i][0] == '-') { 59 if (argv[i][0] == '-') {
66 opt = argv[i][1]; 60 opt = argv[i][1];
67 switch (opt) { 61 switch (opt) {
62 case 'n':
63 tmplen = 0;
64 if (i++ < argc)
65 tmplen = atoi(argv[i]);
66 if (tmplen < 1)
67 usage(head_usage);
68 len = tmplen;
69 break;
68 case '-': 70 case '-':
69 case 'h': 71 case 'h':
70 usage(head_usage); 72 usage(head_usage);
@@ -103,4 +105,4 @@ head_main(int argc, char **argv)
103 exit(0); 105 exit(0);
104} 106}
105 107
106/* $Id: head.c,v 1.4 1999/12/17 18:52:06 erik Exp $ */ 108/* $Id: head.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/internal.h b/internal.h
index 2b07d672d..b77feabad 100644
--- a/internal.h
+++ b/internal.h
@@ -26,6 +26,7 @@
26#include "busybox.def.h" 26#include "busybox.def.h"
27 27
28#include <stdlib.h> 28#include <stdlib.h>
29#include <stdarg.h>
29#include <string.h> 30#include <string.h>
30#include <unistd.h> 31#include <unistd.h>
31#include <sys/stat.h> 32#include <sys/stat.h>
@@ -174,7 +175,7 @@ extern int check_wildcard_match(const char* text, const char* pattern);
174extern long getNum (const char *cp); 175extern long getNum (const char *cp);
175extern pid_t findInitPid(); 176extern pid_t findInitPid();
176 177
177#if (__GLIBC__ < 2) && defined BB_SYSLOGD 178#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
178extern int vdprintf(int d, const char *format, va_list ap); 179extern int vdprintf(int d, const char *format, va_list ap);
179#endif 180#endif
180 181
diff --git a/mkdir.c b/mkdir.c
index dc245a18e..017ef9b08 100644
--- a/mkdir.c
+++ b/mkdir.c
@@ -26,7 +26,8 @@
26#include <errno.h> 26#include <errno.h>
27#include <sys/param.h> 27#include <sys/param.h>
28 28
29static const char mkdir_usage[] = "Usage: mkdir [OPTION] DIRECTORY...\n\n" 29static const char mkdir_usage[] =
30"mkdir [OPTION] DIRECTORY...\n\n"
30"Create the DIRECTORY(ies), if they do not already exist\n\n" 31"Create the DIRECTORY(ies), if they do not already exist\n\n"
31"Options:\n" 32"Options:\n"
32"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n" 33"\t-m\tset permission mode (as in chmod), not rwxrwxrwx - umask\n"
diff --git a/mount.c b/mount.c
index 713e5e850..709c7fc49 100644
--- a/mount.c
+++ b/mount.c
@@ -428,44 +428,42 @@ static int set_loop(const char *device, const char *file, int offset, int *loopr
428 loopinfo.lo_encrypt_key_size = 0; 428 loopinfo.lo_encrypt_key_size = 0;
429 if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { 429 if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
430 perror("ioctl: LOOP_SET_FD"); 430 perror("ioctl: LOOP_SET_FD");
431 exit(1); 431 close(fd);
432 close(ffd);
433 return 1;
432 } 434 }
433 if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { 435 if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
434 (void) ioctl(fd, LOOP_CLR_FD, 0); 436 (void) ioctl(fd, LOOP_CLR_FD, 0);
435 perror("ioctl: LOOP_SET_STATUS"); 437 perror("ioctl: LOOP_SET_STATUS");
436 exit(1); 438 close(fd);
439 close(ffd);
440 return 1;
437 } 441 }
438 close(fd); 442 close(fd);
439 close(ffd); 443 close(ffd);
440 return 0; 444 return 0;
441} 445}
442 446
443static char *find_unused_loop_device (void) 447char *find_unused_loop_device (void)
444{ 448{
445 char dev[20]; 449 char dev[20];
446 int i, fd, somedev = 0, someloop = 0; 450 int i, fd;
447 struct stat statbuf; 451 struct stat statbuf;
448 struct loop_info loopinfo; 452 struct loop_info loopinfo;
449 453
450 for(i = 0; i < 256; i++) { 454 for(i = 0; i <= 7; i++) {
451 sprintf(dev, "/dev/loop%d", i); 455 sprintf(dev, "/dev/loop%d", i);
452 if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { 456 if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
453 somedev++; 457 if ((fd = open (dev, O_RDONLY)) >= 0) {
454 fd = open (dev, O_RDONLY); 458 if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == -1 &&
455 if (fd >= 0) { 459 errno == ENXIO) { /* probably free */
456 if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0) 460 close (fd);
457 someloop++; /* in use */ 461 return strdup(dev);
458 else if (errno == ENXIO) { 462 }
459 close (fd); 463 close (fd);
460 return strdup(dev); /* probably free */ 464 }
461 } 465 }
462 close (fd); 466 }
463 } 467 return NULL;
464 continue;
465 }
466 if (i >= 7)
467 break;
468 }
469 return NULL;
470} 468}
471#endif /* BB_FEATURE_MOUNT_LOOP */ 469#endif /* BB_FEATURE_MOUNT_LOOP */
diff --git a/sfdisk.c b/sfdisk.c
index 5b67e69ab..5dc44eacc 100644
--- a/sfdisk.c
+++ b/sfdisk.c
@@ -55,7 +55,7 @@
55 55
56 56
57static const char sfdisk_usage[] = 57static const char sfdisk_usage[] =
58"Usage: sfdisk [options] device ...\n" 58"sfdisk [options] device ...\n"
59"device: something like /dev/hda or /dev/sda\n" 59"device: something like /dev/hda or /dev/sda\n"
60"useful options:\n" 60"useful options:\n"
61" -s [or --show-size]: list size of a partition\n" 61" -s [or --show-size]: list size of a partition\n"
@@ -2345,7 +2345,7 @@ sfdisk_main(int argc, char **argv) {
2345 char *unhidearg = 0; 2345 char *unhidearg = 0;
2346 2346
2347 if (argc < 1) 2347 if (argc < 1)
2348 usage( sfdisk_usage); 2348 usage(sfdisk_usage);
2349 2349
2350 while ((c = getopt_long (argc, argv, short_opts, long_opts, NULL)) != -1) { 2350 while ((c = getopt_long (argc, argv, short_opts, long_opts, NULL)) != -1) {
2351 switch (c) { 2351 switch (c) {
@@ -2407,7 +2407,7 @@ sfdisk_main(int argc, char **argv) {
2407 verify = 1; break; 2407 verify = 1; break;
2408 case '?': 2408 case '?':
2409 default: 2409 default:
2410 usage( sfdisk_usage); 2410 usage(sfdisk_usage);
2411 2411
2412 /* undocumented flags */ 2412 /* undocumented flags */
2413 case 128: 2413 case 128:
@@ -2461,7 +2461,7 @@ sfdisk_main(int argc, char **argv) {
2461 exit(exit_status); 2461 exit(exit_status);
2462 } 2462 }
2463 2463
2464 if (optind == argc) usage( sfdisk_usage); 2464 if (optind == argc) usage(sfdisk_usage);
2465 2465
2466 if (opt_list || opt_out_geom || opt_size || verify) { 2466 if (opt_list || opt_out_geom || opt_size || verify) {
2467 while (optind < argc) { 2467 while (optind < argc) {
diff --git a/sort.c b/sort.c
index 0fe7bf99b..4df5627ac 100644
--- a/sort.c
+++ b/sort.c
@@ -29,7 +29,7 @@
29#include <errno.h> 29#include <errno.h>
30 30
31static const char sort_usage[] = 31static const char sort_usage[] =
32"Usage: sort [OPTION]... [FILE]...\n\n" 32"sort [OPTION]... [FILE]...\n\n"
33; 33;
34 34
35/* typedefs _______________________________________________________________ */ 35/* typedefs _______________________________________________________________ */
@@ -309,4 +309,4 @@ sort_main(int argc, char **argv)
309 exit(0); 309 exit(0);
310} 310}
311 311
312/* $Id: sort.c,v 1.8 1999/12/23 22:46:10 beppu Exp $ */ 312/* $Id: sort.c,v 1.9 2000/01/23 18:19:02 erik Exp $ */
diff --git a/tar.c b/tar.c
index 21ef24dcb..aedb36a23 100644
--- a/tar.c
+++ b/tar.c
@@ -54,7 +54,7 @@ static const char tar_usage[] =
54#else 54#else
55 55
56static const char tar_usage[] = 56static const char tar_usage[] =
57"tar -[cxtvOf] [tarFileName] [FILE] ...\n\n" 57"tar -[xtvOf] [tarFileName] [FILE] ...\n\n"
58"Extract, or list files stored in a tar file. This\n" 58"Extract, or list files stored in a tar file. This\n"
59"version of tar does not support creation of tar files.\n\n" 59"version of tar does not support creation of tar files.\n\n"
60"Options:\n" 60"Options:\n"
diff --git a/umount.c b/umount.c
index af1b3a43e..9ad6f26c2 100644
--- a/umount.c
+++ b/umount.c
@@ -37,7 +37,7 @@ static int del_loop(const char *device);
37#endif 37#endif
38 38
39static const char umount_usage[] = 39static const char umount_usage[] =
40"Usage: umount [flags] filesystem|directory\n\n" 40"umount [flags] filesystem|directory\n\n"
41"Flags:\n" 41"Flags:\n"
42"\t-a:\tUnmount all file systems" 42"\t-a:\tUnmount all file systems"
43#ifdef BB_MTAB 43#ifdef BB_MTAB
diff --git a/uniq.c b/uniq.c
index 034ea316e..a7bff54ec 100644
--- a/uniq.c
+++ b/uniq.c
@@ -27,7 +27,7 @@
27#include <errno.h> 27#include <errno.h>
28 28
29static const char uniq_usage[] = 29static const char uniq_usage[] =
30"Usage: uniq [OPTION]... [INPUT [OUTPUT]]\n" 30"uniq [OPTION]... [INPUT [OUTPUT]]\n"
31"Discard all but one of successive identical lines from INPUT (or\n" 31"Discard all but one of successive identical lines from INPUT (or\n"
32"standard input), writing to OUTPUT (or standard output).\n" 32"standard input), writing to OUTPUT (or standard output).\n"
33"\n" 33"\n"
@@ -193,4 +193,4 @@ uniq_main(int argc, char **argv)
193 exit(0); 193 exit(0);
194} 194}
195 195
196/* $Id: uniq.c,v 1.4 2000/01/07 01:57:32 beppu Exp $ */ 196/* $Id: uniq.c,v 1.5 2000/01/23 18:19:02 erik Exp $ */
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 713e5e850..709c7fc49 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -428,44 +428,42 @@ static int set_loop(const char *device, const char *file, int offset, int *loopr
428 loopinfo.lo_encrypt_key_size = 0; 428 loopinfo.lo_encrypt_key_size = 0;
429 if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { 429 if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
430 perror("ioctl: LOOP_SET_FD"); 430 perror("ioctl: LOOP_SET_FD");
431 exit(1); 431 close(fd);
432 close(ffd);
433 return 1;
432 } 434 }
433 if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { 435 if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
434 (void) ioctl(fd, LOOP_CLR_FD, 0); 436 (void) ioctl(fd, LOOP_CLR_FD, 0);
435 perror("ioctl: LOOP_SET_STATUS"); 437 perror("ioctl: LOOP_SET_STATUS");
436 exit(1); 438 close(fd);
439 close(ffd);
440 return 1;
437 } 441 }
438 close(fd); 442 close(fd);
439 close(ffd); 443 close(ffd);
440 return 0; 444 return 0;
441} 445}
442 446
443static char *find_unused_loop_device (void) 447char *find_unused_loop_device (void)
444{ 448{
445 char dev[20]; 449 char dev[20];
446 int i, fd, somedev = 0, someloop = 0; 450 int i, fd;
447 struct stat statbuf; 451 struct stat statbuf;
448 struct loop_info loopinfo; 452 struct loop_info loopinfo;
449 453
450 for(i = 0; i < 256; i++) { 454 for(i = 0; i <= 7; i++) {
451 sprintf(dev, "/dev/loop%d", i); 455 sprintf(dev, "/dev/loop%d", i);
452 if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { 456 if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
453 somedev++; 457 if ((fd = open (dev, O_RDONLY)) >= 0) {
454 fd = open (dev, O_RDONLY); 458 if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == -1 &&
455 if (fd >= 0) { 459 errno == ENXIO) { /* probably free */
456 if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0) 460 close (fd);
457 someloop++; /* in use */ 461 return strdup(dev);
458 else if (errno == ENXIO) { 462 }
459 close (fd); 463 close (fd);
460 return strdup(dev); /* probably free */ 464 }
461 } 465 }
462 close (fd); 466 }
463 } 467 return NULL;
464 continue;
465 }
466 if (i >= 7)
467 break;
468 }
469 return NULL;
470} 468}
471#endif /* BB_FEATURE_MOUNT_LOOP */ 469#endif /* BB_FEATURE_MOUNT_LOOP */
diff --git a/util-linux/umount.c b/util-linux/umount.c
index af1b3a43e..9ad6f26c2 100644
--- a/util-linux/umount.c
+++ b/util-linux/umount.c
@@ -37,7 +37,7 @@ static int del_loop(const char *device);
37#endif 37#endif
38 38
39static const char umount_usage[] = 39static const char umount_usage[] =
40"Usage: umount [flags] filesystem|directory\n\n" 40"umount [flags] filesystem|directory\n\n"
41"Flags:\n" 41"Flags:\n"
42"\t-a:\tUnmount all file systems" 42"\t-a:\tUnmount all file systems"
43#ifdef BB_MTAB 43#ifdef BB_MTAB
diff --git a/wc.c b/wc.c
index a1e2fca56..e69f0d899 100644
--- a/wc.c
+++ b/wc.c
@@ -28,7 +28,6 @@ static const char wc_usage[] = "wc [OPTION]... [FILE]...\n\n"
28"\t-c\tprint the byte counts\n" 28"\t-c\tprint the byte counts\n"
29"\t-l\tprint the newline counts\n" 29"\t-l\tprint the newline counts\n"
30"\t-L\tprint the length of the longest line\n" 30"\t-L\tprint the length of the longest line\n"
31"\t-L\tprint the length of the longest line\n"
32"\t-w\tprint the word counts\n"; 31"\t-w\tprint the word counts\n";
33 32
34static int total_lines, total_words, total_chars, max_length; 33static int total_lines, total_words, total_chars, max_length;