From adcd2386eb4f9a08f60b251ec0e5af3ac14c4708 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 15 Aug 2016 17:48:42 +0000 Subject: [PATCH] New -report_system_area mode "gpt_disk_guid" --- xorriso/iso_img.c | 25 ++++++++++++++++++++++++- xorriso/lib_mgt.c | 23 ++++++++++++++++------- xorriso/xorriso_timestamp.h | 2 +- xorriso/xorrisoburn.h | 3 +++ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/xorriso/iso_img.c b/xorriso/iso_img.c index 4a4a6dba..f0d9f0bd 100644 --- a/xorriso/iso_img.c +++ b/xorriso/iso_img.c @@ -2702,8 +2702,9 @@ static void Xorriso_report_lines(struct XorrisO *xorriso, int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag) { int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0; - int do_cmd= 0, as_mkisofs= 0, i; + int do_cmd= 0, as_mkisofs= 0, i, bin_count; char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL; + uint8_t guid[16]; IsoImage *image; if(strcmp(form, "cmd") == 0 || strcmp(form, "as_mkisofs") == 0 || (flag & 2)) @@ -2763,6 +2764,28 @@ int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag) Xorriso_result(xorriso,0); goto ex; + } else if(strcmp(form, "gpt_disk_guid") == 0 && !(flag & 1)) { + ret= Xorriso_get_volume(xorriso, &image, 0); + if(ret <= 0) + goto ex; + ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0); + if(ret <= 0) + goto ex; + for(i= 0; i < sa_line_count; i++) { + if(strncmp(sa_lines[i], "GPT disk GUID : ", 26) == 0) { + ret= Hex_to_bin(sa_lines[i] + 26, 16, &bin_count, guid, 0); + if(ret < 0 || bin_count != 16) + break; + Xorriso_format_guid(xorriso, guid, xorriso->result_line, 0); + strcat(xorriso->result_line, "\n"); + Xorriso_result(xorriso,0); + ret= 1; + goto ex; + } + } + ret= 1; + goto ex; + } else { sprintf(xorriso->info_text, "%s form parameter not recognized: ", diff --git a/xorriso/lib_mgt.c b/xorriso/lib_mgt.c index 83636366..fa7e339a 100644 --- a/xorriso/lib_mgt.c +++ b/xorriso/lib_mgt.c @@ -979,21 +979,19 @@ int Xorriso_set_data_cache(struct XorrisO *xorriso, void *o, return(ret); } - -int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag) +int Xorriso_format_guid(struct XorrisO *xorriso, uint8_t guid[16], char *line, + int flag) { - uint8_t guid[16]; int i; line[0]= 0; - iso_generate_gpt_guid(guid); - for(i= 0; i < 4; i++) + for(i= 3; i >= 0; i--) sprintf(line + strlen(line), "%-2.2x", guid[i]); sprintf(line + strlen(line), "-"); - for(i= 4; i < 6; i++) + for(i= 5; i >= 4; i--) sprintf(line + strlen(line), "%-2.2x", guid[i]); sprintf(line + strlen(line), "-"); - for(i= 6; i < 8; i++) + for(i= 7; i >= 6; i--) sprintf(line + strlen(line), "%-2.2x", guid[i]); sprintf(line + strlen(line), "-"); for(i= 8; i < 10; i++) @@ -1004,3 +1002,14 @@ int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag) return(1); } + +int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag) +{ + uint8_t guid[16]; + int ret; + + iso_generate_gpt_guid(guid); + ret= Xorriso_format_guid(xorriso, guid, line, 0); + return(ret); +} + diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index c79a3bb9..4c34044b 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2016.08.15.102443" +#define Xorriso_timestamP "2016.08.15.175002" diff --git a/xorriso/xorrisoburn.h b/xorriso/xorrisoburn.h index b519eb48..8819f69f 100644 --- a/xorriso/xorrisoburn.h +++ b/xorriso/xorrisoburn.h @@ -644,6 +644,9 @@ int Xorriso_graftable_pathspec(struct XorrisO *xorriso, char *in_pathspec, int Xorriso_parse_gpt_guid(struct XorrisO *xorriso, char *text, int flag); +int Xorriso_format_guid(struct XorrisO *xorriso, uint8_t guid[16], char *line, + int flag); + int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag); #endif /* Xorrisoburn_includeD */