common.dump: filter out latest xfsdump version messages
[xfstests-dev.git] / common.dump
index 59d0afbd18ef5c98484c7e8b72421d3e8db0a447..e89dedcfe77d2d17fd36aad8bd58655ae61c10e7 100644 (file)
@@ -1,54 +1,45 @@
-#/bin/sh
-
+##/bin/bash
 #
-# Functions useful for xfsdump/xfsrestore tests
+# Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.  All Rights Reserved.
 #
-# Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
-# 
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
+# 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.
-# 
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like.  Any license provided herein, whether implied or
-# otherwise, applies only to this software file.  Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-# 
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA  94043, or:
-# 
-# http://www.sgi.com 
-# 
-# For further information regarding this notice, see: 
-# 
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+#
+# 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
+#
+#
+# Functions useful for xfsdump/xfsrestore tests
 #
 
 # --- initializations ---
 rm -f $here/$seq.full
 
 if [ -n "$DEBUGDUMP" ]; then
-  _dump_debug=-v5
-  _restore_debug=-v5
-  _invutil_debug=-d
+       _dump_debug=-v4
+       _restore_debug=-v4
+       _invutil_debug=-d
+
+       # Use dump/restore in qa directory (copy them here) for debugging
+       export PATH="$here:$PATH"
+       export XFSDUMP_PROG="`set_prog_path xfsdump`"
+       export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
+       export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
+       [ -x $here/xfsdump ]    && echo "Using xfstests' xfsdump for debug"
+       [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
+       [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
 fi
-# Use dump/restore in qa directory for debugging
-PATH="$here:$PATH"
-export PATH
-#which xfsdump
-#which xfsrestore
-#which xfsinvutil
+
+[ "$XFSDUMP_PROG" = "" ]    && _notrun "xfsdump not found"
+[ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
+[ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
 
 # status returned for not run tests
 NOTRUNSTS=2
@@ -84,13 +75,32 @@ done
 have_mtvariable=false
 [ `uname` = "Linux" ] && have_mtvariable=true
 
+
+_require_multi_stream()
+{
+    $XFSDUMP_PROG -JF -f /dev/null -f /dev/null 2> /dev/null |
+    grep -q "too many -f arguments" &&
+    _notrun "xfsdump multi-stream support required"
+}
+
+_require_legacy_v2_format()
+{
+    $XFSDUMP_PROG 2>&1 |
+    grep -q "generate format 2 dump" ||
+    _notrun "xfsdump -K option required"
+
+    $XFSRESTORE_PROG 2>&1 |
+    grep -q "force use of format 2 generation" ||
+    _notrun "xfsrestore -K option required"
+}
+
 #
 # do a remote/local mt
 #
 _mt()
 {
     op=$1
-    if _isrmt; then  
+    if _isrmt; then
        # REMOTE
        _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
 
@@ -113,14 +123,14 @@ _check_onl()
 {
     _limit=10
     i=0
-    while [ $i -lt $_limit ]; do  
+    while [ $i -lt $_limit ]; do
         echo "Checking online..." >>$here/$seq.full
        if _mt status >$tmp.status 2>&1; then
-           break; 
+           break;
        else
-           sleep 
+           sleep 1
        fi
-       i=`expr $i + 1`
+       let i=$i+1
     done
 
 
@@ -128,10 +138,10 @@ _check_onl()
        echo "ERROR: mt -f $dumptape failed"
        cat $tmp.status
 
-       echo "mt -f $dumptape failed" >$seq.notrun 
+       echo "mt -f $dumptape failed" >$seq.notrun
        status=$NOTRUNSTS
        exit
-    fi 
+    fi
 
 
     if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
@@ -140,7 +150,7 @@ _check_onl()
        echo "ERROR: $dumptape is not online"
        cat $tmp.status
 
-       echo "dumptape, $dumptape, is not online" >$seq.notrun 
+       echo "dumptape, $dumptape, is not online" >$seq.notrun
        status=$NOTRUNSTS
        exit
     fi
@@ -151,14 +161,14 @@ _wait_tape()
     echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
 
     i=0
-    while [ $i -lt 20 ]; do  
+    while [ $i -lt 20 ]; do
         echo "Checking status..." >>$here/$seq.full
        if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
-           break; 
+           break;
        else
-           sleep 
+           sleep 1
        fi
-       i=`expr $i + 1`
+       let i=$i+1
     done
 }
 
@@ -174,7 +184,7 @@ _rewind()
 }
 
 #
-# Do a custom erase because: 
+# Do a custom erase because:
 # (i) some machines don't support it
 # (ii) some machines take forever to do it
 #
@@ -210,16 +220,16 @@ _set_variable()
        # LOCAL
        echo "Put scsi tape driver into variable block size mode"
        mt -f $dumptape setblk 0
-    fi 
+    fi
 }
 
 _require_tape()
 {
     dumptape=$1
 
-    if [ -z "$dumptape" ]; then
+    if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
         echo "This test requires a dump tape - none was specified"
-       echo "No dump tape specified" >$seq.notrun 
+       echo "No dump tape specified" >$seq.notrun
        status=$NOTRUNSTS
        exit
     fi
@@ -228,31 +238,26 @@ _require_tape()
     _set_variable
 }
 
-_error()
-{
-    echo "Error: $*" | tee -a $here/$seq.full
-    echo "(see $here/$seq.full for details)"
-    status=1
-    exit
-}
-
 _wipe_fs()
 {
     _require_scratch
 
-    mkfs_xfs $SCRATCH_DEV>>$here/$seq.full  ||\
-       _error "mkfs failed"
-      
-    mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$here/$seq.full ||\
-       _error "mount failed"
+    _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
+    _scratch_mount >>$here/$seq.full || _fail "mount failed"
 }
 
-# 
+#
 # Cleanup created dirs and files
 # Called by trap
 #
 _cleanup()
 {
+    # Some tests include this before checking _supported_fs xfs
+    # and the sleeps & checks here get annoying
+    if [ "$FSTYP" != "xfs" ]; then
+       return
+    fi
+
     cd $here
     rm -f $tmp.*
 
@@ -261,7 +266,7 @@ _cleanup()
        for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
            [ -d $dir ] || continue
            tar -cvf $seq.inventory.tar $dir
-           ls -lR $dir >$seq.inventory.ls
+           ls -nR $dir >$seq.inventory.ls
        done
     fi
 
@@ -273,11 +278,11 @@ _cleanup()
     done
 
     if [ $status -ne $NOTRUNSTS ]; then
-       # Sleep added to stop _check_fs from complaining that the
+       # Sleep added to stop _check_scratch_fs from complaining that the
        # scratch_dev is still busy
        sleep 10
 
-       _check_fs $SCRATCH_DEV
+       _check_scratch_fs
     fi
 }
 
@@ -289,27 +294,25 @@ _cleanup()
 _stable_fs()
 {
     _saveddir=`pwd`; cd /
-    umount $SCRATCH_MNT >>$here/$seq.full ||\
-       _error "unmount failed"
-    mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$here/$seq.full ||\
-       _error "mount failed"
+    umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
+    _scratch_mount >>$here/$seq.full || _fail "mount failed"
     cd $_saveddir
 }
 
 #
-# Run src/fsstress to create a mixture of 
+# Run fsstress to create a mixture of
 # files,dirs,links,symlinks
 #
 # Pinched from test 013.
 #
 _create_dumpdir_stress()
 {
-    echo "Creating directory system to dump using src/fsstress."
+    echo "Creating directory system to dump using fsstress."
 
     _wipe_fs
 
     _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
-    _count=200
+    _count=240
     rm -rf $dump_dir
     if ! mkdir $dump_dir; then
         echo "    failed to mkdir $dump_dir"
@@ -320,14 +323,14 @@ _create_dumpdir_stress()
     echo "-----------------------------------------------"
     echo "fsstress : $_param"
     echo "-----------------------------------------------"
-    if ! $here/src/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
+    if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
     then
         echo "    fsstress (count=$_count) returned $? - see $here/$seq.full"
-        
-        echo "--------------------------------------"       >>$here/$here/$seq.full
-        echo "output from fsstress:"                        >>$here/$here/$seq.full
-        echo "--------------------------------------"       >>$here/$here/$seq.full
-        cat $tmp.out                                        >>$here/$here/$seq.full
+
+        echo "--------------------------------------"       >>$here/$seq.full
+        echo "output from fsstress:"                        >>$here/$seq.full
+        echo "--------------------------------------"       >>$here/$seq.full
+        cat $tmp.out                                        >>$here/$seq.full
         status=1
     fi
 
@@ -418,7 +421,7 @@ _mk_fillconfig_ea()
     cat <<End-of-File >$tmp.config
 # pathname     size    user    group    perm   name value namespace
 #
-smalll         10      $nobody $nobody  777    attr1 some_text   user 
+smalll         10      $nobody $nobody  777    attr1 some_text   user
 biggg          102400  $nobody $nobody  777    attr2 some_text2  root
 sub/smalll     10      $nobody $nobody  777    attr3 some_text3  user
 sub/biggg      102400  $nobody $nobody  777    attr4 some_text4  root
@@ -447,6 +450,25 @@ sub/n              8192    $nobody $nobody
 End-of-File
 }
 
+#
+# extended file attribute flags
+#
+_mk_fillconfig_xattr()
+{
+    cat <<End-of-File >$tmp.config
+# pathname     size    user    group    perm   name
+#
+xflag_realtime 10      $nobody $nobody  777    XFS_XFLAG_REALTIME
+xflag_prealloc 10      $nobody $nobody  777    XFS_XFLAG_PREALLOC
+xflag_immutable 10     $nobody $nobody  777    XFS_XFLAG_IMMUTABLE
+xflag_append   10      $nobody $nobody  777    XFS_XFLAG_APPEND
+xflag_sync     10      $nobody $nobody  777    XFS_XFLAG_SYNC
+xflag_noatime  10      $nobody $nobody  777    XFS_XFLAG_NOATIME
+xflag_nodump   10      $nobody $nobody  777    XFS_XFLAG_NODUMP
+xflag_hasattr  10      $nobody $nobody  777    XFS_XFLAG_HASATTR
+End-of-File
+}
+
 #
 # Create a bunch of directories/files of different sizes
 # filled with data.
@@ -457,8 +479,7 @@ _do_create_dumpdir_fill()
 {
     echo "Creating directory system to dump using src/fill."
 
-    mkdir -p $dump_dir ||\
-       _error "cannot mkdir \"$dump_dir\""
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     cd $dump_dir
 
     $verbose && echo -n "Setup "
@@ -467,7 +488,7 @@ _do_create_dumpdir_fill()
     do
        if [ $nbytes = "d" ]; then
            # create a directory
-           dir=$file   
+           dir=$file
            if [ ! -d $dir ]
            then
                if mkdir $dir
@@ -512,12 +533,20 @@ _do_create_dumpdir_fill()
        if [ -n "$perms" ]; then
            chmod $perms $file
        fi
+
+       # extended attributes (EA)
        if [ -n "$ea_name" -a -n "$ea_value" ]; then
            if [ "X$namespace" = "Xroot" ]; then
                attr -R -s $ea_name -V $ea_value $file
            else
                attr -s $ea_name -V $ea_value $file
            fi
+       # extended file attribute flags - no value - NOT EAs
+       elif [ -n "$ea_name" -a -z "$ea_value" ]; then
+           # set the flag
+           # TODO XXX
+            # use xfs_io to send the ioctl
+           :
        fi
        $verbose && echo -n "."
     done
@@ -526,17 +555,29 @@ _do_create_dumpdir_fill()
     cd $here
 }
 
+_mk_fillconfig_multi()
+{
+    _mk_fillconfig1
+    cat <<End-of-File >>$tmp.config
+# pathname     size in bytes
+#
+large000       8874368 $nobody $nobody
+large111       2582912 $nobody $nobody
+large222       7825792 $nobody $nobody
+End-of-File
+}
+
 _create_dumpdir_largefile()
 {
     _wipe_fs
-    mkdir -p $dump_dir ||\
-       _error "cannot mkdir \"$dump_dir\""
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     _largesize=4294967297
     _largefile=$dump_dir/largefile
     echo "dd a largefile at offset $_largesize"
+    POSIXLY_CORRECT=yes \
     dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
     _stable_fs
-}      
+}
 
 _create_dumpdir_fill()
 {
@@ -544,7 +585,7 @@ _create_dumpdir_fill()
     _mk_fillconfig1
     _do_create_dumpdir_fill
     _stable_fs
-}      
+}
 
 _create_dumpdir_fill2()
 {
@@ -552,7 +593,7 @@ _create_dumpdir_fill2()
     _mk_fillconfig2
     _do_create_dumpdir_fill
     _stable_fs
-}      
+}
 
 _create_dumpdir_fill_perm()
 {
@@ -560,7 +601,7 @@ _create_dumpdir_fill_perm()
     _mk_fillconfig_perm
     _do_create_dumpdir_fill
     _stable_fs
-}      
+}
 
 _create_dumpdir_fill_ea()
 {
@@ -568,8 +609,19 @@ _create_dumpdir_fill_ea()
     _mk_fillconfig_ea
     _do_create_dumpdir_fill
     _stable_fs
-}      
+}
 
