Add xfsdump support for the security extended attributes namespace.
[xfstests-dev.git] / common.dump
index 6f834908391510193ebef7aaf3dd1680e959f5c6..fa38afb9f2247fb2b005b9a27c752ef873f4b444 100644 (file)
@@ -1,9 +1,9 @@
-##/bin/sh
+#/bin/sh
 
 #
 # Functions useful for xfsdump/xfsrestore tests
 #
-# Copyright (c) 2000 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
@@ -35,7 +35,7 @@
 #
 
 # --- initializations ---
-rm -f $seq.full
+rm -f $here/$seq.full
 
 if [ -n "$DEBUGDUMP" ]; then
   _dump_debug=-v5
@@ -44,26 +44,29 @@ if [ -n "$DEBUGDUMP" ]; then
 fi
  
 # Use dump/restore in qa directory for debugging
-#PATH=".:$PATH"
-#export PATH
+PATH="$here:$PATH"
+export PATH
 #which xfsdump
 #which xfsrestore
+#which xfsinvutil
 
 # status returned for not run tests
 NOTRUNSTS=2
 
 # name those directories
-dump_dir=$SCRATCH_MNT/dump.$$
 dump_file=$tmp.dumpfile
-dump_sdir=dump.$$
-restore_dir=$SCRATCH_MNT/restore.$$
-restore_sdir=restore.$$
-
+# dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
+dump_sdir=dumpdir
+dump_dir=$SCRATCH_MNT/$dump_sdir
+restore_sdir=restoredir
+restore_dir=$SCRATCH_MNT/$restore_sdir
+multi=3
 dumptape=$TAPE_DEV
 media_label="stress_tape_media"
 session_label="stress_$seq"
 
 nobody=4 # define this uid/gid as a number
+do_quota_check=true # do quota check if quotas enabled
 
 _need_to_be_root
 
@@ -71,13 +74,15 @@ _need_to_be_root
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # start inventory from a known base - move it aside for test
-if [ -d /var/xfsdump/inventory ]; then
-    if [ -d /var/xfsdump/inventory.$seq ]; then    
-       rm -rf /var/xfsdump/inventory.$seq
+for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
+    if [ -d $dir ]; then
+       [ -d $dir.$seq ] && rm -rf $dir.$seq
+       mv $dir $dir.$seq
     fi
-    mv /var/xfsdump/inventory /var/xfsdump/inventory.$seq
-fi
+done
 
+have_mtvariable=false
+[ `uname` = "Linux" ] && have_mtvariable=true
 
 #
 # do a remote/local mt
@@ -87,15 +92,15 @@ _mt()
     op=$1
     if _isrmt; then  
        # REMOTE
-       _rmtdev=`echo $dumptape | awk -F: '{print $2}'`
+       _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
 
         if echo $dumptape | grep '@' >/dev/null; then
-           _spec=`echo $dumptape | awk -F: '{print $1}'`
-           _rmtuser=`echo $_spec | awk -F@ '{print $1}'`
-           _rmthost=`echo $_spec | awk -F@ '{print $2}'`
+           _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
+           _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
+           _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
            rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
        else
-           _rmthost=`echo $dumptape | awk -F: '{print $1}'`
+           _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
            rsh -n $_rmthost "mt -t $_rmtdev $op"
        fi
     else
@@ -109,7 +114,7 @@ _check_onl()
     _limit=10
     i=0
     while [ $i -lt $_limit ]; do  
-        echo "Checking online..." >>$seq.full
+        echo "Checking online..." >>$here/$seq.full
        if _mt status >$tmp.status 2>&1; then
            break; 
        else
