2 #-----------------------------------------------------------------------
3 # Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 # Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
20 # Mountain View, CA 94043, USA, or: http://www.sgi.com
21 #-----------------------------------------------------------------------
25 if [ "$HOSTOS" == "Linux" ]
27 command dd --help | grep noxfer > /dev/null 2>&1
31 command dd status=noxfer $@
44 export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
47 export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
50 export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
61 export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
64 [ ! -z "$udf_fsize" ] && \
65 UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
66 export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
69 export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
76 [ -z "$FSTYP" ] && FSTYP=xfs
77 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
78 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
81 # we need common.config
82 if [ "$iam" != "check" ]
84 if ! . ./common.config
86 echo "$iam: failed to source common.config"
91 # make sure we have a standard umask
96 $MOUNT_PROG `_mount_ops_filter $*`
104 if [ "$FSTYP" != "xfs" ]; then
110 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
119 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
120 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
121 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
122 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
130 if [ "$FSTYP" != "xfs" ]; then
144 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
145 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
146 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
147 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
154 #get mount point to handle dmapi mtpt option correctly
156 [ $last_index -gt 0 ] && shift $last_index
159 # irix is fussy about how it is fed its mount options
160 # - multiple -o's are not allowed
161 # - no spaces between comma delimitered options
162 # the sed script replaces all -o's (except the first) with a comma
163 # not required for linux, but won't hurt
165 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
166 | sed -e 's/dmapi/dmi/' \
167 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
171 _scratch_mount_options()
173 _scratch_options mount
175 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
180 _mount -t $FSTYP `_scratch_mount_options $*`
186 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $* $TEST_DEV $TEST_DIR
189 _scratch_mkfs_options()
191 _scratch_options mkfs
192 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
197 # extra mkfs options can be added by tests
198 local extra_mkfs_options=$*
202 _scratch_options mkfs
204 # save mkfs output in case conflict means we need to run again.
205 # only the output for the mkfs that applies should be shown
206 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
207 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
210 # a mkfs failure may be caused by conflicts between
211 # $MKFS_OPTIONS and $extra_mkfs_options
213 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
214 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
216 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
218 # running mkfs again. overwrite previous mkfs output files
219 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
220 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
224 # output stored mkfs output
225 cat $tmp_dir.mkfserr >&2
227 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
229 if [ "$USE_BIG_LOOPFS" = yes ]; then
230 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
231 ./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
247 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
250 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
255 _scratch_xfs_db_options()
258 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
259 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
260 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
263 _scratch_xfs_logprint()
266 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
267 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
268 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
274 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
275 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
276 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
279 _scratch_xfs_repair()
282 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
283 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
284 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
285 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
286 [ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
287 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
294 echo "Usage: _get_pids_by_name process-name" 1>&2
298 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
299 # HH:MM:SS before the psargs field, use this as the search anchor.
301 # Matches with $1 (process-name) occur if the first psarg is $1
302 # or ends in /$1 ... the matching uses sed's regular expressions,
303 # so passing a regex into $1 will work.
311 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
312 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
320 $NSLOOKUP_PROG $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
323 # fix malloc libs output
327 # filter out the Electric Fence notice
330 if (defined $o && /^\s+Electric Fence/) {
336 print $o if (defined $o);
340 print $o if (defined $o);
344 # check if run as root
348 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
351 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
358 # _df_device : get an IRIX style df line for a given device
360 # - returns "" if not mounted
361 # - returns fs type in field two (ala IRIX)
362 # - joins line together if split by fancy df formatting
363 # - strips header etc
370 echo "Usage: _df_device device" 1>&2
374 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
375 match($1,what) && NF==1 {
389 # _df_dir : get an IRIX style df line for device where a directory resides
391 # - returns fs type in field two (ala IRIX)
392 # - joins line together if split by fancy df formatting
393 # - strips header etc
400 echo "Usage: _df_dir device" 1>&2
404 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
420 # return percentage used disk space for mounted device
426 echo "Usage: _used device" 1>&2
430 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
433 # return the FS type of a mounted device
439 echo "Usage: _fs_type device" 1>&2
443 _df_device $1 | $AWK_PROG '{ print $2 }'
446 # return the FS mount options of a mounted device
448 # should write a version which just parses the output of mount for IRIX
449 # compatibility, but since this isn't used at all, at the moment I'll leave
456 echo "Usage: _fs_options device" 1>&2
460 $AWK_PROG -v dev=$1 '
461 match($1,dev) { print $4 }
465 # returns device number if a file is a block device
471 echo "Usage: _is_block_dev dev" 1>&2
475 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
478 # Do a command, log it to $seq.full, optionally test return status
479 # and die if command fails. If called with one argument _do executes the
480 # command, logs it, and returns its exit status. With two arguments _do
481 # first prints the message passed in the first argument, and then "done"
482 # or "fail" depending on the return status of the command passed in the
483 # second argument. If the command fails and the variable _do_die_on_error
484 # is set to "always" or the two argument form is used and _do_die_on_error
485 # is set to "message_only" _do will print an error message to
490 if [ $# -eq 1 ]; then
492 elif [ $# -eq 2 ]; then
497 echo "Usage: _do [note] cmd" 1>&2
501 (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
502 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
503 cat $tmp._out | _fix_malloc >>$here/$seq.full
504 if [ $# -eq 2 ]; then
505 if [ $ret -eq 0 ]; then
512 && [ "$_do_die_on_error" = "always" \
513 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
516 eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
523 # bail out, setting up .notrun file
527 echo "$*" >$seq.notrun
528 echo "$seq not run: $*"
533 # just plain bail out
537 echo "$*" | tee -a $here/$seq.full
538 echo "(see $seq.full for details)"
543 # tests whether $FSTYP is one of the supported filesystems for a test
549 if [ "$f" = "$FSTYP" ]
555 _notrun "not suitable for this filesystem type: $FSTYP"
558 # tests whether $FSTYP is one of the supported OSes for a test
564 if [ "$h" = "$HOSTOS" ]
570 _notrun "not suitable for this OS: $HOSTOS"
573 # this test needs a scratch partition - check we're ok & unmount it
579 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
581 _notrun "this test requires a valid \$SCRATCH_DEV"
583 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
585 _notrun "this test requires a valid \$SCRATCH_DEV"
588 nfs*|ext2|ext3|reiserfs)
589 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
590 if [ ! -z "$SCRATCH_DEV" -a ! -b "$SCRATCH_DEV" -a "$?" != "0" ]
592 _notrun "this test requires a valid \$SCRATCH_DEV"
596 _notrun "\$FSTYP ($FSTYP) unknown or not specified"
601 if _mount | grep -q $SCRATCH_DEV
603 # if it's mounted, make sure its on $SCRATCH_MNT
604 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
606 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
609 # and then unmount it
610 if ! $UMOUNT_PROG $SCRATCH_DEV
612 echo "failed to unmount $SCRATCH_DEV"
618 # this test needs a logdev
622 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
623 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
624 [ "$USE_EXTERNAL" != yes ] && \
625 _notrun "This test requires USE_EXTERNAL to be enabled"
627 # ensure its not mounted
628 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
631 # this test requires loopback device support
635 if [ "$HOSTOS" != "Linux" ]
637 _notrun "This test requires linux for loopback device support"
640 modprobe loop >/dev/null 2>&1
641 if grep loop /proc/devices >/dev/null 2>&1
645 _notrun "This test requires loopback device support"
649 # this test requires that (large) loopback device files are not in use
651 _require_nobigloopfs()
653 [ "$USE_BIG_LOOPFS" = yes ] && \
654 _notrun "Large filesystem testing in progress, skipped this test"
657 # this test requires that a realtime subvolume is in use, and
658 # that the kernel supports realtime as well.
662 [ "$USE_EXTERNAL" = yes ] || \
663 _notrun "External volumes not in use, skipped this test"
664 [ "$SCRATCH_RTDEV" = "" ] && \
665 _notrun "Realtime device required, skipped this test"
668 # this test requires that a specified command (executable) exists
672 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
675 # this test requires that external log/realtime devices are not in use
677 _require_nonexternal()
679 [ "$USE_EXTERNAL" = yes ] && \
680 _notrun "External device testing in progress, skipped this test"
683 # check for the fsgqa user on the machine
688 cat /etc/passwd | grep -q $qa_user
689 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
692 # check that a FS is mounted as XFS. if so, return mount point
698 echo "Usage: _xfs_mounted device" 1>&2
704 if _mount | grep "$device " | $AWK_PROG '
705 /type xfs/ { print $3 ; exit 0 }
709 echo "_xfs_mounted: $device is not a mounted XFS FS"
715 # remount a FS to a new mode (ro or rw)
721 echo "Usage: _remount device ro/rw" 1>&2
727 if ! mount -o remount,$mode $device
729 echo "_remount: failed to remount filesystem on $device as $mode"
734 # run xfs_check and friends on a FS.
736 # if the filesystem is mounted, it's either remounted ro before being
737 # checked or it's unmounted and then remounted
742 _check_xfs_filesystem()
746 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
750 extra_mount_options=""
752 if [ "$2" != "none" ]; then
753 extra_log_options="-l$2"
754 extra_mount_options="-ologdev=$2"
757 if [ "$3" != "none" ]; then
758 extra_rt_options="-r$3"
759 extra_mount_options=$extra_mount_options" -ortdev=$3"
761 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
763 [ "$FSTYP" != xfs ] && return 0
765 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
767 type=`_fs_type $device`
770 if [ "$type" = "xfs" ]
774 if [ $USE_REMOUNT -eq 0 ]
776 mountpoint=`_xfs_mounted $device`
783 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
784 | tee $tmp.logprint | grep -q "<CLEAN>"
785 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
787 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
789 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
790 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
791 cat $tmp.logprint >>$here/$seq.full
792 echo "*** end xfs_logprint output" >>$here/$seq.full
797 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
798 _fix_malloc >$tmp.fs_check
799 if [ -s $tmp.fs_check ]
801 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
803 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
804 echo "*** xfs_check output ***" >>$here/$seq.full
805 cat $tmp.fs_check >>$here/$seq.full
806 echo "*** end xfs_check output" >>$here/$seq.full
810 # repair doesn't scale massively at this stage, optionally skip it for now
811 [ "$USE_BIG_LOOPFS" = yes ] || \
812 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
815 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
817 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
818 echo "*** xfs_repair -n output ***" >>$here/$seq.full
819 cat $tmp.repair | _fix_malloc >>$here/$seq.full
820 echo "*** end xfs_repair output" >>$here/$seq.full
824 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
828 echo "*** mount output ***" >>$here/$seq.full
829 _mount >>$here/$seq.full
830 echo "*** end mount output" >>$here/$seq.full
831 elif [ "$type" = "xfs" ]
834 if [ $USE_REMOUNT -eq 0 ]
836 if ! _mount -t xfs $extra_mount_options $device $mountpoint
838 echo "!!! failed to remount $device on $mountpoint"
846 [ $ok -eq 0 ] && exit 1
850 # Filter the knowen errors the UDF Verifier reports.
851 _udf_test_known_error_filter()
853 egrep -v "PVD 60 Error: Interchange Level: 1, Maximum Interchange Level: 0|FSD 28 Error: Interchange Level: 1, Maximum Interchange Level: 1,|PVD 72 Warning: Volume Set Identifier: \"\*IRIX UDF\",|Warning: [0-9]+ unused blocks NOT marked as unallocated."
857 _check_udf_filesystem()
859 [ "$DISABLE_UDF_TEST" == "1" ] && return
861 if [ $# -ne 1 -a $# -ne 2 ]
863 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
867 if [ ! -x $here/src/udf_test ]
869 echo "udf_test not installed, please download and build the Philips"
870 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
871 echo "Then copy the udf_test binary to $here/src/."
872 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
880 LAST_BLOCK=`expr \( $2 - 1 \)`
881 OPT_ARG="-lastvalidblock $LAST_BLOCK"
885 sleep 1 # Due to a problem with time stamps in udf_test
886 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
887 _udf_test_known_error_filter | \
888 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
889 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
895 if [ "$FSTYP" != "xfs" ]; then
901 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
902 TEST_LOG="$TEST_LOGDEV"
904 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
905 TEST_RT="$TEST_RTDEV"
907 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
909 # check for ipath consistency
910 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
911 # errors go to stderr
912 xfs_check_ipaths $TEST_DIR >/dev/null
913 xfs_repair_ipaths -n $TEST_DIR >/dev/null
923 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
924 SCRATCH_LOG="$SCRATCH_LOGDEV"
926 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
927 SCRATCH_RT="$SCRATCH_RTDEV"
929 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
932 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
935 # Don't know how to check an NFS filesystem, yet.
942 _full_fstyp_details()
944 [ -z "$FSTYP" ] && FSTYP=xfs
945 if [ $FSTYP = xfs ]; then
946 if [ -d /proc/fs/xfs ]; then
947 if grep -q 'debug 0' /proc/fs/xfs/stat; then
948 FSTYP="$FSTYP (non-debug)"
949 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
950 FSTYP="$FSTYP (debug)"
953 if uname -a | grep -qi 'debug'; then
954 FSTYP="$FSTYP (debug)"
956 FSTYP="$FSTYP (non-debug)"
963 _full_platform_details()
969 echo "$os/$platform $host $kernel"
984 # Don't know how to check an NFS filesystem, yet.
994 [ "$FSTYP" != "xfs" ] \
995 && _fail "setup_xfs_testdir: \$FSTYP ($FSTYP) is not xfs"
1000 _setup_udf_scratchdir()
1002 [ "$FSTYP" != "udf" ] \
1003 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1004 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1005 && _notrun "this test requires a valid \$SCRATCH_DEV"
1006 [ -z "$SCRATCH_MNT" ] \
1007 && _notrun "this test requires a valid \$SCRATCH_MNT"
1010 if _mount | grep -q $SCRATCH_DEV
1012 # if it's mounted, make sure its on $TEST_RW_DIR
1013 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1015 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1017 $UMOUNT_PROG $SCRATCH_DEV
1023 testdir=$SCRATCH_MNT
1026 _setup_nfs_scratchdir()
1028 [ "$FSTYP" != "nfs" ] \
1029 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1030 [ -z "$SCRATCH_DEV" ] \
1031 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1032 [ -z "$SCRATCH_MNT" ] \
1033 && _notrun "this test requires a valid \$SCRATCH_MNT"
1036 if _mount | grep -q $SCRATCH_DEV
1038 # if it's mounted, make sure its on $SCRATCH_MNT
1039 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1041 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1043 $UMOUNT_PROG $SCRATCH_DEV
1049 testdir=$SCRATCH_MNT
1053 # Warning for UDF and NFS this function calls _setup_udf_scratchdir and
1054 # _setup_udf_scratchdir. This is done because testdir is a persistent
1055 # XFS only partition.
1064 _setup_udf_scratchdir
1067 _setup_nfs_scratchdir
1070 _fail "\$FSTYP is not xfs, udf or nfs"
1079 # do nothing, testdir is $TEST_DIR
1083 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1084 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1087 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1088 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1091 _fail "\$FSTYP is not xfs, udf or nfs"
1098 if [ -z "$1" ]; then
1099 echo Error must pass \$seq.
1103 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1105 elif [ "`uname`" == "Linux" ]; then
1108 echo Error test $seq does not run on the operating system: `uname`
1126 if [ $size -gt 0 ]; then
1127 dd if=/dev/zero of=$file bs=1024 count=$size
1133 # takes dirname, depth
1136 dirname=$1; depth=$2
1137 mkdir $dirname || die "mkdir $dirname failed"
1140 _nfiles $files # files for this dir
1142 [ $depth -eq 0 ] && return
1143 let deep=$depth-1 # go 1 down
1145 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1148 while [ $d -lt $dirs ]
1150 _descend d$d $deep &
1156 # Populate a filesystem with inodes for performance experiments
1158 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1163 dirs=5 # ndirs in each subdir till leaves
1164 size=0 # sizeof files in K
1165 files=100 # num files in _each_ subdir
1166 depth=2 # depth of tree from root to leaves
1168 root=root # path of initial root of directory tree
1170 while getopts "d:f:n:r:s:v" c
1182 _descend $root $depth
1187 [ $verbose = true ] && echo done
1190 # query whether the given file has the given inode flag set
1197 if which $XFS_IO_PROG >/dev/null; then
1198 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1205 # query the given files extsize allocator hint in bytes (if any)
1212 if which $XFS_IO_PROG >/dev/null; then
1213 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1214 awk '/^xattr.extsize =/ { print $3 }'`
1216 [ -z "$blocks" ] && blocks="0"
1221 ################################################################################
1223 if [ "$iam" != new -a "$iam" != bench ]
1225 # make some further configuration checks here
1227 if [ "$TEST_DEV" = "" ]
1229 echo "common.rc: Error: \$TEST_DEV is not set"
1233 # if $TEST_DEV is not mounted, mount it now as XFS
1234 if [ -z "`_fs_type $TEST_DEV`" ]
1236 # $TEST_DEV is not mounted
1239 echo "common.rc: retrying test device mount with external set"
1240 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1243 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1249 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1251 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1257 # make sure this script returns success