+#
+# Create enough files, and a few large enough files, so that
+# some files are likely to be split across streams.
+#
+_create_dumpdir_fill_multi()
+{
+    _wipe_fs
+    _mk_fillconfig_multi
+    _do_create_dumpdir_fill
+    _stable_fs
+}
 
 #
 # Append a subset of the fill'ed files
@@ -581,8 +633,8 @@ _append_dumpdir_fill()
     cat <<End-of-File >$tmp.config
 # pathname
 #
-small  
-sub/big        
+small
+sub/big
 #
 sub/a
 sub/c
@@ -602,8 +654,7 @@ _do_create_dump_symlinks()
 {
     echo "Creating directory system of symlinks to dump."
 
-    mkdir -p $dump_dir ||\
-       _error "cannot mkdir \"$dump_dir\""
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     cd $dump_dir
 
     $verbose && echo -n "Setup "
@@ -638,7 +689,7 @@ _do_create_dump_symlinks()
        fi
        ln -s $file $file-link
        if [ -n "$perms2" ]; then
-           umask $omask        
+           umask $omask
        fi
 
        if [ -n "$owner" -a -n "$group" ]; then
@@ -660,7 +711,7 @@ _do_create_dump_symlinks()
 _mk_symlink_config()
 {
     cat <<End-of-File >$tmp.config
-# path size    owner1  group1  owner2  group2  perm1   perm2 
+# path size    owner1  group1  owner2  group2  perm1   perm2
 #
 a      0       $nobody $nobody daemon  sys     124     421
 b      0       daemon  sys     bin     bin     347     743
@@ -675,14 +726,14 @@ _create_dumpdir_symlinks()
     _mk_symlink_config
     _do_create_dump_symlinks
     _stable_fs
-}      
+}
 
 #
 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
 #
 _create_hardlinks()
 {
-    _fname=$1  
+    _fname=$1
     _numlinks=$2
 
     touch $_fname
@@ -692,7 +743,7 @@ _create_hardlinks()
        _hardlink=$_fname$_suffix
        echo "creating hardlink $_hardlink to $_fname"
        ln $_fname $_hardlink
-       _j=`expr $_j + 1`
+       let _j=$_j+1
     done
 }
 
