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
b0d48f57
Commit
b0d48f57
authored
May 07, 2015
by
Mike Hibler
Browse files
Fix bugs in the chunkmap code.
parent
8759fa6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
clientside/os/imagezip/libndz/ndzdata.c
View file @
b0d48f57
...
...
@@ -32,6 +32,7 @@
#include "libndz.h"
//#define CHUNK_DEBUG
//#define CHUNKMAP_DEBUG
#ifndef USE_CHUNKMAP
/*
...
...
@@ -73,6 +74,9 @@ ndz_readdata(struct ndz_file *ndz, void *buf, ndz_size_t nsect, ndz_addr_t sect)
ndz_chunkno_t
chunkno
,
lchunkno
;
ndz_chunk_t
chunk
;
ssize_t
rbytes
,
cc
;
#ifdef USE_CHUNKMAP
struct
ndz_range
*
prev
;
#endif
if
(
ndz
->
rangemap
==
NULL
&&
ndz_readranges
(
ndz
)
==
NULL
)
{
fprintf
(
stderr
,
"%s could not read sector ranges
\n
"
,
ndz
->
fname
);
...
...
@@ -157,9 +161,21 @@ ndz_readdata(struct ndz_file *ndz, void *buf, ndz_size_t nsect, ndz_addr_t sect)
#ifdef USE_CHUNKMAP
assert
(
chunkno
<
ndz
->
chunkmapentries
);
csect
=
ndz
->
chunkmap
[
chunkno
].
losect
;
crange
=
ndz_rangemap_lookup
(
ndz
->
rangemap
,
csect
,
NULL
);
assert
(
crange
!=
NULL
);
assert
(
crange
->
start
==
csect
);
crange
=
ndz_rangemap_lookup
(
ndz
->
rangemap
,
csect
,
&
prev
);
if
(
crange
==
NULL
)
{
if
(
prev
==
NULL
)
crange
=
ndz_rangemap_first
(
ndz
->
rangemap
);
else
crange
=
prev
->
next
;
assert
(
crange
!=
NULL
);
}
csect
=
crange
->
start
;
assert
(
csect
<=
ndz
->
chunkmap
[
chunkno
].
hisect
);
#ifdef CHUNKMAP_DEBUG
fprintf
(
stderr
,
"lookup chunk %u range [%lu-%lu] returns %lu
\n
"
,
chunkno
,
ndz
->
chunkmap
[
chunkno
].
losect
,
ndz
->
chunkmap
[
chunkno
].
hisect
,
csect
);
#endif
#else
{
struct
fcarg
fcarg
;
...
...
clientside/os/imagezip/libndz/ndzfile.c
View file @
b0d48f57
...
...
@@ -31,6 +31,8 @@
#include "libndz.h"
//#define CHUNKMAP_DEBUG
struct
ndz_file
*
ndz_open
(
const
char
*
name
,
int
forwrite
)
{
...
...
@@ -241,9 +243,10 @@ ndz_readranges(struct ndz_file *ndz)
ndz_rangemap_deinit
(
map
);
return
NULL
;
}
#if 0
fprintf(stderr, "allocated chunkmap of %lu bytes\n",
ndz->chunkmapentries * sizeof(ndz->chunkmap[0]));
#ifdef CHUNKMAP_DEBUG
fprintf
(
stderr
,
"allocated chunkmap of %lu bytes for %u chunks
\n
"
,
ndz
->
chunkmapentries
*
sizeof
(
ndz
->
chunkmap
[
0
]),
ndz
->
chunkmapentries
);
#endif
}
#endif
...
...
@@ -253,7 +256,7 @@ ndz_readranges(struct ndz_file *ndz)
*/
for
(
chunkno
=
0
;
;
chunkno
++
)
{
#ifdef USE_CHUNKMAP
ndz_addr_t
clo
,
chi
=
0
;
ndz_addr_t
clo
=
0
,
chi
=
0
;
#endif
rv
=
ndz_readchunkheader
(
ndz
,
chunkno
,
&
head
);
...
...
@@ -317,6 +320,9 @@ ndz_readranges(struct ndz_file *ndz)
}
ndz
->
chunkmapentries
=
chunkno
+
1
;
}
#ifdef CHUNKMAP_DEBUG
fprintf
(
stderr
,
"chunkmap[%u]: [%lu-%lu]
\n
"
,
chunkno
,
clo
,
chi
);
#endif
ndz
->
chunkmap
[
chunkno
].
losect
=
clo
;
ndz
->
chunkmap
[
chunkno
].
hisect
=
chi
;
#endif
...
...
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