summaryrefslogtreecommitdiff
path: root/usr/src/cmd/boot
diff options
context:
space:
mode:
authorEnrico Perla - Sun Microsystems <Enrico.Perla@Sun.COM>2008-11-13 09:24:34 -0800
committerEnrico Perla - Sun Microsystems <Enrico.Perla@Sun.COM>2008-11-13 09:24:34 -0800
commitbbcc54bdf68a1b48730879163225e88169535ce6 (patch)
tree5dd30f9edb8136893626b54b1d2b39f1d5739651 /usr/src/cmd/boot
parentfd9489cef0e9b7d8a708339e560d453f230af2cf (diff)
downloadillumos-gate-bbcc54bdf68a1b48730879163225e88169535ce6.tar.gz
6752721 bootadm lacks 64-bit failsafe support, generates errors post snv_99
Diffstat (limited to 'usr/src/cmd/boot')
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm.c93
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm.h14
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm_upgrade.c56
-rw-r--r--usr/src/cmd/boot/bootadm/message.h8
4 files changed, 134 insertions, 37 deletions
diff --git a/usr/src/cmd/boot/bootadm/bootadm.c b/usr/src/cmd/boot/bootadm/bootadm.c
index 9f0ed6fd93..97d1c74829 100644
--- a/usr/src/cmd/boot/bootadm/bootadm.c
+++ b/usr/src/cmd/boot/bootadm/bootadm.c
@@ -2601,6 +2601,16 @@ kernel_parser(entry_t *entry, char *cmd, char *arg, int linenum)
sizeof (DIRECT_BOOT_FAILSAFE_KERNEL) - 1) == 0) {
BAM_DPRINTF((D_SET_DBOOT_FAILSAFE, fcn, arg));
entry->flags |= BAM_ENTRY_DBOOT | BAM_ENTRY_FAILSAFE;
+ } else if (strncmp(arg, DIRECT_BOOT_FAILSAFE_32,
+ sizeof (DIRECT_BOOT_FAILSAFE_32) - 1) == 0) {
+ BAM_DPRINTF((D_SET_DBOOT_FAILSAFE_32, fcn, arg));
+ entry->flags |= BAM_ENTRY_DBOOT | BAM_ENTRY_FAILSAFE
+ | BAM_ENTRY_32BIT;
+ } else if (strncmp(arg, DIRECT_BOOT_FAILSAFE_64,
+ sizeof (DIRECT_BOOT_FAILSAFE_64) - 1) == 0) {
+ BAM_DPRINTF((D_SET_DBOOT_FAILSAFE_64, fcn, arg));
+ entry->flags |= BAM_ENTRY_DBOOT | BAM_ENTRY_FAILSAFE
+ | BAM_ENTRY_64BIT;
} else if (strncmp(arg, MULTI_BOOT, sizeof (MULTI_BOOT) - 1) == 0) {
BAM_DPRINTF((D_SET_MULTIBOOT, fcn, arg));
entry->flags |= BAM_ENTRY_MULTIBOOT;
@@ -2643,6 +2653,8 @@ module_parser(entry_t *entry, char *cmd, char *arg, int linenum)
strcmp(arg, DIRECT_BOOT_ARCHIVE_64) == 0 ||
strcmp(arg, MULTIBOOT_ARCHIVE) == 0 ||
strcmp(arg, FAILSAFE_ARCHIVE) == 0 ||
+ strcmp(arg, FAILSAFE_ARCHIVE_32) == 0 ||
+ strcmp(arg, FAILSAFE_ARCHIVE_64) == 0 ||
strcmp(arg, XEN_KERNEL_MODULE_LINE) == 0 ||
strcmp(arg, XEN_KERNEL_MODULE_LINE_ZFS) == 0) {
BAM_DPRINTF((D_BOOTADM_LU_MODULE, fcn, arg));
@@ -6197,7 +6209,13 @@ find_boot_entry(
if (kernel &&
(!check_cmd(lp->cmd, KERNEL_CMD, lp->arg, kernel))) {
- continue;
+ if (!(ent->flags & BAM_ENTRY_FAILSAFE) ||
+ !(ent->flags & BAM_ENTRY_DBOOT) ||
+ strcmp(kernel, DIRECT_BOOT_FAILSAFE_LINE) != 0)
+ continue;
+
+ ent->flags |= BAM_ENTRY_UPGFSKERNEL;
+
}
BAM_DPRINTF((D_KERNEL_MATCH, fcn, kernel, lp->arg));
@@ -6215,6 +6233,14 @@ find_boot_entry(
BAM_DPRINTF((D_MODULE_MATCH, fcn, module, lp->arg));
break;
}
+
+ if (strcmp(module, FAILSAFE_ARCHIVE) == 0 &&
+ (strcmp(lp->prev->arg, FAILSAFE_ARCHIVE_32) == 0 ||
+ strcmp(lp->prev->arg, FAILSAFE_ARCHIVE_64) == 0)) {
+ ent->flags |= BAM_ENTRY_UPGFSMODULE;
+ break;
+ }
+
}
if (ent && entry_num) {
@@ -6303,6 +6329,29 @@ update_boot_entry(menu_t *mp, char *title, char *findroot, char *root,
/* kernel line */
lp = lp->next;
+ if (ent->flags & BAM_ENTRY_UPGFSKERNEL) {
+ char *params = NULL;
+
+ params = strstr(lp->line, "-s");
+ if (params != NULL)
+ (void) snprintf(linebuf, sizeof (linebuf), "%s%s%s%s",
+ menu_cmds[KERNEL_DOLLAR_CMD], menu_cmds[SEP_CMD],
+ kernel, params+2);
+ else
+ (void) snprintf(linebuf, sizeof (linebuf), "%s%s%s",
+ menu_cmds[KERNEL_DOLLAR_CMD], menu_cmds[SEP_CMD],
+ kernel);
+
+ free(lp->cmd);
+ free(lp->arg);
+ free(lp->line);
+ lp->cmd = s_strdup(menu_cmds[KERNEL_DOLLAR_CMD]);
+ lp->arg = s_strdup(strstr(linebuf, "/"));
+ lp->line = s_strdup(linebuf);
+ ent->flags &= ~BAM_ENTRY_UPGFSKERNEL;
+ BAM_DPRINTF((D_ADDING_KERNEL_DOLLAR, fcn, lp->prev->cmd));
+ }
+
if (change_kernel) {
/*
* We're upgrading from multiboot to directboot.
@@ -6334,6 +6383,27 @@ update_boot_entry(menu_t *mp, char *title, char *findroot, char *root,
BAM_DPRINTF((D_ADDING_MODULE_DOLLAR, fcn, module));
}
}
+
+ /* module line */
+ lp = lp->next;
+
+ if (ent->flags & BAM_ENTRY_UPGFSMODULE) {
+ if (strcmp(lp->cmd, menu_cmds[MODULE_CMD]) == 0) {
+ (void) snprintf(linebuf, sizeof (linebuf), "%s%s%s",
+ menu_cmds[MODULE_DOLLAR_CMD], menu_cmds[SEP_CMD],
+ module);
+ free(lp->cmd);
+ free(lp->arg);
+ free(lp->line);
+ lp->cmd = s_strdup(menu_cmds[MODULE_DOLLAR_CMD]);
+ lp->arg = s_strdup(module);
+ lp->line = s_strdup(linebuf);
+ lp = lp->next;
+ ent->flags &= ~BAM_ENTRY_UPGFSMODULE;
+ BAM_DPRINTF((D_ADDING_MODULE_DOLLAR, fcn, module));
+ }
+ }
+
BAM_DPRINTF((D_RETURN_RET, fcn, i));
return (i);
}
@@ -6417,6 +6487,7 @@ update_entry(menu_t *mp, char *menu_root, char *osdev)
char *failsafe_kernel = NULL;
struct stat sbuf;
char failsafe[256];
+ char failsafe_64[256];
int ret;
const char *fcn = "update_entry()";
@@ -6485,13 +6556,25 @@ update_entry(menu_t *mp, char *menu_root, char *osdev)
* failsafe may be different than the installed kernel.
*/
(void) snprintf(failsafe, sizeof (failsafe), "%s%s",
- osroot, FAILSAFE_ARCHIVE);
- if (stat(failsafe, &sbuf) == 0) {
+ osroot, FAILSAFE_ARCHIVE_32);
+ (void) snprintf(failsafe_64, sizeof (failsafe_64), "%s%s",
+ osroot, FAILSAFE_ARCHIVE_64);
+
+ /*
+ * Check if at least one of the two archives exists
+ * Using $ISADIR as the default line, we have an entry which works
+ * for both the cases.
+ */
+
+ if (stat(failsafe, &sbuf) == 0 || stat(failsafe_64, &sbuf) == 0) {
/* Figure out where the kernel line should point */
(void) snprintf(failsafe, sizeof (failsafe), "%s%s", osroot,
- DIRECT_BOOT_FAILSAFE_KERNEL);
- if (stat(failsafe, &sbuf) == 0) {
+ DIRECT_BOOT_FAILSAFE_32);
+ (void) snprintf(failsafe_64, sizeof (failsafe_64), "%s%s",
+ osroot, DIRECT_BOOT_FAILSAFE_64);
+ if (stat(failsafe, &sbuf) == 0 ||
+ stat(failsafe_64, &sbuf) == 0) {
failsafe_kernel = DIRECT_BOOT_FAILSAFE_LINE;
} else {
(void) snprintf(failsafe, sizeof (failsafe), "%s%s",
diff --git a/usr/src/cmd/boot/bootadm/bootadm.h b/usr/src/cmd/boot/bootadm/bootadm.h
index cd44496a95..d7edd054b1 100644
--- a/usr/src/cmd/boot/bootadm/bootadm.h
+++ b/usr/src/cmd/boot/bootadm/bootadm.h
@@ -26,8 +26,6 @@
#ifndef _BOOTADM_H
#define _BOOTADM_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -85,6 +83,9 @@ typedef struct entry {
#define BAM_ENTRY_MULTIBOOT 0x200 /* is multiboot (normal or failsafe) */
#define BAM_ENTRY_64BIT 0x400 /* Is a 64-bit entry */
+#define BAM_ENTRY_UPGFSKERNEL 0x800 /* Upgrade failsafe kernel entry */
+#define BAM_ENTRY_UPGFSMODULE 0x1000 /* Upgrade failsafe module entry */
+
typedef struct {
line_t *start;
line_t *end;
@@ -213,7 +214,10 @@ extern int is_sparc(void);
#define DIRECT_BOOT_32 "/platform/i86pc/kernel/unix"
#define DIRECT_BOOT_64 "/platform/i86pc/kernel/amd64/unix"
#define DIRECT_BOOT_KERNEL "/platform/i86pc/kernel/$ISADIR/unix"
-#define DIRECT_BOOT_FAILSAFE_KERNEL "/boot/platform/i86pc/kernel/unix"
+#define DIRECT_BOOT_FAILSAFE_32 "/boot/platform/i86pc/kernel/unix"
+#define DIRECT_BOOT_FAILSAFE_64 "/boot/platform/i86pc/kernel/amd64/unix"
+#define DIRECT_BOOT_FAILSAFE_KERNEL \
+ "/boot/platform/i86pc/kernel/$ISADIR/unix"
#define DIRECT_BOOT_FAILSAFE_LINE DIRECT_BOOT_FAILSAFE_KERNEL " -s"
#define DIRECT_BOOT_KERNEL_ZFS DIRECT_BOOT_KERNEL " " ZFS_BOOT
@@ -227,7 +231,9 @@ extern int is_sparc(void);
#define DIRECT_BOOT_ARCHIVE_32 "/platform/i86pc/boot_archive"
#define DIRECT_BOOT_ARCHIVE_64 "/platform/i86pc/amd64/boot_archive"
#define MULTIBOOT_ARCHIVE DIRECT_BOOT_ARCHIVE_32
-#define FAILSAFE_ARCHIVE "/boot/x86.miniroot-safe"
+#define FAILSAFE_ARCHIVE "/boot/$ISADIR/x86.miniroot-safe"
+#define FAILSAFE_ARCHIVE_32 "/boot/x86.miniroot-safe"
+#define FAILSAFE_ARCHIVE_64 "/boot/amd64/x86.miniroot-safe"
/* Hypervisors */
#define XEN_32 "/boot/xen.gz"
diff --git a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
index 05c0abfb9f..58b618b136 100644
--- a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
+++ b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
@@ -337,11 +335,13 @@ rskip_bspace(char *bound, char *ptr)
*
* <kernel path> is one of:
* /platform/i86pc/kernel/$ISADIR/unix
+ * /boot/platform/i86pc/kernel/$ISADIR/unix
* /platform/i86pc/kernel/unix
* /platform/i86pc/kernel/amd64/unix
* /boot/platform/i86pc/kernel/unix
+ * /boot/platform/i86pc/kernel/amd64/unix
*
- * If <kernel path> is any of the last three, the command may also be "kernel".
+ * If <kernel path> is any of the last four, the command may also be "kernel".
*
* <flags> is anything that isn't <kernel path>.
*
@@ -355,10 +355,10 @@ rskip_bspace(char *bound, char *ptr)
static error_t
cvt_kernel_line(line_t *line, const char *osroot, entry_t *entry)
{
- char path[PATH_MAX];
+ char path[PATH_MAX], path_64[PATH_MAX];
char linebuf[PATH_MAX];
char new_arg[PATH_MAX];
- struct stat sb;
+ struct stat sb, sb_64;
char *old_ptr;
char *unix_ptr;
char *flags1_ptr;
@@ -385,8 +385,10 @@ cvt_kernel_line(line_t *line, const char *osroot, entry_t *entry)
*/
BAM_DPRINTF((D_TRYING_FAILSAFE_CVT_TO_DBOOT, fcn));
(void) snprintf(path, PATH_MAX, "%s%s", osroot,
- DIRECT_BOOT_FAILSAFE_KERNEL);
- if (stat(path, &sb) != 0) {
+ DIRECT_BOOT_FAILSAFE_32);
+ (void) snprintf(path_64, PATH_MAX, "%s%s", osroot,
+ DIRECT_BOOT_FAILSAFE_64);
+ if (stat(path, &sb) != 0 && stat(path_64, &sb_64) != 0) {
if (bam_verbose) {
bam_error(FAILSAFE_MISSING, line->lineNum);
}
@@ -396,14 +398,12 @@ cvt_kernel_line(line_t *line, const char *osroot, entry_t *entry)
}
/*
- * Make sure we have the correct cmd - either kernel or kernel$
- * The failsafe entry should always be kernel.
+ * Make sure we have the correct cmd
*/
- if (!(entry->flags & BAM_ENTRY_FAILSAFE)) {
- free(line->cmd);
- line->cmd = s_strdup(menu_cmds[KERNEL_DOLLAR_CMD]);
- BAM_DPRINTF((D_CVT_CMD_KERN_DOLLAR, fcn, line->cmd));
- }
+
+ free(line->cmd);
+ line->cmd = s_strdup(menu_cmds[KERNEL_DOLLAR_CMD]);
+ BAM_DPRINTF((D_CVT_CMD_KERN_DOLLAR, fcn, line->cmd));
assert(sizeof (linebuf) > strlen(line->arg) + 32);
(void) strlcpy(linebuf, line->arg, sizeof (linebuf));
@@ -510,9 +510,18 @@ create:
* module /platform/i86pc/boot_archive
* module /platform/i86pc/amd64/boot_archive
*
- * For either dboot or multiboot, the failsafe is:
+ * Under multiboot, the failsafe is:
*
* module /boot/x86.miniroot-safe
+ *
+ * Under dboot, the failsafe is:
+ *
+ * module$ /boot/$ISADIR/x86.miniroot-safe
+ *
+ * which may be specified exactly as either of:
+ *
+ * module /boot/x86.miniroot-safe
+ * module /boot/amd64/x86.miniroot-safe
*/
static error_t
cvt_module_line(line_t *line, entry_t *entry)
@@ -541,17 +550,12 @@ cvt_module_line(line_t *line, entry_t *entry)
return (BAM_MSG);
}
- if (entry->flags & BAM_ENTRY_FAILSAFE) {
- free(line->cmd);
- free(line->arg);
- line->cmd = s_strdup(menu_cmds[MODULE_CMD]);
- line->arg = s_strdup(FAILSAFE_ARCHIVE);
- } else {
- free(line->cmd);
- free(line->arg);
- line->cmd = s_strdup(menu_cmds[MODULE_DOLLAR_CMD]);
- line->arg = s_strdup(DIRECT_BOOT_ARCHIVE);
- }
+ free(line->cmd);
+ free(line->arg);
+ line->cmd = s_strdup(menu_cmds[MODULE_DOLLAR_CMD]);
+
+ line->arg = s_strdup(entry->flags & BAM_ENTRY_FAILSAFE ?
+ FAILSAFE_ARCHIVE : DIRECT_BOOT_ARCHIVE);
update_line(line);
BAM_DPRINTF((D_CVTED_MODULE, fcn, line->line));
diff --git a/usr/src/cmd/boot/bootadm/message.h b/usr/src/cmd/boot/bootadm/message.h
index bc7f7496ed..699eadead6 100644
--- a/usr/src/cmd/boot/bootadm/message.h
+++ b/usr/src/cmd/boot/bootadm/message.h
@@ -26,8 +26,6 @@
#ifndef _MESSAGE_H
#define _MESSAGE_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -1036,6 +1034,12 @@ gettext("failed to get special file for menu_root: %s\n")
#define D_SET_DBOOT_FAILSAFE "%s: setting DBOOT|DBOOT_FAILSAFE flag: %s\n"
+#define D_SET_DBOOT_FAILSAFE_32 \
+ "%s: setting DBOOT|DBOOT_FAILSAFE|DBOOT_32 flag: %s\n"
+
+#define D_SET_DBOOT_FAILSAFE_64 \
+ "%s: setting DBOOT|DBOOT_FAILSAFE|DBOOT_64 flag: %s\n"
+
#define D_SET_MULTIBOOT "%s: setting MULTIBOOT flag: %s\n"
#define D_SET_MULTIBOOT_FAILSAFE \