@@ -708,7 +759,7 @@ _create_hardset()
     _i=1
     while [ $_i -le $_numsets ]; do
        _create_hardlinks file$_i 5
-       _i=`expr $_i + 1`
+       let _i=$_i+1
     done
 }
 
@@ -725,8 +776,7 @@ _create_dumpdir_hardlinks()
     _wipe_fs
     echo "Creating directory system of hardlinks to incrementally dump."
 
-    mkdir -p $dump_dir ||\
-       _error "cannot mkdir \"$dump_dir\""
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     cd $dump_dir
 
     _create_hardset $_numsets
@@ -737,52 +787,91 @@ _create_dumpdir_hardlinks()
 
 #
 # Filter for ls
-# Filter out dates on symlinks and char devices
+# Filter out times and dates on symlinks and char devices.
+# Filter out size on directories because this can differ
+# when transitioning to long inode numbers (ie. 64 bits).
 #
 _ls_filter()
 {
   $AWK_PROG '
-        /^l/ { date = $8; sub(date,"DATE"); print}
-        /^c/ { date = $9; sub(date,"DATE"); print}
+        /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
+        /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
+        /^d/ { size = $5; sub(size,"SIZE"); print}
         {print}' \
   | sed -e 's/total [0-9][0-9]*/total TOTAL/'
 }
 
