aboutsummaryrefslogtreecommitdiff
path: root/util-linux
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-23 16:11:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-23 16:11:42 +0200
commit309f5e3775ed9cc0837c6d93482735bc4f117d5b (patch)
tree86fff2acd2b6253afbd8829803aa37998078a52c /util-linux
parent1115e40c887fc4d9ddddbe2b0d71c091065ee997 (diff)
downloadbusybox-309f5e3775ed9cc0837c6d93482735bc4f117d5b.tar.gz
losetup: implement -c
function old new delta losetup_main 422 449 +27 packed_usage 33243 33264 +21 get_next_block 1677 1681 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r--util-linux/losetup.c32
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 @@
//kbuild:lib-$(CONFIG_LOSETUP) += losetup.o
//usage:#define losetup_trivial_usage
-//usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE - associate loop devices\n"
-//usage: " losetup -d LOOPDEV - disassociate\n"
-//usage: " losetup -a - show status\n"
-//usage: " losetup -f - show next free loop device"
+//usage: "[-r] [-o OFS] {-f|LOOPDEV} FILE: associate loop devices\n"
+//usage: " losetup -c LOOPDEV: reread file size\n"
+//usage: " losetup -d LOOPDEV: disassociate\n"
+//usage: " losetup -a: show status\n"
+//usage: " losetup -f: show next free loop device"
//usage:#define losetup_full_usage "\n\n"
//usage: " -o OFS Start OFS bytes into FILE"
//usage: "\n -r Read-only"
@@ -50,14 +51,15 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
char *opt_o;
char dev[LOOP_NAMESIZE];
enum {
- OPT_d = (1 << 0),
- OPT_o = (1 << 1),
- OPT_f = (1 << 2),
- OPT_a = (1 << 3),
- OPT_r = (1 << 4), /* must be last */
+ OPT_c = (1 << 0),
+ OPT_d = (1 << 1),
+ OPT_o = (1 << 2),
+ OPT_f = (1 << 3),
+ OPT_a = (1 << 4),
+ OPT_r = (1 << 5),
};
- opt = getopt32(argv, "^" "do:far" "\0" "?2:d--ofar:a--ofr", &opt_o);
+ opt = getopt32(argv, "^" "cdo:far" "\0" "?2:d--ofar:a--ofr", &opt_o);
argv += optind;
/* LOOPDEV */
@@ -73,6 +75,16 @@ int losetup_main(int argc UNUSED_PARAM, char **argv)
return EXIT_SUCCESS;
}
+ /* -c LOOPDEV */
+ if (opt == OPT_c && argv[0]) {
+ int fd = xopen(argv[0], O_RDONLY);
+#ifndef LOOP_SET_CAPACITY
+# define LOOP_SET_CAPACITY 0x4C07
+#endif
+ xioctl(fd, LOOP_SET_CAPACITY, /*ignored:*/0);
+ return EXIT_SUCCESS;
+ }
+
/* -d LOOPDEV */
if (opt == OPT_d && argv[0]) {
if (del_loop(argv[0]))