summaryrefslogtreecommitdiff
path: root/util-linux/losetup.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-09-27 14:51:27 +0000
committerDenis Vlasenko2006-09-27 14:51:27 +0000
commit956a5693603be076a7a2b0bacc22eea4a3b93cbe (patch)
treec0554cf92ffc22ad9bfea1b36aa7fffc1dcc298e /util-linux/losetup.c
parent0bb628f4f3fbd0fc0a96d257830fcbbb14db2bd1 (diff)
downloadbusybox-956a5693603be076a7a2b0bacc22eea4a3b93cbe.zip
busybox-956a5693603be076a7a2b0bacc22eea4a3b93cbe.tar.gz
losetup: with no arguments lists all /dev/loopN. Corrected help text.
(patch by Vladimir Dronnikov <dronnikov@gmail.ru>)
Diffstat (limited to 'util-linux/losetup.c')
-rw-r--r--util-linux/losetup.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index af0b03a..6b9a810 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -22,7 +22,8 @@ int losetup_main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (opt == 0x3) bb_show_usage(); // -d and -o (illegal)
+ if (opt == 0x3) // -d + -o (illegal)
+ bb_show_usage();
if (opt == 0x1) { // -d
/* detach takes exactly one argument */
@@ -46,7 +47,18 @@ int losetup_main(int argc, char **argv)
if (!s) bb_perror_nomsg_and_die();
printf("%s: %s\n", argv[0], s);
if (ENABLE_FEATURE_CLEAN_UP) free(s);
- } else
- bb_show_usage();
+ } else {
+ char dev[11] = "/dev/loop0";
+ char c;
+ for (c = '0'; c <= '9'; ++c) {
+ char *s;
+ dev[9] = c;
+ s = query_loop(dev);
+ if (s) {
+ printf("%s: %s\n", dev, s);
+ if (ENABLE_FEATURE_CLEAN_UP) free(s);
+ }
+ }
+ }
return EXIT_SUCCESS;
}