Improvements about the block address of empty data files

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

View File

@ -258,7 +258,7 @@ Sources:
The candidates for MBR booting will normally use El Torito rather than MBR The candidates for MBR booting will normally use El Torito rather than MBR
if the ISO image is presented on CD, DVD, or BD media. if the ISO image is presented on CD, DVD, or BD media.
The eventual MBR comes into effect it the image is on a media that is The eventual MBR comes into effect if the image is on a media that is
interpreted by the BIOS as some kind of hard disk. Usually real hard disks, interpreted by the BIOS as some kind of hard disk. Usually real hard disks,
floppy disks, USB sticks, memory cards. floppy disks, USB sticks, memory cards.
@ -526,46 +526,6 @@ Byte Range | Value | Meaning
up to 2048 | 0 | ISO 9660 Block end padding up to 2048 | 0 | ISO 9660 Block end padding
---------- | ---------- | ---------------------------------------------------- ---------- | ---------- | ----------------------------------------------------
Test image produced by
genisoimage -o /u/test/mips_boot.iso -mips-boot checksum.c jte
which reports
Found mips boot image checksum.c, using extent 636 (0x27C), #blocks 14336 (0x3800)
xorriso reports as 2048 byte LBA of the boot image dummy file
File data lba: 0 , 159 , 7 , 14330 , '/CHECKSUM.C'
First 512 bytes in hex:
0 : 0b e5 a9 41 00 00 00 00 00 00 00 00 00 00 00 00
16 : 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00
32 : 00 01 00 00 00 00 00 20 02 00 00 00 00 00 00 34
48 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
64 : 00 00 00 00 00 00 00 00 63 68 65 63 6b 73 75 6d
80 : 00 00 02 7c 00 00 38 00 00 00 00 00 00 00 00 00
... 0 ...
400 : 00 00 00 00 00 00 00 00 00 00 0a 28 00 00 00 00
416 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
432 : 00 00 0a 28 00 00 00 00 00 00 00 06 00 00 00 00
... 0 ...
496 : 00 00 00 00 00 00 00 00 22 ec 2c c9 00 00 00 00
The 32 bit two's complement of bytes 0 to 503 is 0x22ec2cc9.
In decimal:
0 : 11 229 169 65 0 0 0 0 0 0 0 0 0 0 0 0
16 : 0 0 0 0 0 0 0 0 0 0 0 0 0 81 0 0
32 : 0 1 0 0 0 0 0 32 2 0 0 0 0 0 0 52
48 : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
64 : 0 0 0 0 0 0 0 0 99 104 101 99 107 115 117 109
80 : 0 0 2 124 0 0 56 0 0 0 0 0 0 0 0 0
... 0 ...
400 : 0 0 0 0 0 0 0 0 0 0 10 40 0 0 0 0
416 : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
432 : 0 0 10 40 0 0 0 0 0 0 0 6 0 0 0 0
... 0 ...
496 : 0 0 0 0 0 0 0 0 34 236 44 201 0 0 0 0
Cleartext part:
64 : c h e c k s u m
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -1730,6 +1730,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
target->mipsel_p_vaddr = 0; target->mipsel_p_vaddr = 0;
target->mipsel_p_filesz = 0; target->mipsel_p_filesz = 0;
target->empty_file_block = 0;
for (i = 0; i < ISO_MAX_PARTITIONS; i++) { for (i = 0; i < ISO_MAX_PARTITIONS; i++) {
target->appended_partitions[i] = NULL; target->appended_partitions[i] = NULL;
if (opts->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 */ /* Volume Descriptor Set Terminator */
target->curblock++; 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 * Create the writer for possible padding to ensure that in case of image
* growing we can safely overwrite the first 64 KiB 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; 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, * number of dirs in ECMA-119 tree, computed together with dir position,
* and needed for path table computation in a efficient way * 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 boot_media_type = 0;
int load_sectors = 0; /* number of sector to load */ int load_sectors = 0; /* number of sector to load */
unsigned char partition_type = 0; unsigned char partition_type = 0;
off_t size;
IsoNode *imgfile; IsoNode *imgfile;
IsoStream *stream; IsoStream *stream;
@ -331,9 +332,16 @@ int create_image(IsoImage *image, const char *image_path,
return ISO_BOOT_IMAGE_NOT_VALID; 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) { switch (type) {
case ELTORITO_FLOPPY_EMUL: case ELTORITO_FLOPPY_EMUL:
switch (iso_stream_get_size(stream)) { switch (size) {
case 1200 * 1024: case 1200 * 1024:
boot_media_type = 1; /* 1.2 meg diskette */ boot_media_type = 1; /* 1.2 meg diskette */
break; break;

View File

@ -266,7 +266,12 @@ int filesrc_writer_compute_data_blocks(IsoImageWriter *writer)
/* /*
* final section * 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; file->sections[extent].size = (uint32_t)section_size;
t->curblock += DIV_UP(iso_file_src_get_size(file), BLOCK_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); int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel);
/** /**
* Set the ISO-9960 level to write at. * Set the ISO-9960 level to write at.
* *