From c6fcf1d25da72a45d59a3791062bd5241034eb8a Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 29 May 2014 06:29:12 -0500 Subject: Make "losetup /dev/loop0 filename" work. Sigh. Implement the complex cases and you screw up the simple cases you already tested... --- toys/other/losetup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'toys/other/losetup.c') diff --git a/toys/other/losetup.c b/toys/other/losetup.c index 618016e1..aad722e4 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -179,10 +179,13 @@ void losetup_main(void) } else { char *file = (toys.optflags & (FLAG_d|FLAG_c)) ? NULL : toys.optargs[1]; - if (!toys.optc || (file && toys.optc>1)) { + if (!toys.optc || (file && toys.optc != 2)) { toys.exithelp++; - perror_exit("needs 1 arg"); + perror_exit("needs %d arg%s", 1+!!file, file ? "s" : ""); + } + for (s = toys.optargs; *s; s++) { + loopback_setup(*s, file); + if (file) break; } - for (s = toys.optargs; *s; s++) loopback_setup(*s, file); } } -- cgit v1.2.3