diff options
Diffstat (limited to 'util-linux/losetup.c')
| -rw-r--r-- | util-linux/losetup.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/util-linux/losetup.c b/util-linux/losetup.c index bf480e9bf..2248f2cba 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c | |||
| @@ -20,10 +20,11 @@ | |||
| 20 | //kbuild:lib-$(CONFIG_LOSETUP) += losetup.o | 20 | //kbuild:lib-$(CONFIG_LOSETUP) += losetup.o |
| 21 | 21 | ||
| 22 | //usage:#define losetup_trivial_usage | 22 | //usage:#define losetup_trivial_usage |
| 23 | //usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE - associate loop devices\n" | 23 | //usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE: associate loop devices\n" |
| 24 | //usage: " losetup -d LOOPDEV - disassociate\n" | 24 | //usage: " losetup -c LOOPDEV: reread file size\n" |
| 25 | //usage: " losetup -a - show status\n" | 25 | //usage: " losetup -d LOOPDEV: disassociate\n" |
| 26 | //usage: " losetup -f - show next free loop device" | 26 | //usage: " losetup -a: show status\n" |
| 27 | //usage: " losetup -f: show next free loop device" | ||
| 27 | //usage:#define losetup_full_usage "\n\n" | 28 | //usage:#define losetup_full_usage "\n\n" |
| 28 | //usage: " -o OFS Start OFS bytes into FILE" | 29 | //usage: " -o OFS Start OFS bytes into FILE" |
| 29 | //usage: "\n -r Read-only" | 30 | //usage: "\n -r Read-only" |
| @@ -50,14 +51,15 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
| 50 | char *opt_o; | 51 | char *opt_o; |
| 51 | char dev[LOOP_NAMESIZE]; | 52 | char dev[LOOP_NAMESIZE]; |
| 52 | enum { | 53 | enum { |
| 53 | OPT_d = (1 << 0), | 54 | OPT_c = (1 << 0), |
| 54 | OPT_o = (1 << 1), | 55 | OPT_d = (1 << 1), |
| 55 | OPT_f = (1 << 2), | 56 | OPT_o = (1 << 2), |
| 56 | OPT_a = (1 << 3), | 57 | OPT_f = (1 << 3), |
| 57 | OPT_r = (1 << 4), /* must be last */ | 58 | OPT_a = (1 << 4), |
| 59 | OPT_r = (1 << 5), | ||
| 58 | }; | 60 | }; |
| 59 | 61 | ||
| 60 | opt = getopt32(argv, "^" "do:far" "\0" "?2:d--ofar:a--ofr", &opt_o); | 62 | opt = getopt32(argv, "^" "cdo:far" "\0" "?2:d--ofar:a--ofr", &opt_o); |
| 61 | argv += optind; | 63 | argv += optind; |
| 62 | 64 | ||
| 63 | /* LOOPDEV */ | 65 | /* LOOPDEV */ |
| @@ -73,6 +75,16 @@ int losetup_main(int argc UNUSED_PARAM, char **argv) | |||
| 73 | return EXIT_SUCCESS; | 75 | return EXIT_SUCCESS; |
| 74 | } | 76 | } |
| 75 | 77 | ||
| 78 | /* -c LOOPDEV */ | ||
| 79 | if (opt == OPT_c && argv[0]) { | ||
| 80 | int fd = xopen(argv[0], O_RDONLY); | ||
| 81 | #ifndef LOOP_SET_CAPACITY | ||
| 82 | # define LOOP_SET_CAPACITY 0x4C07 | ||
| 83 | #endif | ||
| 84 | xioctl(fd, LOOP_SET_CAPACITY, /*ignored:*/0); | ||
| 85 | return EXIT_SUCCESS; | ||
| 86 | } | ||
| 87 | |||
| 76 | /* -d LOOPDEV */ | 88 | /* -d LOOPDEV */ |
| 77 | if (opt == OPT_d && argv[0]) { | 89 | if (opt == OPT_d && argv[0]) { |
| 78 | if (del_loop(argv[0])) | 90 | if (del_loop(argv[0])) |