@@ -143,12 +148,12 @@ _check_onl()
 
 _wait_tape()
 {
-    echo "Wait for tape, $dumptape, ..." >>$seq.full
+    echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
 
     i=0
     while [ $i -lt 20 ]; do  
-        echo "Checking status..." >>$seq.full
-       if _mt status 2>&1 | tee -a $seq.full | egrep -i "onl|ready" >/dev/null; then
+        echo "Checking status..." >>$here/$seq.full
+       if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
            break; 
        else
            sleep 2 
@@ -162,7 +167,7 @@ _wait_tape()
 #
 _rewind()
 {
-    echo "Initiate rewind..." >>$seq.full
+    echo "Initiate rewind..." >>$here/$seq.full
     _wait_tape
     _mt rewind >/dev/null
     _wait_tape
@@ -175,7 +180,7 @@ _rewind()
 #
 _erase_soft()
 {
-    echo "Erasing tape" | tee -a $seq.full
+    echo "Erasing tape" | tee -a $here/$seq.full
     _rewind
     _mt weof 3
     _rewind
@@ -183,7 +188,7 @@ _erase_soft()
 
 _erase_hard()
 {
-    echo "Erasing tape" | tee -a $seq.full
+    echo "Erasing tape" | tee -a $here/$seq.full
     _mt erase
 }
 
@@ -197,6 +202,8 @@ _isrmt()
 #
 _set_variable()
 {
+    $have_mtvariable || return
+
     if _isrmt; then
        :
     else
@@ -221,23 +228,12 @@ _require_tape()
     _set_variable
 }
 
-_error()
-{
-    echo "Error: $*" | tee -a $seq.full
-    echo "(see $seq.full for details)"
-    status=1
-    exit
-}
-
 _wipe_fs()
 {
     _require_scratch
 
-    mkfs -t xfs -f $SCRATCH_DEV >>$seq.full  ||\
-       _error "mkfs failed"
-      
-    mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$seq.full ||\
-       _error "mount failed"
+    _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
+    _scratch_mount >>$here/$seq.full || _fail "mount failed"
 }
 
 # 
@@ -250,42 +246,52 @@ _cleanup()
     rm -f $tmp.*
 
     if [ -n "$DEBUGDUMP" ]; then
-        # save it for inspection
-       tar -zcvf $seq.inventory.tgz /var/xfsdump/inventory
-       ls -lR /var/xfsdump/inventory >$seq.inventory.ls
+       # save it for inspection
+       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
+       done
     fi
 
     # put inventory dir back
-    if [ -d /var/xfsdump/inventory.$seq ]; then
-       rm -rf /var/xfsdump/inventory # get rid of new one
-       mv /var/xfsdump/inventory.$seq /var/xfsdump/inventory
-    fi
+    for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
+       [ -d $dir.$seq ] || continue
+       rm -rf $dir             # get rid of new one
+       mv $dir.$seq $dir
+    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
 }
 
+#
+# ensure that bulkstat data will
+# match with incore data
+# by forcing disk data to be written out
+#
 _stable_fs()
 {
-#    umount $SCRATCH_MNT >/dev/null 
-#    mount $SCRATCH_MNT >/dev/null
-    sync; sync; sleep 15
+    _saveddir=`pwd`; cd /
+    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
 
@@ -301,14 +307,14 @@ _create_dumpdir_stress()
     echo "-----------------------------------------------"
     echo "fsstress : $_param"
     echo "-----------------------------------------------"
-    if ! $here/src/fsstress $_param $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 $seq.full"
+        echo "    fsstress (count=$_count) returned $? - see $here/$seq.full"
         
-        echo "--------------------------------------"       >>$here/$seq.full
-        echo "output from fsstress:"                        >>$here/$seq.full
-        echo "--------------------------------------"       >>$here/$seq.full
-        cat $tmp.out                                        >>$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
         status=1
     fi
 
@@ -376,6 +382,8 @@ End-of-File
 
 _mk_fillconfig_perm()
 {
+    # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
+
     cat <<End-of-File >$tmp.config
 # pathname     size/dir  user group mode
 #
@@ -385,13 +393,66 @@ file_sticky       10      $nobody $nobody 01777
 file_mix1      10      $nobody $nobody 761
 file_mix2      10      $nobody $nobody 642
 dir_suid       d       $nobody $nobody 04777
-dir_guid       d       $nobody $nobody 02777
+dir_guid       d       $nobody $nobody ugo=rwx,g+s
 dir_sticky     d       $nobody $nobody 01777
 dir_mix1       d       $nobody $nobody 761
 dir_mix2       d       $nobody $nobody 642
 End-of-File
 }
 
+_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 
+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
+dir            d       $nobody $nobody  777    attr5 dir_text    user
+#
+# Add more files so that there are more than the number
+# of streams.
+# There are bugs in dump/restore for # non-dir files < # streams
+# It can be tested in another configuration.
+# It is a pathalogical case.
+#
+sub/a          1       $nobody $nobody
+sub/b          2       $nobody $nobody
+sub/c          4       $nobody $nobody
+sub/d          8       $nobody $nobody
+sub/e          16      $nobody $nobody
+sub/f          32      $nobody $nobody
+sub/g          64      $nobody $nobody
+sub/h          128     $nobody $nobody
+sub/i          256     $nobody $nobody
+sub/j          512     $nobody $nobody
+sub/k          1024    $nobody $nobody
+sub/l          2048    $nobody $nobody
+sub/m          4096    $nobody $nobody
+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.
@@ -402,18 +463,12 @@ _do_create_dumpdir_fill()
 {
     echo "Creating directory system to dump using src/fill."
 
-    if mkdir -p $dump_dir
-    then
-       :
-    else
-       echo "Error: cannot mkdir \"$dump_dir\""
-       exit 1
-    fi
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     cd $dump_dir
 
     $verbose && echo -n "Setup "
     sed -e '/^#/d' $tmp.config \
-    | while read file nbytes owner group perms
+    | while read file nbytes owner group perms ea_name ea_value namespace
     do
        if [ $nbytes = "d" ]; then
            # create a directory
@@ -462,6 +517,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
     $verbose && echo
@@ -469,6 +538,17 @@ _do_create_dumpdir_fill()
     cd $here
 }
 
+_create_dumpdir_largefile()
+{
+    _wipe_fs
+    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()
 {
@@ -494,6 +574,13 @@ _create_dumpdir_fill_perm()
     _stable_fs
 }      
 
+_create_dumpdir_fill_ea()
+{
+    _wipe_fs
+    _mk_fillconfig_ea
+    _do_create_dumpdir_fill
+    _stable_fs
+}      
 
 
 #
@@ -520,19 +607,14 @@ End-of-File
     done
 
     cd $here
+    _stable_fs
 }
 
 _do_create_dump_symlinks()
 {
     echo "Creating directory system of symlinks to dump."
 
-    if mkdir -p $dump_dir
-    then
-       :
-    else
-       echo "Error: cannot mkdir \"$dump_dir\""
-       exit 1
-    fi
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
     cd $dump_dir
 
     $verbose && echo -n "Setup "
@@ -606,15 +688,77 @@ _create_dumpdir_symlinks()
     _stable_fs
 }      
 
+#
+# create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
+#
+_create_hardlinks()
+{
+    _fname=$1  
+    _numlinks=$2
+
+    touch $_fname
+    _j=1
+    while [ $_j -le $_numlinks ]; do
+        _suffix=_h$_j
+       _hardlink=$_fname$_suffix
+       echo "creating hardlink $_hardlink to $_fname"
+       ln $_fname $_hardlink
+       _j=`expr $_j + 1`
+    done
+}
+
+#
+# create a set of hardlinks
+# create hardlinks of form file1, file1_h1 file1_h2 ...
+# create hardlinks of form file2, file2_h1 file2_h2 ...
+# create hardlinks of form file3, file3_h1 file3_h2 ...
+#
+_create_hardset()
+{
+    _numsets=$1
+    _i=1
+    while [ $_i -le $_numsets ]; do
+       _create_hardlinks file$_i 5
+       _i=`expr $_i + 1`
+    done
+}
+
+
+_modify_level()
+{
+    _level=$1
+    echo "mod level $_level" >$dump_dir/file$_level
+}
+
+_create_dumpdir_hardlinks()
+{
+    _numsets=$1
+    _wipe_fs
+    echo "Creating directory system of hardlinks to incrementally dump."
+
+    mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
+    cd $dump_dir
+
+    _create_hardset $_numsets
+
+    cd $here
+    _stable_fs
+}
+
 #
 # Filter for ls
-# Filter out dates on symlinks
+# Filter out 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}
+  $AWK_PROG '
+        /^l/ { date = $8; sub(date,"DATE"); print}
+        /^c/ { date = $9; sub(date,"DATE"); print}
+        /^d/ { size = $5; sub(size,"SIZE"); print}
         {print}' \
-  | sed -e 's/total [0-9][0-9]*/total TOTAL/'
+  | sed -e 's/total [0-9][0-9]*/total TOTAL/' -e 's/[ \t][ \t]*/ /g'
 }
 
 
@@ -622,30 +766,58 @@ _ls_filter()
 # Filter out the non-deterministic dump msgs from
 # xfsdump and xfsrestore
 #
-_dump_filter()
+_dump_filter_main()
 {
   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 '/: dump size/s/[1-9][0-9]*/NUM/'     \
-      -e '/dump size:/s/[1-9][0-9]*/NUM/'      \
-      -e '/media file size/s/[1-9][0-9]*/NUM/' \
+      -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/\(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\)/' \
+  | perl -ne '
+      if ($_ =~ /(?:Dump|Restore) Summary/) {
+        $skip = 1;
+      } elsif ($_ =~ /(?:Dump|Restore) Status/) {
+        $skip = 0;
+      }
+      print if (! $skip);'
+}
 
+_dump_filter()
+{
+   if $do_quota_check
+   then
+       _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
+   else
+       _dump_filter_main
+   fi
 }
 
 _invutil_filter()
 {
-  _dump_filter \
+  _dump_filter_main \
   | sed \
        -e 's/UUID[     ]*:[    ][0-9a-f-]*/UUID                :       ID/' \
        -e 's/TIME OF DUMP[     ]*:.*/TIME OF DUMP      :       TIME/' \
@@ -654,46 +826,70 @@ _invutil_filter()
 
 }
 
+
 _dir_filter()
 {
   sed \
     -e "s#$dump_file#DUMP_FILE#"      \
     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
+    -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"    \
     -e "s#$dumptape#TAPE_DEV#"         \
     -e "s#$dump_dir#DUMP_DIR#g"       \
     -e "s#$restore_dir#RESTORE_DIR#g" \
     -e "s#$SCRATCH_MNT#SCRATCH_MNT#g"       \
     -e "s#$dump_sdir#DUMP_SUBDIR#g"   \
     -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
+    -e "s#$$#PID#g" \
 
 }
 
+#
+# Note: requires a space between option letter and argument 
+#
 _parse_args()
 {
     OPTIND=0
     dump_args=""
-    while getopts "f:FL:o" c $*
+    while [ $# -gt 0 ]
     do
-        case $c
+        case $1
         in
-        f)
-            [ -z "$OPTARG" ] && _error "missing argument for -f"
-           dumptape=$OPTARG    
+        -f)
+            [ -z "$2" ] && _fail "missing argument for -f"
+           dumptape=$2 
+           shift
             ;;
-        L)
-            [ -z "$OPTARG" ] && _error "missing argument for -L"
-           session_label=$OPTARG       
+        -L)
+            [ -z "$2" ] && _fail "missing argument for -L"
+           session_label=$2
+           shift
             ;;
