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-5509af7073ffff75d86ff8c67a2075169a859efd.tar.gz |
* 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 loopinfo.lo_encrypt_key_size = 0; if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { perror("ioctl: LOOP_SET_FD"); - exit(1); + close(fd); + close(ffd); + return 1; } if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { (void) ioctl(fd, LOOP_CLR_FD, 0); perror("ioctl: LOOP_SET_STATUS"); - exit(1); + close(fd); + close(ffd); + return 1; } close(fd); close(ffd); return 0; } -static char *find_unused_loop_device (void) +char *find_unused_loop_device (void) { - char dev[20]; - int i, fd, somedev = 0, someloop = 0; - struct stat statbuf; - struct loop_info loopinfo; - - for(i = 0; i < 256; i++) { - sprintf(dev, "/dev/loop%d", i); - if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { - somedev++; - fd = open (dev, O_RDONLY); - if (fd >= 0) { - if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == 0) - someloop++; /* in use */ - else if (errno == ENXIO) { - close (fd); - return strdup(dev); /* probably free */ - } - close (fd); - } - continue; - } - if (i >= 7) - break; - } - return NULL; + char dev[20]; + int i, fd; + struct stat statbuf; + struct loop_info loopinfo; + + for(i = 0; i <= 7; i++) { + sprintf(dev, "/dev/loop%d", i); + if (stat (dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { + if ((fd = open (dev, O_RDONLY)) >= 0) { + if(ioctl (fd, LOOP_GET_STATUS, &loopinfo) == -1 && + errno == ENXIO) { /* probably free */ + close (fd); + return strdup(dev); + } + close (fd); + } + } + } + return NULL; } #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); #endif static const char umount_usage[] = -"Usage: umount [flags] filesystem|directory\n\n" +"umount [flags] filesystem|directory\n\n" "Flags:\n" "\t-a:\tUnmount all file systems" #ifdef BB_MTAB |