##/bin/bash
-#
+# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms 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. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
# setup and check for config parameters, and in particular
#
# EMAIL - email of the script runner.
# validity or mountedness.
#
+. common/test_names
+
# all tests should use a common language setting to prevent golden
# output mismatches.
export LANG=C
export LC_ALL=C
-# Warning: don't put freeware before /usr/bsd on IRIX coz you'll
-# get the wrong hostname and set your system name to -s :)
-[ -d /usr/bsd ] && PATH=$PATH:/usr/bsd
-[ -d /usr/freeware/bin ] && PATH=$PATH:/usr/freeware/bin
PATH=".:$PATH"
export HOST=`hostname -s`
export HOSTOS=`uname -s`
-[ "$HOSTOS" = "IRIX64" ] && export HOSTOS="IRIX"
export MODULAR=0 # using XFS as a module or not
export BOOT="/boot" # install target for kernels
export RECREATE_TEST_DEV=false
-# $1 = prog to look for, $2* = default pathnames if not found in $PATH
-set_prog_path()
+# Handle mkfs.$fstyp which does (or does not) require -f to overwrite
+set_mkfs_prog_path_with_opts()
{
- p=`which $1 2> /dev/null`
- if [ -n "$p" -a -x "$p" ]; then
- echo $p
- return 0
- fi
- p=$1
-
- shift
- for f; do
- if [ -x $f ]; then
- echo $f
- return 0
- fi
- done
-
- echo ""
- return 1
-}
+ local fstyp=$1
+ local p=$(type -P mkfs.$fstyp)
-# Handle mkfs.btrfs which does (or does not) require -f to overwrite
-set_btrfs_mkfs_prog_path_with_opts()
-{
- p=`set_prog_path mkfs.btrfs`
- if [ "$p" != "" ] && grep -q 'force overwrite' $p; then
+ # Note: mkfs.f2fs doesn't support the --help option yet, but it doesn't
+ # matter since it also prints the help when an invalid option is given.
+ if [ "$p" != "" ] && \
+ $p --help |& grep -q "[[:space:]]-f[[:space:]|]"; then
echo "$p -f"
else
echo $p
exit 1
}
-export MKFS_PROG="`set_prog_path mkfs`"
+export MKFS_PROG="$(type -P mkfs)"
[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
-export MOUNT_PROG="`set_prog_path mount`"
+export MOUNT_PROG="$(type -P mount)"
[ "$MOUNT_PROG" = "" ] && _fatal "mount not found"
-export UMOUNT_PROG="`set_prog_path umount`"
+export UMOUNT_PROG="$(type -P umount)"
[ "$UMOUNT_PROG" = "" ] && _fatal "umount not found"
export FSSTRESS_PROG="./ltp/fsstress"
[ ! -x $FSSTRESS_PROG ] && _fatal "fsstress not found or executable"
-export PERL_PROG="`set_prog_path perl`"
+export PERL_PROG="$(type -P perl)"
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
-export AWK_PROG="`set_prog_path awk`"
+export AWK_PROG="$(type -P awk)"
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
-export SED_PROG="`set_prog_path sed`"
+export SED_PROG="$(type -P sed)"
[ "$SED_PROG" = "" ] && _fatal "sed not found"
-export BC_PROG="`set_prog_path bc`"
+export BC_PROG="$(type -P bc)"
[ "$BC_PROG" = "" ] && _fatal "bc not found"
export PS_ALL_FLAGS="-ef"
-export DF_PROG="`set_prog_path df`"
+export DF_PROG="$(type -P df)"
[ "$DF_PROG" = "" ] && _fatal "df not found"
[ "$HOSTOS" = "Linux" ] && export DF_PROG="$DF_PROG -T -P"
-export XFS_IO_PROG="`set_prog_path xfs_io`"
+export XFS_IO_PROG="$(type -P xfs_io)"
[ "$XFS_IO_PROG" = "" ] && _fatal "xfs_io not found"
-export XFS_LOGPRINT_PROG="`set_prog_path xfs_logprint`"
-export XFS_REPAIR_PROG="`set_prog_path xfs_repair`"
-export XFS_DB_PROG="`set_prog_path xfs_db`"
-export XFS_GROWFS_PROG=`set_prog_path xfs_growfs`
-export XFS_SCRUB_PROG="`set_prog_path xfs_scrub`"
-export XFS_PARALLEL_REPAIR_PROG="`set_prog_path xfs_prepair`"
-export XFS_PARALLEL_REPAIR64_PROG="`set_prog_path xfs_prepair64`"
-export __XFSDUMP_PROG="`set_prog_path xfsdump`"
+export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
+export XFS_REPAIR_PROG="$(type -P xfs_repair)"
+export XFS_DB_PROG="$(type -P xfs_db)"
+export XFS_GROWFS_PROG=$(type -P xfs_growfs)
+export XFS_SPACEMAN_PROG="$(type -P xfs_spaceman)"
+export XFS_SCRUB_PROG="$(type -P xfs_scrub)"
+export XFS_PARALLEL_REPAIR_PROG="$(type -P xfs_prepair)"
+export XFS_PARALLEL_REPAIR64_PROG="$(type -P xfs_prepair64)"
+export __XFSDUMP_PROG="$(type -P xfsdump)"
if [ -n "$__XFSDUMP_PROG" ]; then
export XFSDUMP_PROG="$__XFSDUMP_PROG -e"
else
export XFSDUMP_PROG=""
fi
-export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
-export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
-export GETFATTR_PROG="`set_prog_path getfattr`"
-export SETFATTR_PROG="`set_prog_path setfattr`"
-export CHACL_PROG="`set_prog_path chacl`"
-export ATTR_PROG="`set_prog_path attr`"
-export QUOTA_PROG="`set_prog_path quota`"
-export XFS_QUOTA_PROG="`set_prog_path xfs_quota`"
-export KILLALL_PROG="`set_prog_path killall`"
-export INDENT_PROG="`set_prog_path indent`"
-export XFS_COPY_PROG="`set_prog_path xfs_copy`"
-export FSTRIM_PROG="`set_prog_path fstrim`"
-export DUMPE2FS_PROG="`set_prog_path dumpe2fs`"
-export FIO_PROG="`set_prog_path fio`"
-export FILEFRAG_PROG="`set_prog_path filefrag`"
-export E4DEFRAG_PROG="`set_prog_path e4defrag`"
-export LOGGER_PROG="`set_prog_path logger`"
-export DBENCH_PROG="`set_prog_path dbench`"
-export DMSETUP_PROG="`set_prog_path dmsetup`"
-export WIPEFS_PROG="`set_prog_path wipefs`"
-export DUMP_PROG="`set_prog_path dump`"
-export RESTORE_PROG="`set_prog_path restore`"
-export LVM_PROG="`set_prog_path lvm`"
-export CHATTR_PROG="`set_prog_path chattr`"
-export DEBUGFS_PROG="`set_prog_path debugfs`"
-export UUIDGEN_PROG="`set_prog_path uuidgen`"
-export GETRICHACL_PROG="`set_prog_path getrichacl`"
-export SETRICHACL_PROG="`set_prog_path setrichacl`"
-export KEYCTL_PROG="`set_prog_path keyctl`"
-export XZ_PROG="`set_prog_path xz`"
-export FLOCK_PROG="`set_prog_path flock`"
-export LDD_PROG="`set_prog_path ldd`"
-export TIMEOUT_PROG="`set_prog_path timeout`"
+export XFSRESTORE_PROG="$(type -P xfsrestore)"
+export XFSINVUTIL_PROG="$(type -P xfsinvutil)"
+export GETFATTR_PROG="$(type -P getfattr)"
+export SETFATTR_PROG="$(type -P setfattr)"
+export CHACL_PROG="$(type -P chacl)"
+export ATTR_PROG="$(type -P attr)"
+export QUOTA_PROG="$(type -P quota)"
+export XFS_QUOTA_PROG="$(type -P xfs_quota)"
+export KILLALL_PROG="$(type -P killall)"
+export INDENT_PROG="$(type -P indent)"
+export XFS_COPY_PROG="$(type -P xfs_copy)"
+export FSTRIM_PROG="$(type -P fstrim)"
+export DUMPE2FS_PROG="$(type -P dumpe2fs)"
+export RESIZE2FS_PROG="$(type -P resize2fs)"
+export FIO_PROG="$(type -P fio)"
+export FILEFRAG_PROG="$(type -P filefrag)"
+export E4DEFRAG_PROG="$(type -P e4defrag)"
+export LOGGER_PROG="$(type -P logger)"
+export DBENCH_PROG="$(type -P dbench)"
+export DMSETUP_PROG="$(type -P dmsetup)"
+export WIPEFS_PROG="$(type -P wipefs)"
+export DUMP_PROG="$(type -P dump)"
+export RESTORE_PROG="$(type -P restore)"
+export LVM_PROG="$(type -P lvm)"
+export LSATTR_PROG="$(type -P lsattr)"
+export CHATTR_PROG="$(type -P chattr)"
+export DEBUGFS_PROG="$(type -P debugfs)"
+export UUIDGEN_PROG="$(type -P uuidgen)"
+export GETRICHACL_PROG="$(type -P getrichacl)"
+export SETRICHACL_PROG="$(type -P setrichacl)"
+export KEYCTL_PROG="$(type -P keyctl)"
+export XZ_PROG="$(type -P xz)"
+export FLOCK_PROG="$(type -P flock)"
+export LDD_PROG="$(type -P ldd)"
+export TIMEOUT_PROG="$(type -P timeout)"
+export MAN_PROG="$(type -P man)"
+export NFS4_SETFACL_PROG="$(type -P nfs4_setfacl)"
+export NFS4_GETFACL_PROG="$(type -P nfs4_getfacl)"
+export UBIUPDATEVOL_PROG="$(type -P ubiupdatevol)"
+export THIN_CHECK_PROG="$(type -P thin_check)"
+export PYTHON2_PROG="$(type -P python2)"
+export SQLITE3_PROG="$(type -P sqlite3)"
+export TIMEOUT_PROG="$(type -P timeout)"
+export SETCAP_PROG="$(type -P setcap)"
+export GETCAP_PROG="$(type -P getcap)"
+export CHECKBASHISMS_PROG="$(type -P checkbashisms)"
+export XFS_INFO_PROG="$(type -P xfs_info)"
+export DUPEREMOVE_PROG="$(type -P duperemove)"
# use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
# newer systems have udevadm command but older systems like RHEL5 don't.
# But if neither one is available, just set it to "sleep 1" to wait for lv to
# be settled
-UDEV_SETTLE_PROG="`set_prog_path udevadm`"
+UDEV_SETTLE_PROG="$(type -P udevadm)"
if [ "$UDEV_SETTLE_PROG" == "" ]; then
# try udevsettle command
- UDEV_SETTLE_PROG="`set_prog_path udevsettle`"
+ UDEV_SETTLE_PROG="$(type -P udevsettle)"
else
# udevadm is available, add 'settle' as subcommand
UDEV_SETTLE_PROG="$UDEV_SETTLE_PROG settle"
export UDEV_SETTLE_PROG
case "$HOSTOS" in
- IRIX*)
- export MKFS_XFS_PROG="`set_prog_path mkfs_xfs`"
- export MKFS_UDF_PROG="`set_prog_path mkfs_udf`"
- export XFS_FSR_PROG="`set_prog_path /usr/etc/fsr_xfs`"
- export MKFS_NFS_PROG="false"
- export MKFS_CIFS_PROG="false"
- ;;
Linux)
- export MKFS_XFS_PROG="`set_prog_path mkfs.xfs`"
- export MKFS_EXT4_PROG="`set_prog_path mkfs.ext4`"
- export MKFS_UDF_PROG="`set_prog_path mkudffs`"
- export MKFS_BTRFS_PROG="`set_btrfs_mkfs_prog_path_with_opts`"
- export MKFS_F2FS_PROG="`set_prog_path mkfs.f2fs`"
- export DUMP_F2FS_PROG="`set_prog_path dump.f2fs`"
- export BTRFS_UTIL_PROG="`set_prog_path btrfs`"
- export BTRFS_SHOW_SUPER_PROG="`set_prog_path btrfs-show-super`"
- export BTRFS_CONVERT_PROG="`set_prog_path btrfs-convert`"
- export XFS_FSR_PROG="`set_prog_path xfs_fsr`"
- export MKFS_NFS_PROG="false"
- export MKFS_CIFS_PROG="false"
- export MKFS_OVERLAY_PROG="false"
- export MKFS_REISER4_PROG="`set_prog_path mkfs.reiser4`"
- export E2FSCK_PROG="`set_prog_path e2fsck`"
- export TUNE2FS_PROG="`set_prog_path tune2fs`"
+ export MKFS_XFS_PROG=$(type -P mkfs.xfs)
+ export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
+ export MKFS_UDF_PROG=$(type -P mkudffs)
+ export MKFS_BTRFS_PROG=$(set_mkfs_prog_path_with_opts btrfs)
+ export MKFS_F2FS_PROG=$(set_mkfs_prog_path_with_opts f2fs)
+ export DUMP_F2FS_PROG=$(type -P dump.f2fs)
+ export BTRFS_UTIL_PROG=$(type -P btrfs)
+ export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
+ export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
+ export BTRFS_TUNE_PROG=$(type -P btrfstune)
+ export XFS_FSR_PROG=$(type -P xfs_fsr)
+ export MKFS_NFS_PROG="false"
+ export MKFS_CIFS_PROG="false"
+ export MKFS_OVERLAY_PROG="false"
+ export MKFS_REISER4_PROG=$(type -P mkfs.reiser4)
+ export E2FSCK_PROG=$(type -P e2fsck)
+ export TUNE2FS_PROG=$(type -P tune2fs)
+ export FSCK_OVERLAY_PROG=$(type -P fsck.overlay)
;;
esac
rm -f /tmp/crc_check.img
export XFS_MKFS_HAS_NO_META_SUPPORT
-# new doesn't need config file parsed, we can stop here
-if [ "$iam" == "new" ]; then
- return 0
-fi
-
_mount_opts()
{
case $FSTYP in
+ 9p)
+ export MOUNT_OPTIONS=$PLAN9_MOUNT_OPTIONS
+ ;;
xfs)
export MOUNT_OPTIONS=$XFS_MOUNT_OPTIONS
;;
# We need to specify the size at mount, use 1G by default
export MOUNT_OPTIONS="-o size=1G $TMPFS_MOUNT_OPTIONS"
;;
+ ubifs)
+ export MOUNT_OPTIONS=$UBIFS_MOUNT_OPTIONS
+ ;;
*)
;;
esac
_test_mount_opts()
{
case $FSTYP in
+ 9p)
+ export TEST_FS_MOUNT_OPTS=$PLAN9_MOUNT_OPTIONS
+ ;;
cifs)
export TEST_FS_MOUNT_OPTS=$CIFS_MOUNT_OPTIONS
;;
glusterfs)
export TEST_FS_MOUNT_OPTS=$GLUSTERFS_MOUNT_OPTIONS
;;
+ ext2|ext3|ext4|ext4dev)
+ # acls & xattrs aren't turned on by default on older ext$FOO
+ export TEST_FS_MOUNT_OPTS="-o acl,user_xattr $EXT_MOUNT_OPTIONS"
+ ;;
*)
;;
esac
return 0
fi
- if [ "$FSTYP" == "overlay" ]; then
+ case "$FSTYP" in
+ 9p|tmpfs)
+ # 9p mount tags are just plain strings, so anything is allowed
+ # tmpfs doesn't use mount source, ignore
+ ;;
+ overlay)
if [ ! -d "$dev" ]; then
_fatal "common/config: $name ($dev) is not a directory for overlay"
fi
- else
+ ;;
+ ubifs)
+ if [ ! -c "$dev" ]; then
+ _fatal "common/config: $name ($dev) is not a character device"
+ fi
+ ;;
+ *)
_fatal "common/config: $name ($dev) is not a block device or a network filesystem"
- fi
+ esac
}
# check and return a canonical mount point path
[ -b "$TEST_DEV" ] || return 0
# Config file may specify base fs type, but we obay -overlay flag
- export OVL_BASE_FSTYP="$FSTYP"
+ [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
export FSTYP=overlay
# Store original base fs vars
export OVL_BASE_TEST_DEV="$TEST_DEV"
export OVL_BASE_TEST_DIR="$TEST_DIR"
+ # If config does not set MOUNT_OPTIONS, its value may be
+ # leftover from previous _overlay_config_override, so
+ # don't use that value for base fs mount
+ [ "$MOUNT_OPTIONS" != "$OVERLAY_MOUNT_OPTIONS" ] || unset MOUNT_OPTIONS
export OVL_BASE_MOUNT_OPTIONS="$MOUNT_OPTIONS"
# Set TEST vars to overlay base and mount dirs inside base fs
# Set SCRATCH vars to overlay base and mount dirs inside base fs
export SCRATCH_DEV="$OVL_BASE_SCRATCH_MNT"
export SCRATCH_MNT="$OVL_BASE_SCRATCH_MNT/$OVL_MNT"
+
+ # Set fsck options, use default if user not set directly.
+ export FSCK_OPTIONS="$OVERLAY_FSCK_OPTIONS"
+ [ -z "$FSCK_OPTIONS" ] && _fsck_opts
}
_overlay_config_restore()
local OLD_USE_EXTERNAL=$USE_EXTERNAL
unset MOUNT_OPTIONS
+ unset TEST_FS_MOUNT_OPTS
unset MKFS_OPTIONS
unset FSCK_OPTIONS
unset USE_EXTERNAL
# set default RESULT_BASE
if [ -z "$RESULT_BASE" ]; then
export RESULT_BASE="$here/results/"
+ mkdir -p ${RESULT_BASE}
+ if [ ! -d ${RESULT_BASE} ]; then
+ echo "failed to create results directory $RESULT_BASE"
+ exit 1
+ fi
+ fi
+
+ if [ "$FSTYP" == "tmpfs" ]; then
+ if [ -z "TEST_DEV" ]; then
+ export TEST_DEV=tmpfs_test
+ fi
+ if [ -z "SCRATCH_DEV" ]; then
+ export TEST_DEV=tmpfs_scratch
+ fi
fi
# Mandatory Config values.