bootadm_upgrade.c revision 963390b497bb4a7103b44028e033f1dbb5c81964
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A const char *
fcn =
"get_findroot_cap()";
2N/A const char *
fcn =
"get_boot_cap()";
2N/A /* there is no non dboot sparc new-boot */ 2N/A * Verify that this is a sane unix at least 8192 bytes in length 2N/A * The GRUB multiboot header must be 32-bit aligned and completely 2N/A * contained in the 1st 8K of the file. If the unix binary has 2N/A * a multiboot header, then it is a 'dboot' kernel. Otherwise, 2N/A * this kernel must be booted via multiboot -- we call this a 2N/A * 'multiboot' kernel. 2N/A /* Not a fatal error if this fails */ 2N/A * Return true if root has been bfu'ed. bfu will blow away 2N/A * assume the system has not been bfu'ed. 2N/A const char *
fcn =
"is_bfu_system()";
2N/A * Simply allocate a new line and copy in cmd + sep + arg const char *
fcn =
"update_line()";
const char *
fcn =
"skip_wspace()";
if ((*
ptr !=
' ') && (*
ptr !=
'\t') &&
const char *
fcn =
"rskip_bspace()";
if (*
ptr ==
' ' || *
ptr ==
'\t' || *
ptr ==
'\n')
* The parse_kernel_line function examines a menu.lst kernel line. For * kernel <multiboot path> <flags1> <kernel path> <flags2> * <kernel path> may be missing, or may be any full or relative path to unix. * We check for it by looking for a word ending in "/unix". If it ends * in "kernel/unix", we upgrade it to a 32-bit entry. If it ends in * it's a custom kernel, and we skip it. * <flags*> are anything that doesn't fit either of the above - these will be * For direct boot, the defaults are * kernel$ <kernel path> <flags> * <kernel path> is one of: * If <kernel path> is any of the last three, the command may also be "kernel". * <flags> is anything that isn't <kernel path>. * This function is only called to convert a multiboot entry to a dboot entry * For safety, we do one more check: if the kernel path starts with /boot, * we verify that the new kernel exists before changing it. This is mainly * done for bfu, as it may cause the failsafe archives to be a different * boot architecture from the newly bfu'ed system. const char *
fcn =
"cvt_kernel_line()";
* We only convert multiboot to dboot and nothing else. * We're attempting to change failsafe to dboot. * In the bfu case, we may not have a dboot failsafe * kernel i.e. a "unix" under the "/boot" hierarchy. * If so, just emit a message in verbose mode and * Make sure we have the correct cmd - either kernel or kernel$ * The failsafe entry should always be kernel. * only multiboot and nothing else * i.e. flags1 = unix = flags2 = NULL * old_ptr is either at "flags1" or "unix" /* See if there's a flags2 past unix */ /* see if there is a flags1 before unix */ /* There is no unix, there is only a bunch of flags */ * With dboot, unix is fixed and is at the beginning. We need to * migrate flags1 and flags2 * Similar to above, except this time we're looking at a module line, * which is quite a bit simpler. * Under multiboot, the archive line is: * Under directboot, the archive line is: * which may be specified exactly as either of: * For either dboot or multiboot, the failsafe is: const char *
fcn =
"cvt_module_line()";
* We only convert multiboot to dboot and nothing else const char *
fcn =
"bam_warn_hand_entries()";
* No warning needed, we are automatically converting const char *
fcn =
"find_matching_entry()";
/* Neither root nor findroot */ * The following is a set of routines that attempt to convert the * menu entries for the supplied osroot into a format compatible * with the GRUB installation on osroot. * Each of these conversion routines make no assumptions about * the current state of the menu entry, it does its best to * convert the menu entry to the new state. In the process * we may either upgrade or downgrade. * We don't make any heroic efforts at conversion. It is better * to be conservative and bail out at the first sign of error. We will * in such cases, point the user at the knowledge-base article * so that they can upgrade manually. const char *
fcn =
"bam_add_findroot()";
const char *
fcn =
"bam_add_hv()";
const char *
fcn =
"bam_add_dboot()";
* If we have a kernel$ command, assume it * is dboot already. If it is not a dboot * entry, something funny is going on and const char *
fcn =
"upgrade_menu()";
* We only support upgrades. Xen may not be present * on smaller metaclusters so we don't check for that. * First get the GRUB signature /* not fatal if we can't get grubroot */