+#
+# Filtering of Irix character hwgraph device names
+# e.g.
+# chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
+# blkdev:  /dev/dsk/dks0d1s4
+#
+_filter_devchar()
+{
+    $AWK_PROG '
+       /\/hw\/node/ {
+           sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks")  # blah blah /dev/dsk/dks0/target/1/....
+           sub(/\/target\//,"d")                    # blah blah /dev/dsk/dks0d1/lun/0/disk.....
+           sub(/\/lun.*partition\//,"s")            # blah blah /dev/dsk/dks0d1s4/char
+           sub(/\/char/,"")                         # blah blah /dev/dsk/dks0d1s4
+       }
+       { print }
+    '
+}
 
-# 
+
+#
 # Filter out the non-deterministic dump msgs from
 # xfsdump and xfsrestore
 #
 _dump_filter_main()
 {
+  _filter_devchar |\
   sed \
-      -e "s/`hostname`/HOSTNAME/"   \
-      -e "s#$SCRATCH_DEV#SCRATCH_DEV#"    \
-      -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"    \
-      -e "s#$dumptape#TAPE_DEV#"    \
-      -e "s#$SCRATCH_MNT#SCRATCH_MNT#"    \
-      -e "s#$dump_file#DUMP_FILE#"  \
-      -e 's#/var/lib/xfsdump#/var/xfsdump#' \
-      -e 's/id:[       ]*[0-9a-f-]*/id: ID/'  \
-      -e 's/time:[     ].*/time: TIME/'       \
-      -e 's/date:[     ].*/date: DATE/'       \
-      -e 's/dump begun .*/dump begun DATE/'    \
-      -e 's/[0-9][0-9]* seconds/SECS seconds/' \
-      -e 's/restore.[0-9][0-9]*/restore.PID/' \
-      -e 's/ino [0-9][0-9]*/ino INO/' \
-      -e '/: dump size/s/[0-9][0-9]*/NUM/'     \
-      -e '/dump size:/s/[0-9][0-9]*/NUM/'      \
-      -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
+      -e "s#$XFSDUMP_PROG#xfsdump#"                    \
+      -e "s#$XFSRESTORE_PROG#xfsrestore#"              \
+      -e "s#$XFSINVUTIL_PROG#xfsinvutil#"              \
+      -e "s/`hostname`/HOSTNAME/"                      \
+      -e "s#$SCRATCH_DEV#SCRATCH_DEV#"                 \
+      -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"              \
+      -e "s#$dumptape#TAPE_DEV#"                       \
+      -e "s#$SCRATCH_MNT#SCRATCH_MNT#"                 \
+      -e "s#$dump_file#DUMP_FILE#"                     \
+      -e 's#/var/lib/xfsdump#/var/xfsdump#'            \
+      -e 's/session id:[       ]*[0-9a-f-]*/session id: ID/'  \
+      -e '/filesystem id:[     ]*[0-9a-f-]*/d'         \
+      -e 's/time:[     ].*/time: TIME/'                \
+      -e 's/date:[     ].*/date: DATE/'                \
+      -e 's/dump begun .*/dump begun DATE/'            \
+      -e 's/previously begun .*/previously begun DATE/'        \
+      -e 's/[0-9][0-9]* seconds/SECS seconds/'         \
+      -e 's/restore.[0-9][0-9]*/restore.PID/'          \
+      -e 's/ino [0-9][0-9]*/ino INO/g'                 \
+      -e '/stream [0-9]:/s/offset [0-9][0-9]*/offset NUM/g'    \
+      -e '/: dump size/s/[0-9][0-9]*/NUM/'             \
+      -e '/dump size:/s/[0-9][0-9]*/NUM/'              \
+      -e '/dump size per stream:/s/[0-9][0-9]*/NUM/'   \
       -e 's/\(media file size[  ]*\)[0-9][0-9]*/\1NUM/' \
       -e 's/\(mfile size:[      ]*\)[0-9][0-9]*/\1NUM/' \
-      -e '/drive[       ]*[0-9][0-9]*:/d' \
-      -e '/\/dev\/tty/d' \
-      -e '/inventory session uuid/d' \
-      -e '/ - Running single-threaded/d' \
-      -e '/^.*I\/O metrics: .*$/d' \
-      -e 's/1048576/BLOCKSZ/' \
-      -e 's/2097152/BLOCKSZ/' \
-      -e 's/(pid[       ]*[1-9][0-9]*)/\(pid PID\)/' \
+      -e '/drive[       ]*[0-9][0-9]*:/d'              \
+      -e '/\/dev\/tty/d'                               \
+      -e '/inventory session uuid/d'                   \
+      -e '/ - Running single-threaded/d'               \
+      -e '/Mount point match/d'                                \
+      -e '/^.*I\/O metrics: .*$/d'                     \
+      -e 's/1048576/BLOCKSZ/'                          \
+      -e 's/2097152/BLOCKSZ/'                          \
+      -e 's/(pid[       ]*[1-9][0-9]*)/\(pid PID\)/'   \
+      -e '/version [3-9]\.[0-9]/d'                     \
+      -e 's/\/hw\/module.*$/SCRATCH_DEV/'              \
+      -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
+      -e '/xfsdump: ino map phase [2]/,1d'             \
+      -e '/xfsdump: ino map phase [3]/,1d'             \
+      -e '/xfsdump: ino map phase [4]/,1d'             \
+      -e '/xfsdump: ino map phase [5]/,1d'             \
+      -e 's/id:[[:space:]]*[0-9a-f]\{8\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{4\}-[0-9a-f]\{12\}/ID: ID/'                                             \
+      -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/'             \
   | perl -ne '
       if ($_ =~ /(?:Dump|Restore) Summary/) {
         $skip = 1;
@@ -817,7 +906,7 @@ _invutil_filter()
 _dir_filter()
 {
   sed \
-    -e "s#$dump_file#DUMP_FILE#"      \
+    -e "s#$dump_file#DUMP_FILE#g"      \
     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
     -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"    \
     -e "s#$dumptape#TAPE_DEV#"         \
@@ -831,9 +920,10 @@ _dir_filter()
 }
 
 #
-# Note: requires a space between option letter and argument 
+# Parse xfsdump arguments.
+# Note: requires a space between option letter and argument
 #
-_parse_args()
+_parse_dump_args()
 {
     OPTIND=0
     dump_args=""
@@ -842,38 +932,82 @@ _parse_args()
         case $1
         in
         -f)
-            [ -z "$2" ] && _error "missing argument for -f"
-           dumptape=$2 
+            [ -z "$2" ] && _fail "missing argument for -f"
+           dumptape=$2
+           dump_file=$2
            shift
             ;;
         -L)
-            [ -z "$2" ] && _error "missing argument for -L"
+            [ -z "$2" ] && _fail "missing argument for -L"
            session_label=$2
            shift
             ;;
-       -o)
-           dump_args="$dump_args -o"
+       --multi)
+            [ -z "$2" ] && _fail "missing argument for --multi"
+           multi=$2
+           shift
+           ;;
+        --check-quota)
+            do_quota_check=true
+            ;;
+        --no-check-quota)
+            do_quota_check=false
+            ;;
+       -o|-D|-F|-K)
+           dump_args="$dump_args $1"
             ;;
-       -F)
-           dump_args="$dump_args -F"
+        -l|-d)
+            [ -z "$2" ] && _fail "missing argument for $1"
+           dump_args="$dump_args $1$2"
+           shift
+            ;;
+       *)
+            _fail "invalid argument to common.dump function: $1"
+            ;;
+        esac
+       shift
+    done
+}
+
+#
+# Parse xfsrestore arguments.
+# Note: requires a space between option letter and argument
+#
+_parse_restore_args()
+{
+    OPTIND=0
+    restore_args=""
+    while [ $# -gt 0 ]
+    do
+        case $1
+        in
+        -f)
+            [ -z "$2" ] && _fail "missing argument for -f"
+           dumptape=$2
+           dump_file=$2
+           shift
+            ;;
+        -L)
+            [ -z "$2" ] && _fail "missing argument for -L"
+           session_label=$2
+           shift
             ;;
        --multi)
+            [ -z "$2" ] && _fail "missing argument for --multi"
            multi=$2
            shift
            ;;
-        -q)
+        --check-quota)
             do_quota_check=true
             ;;
-        -Q)
+        --no-check-quota)
             do_quota_check=false
             ;;
-        -l)
-            [ -z "$2" ] && _error "missing argument for -l"
-           dump_args="$dump_args -l$2"
-           shift
+       -K|-R)
+           restore_args="$restore_args $1"
             ;;
        *)
