aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-05-24 02:06:07 -0500
committerRob Landley <rob@landley.net>2020-05-24 02:06:07 -0500
commit9eeabaadca00fd076c60db38f8faed81b4239d62 (patch)
tree09df4c8301ec95981bd2f867d3fe15d910f5049c /toys/other
parent0c2f2030dae091b934f753f0ae920cbb7b06434d (diff)
downloadtoybox-9eeabaadca00fd076c60db38f8faed81b4239d62.tar.gz
Cleanup blkdiscard.
Yeah, this limits 32 bit support, but that's a "fix it properly in lib/args.c or don't care" issue. Why work around it here when truncate -s doesn't?
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/blkdiscard.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/toys/other/blkdiscard.c b/toys/other/blkdiscard.c
index 1859fd88..a516676e 100644
--- a/toys/other/blkdiscard.c
+++ b/toys/other/blkdiscard.c
@@ -8,7 +8,7 @@
* Size parsing does not match util-linux where MB, GB, TB are multiples of
* 1000 and MiB, TiB, GiB are multipes of 1024.
-USE_BLKDISCARD(NEWTOY(blkdiscard, "<1>1f(force)l(length):o(offset):s(secure)z(zeroout)[!sz]", TOYFLAG_BIN))
+USE_BLKDISCARD(NEWTOY(blkdiscard, "<1>1f(force)l(length)#<0o(offset)#<0s(secure)z(zeroout)[!sz]", TOYFLAG_BIN))
config BLKDISCARD
bool "blkdiscard"
@@ -35,7 +35,7 @@ config BLKDISCARD
#include <linux/fs.h>
GLOBALS(
- char *o, *l;
+ long o, l;
)
void blkdiscard_main(void)
@@ -43,13 +43,13 @@ void blkdiscard_main(void)
int fd = xopen(*toys.optargs, O_WRONLY|O_EXCL*!FLAG(f));
unsigned long long ol[2];
- ol[0] = FLAG(o) ? atolx_range(TT.o, 0, LLONG_MAX) : 0;
- if (FLAG(l)) ol[1] = atolx_range(TT.l, 0, LLONG_MAX);
+ // TODO: if numeric arg was long long array could live in TT.
+ if (FLAG(o)) ol[0] = TT.o;
+ if (FLAG(l)) ol[1] = TT.l;
else {
xioctl(fd, BLKGETSIZE64, ol+1);
ol[1] -= ol[0];
}
xioctl(fd, FLAG(s) ? BLKSECDISCARD : FLAG(z) ? BLKZEROOUT : BLKDISCARD, ol);
-
- if (CFG_TOYBOX_FREE) close(fd);
+ close(fd);
}