diff options
Diffstat (limited to 'util-linux/losetup.c')
-rw-r--r-- | util-linux/losetup.c | 16 |
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 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define losetup_trivial_usage | 10 | //usage:#define losetup_trivial_usage |
11 | //usage: "[-o OFS] LOOPDEV FILE - associate loop devices\n" | 11 | //usage: "[-r] [-o OFS] LOOPDEV FILE - associate loop devices\n" |
12 | //usage: " losetup -d LOOPDEV - disassociate\n" | 12 | //usage: " losetup -d LOOPDEV - disassociate\n" |
13 | //usage: " losetup [-f] - show" | 13 | //usage: " losetup [-f] - show" |
14 | //usage:#define losetup_full_usage "\n\n" | 14 | //usage:#define losetup_full_usage "\n\n" |
15 | //usage: " -o OFS Start OFS bytes into FILE" | 15 | //usage: " -o OFS Start OFS bytes into FILE" |
16 | //usage: "\n -r Read-only" | ||
16 | //usage: "\n -f Show first free loop device" | 17 | //usage: "\n -f Show first free loop device" |
17 | //usage: | 18 | //usage: |
18 | //usage:#define losetup_notes_usage | 19 | //usage:#define losetup_notes_usage |
@@ -37,11 +38,12 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
37 | OPT_d = (1 << 0), | 38 | OPT_d = (1 << 0), |
38 | OPT_o = (1 << 1), | 39 | OPT_o = (1 << 1), |
39 | OPT_f = (1 << 2), | 40 | OPT_f = (1 << 2), |
41 | OPT_r = (1 << 3), /* must be last */ | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | /* max 2 args, all opts are mutually exclusive */ | 44 | /* max 2 args, -d,-o,-f opts are mutually exclusive */ |
43 | opt_complementary = "?2:d--of:o--df:f--do"; | 45 | opt_complementary = "?2:d--of:o--df:f--do"; |
44 | opt = getopt32(argv, "do:f", &opt_o); | 46 | opt = getopt32(argv, "do:fr", &opt_o); |
45 | argv += optind; | 47 | argv += optind; |
46 | 48 | ||
47 | if (opt == OPT_o) | 49 | if (opt == OPT_o) |
@@ -63,12 +65,12 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
63 | bb_show_usage(); | 65 | bb_show_usage(); |
64 | 66 | ||
65 | if (argv[1]) { | 67 | if (argv[1]) { |
66 | /* [-o OFS] BLOCKDEV FILE */ | 68 | /* [-r] [-o OFS] BLOCKDEV FILE */ |
67 | if (set_loop(&argv[0], argv[1], offset) < 0) | 69 | if (set_loop(&argv[0], argv[1], offset, (opt / OPT_r)) < 0) |
68 | bb_simple_perror_msg_and_die(argv[0]); | 70 | bb_simple_perror_msg_and_die(argv[0]); |
69 | return EXIT_SUCCESS; | 71 | return EXIT_SUCCESS; |
70 | } | 72 | } |
71 | /* [-o OFS] BLOCKDEV */ | 73 | /* [-r] [-o OFS] BLOCKDEV */ |
72 | s = query_loop(argv[0]); | 74 | s = query_loop(argv[0]); |
73 | if (!s) | 75 | if (!s) |
74 | bb_simple_perror_msg_and_die(argv[0]); | 76 | bb_simple_perror_msg_and_die(argv[0]); |
@@ -78,7 +80,7 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
78 | return EXIT_SUCCESS; | 80 | return EXIT_SUCCESS; |
79 | } | 81 | } |
80 | 82 | ||
81 | /* [-o OFS|-f] with no params */ | 83 | /* [-r] [-o OFS|-f] with no params */ |
82 | n = 0; | 84 | n = 0; |
83 | while (1) { | 85 | while (1) { |
84 | char *s; | 86 | char *s; |