Commit ccf23ccb authored by Mike Hibler's avatar Mike Hibler
Browse files

Added -i (ignore v1 features) support to imagedump. Prevents it

from looking at the embedded (and deprecated) blockindex field in
the headers.  Now imagedump won't complain if you run it on a
piece of a split image.
parent 9e2f4160
......@@ -11,7 +11,7 @@
.Nd dump information about an imagezip compressed image file
.Sh SYNOPSIS
.Nm
.Op Fl dv
.Op Fl div
.Ar imagefile ...
.Sh DESCRIPTION
The
......@@ -38,6 +38,15 @@ options can be specified to dump various levels of structure within the
image file.
.Pp
The
.Fl i
option tells
.Nm
to ignore the deprecated blockindex field in chunk headers.
You need this option when running
.Nm
on pieces of a split image.
.Pp
The
.Fl v
option prints version information about
.Nm
......
......@@ -22,6 +22,7 @@
static int detail = 0;
static int dumpmap = 0;
static int ignorev1 = 0;
static int infd = -1;
static unsigned long long wasted;
......@@ -40,11 +41,14 @@ main(int argc, char **argv)
int ch, version = 0;
extern char build_info[];
while ((ch = getopt(argc, argv, "dmv")) != -1)
while ((ch = getopt(argc, argv, "dimv")) != -1)
switch(ch) {
case 'd':
detail++;
break;
case 'i':
ignorev1++;
break;
case 'm':
dumpmap++;
detail = 0;
......@@ -181,7 +185,11 @@ dumpfile(char *name, int fd)
return;
}
chunkcount = hdr->blocktotal;
if (ignorev1) {
chunkcount = 0;
checkindex = 0;
} else
chunkcount = hdr->blocktotal;
if ((filesize / SUBBLOCKSIZE) != chunkcount) {
if (chunkcount != 0) {
if (isstdin)
......@@ -197,9 +205,11 @@ dumpfile(char *name, int fd)
(filesize/SUBBLOCKSIZE),
chunkcount);
} else if (magic == COMPRESSED_V1) {
printf("%s: WARNING: zero chunk count, "
"ignoring block fields\n",
name);
if (!ignorev1)
printf("%s: WARNING: "
"zero chunk count, "
"ignoring block fields\n",
name);
checkindex = 0;
}
}
......@@ -208,7 +218,7 @@ dumpfile(char *name, int fd)
name, filesize,
(unsigned long)(filesize / SUBBLOCKSIZE),
hdr->magic - COMPRESSED_MAGIC_BASE + 1);
} else if (chunkno == 1) {
} else if (chunkno == 1 && !ignorev1) {
blockhdr_t *hdr = (blockhdr_t *)chunkbuf;
/*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment