Update for extra output from src/acl_test.
[xfstests-dev.git] / common.dump
1 ##/bin/sh
2
3 #
4 # Functions useful for xfsdump/xfsrestore tests
5 #
6 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
7
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of version 2 of the GNU General Public License as
10 # published by the Free Software Foundation.
11
12 # This program is distributed in the hope that it would be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
16 # Further, this software is distributed without any warranty that it is
17 # free of the rightful claim of any third person regarding infringement
18 # or the like.  Any license provided herein, whether implied or
19 # otherwise, applies only to this software file.  Patent licenses, if
20 # any, provided herein do not apply to combinations of this program with
21 # other software, or any other product whatsoever.
22
23 # You should have received a copy of the GNU General Public License along
24 # with this program; if not, write the Free Software Foundation, Inc., 59
25 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
26
27 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
28 # Mountain View, CA  94043, or:
29
30 # http://www.sgi.com 
31
32 # For further information regarding this notice, see: 
33
34 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 #
36
37 # --- initializations ---
38 rm -f $seq.full
39
40 if [ -n "$DEBUGDUMP" ]; then
41   _dump_debug=-v5
42   _restore_debug=-v5
43   _invutil_debug=-d
44 fi
45  
46 # Use dump/restore in qa directory for debugging
47 #PATH=".:$PATH"
48 #export PATH
49 #which xfsdump
50 #which xfsrestore
51
52 # status returned for not run tests
53 NOTRUNSTS=2
54
55 # name those directories
56 dump_dir=$SCRATCH_MNT/dump.$$
57 dump_file=$tmp.dumpfile
58 dump_sdir=dump.$$
59 restore_dir=$SCRATCH_MNT/restore.$$
60 restore_sdir=restore.$$
61
62 dumptape=$TAPE_DEV
63 media_label="stress_tape_media"
64 session_label="stress_$seq"
65
66 nobody=4 # define this uid/gid as a number
67
68 _need_to_be_root
69
70 # install our cleaner
71 trap "_cleanup; exit \$status" 0 1 2 3 15
72
73 # start inventory from a known base - move it aside for test
74 if [ -d /var/xfsdump/inventory ]; then
75     if [ -d /var/xfsdump/inventory.$seq ]; then    
76         rm -rf /var/xfsdump/inventory.$seq
77     fi
78     mv /var/xfsdump/inventory /var/xfsdump/inventory.$seq
79 fi
80
81
82 #
83 # do a remote/local mt
84 #
85 _mt()
86 {
87     op=$1
88     if _isrmt; then  
89         # REMOTE
90         _rmtdev=`echo $dumptape | awk -F: '{print $2}'`
91
92         if echo $dumptape | grep '@' >/dev/null; then
93             _spec=`echo $dumptape | awk -F: '{print $1}'`
94             _rmtuser=`echo $_spec | awk -F@ '{print $1}'`
95             _rmthost=`echo $_spec | awk -F@ '{print $2}'`
96             rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
97         else
98             _rmthost=`echo $dumptape | awk -F: '{print $1}'`
99             rsh -n $_rmthost "mt -t $_rmtdev $op"
100         fi
101     else
102         #LOCAL
103         mt -t $dumptape $op
104     fi
105 }
106
107 _check_onl()
108 {
109     _limit=10
110     i=0
111     while [ $i -lt $_limit ]; do  
112         echo "Checking online..." >>$seq.full
113         if _mt status >$tmp.status 2>&1; then
114             break; 
115         else
116             sleep 2 
117         fi
118         i=`expr $i + 1`
119     done
120
121
122     if [ $i -eq $_limit ]; then
123         echo "ERROR: mt -f $dumptape failed"
124         cat $tmp.status
125
126         echo "mt -f $dumptape failed" >$seq.notrun 
127         status=$NOTRUNSTS
128         exit
129     fi 
130
131
132     if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
133         :
134     else
135         echo "ERROR: $dumptape is not online"
136         cat $tmp.status
137
138         echo "dumptape, $dumptape, is not online" >$seq.notrun 
139         status=$NOTRUNSTS
140         exit
141     fi
142 }
143
144 _wait_tape()
145 {
146     echo "Wait for tape, $dumptape, ..." >>$seq.full
147
148     i=0
149     while [ $i -lt 20 ]; do  
150         echo "Checking status..." >>$seq.full
151         if _mt status 2>&1 | tee -a $seq.full | egrep -i "onl|ready" >/dev/null; then
152             break; 
153         else
154             sleep 2 
155         fi
156         i=`expr $i + 1`
157     done
158 }
159
160 #
161 # Keep trying so we know we really have rewound
162 #
163 _rewind()
164 {
165     echo "Initiate rewind..." >>$seq.full
166     _wait_tape
167     _mt rewind >/dev/null
168     _wait_tape
169 }
170
171 #
172 # Do a custom erase because: 
173 # (i) some machines don't support it
174 # (ii) some machines take forever to do it
175 #
176 _erase_soft()
177 {
178     echo "Erasing tape" | tee -a $seq.full
179     _rewind
180     _mt weof 3
181     _rewind
182 }
183
184 _erase_hard()
185 {
186     echo "Erasing tape" | tee -a $seq.full
187     _mt erase
188 }
189
190 _isrmt()
191 {
192     echo $dumptape | grep ':' >/dev/null
193 }
194
195 #
196 # Get tape ready
197 #
198 _set_variable()
199 {
200     if _isrmt; then
201         :
202     else
203         # LOCAL
204         echo "Put scsi tape driver into variable block size mode"
205         mt -f $dumptape setblk 0
206     fi  
207 }
208
209 _require_tape()
210 {
211     dumptape=$1
212
213     if [ -z "$dumptape" ]; then
214         echo "This test requires a dump tape - none was specified"
215         echo "No dump tape specified" >$seq.notrun 
216         status=$NOTRUNSTS
217         exit
218     fi
219
220     _check_onl
221     _set_variable
222 }
223
224 _error()
225 {
226     echo "Error: $*" | tee -a $seq.full
227     echo "(see $seq.full for details)"
228     status=1
229     exit
230 }
231
232 _wipe_fs()
233 {
234     _require_scratch
235
236     mkfs -t xfs -f $SCRATCH_DEV >>$seq.full  ||\
237         _error "mkfs failed"
238       
239     mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$seq.full ||\
240         _error "mount failed"
241 }
242
243
244 # Cleanup created dirs and files
245 # Called by trap
246 #
247 _cleanup()
248 {
249     cd $here
250     rm -f $tmp.*
251
252     if [ -n "$DEBUGDUMP" ]; then
253         # save it for inspection
254         tar -zcvf $seq.inventory.tgz /var/xfsdump/inventory
255         ls -lR /var/xfsdump/inventory >$seq.inventory.ls
256     fi
257
258     # put inventory dir back
259     if [ -d /var/xfsdump/inventory.$seq ]; then
260         rm -rf /var/xfsdump/inventory # get rid of new one
261         mv /var/xfsdump/inventory.$seq /var/xfsdump/inventory
262     fi
263
264     if [ $status -ne $NOTRUNSTS ]; then
265         # Sleep added to stop _check_fs from complaining that the
266         # scratch_dev is still busy
267         sleep 10
268
269         _check_fs $SCRATCH_DEV
270     fi
271 }
272
273 _stable_fs()
274 {
275 #    umount $SCRATCH_MNT >/dev/null 
276 #    mount $SCRATCH_MNT >/dev/null
277     sync; sync; sleep 15
278 }
279
280 #
281 # Run src/fsstress to create a mixture of 
282 # files,dirs,links,symlinks
283 #
284 # Pinched from test 013.
285 #
286 _create_dumpdir_stress()
287 {
288     echo "Creating directory system to dump using src/fsstress."
289
290     _wipe_fs
291     _setup_seq_out
292
293     _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
294     _count=200
295     rm -rf $dump_dir
296     if ! mkdir $dump_dir; then
297         echo "    failed to mkdir $dump_dir"
298         status=1
299         exit
300     fi
301     echo ""
302     echo "-----------------------------------------------"
303     echo "fsstress : $_param"
304     echo "-----------------------------------------------"
305     if ! $here/src/fsstress $_param $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
306     then
307         echo "    fsstress (count=$_count) returned $? - see $seq.full"
308         
309         echo "--------------------------------------"       >>$here/$seq.full
310         echo "output from fsstress:"                        >>$here/$seq.full
311         echo "--------------------------------------"       >>$here/$seq.full
312         cat $tmp.out                                        >>$here/$seq.full
313         status=1
314     fi
315
316     _stable_fs
317 }
318
319 _mk_fillconfig1()
320 {
321     cat <<End-of-File >$tmp.config
322 # pathname      size in bytes   owner   group
323 #
324 small           10      $nobody $nobody
325 big             102400  daemon  sys
326 sub/small       10      bin     bin
327 sub/big         102400  $nobody sys
328 #
329 sub/a           1       $nobody $nobody
330 sub/b           2       $nobody $nobody
331 sub/c           4       $nobody $nobody
332 sub/d           8       $nobody $nobody
333 sub/e           16      $nobody $nobody
334 sub/f           32      $nobody $nobody
335 sub/g           64      $nobody $nobody
336 sub/h           128     $nobody $nobody
337 sub/i           256     $nobody $nobody
338 sub/j           512     $nobody $nobody
339 sub/k           1024    $nobody $nobody
340 sub/l           2048    $nobody $nobody
341 sub/m           4096    $nobody $nobody
342 sub/n           8192    $nobody $nobody
343 #
344 sub/a00         100     $nobody $nobody
345 sub/b00         200     $nobody $nobody
346 sub/c00         400     $nobody $nobody
347 sub/d00         800     $nobody $nobody
348 sub/e00         1600    $nobody $nobody
349 sub/f00         3200    $nobody $nobody
350 sub/g00         6400    $nobody $nobody
351 sub/h00         12800   $nobody $nobody
352 sub/i00         25600   $nobody $nobody
353 sub/j00         51200   $nobody $nobody
354 sub/k00         102400  $nobody $nobody
355 sub/l00         204800  $nobody $nobody
356 sub/m00         409600  $nobody $nobody
357 sub/n00         819200  $nobody $nobody
358 #
359 sub/a000        1000    $nobody $nobody
360 sub/e000        16000   $nobody $nobody
361 sub/h000        128000  $nobody $nobody
362 sub/k000        1024000 $nobody $nobody
363 End-of-File
364 }
365
366 _mk_fillconfig2()
367 {
368     cat <<End-of-File >$tmp.config
369 # pathname      size in bytes
370 #
371 smalll          10      $nobody $nobody
372 biggg           102400  $nobody $nobody
373 sub/smalll      10      $nobody $nobody
374 sub/biggg       102400  $nobody $nobody
375 End-of-File
376 }
377
378 _mk_fillconfig_perm()
379 {
380     cat <<End-of-File >$tmp.config
381 # pathname      size/dir  user group mode
382 #
383 file_suid       10      $nobody $nobody 04777
384 file_guid       10      $nobody $nobody 02777
385 file_sticky     10      $nobody $nobody 01777
386 file_mix1       10      $nobody $nobody 761
387 file_mix2       10      $nobody $nobody 642
388 dir_suid        d       $nobody $nobody 04777
389 dir_guid        d       $nobody $nobody 02777
390 dir_sticky      d       $nobody $nobody 01777
391 dir_mix1        d       $nobody $nobody 761
392 dir_mix2        d       $nobody $nobody 642
393 End-of-File
394 }
395
396 #
397 # Create a bunch of directories/files of different sizes
398 # filled with data.
399 #
400 # Pinched from test 001.
401 #
402 _do_create_dumpdir_fill()
403 {
404     echo "Creating directory system to dump using src/fill."
405
406     if mkdir -p $dump_dir
407     then
408         :
409     else
410         echo "Error: cannot mkdir \"$dump_dir\""
411         exit 1
412     fi
413     cd $dump_dir
414
415     $verbose && echo -n "Setup "
416     sed -e '/^#/d' $tmp.config \
417     | while read file nbytes owner group perms
418     do
419         if [ $nbytes = "d" ]; then
420             # create a directory
421             dir=$file   
422             if [ ! -d $dir ]
423             then
424                 if mkdir $dir
425                 then
426                     :
427                 else
428                     $verbose && echo
429                     echo "Error: cannot mkdir \"$dir\""
430                     exit 1
431                 fi
432             fi
433         else
434             # create a directory/file
435             dir=`dirname $file`
436             if [ "$dir" != "." ]
437             then
438                 if [ ! -d $dir ]
439                 then
440                     if mkdir $dir
441                     then
442                         :
443                     else
444                         $verbose && echo
445                         echo "Error: cannot mkdir \"$dir\""
446                         exit 1
447                     fi
448                 fi
449             fi
450             rm -f $file
451             if $here/src/fill $file $file $nbytes
452             then
453                 :
454             else
455                 $verbose && echo
456                 echo "Error: cannot create \"$file\""
457                 exit 1
458             fi
459         fi
460         if [ -n "$owner" -a -n "$group" ]; then
461             chown $owner.$group $file
462         fi
463         if [ -n "$perms" ]; then
464             chmod $perms $file
465         fi
466         $verbose && echo -n "."
467     done
468     $verbose && echo
469
470     cd $here
471 }
472
473
474 _create_dumpdir_fill()
475 {
476     _wipe_fs
477     _setup_seq_out
478     _mk_fillconfig1
479     _do_create_dumpdir_fill
480     _stable_fs
481 }       
482
483 _create_dumpdir_fill2()
484 {
485     _wipe_fs
486     _setup_seq_out
487     _mk_fillconfig2
488     _do_create_dumpdir_fill
489     _stable_fs
490 }       
491
492 _create_dumpdir_fill_perm()
493 {
494     _wipe_fs
495     _setup_seq_out
496     _mk_fillconfig_perm
497     _do_create_dumpdir_fill
498     _stable_fs
499 }       
500
501
502
503 #
504 # Append a subset of the fill'ed files
505 # So we can see if just these get dumped on an incremental
506 #
507 _append_dumpdir_fill()
508 {
509     cd $dump_dir
510     cat <<End-of-File >$tmp.config
511 # pathname
512 #
513 small   
514 sub/big 
515 #
516 sub/a
517 sub/c
518 sub/e
519 End-of-File
520     sed -e '/^#/d' $tmp.config \
521     | while read file
522     do
523         echo 'Extra text' >>$file
524     done
525
526     cd $here
527 }
528
529 _do_create_dump_symlinks()
530 {
531     echo "Creating directory system of symlinks to dump."
532
533     if mkdir -p $dump_dir
534     then
535         :
536     else
537         echo "Error: cannot mkdir \"$dump_dir\""
538         exit 1
539     fi
540     cd $dump_dir
541
542     $verbose && echo -n "Setup "
543     sed -e '/^#/d' $tmp.config \
544     | while read file nbytes owner group owner2 group2 perms perms2
545     do
546         dir=`dirname $file`
547         if [ "$dir" != "." ]
548         then
549             if [ ! -d $dir ]
550             then
551                 if mkdir $dir
552                 then
553                     :
554                 else
555                     $verbose && echo
556                     echo "Error: cannot mkdir \"$dir\""
557                     exit 1
558                 fi
559             fi
560         fi
561         rm -f $file
562         touch $file
563
564         # Do chmod on symlink using umask.
565         # This won't do the right thing as it subtracts permissions.
566         # However, I don't care, as long as I get some different perms
567         # for testing.
568         if [ -n "$perms2" ]; then
569             omask=`umask`
570             umask $perms2
571         fi
572         ln -s $file $file-link
573         if [ -n "$perms2" ]; then
574             umask $omask        
575         fi
576
577         if [ -n "$owner" -a -n "$group" ]; then
578             chown $owner.$group $file
579         fi
580         if [ -n "$owner" -a -n "$group" ]; then
581             chown -h $owner.$group $file-link
582         fi
583         if [ -n "$perms" ]; then
584             chmod $perms $file
585         fi
586         $verbose && echo -n "."
587     done
588     $verbose && echo
589
590     cd $here
591 }
592
593 _mk_symlink_config()
594 {
595     cat <<End-of-File >$tmp.config
596 # path  size    owner1  group1  owner2  group2  perm1   perm2 
597 #
598 a       0       $nobody $nobody daemon  sys     124     421
599 b       0       daemon  sys     bin     bin     347     743
600 sub/a   0       bin     bin     $nobody sys     777     777
601 sub/b   0       $nobody sys     $nobody $nobody 367     763
602 End-of-File
603 }
604
605 _create_dumpdir_symlinks()
606 {
607     _wipe_fs
608     _setup_seq_out
609     _mk_symlink_config
610     _do_create_dump_symlinks
611     _stable_fs
612 }       
613
614 #
615 # Filter for ls
616 # Filter out dates on symlinks
617 #
618 _ls_filter()
619 {
620   $AWK_PROG '/^l/ { date = $8; sub(date,"DATE"); print}
621         {print}' \
622   | sed -e 's/total [0-9][0-9]*/total TOTAL/'
623 }
624
625
626
627 # Filter out the non-deterministic dump msgs from
628 # xfsdump and xfsrestore
629 #
630 _dump_filter()
631 {
632   sed \
633       -e "s/`hostname`/HOSTNAME/"   \
634       -e "s#$SCRATCH_DEV#SCRATCH_DEV#"    \
635       -e "s#$dumptape#TAPE_DEV#"    \
636       -e "s#$SCRATCH_MNT#SCRATCH_MNT#"    \
637       -e "s#$dump_file#DUMP_FILE#"  \
638       -e 's/id:[        ]*[0-9a-f-]*/id: ID/'  \
639       -e 's/time:[      ].*/time: TIME/'       \
640       -e 's/date:[      ].*/date: DATE/'       \
641       -e 's/dump begun .*/dump begun DATE/'    \
642       -e 's/[0-9][0-9]* seconds/SECS seconds/' \
643       -e 's/restore.[0-9][0-9]*/restore.PID/' \
644       -e 's/ino [0-9][0-9]*/ino INO/' \
645       -e '/: dump size/s/[1-9][0-9]*/NUM/'     \
646       -e '/dump size:/s/[1-9][0-9]*/NUM/'      \
647       -e '/media file size/s/[1-9][0-9]*/NUM/' \
648       -e '/mfile size:[  ]*/s/[1-9][0-9]*/NUM/' \
649       -e '/\/dev\/tty/d' \
650       -e '/inventory session uuid/d' \
651
652 }
653
654 _invutil_filter()
655 {
656   _dump_filter \
657   | sed \
658         -e 's/UUID[     ]*:[    ][0-9a-f-]*/UUID                :       ID/' \
659         -e 's/TIME OF DUMP[     ]*:.*/TIME OF DUMP      :       TIME/' \
660         -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
661         -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
662
663 }
664
665 _dir_filter()
666 {
667   sed \
668     -e "s#$dump_file#DUMP_FILE#"      \
669     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
670     -e "s#$dumptape#TAPE_DEV#"         \
671     -e "s#$dump_dir#DUMP_DIR#g"       \
672     -e "s#$restore_dir#RESTORE_DIR#g" \
673     -e "s#$SCRATCH_MNT#SCRATCH_MNT#g"       \
674     -e "s#$dump_sdir#DUMP_SUBDIR#g"   \
675     -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
676
677 }
678
679 _parse_args()
680 {
681     OPTIND=0
682     dump_args=""
683     while getopts "f:FL:o" c $*
684     do
685         case $c
686         in
687         f)
688             [ -z "$OPTARG" ] && _error "missing argument for -f"
689             dumptape=$OPTARG    
690             ;;
691         L)
692             [ -z "$OPTARG" ] && _error "missing argument for -L"
693             session_label=$OPTARG       
694             ;;
695         o)
696             dump_args="$dump_args -o"
697             ;;
698         F)
699             dump_args="$dump_args -F"
700             ;;
701         \?)
702             _error "invalid argument"
703             ;;
704         esac
705     done
706 }
707
708
709 #
710 # Dump a subdir
711 #
712 _do_dump_sub()
713 {
714     _parse_args $*
715
716     echo "Dumping to tape..."
717     opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
718     echo "xfsdump $opts" | _dir_filter  
719     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
720 }
721
722 #
723 # Do full level 0 dump
724 #
725 _do_dump()
726 {
727     _parse_args $*
728
729     echo "Dumping to tape..."
730     opts="$_dump_debug$dump_args -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
731     echo "xfsdump $opts" | _dir_filter  
732     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
733 }
734
735
736 #
737 # Do full dump with -m
738 #
739 _do_dump_min()
740 {
741     _parse_args $*
742
743     echo "Dumping to tape..."
744     onemeg=1048576
745     opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
746     echo "xfsdump $opts" | _dir_filter  
747     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
748 }
749
750 #
751 # Do level 1 incremental dump
752 #
753 _do_dump_incremental()
754 {
755     _parse_args $*
756
757     echo "Dumping incrementally to tape..."
758     opts="$_dump_debug$dump_args -l1 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
759     echo "xfsdump $opts" | _dir_filter  
760     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
761 }
762
763 #
764 # Do full dump to file
765 #
766 _do_dump_file()
767 {
768     _parse_args $*
769
770     echo "Dumping to file..."
771     opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
772     echo "xfsdump $opts" | _dir_filter  
773     xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
774 }
775
776
777 _prepare_restore_dir()
778 {
779     rm -rf $restore_dir
780     if ! mkdir $restore_dir; then
781         echo "    failed to mkdir $restore_dir"
782         status=1
783         exit
784     fi
785 }
786
787
788 #
789 # Get tape ready and restore dir
790 #
791 _prepare_restore()
792 {
793     _prepare_restore_dir
794
795     echo "Rewinding tape"
796     _rewind
797 }
798
799 #
800 # Restore the tape into $restore_dir
801 #
802 _do_restore()
803 {
804     _parse_args $*
805     _prepare_restore
806
807
808     echo "Restoring from tape..."
809     opts="$_restore_debug$dump_args -f $dumptape  -L $session_label $restore_dir"
810     echo "xfsrestore $opts" | _dir_filter  
811     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
812 }
813
814 #
815 # Restore the tape into $restore_dir using -m
816 #
817 _do_restore_min()
818 {
819     _parse_args $*
820     _prepare_restore
821
822     echo "Restoring from tape..."
823     onemeg=1048576
824     opts="$_restore_debug$dump_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
825     echo "xfsrestore $opts" | _dir_filter  
826     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
827 }
828
829 #
830 # Restore the tape from a dump file
831 #
832 _do_restore_file()
833 {
834     _parse_args $*
835     _prepare_restore_dir
836
837     echo "Restoring from file..."
838     opts="$_restore_debug$dumpargs -f $dump_file  -L $session_label $restore_dir"
839     echo "xfsrestore $opts" | _dir_filter  
840     xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
841 }
842
843 #
844 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
845 #
846 # Use -s as we want to dump and restore to the same xfs partition
847 #
848 _do_dump_restore()
849 {
850     _parse_args $*
851     _prepare_restore_dir
852     echo "xfsdump|xfsrestore ..."
853     restore_opts="$_restore_debug - $restore_dir"
854     dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
855     echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter  
856     xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $seq.full | _dump_filter
857     _dump_filter <$tmp.dump.mlog
858 }
859
860 #
861 # Compare dumped subdirectory with restored dir
862 # using ls -lR.
863 # Thus no contents are compared but permissions, sizes,
864 # owners, etc... are.
865 #
866 _ls_compare_sub()
867 {
868     #
869     # verify we got back what we dumped
870     #
871     echo "Comparing listing of dump directory with restore directory"
872     ls -lR $dump_dir | tee -a $seq.full | _ls_filter >$tmp.dump_dir
873     ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
874     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
875
876     diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
877 }
878
879
880 #
881 # Compare using recursive diff the files of the dumped
882 # subdirectory.
883 # This one will compare the contents.
884 #
885 _diff_compare_sub()
886 {
887     echo "Comparing dump directory with restore directory"
888     diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
889 }
890
891 #
892 # Compare using recursive diff the files of the dumped
893 # filesystem
894 #
895 _diff_compare()
896 {
897     echo "Comparing dump directory with restore directory"
898     diff -rs $SCRATCH_MNT $restore_dir | _dir_filter
899 }
900
901 #
902 # Check out the dump inventory
903 #
904 _dump_inventory()
905 {
906     xfsdump $_dump_debug -I | tee -a $seq.full | _dump_filter 
907 }
908
909 #
910 # Do the xfsinvutil cmd with debug and filters
911 # Need to set variable: "$middate" to the invutil date 
912 #
913 _do_invutil()
914 {
915     host=`hostname`
916     echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seq.full
917     xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT "$middate" $* \
918     | tee -a $seq.full | _invutil_filter
919 }
920
921 # make sure this script returns success
922 /bin/true