summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorbenno <benno@FreeBSD.org>2018-04-25 01:59:15 +0000
committerbenno <benno@FreeBSD.org>2018-04-25 01:59:15 +0000
commit265e7a4f240fa5c7afeb652bf59b924acd56533f (patch)
treea337c852fc709fb7a2c8a1172008dd0aa994f3f5 /usr.sbin
parent2864c5e88c7c66d3479482080efc5834ce68232b (diff)
downloadFreeBSD-src-265e7a4f240fa5c7afeb652bf59b924acd56533f.zip
FreeBSD-src-265e7a4f240fa5c7afeb652bf59b924acd56533f.tar.gz
MFC r331463 (partial), r331467, r331468, r331843
r331463, r331467, and r331468 are all replaced by r331843 but are included for completeness' sake. r331463 also contained a change to release/amd64/mkisoimages.sh which I've left out since those changes were also obsoleted by a later commit which will be merged later. r331843: Synchronise with NetBSD's version of EFI handling for El Torito images. Sponsored by: iXsystems, Inc.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/makefs/cd9660.c4
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.c83
-rw-r--r--usr.sbin/makefs/cd9660/cd9660_eltorito.h4
-rw-r--r--usr.sbin/makefs/makefs.84
4 files changed, 75 insertions, 20 deletions
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 4683b0f..680df73 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -312,6 +312,7 @@ cd9660_prep_opts(fsinfo_t *fsopts)
OPT_STR('\0', "no-boot", "No boot support"),
OPT_STR('\0', "hard-disk-boot", "Boot from hard disk"),
OPT_STR('\0', "boot-load-segment", "Boot load segment"),
+ OPT_STR('\0', "platformid", "Section Header Platform ID"),
{ .name = NULL }
};
@@ -447,7 +448,8 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
/* RRIP */
cd9660_eltorito_add_boot_option(diskStructure, name, 0);
rv = 1;
- } else if (strcmp(name, "boot-load-segment") == 0) {
+ } else if (strcmp(name, "boot-load-segment") == 0 ||
+ strcmp(name, "platformid") == 0) {
if (buf[0] == '\0') {
warnx("Option `%s' doesn't contain a value",
name);
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.c b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
index 14a3b68..b1b162f 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_eltorito.c,v 1.17 2011/06/23 02:35:56 enami Exp $ */
+/* $NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -47,16 +47,19 @@ __FBSDID("$FreeBSD$");
#define ELTORITO_DPRINTF(__x)
#endif
+#include <util.h>
+
static struct boot_catalog_entry *cd9660_init_boot_catalog_entry(void);
static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char);
static struct boot_catalog_entry *cd9660_boot_setup_default_entry(
struct cd9660_boot_image *);
static struct boot_catalog_entry *cd9660_boot_setup_section_head(char);
-static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char);
#if 0
static u_char cd9660_boot_get_system_type(struct cd9660_boot_image *);
#endif
+static struct cd9660_boot_image *default_boot_image;
+
int
cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info)
{
@@ -171,9 +174,15 @@ cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info)
new_image->serialno = diskStructure->image_serialno++;
+ new_image->platform_id = new_image->system;
+
/* TODO : Need to do anything about the boot image in the tree? */
diskStructure->is_bootable = 1;
+ /* First boot image is initial/default entry. */
+ if (default_boot_image == NULL)
+ default_boot_image = new_image;
+
return 1;
}
@@ -207,6 +216,13 @@ cd9660_eltorito_add_boot_option(iso9660_disk *diskStructure,
warn("%s: strtoul", __func__);
return 0;
}
+ } else if (strcmp(option_string, "platformid") == 0) {
+ if (strcmp(value, "efi") == 0)
+ image->platform_id = ET_SYS_EFI;
+ else {
+ warn("%s: unknown platform: %s", __func__, value);
+ return 0;
+ }
} else {
return 0;
}
@@ -229,6 +245,7 @@ cd9660_boot_setup_validation_entry(char sys)
int i;
entry = cd9660_init_boot_catalog_entry();
+ entry->entry_type = ET_ENTRY_VE;
ve = &entry->entry_data.VE;
ve->header_id[0] = 1;
@@ -263,6 +280,7 @@ cd9660_boot_setup_default_entry(struct cd9660_boot_image *disk)
if (default_entry == NULL)
return NULL;
+ default_entry->entry_type = ET_ENTRY_IE;
ie = &default_entry->entry_data.IE;
ie->boot_indicator[0] = disk->bootable;
@@ -290,8 +308,12 @@ cd9660_boot_setup_section_head(char platform)
if (entry == NULL)
return NULL;
+ entry->entry_type = ET_ENTRY_SH;
sh = &entry->entry_data.SH;
- /* More by default. The last one will manually be set to 0x91 */
+ /*
+ * More by default.
+ * The last one will manually be set to ET_SECTION_HEADER_LAST
+ */
sh->header_indicator[0] = ET_SECTION_HEADER_MORE;
sh->platform_id[0] = platform;
sh->num_section_entries[0] = 0;
@@ -306,6 +328,7 @@ cd9660_boot_setup_section_entry(struct cd9660_boot_image *disk)
if ((entry = cd9660_init_boot_catalog_entry()) == NULL)
return NULL;
+ entry->entry_type = ET_ENTRY_SE;
se = &entry->entry_data.SE;
se->boot_indicator[0] = ET_BOOTABLE;
@@ -338,12 +361,12 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
int used_sectors;
int num_entries = 0;
int catalog_sectors;
- struct boot_catalog_entry *x86_head, *mac_head, *ppc_head,
+ struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, *efi_head,
*valid_entry, *default_entry, *temp, *head, **headp, *next;
struct cd9660_boot_image *tmp_disk;
headp = NULL;
- x86_head = mac_head = ppc_head = NULL;
+ x86_head = mac_head = ppc_head = efi_head = NULL;
/* If there are no boot disks, don't bother building boot information */
if (TAILQ_EMPTY(&diskStructure->boot_images))
@@ -387,14 +410,25 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
sector = first_sector + catalog_sectors;
TAILQ_FOREACH(tmp_disk, &diskStructure->boot_images, image_list) {
tmp_disk->sector = sector;
- sector += tmp_disk->num_sectors;
+ sector += tmp_disk->num_sectors /
+ (diskStructure->sectorSize / 512);
}
LIST_INSERT_HEAD(&diskStructure->boot_entries, valid_entry, ll_struct);
/* Step 1b: Initial/default entry */
/* TODO : PARAM */
- tmp_disk = TAILQ_FIRST(&diskStructure->boot_images);
+ if (default_boot_image != NULL) {
+ struct cd9660_boot_image *tcbi;
+ TAILQ_FOREACH(tcbi, &diskStructure->boot_images, image_list) {
+ if (tcbi == default_boot_image) {
+ tmp_disk = tcbi;
+ break;
+ }
+ }
+ }
+ if (tmp_disk == NULL)
+ tmp_disk = TAILQ_FIRST(&diskStructure->boot_images);
default_entry = cd9660_boot_setup_default_entry(tmp_disk);
if (default_entry == NULL) {
warnx("Error: memory allocation failed in cd9660_setup_boot");
@@ -405,14 +439,18 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
/* Todo: multiple default entries? */
- tmp_disk = TAILQ_NEXT(tmp_disk, image_list);
+ tmp_disk = TAILQ_FIRST(&diskStructure->boot_images);
+ head = NULL;
temp = default_entry;
/* If multiple boot images are given : */
- while (tmp_disk != NULL) {
+ for (; tmp_disk != NULL; tmp_disk = TAILQ_NEXT(tmp_disk, image_list)) {
+ if (tmp_disk == default_boot_image)
+ continue;
+
/* Step 2: Section header */
- switch (tmp_disk->system) {
+ switch (tmp_disk->platform_id) {
case ET_SYS_X86:
headp = &x86_head;
break;
@@ -422,6 +460,9 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
case ET_SYS_MAC:
headp = &mac_head;
break;
+ case ET_SYS_EFI:
+ headp = &efi_head;
+ break;
default:
warnx("%s: internal error: unknown system type",
__func__);
@@ -430,7 +471,7 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
if (*headp == NULL) {
head =
- cd9660_boot_setup_section_head(tmp_disk->system);
+ cd9660_boot_setup_section_head(tmp_disk->platform_id);
if (head == NULL) {
warnx("Error: memory allocation failed in "
"cd9660_setup_boot");
@@ -455,9 +496,17 @@ cd9660_setup_boot(iso9660_disk *diskStructure, int first_sector)
head = next;
LIST_INSERT_AFTER(head, temp, ll_struct);
- tmp_disk = TAILQ_NEXT(tmp_disk, image_list);
}
+ /* Find the last Section Header entry and mark it as the last. */
+ head = NULL;
+ LIST_FOREACH(next, &diskStructure->boot_entries, ll_struct) {
+ if (next->entry_type == ET_ENTRY_SH)
+ head = next;
+ }
+ if (head != NULL)
+ head->entry_data.SH.header_indicator[0] = ET_SECTION_HEADER_LAST;
+
/* TODO: Remaining boot disks when implemented */
return first_sector + used_sectors;
@@ -558,13 +607,13 @@ cd9660_write_apm_partition_entry(FILE *fd, int idx, int total_partitions,
apm32 = 0;
/* pmLgDataStart */
- fwrite(&apm32, sizeof(apm32), 1, fd);
+ fwrite(&apm32, sizeof(apm32), 1, fd);
/* pmDataCnt */
apm32 = htobe32(nsectors);
- fwrite(&apm32, sizeof(apm32), 1, fd);
+ fwrite(&apm32, sizeof(apm32), 1, fd);
/* pmPartStatus */
apm32 = htobe32(part_status);
- fwrite(&apm32, sizeof(apm32), 1, fd);
+ fwrite(&apm32, sizeof(apm32), 1, fd);
return 0;
}
@@ -681,8 +730,9 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
t->num_sectors * (diskStructure->sectorSize / 512),
512, "CD Boot", "Apple_Bootstrap");
}
+
/* Write ISO9660 descriptor, enclosing the whole disk */
- cd9660_write_apm_partition_entry(fd, 2 + apm_partitions,
+ cd9660_write_apm_partition_entry(fd, 2 + apm_partitions,
total_parts, 0, diskStructure->totalSectors *
(diskStructure->sectorSize / 512), 512, "ISO9660",
"CD_ROM_Mode_1");
@@ -690,4 +740,3 @@ cd9660_write_boot(iso9660_disk *diskStructure, FILE *fd)
return 0;
}
-
diff --git a/usr.sbin/makefs/cd9660/cd9660_eltorito.h b/usr.sbin/makefs/cd9660/cd9660_eltorito.h
index 976dd98..cbc3f84 100644
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.h
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.h
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_eltorito.h,v 1.5 2009/07/04 14:31:38 ahoka Exp $ */
+/* $NetBSD: cd9660_eltorito.h,v 1.6 2017/01/24 11:22:43 nonaka Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-NetBSD
@@ -44,6 +44,7 @@
#define ET_SYS_X86 0
#define ET_SYS_PPC 1
#define ET_SYS_MAC 2
+#define ET_SYS_EFI 0xef /* Platform ID at section header entry */
#define ET_BOOT_ENTRY_SIZE 0x20
@@ -149,6 +150,7 @@ struct cd9660_boot_image {
u_char targetMode;
u_char system;
u_char bootable;
+ u_char platform_id; /* for section header entry */
/*
* If the boot image exists in the filesystem
* already, this is a pointer to that node. For the sake
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index 7a8e67e..c4672d0 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 6, 2017
+.Dd March 30, 2018
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -386,6 +386,8 @@ ElTorito image.
Do not pad the image (apparently Linux needs the padding).
.It Sy omit-trailing-period
Omit trailing periods in filenames.
+.It Sy platformid
+Set platform ID of section header entry of the boot image.
.It Sy preparer
Preparer ID of the image.
.It Sy publisher
OpenPOWER on IntegriCloud