From 9eeabaadca00fd076c60db38f8faed81b4239d62 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 24 May 2020 02:06:07 -0500 Subject: 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? --- toys/other/blkdiscard.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'toys/other') 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 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); } -- cgit v1.2.3