svn commit: trunk/busybox: include util-linux

vda at busybox.net vda at busybox.net
Wed Sep 27 14:51:27 UTC 2006


Author: vda
Date: 2006-09-27 07:51:27 -0700 (Wed, 27 Sep 2006)
New Revision: 16236

Log:
losetup: with no arguments lists all /dev/loopN. Corrected help text.
(patch by Vladimir Dronnikov <dronnikov at gmail.ru>)


Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/util-linux/losetup.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2006-09-27 14:25:33 UTC (rev 16235)
+++ trunk/busybox/include/usage.h	2006-09-27 14:51:27 UTC (rev 16236)
@@ -1623,13 +1623,14 @@
 	"\t-f\t\toutput data as the log grows"
 
 #define losetup_trivial_usage \
-	"[-od] LOOPDEVICE [FILE]"
+	"[-o OFFSET] [-d] LOOPDEVICE [FILE]]"
 #define losetup_full_usage \
-	"Associate LOOPDEVICE with FILE, or display current association.\n\n" \
+	"(Dis)associate LOOPDEVICE with FILE, or display current associations.\n\n" \
 	"Options:\n" \
 	"\t-d\t\tDisassociate LOOPDEVICE\n" \
 	"\t-o OFFSET\tStart OFFSET bytes into FILE"
 #define losetup_notes_usage \
+	"No arguments will display all current associations.\n" \
 	"One argument (losetup /dev/loop1) will display the current association\n" \
 	"(if any), or disassociate it (with -d).  The display shows the offset\n" \
 	"and filename of the file the loop device is currently bound to.\n\n" \

Modified: trunk/busybox/util-linux/losetup.c
===================================================================
--- trunk/busybox/util-linux/losetup.c	2006-09-27 14:25:33 UTC (rev 16235)
+++ trunk/busybox/util-linux/losetup.c	2006-09-27 14:51:27 UTC (rev 16236)
@@ -22,7 +22,8 @@
 	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 @@
 		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;
 }




More information about the busybox-cvs mailing list