-       o)
+       -o)
            dump_args="$dump_args -o"
             ;;
-       F)
+       -F)
            dump_args="$dump_args -F"
             ;;
-       \?)
-            _error "invalid argument"
+       --multi)
+           multi=$2
+           shift
+           ;;
+        -q)
+            do_quota_check=true
+            ;;
+        -Q)
+            do_quota_check=false
+            ;;
+        -l)
+            [ -z "$2" ] && _fail "missing argument for -l"
+           dump_args="$dump_args -l$2"
+           shift
+            ;;
+       *)
+            _fail "invalid argument to common.dump function: $1"
             ;;
         esac
+       shift
     done
 }
 
@@ -708,20 +904,20 @@ _do_dump_sub()
     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 $seq.full | _dump_filter
+    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
-# Do full level 0 dump
+# Do dump to tape
 #
 _do_dump()
 {
     _parse_args $*
 
     echo "Dumping to tape..."
-    opts="$_dump_debug$dump_args -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
+    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 $seq.full | _dump_filter
+    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 
@@ -736,44 +932,50 @@ _do_dump_min()
     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 $seq.full | _dump_filter
+    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
+
 #
-# Do level 1 incremental dump
+# Do full dump to file
 #
-_do_dump_incremental()
+_do_dump_file()
 {
     _parse_args $*
 
-    echo "Dumping incrementally to tape..."
-    opts="$_dump_debug$dump_args -l1 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
+    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 $seq.full | _dump_filter
+    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
-# Do full dump to file
+# Do full dump to multiple files
 #
-_do_dump_file()
+_do_dump_multi_file()
 {
-    _parse_args $*
+    _parse_args "$@"
 
-    echo "Dumping to file..."
-    opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
+    multi_args=""
+
+    i=0
+    while [ $i -lt $multi ]
+    do
+       multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
+       i=`expr $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 $seq.full | _dump_filter
+    xfsdump $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 
 _prepare_restore_dir()
 {
     rm -rf $restore_dir
-    if ! mkdir $restore_dir; then
-       echo "    failed to mkdir $restore_dir"
-       status=1
-       exit
-    fi
+    mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
 }
 
 
@@ -798,9 +1000,9 @@ _do_restore()
 
 
     echo "Restoring from tape..."
-    opts="$_restore_debug$dump_args -f $dumptape  -L $session_label $restore_dir"
+    opts="$_restore_debug -f $dumptape  -L $session_label $restore_dir"
     echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
+    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -813,9 +1015,9 @@ _do_restore_min()
 
     echo "Restoring from tape..."
     onemeg=1048576
-    opts="$_restore_debug$dump_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
+    opts="$_restore_debug -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
     echo "xfsrestore $opts" | _dir_filter  
-    xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
+    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -827,9 +1029,66 @@ _do_restore_file()
     _prepare_restore_dir
 
     echo "Restoring from file..."
-    opts="$_restore_debug$dumpargs -f $dump_file  -L $session_label $restore_dir"
+    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
+}
+
+#
+# Cumulative restore from a file
+# Need to specify the dump level e.g. "-l 0"
+#
+_do_restore_file_cum()
+{
+    _parse_args $*
+    if echo $dump_args | grep '\-l0' >/dev/null; then
+       _prepare_restore_dir
+    fi
+
+    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
+}
+
+_do_restore_toc()
+{
+    echo "Contents of dump ..."
+    opts="$_restore_debug -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 |\
+    _check_quota_file |\
+    _check_quota_entries |\
+    $AWK_PROG 'NF != 1 { print; next }
+              {files = sprintf("%s\n%s", files, $1)}
+               END { print files | "sort" } '
+    # the above awk code is to alpha sort only the output
+    # of files (and not the verbose restore msgs)
+    cd $here # put back
+}
+
+#
+# Restore the tape from multiple dump files
+#
+_do_restore_multi_file()
+{
+    _parse_args "$@"
+    _prepare_restore_dir
+
+    multi_args=""
+
+    i=0
+    while [ $i -lt $multi ]
+    do
+       multi_args="$multi_args -f $dump_file.$i"
+       i=`expr $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 $seq.full | _dump_filter
+    xfsrestore $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
 }
 
 #
@@ -845,7 +1104,7 @@ _do_dump_restore()
     restore_opts="$_restore_debug - $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 $seq.full | _dump_filter
+    xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
     _dump_filter <$tmp.dump.mlog
 }
 
@@ -861,13 +1120,35 @@ _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 $seq.full | _ls_filter >$tmp.dump_dir
-    ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
+    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 \
     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
 
     diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
 }
 
