mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 16:08:06 +11:00
tools/blkup: add shortcut for zero blocks
This commit is contained in:
parent
da72d7bbe1
commit
efa2556c82
@ -3,6 +3,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -30,9 +31,22 @@ int main(int argc, char **argv)
|
|||||||
char s[0x40];
|
char s[0x40];
|
||||||
char buf[1024] = {0};
|
char buf[1024] = {0};
|
||||||
sendcmdp(fd, ": _ 1024 0 DO KEY DUP .x I BLK( + C! LOOP ;");
|
sendcmdp(fd, ": _ 1024 0 DO KEY DUP .x I BLK( + C! LOOP ;");
|
||||||
|
sendcmdp(fd, ": Z BLK( 1024 0 FILL ;");
|
||||||
|
|
||||||
int returncode = 0;
|
int returncode = 0;
|
||||||
while (fread(buf, 1, 1024, fp)) {
|
while (fread(buf, 1, 1024, fp)) {
|
||||||
|
bool allzero = true;
|
||||||
|
for (int i=0; i<1024; i++) {
|
||||||
|
if (buf[i] != 0) {
|
||||||
|
allzero = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allzero) {
|
||||||
|
sendcmdp(fd, "Z");
|
||||||
|
putchar('Z');
|
||||||
|
fflush(stdout);
|
||||||
|
} else {
|
||||||
sendcmd(fd, "_");
|
sendcmd(fd, "_");
|
||||||
for (int i=0; i<1024; i++) {
|
for (int i=0; i<1024; i++) {
|
||||||
putchar('.');
|
putchar('.');
|
||||||
@ -53,6 +67,7 @@ int main(int argc, char **argv)
|
|||||||
readprompt(fd);
|
readprompt(fd);
|
||||||
if (returncode) break;
|
if (returncode) break;
|
||||||
memset(buf, 0, 1024);
|
memset(buf, 0, 1024);
|
||||||
|
}
|
||||||
sprintf(s, "%d BLK> ! BLK!", blkno);
|
sprintf(s, "%d BLK> ! BLK!", blkno);
|
||||||
sendcmdp(fd, s);
|
sendcmdp(fd, s);
|
||||||
blkno++;
|
blkno++;
|
||||||
|
Loading…
Reference in New Issue
Block a user