aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-27 14:51:27 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-27 14:51:27 +0000
commit956a5693603be076a7a2b0bacc22eea4a3b93cbe (patch)
treec0554cf92ffc22ad9bfea1b36aa7fffc1dcc298e
parent0bb628f4f3fbd0fc0a96d257830fcbbb14db2bd1 (diff)
downloadbusybox-w32-956a5693603be076a7a2b0bacc22eea4a3b93cbe.tar.gz
busybox-w32-956a5693603be076a7a2b0bacc22eea4a3b93cbe.tar.bz2
busybox-w32-956a5693603be076a7a2b0bacc22eea4a3b93cbe.zip
losetup: with no arguments lists all /dev/loopN. Corrected help text.
(patch by Vladimir Dronnikov <dronnikov@gmail.ru>)
-rw-r--r--include/usage.h5
-rw-r--r--util-linux/losetup.c18
2 files changed, 18 insertions, 5 deletions
diff --git a/include/usage.h b/include/usage.h
index 8b8d64e84..36739c712 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -1623,13 +1623,14 @@ USE_FEATURE_DATE_ISOFMT( \
1623 "\t-f\t\toutput data as the log grows" 1623 "\t-f\t\toutput data as the log grows"
1624 1624
1625#define losetup_trivial_usage \ 1625#define losetup_trivial_usage \
1626 "[-od] LOOPDEVICE [FILE]" 1626 "[-o OFFSET] [-d] LOOPDEVICE [FILE]]"
1627#define losetup_full_usage \ 1627#define losetup_full_usage \
1628 "Associate LOOPDEVICE with FILE, or display current association.\n\n" \ 1628 "(Dis)associate LOOPDEVICE with FILE, or display current associations.\n\n" \
1629 "Options:\n" \ 1629 "Options:\n" \
1630 "\t-d\t\tDisassociate LOOPDEVICE\n" \ 1630 "\t-d\t\tDisassociate LOOPDEVICE\n" \
1631 "\t-o OFFSET\tStart OFFSET bytes into FILE" 1631 "\t-o OFFSET\tStart OFFSET bytes into FILE"
1632#define losetup_notes_usage \ 1632#define losetup_notes_usage \
1633 "No arguments will display all current associations.\n" \
1633 "One argument (losetup /dev/loop1) will display the current association\n" \ 1634 "One argument (losetup /dev/loop1) will display the current association\n" \
1634 "(if any), or disassociate it (with -d). The display shows the offset\n" \ 1635 "(if any), or disassociate it (with -d). The display shows the offset\n" \
1635 "and filename of the file the loop device is currently bound to.\n\n" \ 1636 "and filename of the file the loop device is currently bound to.\n\n" \
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index af0b03a53..6b9a810f2 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -22,7 +22,8 @@ int losetup_main(int argc, char **argv)
22 argc -= optind; 22 argc -= optind;
23 argv += optind; 23 argv += optind;
24 24
25 if (opt == 0x3) bb_show_usage(); // -d and -o (illegal) 25 if (opt == 0x3) // -d + -o (illegal)
26 bb_show_usage();
26 27
27 if (opt == 0x1) { // -d 28 if (opt == 0x1) { // -d
28 /* detach takes exactly one argument */ 29 /* detach takes exactly one argument */
@@ -46,7 +47,18 @@ int losetup_main(int argc, char **argv)
46 if (!s) bb_perror_nomsg_and_die(); 47 if (!s) bb_perror_nomsg_and_die();
47 printf("%s: %s\n", argv[0], s); 48 printf("%s: %s\n", argv[0], s);
48 if (ENABLE_FEATURE_CLEAN_UP) free(s); 49 if (ENABLE_FEATURE_CLEAN_UP) free(s);
49 } else 50 } else {
50 bb_show_usage(); 51 char dev[11] = "/dev/loop0";
52 char c;
53 for (c = '0'; c <= '9'; ++c) {
54 char *s;
55 dev[9] = c;
56 s = query_loop(dev);
57 if (s) {
58 printf("%s: %s\n", dev, s);
59 if (ENABLE_FEATURE_CLEAN_UP) free(s);
60 }
61 }
62 }
51 return EXIT_SUCCESS; 63 return EXIT_SUCCESS;
52} 64}