Print more verbose info for flux images with tool

This commit is contained in:
Rebecca Wallander
2026-01-01 00:25:44 +01:00
parent d644f81fe3
commit 588b354725

View File

@@ -857,6 +857,114 @@ int info(const char *path)
if(ctx->flux_data_header.entries > 0) {
printf("Image contains %d flux captures.\n", ctx->flux_data_header.entries);
// Get flux capture metadata
size_t flux_captures_length = 0;
int32_t res = aaruf_get_flux_captures(ctx, NULL, &flux_captures_length);
if(res == AARUF_ERROR_BUFFER_TOO_SMALL)
{
uint8_t *flux_captures = malloc(flux_captures_length);
if(flux_captures != NULL)
{
res = aaruf_get_flux_captures(ctx, flux_captures, &flux_captures_length);
if(res == AARUF_STATUS_OK)
{
size_t capture_count = flux_captures_length / sizeof(FluxCaptureMeta);
const FluxCaptureMeta *captures = (const FluxCaptureMeta *)flux_captures;
printf("Flux capture details:\n");
// Calculate statistics
uint64_t min_index_res = UINT64_MAX;
uint64_t max_index_res = 0;
uint64_t min_data_res = UINT64_MAX;
uint64_t max_data_res = 0;
// Track unique heads and tracks
uint16_t *seen_tracks = calloc(capture_count, sizeof(uint16_t));
uint32_t *seen_heads = calloc(capture_count, sizeof(uint32_t));
uint32_t track_count = 0;
uint32_t head_count = 0;
for(size_t i = 0; i < capture_count; i++)
{
// Update resolution statistics
if(captures[i].indexResolution < min_index_res) min_index_res = captures[i].indexResolution;
if(captures[i].indexResolution > max_index_res) max_index_res = captures[i].indexResolution;
if(captures[i].dataResolution < min_data_res) min_data_res = captures[i].dataResolution;
if(captures[i].dataResolution > max_data_res) max_data_res = captures[i].dataResolution;
// Track unique tracks
bool track_seen = false;
for(uint32_t j = 0; j < track_count; j++)
{
if(seen_tracks[j] == captures[i].track)
{
track_seen = true;
break;
}
}
if(!track_seen)
{
seen_tracks[track_count++] = captures[i].track;
}
// Track unique heads
bool head_seen = false;
for(uint32_t j = 0; j < head_count; j++)
{
if(seen_heads[j] == captures[i].head)
{
head_seen = true;
break;
}
}
if(!head_seen)
{
seen_heads[head_count++] = captures[i].head;
}
}
free(seen_tracks);
free(seen_heads);
// Display statistics
printf("\tStatistics:\n");
printf("\t\tUnique heads: %u\n", head_count);
printf("\t\tUnique tracks: %u\n", track_count);
if(min_index_res != UINT64_MAX)
{
printf("\t\tIndex resolution: %llu - %llu picoseconds (%.3f - %.3f nanoseconds)\n",
(unsigned long long)min_index_res, (unsigned long long)max_index_res,
min_index_res / 1000.0, max_index_res / 1000.0);
}
if(min_data_res != UINT64_MAX)
{
printf("\t\tData resolution: %llu - %llu picoseconds (%.3f - %.3f nanoseconds)\n",
(unsigned long long)min_data_res, (unsigned long long)max_data_res,
min_data_res / 1000.0, max_data_res / 1000.0);
}
// Display individual captures
printf("\tCaptures:\n");
for(size_t i = 0; i < capture_count; i++)
{
printf("\t\tCapture %zu:\n", i + 1);
printf("\t\t\tHead: %u\n", captures[i].head);
printf("\t\t\tTrack: %u\n", captures[i].track);
printf("\t\t\tSubtrack: %u\n", captures[i].subtrack);
printf("\t\t\tCapture index: %u\n", captures[i].captureIndex);
printf("\t\t\tIndex resolution: %llu picoseconds (%.3f nanoseconds)\n",
(unsigned long long)captures[i].indexResolution,
captures[i].indexResolution / 1000.0);
printf("\t\t\tData resolution: %llu picoseconds (%.3f nanoseconds)\n",
(unsigned long long)captures[i].dataResolution,
captures[i].dataResolution / 1000.0);
}
}
free(flux_captures);
}
}
}
// Checksums Section