summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGangadhar Mylapuram <Gangadhar.M@Sun.COM>2010-03-12 03:46:56 -0800
committerGangadhar Mylapuram <Gangadhar.M@Sun.COM>2010-03-12 03:46:56 -0800
commit3b133bec939f5230f040960ee1503dadd3dff343 (patch)
treed46c06cef5d4f4ff6a1433473fc24cb540bbcfe8
parent967a0a51c3e8ee257644dcad360e72dd4cf555f8 (diff)
downloadillumos-joyent-3b133bec939f5230f040960ee1503dadd3dff343.tar.gz
6276367 recovery from boot_archive failures could be more fully automated
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm.c14
-rw-r--r--usr/src/cmd/boot/scripts/boot-archive-update.ksh5
-rw-r--r--usr/src/cmd/eeprom/i386/benv.c5
-rw-r--r--usr/src/cmd/eeprom/i386/benv_kvm.c18
-rw-r--r--usr/src/cmd/eeprom/sparc/openprom.c24
-rw-r--r--usr/src/cmd/halt/smf.i386/boot-config.xml2
-rw-r--r--usr/src/cmd/svc/milestone/boot-archive34
-rw-r--r--usr/src/cmd/svc/milestone/fs-usr42
-rw-r--r--usr/src/uts/common/io/openprom.c61
-rw-r--r--usr/src/uts/common/sys/openpromio.h9
10 files changed, 160 insertions, 54 deletions
diff --git a/usr/src/cmd/boot/bootadm/bootadm.c b/usr/src/cmd/boot/bootadm/bootadm.c
index 5e8110e481..995b7c9473 100644
--- a/usr/src/cmd/boot/bootadm/bootadm.c
+++ b/usr/src/cmd/boot/bootadm/bootadm.c
@@ -399,8 +399,19 @@ struct safefile {
};
static struct safefile *safefiles = NULL;
+
+/*
+ * svc:/system/filesystem/usr:default service checks for this file and
+ * does a boot archive update and then reboot the system.
+ */
#define NEED_UPDATE_FILE "/etc/svc/volatile/boot_archive_needs_update"
+/*
+ * svc:/system/boot-archive-update:default checks for this file and
+ * updates the boot archive.
+ */
+#define NEED_UPDATE_SAFE_FILE "/etc/svc/volatile/boot_archive_safefile_update"
+
/* Thanks growisofs */
#define CD_BLOCK ((off64_t)2048)
#define VOLDESC_OFF 16
@@ -2061,7 +2072,8 @@ cmpstat(
file + bam_rootlen, 0, NULL, 0);
regfree(&re);
if (status == 0) {
- (void) creat(NEED_UPDATE_FILE,
+ (void) creat(
+ NEED_UPDATE_SAFE_FILE,
0644);
return (0);
}
diff --git a/usr/src/cmd/boot/scripts/boot-archive-update.ksh b/usr/src/cmd/boot/scripts/boot-archive-update.ksh
index 4db6b72478..693c715c73 100644
--- a/usr/src/cmd/boot/scripts/boot-archive-update.ksh
+++ b/usr/src/cmd/boot/scripts/boot-archive-update.ksh
@@ -20,15 +20,14 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
. /lib/svc/share/smf_include.sh
. /lib/svc/share/fs_include.sh
-UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update
+UPDATEFILE=/etc/svc/volatile/boot_archive_safefile_update
smf_is_globalzone || exit $SMF_EXIT_OK
diff --git a/usr/src/cmd/eeprom/i386/benv.c b/usr/src/cmd/eeprom/i386/benv.c
index 524859a826..fb2ee55cc5 100644
--- a/usr/src/cmd/eeprom/i386/benv.c
+++ b/usr/src/cmd/eeprom/i386/benv.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -41,6 +41,7 @@ extern void get_kbenv(void);
extern void close_kbenv(void);
extern caddr_t get_propval(char *name, char *node);
extern void setprogname(char *prog);
+extern char *getbootcmd(void);
char *boottree;
struct utsname uts_buf;
@@ -949,6 +950,8 @@ add_cmd(benv_des_t *bd, char *last, char **next, int *line)
add_bent(bd->elist, NULL, cmd, name, val);
(*line)++;
};
+
+ add_bent(bd->elist, NULL, "getprop", "bootcmd", getbootcmd());
}
/*
diff --git a/usr/src/cmd/eeprom/i386/benv_kvm.c b/usr/src/cmd/eeprom/i386/benv_kvm.c
index b7b912eb73..6ab6bdb918 100644
--- a/usr/src/cmd/eeprom/i386/benv_kvm.c
+++ b/usr/src/cmd/eeprom/i386/benv_kvm.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 1996-2002 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
#include "benv.h"
#include <sys/sunddi.h>
@@ -151,6 +149,16 @@ getnextprop(struct openpromio *opp, char *prop)
return (1);
}
+char *
+getbootcmd(void)
+{
+ struct openpromio *opp = &(oppbuf.opp);
+ opp->oprom_size = MAXVALSIZE;
+ if (ioctl(prom_fd, OPROMGETBOOTPATH, opp) < 0)
+ return (NULL);
+ return (opp->oprom_array);
+}
+
/*
* Get a pointer to the requested property from the current node.
* The property is stored in static storage and the returned pointer
diff --git a/usr/src/cmd/eeprom/sparc/openprom.c b/usr/src/cmd/eeprom/sparc/openprom.c
index 36bf325a62..d23fa6fe62 100644
--- a/usr/src/cmd/eeprom/sparc/openprom.c
+++ b/usr/src/cmd/eeprom/sparc/openprom.c
@@ -1,10 +1,6 @@
-#ifndef lint
-#pragma ident "%Z%%M% %I% %E% SMI"
-#endif
-
/*
* Open Boot Prom eeprom utility
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -255,6 +251,24 @@ print_one(char *var)
{
Oppbuf oppbuf;
struct openpromio *opp = &(oppbuf.opp);
+ char bootargs[MAXVALSIZE];
+
+ if (strcmp(var, "bootcmd") == 0) {
+ opp->oprom_size = MAXVALSIZE;
+ if (ioctl(prom_fd, OPROMGETBOOTARGS, opp) < 0) {
+ (void) _error(PERROR, "OPROMGETBOOTARGS");
+ return;
+ }
+ (void) strlcpy(bootargs, opp->oprom_array, MAXVALSIZE);
+
+ opp->oprom_size = MAXVALSIZE;
+ if (ioctl(prom_fd, OPROMGETBOOTPATH, opp) < 0) {
+ (void) _error(PERROR, "OPROMGETBOOTPATH");
+ return;
+ }
+ (void) printf("%s=%s %s\n", var, opp->oprom_array, bootargs);
+ return;
+ }
(void) strlcpy(opp->oprom_array, var, MAXNAMESIZE);
if (getpropval(opp) || opp->oprom_size <= 0)
diff --git a/usr/src/cmd/halt/smf.i386/boot-config.xml b/usr/src/cmd/halt/smf.i386/boot-config.xml
index 52ecb8965c..5eed69e7c1 100644
--- a/usr/src/cmd/halt/smf.i386/boot-config.xml
+++ b/usr/src/cmd/halt/smf.i386/boot-config.xml
@@ -90,6 +90,8 @@
<property_group name='config' type='application'>
<stability value='Stable' />
+ <propval name='trust-bios-boot-device' type='boolean'
+ value='false' />
<propval name='fastreboot_default' type='boolean'
value='true' />
<propval name='fastreboot_onpanic' type='boolean'
diff --git a/usr/src/cmd/svc/milestone/boot-archive b/usr/src/cmd/svc/milestone/boot-archive
index 94a2006d23..bdf6c0dc9b 100644
--- a/usr/src/cmd/svc/milestone/boot-archive
+++ b/usr/src/cmd/svc/milestone/boot-archive
@@ -20,31 +20,19 @@
# CDDL HEADER END
#
#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
. /lib/svc/share/smf_include.sh
. /lib/svc/share/fs_include.sh
-ERRORFILE=/etc/svc/volatile/boot_archive_error
FILELIST=/etc/svc/volatile/boot_archive_filelist
UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update
smf_is_globalzone || exit $SMF_EXIT_OK
#
-# Make sure we return failure only once. If user choose to ignore
-# error, we return success to permit boot to continue. The boot
-# archive will be updated on the subsequent shutdown.
-#
-if [ -f "${ERRORFILE}" ]; then
- rm ${ERRORFILE}
- exit $SMF_EXIT_OK
-fi
-
-#
# Now check the archive.
#
/sbin/bootadm update-archive -vnC 2> /dev/null
@@ -52,23 +40,5 @@ if [ $? = 0 ]; then
exit $SMF_EXIT_OK
fi
-touch $ERRORFILE
touch $UPDATEFILE
-
-cecho ""
-cecho "WARNING: The following files in / differ from the boot archive:"
-cecho ""
-
-/sbin/bootadm update-archive -vn | grep -v "cannot find" > /dev/msglog
-
-cecho ""
-cecho "The recommended action is to reboot to the failsafe archive to correct"
-cecho "the above inconsistency. To accomplish this, on a GRUB-based platform,"
-cecho "reboot and select the \"Solaris failsafe\" option from the boot menu."
-cecho "On an OBP-based platform, reboot then type \"boot -F failsafe\". Then"
-cecho "follow the prompts to update the boot archive. Alternately, to continue"
-cecho "booting at your own risk, you may clear the service by running:"
-cecho "\"svcadm clear system/boot-archive\""
-cecho ""
-
-exit $SMF_EXIT_ERR_FATAL
+exit $SMF_EXIT_OK
diff --git a/usr/src/cmd/svc/milestone/fs-usr b/usr/src/cmd/svc/milestone/fs-usr
index 991f9cb8ff..a9e346611c 100644
--- a/usr/src/cmd/svc/milestone/fs-usr
+++ b/usr/src/cmd/svc/milestone/fs-usr
@@ -20,7 +20,7 @@
# CDDL HEADER END
#
#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T.
@@ -30,6 +30,8 @@
. /lib/svc/share/smf_include.sh
. /lib/svc/share/fs_include.sh
+UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update
+
#
# Once root is read/write we can enable the dedicated dumpdevice if it exists
# locally. This is an optimization as svc-dumpadm will attempt do this later.
@@ -151,4 +153,42 @@ if [ "$mountp" -a -d /dev/fd ]; then
mountfs - /dev/fd - - - || exit $SMF_EXIT_ERR_FATAL
fi
+if [ -f "${UPDATEFILE}" ]; then
+ /usr/sbin/bootadm update-archive
+ if [ $? != 0 ]; then
+ cecho ""
+ cecho "WARNING: Automatic update of the boot archive failed."
+ cecho "Try update the archives using 'bootadm update-archive'"
+ cecho "command and then reboot the system from the same device that"
+ cecho "was previously booted."
+ cecho ""
+ exit $SMF_EXIT_ERR_FATAL
+ fi
+ rm -f $UPDATEFILE
+ bootcmd=`/usr/sbin/eeprom bootcmd | /usr/bin/sed -e 's#bootcmd=##g'`
+ if [ `uname -p` = "i386" ]; then
+ /usr/sbin/reboot -f dryrun
+ if [ $? = 0 ]; then
+ /usr/sbin/reboot -f -- "$bootcmd"
+ exit $SMF_EXIT_OK
+ fi
+ boot_prop=`/usr/sbin/svccfg -s svc:/system/boot-config:default listprop config/trust-bios-boot-device | \
+ /usr/bin/nawk '{ print $3}'`
+ if [ "$boot_prop" != "true" ]; then
+ cecho ""
+ cecho "WARNING: Reboot required."
+ cecho "The system has updated the cache of files (boot archive) that is used"
+ cecho "during the early boot sequence. To avoid booting and running the system"
+ cecho "with the previously out-of-sync version of these files, reboot the"
+ cecho "system from the same device that was previously booted."
+ cecho ""
+ exit $SMF_EXIT_ERR_FATAL
+ else
+ /usr/sbin/reboot -p
+ exit $SMF_EXIT_OK
+ fi
+ fi
+ /usr/sbin/reboot -- "$bootcmd"
+fi
+
exit $SMF_EXIT_OK
diff --git a/usr/src/uts/common/io/openprom.c b/usr/src/uts/common/io/openprom.c
index c420e7668a..f541037450 100644
--- a/usr/src/uts/common/io/openprom.c
+++ b/usr/src/uts/common/io/openprom.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -56,6 +56,9 @@
#include <sys/wanboot_impl.h>
#include <sys/zone.h>
#include <sys/consplat.h>
+#include <sys/bootconf.h>
+#include <sys/systm.h>
+#include <sys/bootprops.h>
#define MAX_OPENS 32 /* Up to this many simultaneous opens */
@@ -315,6 +318,30 @@ opromclose(dev_t dev, int flag, int otype, cred_t *cred_p)
return (0);
}
+#ifdef __sparc
+static int
+get_bootpath_prop(char *bootpath)
+{
+ if (root_is_ramdisk) {
+ if (BOP_GETPROP(bootops, "bootarchive", bootpath) == -1)
+ return (-1);
+ (void) strlcat(bootpath, ":a", BO_MAXOBJNAME);
+ } else {
+ if ((BOP_GETPROP(bootops, "bootpath", bootpath) == -1) ||
+ strlen(bootpath) == 0) {
+ if (BOP_GETPROP(bootops,
+ "boot-path", bootpath) == -1)
+ return (-1);
+ }
+ if (memcmp(bootpath, BP_ISCSI_DISK,
+ strlen(BP_ISCSI_DISK)) == 0) {
+ get_iscsi_bootpath_vhci(bootpath);
+ }
+ }
+ return (0);
+}
+#endif
+
struct opromioctl_args {
struct oprom_state *st;
int cmd;
@@ -457,6 +484,7 @@ opromioctl_cb(void *avp, int has_changed)
case OPROMSNAPSHOT:
case OPROMGETCONS:
case OPROMGETBOOTARGS:
+ case OPROMGETBOOTPATH:
case OPROMGETVERSION:
case OPROMPATH2DRV:
case OPROMPROM2DEVNAME:
@@ -709,6 +737,37 @@ opromioctl_cb(void *avp, int has_changed)
break;
}
+ case OPROMGETBOOTPATH: {
+#if defined(__sparc) && defined(_OBP)
+
+ char bpath[OBP_MAXPATHLEN];
+ if (get_bootpath_prop(bpath) != 0) {
+ error = EINVAL;
+ break;
+ }
+ valsize = strlen(bpath) + 1;
+ if (valsize > userbufsize) {
+ error = EINVAL;
+ break;
+ }
+ (void) strcpy(opp->oprom_array, bpath);
+
+#elif defined(__i386) || defined(__amd64)
+
+ extern char saved_cmdline[];
+ valsize = strlen(saved_cmdline) + 1;
+ if (valsize > userbufsize) {
+ error = EINVAL;
+ break;
+ }
+ (void) strcpy(opp->oprom_array, saved_cmdline);
+#endif
+ opp->oprom_size = valsize - 1;
+ if (copyout(opp, (void *)arg, valsize + sizeof (uint_t)) != 0)
+ error = EFAULT;
+ break;
+ }
+
/*
* convert a prom device path to an equivalent devfs path
*/
diff --git a/usr/src/uts/common/sys/openpromio.h b/usr/src/uts/common/sys/openpromio.h
index a3b207e055..824943791a 100644
--- a/usr/src/uts/common/sys/openpromio.h
+++ b/usr/src/uts/common/sys/openpromio.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -20,14 +19,13 @@
* CDDL HEADER END
*/
/*
- * Copyright 1989-2000, 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_OPENPROMIO_H
#define _SYS_OPENPROMIO_H
-#pragma ident "%Z%%M% %I% %E% SMI"
/* From SunOS 4.1.1 <sundev/openpromio.h> */
#ifdef __cplusplus
@@ -95,6 +93,7 @@ struct openpromio {
#define OPROMLISTKEYSLEN (OIOC | 23) /* asr-list-keys-len */
#define OPROMEXPORT (OIOC | 24) /* asr-export */
#define OPROMEXPORTLEN (OIOC | 25) /* asr-export-len */
+#define OPROMGETBOOTPATH (OIOC | 26) /* Get bootpath */
/*
* Return values from OPROMGETCONS: