Report writting progress.

This commit is contained in:
Vreixo Formoso 2007-12-29 17:42:57 +01:00
parent a2645cbf40
commit 4b8db2f274
2 changed files with 21 additions and 0 deletions

View File

@ -656,6 +656,9 @@ void *write_function(void *arg)
Ecma119Image *target = (Ecma119Image*)arg;
iso_msg_debug(target->image, "Starting image writing...");
target->bytes_written = (off_t) 0;
target->percent_written = 0;
/* Write System Area, 16 blocks of zeros (ECMA-119, 6.2.1) */
memset(buf, 0, BLOCK_SIZE);
for (i = 0; i < 16; ++i) {
@ -960,5 +963,19 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
/* reader cancelled */
return ISO_WRITE_ERROR;
}
target->bytes_written += count;
{
int percent = (target->bytes_written * 100) / target->total_size;
/* only report in 5% chunks */
if (percent >= target->percent_written + 5) {
iso_msg_debug(target->image, "Processed %u of %u KB (%d %%)",
(unsigned int) target->bytes_written >> 10,
(unsigned int) target->total_size >> 10, percent);
target->percent_written = percent;
}
}
return ret;
}

View File

@ -73,6 +73,10 @@ struct ecma119_image
off_t total_size;
uint32_t vol_space_size;
/* Bytes already written, just for progress notification */
off_t bytes_written;
int percent_written;
/*
* Block being processed, either during image writing or structure
* size calculation.