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
3f02cf23
Commit
3f02cf23
authored
May 05, 2015
by
Mike Hibler
Browse files
Fix delta computation logic.
Also make case of signature that exactly matches the delta not be a fatal error.
parent
7e8e73d1
Changes
1
Show whitespace changes
Inline
Side-by-side
clientside/os/imagezip/imageundelta.c
View file @
3f02cf23
...
...
@@ -292,10 +292,11 @@ readifile(struct fileinfo *info, int usesig)
}
if
(
ssects
-
isects
==
0
)
{
fprintf
(
stderr
,
"%s: signature exactly matches image.
\n
Either image "
"is not a delta or signature is not complete.
\n
"
,
"%s: WARNING: delta signature exactly matches image.
\n
"
"Either delta is really a full image or "
"signature is not for a full image.
\n
"
,
ndz_filename
(
info
->
ndz
));
exit
(
1
)
;
return
;
}
if
(
debug
)
fprintf
(
stderr
,
"sig covers %lu more sectors than in image
\n
"
,
...
...
@@ -333,7 +334,7 @@ addmmrange(struct ndz_rangemap *mmap, ndz_addr_t addr, ndz_addr_t eaddr,
mdata
->
frombase
=
frombase
;
mdata
->
chunkno
=
chunkno
;
#ifdef APPLYDELTA_DEBUG
fprintf
(
stderr
,
" adding %s range [%lu-%lu]
:
\n
"
,
fprintf
(
stderr
,
" adding %s range [%lu-%lu]
\n
"
,
frombase
?
"base"
:
"delta"
,
addr
,
eaddr
);
#endif
if
(
ndz_rangemap_alloc
(
mmap
,
addr
,
eaddr
-
addr
+
1
,
mdata
))
{
...
...
@@ -387,9 +388,7 @@ applydelta(struct ndz_rangemap *bmap, struct ndz_range *brange, void *arg)
if
(
drange
==
NULL
||
daddr
>
beaddr
)
{
if
(
addmmrange
(
mmap
,
baddr
,
beaddr
,
1
,
(
uintptr_t
)
brange
->
data
))
goto
fail
;
state
->
dmapnext
=
drange
;
state
->
dmapaddr
=
daddr
;
return
0
;
goto
done
;
}
/*
...
...
@@ -449,6 +448,27 @@ applydelta(struct ndz_rangemap *bmap, struct ndz_range *brange, void *arg)
}
}
done:
/*
* This is the final base map entry, must add everything else
* from the delta map.
*/
if
(
brange
->
next
==
NULL
&&
drange
!=
NULL
)
{
#ifdef APPLYDELTA_DEBUG
fprintf
(
stderr
,
" base finished, adding remaining delta"
" starting at [%lu-%lu]
\n
"
,
daddr
,
deaddr
);
#endif
while
(
drange
)
{
if
(
addmmrange
(
mmap
,
daddr
,
deaddr
,
0
,
(
uintptr_t
)
drange
->
data
))
goto
fail
;
if
(
drange
->
next
)
{
daddr
=
drange
->
next
->
start
;
deaddr
=
drange
->
next
->
end
;
}
drange
=
drange
->
next
;
}
}
state
->
dmapnext
=
drange
;
state
->
dmapaddr
=
daddr
;
return
0
;
...
...
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