From ed1041a0692038d5b9bd89235bb429caa85fa889 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 25 Nov 2008 12:23:25 +0100 Subject: [PATCH] Bug fix for ticket 145: ISOLINUX boot image does not get patched properly Delayed the computation of El Torito until all other computation methods were called. This ensures that the LBA of isolinux.bin is already computed when the patching gets defined. The position of the El Torito writer in the list was not changed. The call sequence of the write methods was not changed. --- libisofs/ecma119.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 52be0c5..053cab5 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -853,6 +853,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) { int ret, i, voldesc_size, nwriters; Ecma119Image *target; + int el_torito_writer_index = -1; /* 1. Allocate target and copy opts there */ target = calloc(1, sizeof(Ecma119Image)); @@ -977,6 +978,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) if (ret < 0) { goto target_cleanup; } + el_torito_writer_index = target->nwriters - 1; } /* create writer for Joliet structure */ @@ -1023,11 +1025,28 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) */ for (i = 0; i < target->nwriters; ++i) { IsoImageWriter *writer = target->writers[i]; + +#define Libisofs_patch_ticket_145 yes +#ifdef Libisofs_patch_ticket_145 + /* Delaying boot image patching until new LBA is known */ + if (i == el_torito_writer_index) + continue; +#endif ret = writer->compute_data_blocks(writer); if (ret < 0) { goto target_cleanup; } } +#ifdef Libisofs_patch_ticket_145 + /* Now perform delayed image patching */ + if (el_torito_writer_index >= 0) { + IsoImageWriter *writer = target->writers[el_torito_writer_index]; + ret = writer->compute_data_blocks(writer); + if (ret < 0) { + goto target_cleanup; + } + } +#endif /* Libisofs_patch_ticket_145 */ /* create the ring buffer */ ret = iso_ring_buffer_new(opts->fifo_size, &target->buffer);