aboutsummaryrefslogtreecommitdiff
path: root/util-linux/losetup.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-09-12 02:13:47 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2011-09-12 08:30:16 +0200
commit13e709c53f700a18a660feebdf72c613a233bf48 (patch)
tree248b913b7bb6629b751bbd5a79a7e3c6b55dd1af /util-linux/losetup.c
parentdd1061b6a79b0161597799e825bfefc27993ace5 (diff)
downloadbusybox-13e709c53f700a18a660feebdf72c613a233bf48.tar.gz
losetup: implement -r option. Closes 4033.
function old new delta packed_usage 28595 28633 +38 losetup_main 285 290 +5 singlemount 906 908 +2 set_loop 674 672 -2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/losetup.c')
-rw-r--r--util-linux/losetup.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/util-linux/losetup.c b/util-linux/losetup.c
index 9b7c49f50..21108d0bf 100644
--- a/util-linux/losetup.c
+++ b/util-linux/losetup.c
@@ -8,11 +8,12 @@
*/
//usage:#define losetup_trivial_usage
-//usage: "[-o OFS] LOOPDEV FILE - associate loop devices\n"
+//usage: "[-r] [-o OFS] LOOPDEV FILE - associate loop devices\n"
//usage: " losetup -d LOOPDEV - disassociate\n"
//usage: " losetup [-f] - show"
//usage:#define losetup_full_usage "\n\n"
//usage: " -o OFS Start OFS bytes into FILE"
+//usage: "\n -r Read-only"
//usage: "\n -f Show first free loop device"
//usage:
//usage:#define losetup_notes_usage
@@ -37,11 +38,12 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
OPT_d = (1 << 0),
OPT_o = (1 << 1),
OPT_f = (1 << 2),
+ OPT_r = (1 << 3), /* must be last */
};
- /* max 2 args, all opts are mutually exclusive */
+ /* max 2 args, -d,-o,-f opts are mutually exclusive */
opt_complementary = "?2:d--of:o--df:f--do";
- opt = getopt32(argv, "do:f", &opt_o);
+ opt = getopt32(argv, "do:fr", &opt_o);
argv += optind;
if (opt == OPT_o)
@@ -63,12 +65,12 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
bb_show_usage();
if (argv[1]) {
- /* [-o OFS] BLOCKDEV FILE */
- if (set_loop(&argv[0], argv[1], offset) < 0)
+ /* [-r] [-o OFS] BLOCKDEV FILE */
+ if (set_loop(&argv[0], argv[1], offset, (opt / OPT_r)) < 0)
bb_simple_perror_msg_and_die(argv[0]);
return EXIT_SUCCESS;
}
- /* [-o OFS] BLOCKDEV */
+ /* [-r] [-o OFS] BLOCKDEV */
s = query_loop(argv[0]);
if (!s)
bb_simple_perror_msg_and_die(argv[0]);
@@ -78,7 +80,7 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
return EXIT_SUCCESS;
}
- /* [-o OFS|-f] with no params */
+ /* [-r] [-o OFS|-f] with no params */
n = 0;
while (1) {
char *s;