+#
+# filter out the date fields
+#
+_ls_nodate_filter()
+{
+    $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
+}
+
+#
+# _ls_compare_sub but don't compare dates
+_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_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
+
+    diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
+}
 
 #
 # Compare using recursive diff the files of the dumped
@@ -880,6 +1161,72 @@ _diff_compare_sub()
     diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
 }
 
+_get_eas_on_path()
+{
+    _path=$1
+
+# Tim - this is the IRIX way...
+    # find $_path -exec attr -l {} \; |\
+    # awk '{print $9, $2}' |\
+    # sed 's/["]//g' |\
+    # sort |\
+# and this is now the Linux way...
+    echo "User names"
+    getfattr --absolute-names -Rh -m user $_path |\
+    perl -wn -e '
+       if (m/^# file: (\S+)/) { $file = $1 }
+       elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+    sort |\
+    while read file ea_name; do
+       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 '
+       if (m/^# file: (\S+)/) { $file = $1 }
+       elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
+    sort |\
+    while read file ea_name; do
+       attr -R -g $ea_name $file
+    done
+}
+
+#
+# Compare the extended attributes of the files/dirs
+# b/w the dumped and restore dirs.
+#
+#
+# Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
+# Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
+#
+_diff_compare_eas()
+{
+    echo "Comparing dump directory with restore directory"
+    echo "Looking at the extended attributes (EAs)"
+    echo "EAs on dump"
+    _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
+    echo "EAs on restore"
+    _get_eas_on_path $restore_dir/$dump_sdir \
+    | sed -e "s#$restore_sdir\/##" \
+    | tee $seq.ea2 \
+    | _dir_filter
+    diff -s $seq.ea1 $seq.ea2
+}
+
+
 #
 # Compare using recursive diff the files of the dumped
 # filesystem
@@ -887,7 +1234,7 @@ _diff_compare_sub()
 _diff_compare()
 {
     echo "Comparing dump directory with restore directory"
-    diff -rs $SCRATCH_MNT $restore_dir | _dir_filter
+    diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
 }
 
 #
@@ -895,7 +1242,7 @@ _diff_compare()
 #
 _dump_inventory()
 {
-    xfsdump $_dump_debug -I | tee -a $seq.full | _dump_filter 
+    xfsdump $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
 }
 
 #
@@ -905,9 +1252,106 @@ _dump_inventory()
 _do_invutil()
 {
     host=`hostname`
-    echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seq.full
-    xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT "$middate" $* \
-    | tee -a $seq.full | _invutil_filter
+    echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
+    xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
+    | tee -a $here/$seq.full | _invutil_filter
+}
+
+#
+# ensure we can find the user quota msg if user quotas are on
+# ensure we can find the group quota msg if group quotas are on
+#
+_check_quota()
+{
+    usermsg=$1 
+    groupmsg=$2 
+    uquota=0
+    gquota=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" '
+       $0 ~ groupmsg {
+                       print "Found group quota:", $0 >>full
+                       found_gquota = 1
+                       if (!gquota) {
+                           print "Found extra:", $0
+                       }
+                       next
+       }
+       $0 ~ usermsg {
+                       print "Found user quota:", $0 >>full
+                       found_uquota = 1
+                       if (!uquota) {
+                           print "Found extra:", $0
+                       }
+                       next
+       }
+                       { print }
+       END {
+               if (uquota && !found_uquota) {
+                   print "Missing: ", usermsg
+               }
+               if (gquota && !found_gquota) {
+                   print "Missing: ", groupmsg
+               }
+       }
+    '
+}
+
+#
+# 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 
+    $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/ { 
+               if (uquota) $5--
+               if (gquota) $5--
+       }
+       {print}'
+}
+
+#
+# Look for:
+# xfsdump: saving user quota information for: SCRATCH_MNT
+# xfsdump: saving group quota information for: SCRATCH_MNT
+# xfsrestore: user quota information written to ...'
+# xfsrestore: group quota information written to ...'
+#
+_check_quota_dumprestore()
+{
+   _check_quota 'user quota information' \
+                'group quota information'
+}
+
+#
+# Look for:
+# Only in RESTORE_DIR: xfsdump_quotas
+# Only in RESTORE_DIR: xfsdump_quotas_group
+#
+_check_quota_diff()
+{
+   _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
+       'Only in RESTORE_DIR: xfsdump_quotas_group' 
+}
+
+#
+# Look for the quota file in the output
+# Ensure that it is there if it should be
+# Filter it out so that the output is always the same
+# even with no quotas
+#
+_check_quota_file()
+{
+   _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group'
 }
 
 # make sure this script returns success