Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
a7957e26
Commit
a7957e26
authored
Apr 22, 2015
by
Mike Hibler
Browse files
Fix up writing of delta image signature file.
Also added option (-F) to write full-image signature (what we do).
parent
29628dee
Changes
3
Hide whitespace changes
Inline
Side-by-side
clientside/os/imagezip/imagedelta.c
View file @
a7957e26
...
...
@@ -95,6 +95,7 @@ static int forcesig = 0;
static
int
debug
=
0
;
static
int
verify
=
0
;
static
int
clevel
=
4
;
static
int
fullsig
=
0
;
static
int
hashtype
=
HASH_TYPE_SHA1
;
static
int
hashlen
=
20
;
static
long
hashblksize
=
HASHBLK_SIZE
/
512
;
...
...
@@ -110,6 +111,7 @@ usage(void)
"
\n
"
"-S Use signature files when computing differences.
\n
"
"-V Verify consistency of image and signature.
\n
"
"-F Generate a full-image signature for the delta.
\n
"
"-f Force imagedelta to use a questionable sigfile.
\n
"
"-d Enable debugging.
\n
"
"-D hfunc Hash function to use (md5 or sha1).
\n
"
...
...
@@ -663,7 +665,7 @@ main(int argc, char **argv)
{
int
ch
;
while
((
ch
=
getopt
(
argc
,
argv
,
"SfdVb:D:"
))
!=
-
1
)
while
((
ch
=
getopt
(
argc
,
argv
,
"SfdVb:D:
F
"
))
!=
-
1
)
switch
(
ch
)
{
case
'S'
:
usesigfiles
=
1
;
...
...
@@ -704,6 +706,9 @@ main(int argc, char **argv)
usage
();
}
break
;
case
'F'
:
fullsig
=
1
;
break
;
case
'h'
:
case
'?'
:
default:
...
...
@@ -856,8 +861,12 @@ main(int argc, char **argv)
}
free
(
cstate
);
/* readjust to reflect the actual number of hash entries */
delta
.
ndz
->
hashentries
=
delta
.
ndz
->
hashcurentry
;
/* write the new sigfile */
if
(
ndz_writehashinfo
(
delta
.
ndz
,
delta
.
sigfile
)
!=
0
)
{
if
(
ndz_writehashinfo
(
fullsig
?
ndz2
.
ndz
:
delta
.
ndz
,
delta
.
sigfile
,
argv
[
2
])
!=
0
)
{
fprintf
(
stderr
,
"%s: could not write signature file %s
\n
"
,
argv
[
2
],
delta
.
sigfile
);
}
...
...
clientside/os/imagezip/libndz/hash.c
View file @
a7957e26
...
...
@@ -246,11 +246,10 @@ writehinfo(struct ndz_rangemap *map, struct ndz_range *range, void *arg)
* Write out hash (signature) info associated with the named image.
*/
int
ndz_writehashinfo
(
struct
ndz_file
*
ndz
,
char
*
sigfile
)
ndz_writehashinfo
(
struct
ndz_file
*
ndz
,
char
*
sigfile
,
char
*
ifile
)
{
int
ofd
,
cc
;
struct
hashinfo
hi
;
char
*
iname
;
if
(
ndz
==
NULL
||
ndz
->
hashmap
==
NULL
||
sigfile
==
NULL
)
return
-
1
;
...
...
@@ -261,7 +260,8 @@ ndz_writehashinfo(struct ndz_file *ndz, char *sigfile)
return
-
1
;
}
iname
=
ndz
->
fname
;
if
(
ifile
==
NULL
)
ifile
=
ndz
->
fname
;
memset
(
&
hi
,
0
,
sizeof
(
hi
));
strcpy
((
char
*
)
hi
.
magic
,
HASH_MAGIC
);
...
...
@@ -277,7 +277,7 @@ ndz_writehashinfo(struct ndz_file *ndz, char *sigfile)
else
fprintf
(
stderr
,
"%s: incomplete write (%d) to sigfile %s
\n
"
,
i
nam
e
,
cc
,
sigfile
);
i
fil
e
,
cc
,
sigfile
);
close
(
ofd
);
unlink
(
sigfile
);
return
-
1
;
...
...
@@ -290,7 +290,7 @@ ndz_writehashinfo(struct ndz_file *ndz, char *sigfile)
(
void
*
)(
uintptr_t
)
ofd
)
!=
0
)
{
fprintf
(
stderr
,
"%s: could not write one or more hash entries to sigfile %s
\n
"
,
ndz
->
fnam
e
,
sigfile
);
ifil
e
,
sigfile
);
close
(
ofd
);
unlink
(
sigfile
);
return
-
1
;
...
...
@@ -303,11 +303,11 @@ ndz_writehashinfo(struct ndz_file *ndz, char *sigfile)
* This is a crude (but fast!) method for matching images with
* signatures.
*/
if
(
strcmp
(
i
nam
e
,
"-"
)
!=
0
)
{
if
(
strcmp
(
i
fil
e
,
"-"
)
!=
0
)
{
struct
stat
sb
;
struct
timeval
tm
[
2
];
cc
=
stat
(
i
nam
e
,
&
sb
);
cc
=
stat
(
i
fil
e
,
&
sb
);
if
(
cc
>=
0
)
{
#ifdef linux
tm
[
0
].
tv_sec
=
sb
.
st_atime
;
...
...
@@ -326,7 +326,7 @@ ndz_writehashinfo(struct ndz_file *ndz, char *sigfile)
sigfile
,
strerror
(
errno
));
}
fprintf
(
stderr
,
"%s: new signature written to %s
\n
"
,
i
nam
e
,
sigfile
);
fprintf
(
stderr
,
"%s: new signature written to %s
\n
"
,
i
fil
e
,
sigfile
);
return
0
;
}
...
...
clientside/os/imagezip/libndz/libndz.h
View file @
a7957e26
...
...
@@ -104,7 +104,7 @@ ssize_t ndz_chunk_left(ndz_chunk_t chobj);
ssize_t
ndz_chunk_append
(
ndz_chunk_t
chobj
,
void
*
buf
,
size_t
bytes
);
struct
ndz_rangemap
*
ndz_readhashinfo
(
struct
ndz_file
*
ndz
,
char
*
sigfile
);
int
ndz_writehashinfo
(
struct
ndz_file
*
ndz
,
char
*
sigfile
);
int
ndz_writehashinfo
(
struct
ndz_file
*
ndz
,
char
*
sigfile
,
char
*
ifile
);
void
ndz_hash_data
(
struct
ndz_file
*
ndz
,
unsigned
char
*
data
,
unsigned
long
count
,
unsigned
char
*
hash
);
char
*
ndz_hash_dump
(
unsigned
char
*
h
,
int
hlen
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment