Skip to content
Snippets Groups Projects
Commit 645e6786 authored by raphael.bach's avatar raphael.bach
Browse files

Add Sparse_DumpInfo() in sparse.h

parent c4d42e81
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,10 @@ void Sparse_PrintHeader(const struct Sparse_Header * const header); ...@@ -124,6 +124,10 @@ void Sparse_PrintHeader(const struct Sparse_Header * const header);
Sparse_PrintChunkHeader() Sparse_PrintChunkHeader()
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
void Sparse_PrintChunkHeader(const struct Sparse_ChunkHeader * const header); void Sparse_PrintChunkHeader(const struct Sparse_ChunkHeader * const header);
/*------------------------------------------------------------------------------
Sparse_DumpInfo()
------------------------------------------------------------------------------*/
void Sparse_DumpInfo(const struct Sparse * const sparse);
/*============================================================================== /*==============================================================================
GUARD GUARD
==============================================================================*/ ==============================================================================*/
......
...@@ -174,3 +174,45 @@ void Sparse_PrintChunkHeader(const struct Sparse_ChunkHeader * const header) ...@@ -174,3 +174,45 @@ void Sparse_PrintChunkHeader(const struct Sparse_ChunkHeader * const header)
printf("%"PRIu32"\t\t" , header->block_count); printf("%"PRIu32"\t\t" , header->block_count);
printf("%"PRIu32"\n" , header->total_size); printf("%"PRIu32"\n" , header->total_size);
} }
/*------------------------------------------------------------------------------
Sparse_DumpInfo()
------------------------------------------------------------------------------*/
void Sparse_DumpInfo(const struct Sparse * const sparse)
{
assert(sparse != NULL);
assert(sparse->chunks != NULL);
assert(sparse->path != NULL);
printf("Path: %s\n", sparse->path);
printf("Size: %zu\n", sparse->size);
printf("magic\t\tversion_major\tversion_minor\tsize\tchunk_header_size\t"
"block_size\tblock_count\tchunk_count\timage_checksum\n");
printf("%#"PRIx32"\t" , sparse->header.magic);
printf("%"PRIu16"\t\t" , sparse->header.version_major);
printf("%"PRIu16"\t\t" , sparse->header.version_minor);
printf("%"PRIu16"\t" , sparse->header.size);
printf("%"PRIu16"\t\t\t", sparse->header.chunk_header_size);
printf("%"PRIu32"\t\t" , sparse->header.block_size);
printf("%"PRIu32"\t\t" , sparse->header.block_count);
printf("%"PRIu32"\t\t" , sparse->header.chunk_count);
printf("%"PRIu32"\n" , sparse->header.image_checksum);
printf("chunk\ttype\t\treserved1\tblock_count\ttotal_size\n");
for(size_t i = 0; i < sparse->header.chunk_count; i++) {
assert(sparse->chunks + i != NULL);
printf("%zu\t", i);
printf("%#"PRIx16 , (sparse->chunks + i)->header.type);
if((sparse->chunks + i)->header.type == CHUNK_TYPE_RAW) {
printf("(Raw)\t");
} else if((sparse->chunks + i)->header.type == CHUNK_TYPE_FILL) {
printf("(Fill)\t");
} else if((sparse->chunks + i)->header.type == CHUNK_TYPE_DONT_CARE) {
printf("(Don't care)\t");
} else if((sparse->chunks + i)->header.type == CHUNK_TYPE_CRC32) {
printf("(CRC32)\t");
} else {
printf("(Unknown)\t");
}
printf("%"PRIu16"\t\t\t" , (sparse->chunks + i)->header.reserved1);
printf("%"PRIu32"\t\t" , (sparse->chunks + i)->header.block_count);
printf("%"PRIu32"\n" , (sparse->chunks + i)->header.total_size);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment