clean up scsi_debug module handling
[xfstests-dev.git] / common.dump
1 ##/bin/bash
2 #
3 # Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 #
18 #
19 # Functions useful for xfsdump/xfsrestore tests
20 #
21
22 # --- initializations ---
23 rm -f $here/$seq.full
24
25 if [ -n "$DEBUGDUMP" ]; then
26         _dump_debug=-v4
27         _restore_debug=-v4
28         _invutil_debug=-d
29
30         # Use dump/restore in qa directory (copy them here) for debugging
31         export PATH="$here:$PATH"
32         export XFSDUMP_PROG="`set_prog_path xfsdump`"
33         export XFSRESTORE_PROG="`set_prog_path xfsrestore`"
34         export XFSINVUTIL_PROG="`set_prog_path xfsinvutil`"
35         [ -x $here/xfsdump ]    && echo "Using xfstests' xfsdump for debug"
36         [ -x $here/xfsrestore ] && echo "Using xfstests' xfsrestore for debug"
37         [ -x $here/xfsinvutil ] && echo "Using xfstests' xfsinvutil for debug"
38 fi
39
40 [ "$XFSDUMP_PROG" = "" ]    && _notrun "xfsdump not found"
41 [ "$XFSRESTORE_PROG" = "" ] && _notrun "xfsrestore not found"
42 [ "$XFSINVUTIL_PROG" = "" ] && _notrun "xfsinvutil not found"
43
44 # status returned for not run tests
45 NOTRUNSTS=2
46
47 # name those directories
48 dump_file=$tmp.dumpfile
49 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
50 dump_sdir=dumpdir
51 dump_dir=$SCRATCH_MNT/$dump_sdir
52 restore_sdir=restoredir
53 restore_dir=$SCRATCH_MNT/$restore_sdir
54 multi=3
55 dumptape=$TAPE_DEV
56 media_label="stress_tape_media"
57 session_label="stress_$seq"
58
59 nobody=4 # define this uid/gid as a number
60 do_quota_check=true # do quota check if quotas enabled
61
62 _need_to_be_root
63
64 # install our cleaner
65 trap "_cleanup; exit \$status" 0 1 2 3 15
66
67 # start inventory from a known base - move it aside for test
68 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
69     if [ -d $dir ]; then
70         [ -d $dir.$seq ] && rm -rf $dir.$seq
71         mv $dir $dir.$seq
72     fi
73 done
74
75 have_mtvariable=false
76 [ `uname` = "Linux" ] && have_mtvariable=true
77
78
79 _require_multi_stream()
80 {
81     $XFSDUMP_PROG -JF -f /dev/null -f /dev/null 2> /dev/null |
82     grep -q "too many -f arguments" &&
83     _notrun "xfsdump multi-stream support required"
84 }
85
86 #
87 # do a remote/local mt
88 #
89 _mt()
90 {
91     op=$1
92     if _isrmt; then
93         # REMOTE
94         _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
95
96         if echo $dumptape | grep '@' >/dev/null; then
97             _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
98             _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
99             _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
100             rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
101         else
102             _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
103             rsh -n $_rmthost "mt -t $_rmtdev $op"
104         fi
105     else
106         #LOCAL
107         mt -t $dumptape $op
108     fi
109 }
110
111 _check_onl()
112 {
113     _limit=10
114     i=0
115     while [ $i -lt $_limit ]; do
116         echo "Checking online..." >>$here/$seq.full
117         if _mt status >$tmp.status 2>&1; then
118             break;
119         else
120             sleep 1
121         fi
122         let i=$i+1
123     done
124
125
126     if [ $i -eq $_limit ]; then
127         echo "ERROR: mt -f $dumptape failed"
128         cat $tmp.status
129
130         echo "mt -f $dumptape failed" >$seq.notrun
131         status=$NOTRUNSTS
132         exit
133     fi
134
135
136     if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
137         :
138     else
139         echo "ERROR: $dumptape is not online"
140         cat $tmp.status
141
142         echo "dumptape, $dumptape, is not online" >$seq.notrun
143         status=$NOTRUNSTS
144         exit
145     fi
146 }
147
148 _wait_tape()
149 {
150     echo "Wait for tape, $dumptape, ..." >>$here/$seq.full
151
152     i=0
153     while [ $i -lt 20 ]; do
154         echo "Checking status..." >>$here/$seq.full
155         if _mt status 2>&1 | tee -a $here/$seq.full | egrep -i "onl|ready" >/dev/null; then
156             break;
157         else
158             sleep 1
159         fi
160         let i=$i+1
161     done
162 }
163
164 #
165 # Keep trying so we know we really have rewound
166 #
167 _rewind()
168 {
169     echo "Initiate rewind..." >>$here/$seq.full
170     _wait_tape
171     _mt rewind >/dev/null
172     _wait_tape
173 }
174
175 #
176 # Do a custom erase because:
177 # (i) some machines don't support it
178 # (ii) some machines take forever to do it
179 #
180 _erase_soft()
181 {
182     echo "Erasing tape" | tee -a $here/$seq.full
183     _rewind
184     _mt weof 3
185     _rewind
186 }
187
188 _erase_hard()
189 {
190     echo "Erasing tape" | tee -a $here/$seq.full
191     _mt erase
192 }
193
194 _isrmt()
195 {
196     echo $dumptape | grep ':' >/dev/null
197 }
198
199 #
200 # Get tape ready
201 #
202 _set_variable()
203 {
204     $have_mtvariable || return
205
206     if _isrmt; then
207         :
208     else
209         # LOCAL
210         echo "Put scsi tape driver into variable block size mode"
211         mt -f $dumptape setblk 0
212     fi
213 }
214
215 _require_tape()
216 {
217     dumptape=$1
218
219     if [ -z "$dumptape" -o "@" == "$dumptape" ]; then
220         echo "This test requires a dump tape - none was specified"
221         echo "No dump tape specified" >$seq.notrun
222         status=$NOTRUNSTS
223         exit
224     fi
225
226     _check_onl
227     _set_variable
228 }
229
230 _wipe_fs()
231 {
232     _require_scratch
233
234     _scratch_mkfs_xfs >>$here/$seq.full || _fail "mkfs failed"
235     _scratch_mount >>$here/$seq.full || _fail "mount failed"
236 }
237
238 #
239 # Cleanup created dirs and files
240 # Called by trap
241 #
242 _cleanup()
243 {
244     # Some tests include this before checking _supported_fs xfs
245     # and the sleeps & checks here get annoying
246     if [ "$FSTYP" != "xfs" ]; then
247        return
248     fi
249
250     cd $here
251     rm -f $tmp.*
252
253     if [ -n "$DEBUGDUMP" ]; then
254         # save it for inspection
255         for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
256             [ -d $dir ] || continue
257             tar -cvf $seq.inventory.tar $dir
258             ls -nR $dir >$seq.inventory.ls
259         done
260     fi
261
262     # put inventory dir back
263     for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
264         [ -d $dir.$seq ] || continue
265         rm -rf $dir             # get rid of new one
266         mv $dir.$seq $dir
267     done
268
269     if [ $status -ne $NOTRUNSTS ]; then
270         # Sleep added to stop _check_scratch_fs from complaining that the
271         # scratch_dev is still busy
272         sleep 10
273
274         _check_scratch_fs
275     fi
276 }
277
278 #
279 # ensure that bulkstat data will
280 # match with incore data
281 # by forcing disk data to be written out
282 #
283 _stable_fs()
284 {
285     _saveddir=`pwd`; cd /
286     umount $SCRATCH_MNT >>$here/$seq.full || _fail "unmount failed"
287     _scratch_mount >>$here/$seq.full || _fail "mount failed"
288     cd $_saveddir
289 }
290
291 #
292 # Run fsstress to create a mixture of
293 # files,dirs,links,symlinks
294 #
295 # Pinched from test 013.
296 #
297 _create_dumpdir_stress()
298 {
299     echo "Creating directory system to dump using fsstress."
300
301     _wipe_fs
302
303     _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
304     _count=240
305     rm -rf $dump_dir
306     if ! mkdir $dump_dir; then
307         echo "    failed to mkdir $dump_dir"
308         status=1
309         exit
310     fi
311     echo ""
312     echo "-----------------------------------------------"
313     echo "fsstress : $_param"
314     echo "-----------------------------------------------"
315     if ! $here/ltp/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
316     then
317         echo "    fsstress (count=$_count) returned $? - see $here/$seq.full"
318
319         echo "--------------------------------------"       >>$here/$seq.full
320         echo "output from fsstress:"                        >>$here/$seq.full
321         echo "--------------------------------------"       >>$here/$seq.full
322         cat $tmp.out                                        >>$here/$seq.full
323         status=1
324     fi
325
326     _stable_fs
327 }
328
329 _mk_fillconfig1()
330 {
331     cat <<End-of-File >$tmp.config
332 # pathname      size in bytes   owner   group
333 #
334 small           10      $nobody $nobody
335 big             102400  daemon  sys
336 sub/small       10      bin     bin
337 sub/big         102400  $nobody sys
338 #
339 sub/a           1       $nobody $nobody
340 sub/b           2       $nobody $nobody
341 sub/c           4       $nobody $nobody
342 sub/d           8       $nobody $nobody
343 sub/e           16      $nobody $nobody
344 sub/f           32      $nobody $nobody
345 sub/g           64      $nobody $nobody
346 sub/h           128     $nobody $nobody
347 sub/i           256     $nobody $nobody
348 sub/j           512     $nobody $nobody
349 sub/k           1024    $nobody $nobody
350 sub/l           2048    $nobody $nobody
351 sub/m           4096    $nobody $nobody
352 sub/n           8192    $nobody $nobody
353 #
354 sub/a00         100     $nobody $nobody
355 sub/b00         200     $nobody $nobody
356 sub/c00         400     $nobody $nobody
357 sub/d00         800     $nobody $nobody
358 sub/e00         1600    $nobody $nobody
359 sub/f00         3200    $nobody $nobody
360 sub/g00         6400    $nobody $nobody
361 sub/h00         12800   $nobody $nobody
362 sub/i00         25600   $nobody $nobody
363 sub/j00         51200   $nobody $nobody
364 sub/k00         102400  $nobody $nobody
365 sub/l00         204800  $nobody $nobody
366 sub/m00         409600  $nobody $nobody
367 sub/n00         819200  $nobody $nobody
368 #
369 sub/a000        1000    $nobody $nobody
370 sub/e000        16000   $nobody $nobody
371 sub/h000        128000  $nobody $nobody
372 sub/k000        1024000 $nobody $nobody
373 End-of-File
374 }
375
376 _mk_fillconfig2()
377 {
378     cat <<End-of-File >$tmp.config
379 # pathname      size in bytes
380 #
381 smalll          10      $nobody $nobody
382 biggg           102400  $nobody $nobody
383 sub/smalll      10      $nobody $nobody
384 sub/biggg       102400  $nobody $nobody
385 End-of-File
386 }
387
388 _mk_fillconfig_perm()
389 {
390     # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
391
392     cat <<End-of-File >$tmp.config
393 # pathname      size/dir  user group mode
394 #
395 file_suid       10      $nobody $nobody 04777
396 file_guid       10      $nobody $nobody 02777
397 file_sticky     10      $nobody $nobody 01777
398 file_mix1       10      $nobody $nobody 761
399 file_mix2       10      $nobody $nobody 642
400 dir_suid        d       $nobody $nobody 04777
401 dir_guid        d       $nobody $nobody ugo=rwx,g+s
402 dir_sticky      d       $nobody $nobody 01777
403 dir_mix1        d       $nobody $nobody 761
404 dir_mix2        d       $nobody $nobody 642
405 End-of-File
406 }
407
408 _mk_fillconfig_ea()
409 {
410     cat <<End-of-File >$tmp.config
411 # pathname      size    user    group    perm   name value namespace
412 #
413 smalll          10      $nobody $nobody  777    attr1 some_text   user
414 biggg           102400  $nobody $nobody  777    attr2 some_text2  root
415 sub/smalll      10      $nobody $nobody  777    attr3 some_text3  user
416 sub/biggg       102400  $nobody $nobody  777    attr4 some_text4  root
417 dir             d       $nobody $nobody  777    attr5 dir_text    user
418 #
419 # Add more files so that there are more than the number
420 # of streams.
421 # There are bugs in dump/restore for # non-dir files < # streams
422 # It can be tested in another configuration.
423 # It is a pathalogical case.
424 #
425 sub/a           1       $nobody $nobody
426 sub/b           2       $nobody $nobody
427 sub/c           4       $nobody $nobody
428 sub/d           8       $nobody $nobody
429 sub/e           16      $nobody $nobody
430 sub/f           32      $nobody $nobody
431 sub/g           64      $nobody $nobody
432 sub/h           128     $nobody $nobody
433 sub/i           256     $nobody $nobody
434 sub/j           512     $nobody $nobody
435 sub/k           1024    $nobody $nobody
436 sub/l           2048    $nobody $nobody
437 sub/m           4096    $nobody $nobody
438 sub/n           8192    $nobody $nobody
439 End-of-File
440 }
441
442 #
443 # extended file attribute flags
444 #
445 _mk_fillconfig_xattr()
446 {
447     cat <<End-of-File >$tmp.config
448 # pathname      size    user    group    perm   name
449 #
450 xflag_realtime  10      $nobody $nobody  777    XFS_XFLAG_REALTIME
451 xflag_prealloc  10      $nobody $nobody  777    XFS_XFLAG_PREALLOC
452 xflag_immutable 10      $nobody $nobody  777    XFS_XFLAG_IMMUTABLE
453 xflag_append    10      $nobody $nobody  777    XFS_XFLAG_APPEND
454 xflag_sync      10      $nobody $nobody  777    XFS_XFLAG_SYNC
455 xflag_noatime   10      $nobody $nobody  777    XFS_XFLAG_NOATIME
456 xflag_nodump    10      $nobody $nobody  777    XFS_XFLAG_NODUMP
457 xflag_hasattr   10      $nobody $nobody  777    XFS_XFLAG_HASATTR
458 End-of-File
459 }
460
461 #
462 # Create a bunch of directories/files of different sizes
463 # filled with data.
464 #
465 # Pinched from test 001.
466 #
467 _do_create_dumpdir_fill()
468 {
469     echo "Creating directory system to dump using src/fill."
470
471     mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
472     cd $dump_dir
473
474     $verbose && echo -n "Setup "
475     sed -e '/^#/d' $tmp.config \
476     | while read file nbytes owner group perms ea_name ea_value namespace
477     do
478         if [ $nbytes = "d" ]; then
479             # create a directory
480             dir=$file
481             if [ ! -d $dir ]
482             then
483                 if mkdir $dir
484                 then
485                     :
486                 else
487                     $verbose && echo
488                     echo "Error: cannot mkdir \"$dir\""
489                     exit 1
490                 fi
491             fi
492         else
493             # create a directory/file
494             dir=`dirname $file`
495             if [ "$dir" != "." ]
496             then
497                 if [ ! -d $dir ]
498                 then
499                     if mkdir $dir
500                     then
501                         :
502                     else
503                         $verbose && echo
504                         echo "Error: cannot mkdir \"$dir\""
505                         exit 1
506                     fi
507                 fi
508             fi
509             rm -f $file
510             if $here/src/fill $file $file $nbytes
511             then
512                 :
513             else
514                 $verbose && echo
515                 echo "Error: cannot create \"$file\""
516                 exit 1
517             fi
518         fi
519         if [ -n "$owner" -a -n "$group" ]; then
520             chown $owner.$group $file
521         fi
522         if [ -n "$perms" ]; then
523             chmod $perms $file
524         fi
525
526         # extended attributes (EA)
527         if [ -n "$ea_name" -a -n "$ea_value" ]; then
528             if [ "X$namespace" = "Xroot" ]; then
529                 attr -R -s $ea_name -V $ea_value $file
530             else
531                 attr -s $ea_name -V $ea_value $file
532             fi
533         # extended file attribute flags - no value - NOT EAs
534         elif [ -n "$ea_name" -a -z "$ea_value" ]; then
535             # set the flag
536             # TODO XXX
537             # use xfs_io to send the ioctl
538             :
539         fi
540         $verbose && echo -n "."
541     done
542     $verbose && echo
543
544     cd $here
545 }
546
547 _mk_fillconfig_multi()
548 {
549     _mk_fillconfig1
550     cat <<End-of-File >>$tmp.config
551 # pathname      size in bytes
552 #
553 large000        8874368 $nobody $nobody
554 large111        2582912 $nobody $nobody
555 large222        7825792 $nobody $nobody
556 End-of-File
557 }
558
559 _create_dumpdir_largefile()
560 {
561     _wipe_fs
562     mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
563     _largesize=4294967297
564     _largefile=$dump_dir/largefile
565     echo "dd a largefile at offset $_largesize"
566     POSIXLY_CORRECT=yes \
567     dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
568     _stable_fs
569 }
570
571 _create_dumpdir_fill()
572 {
573     _wipe_fs
574     _mk_fillconfig1
575     _do_create_dumpdir_fill
576     _stable_fs
577 }
578
579 _create_dumpdir_fill2()
580 {
581     _wipe_fs
582     _mk_fillconfig2
583     _do_create_dumpdir_fill
584     _stable_fs
585 }
586
587 _create_dumpdir_fill_perm()
588 {
589     _wipe_fs
590     _mk_fillconfig_perm
591     _do_create_dumpdir_fill
592     _stable_fs
593 }
594
595 _create_dumpdir_fill_ea()
596 {
597     _wipe_fs
598     _mk_fillconfig_ea
599     _do_create_dumpdir_fill
600     _stable_fs
601 }
602
603 #
604 # Create enough files, and a few large enough files, so that
605 # some files are likely to be split across streams.
606 #
607 _create_dumpdir_fill_multi()
608 {
609     _wipe_fs
610     _mk_fillconfig_multi
611     _do_create_dumpdir_fill
612     _stable_fs
613 }
614
615 #
616 # Append a subset of the fill'ed files
617 # So we can see if just these get dumped on an incremental
618 #
619 _append_dumpdir_fill()
620 {
621     cd $dump_dir
622     cat <<End-of-File >$tmp.config
623 # pathname
624 #
625 small
626 sub/big
627 #
628 sub/a
629 sub/c
630 sub/e
631 End-of-File
632     sed -e '/^#/d' $tmp.config \
633     | while read file
634     do
635         echo 'Extra text' >>$file
636     done
637
638     cd $here
639     _stable_fs
640 }
641
642 _do_create_dump_symlinks()
643 {
644     echo "Creating directory system of symlinks to dump."
645
646     mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
647     cd $dump_dir
648
649     $verbose && echo -n "Setup "
650     sed -e '/^#/d' $tmp.config \
651     | while read file nbytes owner group owner2 group2 perms perms2
652     do
653         dir=`dirname $file`
654         if [ "$dir" != "." ]
655         then
656             if [ ! -d $dir ]
657             then
658                 if mkdir $dir
659                 then
660                     :
661                 else
662                     $verbose && echo
663                     echo "Error: cannot mkdir \"$dir\""
664                     exit 1
665                 fi
666             fi
667         fi
668         rm -f $file
669         touch $file
670
671         # Do chmod on symlink using umask.
672         # This won't do the right thing as it subtracts permissions.
673         # However, I don't care, as long as I get some different perms
674         # for testing.
675         if [ -n "$perms2" ]; then
676             omask=`umask`
677             umask $perms2
678         fi
679         ln -s $file $file-link
680         if [ -n "$perms2" ]; then
681             umask $omask
682         fi
683
684         if [ -n "$owner" -a -n "$group" ]; then
685             chown $owner.$group $file
686         fi
687         if [ -n "$owner" -a -n "$group" ]; then
688             chown -h $owner.$group $file-link
689         fi
690         if [ -n "$perms" ]; then
691             chmod $perms $file
692         fi
693         $verbose && echo -n "."
694     done
695     $verbose && echo
696
697     cd $here
698 }
699
700 _mk_symlink_config()
701 {
702     cat <<End-of-File >$tmp.config
703 # path  size    owner1  group1  owner2  group2  perm1   perm2
704 #
705 a       0       $nobody $nobody daemon  sys     124     421
706 b       0       daemon  sys     bin     bin     347     743
707 sub/a   0       bin     bin     $nobody sys     777     777
708 sub/b   0       $nobody sys     $nobody $nobody 367     763
709 End-of-File
710 }
711
712 _create_dumpdir_symlinks()
713 {
714     _wipe_fs
715     _mk_symlink_config
716     _do_create_dump_symlinks
717     _stable_fs
718 }
719
720 #
721 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
722 #
723 _create_hardlinks()
724 {
725     _fname=$1
726     _numlinks=$2
727
728     touch $_fname
729     _j=1
730     while [ $_j -le $_numlinks ]; do
731         _suffix=_h$_j
732         _hardlink=$_fname$_suffix
733         echo "creating hardlink $_hardlink to $_fname"
734         ln $_fname $_hardlink
735         let _j=$_j+1
736     done
737 }
738
739 #
740 # create a set of hardlinks
741 # create hardlinks of form file1, file1_h1 file1_h2 ...
742 # create hardlinks of form file2, file2_h1 file2_h2 ...
743 # create hardlinks of form file3, file3_h1 file3_h2 ...
744 #
745 _create_hardset()
746 {
747     _numsets=$1
748     _i=1
749     while [ $_i -le $_numsets ]; do
750         _create_hardlinks file$_i 5
751         let _i=$_i+1
752     done
753 }
754
755
756 _modify_level()
757 {
758     _level=$1
759     echo "mod level $_level" >$dump_dir/file$_level
760 }
761
762 _create_dumpdir_hardlinks()
763 {
764     _numsets=$1
765     _wipe_fs
766     echo "Creating directory system of hardlinks to incrementally dump."
767
768     mkdir -p $dump_dir || _fail "cannot mkdir \"$dump_dir\""
769     cd $dump_dir
770
771     _create_hardset $_numsets
772
773     cd $here
774     _stable_fs
775 }
776
777 #
778 # Filter for ls
779 # Filter out times and dates on symlinks and char devices.
780 # Filter out size on directories because this can differ
781 # when transitioning to long inode numbers (ie. 64 bits).
782 #
783 _ls_filter()
784 {
785   $AWK_PROG '
786         /^l/ { date = $8; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
787         /^c/ { date = $9; time = $7; sub(date,"DATE"); sub(time,"TIME"); print}
788         /^d/ { size = $5; sub(size,"SIZE"); print}
789         {print}' \
790   | sed -e 's/total [0-9][0-9]*/total TOTAL/'
791 }
792
793 #
794 # Filtering of Irix character hwgraph device names
795 # e.g.
796 # chardev: /hw/node/xtalk/15/pci/0/scsi_ctlr/0/target/1/lun/0/disk/partition/4/char
797 # blkdev:  /dev/dsk/dks0d1s4
798 #
799 _filter_devchar()
800 {
801     $AWK_PROG '
802         /\/hw\/node/ {
803             sub(/\/hw.*scsi_ctlr\//,"/dev/dsk/dks")  # blah blah /dev/dsk/dks0/target/1/....
804             sub(/\/target\//,"d")                    # blah blah /dev/dsk/dks0d1/lun/0/disk.....
805             sub(/\/lun.*partition\//,"s")            # blah blah /dev/dsk/dks0d1s4/char
806             sub(/\/char/,"")                         # blah blah /dev/dsk/dks0d1s4
807         }
808         { print }
809     '
810 }
811
812
813 #
814 # Filter out the non-deterministic dump msgs from
815 # xfsdump and xfsrestore
816 #
817 _dump_filter_main()
818 {
819   _filter_devchar |\
820   sed \
821       -e "s#$XFSDUMP_PROG#xfsdump#"                     \
822       -e "s#$XFSRESTORE_PROG#xfsrestore#"               \
823       -e "s#$XFSINVUTIL_PROG#xfsinvutil#"               \
824       -e "s/`hostname`/HOSTNAME/"                       \
825       -e "s#$SCRATCH_DEV#SCRATCH_DEV#"                  \
826       -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"               \
827       -e "s#$dumptape#TAPE_DEV#"                        \
828       -e "s#$SCRATCH_MNT#SCRATCH_MNT#"                  \
829       -e "s#$dump_file#DUMP_FILE#"                      \
830       -e 's#/var/lib/xfsdump#/var/xfsdump#'             \
831       -e 's/session id:[        ]*[0-9a-f-]*/session id: ID/'  \
832       -e '/filesystem id:[      ]*[0-9a-f-]*/d'         \
833       -e 's/time:[      ].*/time: TIME/'                \
834       -e 's/date:[      ].*/date: DATE/'                \
835       -e 's/dump begun .*/dump begun DATE/'             \
836       -e 's/previously begun .*/previously begun DATE/' \
837       -e 's/[0-9][0-9]* seconds/SECS seconds/'          \
838       -e 's/restore.[0-9][0-9]*/restore.PID/'           \
839       -e 's/ino [0-9][0-9]*/ino INO/g'                  \
840       -e '/stream [0-9]:/s/offset [0-9][0-9]*/offset NUM/g'     \
841       -e '/: dump size/s/[0-9][0-9]*/NUM/'              \
842       -e '/dump size:/s/[0-9][0-9]*/NUM/'               \
843       -e '/dump size per stream:/s/[0-9][0-9]*/NUM/'    \
844       -e 's/\(media file size[   ]*\)[0-9][0-9]*/\1NUM/' \
845       -e 's/\(mfile size:[       ]*\)[0-9][0-9]*/\1NUM/' \
846       -e '/drive[        ]*[0-9][0-9]*:/d'              \
847       -e '/\/dev\/tty/d'                                \
848       -e '/inventory session uuid/d'                    \
849       -e '/ - Running single-threaded/d'                \
850       -e '/Mount point match/d'                         \
851       -e '/^.*I\/O metrics: .*$/d'                      \
852       -e 's/1048576/BLOCKSZ/'                           \
853       -e 's/2097152/BLOCKSZ/'                           \
854       -e 's/(pid[        ]*[1-9][0-9]*)/\(pid PID\)/'   \
855       -e '/version 3\.0/d'                              \
856       -e 's/\/hw\/module.*$/SCRATCH_DEV/'               \
857       -e 's/xfsdump: ino map phase 1: .*/xfsdump: ino map <PHASES>/' \
858       -e '/xfsdump: ino map phase [2]/,1d'              \
859       -e '/xfsdump: ino map phase [3]/,1d'              \
860       -e '/xfsdump: ino map phase [4]/,1d'              \
861       -e '/xfsdump: ino map phase [5]/,1d'              \
862       -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/'                                              \
863       -e 's/\[y\/n\][- ]----------------------*/\[y\/n\]/'              \
864   | perl -ne '
865       if ($_ =~ /(?:Dump|Restore) Summary/) {
866         $skip = 1;
867       } elsif ($_ =~ /(?:Dump|Restore) Status/) {
868         $skip = 0;
869       }
870       print if (! $skip);'
871 }
872
873 _dump_filter()
874 {
875    if $do_quota_check
876    then
877        _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
878    else
879        _dump_filter_main
880    fi
881 }
882
883 _invutil_filter()
884 {
885   _dump_filter_main \
886   | sed \
887         -e 's/UUID[     ]*:[    ][0-9a-f-]*/UUID                :       ID/' \
888         -e 's/TIME OF DUMP[     ]*:.*/TIME OF DUMP      :       TIME/' \
889         -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
890         -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
891
892 }
893
894
895 _dir_filter()
896 {
897   sed \
898     -e "s#$dump_file#DUMP_FILE#g"      \
899     -e "s#$SCRATCH_DEV#SCRATCH_DEV#"        \
900     -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#"    \
901     -e "s#$dumptape#TAPE_DEV#"         \
902     -e "s#$dump_dir#DUMP_DIR#g"       \
903     -e "s#$restore_dir#RESTORE_DIR#g" \
904     -e "s#$SCRATCH_MNT#SCRATCH_MNT#g"       \
905     -e "s#$dump_sdir#DUMP_SUBDIR#g"   \
906     -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
907     -e "s#$$#PID#g" \
908
909 }
910
911 #
912 # Parse xfsdump arguments.
913 # Note: requires a space between option letter and argument
914 #
915 _parse_dump_args()
916 {
917     OPTIND=0
918     dump_args=""
919     while [ $# -gt 0 ]
920     do
921         case $1
922         in
923         -f)
924             [ -z "$2" ] && _fail "missing argument for -f"
925             dumptape=$2
926             dump_file=$2
927             shift
928             ;;
929         -L)
930             [ -z "$2" ] && _fail "missing argument for -L"
931             session_label=$2
932             shift
933             ;;
934         --multi)
935             [ -z "$2" ] && _fail "missing argument for --multi"
936             multi=$2
937             shift
938             ;;
939         --check-quota)
940             do_quota_check=true
941             ;;
942         --no-check-quota)
943             do_quota_check=false
944             ;;
945         -o|-D|-F)
946             dump_args="$dump_args $1"
947             ;;
948         -l|-d)
949             [ -z "$2" ] && _fail "missing argument for $1"
950             dump_args="$dump_args $1$2"
951             shift
952             ;;
953         *)
954             _fail "invalid argument to common.dump function: $1"
955             ;;
956         esac
957         shift
958     done
959 }
960
961 #
962 # Parse xfsrestore arguments.
963 # Note: requires a space between option letter and argument
964 #
965 _parse_restore_args()
966 {
967     OPTIND=0
968     restore_args=""
969     while [ $# -gt 0 ]
970     do
971         case $1
972         in
973         -f)
974             [ -z "$2" ] && _fail "missing argument for -f"
975             dumptape=$2
976             dump_file=$2
977             shift
978             ;;
979         -L)
980             [ -z "$2" ] && _fail "missing argument for -L"
981             session_label=$2
982             shift
983             ;;
984         --multi)
985             [ -z "$2" ] && _fail "missing argument for --multi"
986             multi=$2
987             shift
988             ;;
989         --check-quota)
990             do_quota_check=true
991             ;;
992         --no-check-quota)
993             do_quota_check=false
994             ;;
995         -R)
996             restore_args="$restore_args $1"
997             ;;
998         *)
999             _fail "invalid argument to common.dump function: $1"
1000             ;;
1001         esac
1002         shift
1003     done
1004 }
1005
1006
1007 #
1008 # Dump a subdir
1009 #
1010 _do_dump_sub()
1011 {
1012     _parse_dump_args $*
1013
1014     echo "Dumping to tape..."
1015     opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1016     echo "xfsdump $opts" | _dir_filter
1017     $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1018 }
1019
1020 #
1021 # Do dump to tape
1022 #
1023 _do_dump()
1024 {
1025     _parse_dump_args $*
1026
1027     echo "Dumping to tape..."
1028     opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1029     echo "xfsdump $opts" | _dir_filter
1030     $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1031 }
1032
1033
1034 #
1035 # Do full dump with -m
1036 #
1037 _do_dump_min()
1038 {
1039     _parse_dump_args $*
1040
1041     echo "Dumping to tape..."
1042     onemeg=1048576
1043     opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
1044     echo "xfsdump $opts" | _dir_filter
1045     $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1046 }
1047
1048
1049 #
1050 # Do full dump to file
1051 #
1052 _do_dump_file()
1053 {
1054     _parse_dump_args $*
1055
1056     echo "Dumping to file..."
1057     opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
1058     echo "xfsdump $opts" | _dir_filter
1059     $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1060 }
1061
1062 #
1063 # Do full dump to multiple files
1064 #
1065 _do_dump_multi_file()
1066 {
1067     _parse_dump_args $*
1068
1069     multi_args=""
1070
1071     i=0
1072     while [ $i -lt $multi ]
1073     do
1074         multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
1075         let i=$i+1
1076     done
1077
1078     echo "Dumping to files..."
1079     opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
1080     echo "xfsdump $opts" | _dir_filter
1081     $XFSDUMP_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1082 }
1083
1084
1085 _prepare_restore_dir()
1086 {
1087     rm -rf $restore_dir
1088     mkdir $restore_dir || _fail "failed to mkdir $restore_dir"
1089 }
1090
1091
1092 #
1093 # Get tape ready and restore dir
1094 #
1095 _prepare_restore()
1096 {
1097     _prepare_restore_dir
1098
1099     echo "Rewinding tape"
1100     _rewind
1101 }
1102
1103 #
1104 # Restore the tape into $restore_dir
1105 #
1106 _do_restore()
1107 {
1108     _parse_restore_args $*
1109     _prepare_restore
1110
1111     echo "Restoring from tape..."
1112     opts="$_restore_debug$restore_args -f $dumptape  -L $session_label $restore_dir"
1113     echo "xfsrestore $opts" | _dir_filter
1114     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1115 }
1116
1117 #
1118 # Restore the tape into $restore_dir using -m
1119 #
1120 _do_restore_min()
1121 {
1122     _parse_restore_args $*
1123     _prepare_restore
1124
1125     echo "Restoring from tape..."
1126     onemeg=1048576
1127     opts="$_restore_debug$restore_args -m -b $onemeg -f $dumptape  -L $session_label $restore_dir"
1128     echo "xfsrestore $opts" | _dir_filter
1129     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1130 }
1131
1132 #
1133 # Restore the tape from a dump file
1134 #
1135 _do_restore_file()
1136 {
1137     _parse_restore_args $*
1138     _prepare_restore_dir
1139
1140     echo "Restoring from file..."
1141     opts="$_restore_debug$restore_args -f $dump_file  -L $session_label $restore_dir"
1142     echo "xfsrestore $opts" | _dir_filter
1143     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1144 }
1145
1146 #
1147 # Cumulative restore from a file
1148 # Must call _prepare_restore_dir before the first
1149 # (and only the first) call to this function.
1150 #
1151 _do_restore_file_cum()
1152 {
1153     _parse_restore_args $*
1154
1155     echo "Restoring cumumlative from file..."
1156     opts="$_restore_debug$restore_args -f $dump_file -r $restore_dir"
1157     echo "xfsrestore $opts" | _dir_filter
1158     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1159 }
1160
1161 _do_restore_toc()
1162 {
1163     _parse_restore_args $*
1164
1165     echo "Contents of dump ..."
1166     opts="$_restore_debug$restore_args -f $dump_file -t"
1167     echo "xfsrestore $opts" | _dir_filter
1168     cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1169     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter_main |\
1170     _check_quota_file |\
1171     _check_quota_entries |\
1172     $AWK_PROG 'NF != 1 { print; next }
1173                {files = sprintf("%s\n%s", files, $1)}
1174                 END { print files | "sort" } '
1175     # the above awk code is to alpha sort only the output
1176     # of files (and not the verbose restore msgs)
1177     cd $here # put back
1178 }
1179
1180 #
1181 # Restore the tape from multiple dump files
1182 #
1183 _do_restore_multi_file()
1184 {
1185     _parse_restore_args $*
1186     _prepare_restore_dir
1187
1188     multi_args=""
1189
1190     i=0
1191     while [ $i -lt $multi ]
1192     do
1193         multi_args="$multi_args -f $dump_file.$i"
1194         let i=$i+1
1195     done
1196
1197     echo "Restoring from file..."
1198     opts="$_restore_debug$restore_args $multi_args -L $session_label $restore_dir"
1199     echo "xfsrestore $opts" | _dir_filter
1200     $XFSRESTORE_PROG $opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1201 }
1202
1203 #
1204 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1205 # Pass dump options in $1 and restore options in $2, if required. e.g.:
1206 #     _do_dump_restore "-o -F" "-R"
1207 #     _do_dump_restore "" "-R"
1208 #
1209 # Use -s as we want to dump and restore to the same xfs partition
1210 #
1211 _do_dump_restore()
1212 {
1213     _parse_dump_args $1
1214     _parse_restore_args $2
1215     _prepare_restore_dir
1216     echo "xfsdump|xfsrestore ..."
1217     restore_opts="$_restore_debug$restore_args - $restore_dir"
1218     dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1219     echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1220     $XFSDUMP_PROG $dump_opts 2>$tmp.dump.mlog | $XFSRESTORE_PROG $restore_opts 2>&1 | tee -a $here/$seq.full | _dump_filter
1221     _dump_filter <$tmp.dump.mlog
1222 }
1223
1224 #
1225 # Compare dumped subdirectory with restored dir
1226 # using ls -nR.
1227 # Thus no contents are compared but permissions, sizes,
1228 # owners, etc... are.
1229 #
1230 _ls_compare_sub()
1231 {
1232     #
1233     # verify we got back what we dumped
1234     #
1235     echo "Comparing listing of dump directory with restore directory"
1236     ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter >$tmp.dump_dir
1237     ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1238     | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1239
1240     diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1241 }
1242
1243 #
1244 # filter out the date fields
1245 #
1246 _ls_nodate_filter()
1247 {
1248     $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1249 }
1250
1251 #
1252 # _ls_compare_sub but don't compare dates
1253 _ls_nodate_compare_sub()
1254 {
1255     #
1256     # verify we got back what we dumped
1257     #
1258     echo "Comparing listing of dump directory with restore directory"
1259     ls -nR $dump_dir | tee -a $here/$seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1260     ls -nR $restore_dir/$dump_sdir | tee -a $here/$seq.full | _ls_filter \
1261     | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1262
1263     diff -bcs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1264 }
1265
1266 #
1267 # Compare using recursive diff the files of the dumped
1268 # subdirectory.
1269 # This one will compare the contents.
1270 #
1271 _diff_compare_sub()
1272 {
1273     echo "Comparing dump directory with restore directory"
1274     diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1275 }
1276
1277 _get_eas_on_path()
1278 {
1279     _path=$1
1280
1281 # Tim - this is the IRIX way...
1282     # find $_path -exec attr -l {} \; |\
1283     # awk '{print $9, $2}' |\
1284     # sed 's/["]//g' |\
1285     # sort |\
1286 # and this is now the Linux way...
1287     echo "User names"
1288     getfattr --absolute-names -Rh -m user $_path |\
1289     perl -wn -e '
1290         if (m/^# file: (\S+)/) { $file = $1 }
1291         elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1292     sort |\
1293     while read file ea_name; do
1294         attr -g $ea_name $file
1295     done
1296
1297     if [ "$USE_ATTR_SECURE" = yes ]; then
1298         echo "Security names"
1299         getfattr --absolute-names -Rh -m security $_path |\
1300         perl -wn -e '
1301             if (m/^# file: (\S+)/) { $file = $1 }
1302             elsif (m/^security\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1303         sort |\
1304         while read file ea_name; do
1305             attr -g $ea_name $file
1306         done
1307     fi
1308
1309     echo "Root names"
1310     getfattr --absolute-names -Rh -m trusted $_path |\
1311     perl -wn -e '
1312         if (m/^# file: (\S+)/) { $file = $1 }
1313         elsif (m/^trusted\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1314     sort |\
1315     while read file ea_name; do
1316         attr -R -g $ea_name $file
1317     done
1318 }
1319
1320 #
1321 # Compare the extended attributes of the files/dirs
1322 # b/w the dumped and restore dirs.
1323 #
1324 #
1325 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1326 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1327 #
1328 _diff_compare_eas()
1329 {
1330     echo "Comparing dump directory with restore directory"
1331     echo "Looking at the extended attributes (EAs)"
1332     echo "EAs on dump"
1333     _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1334     echo "EAs on restore"
1335     _get_eas_on_path $restore_dir/$dump_sdir \
1336     | sed -e "s#$restore_sdir\/##" \
1337     | tee $seq.ea2 \
1338     | _dir_filter
1339     diff -s $seq.ea1 $seq.ea2
1340 }
1341
1342
1343 #
1344 # Compare using recursive diff the files of the dumped
1345 # filesystem
1346 #
1347 _diff_compare()
1348 {
1349     echo "Comparing dump directory with restore directory"
1350     diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1351 }
1352
1353 #
1354 # Check out the dump inventory
1355 #
1356 _dump_inventory()
1357 {
1358     $XFSDUMP_PROG $_dump_debug -I | tee -a $here/$seq.full | _dump_filter_main
1359 }
1360
1361 #
1362 # Do the xfsinvutil cmd with debug and filters
1363 # Need to set variable: "$middate" to the invutil date
1364 #
1365 _do_invutil()
1366 {
1367     host=`hostname`
1368     echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$here/$seq.full
1369     $XFSINVUTIL_PROG $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1370     | tee -a $here/$seq.full | _invutil_filter
1371 }
1372
1373 #
1374 # ensure we can find the user quota msg if user quotas are on
1375 # ensure we can find the group quota msg if group quotas are on
1376 #
1377 _check_quota()
1378 {
1379     usermsg=$1
1380     groupmsg=$2
1381     projectmsg=$3
1382     uquota=0
1383     gquota=0
1384     pquota=0
1385     $here/src/feature -U $SCRATCH_DEV && uquota=1
1386     $here/src/feature -G $SCRATCH_DEV && gquota=1
1387     $here/src/feature -P $SCRATCH_DEV && pquota=1
1388
1389     $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota \
1390               -v full=$here/$seq.full -v usermsg="$usermsg" \
1391               -v groupmsg="$groupmsg" -v projectmsg="$projectmsg" '
1392         $0 ~ projectmsg {
1393                         print "Found project quota:", $0 >>full
1394                         found_pquota = 1
1395                         if (!pquota) {
1396                             print "Found extra:", $0
1397                         }
1398                         next
1399         }
1400         $0 ~ groupmsg {
1401                         print "Found group quota:", $0 >>full
1402                         found_gquota = 1
1403                         if (!gquota) {
1404                             print "Found extra:", $0
1405                         }
1406                         next
1407         }
1408         $0 ~ usermsg {
1409                         print "Found user quota:", $0 >>full
1410                         found_uquota = 1
1411                         if (!uquota) {
1412                             print "Found extra:", $0
1413                         }
1414                         next
1415         }
1416                         { print }
1417         END {
1418                 if (uquota && !found_uquota) {
1419                     print "Missing user quota msg:", usermsg
1420                 }
1421                 if (gquota && !found_gquota) {
1422                     print "Missing group quota msg:", groupmsg
1423                 }
1424                 if (pquota && !found_pquota) {
1425                     print "Missing project quota msg:", projectmsg
1426                 }
1427         }
1428     '
1429 }
1430
1431 #
1432 # xfsrestore: 3 directories and 40 entries processed
1433 #   $5 = 40
1434 #   num entries needs to be reduced by num quota file(s)
1435 #
1436 _check_quota_entries()
1437 {
1438     uquota=0
1439     gquota=0
1440     pquota=0
1441     $here/src/feature -U $SCRATCH_DEV && uquota=1
1442     $here/src/feature -G $SCRATCH_DEV && gquota=1
1443     $here/src/feature -P $SCRATCH_DEV && pquota=1
1444     $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v pquota=$pquota '
1445         /entries processed/ {
1446                 if (uquota) $5--
1447                 if (gquota) $5--
1448                 if (pquota) $5--
1449         }
1450         {print}'
1451 }
1452
1453 #
1454 # Look for:
1455 # xfsdump: saving user quota information for: SCRATCH_MNT
1456 # xfsdump: saving group quota information for: SCRATCH_MNT
1457 # xfsdump: saving project quota information for: SCRATCH_MNT
1458 # xfsrestore: user quota information written to ...'
1459 # xfsrestore: group quota information written to ...'
1460 # xfsrestore: project quota information written to ...'
1461 #
1462 # If on IRIX then look for:
1463 # xfsrestore: use 'edquota' to restore quotas
1464 # Else look for:
1465 # xfsrestore: use 'xfs_quota' to restore quotas
1466 #
1467 _check_quota_dumprestore()
1468 {
1469     if [ "$HOSTOS" == "IRIX" ]; then
1470         _check_quota 'user quota information' \
1471                      'group quota information' \
1472                      'project quota information' | \
1473         sed "/xfsrestore:.*use 'edquota' to restore quotas/d"
1474     else
1475         _check_quota 'user quota information' \
1476                      'group quota information' \
1477                      'project quota information' | \
1478         sed "/xfsrestore:.*use 'xfs_quota' to restore quotas/d"
1479     fi
1480 }
1481
1482 #
1483 # Look for:
1484 # Only in RESTORE_DIR: xfsdump_quotas
1485 # Only in RESTORE_DIR: xfsdump_quotas_group
1486 # Only in RESTORE_DIR: xfsdump_quotas_project
1487 #
1488 _check_quota_diff()
1489 {
1490    _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1491         'Only in RESTORE_DIR: xfsdump_quotas_group' \
1492         'Only in RESTORE_DIR: xfsdump_quotas_proj'
1493 }
1494
1495 #
1496 # Look for the quota file in the output
1497 # Ensure that it is there if it should be
1498 # Filter it out so that the output is always the same
1499 # even with no quotas
1500 #
1501 _check_quota_file()
1502 {
1503    _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group' 'xfsdump_quotas_proj'
1504 }
1505
1506
1507 # make sure this script returns success
1508 /bin/true