2001-01-15 05:01:19 +00:00
|
|
|
##/bin/sh
|
|
|
|
|
|
|
|
|
|
#
|
2003-05-22 04:16:45 +00:00
|
|
|
# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of version 2 of the GNU General Public License as
|
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it would be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
#
|
|
|
|
|
# Further, this software is distributed without any warranty that it is
|
|
|
|
|
# free of the rightful claim of any third person regarding infringement
|
|
|
|
|
# or the like. Any license provided herein, whether implied or
|
|
|
|
|
# otherwise, applies only to this software file. Patent licenses, if
|
|
|
|
|
# any, provided herein do not apply to combinations of this program with
|
|
|
|
|
# other software, or any other product whatsoever.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write the Free Software Foundation, Inc., 59
|
|
|
|
|
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
|
|
|
|
# Mountain View, CA 94043, or:
|
|
|
|
|
#
|
|
|
|
|
# http://www.sgi.com
|
|
|
|
|
#
|
|
|
|
|
# For further information regarding this notice, see:
|
|
|
|
|
#
|
|
|
|
|
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# we need common.config
|
|
|
|
|
if ! . ./common.config
|
|
|
|
|
then
|
|
|
|
|
echo "$iam: failed to source common.config"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2001-04-24 01:50:45 +00:00
|
|
|
# make sure we have a standard umask
|
|
|
|
|
umask 022
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# awk
|
2001-01-25 01:28:18 +00:00
|
|
|
AWK_PROG=awk
|
2003-07-17 23:06:11 +00:00
|
|
|
export AWK_PROG
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2002-01-20 00:47:43 +00:00
|
|
|
# we override mount and mkfs.xfs so we can specify extra options
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
mount()
|
|
|
|
|
{
|
|
|
|
|
case "$*"
|
|
|
|
|
in
|
|
|
|
|
*remount*)
|
|
|
|
|
/bin/mount $*
|
|
|
|
|
;;
|
|
|
|
|
*ext2*)
|
|
|
|
|
/bin/mount $*
|
|
|
|
|
;;
|
|
|
|
|
*xfs*)
|
|
|
|
|
/bin/mount $* $MOUNT_OPTIONS
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
/bin/mount $*
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_test_mount()
|
2002-01-20 00:47:43 +00:00
|
|
|
{
|
2003-05-22 04:16:45 +00:00
|
|
|
TEST_OPTIONS=""
|
2003-06-01 21:40:24 +00:00
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
|
|
|
|
|
TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
|
|
|
|
|
TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
|
2003-08-25 01:18:54 +00:00
|
|
|
[ -z "$FSTYP" ] && FSTYP=xfs
|
|
|
|
|
mount -t $FSTYP $TEST_OPTIONS $MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
|
2003-05-22 04:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_mount_options()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -ortdev=$SCRATCH_RTDEV"
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -ologdev=$SCRATCH_LOGDEV"
|
2003-06-02 01:49:23 +00:00
|
|
|
echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
|
2003-05-22 04:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_mount()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -ortdev=$SCRATCH_RTDEV"
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -ologdev=$SCRATCH_LOGDEV"
|
2003-08-25 01:18:54 +00:00
|
|
|
[ -z "$FSTYP" ] && FSTYP=xfs
|
|
|
|
|
mount -t $FSTYP $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
|
2003-05-22 04:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_mkfs_options()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -rrtdev=$SCRATCH_RTDEV"
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -llogdev=$SCRATCH_LOGDEV"
|
|
|
|
|
echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-25 01:18:54 +00:00
|
|
|
_scratch_mkfs()
|
|
|
|
|
{
|
|
|
|
|
if [ -z "$FSTYP" -o "$FSTYP" = xfs ]; then
|
|
|
|
|
_scratch_mkfs_xfs $*
|
|
|
|
|
else
|
|
|
|
|
/sbin/mkfs.$FSTYP $MKFS_OPTIONS $* $SCRATCH_DEV
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -rrtdev=$SCRATCH_RTDEV"
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="$SCRATCH_OPTIONS -llogdev=$SCRATCH_LOGDEV"
|
|
|
|
|
/sbin/mkfs.xfs -f $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
|
2003-08-29 06:04:54 +00:00
|
|
|
mkfs_status=$?
|
2003-09-12 00:38:26 +00:00
|
|
|
if [ "$USE_BIG_LOOPFS" = yes ]; then
|
|
|
|
|
[ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
|
|
|
|
|
./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
|
|
|
|
|
fi
|
2003-08-29 06:04:54 +00:00
|
|
|
return $mkfs_status
|
2003-05-22 04:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_xfs_db_options()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
|
|
|
|
|
echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_xfs_logprint()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
|
|
|
|
|
/usr/sbin/xfs_logprint $SCRATCH_OPTIONS $* $SCRATCH_DEV
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_scratch_xfs_repair()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_OPTIONS=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
|
2003-08-29 06:04:54 +00:00
|
|
|
[ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
|
2003-05-22 04:16:45 +00:00
|
|
|
/sbin/xfs_repair $SCRATCH_OPTIONS $* $SCRATCH_DEV
|
2002-01-20 00:47:43 +00:00
|
|
|
}
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
_get_pids_by_name()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _get_pids_by_name process-name" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Algorithm ... all ps(1) variants have a time of the form MM:SS or
|
|
|
|
|
# HH:MM:SS before the psargs field, use this as the search anchor.
|
|
|
|
|
#
|
|
|
|
|
# Matches with $1 (process-name) occur if the first psarg is $1
|
|
|
|
|
# or ends in /$1 ... the matching uses sed's regular expressions,
|
|
|
|
|
# so passing a regex into $1 will work.
|
|
|
|
|
|
|
|
|
|
ps $PS_ALL_FLAGS \
|
|
|
|
|
| sed -n \
|
|
|
|
|
-e 's/$/ /' \
|
|
|
|
|
-e 's/[ ][ ]*/ /g' \
|
|
|
|
|
-e 's/^ //' \
|
|
|
|
|
-e 's/^[^ ]* //' \
|
|
|
|
|
-e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
|
|
|
|
|
-e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# fqdn for localhost
|
|
|
|
|
#
|
|
|
|
|
_get_fqdn()
|
|
|
|
|
{
|
|
|
|
|
host=`hostname`
|
|
|
|
|
nslookup $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# fix malloc libs output
|
|
|
|
|
#
|
|
|
|
|
_fix_malloc()
|
|
|
|
|
{
|
|
|
|
|
# filter out the Electric Fence notice
|
|
|
|
|
perl -e '
|
|
|
|
|
while (<>) {
|
|
|
|
|
if (defined $o && /^\s+Electric Fence/) {
|
|
|
|
|
chomp($o);
|
|
|
|
|
print "$o";
|
|
|
|
|
undef $o;
|
|
|
|
|
next;
|
|
|
|
|
}
|
|
|
|
|
print $o if (defined $o);
|
|
|
|
|
|
|
|
|
|
$o=$_;
|
|
|
|
|
}
|
|
|
|
|
print $o if (defined $o);
|
|
|
|
|
'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# check if run as root
|
|
|
|
|
#
|
|
|
|
|
_need_to_be_root()
|
|
|
|
|
{
|
|
|
|
|
id=`id | sed -e 's/(.*//' -e 's/.*=//'`
|
|
|
|
|
if [ "$id" -ne 0 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Arrgh ... you need to be root (not uid=$id) to run this test"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# _df_device : get an IRIX style df line for a given device
|
|
|
|
|
#
|
|
|
|
|
# - returns "" if not mounted
|
|
|
|
|
# - returns fs type in field two (ala IRIX)
|
|
|
|
|
# - joins line together if split by fancy df formatting
|
|
|
|
|
# - strips header etc
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
_df_device()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _df_device device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
df -T 2>/dev/null | $AWK_PROG -v what=$1 '
|
|
|
|
|
match($1,what) && NF==1 {
|
|
|
|
|
v=$1
|
|
|
|
|
getline
|
|
|
|
|
print v, $0
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
match($1,what) {
|
|
|
|
|
print
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# _df_dir : get an IRIX style df line for device where a directory resides
|
|
|
|
|
#
|
|
|
|
|
# - returns fs type in field two (ala IRIX)
|
|
|
|
|
# - joins line together if split by fancy df formatting
|
|
|
|
|
# - strips header etc
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
_df_dir()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _df_dir device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
df -T $1 2>/dev/null | $AWK_PROG -v what=$1 '
|
|
|
|
|
NR == 2 && NF==1 {
|
|
|
|
|
v=$1
|
|
|
|
|
getline
|
|
|
|
|
print v, $0;
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
NR == 2 {
|
|
|
|
|
print;
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
{}
|
|
|
|
|
'
|
|
|
|
|
# otherwise, nada
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# return percentage used disk space for mounted device
|
|
|
|
|
|
|
|
|
|
_used()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _used device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# return the FS type of a mounted device
|
|
|
|
|
#
|
|
|
|
|
_fs_type()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _fs_type device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_df_device $1 | $AWK_PROG '{ print $2 }'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# return the FS mount options of a mounted device
|
|
|
|
|
#
|
|
|
|
|
_fs_options()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _fs_options device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
$AWK_PROG -v dev=$1 '
|
|
|
|
|
match($1,dev) { print $4 }
|
|
|
|
|
' </proc/mounts
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# returns device number if a file is a block device
|
|
|
|
|
#
|
|
|
|
|
_is_block_dev()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _is_block_dev dev" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-04 01:45:38 +00:00
|
|
|
# Do a command, log it to $seq.full, optionally test return status
|
|
|
|
|
# and die if command fails. If called with one argument _do executes the
|
|
|
|
|
# command, logs it, and returns its exit status. With two arguments _do
|
|
|
|
|
# first prints the message passed in the first argument, and then "done"
|
|
|
|
|
# or "fail" depending on the return status of the command passed in the
|
|
|
|
|
# second argument. If the command fails and the variable _do_die_on_error
|
|
|
|
|
# is set to "always" or the two argument form is used and _do_die_on_error
|
|
|
|
|
# is set to "message_only" _do will print an error message to
|
|
|
|
|
# $seq.out and exit.
|
|
|
|
|
|
2001-04-02 00:41:31 +00:00
|
|
|
_do()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -eq 1 ]; then
|
|
|
|
|
_cmd=$1
|
|
|
|
|
elif [ $# -eq 2 ]; then
|
|
|
|
|
_note=$1
|
|
|
|
|
_cmd=$2
|
|
|
|
|
echo -n "$_note... "
|
|
|
|
|
else
|
|
|
|
|
echo "Usage: _do [note] cmd" 1>&2
|
|
|
|
|
status=1; exit
|
|
|
|
|
fi
|
|
|
|
|
|
2001-04-02 05:21:15 +00:00
|
|
|
(eval "echo '---' \"$_cmd\"") >>$seq.full
|
2001-04-02 00:41:31 +00:00
|
|
|
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
|
|
|
|
|
cat $tmp._out | _fix_malloc >>$seq.full
|
|
|
|
|
if [ $# -eq 2 ]; then
|
2001-04-04 01:45:38 +00:00
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
|
echo "done"
|
|
|
|
|
else
|
|
|
|
|
echo "fail"
|
|
|
|
|
fi
|
2001-04-02 00:41:31 +00:00
|
|
|
fi
|
2001-04-04 01:45:38 +00:00
|
|
|
if [ $ret -ne 0 ] \
|
|
|
|
|
&& [ "$_do_die_on_error" = "always" \
|
|
|
|
|
-o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
|
|
|
|
|
then
|
|
|
|
|
[ $# -ne 2 ] && echo
|
|
|
|
|
eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
|
|
|
|
|
status=1; exit
|
2001-04-02 00:41:31 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# bail out, setting up .notrun file
|
|
|
|
|
#
|
|
|
|
|
_notrun()
|
|
|
|
|
{
|
|
|
|
|
echo "$*" >$seq.notrun
|
2001-01-31 07:08:16 +00:00
|
|
|
echo "$seq not run: $*"
|
2001-01-15 05:01:19 +00:00
|
|
|
status=0
|
|
|
|
|
exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# just plain bail out
|
|
|
|
|
#
|
|
|
|
|
_fail()
|
|
|
|
|
{
|
|
|
|
|
echo "$*" | tee -a $seq.full
|
|
|
|
|
echo "(see $seq.full for details)"
|
|
|
|
|
status=1
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# this test needs a scratch partition - check we're ok & unmount it
|
|
|
|
|
#
|
|
|
|
|
_require_scratch()
|
|
|
|
|
{
|
|
|
|
|
if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
|
|
|
|
|
then
|
|
|
|
|
_notrun "this test requires a valid \$SCRATCH_DEV"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
|
|
|
|
|
then
|
|
|
|
|
_notrun "this test requires a valid \$SCRATCH_DEV"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# mounted?
|
|
|
|
|
if mount | grep -q $SCRATCH_DEV
|
|
|
|
|
then
|
|
|
|
|
# if it's mounted, make sure its on $SCRATCH_MNT
|
|
|
|
|
if ! mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
|
|
|
|
|
then
|
|
|
|
|
echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
# and then unmount it
|
|
|
|
|
if ! umount $SCRATCH_DEV
|
|
|
|
|
then
|
|
|
|
|
echo "failed to unmount $SCRATCH_DEV"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# this test needs a logdev
|
|
|
|
|
#
|
|
|
|
|
_require_logdev()
|
|
|
|
|
{
|
2003-05-22 04:16:45 +00:00
|
|
|
[ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
|
2001-01-15 05:01:19 +00:00
|
|
|
_notrun "This test requires a valid \$SCRATCH_LOGDEV"
|
2003-05-22 04:16:45 +00:00
|
|
|
[ "$USE_EXTERNAL" != yes ] && \
|
|
|
|
|
_notrun "This test requires USE_EXTERNAL to be enabled"
|
|
|
|
|
|
2002-05-06 07:44:22 +00:00
|
|
|
# ensure its not mounted
|
|
|
|
|
umount $SCRATCH_LOGDEV 2>/dev/null
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# this test requires loopback device support
|
|
|
|
|
#
|
|
|
|
|
_require_loop()
|
|
|
|
|
{
|
2002-06-05 02:24:23 +00:00
|
|
|
modprobe loop >/dev/null 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
if grep loop /proc/devices >/dev/null 2>&1
|
|
|
|
|
then
|
|
|
|
|
:
|
|
|
|
|
else
|
|
|
|
|
_notrun "This test requires loopback device support"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-29 06:04:54 +00:00
|
|
|
# this test requires that (large) loopback device files are not in use
|
|
|
|
|
#
|
|
|
|
|
_require_nobigloopfs()
|
|
|
|
|
{
|
|
|
|
|
[ "$USE_BIG_LOOPFS" = yes ] && \
|
|
|
|
|
_notrun "Large filesystem testing in progress, skipped this test"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# this test requires that external log/realtime devices are not in use
|
|
|
|
|
#
|
|
|
|
|
_require_nonexternal()
|
|
|
|
|
{
|
|
|
|
|
[ "$USE_EXTERNAL" = yes ] && \
|
|
|
|
|
_notrun "External device testing in progress, skipped this test"
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# check that a FS is mounted as XFS. if so, return mount point
|
|
|
|
|
#
|
|
|
|
|
_xfs_mounted()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _xfs_mounted device" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
device=$1
|
|
|
|
|
|
|
|
|
|
if mount | grep $device | $AWK_PROG '
|
|
|
|
|
/type xfs/ { print $3 ; exit 0 }
|
|
|
|
|
END { exit 1 }
|
|
|
|
|
'
|
|
|
|
|
then
|
|
|
|
|
echo "_xfs_mounted: $device is not a mounted XFS FS"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-22 06:07:23 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# remount a FS to a new mode (ro or rw)
|
|
|
|
|
#
|
|
|
|
|
_remount()
|
|
|
|
|
{
|
|
|
|
|
if [ $# -ne 2 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Usage: _remount device ro/rw" 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
device=$1
|
|
|
|
|
mode=$2
|
|
|
|
|
|
|
|
|
|
if ! mount -o remount,$mode $device
|
|
|
|
|
then
|
|
|
|
|
echo "_remount: failed to remount filesystem on $device as $mode"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# we might like to check here later
|
|
|
|
|
#options=`_fs_options $device`
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
# run xfs_check and friends on a FS.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# if the filesystem is mounted, it's either remounted ro before being
|
|
|
|
|
# checked or it's unmounted and then remounted
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
USE_REMOUNT=0
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_check_filesystem()
|
2001-01-15 05:01:19 +00:00
|
|
|
{
|
2003-05-22 04:16:45 +00:00
|
|
|
if [ $# -ne 1 -a $# -ne 2 ]
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
2003-05-22 04:16:45 +00:00
|
|
|
echo "Usage: _check_fs device [logdevice]" 1>&2
|
2001-01-15 05:01:19 +00:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
device=$1
|
2003-05-22 04:16:45 +00:00
|
|
|
if [ $# -eq 2 -a "$2" != "" ]; then
|
|
|
|
|
extra_log_options="-l$2"
|
|
|
|
|
extra_mount_options="-ologdev=$2"
|
|
|
|
|
fi
|
2003-08-25 01:18:54 +00:00
|
|
|
|
|
|
|
|
[ "$FSTYP" != xfs ] && return 0
|
2003-08-29 06:04:54 +00:00
|
|
|
testoption=""
|
|
|
|
|
[ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
|
2003-08-25 01:18:54 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
type=`_fs_type $device`
|
|
|
|
|
ok=1
|
|
|
|
|
|
|
|
|
|
if [ "$type" = "xfs" ]
|
|
|
|
|
then
|
|
|
|
|
# mounted...
|
|
|
|
|
|
|
|
|
|
if [ $USE_REMOUNT -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
mountpoint=`_xfs_mounted $device`
|
|
|
|
|
umount $device
|
|
|
|
|
else
|
|
|
|
|
_remount $device ro
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
/usr/sbin/xfs_logprint -t $device $extra_log_options 2>&1 \
|
2002-12-18 01:10:06 +00:00
|
|
|
| tee $tmp.fs_check | grep -q "<CLEAN>"
|
2001-01-15 05:01:19 +00:00
|
|
|
if [ $? -ne 0 ]
|
|
|
|
|
then
|
|
|
|
|
echo "_check_fs: filesystem on $device has dirty log (see $seq.full)"
|
|
|
|
|
|
|
|
|
|
echo "_check_fs: filesystem on $device has dirty log" >>$seq.full
|
|
|
|
|
echo "*** xfs_logprint -t output ***" >>$seq.full
|
|
|
|
|
cat $tmp.fs_check >>$seq.full
|
|
|
|
|
echo "*** end xfs_logprint output" >>$seq.full
|
|
|
|
|
|
|
|
|
|
ok=0
|
|
|
|
|
fi
|
2003-05-22 04:16:45 +00:00
|
|
|
|
2003-08-29 06:04:54 +00:00
|
|
|
/usr/sbin/xfs_check $testoption $device 2>&1 | _fix_malloc >$tmp.fs_check
|
2001-01-15 05:01:19 +00:00
|
|
|
if [ -s $tmp.fs_check ]
|
|
|
|
|
then
|
|
|
|
|
echo "_check_fs: filesystem on $device is inconsistent (c) (see $seq.full)"
|
|
|
|
|
|
|
|
|
|
echo "_check_fs: filesystem on $device is inconsistent" >>$seq.full
|
|
|
|
|
echo "*** xfs_check output ***" >>$seq.full
|
|
|
|
|
cat $tmp.fs_check >>$seq.full
|
|
|
|
|
echo "*** end xfs_check output" >>$seq.full
|
|
|
|
|
|
|
|
|
|
ok=0
|
|
|
|
|
fi
|
2003-09-12 00:38:26 +00:00
|
|
|
|
|
|
|
|
# repair doesn't scale massively at this stage, optionally skip it for now
|
|
|
|
|
[ "$USE_BIG_LOOPFS" = yes ] || \
|
|
|
|
|
/sbin/xfs_repair -n $device $extra_log_options >$tmp.fs_check 2>&1
|
|
|
|
|
if [ $? -ne 0 ]
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
|
|
|
|
echo "_check_fs: filesystem on $device is inconsistent (r) (see $seq.full)"
|
|
|
|
|
|
|
|
|
|
echo "_check_fs: filesystem on $device is inconsistent" >>$seq.full
|
|
|
|
|
echo "*** xfs_repair -n output ***" >>$seq.full
|
|
|
|
|
cat $tmp.fs_check | _fix_malloc >>$seq.full
|
|
|
|
|
echo "*** end xfs_repair output" >>$seq.full
|
|
|
|
|
|
|
|
|
|
ok=0
|
|
|
|
|
fi
|
|
|
|
|
rm -f $tmp.fs_check
|
2003-09-12 00:38:26 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
if [ $ok -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
echo "*** mount output ***" >>$seq.full
|
|
|
|
|
mount >>$seq.full
|
|
|
|
|
echo "*** end mount output" >>$seq.full
|
2003-05-30 04:41:31 +00:00
|
|
|
elif [ "$type" = "xfs" ]
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
|
|
|
|
# mounted...
|
|
|
|
|
if [ $USE_REMOUNT -eq 0 ]
|
|
|
|
|
then
|
2003-05-22 04:16:45 +00:00
|
|
|
if ! mount -t xfs $extra_mount_options $device $mountpoint
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
|
|
|
|
echo "!!! failed to remount $device on $mountpoint"
|
|
|
|
|
ok=0
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
_remount $device rw
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[ $ok -eq 0 ] && exit 1
|
2001-04-04 01:45:38 +00:00
|
|
|
return 0
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
2003-05-22 04:16:45 +00:00
|
|
|
_check_test_fs()
|
|
|
|
|
{
|
2003-05-27 01:04:39 +00:00
|
|
|
TEST_LOG=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
|
|
|
|
|
TEST_LOG="$TEST_LOGDEV"
|
|
|
|
|
_check_filesystem $TEST_DEV $TEST_LOG
|
2003-05-22 04:16:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_check_scratch_fs()
|
|
|
|
|
{
|
|
|
|
|
SCRATCH_LOG=""
|
|
|
|
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
|
|
|
|
SCRATCH_LOG="$SCRATCH_LOGDEV"
|
|
|
|
|
_check_filesystem $SCRATCH_DEV $SCRATCH_LOG
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-02 01:13:25 +00:00
|
|
|
_full_fstyp_details()
|
|
|
|
|
{
|
|
|
|
|
[ -z "$FSTYP" ] && FSTYP=xfs
|
|
|
|
|
if [ $FSTYP = xfs ]; then
|
|
|
|
|
if grep 'debug 0' /proc/fs/xfs/stat >/dev/null; then
|
|
|
|
|
FSTYP="$FSTYP (non-debug)"
|
|
|
|
|
elif grep 'debug 1' /proc/fs/xfs/stat >/dev/null; then
|
|
|
|
|
FSTYP="$FSTYP (debug)"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
echo $FSTYP
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_full_platform_details()
|
|
|
|
|
{
|
|
|
|
|
os=`uname -s`
|
|
|
|
|
host=`hostname -s`
|
|
|
|
|
kernel=`uname -r`
|
|
|
|
|
platform=`uname -m`
|
|
|
|
|
echo "$os/$platform $host $kernel"
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
|
|
|
|
|
[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
|
|
|
|
|
|
2003-08-25 01:18:54 +00:00
|
|
|
if [ "$iam" != new -a "$iam" != bench ]
|
2001-01-15 05:01:19 +00:00
|
|
|
then
|
|
|
|
|
|
|
|
|
|
# make some further configuration checks here
|
|
|
|
|
|
|
|
|
|
if [ "$TEST_DEV" = "" ]
|
|
|
|
|
then
|
|
|
|
|
echo "common.rc: Error: \$TEST_DEV is not set"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2001-09-19 22:08:37 +00:00
|
|
|
# if $TEST_DEV is not mounted, mount it now as XFS
|
|
|
|
|
if [ -z "`_fs_type $TEST_DEV`" ]
|
|
|
|
|
then
|
|
|
|
|
# $TEST_DEV is not mounted
|
2003-05-22 04:16:45 +00:00
|
|
|
if ! _test_mount
|
2001-09-19 22:08:37 +00:00
|
|
|
then
|
2003-07-17 04:09:59 +00:00
|
|
|
echo "common.rc: retrying test device mount with external set"
|
2003-07-17 23:06:11 +00:00
|
|
|
[ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
|
2003-07-17 04:09:59 +00:00
|
|
|
if ! _test_mount
|
|
|
|
|
then
|
|
|
|
|
echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2001-09-19 22:08:37 +00:00
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
if [ "`_fs_type $TEST_DEV`" != "xfs" ]
|
|
|
|
|
then
|
|
|
|
|
echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED XFS filesystem"
|
|
|
|
|
df -T $TEST_DEV
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
2002-01-20 00:47:43 +00:00
|
|
|
# check for some required binaries on our $PATH
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
for exec in mkfs.xfs xfs_logprint xfs_check xfs_repair xfs_db
|
|
|
|
|
do
|
|
|
|
|
if which $exec >/dev/null 2>&1
|
|
|
|
|
then
|
|
|
|
|
:
|
|
|
|
|
else
|
|
|
|
|
echo "common.rc: cannot find $exec on \$PATH=$PATH"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# make sure this script returns success
|
|
|
|
|
/bin/true
|