Blame SOURCES/cdrkit-1.1.9-efi-boot.patch

702422
diff --git a/doc/icedax/tracknames.pl b/doc/icedax/tracknames.pl
702422
old mode 100755
702422
new mode 100644
702422
index 09f0fcf..801b89e
702422
--- a/doc/icedax/tracknames.pl
702422
+++ b/doc/icedax/tracknames.pl
702422
@@ -1,4 +1,4 @@
702422
-#!/usr/local/bin/perl 
702422
+#!/usr/bin/perl 
702422
 # A quick perl hack to get rename files pulled in with icedax.
702422
 # by billo@billo.com
702422
 #
702422
diff --git a/genisoimage/eltorito.c b/genisoimage/eltorito.c
702422
index b97bdf1..5d7c2d1 100644
702422
--- a/genisoimage/eltorito.c
702422
+++ b/genisoimage/eltorito.c
702422
@@ -59,7 +59,7 @@ static	void	get_torito_desc(struct eltorito_boot_descriptor *boot_desc);
702422
 static	void	fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry,
702422
 										struct eltorito_boot_entry_info *boot_entry);
702422
 void	get_boot_entry(void);
702422
-void	new_boot_entry(void);
702422
+void	new_boot_entry();
702422
 static	int	tvd_write(FILE *outfile);
702422
 
702422
 
702422
@@ -283,6 +283,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
702422
 	int			i;
702422
 	int			offset;
702422
 	struct eltorito_defaultboot_entry boot_desc_record;
702422
+	struct eltorito_sectionheader_entry section_header;
702422
 
702422
 	memset(boot_desc, 0, sizeof (*boot_desc));
702422
 	boot_desc->type[0] = 0;
702422
@@ -317,7 +318,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
702422
 	 */
702422
 	memset(&valid_desc, 0, sizeof (valid_desc));
702422
 	valid_desc.headerid[0] = 1;
702422
-	valid_desc.arch[0] = EL_TORITO_ARCH_x86;
702422
+	valid_desc.arch[0] = first_boot_entry->arch;
702422
 
702422
 	/*
702422
 	 * we'll shove start of publisher id into id field,
702422
@@ -347,10 +348,53 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
702422
 	/* now write it to the virtual boot catalog */
702422
 	memcpy(de2->table, &valid_desc, 32);
702422
 
702422
-	for (current_boot_entry = first_boot_entry, offset = sizeof (valid_desc);
702422
-		current_boot_entry != NULL;
702422
-		current_boot_entry = current_boot_entry->next,
702422
-		offset += sizeof (boot_desc_record)) {
702422
+	/* Fill the first entry, since it's special and already has the
702422
+	 * matching header via the validation header... */
702422
+	offset = sizeof (valid_desc);
702422
+	current_boot_entry = first_boot_entry;
702422
+
702422
+	if (offset >= SECTOR_SIZE) {
702422
+#ifdef	USE_LIBSCHILY
702422
+		comerrno(EX_BAD, "Too many El Torito boot entries\n");
702422
+#else
702422
+		fprintf(stderr,	"Too many El Torito boot entries\n");
702422
+		exit(1);
702422
+#endif
702422
+	}
702422
+	fill_boot_desc(&boot_desc_record, current_boot_entry);
702422
+	memcpy(de2->table + offset, &boot_desc_record,
702422
+				sizeof (boot_desc_record));
702422
+
702422
+	offset += sizeof(boot_desc_record);
702422
+
702422
+	for (current_boot_entry = current_boot_entry->next;
702422
+			current_boot_entry != NULL;
702422
+			current_boot_entry = current_boot_entry->next) {
702422
+		struct eltorito_sectionheader_entry section_header;
702422
+
702422
+		if (offset >= SECTOR_SIZE) {
702422
+#ifdef	USE_LIBSCHILY
702422
+			comerrno(EX_BAD,
702422
+			"Too many El Torito boot entries\n");
702422
+#else
702422
+			fprintf(stderr,
702422
+			"Too many El Torito boot entries\n");
702422
+			exit(1);
702422
+#endif
702422
+		}
702422
+
702422
+		memset(&section_header, '\0', sizeof(section_header));
702422
+		if (current_boot_entry->next)
702422
+			section_header.headerid[0] = EL_TORITO_SECTION_HEADER;
702422
+		else
702422
+			section_header.headerid[0] = EL_TORITO_LAST_SECTION_HEADER;
702422
+
702422
+		section_header.arch[0] = current_boot_entry->arch;
702422
+		set_721(section_header.num_entries, 1);
702422
+
702422
+		memcpy(de2->table + offset, &section_header,
702422
+					sizeof(section_header));
702422
+		offset += sizeof(section_header);
702422
 
702422
 		if (offset >= SECTOR_SIZE) {
702422
 #ifdef	USE_LIBSCHILY
702422
@@ -365,6 +409,8 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
702422
 		fill_boot_desc(&boot_desc_record, current_boot_entry);
702422
 		memcpy(de2->table + offset, &boot_desc_record,
702422
 					sizeof (boot_desc_record));
702422
+		offset += sizeof (boot_desc_record);
702422
+
702422
 	}
702422
 }/* get_torito_desc(... */
702422
 
702422
diff --git a/genisoimage/genisoimage.c b/genisoimage/genisoimage.c
702422
index a5b0b46..8add1ac 100644
702422
--- a/genisoimage/genisoimage.c
702422
+++ b/genisoimage/genisoimage.c
702422
@@ -47,6 +47,7 @@
702422
 
702422
 #include <mconfig.h>
702422
 #include "genisoimage.h"
702422
+#include "iso9660.h"
702422
 #include <errno.h>
702422
 #include <timedefs.h>
702422
 #include <fctldefs.h>
702422
@@ -523,6 +524,8 @@ static const struct ld_option ld_options[] =
702422
 	'\0', NULL, "Set debug flag", ONE_DASH},
