summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2017-05-01 22:34:08 +0300
committerRobert Mustacchi <rm@joyent.com>2017-05-03 17:14:38 +0000
commit719db50f9baba455978a31987e3e235ebd8a1592 (patch)
treed481f7a52119067ce46e715e0ec81cfda72565f0
parent903134fe16f881063d995b98c1abaa8151f102b6 (diff)
downloadillumos-joyent-719db50f9baba455978a31987e3e235ebd8a1592.tar.gz
8142 bootadm: get_boot_cap() should test for both 32-bit and 64-bit kernel
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm_upgrade.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
index 0a6b95f7ed..86a184e623 100644
--- a/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
+++ b/usr/src/cmd/boot/bootadm/bootadm_upgrade.c
@@ -21,7 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2016 Toomas Soome <tsoome@me.com>
+ * Copyright 2017 Toomas Soome <tsoome@me.com>
*/
#include <stdio.h>
@@ -109,6 +109,7 @@ get_boot_cap(const char *osroot)
char fname[PATH_MAX];
char *image;
uchar_t *ident;
+ uchar_t class;
int fd;
int m;
multiboot_header_t *mbh;
@@ -123,9 +124,25 @@ get_boot_cap(const char *osroot)
return (BAM_SUCCESS);
}
+ /*
+ * The install media can support both 64 and 32 bit boot
+ * by using boot archive as ramdisk image. However, to save
+ * the memory, the ramdisk may only have either 32 or 64
+ * bit kernel files. To avoid error message about missing unix,
+ * we should try both variants here and only complain if neither
+ * is found. Since the 64-bit systems are more common, we start
+ * from amd64.
+ */
+ class = ELFCLASS64;
(void) snprintf(fname, PATH_MAX, "%s/%s", osroot,
- "platform/i86pc/kernel/unix");
+ "platform/i86pc/kernel/amd64/unix");
fd = open(fname, O_RDONLY);
+ if (fd < 0) {
+ class = ELFCLASS32;
+ (void) snprintf(fname, PATH_MAX, "%s/%s", osroot,
+ "platform/i86pc/kernel/unix");
+ fd = open(fname, O_RDONLY);
+ }
error = errno;
INJECT_ERROR1("GET_CAP_UNIX_OPEN", fd = -1);
if (fd < 0) {
@@ -161,7 +178,7 @@ get_boot_cap(const char *osroot)
bam_error(_("%s is not an ELF file.\n"), fname);
return (BAM_ERROR);
}
- if (ident[EI_CLASS] != ELFCLASS32) {
+ if (ident[EI_CLASS] != class) {
bam_error(_("%s is wrong ELF class 0x%x\n"), fname,
ident[EI_CLASS]);
return (BAM_ERROR);