-            _error "invalid argument to common.dump function: $1"
+            _fail "invalid argument to common.dump function: $1"
             ;;
         esac
        shift
@@ -886,12 +1020,12 @@ _parse_args()
 #
 _do_dump_sub()
 {
-    _parse_args $*
+    _parse_dump_args $*
 
     echo "Dumping to tape..."
     opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
-    echo "xfsdump $opts" | _dir_filter  
-    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $opts" | _dir_filter
+    $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -899,12 +1033,12 @@ _do_dump_sub()
 #
 _do_dump()
 {
-    _parse_args $*
+    _parse_dump_args $*
 
     echo "Dumping to tape..."
     opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
-    echo "xfsdump $opts" | _dir_filter  
-    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $opts" | _dir_filter
+    $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 
@@ -913,13 +1047,13 @@ _do_dump()
 #
 _do_dump_min()
 {
-    _parse_args $*
+    _parse_dump_args $*
 
     echo "Dumping to tape..."
     onemeg=1048576
     opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
-    echo "xfsdump $opts" | _dir_filter  
-    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $opts" | _dir_filter
+    $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 
@@ -928,12 +1062,12 @@ _do_dump_min()
 #
 _do_dump_file()
 {
-    _parse_args $*
+    _parse_dump_args $*
 
     echo "Dumping to file..."
     opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
-    echo "xfsdump $opts" | _dir_filter  
-    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $opts" | _dir_filter
+    $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -941,7 +1075,7 @@ _do_dump_file()
 #
 _do_dump_multi_file()
 {
-    _parse_args "$@"
+    _parse_dump_args $*
 
     multi_args=""
 
@@ -949,21 +1083,20 @@ _do_dump_multi_file()
     while [ $i -lt $multi ]
     do
        multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
-       i=`expr $i + 1`
+       let i=$i+1
     done
 
     echo "Dumping to files..."
     opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
-    echo "xfsdump $opts" | _dir_filter  
-    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $opts" | _dir_filter
+    $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 
 _prepare_restore_dir()
 {
     rm -rf $restore_dir
-    mkdir $restore_dir ||\
-       _error "failed to mkdir $restore_dir"
+    mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
 }
 
 
@@ -983,14 +1116,13 @@ _prepare_restore()
 #
 _do_restore()
 {
-    _parse_args $*
+    _parse_restore_args $*
     _prepare_restore
 
-
     echo "Restoring from tape..."
-    opts="$_restore_debug -f $dumptape  -L $session_label $restore_dir"
-    echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    opts="$_restore_debug$restore_args -f $dumptape  -L $session_label $restore_dir"
+    echo "xfsrestore $opts" | _dir_filter
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -998,14 +1130,14 @@ _do_restore()
 #
 _do_restore_min()
 {
-    _parse_args $*
+    _parse_restore_args $*
     _prepare_restore
 
     echo "Restoring from tape..."
     onemeg=1048576
-    opts="$_restore_debug -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
-    echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
+    echo "xfsrestore $opts" | _dir_filter
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -1013,39 +1145,39 @@ _do_restore_min()
 #
 _do_restore_file()
 {
-    _parse_args $*
+    _parse_restore_args $*
     _prepare_restore_dir
 
     echo "Restoring from file..."
-    opts="$_restore_debug -f $dump_file  -L $session_label $restore_dir"
-    echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    opts="$_restore_debug$restore_args -f $dump_file  -L $session_label $restore_dir"
+    echo "xfsrestore $opts" | _dir_filter
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
 # Cumulative restore from a file
-# Need to specify the dump level e.g. "-l 0"
+# Must call _prepare_restore_dir before the first
+# (and only the first) call to this function.
 #
 _do_restore_file_cum()
 {
-    _parse_args $*
-    if echo $dump_args | grep '\-l0' >/dev/null; then
-       _prepare_restore_dir
-    fi
+    _parse_restore_args $*
 
     echo "Restoring cumumlative from file..."
-    opts="$_restore_debug -f $dump_file -r $restore_dir"
-    echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
+    echo "xfsrestore $opts" | _dir_filter
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 _do_restore_toc()
 {
+    _parse_restore_args $*
+
     echo "Contents of dump ..."
-    opts="$_restore_debug -f $dump_file -t"
+    opts="$_restore_debug$restore_args -f $dump_file -t"
     echo "xfsrestore $opts" | _dir_filter
     cd $SCRATCH_MNT # for IRIX which needs xfs cwd
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
     _check_quota_file |\
     _check_quota_entries |\
     $AWK_PROG 'NF != 1 { print; next }
@@ -1061,7 +1193,7 @@ _do_restore_toc()
 #
 _do_restore_multi_file()
 {
-    _parse_args "$@"
+    _parse_restore_args $*
     _prepare_restore_dir
 
     multi_args=""
@@ -1070,35 +1202,39 @@ _do_restore_multi_file()
     while [ $i -lt $multi ]
     do
        multi_args="$multi_args -f $dump_file.$i"
-       i=`expr $i + 1`
+       let i=$i+1
     done
 
     echo "Restoring from file..."
-    opts="$_restore_debug $multi_args -L $session_label $restore_dir"
-    echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
+    echo "xfsrestore $opts" | _dir_filter
+    $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
+# Pass dump options in $1 and restore options in $2, if required. e.g.:
+#     _do_dump_restore "-o -F" "-R"
+#     _do_dump_restore "" "-R"
 #
 # Use -s as we want to dump and restore to the same xfs partition
 #
 _do_dump_restore()
 {
-    _parse_args $*
+    _parse_dump_args $1
+    _parse_restore_args $2
     _prepare_restore_dir
     echo "xfsdump|xfsrestore ..."
-    restore_opts="$_restore_debug - $restore_dir"
+    restore_opts="$_restore_debug$restore_args - $restore_dir"
     dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
-    echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter  
-    xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
+    echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
+    $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
     _dump_filter <$tmp.dump.mlog
 }
 
 #
 # Compare dumped subdirectory with restored dir
-# using ls -lR.
+# using ls -nR.
 # Thus no contents are compared but permissions, sizes,
 # owners, etc... are.
 #
@@ -1108,11 +1244,11 @@ _ls_compare_sub()
     # verify we got back what we dumped
     #
     echo "Comparing listing of dump directory with restore directory"
-    ls -lR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
-    ls -lR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
+    ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
+    ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
 
-    diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
+    diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
 }
 
 #
@@ -1131,11 +1267,11 @@ _ls_nodate_compare_sub()
     # verify we got back what we dumped
     #
     echo "Comparing listing of dump directory with restore directory"
-    ls -lR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
-    ls -lR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
+    ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
+    ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
     | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
 
-    diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
+    diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
 }
 
 #
@@ -1160,7 +1296,7 @@ _get_eas_on_path()
     # sort |\
 # and this is now the Linux way...
     echo "User names"
-    getfattr --absolute-names -Rh $_path |\
+    getfattr --absolute-names -Rh -m user $_path |\
     perl -wn -e '
        if (m/^# file: (\S+)/) { $file = $1 }
        elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
@@ -1169,6 +1305,18 @@ _get_eas_on_path()
        attr -g $ea_name $file
     done
 
+    if [ "$USE_ATTR_SECURE" = yes ]; then
+       echo "Security names"
+       getfattr --absolute-names -Rh -m security $_path |\
+       perl -wn -e '
+           if (m/^# file: (\S+)/) { $file = $1 }
+           elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+       sort |\
+       while read file ea_name; do
+           attr -g $ea_name $file
+       done
+    fi
+
     echo "Root names"
     getfattr --absolute-names -Rh -m trusted $_path |\
     perl -wn -e '
@@ -1218,18 +1366,18 @@ _diff_compare()
 #
 _dump_inventory()
 {
-    xfsdump $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
+    $XFSDUMP_PROG $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
 }
 
 #
 # Do the xfsinvutil cmd with debug and filters
-# Need to set variable: "$middate" to the invutil date 
+# Need to set variable: "$middate" to the invutil date
 #
 _do_invutil()
 {
     host=`hostname`
     echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
-    xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
+    $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
     | tee -a $here/$seq.full | _invutil_filter
 }
 
@@ -1239,15 +1387,27 @@ _do_invutil()
 #
 _check_quota()
 {
-    usermsg=$1 
-    groupmsg=$2 
+    usermsg=$1
+    groupmsg=$2
+    projectmsg=$3
     uquota=0
-    gquota=0 
+    gquota=0
+    pquota=0
     $here/src/feature -U $SCRATCH_DEV && uquota=1
     $here/src/feature -G $SCRATCH_DEV && gquota=1
-
-    $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v full=$here/$seq.full \
-              -v usermsg="$usermsg" -v groupmsg="$groupmsg" '
+    $here/src/feature -P $SCRATCH_DEV && pquota=1
+
+    $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
+             -v full=$here/$seq.full -v usermsg="$usermsg" \
+             -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
+       $0 ~ projectmsg {
+                       print "Found project quota:", $0 >>full
+                       found_pquota = 1
+                       if (!pquota) {
+                           print "Found extra:", $0
+                       }
+                       next
+       }
        $0 ~ groupmsg {
                        print "Found group quota:", $0 >>full
                        found_gquota = 1
@@ -1267,30 +1427,36 @@ _check_quota()
                        { print }
        END {
                if (uquota && !found_uquota) {
-                   print "Missing", usermsg
+                   print "Missing user quota msg:", usermsg
                }
                if (gquota && !found_gquota) {
-                   print "Missing: ", groupmsg
+                   print "Missing group quota msg:", groupmsg
+               }
+               if (pquota && !found_pquota) {
+                   print "Missing project quota msg:", projectmsg
                }
        }
     '
 }
 
 #
-# xfsrestore: 3 directories and 40 entries processed 
-#   $5 = 40 
-#   num entries needs to be reduced by num quota file(s) 
+# xfsrestore: 3 directories and 40 entries processed
+#   $5 = 40
+#   num entries needs to be reduced by num quota file(s)
 #
 _check_quota_entries()
 {
     uquota=0
-    gquota=0 
+    gquota=0
+    pquota=0
     $here/src/feature -U $SCRATCH_DEV && uquota=1
     $here/src/feature -G $SCRATCH_DEV && gquota=1
-    $AWK_PROG -v uquota=$uquota -v gquota=$gquota '
-       /entries processed/ { 
+    $here/src/feature -P $SCRATCH_DEV && pquota=1
+    $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
+       /entries processed/ {
                if (uquota) $5--
                if (gquota) $5--
+               if (pquota) $5--
        }
        {print}'
 }
@@ -1299,24 +1465,42 @@ _check_quota_entries()
 # Look for:
 # xfsdump: saving user quota information for: SCRATCH_MNT
 # xfsdump: saving group quota information for: SCRATCH_MNT
+# xfsdump: saving project quota information for: SCRATCH_MNT
 # xfsrestore: user quota information written to ...'
 # xfsrestore: group quota information written to ...'
+# xfsrestore: project quota information written to ...'
+#
+# If on IRIX then look for:
+# xfsrestore: use 'edquota' to restore quotas
+# Else look for:
+# xfsrestore: use 'xfs_quota' to restore quotas
 #
 _check_quota_dumprestore()
 {
-   _check_quota 'user quota information' \
-                'group quota information'
+    if [ "$HOSTOS" == "IRIX" ]; then
+       _check_quota 'user quota information' \
+                    'group quota information' \
+                    'project quota information' | \
+       sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
+    else
+       _check_quota 'user quota information' \
+                    'group quota information' \
+                    'project quota information' | \
+       sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
+    fi
 }
 
 #
 # Look for:
 # Only in RESTORE_DIR: xfsdump_quotas
 # Only in RESTORE_DIR: xfsdump_quotas_group
+# Only in RESTORE_DIR: xfsdump_quotas_project
 #
 _check_quota_diff()
 {
    _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
-       'Only in RESTORE_DIR: xfsdump_quotas_group' 
+       'Only in RESTORE_DIR: xfsdump_quotas_group' \
+       'Only in RESTORE_DIR: xfsdump_quotas_proj'
 }
 
 #
@@ -1327,8 +1511,9 @@ _check_quota_diff()
 #
 _check_quota_file()
 {
-   _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group'
+   _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
 }
 
+
 # make sure this script returns success
 /bin/true