Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs makefs(8): add cd9660 eltorito-alt-boot opti...



details:   https://anonhg.NetBSD.org/src/rev/ed803d755b59
branches:  trunk
changeset: 821091:ed803d755b59
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Tue Jan 24 11:22:43 2017 +0000

description:
makefs(8): add cd9660 eltorito-alt-boot option for EFI boot.

diffstat:

 usr.sbin/makefs/cd9660.c                 |   8 ++-
 usr.sbin/makefs/cd9660/cd9660_eltorito.c |  58 +++++++++++++++++++++++++------
 usr.sbin/makefs/cd9660/cd9660_eltorito.h |   4 +-
 usr.sbin/makefs/makefs.8                 |   4 +-
 4 files changed, 57 insertions(+), 17 deletions(-)

diffs (238 lines):

diff -r 2a3430c78cf2 -r ed803d755b59 usr.sbin/makefs/cd9660.c
--- a/usr.sbin/makefs/cd9660.c  Tue Jan 24 11:16:50 2017 +0000
+++ b/usr.sbin/makefs/cd9660.c  Tue Jan 24 11:22:43 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $     */
+/*     $NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $       */
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $");
 #endif  /* !__lint */
 
 #include <string.h>
@@ -321,6 +321,7 @@
                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 }
        };
@@ -458,7 +459,8 @@
                        /* 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 -r 2a3430c78cf2 -r ed803d755b59 usr.sbin/makefs/cd9660/cd9660_eltorito.c
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.c  Tue Jan 24 11:16:50 2017 +0000
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.c  Tue Jan 24 11:22:43 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_eltorito.c,v 1.20 2013/01/28 21:03:28 christos Exp $    */
+/*     $NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $      */
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.20 2013/01/28 21:03:28 christos Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -56,11 +56,12 @@
 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)
 {
@@ -175,9 +176,15 @@
 
        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;
 }
 
@@ -211,6 +218,13 @@
                        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;
        }
@@ -342,12 +356,12 @@
        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))
@@ -391,14 +405,25 @@
        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");
@@ -409,14 +434,18 @@
 
        /* 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;
@@ -426,6 +455,9 @@
                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__);
@@ -434,7 +466,7 @@
 
                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");
@@ -459,9 +491,11 @@
                        head = next;
 
                LIST_INSERT_AFTER(head, temp, ll_struct);
-               tmp_disk = TAILQ_NEXT(tmp_disk, image_list);
        }
 
+       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;
diff -r 2a3430c78cf2 -r ed803d755b59 usr.sbin/makefs/cd9660/cd9660_eltorito.h
--- a/usr.sbin/makefs/cd9660/cd9660_eltorito.h  Tue Jan 24 11:16:50 2017 +0000
+++ b/usr.sbin/makefs/cd9660/cd9660_eltorito.h  Tue Jan 24 11:22:43 2017 +0000
@@ -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 $       */
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,6 +40,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
 
@@ -145,6 +146,7 @@
        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 -r 2a3430c78cf2 -r ed803d755b59 usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8  Tue Jan 24 11:16:50 2017 +0000
+++ b/usr.sbin/makefs/makefs.8  Tue Jan 24 11:22:43 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: makefs.8,v 1.57 2017/01/11 13:47:27 wiz Exp $
+.\"    $NetBSD: makefs.8,v 1.58 2017/01/24 11:22:43 nonaka Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -366,6 +366,8 @@
 Do not pad the image (apparently Linux needs the padding).
 .\" .It Sy omit-trailing-period
 .\" Unknown
+.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



Home | Main Index | Thread Index | Old Index