From: Rob Landley Date: Thu, 29 May 2014 11:29:12 +0000 (-0500) Subject: Make "losetup /dev/loop0 filename" work. X-Git-Tag: android-x86-6.0-r1~501 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c6fcf1d25da72a45d59a3791062bd5241034eb8a;p=android-x86%2Fexternal-toybox.git Make "losetup /dev/loop0 filename" work. Sigh. Implement the complex cases and you screw up the simple cases you already tested... --- 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); } }