4 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of version 2 of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # Further, this software is distributed without any warranty that it is
15 # free of the rightful claim of any third person regarding infringement
16 # or the like. Any license provided herein, whether implied or
17 # otherwise, applies only to this software file. Patent licenses, if
18 # any, provided herein do not apply to combinations of this program with
19 # other software, or any other product whatsoever.
21 # You should have received a copy of the GNU General Public License along
22 # with this program; if not, write the Free Software Foundation, Inc., 59
23 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
26 # Mountain View, CA 94043, or:
30 # For further information regarding this notice, see:
32 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 # we need common.config
36 if ! . ./common.config
38 echo "$iam: failed to source common.config"
52 # extra parameters for fsstress
53 FSSTRESS_AVOID="-f resvsp=0 -f unresvsp=0"
55 export AWK_PROG PS_HAVE_BSD PS_ALL_FLAGS PLATFORM
57 # we override mount so we can specify mount options
70 /bin/mount $* $MOUNT_OPTIONS
84 echo "Usage: _get_pids_by_name process-name" 1>&2
88 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
89 # HH:MM:SS before the psargs field, use this as the search anchor.
91 # Matches with $1 (process-name) occur if the first psarg is $1
92 # or ends in /$1 ... the matching uses sed's regular expressions,
93 # so passing a regex into $1 will work.
101 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
102 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
110 nslookup $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
113 # fix malloc libs output
117 # filter out the Electric Fence notice
120 if (defined $o && /^\s+Electric Fence/) {
126 print $o if (defined $o);
130 print $o if (defined $o);
134 # check if run as root
138 id=`id | sed -e 's/(.*//' -e 's/.*=//'`
141 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
148 # _df_device : get an IRIX style df line for a given device
150 # - returns "" if not mounted
151 # - returns fs type in field two (ala IRIX)
152 # - joins line together if split by fancy df formatting
153 # - strips header etc
160 echo "Usage: _df_device device" 1>&2
164 df -T 2>/dev/null | $AWK_PROG -v what=$1 '
165 match($1,what) && NF==1 {
179 # _df_dir : get an IRIX style df line for device where a directory resides
181 # - returns fs type in field two (ala IRIX)
182 # - joins line together if split by fancy df formatting
183 # - strips header etc
190 echo "Usage: _df_dir device" 1>&2
194 df -T $1 2>/dev/null | $AWK_PROG -v what=$1 '
210 # return percentage used disk space for mounted device
216 echo "Usage: _used device" 1>&2
220 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
223 # return the FS type of a mounted device
229 echo "Usage: _fs_type device" 1>&2
233 _df_device $1 | $AWK_PROG '{ print $2 }'
236 # return the FS mount options of a mounted device
242 echo "Usage: _fs_options device" 1>&2
246 $AWK_PROG -v dev=$1 '
247 match($1,dev) { print $4 }
252 # returns device number if a file is a block device
258 echo "Usage: _is_block_dev dev" 1>&2
262 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
265 # bail out, setting up .notrun file
269 echo "$*" >$seq.notrun
270 echo "$seq not run: $*"
275 # just plain bail out
279 echo "$*" | tee -a $seq.full
280 echo "(see $seq.full for details)"
285 # this test needs a scratch partition - check we're ok & unmount it
290 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
292 _notrun "this test requires a valid \$SCRATCH_DEV"
295 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
297 _notrun "this test requires a valid \$SCRATCH_DEV"
301 if mount | grep -q $SCRATCH_DEV
303 # if it's mounted, make sure its on $SCRATCH_MNT
304 if ! mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
306 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
310 # and then unmount it
312 if ! umount $SCRATCH_DEV
314 echo "failed to unmount $SCRATCH_DEV"
323 # this test needs a logdev
327 if [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ]
329 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
333 # this test requires loopback device support
337 if grep loop /proc/devices >/dev/null 2>&1
341 _notrun "This test requires loopback device support"
346 # check that a FS is mounted as XFS. if so, return mount point
352 echo "Usage: _xfs_mounted device" 1>&2
358 if mount | grep $device | $AWK_PROG '
359 /type xfs/ { print $3 ; exit 0 }
363 echo "_xfs_mounted: $device is not a mounted XFS FS"
368 # remount a FS to a new mode (ro or rw)
375 echo "Usage: _remount device ro/rw" 1>&2
381 if ! mount -o remount,$mode $device
383 echo "_remount: failed to remount filesystem on $device as $mode"
387 # we might like to check here later
388 #options=`_fs_options $device`
392 # run xfs_check on a FS.
394 # if the filesystem is mounted, it's either remounted ro before being
395 # checked or it's unmounted and then remounted
404 echo "Usage: _check_fs device" 1>&2
409 type=`_fs_type $device`
412 if [ "$type" = "xfs" ]
416 if [ $USE_REMOUNT -eq 0 ]
418 mountpoint=`_xfs_mounted $device`
425 xfs_logprint -t $device 2>&1 | tee $tmp.fs_check | grep -q "<CLEAN>"
428 echo "_check_fs: filesystem on $device has dirty log (see $seq.full)"
430 echo "_check_fs: filesystem on $device has dirty log" >>$seq.full
431 echo "*** xfs_logprint -t output ***" >>$seq.full
432 cat $tmp.fs_check >>$seq.full
433 echo "*** end xfs_logprint output" >>$seq.full
439 xfs_check $device 2>&1 | _fix_malloc >$tmp.fs_check
440 if [ -s $tmp.fs_check ]
442 echo "_check_fs: filesystem on $device is inconsistent (c) (see $seq.full)"
444 echo "_check_fs: filesystem on $device is inconsistent" >>$seq.full
445 echo "*** xfs_check output ***" >>$seq.full
446 cat $tmp.fs_check >>$seq.full
447 echo "*** end xfs_check output" >>$seq.full
452 if ! xfs_repair -n $device >$tmp.fs_check 2>&1
454 echo "_check_fs: filesystem on $device is inconsistent (r) (see $seq.full)"
456 echo "_check_fs: filesystem on $device is inconsistent" >>$seq.full
457 echo "*** xfs_repair -n output ***" >>$seq.full
458 cat $tmp.fs_check | _fix_malloc >>$seq.full
459 echo "*** end xfs_repair output" >>$seq.full
467 echo "*** mount output ***" >>$seq.full
469 echo "*** end mount output" >>$seq.full
472 if [ "$type" = "xfs" ]
475 if [ $USE_REMOUNT -eq 0 ]
477 if ! mount -t xfs $device $mountpoint
479 echo "!!! failed to remount $device on $mountpoint"
487 [ $ok -eq 0 ] && exit 1
491 ################################################################################
493 [ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
494 [ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
499 # make some further configuration checks here
501 if [ "$TEST_DEV" = "" ]
503 echo "common.rc: Error: \$TEST_DEV is not set"
507 if [ "`_fs_type $TEST_DEV`" != "xfs" ]
509 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED XFS filesystem"
516 # check for some required biunaries on our $PATH
518 for exec in mkfs.xfs xfs_logprint xfs_check xfs_repair xfs_db
520 if which $exec >/dev/null 2>&1
524 echo "common.rc: cannot find $exec on \$PATH=$PATH"
529 # make sure this script returns success