overlay: Enable character device to be the base fs partition
[xfstests-dev.git] / common / config
index a127e98fba2d62c5853841336df4e66159abf00d..4eda36c7aaeb16b16d1473a7ad752d36ecafba81 100644 (file)
@@ -69,6 +69,17 @@ export OVL_WORK="ovl-work"
 # overlay mount point parent must be the base fs root
 export OVL_MNT="ovl-mnt"
 
+# From e2fsprogs/e2fsck/e2fsck.h:
+# Exit code used by fsck-type programs
+export FSCK_OK=0
+export FSCK_NONDESTRUCT=1
+export FSCK_REBOOT=2
+export FSCK_UNCORRECTED=4
+export FSCK_ERROR=8
+export FSCK_USAGE=16
+export FSCK_CANCELED=32
+export FSCK_LIBRARY=128
+
 export PWD=`pwd`
 #export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really.
 export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
@@ -132,6 +143,11 @@ export DF_PROG="$(type -P df)"
 export XFS_IO_PROG="$(type -P xfs_io)"
 [ "$XFS_IO_PROG" = "" ] && _fatal "xfs_io not found"
 
+export MKSWAP_PROG="$(type -P mkswap)"
+# mkswap from util-linux v2.17.2 or older needs "-f" option to force to erase
+# bootbits sectors
+MKSWAP_PROG="$MKSWAP_PROG -f"
+
 export XFS_LOGPRINT_PROG="$(type -P xfs_logprint)"
 export XFS_REPAIR_PROG="$(type -P xfs_repair)"
 export XFS_DB_PROG="$(type -P xfs_db)"
@@ -167,9 +183,11 @@ 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 BLKDISCARD_PROG="$(type -P blkdiscard)"
 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)"
@@ -190,8 +208,11 @@ 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 CAPSH_PROG="$(type -P capsh)"
 export CHECKBASHISMS_PROG="$(type -P checkbashisms)"
 export XFS_INFO_PROG="$(type -P xfs_info)"
+export DUPEREMOVE_PROG="$(type -P duperemove)"
+export CC_PROG="$(type -P cc)"
 
 # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled.
 # newer systems have udevadm command but older systems like RHEL5 don't.
@@ -249,15 +270,17 @@ if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
 fi
 
 # check if mkfs.xfs supports v5 xfs
-XFS_MKFS_HAS_NO_META_SUPPORT=""
-touch /tmp/crc_check.img
-$MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
-       >/dev/null 2>&1;
-if [ $? -ne 0 ]; then
-       XFS_MKFS_HAS_NO_META_SUPPORT=true
+if [ "$FSTYP" == "xfs" ]; then
+       XFS_MKFS_HAS_NO_META_SUPPORT=""
+       touch /tmp/crc_check.img
+       $MKFS_XFS_PROG -N -d file,name=/tmp/crc_check.img,size=32m -m crc=0 \
+               >/dev/null 2>&1;
+       if [ $? -ne 0 ]; then
+               XFS_MKFS_HAS_NO_META_SUPPORT=true
+       fi
+       rm -f /tmp/crc_check.img
+       export XFS_MKFS_HAS_NO_META_SUPPORT
 fi
-rm -f /tmp/crc_check.img
-export XFS_MKFS_HAS_NO_META_SUPPORT
 
 _mount_opts()
 {
@@ -455,8 +478,9 @@ _check_device()
        fi
 
        case "$FSTYP" in
-       9p)
+       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
@@ -508,7 +532,7 @@ _canonicalize_mountpoint()
 # When SCRATCH/TEST_* vars are defined in evironment and not
 # in config file, this function is called after vars have already
 # been overriden in the previous test.
-# In that case, TEST_DEV is a directory and not a blockdev and
+# In that case, TEST_DEV is a directory and not a blockdev/chardev and
 # the function will return without overriding the SCRATCH/TEST_* vars.
 _overlay_config_override()
 {
@@ -526,10 +550,10 @@ _overlay_config_override()
        #    the new OVL_BASE_SCRATCH/TEST_DEV/MNT vars are set to the values
        #    of the configured base fs and SCRATCH/TEST_DEV vars are set to the
        #    overlayfs base and mount dirs inside base fs mount.
-       [ -b "$TEST_DEV" ] || return 0
+       [ -b "$TEST_DEV" ] || [ -c "$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
@@ -546,7 +570,7 @@ _overlay_config_override()
        export TEST_DIR="$OVL_BASE_TEST_DIR/$OVL_MNT"
        export MOUNT_OPTIONS="$OVERLAY_MOUNT_OPTIONS"
 
-       [ -b "$SCRATCH_DEV" ] || return 0
+       [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || return 0
 
        # Store original base fs vars
        export OVL_BASE_SCRATCH_DEV="$SCRATCH_DEV"
@@ -656,6 +680,15 @@ get_next_config() {
                export RESULT_BASE="$here/results/"
        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.
        MC=""
        [ -z "$EMAIL" ]          && MC="$MC EMAIL"