From 3eef0411d57f304f7cca6fff21e4927f699dbf56 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 13 Jun 2022 22:56:17 +0200 Subject: [PATCH] Warning if EFI boot equipment is present but no /EFI/BOOT directory is in ISO --- xorriso/write_run.c | 74 +++++++++++++++++++++++++++++++++++++ xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/xorriso/write_run.c b/xorriso/write_run.c index 1ddbcf1f..fa3c8bf2 100644 --- a/xorriso/write_run.c +++ b/xorriso/write_run.c @@ -1084,6 +1084,78 @@ int Xorriso_set_all_file_dates(struct XorrisO *xorriso, int flag) } +/* @return 0= no EFI , 1= EFI but no warning needed , 2= warning was issued +*/ +int Xorriso_warn_efi_boot_dir(struct XorrisO *xorriso, IsoImage *image, + int flag) +{ + int ret, num_boots, i, filec; + off_t mem= 0; + char *patterns[1], **filev= NULL; + ElToritoBootImage **boots = NULL; + IsoFile **bootnodes = NULL; + IsoNode *node; + + /* Check El Torito images for EFI */ + ret= iso_image_get_all_boot_imgs(image, &num_boots, &boots, &bootnodes, 0); + Xorriso_process_msg_queues(xorriso,0); + if(ret == 1) { + for(i= 0; i appended_partitions[i] == NULL) + continue; + if(xorriso->appended_partitions[i][0] == 0) + continue; + if(xorriso->appended_part_types[i] == 0xef) + goto has_efi; + } + + /* No EFI found */ + ret= 0; goto ex; + +has_efi:; + + /* Check for /[Ee][Ff][Ii]/[Bb][Oo][Oo][Tt]/ in ISO tree */ + patterns[0]= "/[Ee][Ff][Ii]/[Bb][Oo][Oo][Tt]"; + ret= Xorriso_expand_pattern(xorriso, 1, patterns, 0, &filec, &filev, &mem, 0); + if(ret > 0 && filec > 0) { + ret= Xorriso_node_from_path(xorriso, image, filev[0], &node, 1); + if(ret > 0) { + if(LIBISO_ISDIR(node)) { + ret= 1; goto ex; + } + } + } + + Xorriso_msgs_submit(xorriso, 0, + "EFI boot equipment is provided but no directory /EFI/BOOT", + 0, "WARNING", 0); + Xorriso_msgs_submit(xorriso, 0, + "will emerge in the ISO filesystem. A popular method to", + 0, "WARNING", 0); + Xorriso_msgs_submit(xorriso, 0, + "prepare a USB stick on MS-Windows relies on having in the", + 0, "WARNING", 0); + Xorriso_msgs_submit(xorriso, 0, + "ISO filesystem a copy of the EFI System Partition tree.", + 0, "WARNING", 0); + ret= 2; +ex:; + Sfile_destroy_argv(&filec, &filev, 0); + if(boots != NULL) + free(boots); + if(bootnodes != NULL) + free(bootnodes); + return(ret); +} + + /* @param flag bit0= do not write but only prepare and return size in sectors @return <=0 error , 1= success 2= failure with DVD-RW, please call Xorriso_retry_write_session() @@ -1335,6 +1407,8 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) &value_length, &value, 2 | 8); } + Xorriso_warn_efi_boot_dir(xorriso, image, 0); + ret= Xorriso_make_iso_write_opts(xorriso, image, sopts, flag & 1); if(ret <= 0) goto ex; diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 3d500c37..084351d6 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2022.06.02.140943" +#define Xorriso_timestamP "2022.06.13.205546"