# HG changeset patch # User Rob Landley # Date 1401362952 18000 # Node ID b91284c2e56964847304d1db648faeea10fb2fdd # Parent 4d898affda0c50ab98f5be4412e748f3216af260 Make "losetup /dev/loop0 filename" work. Sigh. Implement the complex cases and you screw up the simple cases you already tested... diff -r 4d898affda0c -r b91284c2e569 toys/other/losetup.c --- a/toys/other/losetup.c Thu May 29 05:22:02 2014 -0500 +++ b/toys/other/losetup.c Thu May 29 06:29:12 2014 -0500 @@ -179,10 +179,13 @@ } 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); + for (s = toys.optargs; *s; s++) { + loopback_setup(*s, file); + if (file) break; + } } }