From 79a45f90f63aad23ff36bab932ef1a748293e156 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 12 Aug 2016 18:46:36 +0000 Subject: [PATCH] New API calls isoburn_igopt_set_gpt_guid(), isoburn_igopt_get_gpt_guid() --- libisoburn/isoburn.c | 34 +++++++++++++++++++++++++++++- libisoburn/isoburn.h | 5 +++++ libisoburn/libisoburn.h | 41 +++++++++++++++++++++++++++++++++++++ libisoburn/libisoburn.ver | 2 ++ xorriso/xorriso_timestamp.h | 2 +- 5 files changed, 82 insertions(+), 2 deletions(-) diff --git a/libisoburn/isoburn.c b/libisoburn/isoburn.c index ae8156e8..01b07894 100644 --- a/libisoburn/isoburn.c +++ b/libisoburn/isoburn.c @@ -405,7 +405,7 @@ int isoburn_make_iso_write_opts(struct isoburn *out_o, IsoWriteOpts *wopts, int flag) { - int ret, rec_mtime, new_img, lba, nwa, i; + int ret, rec_mtime, new_img, lba, nwa, i, guid_mode; struct burn_drive *out_d; new_img= flag&1; @@ -477,6 +477,10 @@ int isoburn_make_iso_write_opts(struct isoburn *out_o, opts->vol_creation_time, opts->vol_modification_time, opts->vol_expiration_time, opts->vol_effective_time, opts->vol_uuid); + guid_mode= opts->gpt_guid_mode; + if(opts->vol_uuid[0] == 0 && opts->gpt_guid_mode == 2) + guid_mode= 0; + iso_write_opts_set_gpt_guid(wopts, opts->gpt_guid, guid_mode); iso_write_opts_attach_jte(wopts, opts->libjte_handle); iso_write_opts_set_hfsp_serial_number(wopts, opts->hfsp_serial_number); @@ -1175,6 +1179,8 @@ int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag) o->appended_as_gpt= 0; o->appended_as_apm= 0; o->part_like_isohybrid= 0; + memset(o->gpt_guid, 0, 16); + o->gpt_guid_mode= 0; memset(o->hfsp_serial_number, 0, 8); o->hfsp_block_size= 0; o->apm_block_size= 0; @@ -1804,6 +1810,32 @@ int isoburn_igopt_get_part_like_isohybrid(struct isoburn_imgen_opts *opts, } +int isoburn_igopt_set_gpt_guid(struct isoburn_imgen_opts *opts, + uint8_t guid[16], int mode) +{ + if(mode < 0 || mode > 2) { + isoburn_msgs_submit(NULL, 0x00060000, + "Unrecognized GPT disk GUID setup mode. (0 ... 2)", + 0, "FAILURE", 0); + return(0); + } + opts->gpt_guid_mode= mode; + if(opts->gpt_guid_mode == 1) + memcpy(opts->gpt_guid, guid, 16); + return 1; +} + + +int isoburn_igopt_get_gpt_guid(struct isoburn_imgen_opts *opts, + uint8_t guid[16], int *mode) +{ + if(opts->gpt_guid_mode == 1) + memcpy(guid, opts->gpt_guid, 16); + *mode = opts->gpt_guid_mode; + return(1); +} + + int isoburn_igopt_set_disc_label(struct isoburn_imgen_opts *opts, char *label) { strncpy(opts->ascii_disc_label, label, Libisoburn_disc_label_sizE - 1); diff --git a/libisoburn/isoburn.h b/libisoburn/isoburn.h index 3e5117d5..b1d6a39d 100644 --- a/libisoburn/isoburn.h +++ b/libisoburn/isoburn.h @@ -710,6 +710,11 @@ struct isoburn_imgen_opts { */ int part_like_isohybrid; + /* See libisoburn.h isoburn_igopt_set_gpt_guid() + */ + uint8_t gpt_guid[16]; + int gpt_guid_mode; + /* Eventual name of the non-ISO aspect of the image. E.g. SUN ASCII label. */ char ascii_disc_label[Libisoburn_disc_label_sizE]; diff --git a/libisoburn/libisoburn.h b/libisoburn/libisoburn.h index 71261105..ba7286d5 100644 --- a/libisoburn/libisoburn.h +++ b/libisoburn/libisoburn.h @@ -1987,6 +1987,47 @@ int isoburn_igopt_set_part_like_isohybrid(struct isoburn_imgen_opts *opts, int isoburn_igopt_get_part_like_isohybrid(struct isoburn_imgen_opts *opts, int *alike); +/** Control whether the emerging GPT gets a pseudo-randomly generated disk GUID + or whether it gets a user supplied GUID. + The partition GUIDs will be generated in a reproducible way by exoring a + little-endian 32 bit counter with the disk GUID beginning at byte offset 9. + @since 1.4.6 + @param opts + The option set to be manipulated. + @param guid + 16 bytes of user supplied GUID. + The upper 4 bit of guid[6] and guid[7] should bear the value 4 to + express the version 4 in both endiannesses. Bit 7 of byte[8] should + be set to 1 and bit 6 be set to 0, in order to express the RFC 4122 + variant of GUID, where version 4 means "random". + @param mode + 0 = ignore parameter guid and produce the GPT disk GUID by a + pseudo-random algorithm. This is the default setting. + 1 = use parameter guid as GPT disk GUID + 2 = ignore parameter guid and derive the GPT disk GUID from + parameter uuid of isoburn_igopt_set_pvd_times(). + The 16 bytes of uuid get copied and bytes 6, 7, 8 get their + upper bits changed to comply to RFC 4122. + If no such uuid is given when ISO production starts, then + mode 2 defaults to mode 0. +*/ +int isoburn_igopt_set_gpt_guid(struct isoburn_imgen_opts *opts, + uint8_t guid[16], int mode); + +/** Inquire the current setting of isoburn_igopt_set_gpt_guid(). + @since 1.4.6 + @param opts + The option set to be inquired. + @param guid + Returns the current guid if current mode is 1. + @param mode + Returns the current value. + @return + <=0 = error, 1 = success +*/ +int isoburn_igopt_get_gpt_guid(struct isoburn_imgen_opts *opts, + uint8_t guid[16], int *mode); + /** Set a name for the system area. This setting is ignored unless system area type 3 "SUN Disk Label" is in effect by iso_write_opts_set_system_area(). diff --git a/libisoburn/libisoburn.ver b/libisoburn/libisoburn.ver index c6129795..70348095 100644 --- a/libisoburn/libisoburn.ver +++ b/libisoburn/libisoburn.ver @@ -36,6 +36,7 @@ isoburn_igopt_get_effective_lba; isoburn_igopt_get_efi_bootp; isoburn_igopt_get_extensions; isoburn_igopt_get_fifo_size; +isoburn_igopt_get_gpt_guid; isoburn_igopt_get_hfsp_block_size; isoburn_igopt_get_hfsp_serial_number; isoburn_igopt_get_level; @@ -63,6 +64,7 @@ isoburn_igopt_set_disc_label; isoburn_igopt_set_efi_bootp; isoburn_igopt_set_extensions; isoburn_igopt_set_fifo_size; +isoburn_igopt_set_gpt_guid; isoburn_igopt_set_hfsp_block_size; isoburn_igopt_set_hfsp_serial_number; isoburn_igopt_set_level; diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 8a37b6d1..0a2c3f65 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2016.08.07.193333" +#define Xorriso_timestamP "2016.08.12.184736"