aboutsummaryrefslogtreecommitdiff
path: root/toys/other/shred.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-11-02 20:07:02 -0500
committerRob Landley <rob@landley.net>2018-11-02 20:07:02 -0500
commit6a73e13d75d31da2c3f1145d8487725f0073a4b8 (patch)
tree17b5bb8b6b5e94b1c93818954cf322a39941a4be /toys/other/shred.c
parent49e1d8733ebcaf130623c68a2393a3c43702a524 (diff)
downloadtoybox-6a73e13d75d31da2c3f1145d8487725f0073a4b8.tar.gz
Convert more option vars to the new (single letter) coding style.
Diffstat (limited to 'toys/other/shred.c')
-rw-r--r--toys/other/shred.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/toys/other/shred.c b/toys/other/shred.c
index 680320ec..1bac75c5 100644
--- a/toys/other/shred.c
+++ b/toys/other/shred.c
@@ -30,22 +30,20 @@ config SHRED
#include "toys.h"
GLOBALS(
- long offset;
- long iterations;
- long size;
+ long o, n, s;
)
void shred_main(void)
{
char **try;
- if (!(toys.optflags & FLAG_n)) TT.iterations++;
+ if (!(toys.optflags & FLAG_n)) TT.n++;
// We don't use loopfiles() here because "-" isn't stdin, and want to
// respond to files we can't open via chmod.
for (try = toys.optargs; *try; try++) {
- off_t pos = 0, len = TT.size;
+ off_t pos = 0, len = TT.s;
int fd = open(*try, O_RDWR), iter = 0, throw;
// do -f chmod if necessary
@@ -72,19 +70,19 @@ void shred_main(void)
if (pos >= len) {
pos = -1;
- if (++iter == TT.iterations && (toys.optargs && FLAG_z)) {
+ if (++iter == TT.n && (toys.optargs && FLAG_z)) {
memset(toybuf, 0, sizeof(toybuf));
continue;
}
- if (iter >= TT.iterations) break;
+ if (iter >= TT.n) break;
}
- if (pos < TT.offset) {
- if (TT.offset != lseek(fd, TT.offset, SEEK_SET)) {
+ if (pos < TT.o) {
+ if (TT.o != lseek(fd, TT.o, SEEK_SET)) {
perror_msg_raw(*try);
break;
}
- pos = TT.offset;
+ pos = TT.o;
}
// Determine length, read random data if not zeroing, write.
@@ -93,7 +91,7 @@ void shred_main(void)
if (toys.optflags & FLAG_x)
if (len-pos < throw) throw = len-pos;
- if (iter != TT.iterations) xgetrandom(toybuf, throw, 0);
+ if (iter != TT.n) xgetrandom(toybuf, throw, 0);
if (throw != writeall(fd, toybuf, throw)) perror_msg_raw(*try);
pos += throw;
}