diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-01-23 18:19:02 +0000 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-01-23 18:19:02 +0000 |
commit | 5509af7073ffff75d86ff8c67a2075169a859efd (patch) | |
tree | 2728cbb296484026cb657f92f78e1bb0806ba6f4 /util-linux | |
parent | 9bc7e89fc1eb493c06494ad86781ab49fc28c509 (diff) | |
download | busybox-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
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/mount.c | 54 | ||||
-rw-r--r-- | util-linux/umount.c | 2 |
2 files changed, 27 insertions, 29 deletions
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 | ||
443 | static char *find_unused_loop_device (void) | 447 | char *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 | ||
39 | static const char umount_usage[] = | 39 | static 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 |