Browse Source

tools/blkunpack: add "upto" argument

master
Virgil Dupras 3 years ago
parent
commit
45fbce4eb9
1 changed files with 14 additions and 2 deletions
  1. +14
    -2
      tools/blkunpack.c

+ 14
- 2
tools/blkunpack.c View File

@@ -2,19 +2,28 @@
#include <stdlib.h>
#include <sys/stat.h>

/* Unpacks blkfs into its source form.
*
* If numerical "upto" is specified, we stop unpacking when reaching this
* blkno.
*/
void usage()
{
fprintf(stderr, "Usage: blkunpack < blkfs > blk.fs\n");
fprintf(stderr, "Usage: blkunpack [upto] < blkfs > blk.fs\n");
}

int main(int argc, char *argv[])
{
char buf[1024];
int blkid = 0;
if (argc != 1) {
int upto = 0;
if (argc > 2) {
usage();
return 1;
}
if (argc == 2) {
upto = strtol(argv[1], NULL, 10);
}
while (fread(buf, 1024, 1, stdin) == 1) {
int linecnt = 0 ;
for (int i=1023; i>=0; i--) {
@@ -51,6 +60,9 @@ int main(int argc, char *argv[])
}
}
blkid++;
if (blkid == upto) {
break;
}
}
return 0;
}

Loading…
Cancel
Save