New API calls isoburn_igopt_set_part_type_guid(), isoburn_igopt_get_part_type_guid(), isoburn_igopt_set_iso_type_guid(), isoburn_igopt_get_iso_type_guid()

This commit is contained in:
Thomas Schmitt 2019-02-18 13:03:37 +01:00
parent 122e43da86
commit caf38e81ae
4 changed files with 175 additions and 10 deletions

View File

@ -6,8 +6,8 @@
/* /*
Class core of libisoburn. Class core of libisoburn.
Copyright 2007 - 2017 Vreixo Formoso Lopes <metalpain2002@yahoo.es> Copyright 2007 - 2009 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
Thomas Schmitt <scdbackup@gmx.net> Copyright 2007 - 2019 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later. Provided under GPL version 2 or later.
*/ */
@ -554,11 +554,16 @@ int isoburn_make_iso_write_opts(struct isoburn *out_o,
0, "FAILURE", 0); 0, "FAILURE", 0);
{ret= -1; goto ex;} {ret= -1; goto ex;}
} }
iso_write_opts_set_part_type_guid(wopts, i + 1,
opts->appended_part_type_guids[i],
opts->appended_part_gpt_flags[i] & 1);
} }
iso_write_opts_set_appended_as_gpt(wopts, opts->appended_as_gpt); iso_write_opts_set_appended_as_gpt(wopts, opts->appended_as_gpt);
iso_write_opts_set_appended_as_apm(wopts, opts->appended_as_apm); iso_write_opts_set_appended_as_apm(wopts, opts->appended_as_apm);
iso_write_opts_set_part_like_isohybrid(wopts, opts->part_like_isohybrid); iso_write_opts_set_part_like_isohybrid(wopts, opts->part_like_isohybrid);
iso_write_opts_set_iso_mbr_part_type(wopts, opts->iso_mbr_part_type); iso_write_opts_set_iso_mbr_part_type(wopts, opts->iso_mbr_part_type);
iso_write_opts_set_iso_type_guid(wopts, opts->iso_gpt_type_guid,
opts->iso_gpt_flag & 1);
iso_write_opts_set_disc_label(wopts, opts->ascii_disc_label); iso_write_opts_set_disc_label(wopts, opts->ascii_disc_label);
ret= 1; ret= 1;
@ -1176,6 +1181,8 @@ int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag)
o->appended_partitions[i]= NULL; o->appended_partitions[i]= NULL;
o->appended_part_types[i]= 0; o->appended_part_types[i]= 0;
o->appended_part_flags[i]= 0; o->appended_part_flags[i]= 0;
memset(o->appended_part_type_guids[i], 0, 16);
o->appended_part_gpt_flags[i]= 0;
} }
o->appended_as_gpt= 0; o->appended_as_gpt= 0;
o->appended_as_apm= 0; o->appended_as_apm= 0;
@ -1781,6 +1788,48 @@ int isoburn_igopt_get_appended_as_gpt(struct isoburn_imgen_opts *opts,
} }
int isoburn_igopt_set_part_type_guid(struct isoburn_imgen_opts *opts,
int partition_number, uint8_t guid[16],
int valid)
{
char msg[80];
if (partition_number < 1 ||
partition_number > Libisoburn_max_appended_partitionS) {
sprintf(msg, "Partition number is out of range (1 ... %d)",
Libisoburn_max_appended_partitionS);
isoburn_msgs_submit(NULL, 0x00060000, msg, 0, "FAILURE", 0);
return(0);
}
if(valid)
memcpy(opts->appended_part_type_guids[partition_number - 1], guid, 16);
if(valid)
opts->appended_part_gpt_flags[partition_number - 1]|= 1;
else
opts->appended_part_gpt_flags[partition_number - 1]&= ~1;
return(1);
}
int isoburn_igopt_get_part_type_guid(struct isoburn_imgen_opts *opts,
int num_entries, uint8_t guids[][16],
int valids[])
{
int i, max_entry= 0;
for(i= 0; i < num_entries; i++) {
memset(guids[i], 0, 16);
valids[i]= 0;
}
for(i= 0; i < Libisoburn_max_appended_partitionS; i++) {
if(i < num_entries) {
memcpy(guids[i], opts->appended_part_type_guids[i], 16);
valids[i]= opts->appended_part_gpt_flags[i] & 1;
}
max_entry= i + 1;
}
return(max_entry);
}
int isoburn_igopt_set_appended_as_apm(struct isoburn_imgen_opts *opts, int apm) int isoburn_igopt_set_appended_as_apm(struct isoburn_imgen_opts *opts, int apm)
{ {
opts->appended_as_apm= !!apm; opts->appended_as_apm= !!apm;
@ -1830,6 +1879,24 @@ int isoburn_igopt_get_iso_mbr_part_type(struct isoburn_imgen_opts *opts,
} }
int isoburn_igopt_set_iso_type_guid(struct isoburn_imgen_opts *opts,
uint8_t guid[16], int valid)
{
if(valid)
memcpy(opts->iso_gpt_type_guid, guid, 16);
opts->iso_gpt_flag= (opts->iso_gpt_flag & ~1) | !!valid;
return(1);
}
int isoburn_igopt_get_iso_type_guid(struct isoburn_imgen_opts *opts,
uint8_t guid[16])
{
memcpy(guid, opts->iso_gpt_type_guid, 16);
return(opts->iso_gpt_flag & 1);
}
int isoburn_igopt_set_gpt_guid(struct isoburn_imgen_opts *opts, int isoburn_igopt_set_gpt_guid(struct isoburn_imgen_opts *opts,
uint8_t guid[16], int mode) uint8_t guid[16], int mode)
{ {

View File

@ -2,8 +2,9 @@
/* /*
Class struct of libisoburn. Class struct of libisoburn.
Copyright 2007 - 2017 Vreixo Formoso Lopes <metalpain2002@yahoo.es> Copyright 2007 - 2009 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net> Copyright 2007 - 2019 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later. Provided under GPL version 2 or later.
*/ */
@ -691,12 +692,19 @@ struct isoburn_imgen_opts {
char *efi_boot_partition; char *efi_boot_partition;
int efi_boot_part_flag; int efi_boot_part_flag;
/* Eventual disk file paths of prepared images which shall be appended /* Disk file paths of prepared images which shall be appended
after the ISO image and described by partiton table entries in a MBR. after the ISO image and described by partiton table entries in a MBR.
NULL means unused.
*/ */
char *appended_partitions[Libisoburn_max_appended_partitionS]; char *appended_partitions[Libisoburn_max_appended_partitionS];
uint8_t appended_part_types[Libisoburn_max_appended_partitionS]; uint8_t appended_part_types[Libisoburn_max_appended_partitionS];
int appended_part_flags[Libisoburn_max_appended_partitionS]; int appended_part_flags[Libisoburn_max_appended_partitionS];
uint8_t appended_part_type_guids[Libisoburn_max_appended_partitionS][16];
/* Flags in case that appended partitions show up in GPT:
bit0= appended_part_type_guids[same_index] is valid
*/
uint8_t appended_part_gpt_flags[Libisoburn_max_appended_partitionS];
/* If 1: With appended partitions: create protective MBR and mark by GPT /* If 1: With appended partitions: create protective MBR and mark by GPT
*/ */
@ -714,6 +722,13 @@ struct isoburn_imgen_opts {
*/ */
int iso_mbr_part_type; int iso_mbr_part_type;
/* isoburn_igopt_set_iso_type_guid()
*/
uint8_t iso_gpt_type_guid[16];
/* bit0= iso_gpt_type_guid is valid
*/
int iso_gpt_flag;
/* See libisoburn.h isoburn_igopt_set_gpt_guid() /* See libisoburn.h isoburn_igopt_set_gpt_guid()
*/ */
uint8_t gpt_guid[16]; uint8_t gpt_guid[16];

View File

@ -5,8 +5,8 @@
/* /*
Lower level API definition of libisoburn. Lower level API definition of libisoburn.
Copyright 2007-2018 Vreixo Formoso Lopes <metalpain2002@yahoo.es> Copyright 2007-2009 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net> Copyright 2007-2019 Thomas Schmitt <scdbackup@gmx.net>
Provided under GPL version 2 or later. Provided under GPL version 2 or later.
*/ */
@ -249,7 +249,7 @@ void isoburn_version(int *major, int *minor, int *micro);
*/ */
#define isoburn_libisofs_req_major 1 #define isoburn_libisofs_req_major 1
#define isoburn_libisofs_req_minor 5 #define isoburn_libisofs_req_minor 5
#define isoburn_libisofs_req_micro 0 #define isoburn_libisofs_req_micro 1
/** The minimum version of libburn to be used with this version of libisoburn /** The minimum version of libburn to be used with this version of libisoburn
at compile time. at compile time.
@ -1898,7 +1898,6 @@ int isoburn_igopt_set_part_flag(struct isoburn_imgen_opts *opts,
int isoburn_igopt_get_part_flags(struct isoburn_imgen_opts *opts, int isoburn_igopt_get_part_flags(struct isoburn_imgen_opts *opts,
int num_entries, int part_flags[]); int num_entries, int part_flags[]);
/** Control whether partitions created by iso_write_opts_set_partition_img() /** Control whether partitions created by iso_write_opts_set_partition_img()
are to be represented in MBR or as GPT partitions. are to be represented in MBR or as GPT partitions.
@since 1.4.0 @since 1.4.0
@ -1929,6 +1928,50 @@ int isoburn_igopt_set_appended_as_gpt(struct isoburn_imgen_opts *opts,
int isoburn_igopt_get_appended_as_gpt(struct isoburn_imgen_opts *opts, int isoburn_igopt_get_appended_as_gpt(struct isoburn_imgen_opts *opts,
int *gpt); int *gpt);
/** Set the GPT Type GUID for a partition defined by
isoburn_igopt_set_partition_img().
@since 1.5.2
@param opts
The option set to be manipulated.
@param partition_number
Depicts the partition table entry which shall get the Type GUID.
@param guid
16 bytes of user supplied GUID. Readily byte-swapped from the text
form as prescribed by UEFI specs:
4 byte, 2 byte, 2 byte as little-endian.
2 byte, 6 byte as big-endian.
@param valid
Set to 1 to make this Type GUID valid.
Set to 0 in order to invalidate a previously made setting. In this
case MBR type 0xEF will become the EFI Type GUID. All others will
become the Basic Data Partition Type GUID.
@return
<=0 = error, 1 = success
*/
int isoburn_igopt_set_part_type_guid(struct isoburn_imgen_opts *opts,
int partition_number, uint8_t guid[16],
int valid);
/** Inquire the current settings made by isoburn_igopt_set_part_type_guid().
@since 1.5.2
@param opts
The option set to be inquired.
@param num_entries
Number of array elements in part_flags[].
@param type_guids
The array elements 0 to num_entries - 1 will get filled by the
16 flag bits of the images of the corresponding partition.
@param valids
The array elements 0 to num_entries - 1 will get filled by 1 or 0
to indicate whether the corresponding type_guids elemet is valid.
@return
<0 = error
0 = no partition image set
>0 highest used partition number
*/
int isoburn_igopt_get_part_type_guid(struct isoburn_imgen_opts *opts,
int num_entries, uint8_t guids[][16],
int valids[]);
/** Control whether partitions created by iso_write_opts_set_partition_img() /** Control whether partitions created by iso_write_opts_set_partition_img()
are to be represented in Apple Partition Map. are to be represented in Apple Partition Map.
@ -2018,6 +2061,39 @@ int isoburn_igopt_set_iso_mbr_part_type(struct isoburn_imgen_opts *opts,
int isoburn_igopt_get_iso_mbr_part_type(struct isoburn_imgen_opts *opts, int isoburn_igopt_get_iso_mbr_part_type(struct isoburn_imgen_opts *opts,
int *part_type); int *part_type);
/** Set the GPT Type GUID for the partition which represents the ISO 9660
filesystem, if such a partition emerges in GPT.
@since 1.5.2
@param opts
The option set to be manipulated.
@param guid
16 bytes of user supplied GUID. Readily byte-swapped from the text
form as prescribed by UEFI specs:
4 byte, 2 byte, 2 byte as little-endian.
2 byte, 6 byte as big-endian.
@param valid
Set to 1 to make this Type GUID valid.
Set to 0 in order to invalidate a previously made setting. In this
case the setting of isoburn_igopt_set_iso_mbr_part_type() or its
default gets into effect.
@return
<=0 = error, 1 = success
*/
int isoburn_igopt_set_iso_type_guid(struct isoburn_imgen_opts *opts,
uint8_t guid[16], int valid);
/** Inquire the current setting of isoburn_igopt_set_iso_type_guid().
@since 1.5.2
@param opts
The option set to be inquired.
@param guid
Gets filled with the 16 bytes of GUID.
@return
<= error, 0= guid is invalid, 1 = guid is valid
*/
int isoburn_igopt_get_iso_type_guid(struct isoburn_imgen_opts *opts,
uint8_t guid[16]);
/** Control whether the emerging GPT gets a pseudo-randomly generated disk GUID /** Control whether the emerging GPT gets a pseudo-randomly generated disk GUID
or whether it gets a user supplied GUID. or whether it gets a user supplied GUID.
The partition GUIDs will be generated in a reproducible way by exoring a The partition GUIDs will be generated in a reproducible way by exoring a
@ -2026,7 +2102,10 @@ int isoburn_igopt_get_iso_mbr_part_type(struct isoburn_imgen_opts *opts,
@param opts @param opts
The option set to be manipulated. The option set to be manipulated.
@param guid @param guid
16 bytes of user supplied GUID. 16 bytes of user supplied GUID. Readily byte-swapped from the text
form as prescribed by UEFI specs:
4 byte, 2 byte, 2 byte as little-endian.
2 byte, 6 byte as big-endian.
The upper 4 bit of guid[6] and guid[7] should bear the value 4 to 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 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 be set to 1 and bit 6 be set to 0, in order to express the RFC 4122

View File

@ -40,12 +40,14 @@ isoburn_igopt_get_gpt_guid;
isoburn_igopt_get_hfsp_block_size; isoburn_igopt_get_hfsp_block_size;
isoburn_igopt_get_hfsp_serial_number; isoburn_igopt_get_hfsp_serial_number;
isoburn_igopt_get_iso_mbr_part_type; isoburn_igopt_get_iso_mbr_part_type;
isoburn_igopt_get_iso_type_guid;
isoburn_igopt_get_level; isoburn_igopt_get_level;
isoburn_igopt_get_out_charset; isoburn_igopt_get_out_charset;
isoburn_igopt_get_over_mode; isoburn_igopt_get_over_mode;
isoburn_igopt_get_over_ugid; isoburn_igopt_get_over_ugid;
isoburn_igopt_get_part_flags; isoburn_igopt_get_part_flags;
isoburn_igopt_get_part_like_isohybrid; isoburn_igopt_get_part_like_isohybrid;
isoburn_igopt_get_part_type_guid;
isoburn_igopt_get_partition_img; isoburn_igopt_get_partition_img;
isoburn_igopt_get_prep_partition; isoburn_igopt_get_prep_partition;
isoburn_igopt_get_pvd_times; isoburn_igopt_get_pvd_times;
@ -69,12 +71,14 @@ isoburn_igopt_set_gpt_guid;
isoburn_igopt_set_hfsp_block_size; isoburn_igopt_set_hfsp_block_size;
isoburn_igopt_set_hfsp_serial_number; isoburn_igopt_set_hfsp_serial_number;
isoburn_igopt_set_iso_mbr_part_type; isoburn_igopt_set_iso_mbr_part_type;
isoburn_igopt_set_iso_type_guid;
isoburn_igopt_set_level; isoburn_igopt_set_level;
isoburn_igopt_set_out_charset; isoburn_igopt_set_out_charset;
isoburn_igopt_set_over_mode; isoburn_igopt_set_over_mode;
isoburn_igopt_set_over_ugid; isoburn_igopt_set_over_ugid;
isoburn_igopt_set_part_flag; isoburn_igopt_set_part_flag;
isoburn_igopt_set_part_like_isohybrid; isoburn_igopt_set_part_like_isohybrid;
isoburn_igopt_set_part_type_guid;
isoburn_igopt_set_partition_img; isoburn_igopt_set_partition_img;
isoburn_igopt_set_prep_partition; isoburn_igopt_set_prep_partition;
isoburn_igopt_set_pvd_times; isoburn_igopt_set_pvd_times;