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

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