From e57e45e40bddd1b0f71fc49340614eea7f1e53eb Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 27 May 2012 18:55:04 +0200 Subject: [PATCH] New API call iso_write_opts_set_hfsp_serial_number(). --- libisofs/ecma119.c | 17 ++++++++++++++--- libisofs/ecma119.h | 10 ++++++++++ libisofs/libisofs.h | 17 +++++++++++++++++ libisofs/libisofs.ver | 1 + 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index 30f5212..2802654 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -1815,6 +1815,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) goto target_cleanup; } + memcpy(target->hfsp_serial_number, opts->hfsp_serial_number, 8); + target->md5_file_checksums = opts->md5_file_checksums; target->md5_session_checksum = opts->md5_session_checksum; strcpy(target->scdbackup_tag_parm, opts->scdbackup_tag_parm); @@ -1875,9 +1877,9 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img) } strcpy(target->ascii_disc_label, opts->ascii_disc_label); for (i = 0; i < ISO_HFSPLUS_BLESS_MAX; i++) { - target->hfsplus_blessed[i] = src->hfsplus_blessed[i]; - if (target->hfsplus_blessed[i] != NULL) - iso_node_ref(target->hfsplus_blessed[i]); + target->hfsplus_blessed[i] = src->hfsplus_blessed[i]; + if (target->hfsplus_blessed[i] != NULL) + iso_node_ref(target->hfsplus_blessed[i]); } target->apm_block_size = 512; for (i = 0; i < ISO_APM_ENTRIES_MAX; i++) @@ -2617,6 +2619,8 @@ int iso_write_opts_new(IsoWriteOpts **opts, int profile) wopts->allow_dir_id_ext = 0; wopts->old_empty = 0; wopts->untranslated_name_len = 0; + for (i = 0; i < 8; i++) + wopts->hfsp_serial_number[i] = 0; *opts = wopts; return ISO_SUCCESS; @@ -3235,4 +3239,11 @@ int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label) opts->ascii_disc_label[ISO_DISC_LABEL_SIZE - 1] = 0; return ISO_SUCCESS; } + +int iso_write_opts_set_hfsp_serial_number(IsoWriteOpts *opts, + uint8_t serial_number[8]) +{ + memcpy(opts->hfsp_serial_number, serial_number, 8); + return ISO_SUCCESS; +} diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index 04426fb..2de7d9c 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -449,6 +449,11 @@ struct iso_write_opts { */ char ascii_disc_label[ISO_DISC_LABEL_SIZE]; + /* HFS+ image serial number. + * 00...00 means that it shall be generated by libisofs. + */ + uint8_t hfsp_serial_number[8]; + }; typedef struct ecma119_image Ecma119Image; @@ -553,6 +558,11 @@ struct ecma119_image char *input_charset; char *output_charset; + /* See iso_write_opts and iso_write_opts_set_hfsp_serial_number(). + * 00...00 means that it shall be generated by libisofs. + */ + uint8_t hfsp_serial_number[8]; + unsigned int appendable : 1; uint32_t ms_block; /**< start block for a ms image */ time_t now; /**< Time at which writing began. */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index b2ffb0d..490085c 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -1410,6 +1410,23 @@ int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable); */ int iso_write_opts_set_hfsplus(IsoWriteOpts *opts, int enable); +/** + * Supply a serial number for the HFS+ extension of the emerging image. + * + * @param opts + * The option set to be manipulated. + * @param serial_number + * 8 bytes which should be unique to the image. + * If all bytes are 0, then the serial number will be generated as + * random number by libisofs. This is the default setting. + * @return + * 1 success, < 0 error + * + * @since 1.2.4 + */ +int iso_write_opts_set_hfsp_serial_number(IsoWriteOpts *opts, + uint8_t serial_number[8]); + /** * Whether to use newer ISO-9660:1999 version. * diff --git a/libisofs/libisofs.ver b/libisofs/libisofs.ver index aedf021..57f057f 100644 --- a/libisofs/libisofs.ver +++ b/libisofs/libisofs.ver @@ -286,6 +286,7 @@ iso_write_opts_set_dir_rec_mtime; iso_write_opts_set_disc_label; iso_write_opts_set_fifo_size; iso_write_opts_set_hardlinks; +iso_write_opts_set_hfsp_serial_number; iso_write_opts_set_hfsplus; iso_write_opts_set_iso1999; iso_write_opts_set_iso_level;