5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
26 .
/lib
/svc
/share
/smf_include.sh
27 .
/lib
/svc
/share
/fs_include.sh
31 # Make sure that $DUMPADM_SAVDIR is set and exists.
35 [ -z "$DUMPADM_SAVDIR" ] && DUMPADM_SAVDIR
=/var
/crash
/`uname -n`
36 [ -d "$DUMPADM_SAVDIR" ] ||
/usr
/bin
/mkdir
-m 0700 -p $DUMPADM_SAVDIR
40 # We haven't run savecore on a dump device yet
45 # If we previously crashed early in boot before dumpadm was used to configure
46 # an alternate dump device, then the dump is in the primary swap partition,
47 # which was configured as the dump device by the first swapadd early in boot.
48 # Thus before we run dumpadm to configure the dump device, we first run
49 # savecore to check the swap partition for a dump; this is run in the
50 # foreground to reduce the chances of overwriting the dump.
52 # This does not apply for zfs root systems that use a zvol for dump;
53 # for such systems the dedicated dump device is appointed during startup
54 # of the filesystem/usr:default instance before any swap is added.
55 # Therefore we must check that the dump device is a swap device here -
56 # if not then we'll run savecore here in the foreground and prevent
57 # our dependent services coming online until we're done.
63 readmnttab
/ </etc
/mnttab
64 if [ "$fstype" = zfs
] ; then
66 if [ -x /usr
/sbin
/dumpadm
]; then
67 if /usr
/sbin
/dumpadm
2>/dev
/null |
grep "Dump device:" | \
68 grep '(dedicated)' > /dev
/null
2>&1; then
74 if [ -x /usr
/bin
/savecore
-a \
75 \
( ! $rootiszfs -eq 1 -o $alreadydedicated -eq 0 \
) ]; then
76 [ -r /etc
/dumpadm.conf
] && .
/etc
/dumpadm.conf
78 if [ "x$DUMPADM_ENABLE" != xno
] && mksavedir
; then
79 /usr
/bin
/savecore
$DUMPADM_SAVDIR
81 set -- `/usr/sbin/dumpadm 2>/dev/null | /usr/bin/grep 'device:'`
85 # dumpadm -n is in effect, but we can still run savecore
86 # to raise an event with initial panic detail extracted
87 # from the dump header.
93 if [ ! -x /usr
/bin
/savecore
]; then
94 echo "WARNING: /usr/bin/savecore is missing or not executable" >& 2
98 # Now run dumpadm to configure the dump device based on the settings
99 # previously saved by dumpadm. See dumpadm(1m) for instructions on
100 # how to modify the dump settings.
102 if [ -x /usr
/sbin
/dumpadm
]; then
103 /usr
/sbin
/dumpadm
-u ||
$SMF_EXIT_ERR_CONFIG
105 echo "WARNING: /usr/sbin/dumpadm is missing or not executable" >& 2
106 exit $SMF_EXIT_ERR_CONFIG
109 if [ -r /etc
/dumpadm.conf
]; then
112 echo "WARNING: /etc/dumpadm.conf is missing or unreadable" >& 2
113 exit $SMF_EXIT_ERR_CONFIG
117 # If the savecore executable is absent then we're done
119 if [ ! -x /usr
/bin
/savecore
]; then
120 exit $SMF_EXIT_ERR_CONFIG
124 # Now that dumpadm has reconfigured /dev/dump, we need to run savecore again
125 # because the dump device may have changed. If the earlier savecore had
126 # saved the dump, savecore will just exit immediately.
131 if /usr
/sbin
/swap
-l 2>/dev
/null |
grep "^${DUMPADM_DEVICE} " \
132 >/dev
/null
2>&1; then
134 if [ "x$savedev" != "x$DUMPADM_DEVICE" ]; then
139 if [ "x$DUMPADM_ENABLE" != xno
]; then
140 if [ $isswap -eq 1 ]; then
142 # If the dump device is part of swap, we only need to run
143 # savecore a second time if the device is different from the
144 # swap device on which we initially ran savecore.
146 if [ $swapchanged -eq 1 ]; then
147 mksavedir
&& /usr
/bin
/savecore
$DUMPADM_SAVDIR &
151 # The dump device couldn't have been dedicated before we
152 # ran dumpadm, so we must execute savecore again.
154 mksavedir
&& /usr
/bin
/savecore
$DUMPADM_SAVDIR &
158 # savecore not enabled. Check whether a valid dump is
159 # present on the device and raise an event to signal that,
160 # but avoid sending a duplicate event from the savecore -c
163 if [ $isswap -eq 0 -o $swapchanged -eq 1 ]; then