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 $@
40 # ls -l w/ selinux sometimes puts a dot at the end:
41 # -rwxrw-r--. id1 id2 file1
45 ls -l $* | sed "s/\(^[-rwxdlbcpsStT]*\)\. /\1 /"
52 export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
55 export MOUNT_OPTIONS=$UDF_MOUNT_OPTIONS
58 export MOUNT_OPTIONS=$NFS_MOUNT_OPTIONS
61 # acls & xattrs aren't turned on by default on ext$FOO
62 export MOUNT_OPTIONS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
65 # acls & xattrs aren't turned on by default on reiserfs
66 export MOUNT_OPTIONS="-o acl,user_xattr $REISERFS_MOUNT_OPTIONS"
69 # acls aren't turned on by default on gfs2
70 export MOUNT_OPTIONS="-o acl $GFS2_MOUNT_OPTIONS"
81 export MKFS_OPTIONS=$XFS_MKFS_OPTIONS
84 [ ! -z "$udf_fsize" ] && \
85 UDF_MKFS_OPTIONS="$UDF_MKFS_OPTIONS -s $udf_fsize"
86 export MKFS_OPTIONS=$UDF_MKFS_OPTIONS
89 export MKFS_OPTIONS=$NFS_MKFS_OPTIONS
92 export MKFS_OPTIONS="$REISERFS_MKFS_OPTIONS -q"
95 export MKFS_OPTIONS="$GFS2_MKFS_OPTIONS -O -p lock_nolock"
106 export FSCK_OPTIONS="-nf"
109 export FSCK_OPTIONS="--yes"
112 export FSCK_OPTIONS="-n"
117 [ -z "$FSTYP" ] && FSTYP=xfs
118 [ -z "$MOUNT_OPTIONS" ] && _mount_opts
119 [ -z "$MKFS_OPTIONS" ] && _mkfs_opts
120 [ -z "$FSCK_OPTIONS" ] && _fsck_opts
123 # we need common.config
124 if [ "$iam" != "check" ]
126 if ! . ./common.config
128 echo "$iam: failed to source common.config"
133 # make sure we have a standard umask
138 $MOUNT_PROG `_mount_ops_filter $*`
146 if [ "$FSTYP" != "xfs" ]; then
152 [ "$HOSTOS" != "IRIX" ] && SCRATCH_OPTIONS="$SCRATCH_OPTIONS -f"
161 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
162 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${rt_opt}rtdev=$SCRATCH_RTDEV"
163 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
164 SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}logdev=$SCRATCH_LOGDEV"
172 if [ "$FSTYP" != "xfs" ]; then
186 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
187 TEST_OPTIONS="$TEST_OPTIONS ${rt_opt}rtdev=$TEST_RTDEV"
188 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
189 TEST_OPTIONS="$TEST_OPTIONS ${log_opt}logdev=$TEST_LOGDEV"
196 #get mount point to handle dmapi mtpt option correctly
198 [ $last_index -gt 0 ] && shift $last_index
201 # irix is fussy about how it is fed its mount options
202 # - multiple -o's are not allowed
203 # - no spaces between comma delimitered options
204 # the sed script replaces all -o's (except the first) with a comma
205 # not required for linux, but won't hurt
207 echo $params | sed -e 's/[[:space:]]*-o[[:space:]]*/UnIqUe/1; s/[[:space:]]*-o[[:space:]]*/,/g; s/UnIqUe/ -o /1' \
208 | sed -e 's/dmapi/dmi/' \
209 | $PERL_PROG -ne "s#mtpt=[^,|^\n|^\s]*#mtpt=$FS_ESCAPED\1\2#; print;"
213 _scratch_mount_options()
215 _scratch_options mount
217 echo $SCRATCH_OPTIONS $MOUNT_OPTIONS $* $SCRATCH_DEV $SCRATCH_MNT
222 _mount -t $FSTYP `_scratch_mount_options $*`
227 $UMOUNT_PROG $SCRATCH_DEV
239 _mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $* $TEST_DEV $TEST_DIR
242 _scratch_mkfs_options()
244 _scratch_options mkfs
245 echo $SCRATCH_OPTIONS $MKFS_OPTIONS $* $SCRATCH_DEV
250 # extra mkfs options can be added by tests
251 local extra_mkfs_options=$*
255 _scratch_options mkfs
257 # save mkfs output in case conflict means we need to run again.
258 # only the output for the mkfs that applies should be shown
259 $MKFS_XFS_PROG $SCRATCH_OPTIONS $MKFS_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
260 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
263 # a mkfs failure may be caused by conflicts between
264 # $MKFS_OPTIONS and $extra_mkfs_options
266 if [ $mkfs_status -ne 0 -a ! -z "$extra_mkfs_options" ]; then
267 echo "** mkfs failed with extra mkfs options added to \"$MKFS_OPTIONS\" by test $seq **" \
269 echo "** attempting to mkfs using only test $seq options: $extra_mkfs_options **" \
271 # running mkfs again. overwrite previous mkfs output files
272 $MKFS_XFS_PROG $SCRATCH_OPTIONS $extra_mkfs_options $SCRATCH_DEV \
273 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
277 # output stored mkfs output
278 cat $tmp_dir.mkfserr >&2
280 rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
282 if [ "$USE_BIG_LOOPFS" = yes ]; then
283 [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
284 ./tools/ag-wipe -q -r $RETAIN_AG_BYTES $SCRATCH_DEV
300 $MKFS_UDF_PROG $MKFS_OPTIONS $* $SCRATCH_DEV > /dev/null
303 /sbin/mkfs -t $FSTYP -- $MKFS_OPTIONS $* $SCRATCH_DEV
308 # Emulate an N-data-disk stripe w/ various stripe units
309 # _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
315 [ -z "$blocksize" ] && blocksize=4096
317 let sunit_blocks=$sunit_bytes/$blocksize
318 let swidth_blocks=$sunit_blocks*$swidth_mult
322 MKFS_OPTIONS="-b size=$blocksize, -d su=$sunit_bytes,sw=$swidth_mult"
325 MKFS_OPTIONS="-b $blocksize -E stride=$sunit_blocks,stripe_width=$swidth_blocks"
328 _notrun "can't mkfs $FSTYP with geometry"
334 _scratch_xfs_db_options()
337 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
338 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
339 echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
342 _scratch_xfs_logprint()
345 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
346 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
347 $XFS_LOGPRINT_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
353 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
354 SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
355 $XFS_CHECK_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
358 _scratch_xfs_repair()
361 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
362 SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
363 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
364 SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
365 [ "$USE_BIG_LOOPFS" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
366 $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
373 echo "Usage: _get_pids_by_name process-name" 1>&2
377 # Algorithm ... all ps(1) variants have a time of the form MM:SS or
378 # HH:MM:SS before the psargs field, use this as the search anchor.
380 # Matches with $1 (process-name) occur if the first psarg is $1
381 # or ends in /$1 ... the matching uses sed's regular expressions,
382 # so passing a regex into $1 will work.
390 -e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
391 -e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
394 # fix malloc libs output
398 # filter out the Electric Fence notice
401 if (defined $o && /^\s+Electric Fence/) {
407 print $o if (defined $o);
411 print $o if (defined $o);
415 # check if run as root
419 id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
422 echo "Arrgh ... you need to be root (not uid=$id) to run this test"
429 # _df_device : get an IRIX style df line for a given device
431 # - returns "" if not mounted
432 # - returns fs type in field two (ala IRIX)
433 # - joins line together if split by fancy df formatting
434 # - strips header etc
441 echo "Usage: _df_device device" 1>&2
445 $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
446 match($1,what) && NF==1 {
460 # _df_dir : get an IRIX style df line for device where a directory resides
462 # - returns fs type in field two (ala IRIX)
463 # - joins line together if split by fancy df formatting
464 # - strips header etc
471 echo "Usage: _df_dir device" 1>&2
475 $DF_PROG $1 2>/dev/null | $AWK_PROG -v what=$1 '
491 # return percentage used disk space for mounted device
497 echo "Usage: _used device" 1>&2
501 _df_device $1 | $AWK_PROG '{ sub("%", "") ; print $6 }'
504 # return the FS type of a mounted device
510 echo "Usage: _fs_type device" 1>&2
514 _df_device $1 | $AWK_PROG '{ print $2 }'
517 # return the FS mount options of a mounted device
519 # should write a version which just parses the output of mount for IRIX
520 # compatibility, but since this isn't used at all, at the moment I'll leave
527 echo "Usage: _fs_options device" 1>&2
531 $AWK_PROG -v dev=$1 '
532 match($1,dev) { print $4 }
536 # returns device number if a file is a block device
542 echo "Usage: _is_block_dev dev" 1>&2
546 [ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
549 # Do a command, log it to $seq.full, optionally test return status
550 # and die if command fails. If called with one argument _do executes the
551 # command, logs it, and returns its exit status. With two arguments _do
552 # first prints the message passed in the first argument, and then "done"
553 # or "fail" depending on the return status of the command passed in the
554 # second argument. If the command fails and the variable _do_die_on_error
555 # is set to "always" or the two argument form is used and _do_die_on_error
556 # is set to "message_only" _do will print an error message to
561 if [ $# -eq 1 ]; then
563 elif [ $# -eq 2 ]; then
568 echo "Usage: _do [note] cmd" 1>&2
572 (eval "echo '---' \"$_cmd\"") >>$here/$seq.full
573 (eval "$_cmd") >$tmp._out 2>&1; ret=$?
574 cat $tmp._out | _fix_malloc >>$here/$seq.full
575 if [ $# -eq 2 ]; then
576 if [ $ret -eq 0 ]; then
583 && [ "$_do_die_on_error" = "always" \
584 -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
587 eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
594 # bail out, setting up .notrun file
598 echo "$*" >$seq.notrun
599 echo "$seq not run: $*"
604 # just plain bail out
608 echo "$*" | tee -a $here/$seq.full
609 echo "(see $seq.full for details)"
614 # tests whether $FSTYP is one of the supported filesystems for a test
620 if [ "$f" = "$FSTYP" -o "$f" = "generic" ]
626 _notrun "not suitable for this filesystem type: $FSTYP"
629 # tests whether $FSTYP is one of the supported OSes for a test
635 if [ "$h" = "$HOSTOS" ]
641 _notrun "not suitable for this OS: $HOSTOS"
644 # this test needs a scratch partition - check we're ok & unmount it
650 echo $SCRATCH_DEV | grep -q ":" > /dev/null 2>&1
651 if [ -z "$SCRATCH_DEV" -o "$?" != "0" ]
653 _notrun "this test requires a valid \$SCRATCH_DEV"
657 if [ -z "$SCRATCH_DEV" -o "`_is_block_dev $SCRATCH_DEV`" = "" ]
659 _notrun "this test requires a valid \$SCRATCH_DEV"
661 if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
663 _notrun "this test requires a valid \$SCRATCH_DEV"
669 if _mount | grep -q $SCRATCH_DEV
671 # if it's mounted, make sure its on $SCRATCH_MNT
672 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
674 echo "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
677 # and then unmount it
678 if ! $UMOUNT_PROG $SCRATCH_DEV
680 echo "failed to unmount $SCRATCH_DEV"
686 # this test needs a logdev
690 [ -z "$SCRATCH_LOGDEV" -o ! -b "$SCRATCH_LOGDEV" ] && \
691 _notrun "This test requires a valid \$SCRATCH_LOGDEV"
692 [ "$USE_EXTERNAL" != yes ] && \
693 _notrun "This test requires USE_EXTERNAL to be enabled"
695 # ensure its not mounted
696 $UMOUNT_PROG $SCRATCH_LOGDEV 2>/dev/null
699 # this test requires loopback device support
703 if [ "$HOSTOS" != "Linux" ]
705 _notrun "This test requires linux for loopback device support"
708 modprobe loop >/dev/null 2>&1
709 if grep loop /proc/devices >/dev/null 2>&1
713 _notrun "This test requires loopback device support"
717 # this test requires that (large) loopback device files are not in use
719 _require_nobigloopfs()
721 [ "$USE_BIG_LOOPFS" = yes ] && \
722 _notrun "Large filesystem testing in progress, skipped this test"
725 # this test requires that a realtime subvolume is in use, and
726 # that the kernel supports realtime as well.
730 [ "$USE_EXTERNAL" = yes ] || \
731 _notrun "External volumes not in use, skipped this test"
732 [ "$SCRATCH_RTDEV" = "" ] && \
733 _notrun "Realtime device required, skipped this test"
736 # this test requires that a specified command (executable) exists
740 [ -x "$1" ] || _notrun "$1 utility required, skipped this test"
743 # this test requires that external log/realtime devices are not in use
745 _require_nonexternal()
747 [ "$USE_EXTERNAL" = yes ] && \
748 _notrun "External device testing in progress, skipped this test"
751 # check for the fsgqa user on the machine
756 cat /etc/passwd | grep -q $qa_user
757 [ "$?" == "0" ] || _notrun "$qa_user user not defined."
760 # check that xfs_io, glibc, kernel, and filesystem all (!) support
763 _require_xfs_io_falloc()
765 testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $TEST_DIR/$tmp.io 2>&1`
766 rm -f $TEST_DIR/$tmp.io 2>&1 > /dev/null
767 echo $testio | grep -q "not found" && \
768 _notrun "xfs_io fallocate support is missing"
769 echo $testio | grep -q "Operation not supported" && \
770 _notrun "xfs_io fallocate command failed (old kernel/wrong fs?)"
773 # Check that a fs has enough free space (in 1024b blocks)
778 BLOCKS=$2 # in units of 1024
779 let GB=$BLOCKS/1024/1024
781 FREE_BLOCKS=`df -klP $MNT | grep -v Filesystem | awk '{print $4}'`
782 [ $FREE_BLOCKS -lt $BLOCKS ] && \
783 _notrun "This test requires at least ${GB}GB free on $MNT to run"
786 # check that a FS on a device is mounted
787 # if so, return mount point
793 echo "Usage: _is_mounted device" 1>&2
799 if _mount | grep "$device " | $AWK_PROG -v pattern="type $FSTYP" '
800 pattern { print $3 ; exit 0 }
804 echo "_is_mounted: $device is not a mounted $FSTYP FS"
809 # remount a FS to a new mode (ro or rw)
815 echo "Usage: _remount device ro/rw" 1>&2
821 if ! mount -o remount,$mode $device
823 echo "_remount: failed to remount filesystem on $device as $mode"
828 # Run the appropriate repair/check on a filesystem
830 # if the filesystem is mounted, it's either remounted ro before being
831 # checked or it's unmounted and then remounted
834 # If set, we remount ro instead of unmounting for fsck
837 _umount_or_remount_ro()
841 echo "Usage: _umount_or_remount_ro <device>" 1>&2
846 mountpoint=`_is_mounted $device`
848 if [ $USE_REMOUNT -eq 0 ]; then
856 _mount_or_remount_rw()
860 echo "Usage: _mount_or_remount_rw <opts> <device> <mountpoint>" 1>&2
867 if [ $USE_REMOUNT -eq 0 ]
869 if ! _mount -t $FSTYP $mount_opts $device $mountpoint
871 echo "!!! failed to remount $device on $mountpoint"
881 # Check a generic filesystem in no-op mode; this assumes that the
882 # underlying fsck program accepts "-n" for a no-op (check-only) run,
883 # and that it will still return an errno for corruption in this mode.
885 # Filesystems which don't support this will need to define their
888 _check_generic_filesystem()
892 # If type is set, we're mounted
893 type=`_fs_type $device`
896 if [ "$type" = "$FSTYP" ]
899 mountpoint=`_umount_or_remount_ro $device`
902 fsck -t $FSTYP $FSCK_OPTIONS $device >$tmp.fsck 2>&1
905 echo "_check_generic_filesystem: filesystem on $device is inconsistent (see $seq.full)"
907 echo "_check_generic filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
908 echo "*** fsck.$FSTYP output ***" >>$here/$seq.full
909 cat $tmp.fsck >>$here/$seq.full
910 echo "*** end fsck.$FSTYP output" >>$here/$seq.full
918 echo "*** mount output ***" >>$here/$seq.full
919 _mount >>$here/$seq.full
920 echo "*** end mount output" >>$here/$seq.full
921 elif [ "$type" = "$FSTYP" ]
924 _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
928 [ $ok -eq 0 ] && exit 1
932 # run xfs_check and friends on a FS.
934 _check_xfs_filesystem()
938 echo "Usage: _check_xfs_filesystem device <logdev>|none <rtdev>|none" 1>&2
942 extra_mount_options=""
944 if [ "$2" != "none" ]; then
945 extra_log_options="-l$2"
946 extra_mount_options="-ologdev=$2"
949 if [ "$3" != "none" ]; then
950 extra_rt_options="-r$3"
951 extra_mount_options=$extra_mount_options" -ortdev=$3"
953 extra_mount_options=$extra_mount_options" $MOUNT_OPTIONS"
955 [ "$FSTYP" != xfs ] && return 0
957 [ "$USE_BIG_LOOPFS" = yes ] && testoption=-t
959 type=`_fs_type $device`
962 if [ "$type" = "xfs" ]
965 mountpoint=`_umount_or_remount_ro $device`
968 $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
969 | tee $tmp.logprint | grep -q "<CLEAN>"
970 if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]
972 echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seq.full)"
974 echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$here/$seq.full
975 echo "*** xfs_logprint -t output ***" >>$here/$seq.full
976 cat $tmp.logprint >>$here/$seq.full
977 echo "*** end xfs_logprint output" >>$here/$seq.full
982 $XFS_CHECK_PROG $testoption $extra_log_options $device 2>&1 |\
983 _fix_malloc >$tmp.fs_check
984 if [ -s $tmp.fs_check ]
986 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (c) (see $seq.full)"
988 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
989 echo "*** xfs_check output ***" >>$here/$seq.full
990 cat $tmp.fs_check >>$here/$seq.full
991 echo "*** end xfs_check output" >>$here/$seq.full
995 # repair doesn't scale massively at this stage, optionally skip it for now
996 [ "$USE_BIG_LOOPFS" = yes ] || \
997 $XFS_REPAIR_PROG -n $extra_log_options $extra_rt_options $device >$tmp.repair 2>&1
1000 echo "_check_xfs_filesystem: filesystem on $device is inconsistent (r) (see $seq.full)"
1002 echo "_check_xfs_filesystem: filesystem on $device is inconsistent" >>$here/$seq.full
1003 echo "*** xfs_repair -n output ***" >>$here/$seq.full
1004 cat $tmp.repair | _fix_malloc >>$here/$seq.full
1005 echo "*** end xfs_repair output" >>$here/$seq.full
1009 rm -f $tmp.fs_check $tmp.logprint $tmp.repair
1013 echo "*** mount output ***" >>$here/$seq.full
1014 _mount >>$here/$seq.full
1015 echo "*** end mount output" >>$here/$seq.full
1016 elif [ "$type" = "xfs" ]
1018 _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
1021 [ $ok -eq 0 ] && exit 1
1025 # Filter the knowen errors the UDF Verifier reports.
1026 _udf_test_known_error_filter()
1028 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."
1032 _check_udf_filesystem()
1034 [ "$DISABLE_UDF_TEST" == "1" ] && return
1036 if [ $# -ne 1 -a $# -ne 2 ]
1038 echo "Usage: _check_udf_filesystem device [last_block]" 1>&2
1042 if [ ! -x $here/src/udf_test ]
1044 echo "udf_test not installed, please download and build the Philips"
1045 echo "UDF Verification Software from http://www.extra.research.philips.com/udf/."
1046 echo "Then copy the udf_test binary to $here/src/."
1047 echo "If you do not wish to run udf_test then set environment variable DISABLE_UDF_TEST"
1055 LAST_BLOCK=`expr \( $2 - 1 \)`
1056 OPT_ARG="-lastvalidblock $LAST_BLOCK"
1060 sleep 1 # Due to a problem with time stamps in udf_test
1061 $here/src/udf_test $OPT_ARG $device | tee $here/$seq.checkfs | egrep "Error|Warning" | \
1062 _udf_test_known_error_filter | \
1063 egrep -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" | \
1064 sed "s/^.*$/Warning UDF Verifier reported errors see $seq.checkfs./g"
1068 _check_xfs_test_fs()
1072 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
1073 TEST_LOG="$TEST_LOGDEV"
1075 [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
1076 TEST_RT="$TEST_RTDEV"
1078 _check_xfs_filesystem $TEST_DEV $TEST_LOG $TEST_RT
1080 # check for ipath consistency
1081 if $XFS_GROWFS_PROG -n $TEST_DIR | grep -q 'inode-paths=1'; then
1082 # errors go to stderr
1083 xfs_check_ipaths $TEST_DIR >/dev/null
1084 xfs_repair_ipaths -n $TEST_DIR >/dev/null
1095 # no way to check consistency for nfs
1098 # do nothing for now
1101 _check_generic_filesystem $TEST_DEV
1112 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
1113 SCRATCH_LOG="$SCRATCH_LOGDEV"
1115 [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
1116 SCRATCH_RT="$SCRATCH_RTDEV"
1118 _check_xfs_filesystem $SCRATCH_DEV $SCRATCH_LOG $SCRATCH_RT
1121 _check_udf_filesystem $SCRATCH_DEV $udf_fsize
1124 # Don't know how to check an NFS filesystem, yet.
1127 _check_generic_filesystem $SCRATCH_DEV
1132 _full_fstyp_details()
1134 [ -z "$FSTYP" ] && FSTYP=xfs
1135 if [ $FSTYP = xfs ]; then
1136 if [ -d /proc/fs/xfs ]; then
1137 if grep -q 'debug 0' /proc/fs/xfs/stat; then
1138 FSTYP="$FSTYP (non-debug)"
1139 elif grep -q 'debug 1' /proc/fs/xfs/stat; then
1140 FSTYP="$FSTYP (debug)"
1143 if uname -a | grep -qi 'debug'; then
1144 FSTYP="$FSTYP (debug)"
1146 FSTYP="$FSTYP (non-debug)"
1153 _full_platform_details()
1159 echo "$os/$platform $host $kernel"
1162 _setup_udf_scratchdir()
1164 [ "$FSTYP" != "udf" ] \
1165 && _fail "setup_udf_testdir: \$FSTYP is not udf"
1166 [ -z "$SCRATCH_DEV" -o ! -b "$SCRATCH_DEV" ] \
1167 && _notrun "this test requires a valid \$SCRATCH_DEV"
1168 [ -z "$SCRATCH_MNT" ] \
1169 && _notrun "this test requires a valid \$SCRATCH_MNT"
1172 if _mount | grep -q $SCRATCH_DEV
1174 # if it's mounted, make sure its on $TEST_RW_DIR
1175 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1177 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1179 $UMOUNT_PROG $SCRATCH_DEV
1185 testdir=$SCRATCH_MNT
1188 _setup_nfs_scratchdir()
1190 [ "$FSTYP" != "nfs" ] \
1191 && _fail "setup_nfs_testdir: \$FSTYP is not nfs"
1192 [ -z "$SCRATCH_DEV" ] \
1193 && _notrun "this test requires a valid host fs for \$SCRATCH_DEV"
1194 [ -z "$SCRATCH_MNT" ] \
1195 && _notrun "this test requires a valid \$SCRATCH_MNT"
1198 if _mount | grep -q $SCRATCH_DEV
1200 # if it's mounted, make sure its on $SCRATCH_MNT
1201 if ! _mount | grep $SCRATCH_DEV | grep -q $SCRATCH_MNT
1203 _fail "\$SCRATCH_DEV is mounted but not on \$SCRATCH_MNT - aborting"
1205 $UMOUNT_PROG $SCRATCH_DEV
1211 testdir=$SCRATCH_MNT
1215 # Warning for UDF and NFS:
1216 # this function calls _setup_udf_scratchdir and _setup_udf_scratchdir
1217 # which actually uses the scratch dir for the test dir.
1219 # This was done because testdir was intended to be a persistent
1220 # XFS only partition. This should eventually change, and treat
1221 # at least local filesystems all the same.
1227 _setup_udf_scratchdir
1230 _setup_nfs_scratchdir
1242 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1243 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1246 # umount testdir as it is $SCRATCH_MNT which could be used by xfs next
1247 [ -n "$testdir" ] && $UMOUNT_PROG $testdir
1250 # do nothing, testdir is $TEST_DIR
1258 if [ -z "$1" ]; then
1259 echo Error must pass \$seq.
1263 if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
1265 elif [ "`uname`" == "Linux" ]; then
1268 echo Error test $seq does not run on the operating system: `uname`
1286 if [ $size -gt 0 ]; then
1287 dd if=/dev/zero of=$file bs=1024 count=$size
1293 # takes dirname, depth
1296 dirname=$1; depth=$2
1297 mkdir $dirname || die "mkdir $dirname failed"
1300 _nfiles $files # files for this dir
1302 [ $depth -eq 0 ] && return
1303 let deep=$depth-1 # go 1 down
1305 [ $verbose = true ] && echo "descending, depth from leaves = $deep"
1308 while [ $d -lt $dirs ]
1310 _descend d$d $deep &
1316 # Populate a filesystem with inodes for performance experiments
1318 # usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
1323 dirs=5 # ndirs in each subdir till leaves
1324 size=0 # sizeof files in K
1325 files=100 # num files in _each_ subdir
1326 depth=2 # depth of tree from root to leaves
1328 root=root # path of initial root of directory tree
1330 while getopts "d:f:n:r:s:v" c
1342 _descend $root $depth
1347 [ $verbose = true ] && echo done
1350 # query whether the given file has the given inode flag set
1357 if which $XFS_IO_PROG >/dev/null; then
1358 if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | grep -q "$flag" ; then
1365 # query the given files extsize allocator hint in bytes (if any)
1372 if which $XFS_IO_PROG >/dev/null; then
1373 blocks=`$XFS_IO_PROG -r -c 'stat' "$file" | \
1374 awk '/^xattr.extsize =/ { print $3 }'`
1376 [ -z "$blocks" ] && blocks="0"
1381 ################################################################################
1383 if [ "$iam" != new -a "$iam" != bench ]
1385 # make some further configuration checks here
1387 if [ "$TEST_DEV" = "" ]
1389 echo "common.rc: Error: \$TEST_DEV is not set"
1393 # if $TEST_DEV is not mounted, mount it now as XFS
1394 if [ -z "`_fs_type $TEST_DEV`" ]
1396 # $TEST_DEV is not mounted
1399 echo "common.rc: retrying test device mount with external set"
1400 [ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
1403 echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
1409 if [ "`_fs_type $TEST_DEV`" != "$FSTYP" ]
1411 echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED $FSTYP filesystem"
1417 # make sure this script returns success