Improvements about the block address of empty data files

This commit is contained in:
2010-11-25 14:40:44 +01:00
parent b2997dcc46
commit 5482d5d7b4
6 changed files with 28 additions and 44 deletions

View File

@ -1730,6 +1730,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->mipsel_p_vaddr = 0;
target->mipsel_p_filesz = 0;
target->empty_file_block = 0;
for (i = 0; i < ISO_MAX_PARTITIONS; i++) {
target->appended_partitions[i] = NULL;
if (opts->appended_partitions[i] != NULL) {
@ -1833,6 +1835,11 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
/* Volume Descriptor Set Terminator */
target->curblock++;
/* All empty files point to the Volume Descriptor Set Terminator
* rather than to addresses of non-empty files.
*/
target->empty_file_block = target->curblock - 1;
/*
* Create the writer for possible padding to ensure that in case of image
* growing we can safely overwrite the first 64 KiB of image.

View File

@ -470,6 +470,11 @@ struct ecma119_image
*/
uint32_t curblock;
/*
* The address to be used for the content pointer of empty data files.
*/
uint32_t empty_file_block;
/*
* number of dirs in ECMA-119 tree, computed together with dir position,
* and needed for path table computation in a efficient way

View File

@ -309,6 +309,7 @@ int create_image(IsoImage *image, const char *image_path,
int boot_media_type = 0;
int load_sectors = 0; /* number of sector to load */
unsigned char partition_type = 0;
off_t size;
IsoNode *imgfile;
IsoStream *stream;
@ -331,9 +332,16 @@ int create_image(IsoImage *image, const char *image_path,
return ISO_BOOT_IMAGE_NOT_VALID;
}
size = iso_stream_get_size(stream);
if (size <= 0) {
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Boot image file is empty");
return ISO_BOOT_IMAGE_NOT_VALID;
}
switch (type) {
case ELTORITO_FLOPPY_EMUL:
switch (iso_stream_get_size(stream)) {
switch (size) {
case 1200 * 1024:
boot_media_type = 1; /* 1.2 meg diskette */
break;

View File

@ -266,7 +266,12 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
/*
* final section
*/
file->sections[extent].block = t->curblock + extent * (ISO_EXTENT_SIZE / BLOCK_SIZE);
if (section_size <= 0) {
file->sections[extent].block = t->empty_file_block;
} else {
file->sections[extent].block =
t->curblock + extent * (ISO_EXTENT_SIZE / BLOCK_SIZE);
}
file->sections[extent].size = (uint32_t)section_size;
t->curblock += DIV_UP(iso_file_src_get_size(file), BLOCK_SIZE);

View File

@ -1224,7 +1224,6 @@ void iso_write_opts_free(IsoWriteOpts *opts);
*/
int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel);
/**
* Set the ISO-9960 level to write at.
*