702422
 	{{"eltorito-boot", required_argument, NULL, 'b'},
702422
 	'b', "FILE", "Set El Torito boot image name", ONE_DASH},
702422
+	{{"efi-boot", required_argument, NULL, 'e'},
702422
+	'e', "FILE", "Set EFI boot image name", ONE_DASH},
702422
 	{{"eltorito-alt-boot", no_argument, NULL, OPTION_ALT_BOOT},
702422
 	'\0', NULL, "Start specifying alternative El Torito boot parameters", ONE_DASH},
702422
 	{{"sparc-boot", required_argument, NULL, 'B'},
702422
@@ -1502,6 +1505,7 @@ int main(int argc, char *argv[])
702422
 			all_files = 0;
702422
 			break;
702422
 		case 'b':
702422
+		case 'e':
702422
 			do_sort++;		/* We sort bootcat/botimage */
702422
 			use_eltorito++;
702422
 			boot_image = optarg;	/* pathname of the boot image */
702422
@@ -1517,6 +1521,10 @@ int main(int argc, char *argv[])
702422
 #endif
702422
 			}
702422
 			get_boot_entry();
702422
+			if (c == 'e')
702422
+				current_boot_entry->arch = EL_TORITO_ARCH_EFI;
702422
+			else
702422
+				current_boot_entry->arch = EL_TORITO_ARCH_x86;
702422
 			current_boot_entry->boot_image = boot_image;
702422
 			break;
702422
 		case OPTION_ALT_BOOT:
702422
diff --git a/genisoimage/genisoimage.h b/genisoimage/genisoimage.h
702422
index bbedfb0..76e5e21 100644
702422
--- a/genisoimage/genisoimage.h
702422
+++ b/genisoimage/genisoimage.h
702422
@@ -293,6 +293,7 @@ struct deferred_write {
702422
 struct eltorito_boot_entry_info {
702422
 	struct eltorito_boot_entry_info *next;
702422
 	char		*boot_image;
702422
+	char		arch;
702422
 	int		not_bootable;
702422
 	int		no_emul_boot;
702422
 	int		hard_disk_boot;
702422
diff --git a/genisoimage/iso9660.h b/genisoimage/iso9660.h
702422
index c74c2a9..c8b7a05 100644
702422
--- a/genisoimage/iso9660.h
702422
+++ b/genisoimage/iso9660.h
702422
@@ -62,10 +62,14 @@ struct iso_volume_descriptor {
702422
 #define	EL_TORITO_ARCH_x86	0
702422
 #define	EL_TORITO_ARCH_PPC	1
702422
 #define	EL_TORITO_ARCH_MAC	2
702422
+#define	EL_TORITO_ARCH_EFI	0xef
702422
 
702422
 #define	EL_TORITO_BOOTABLE	0x88
702422
 #define	EL_TORITO_NOT_BOOTABLE	0
702422
 
702422
+#define	EL_TORITO_SECTION_HEADER	0x90
702422
+#define	EL_TORITO_LAST_SECTION_HEADER	0x91
702422
+
702422
 #define	EL_TORITO_MEDIA_NOEMUL	0
702422
 #define	EL_TORITO_MEDIA_12FLOP	1
702422
 #define	EL_TORITO_MEDIA_144FLOP	2
702422
@@ -173,7 +177,7 @@ struct eltorito_validation_entry {
702422
 struct eltorito_defaultboot_entry {
702422
 	char boot_id			[ISODCL(1,    1)]; /* 711 */
702422
 	char boot_media			[ISODCL(2,    2)];
702422
-	char loadseg			[ISODCL(3,    4)]; /* 711 */
702422
+	char loadseg			[ISODCL(3,    4)]; /* 712 */
702422
 	char sys_type			[ISODCL(5,    5)];
702422
 	char pad1			[ISODCL(6,    6)];
702422
 	char nsect			[ISODCL(7,    8)];
702422
@@ -181,6 +185,14 @@ struct eltorito_defaultboot_entry {
702422
 	char pad2			[ISODCL(13,  32)];
702422
 };
702422
 
702422
+/* El Torito Section Header Entry in boot catalog */
702422
+struct eltorito_sectionheader_entry {
702422
+	char headerid			[ISODCL(1,    1)]; /* 711 */
702422
+	char arch			[ISODCL(2,    2)];
702422
+	char num_entries		[ISODCL(3,    4)]; /* 711 */
702422
+	char id				[ISODCL(5,   32)];
702422
+};
702422
+
702422
 /*
702422
  * XXX JS: The next two structures have odd lengths!
702422
  * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.