diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 290020e..ec4be4d 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -1412,7 +1412,9 @@ void *write_function(void *arg) target->eff_partition_offset = 0; if (res == ISO_CANCELED) { /* canceled */ - iso_msg_submit(target->image->id, ISO_IMAGE_WRITE_CANCELED, 0, NULL); + if (!target->will_cancel) + iso_msg_submit(target->image->id, ISO_IMAGE_WRITE_CANCELED, + 0, NULL); } else { /* image write error */ iso_msg_submit(target->image->id, ISO_WRITE_ERROR, res, @@ -1565,6 +1567,7 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) target->image = src; iso_image_ref(src); + target->will_cancel = opts->will_cancel; target->iso_level = opts->level; target->rockridge = opts->rockridge; target->joliet = opts->joliet; @@ -2330,6 +2333,7 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile) for (i = 0; i < ISO_MAX_PARTITIONS; i++) wopts->appended_partitions[i] = NULL; wopts->ascii_disc_label[0] = 0; + wopts->will_cancel = 0; *opts = wopts; return ISO_SUCCESS; @@ -2352,6 +2356,15 @@ void iso_write_opts_free(IsoWriteOpts *opts) free(opts); } +int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel) +{ + if (opts == NULL) { + return ISO_NULL_POINTER; + } + opts->will_cancel = !!will_cancel; + return ISO_SUCCESS; +} + int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level) { if (opts == NULL) { diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index dc907c8..c65610a 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -57,6 +57,8 @@ */ struct iso_write_opts { + int will_cancel; + int level; /**< ISO level to write at. (ECMA-119, 10) */ /** Which extensions to support. */ @@ -379,6 +381,8 @@ struct ecma119_image IsoImage *image; Ecma119Node *root; + int will_cancel :1; + unsigned int iso_level :2; /* extensions */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index bf3036c..5a79efb 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -1205,6 +1205,26 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile); */ void iso_write_opts_free(IsoWriteOpts *opts); +/** + * Announce that only the image size is desired and that the write thread + * will be cancelled by the .cancel() method of the struct burn_source that + * consumes the image output stream. + * This avoids to generate a MISHAP event when the effect of .cancel() + * reaches the image generator thread. + * + * @param opts + * The option set to be manipulated. + * @param will_cancel + * 0= normal image generation + * 1= prepare for being canceled before image stream output is completed + * @return + * 1 success, < 0 error + * + * @since 0.6.40 + */ +int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel); + + /** * Set the ISO-9960 level to write at. * diff --git a/libisofs/libisofs.ver b/libisofs/libisofs.ver index c9b25dd..ceb7b8f 100644 --- a/libisofs/libisofs.ver +++ b/libisofs/libisofs.ver @@ -293,6 +293,7 @@ iso_write_opts_set_scdbackup_tag; iso_write_opts_set_sort_files; iso_write_opts_set_system_area; iso_write_opts_set_tail_blocks; +iso_write_opts_set_will_cancel; iso_zisofs_get_params; iso_zisofs_get_refcounts; iso_zisofs_set_params;