ae115bc77f6fcde83175c75b4206dc2e50747966mrj * CDDL HEADER START
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The contents of this file are subject to the terms of the
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Common Development and Distribution License (the "License").
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * You may not use this file except in compliance with the License.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * See the License for the specific language governing permissions
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * and limitations under the License.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * When distributing Covered Code, include this CDDL HEADER in each
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * If applicable, add the following below this CDDL HEADER, with the
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * fields enclosed by brackets "[]" replaced with your own identifying
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * information: Portions Copyright [yyyy] [name of copyright owner]
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * CDDL HEADER END
3028dfd677c76945aa0d0f6682daafb71a0abad9Frank Van Der Linden * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Use is subject to license terms.
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome * Copyright 2016 Toomas Soome <tsoome@me.com>
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: findroot capability absent\n", fcn));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("failed to open file: %s: %s\n"), path,
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: findroot capability present\n", fcn));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: dboot capability present\n", fcn));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: findroot capability absent\n", fcn));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram if (ret != 0) {
986fd29a0dc13f7608ef7f508f6e700bd7bc2720setje /* there is no non dboot sparc new-boot */
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: is sparc - always DBOOT\n", fcn));
ae115bc77f6fcde83175c75b4206dc2e50747966mrj if (fd < 0) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("failed to open file: %s: %s\n"), fname,
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * Verify that this is a sane unix at least 8192 bytes in length
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("invalid or corrupted binary: %s\n"), fname);
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * mmap the first 8K
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("failed to mmap file: %s: %s\n"), fname,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj if (ident[EI_MAG0] != ELFMAG0 || ident[EI_MAG1] != ELFMAG1 ||
ae115bc77f6fcde83175c75b4206dc2e50747966mrj ident[EI_MAG2] != ELFMAG2 || ident[EI_MAG3] != ELFMAG3) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("%s is not an ELF file.\n"), fname);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("%s is wrong ELF class 0x%x\n"), fname,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The GRUB multiboot header must be 32-bit aligned and completely
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * contained in the 1st 8K of the file. If the unix binary has
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * a multiboot header, then it is a 'dboot' kernel. Otherwise,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * this kernel must be booted via multiboot -- we call this a
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * 'multiboot' kernel.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj for (m = 0; m < 8192 - sizeof (multiboot_header_t); m += 4) {
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram INJECT_ERROR1("GET_CAP_MULTIBOOT", bam_direct = BAM_DIRECT_MULTIBOOT);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: is *NOT* xVM system\n", fcn));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* Not a fatal error if this fails */
ae115bc77f6fcde83175c75b4206dc2e50747966mrj#define INST_RELEASE "var/sadm/system/admin/INST_RELEASE"
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Return true if root has been bfu'ed. bfu will blow away
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * var/sadm/system/admin/INST_RELEASE, so if it's still there, we can
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * assume the system has not been bfu'ed.
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: already done bfu test. bfu is %s present\n",
ae115bc77f6fcde83175c75b4206dc2e50747966mrj (void) snprintf(path, sizeof (path), "%s/%s", root, INST_RELEASE);
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Simply allocate a new line and copy in cmd + sep + arg
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: line before update: %s\n", fcn, linep->line));
ae115bc77f6fcde83175c75b4206dc2e50747966mrj size = strlen(linep->cmd) + strlen(linep->sep) + strlen(linep->arg) + 1;
ae115bc77f6fcde83175c75b4206dc2e50747966mrj (void) snprintf(linep->line, size, "%s%s%s", linep->cmd, linep->sep,
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: line after update: %s\n", fcn, linep->line));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikramstatic char *
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: ptr on entry: %s\n", fcn, ptr));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: ptr on exit: %s\n", fcn, ptr ? ptr : "NULL"));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikramstatic char *
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram assert(*bound != ' ' && *bound != '\t' && *bound != '\n');
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: ptr on entry: %s\n", fcn, ptr));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: ptr on exit: %s\n", fcn, ptr));
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * The parse_kernel_line function examines a menu.lst kernel line. For
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * multiboot, this is:
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * kernel <multiboot path> <flags1> <kernel path> <flags2>
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * <multiboot path> is either /platform/i86pc/multiboot or /boot/multiboot
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * <kernel path> may be missing, or may be any full or relative path to unix.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * We check for it by looking for a word ending in "/unix". If it ends
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * in "kernel/unix", we upgrade it to a 32-bit entry. If it ends in
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * "kernel/amd64/unix", we upgrade it to the default entry. Otherwise,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * it's a custom kernel, and we skip it.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * <flags*> are anything that doesn't fit either of the above - these will be
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * copied over.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * For direct boot, the defaults are
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * kernel$ <kernel path> <flags>
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * <kernel path> is one of:
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * /boot/platform/i86pc/kernel/$ISADIR/unix
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * /boot/platform/i86pc/kernel/amd64/unix
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * If <kernel path> is any of the last four, the command may also be "kernel".
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * <flags> is anything that isn't <kernel path>.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * This function is only called to convert a multiboot entry to a dboot entry
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * For safety, we do one more check: if the kernel path starts with /boot,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * we verify that the new kernel exists before changing it. This is mainly
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * done for bfu, as it may cause the failsafe archives to be a different
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * boot architecture from the newly bfu'ed system.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikramcvt_kernel_line(line_t *line, const char *osroot, entry_t *entry)
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems char path[PATH_MAX], path_64[PATH_MAX];
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entered. args: %s %s\n", fcn, line->line, osroot));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * We only convert multiboot to dboot and nothing else.
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: not MULTIBOOT, not converting\n", fcn));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * We're attempting to change failsafe to dboot.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * In the bfu case, we may not have a dboot failsafe
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * kernel i.e. a "unix" under the "/boot" hierarchy.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * If so, just emit a message in verbose mode and
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * return success.
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: trying to convert failsafe to DBOOT\n", fcn));
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems (void) snprintf(path_64, PATH_MAX, "%s%s", osroot,
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems if (stat(path, &sb) != 0 && stat(path_64, &sb_64) != 0) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "failsafe archives have not been\nupdated. "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: no FAILSAFE unix, not converting\n",
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * Make sure we have the correct cmd
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems line->cmd = s_strdup(menu_cmds[KERNEL_DOLLAR_CMD]);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: converted kernel cmd to %s\n", fcn, line->cmd));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram (void) strlcpy(linebuf, line->arg, sizeof (linebuf));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * only multiboot and nothing else
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * i.e. flags1 = unix = flags2 = NULL
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: NULL flags1, unix, flags2\n", fcn))
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * old_ptr is either at "flags1" or "unix"
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome if ((unix_ptr = strstr(old_ptr, "/unix")) != NULL) {
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * There is a unix.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* See if there's a flags2 past unix */
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* see if there is a flags1 before unix */
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* There is no unix, there is only a bunch of flags */
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: flags1 present: %s, unix, flags2 absent\n",
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * With dboot, unix is fixed and is at the beginning. We need to
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * migrate flags1 and flags2
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: converted unix: %s\n", fcn, new_arg));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram (void) strlcat(new_arg, flags1_ptr, sizeof (new_arg));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram (void) strlcat(new_arg, flags2_ptr, sizeof (new_arg));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: converted unix with flags : %s\n", fcn, new_arg));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: converted line is: %s\n", fcn, line->line));
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Similar to above, except this time we're looking at a module line,
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * which is quite a bit simpler.
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Under multiboot, the archive line is:
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * Under directboot, the archive line is:
ae115bc77f6fcde83175c75b4206dc2e50747966mrj * which may be specified exactly as either of:
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * Under multiboot, the failsafe is:
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * Under dboot, the failsafe is:
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * module$ /boot/$ISADIR/x86.miniroot-safe
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * which may be specified exactly as either of:
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * module /boot/x86.miniroot-safe
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems * module /boot/amd64/x86.miniroot-safe
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entered. arg: %s\n", fcn, line->line));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * We only convert multiboot to dboot and nothing else
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: not MULTIBOOT, not converting\n", fcn));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: failsafe module line needs no "
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram } else if (strcmp(line->arg, MULTIBOOT_ARCHIVE) != 0) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("module command on line %d not recognized.\n"),
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems line->cmd = s_strdup(menu_cmds[MODULE_DOLLAR_CMD]);
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems line->arg = s_strdup(entry->flags & BAM_ENTRY_FAILSAFE ?
bbcc54bdf68a1b48730879163225e88169535ce6Enrico Perla - Sun Microsystems FAILSAFE_ARCHIVE : DIRECT_BOOT_ARCHIVE);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: converted module line is: %s\n", fcn, line->line));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * No warning needed, we are automatically converting
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * the "hand" entries
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: force specified, no warnings about hand "
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram for (entry = mp->entries; entry; entry = entry->next) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: found hand entry #: %d\n", fcn,
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram hand_max * sizeof (int));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("bootadm(1M) will only upgrade GRUB menu entries added "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "by \nbootadm(1M) or lu(1M). The following entries on %s will "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "not be upgraded.\nFor details on manually updating entries, "
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram bam_print_stderr("Entry Number%s: ", (hand_num > 1) ?
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram for (i = 0; i < hand_num; i++) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entered. args: %s %s %s\n", fcn, grubsign,
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram if (!(entry->flags & (BAM_ENTRY_BOOTADM|BAM_ENTRY_LU)) &&
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: skipping hand entry #: %d\n",
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram } else if (root_opt) {
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* Neither root nor findroot */
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: no root or findroot and root is "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: no matching entry found\n", fcn));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * The following is a set of routines that attempt to convert the
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * menu entries for the supplied osroot into a format compatible
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * with the GRUB installation on osroot.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * Each of these conversion routines make no assumptions about
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * the current state of the menu entry, it does its best to
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * convert the menu entry to the new state. In the process
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * we may either upgrade or downgrade.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * We don't make any heroic efforts at conversion. It is better
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * to be conservative and bail out at the first sign of error. We will
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * in such cases, point the user at the knowledge-base article
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * so that they can upgrade manually.
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikrambam_add_findroot(menu_t *mp, char *grubsign, char *grubroot, int root_opt)
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_print(_("converting entries to findroot...\n"));
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt);
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* already converted */
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entry %d already converted to "
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(entry->next, grubsign,
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(entry->next, grubsign, grubroot,
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikrambam_add_hv(menu_t *mp, char *grubsign, char *grubroot, int root_opt)
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entry %d already converted to "
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(entry->next, grubsign, grubroot,
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram (void) add_boot_entry(mp, NEW_HV_ENTRY, grubsign, XEN_MENU,
44da779fd55c337eb9877e490e494037fc1ddf06William Kucharski XEN_KERNEL_MODULE_LINE, DIRECT_BOOT_ARCHIVE, NULL);
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: added xVM HV entry via add_boot_entry()\n", fcn));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_print(_("converting entries to dboot...\n"));
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(mp->entries, grubsign, grubroot, root_opt);
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * If we have a kernel$ command, assume it
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * is dboot already. If it is not a dboot
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * entry, something funny is going on and
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * we will leave it alone
3bbf88b3546192f29c18986b9fb8a19ff364a4eaToomas Soome entry = find_matching_entry(entry->next, grubsign, grubroot,
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: returning ret = %d\n", fcn, ret));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram/*ARGSUSED*/
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikramupgrade_menu(menu_t *mp, char *osroot, char *menu_root)
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: entered. args: %s %s\n", fcn, osroot, menu_root));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * We only support upgrades. Xen may not be present
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * on smaller metaclusters so we don't check for that.
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("automated downgrade of GRUB menu to older "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "version not supported.\n"));
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram * First get the GRUB signature
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("cant find special file for mount-point %s\n"),
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("cannot find GRUB signature for %s\n"), osroot);
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram /* not fatal if we can't get grubroot */
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram INJECT_ERROR1("UPGRADE_ADD_FINDROOT", ret1 = BAM_ERROR);
3028dfd677c76945aa0d0f6682daafb71a0abad9Frank Van Der Linden ret2 = bam_add_hv(mp, grubsign, grubroot,
3028dfd677c76945aa0d0f6682daafb71a0abad9Frank Van Der Linden INJECT_ERROR1("UPGRADE_ADD_HV", ret2 = BAM_ERROR);
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram INJECT_ERROR1("UPGRADE_ADD_DBOOT", ret3 = BAM_ERROR);
eb2bd6624e082e367f66e2b0fdfe54c9b5d493afvikram if (ret1 == BAM_MSG || ret2 == BAM_MSG || ret3 == BAM_MSG) {
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("one or more GRUB menu entries were not "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "automatically upgraded\nFor details on manually "
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "updating entries, see %s\n"), MENU_URL(osroot));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome BAM_DPRINTF(("%s: returning ret = %d\n", fcn, BAM_WRITE));
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome bam_error(_("error upgrading GRUB menu entries on %s. Aborting.\n"
c262cbbc8301f7c884fd4800056ee51ba75d931cToomas Soome "For details on manually updating entries, see %s\n"), osroot,