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 # ident "%Z%%M% %I% %E% SMI"
25 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
26 # Use is subject to license terms.
30 # This script is called by flarcreate.sh
32 # Unmount all hwcap libraries (like /usr/lib/libc/libc_hwcap2.so.1)
33 # and store commands needed to remount them in preexit/remount_hwcap.xxxx
34 # scripts, which remounts them in the preexit phase.
37 if [ -z "$FLASH_PID" ]; then
38 echo "$0: ERROR: FLASH_PID not set in execution environment, exiting..."
41 if [ -z "$FLASH_DIR" ]; then
42 echo "$0: ERROR: FLASH_DIR not set in execution environment, exiting..."
47 ELFDUMP
=/usr
/ccs
/bin
/elfdump
49 UMOUNT
=/usr
/sbin
/umount
52 CMD_LIST
="$CHMOD $ELFDUMP $MOUNT $UMOUNT $EGREP $SED"
56 if [ ! -x $cmd ]; then
57 echo "$0: ERROR: $cmd not found or not executable, exiting..."
63 # Fill "LIBS" with a list of mounted libraries in the form:
66 # /lib/libc.so.1:/usr/lib/libc/libc_hwcap2.so.1
68 LIBS
=`$MOUNT | $EGREP "^/lib|^/usr/lib" | \
69 $SED -e 's:^\(/[^ ]*\) on \([^ ]*\).*$:\1@\2:'`
71 if [ ! "$LIBS" ]; then
75 REMOUNT_DIR
=${FLASH_DIR}/preexit
76 REMOUNT
=${REMOUNT_DIR}/remount_hwcap.
${FLASH_PID}
79 # Create the flash preexit script directory for the remount scripts if it
80 # doesn't already exist.
82 if [ ! -d $REMOUNT_DIR ]; then
84 /usr
/bin
/mkdir
$REMOUNT_DIR
86 echo "$0: ERROR: could not mkdir $REMOUNT_DIR, exiting..."
92 # If an old remount script by this name exists, delete it
94 if [ -f $REMOUNT ]; then
100 cat > $REMOUNT << EOF
102 if [ \"\$FLASH_PID\" != \"$FLASH_PID\" ]; then
108 if [ $?
-ne 0 ]; then
109 echo "$0: ERROR: could not create $REMOUNT, exiting..."
114 # Now process each of the libraries that are mounted. For each, find out if
115 # it's a hwcap library; if it is, unmount it and write instructions to the
116 # preexit script as to how to remount it.
120 echo $entry | IFS
=@
read MOUNTPOINT MOUNTLIB
121 CAPLIB
=`$ELFDUMP -H $MOUNTLIB`
122 if [ \
( $?
-eq 0 \
) -a \
( -n "$CAPLIB" \
) ]; then
123 $UMOUNT $MOUNTPOINT ||
$UMOUNT -f $MOUNTPOINT || \
124 { echo "$0: ERROR: Could not unmount" \
125 "$MOUNTPOINT, exiting..."; \
126 /bin
/sh
$REMOUNT; /bin
/rm -f $REMOUNT; exit 1; }
128 echo $MOUNTLIB |
$EGREP -s :
129 if [ $?
-eq 0 ]; then
132 MOUNTOPTS
="-O -F lofs"
134 echo "$MOUNT $MOUNTOPTS $MOUNTLIB $MOUNTPOINT" >> $REMOUNT
139 # Write final cleanup instructions to the flash preexit remount script and make
142 echo "/bin/rm -f $REMOUNT" >> $REMOUNT
143 echo "exit 0" >> $REMOUNT