4 # Functions useful for xfsdump/xfsrestore tests
6 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
27 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
28 # Mountain View, CA 94043, or:
32 # For further information regarding this notice, see:
34 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 # --- initializations ---
40 if [ -n "$DEBUGDUMP" ]; then
46 # Use dump/restore in qa directory for debugging
53 # status returned for not run tests
56 # name those directories
57 dump_file=$tmp.dumpfile
58 # dump_file=$here/dumpfile #TEMP OVERRIDE DUMP FILE
60 dump_dir=$SCRATCH_MNT/$dump_sdir
61 restore_sdir=restoredir
62 restore_dir=$SCRATCH_MNT/$restore_sdir
65 media_label="stress_tape_media"
66 session_label="stress_$seq"
68 nobody=4 # define this uid/gid as a number
69 do_quota_check=true # do quota check if quotas enabled
74 trap "_cleanup; exit \$status" 0 1 2 3 15
76 # start inventory from a known base - move it aside for test
77 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
79 [ -d $dir.$seq ] && rm -rf $dir.$seq
84 # remove this when xfstests irix/linux port done
85 if [ "X$XFS_HOST_OS" = "Xirix" ]
96 # do a remote/local mt
103 _rmtdev=`echo $dumptape | $AWK_PROG -F: '{print $2}'`
105 if echo $dumptape | grep '@' >/dev/null; then
106 _spec=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
107 _rmtuser=`echo $_spec | $AWK_PROG -F@ '{print $1}'`
108 _rmthost=`echo $_spec | $AWK_PROG -F@ '{print $2}'`
109 rsh -n -l $_rmtuser $_rmthost "mt -t $_rmtdev $op"
111 _rmthost=`echo $dumptape | $AWK_PROG -F: '{print $1}'`
112 rsh -n $_rmthost "mt -t $_rmtdev $op"
124 while [ $i -lt $_limit ]; do
125 echo "Checking online..." >>$seq.full
126 if _mt status >$tmp.status 2>&1; then
135 if [ $i -eq $_limit ]; then
136 echo "ERROR: mt -f $dumptape failed"
139 echo "mt -f $dumptape failed" >$seq.notrun
145 if egrep -i 'onl|ready' $tmp.status | grep -iv 'not ready' >/dev/null; then
148 echo "ERROR: $dumptape is not online"
151 echo "dumptape, $dumptape, is not online" >$seq.notrun
159 echo "Wait for tape, $dumptape, ..." >>$seq.full
162 while [ $i -lt 20 ]; do
163 echo "Checking status..." >>$seq.full
164 if _mt status 2>&1 | tee -a $seq.full | egrep -i "onl|ready" >/dev/null; then
174 # Keep trying so we know we really have rewound
178 echo "Initiate rewind..." >>$seq.full
180 _mt rewind >/dev/null
185 # Do a custom erase because:
186 # (i) some machines don't support it
187 # (ii) some machines take forever to do it
191 echo "Erasing tape" | tee -a $seq.full
199 echo "Erasing tape" | tee -a $seq.full
205 echo $dumptape | grep ':' >/dev/null
213 $have_mtvariable || return
219 echo "Put scsi tape driver into variable block size mode"
220 mt -f $dumptape setblk 0
228 if [ -z "$dumptape" ]; then
229 echo "This test requires a dump tape - none was specified"
230 echo "No dump tape specified" >$seq.notrun
241 echo "Error: $*" | tee -a $seq.full
242 echo "(see $seq.full for details)"
251 mkfs_xfs $MKFS_OPTS $SCRATCH_DEV>>$seq.full ||\
254 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$seq.full ||\
255 _error "mount failed"
259 # Cleanup created dirs and files
267 if [ -n "$DEBUGDUMP" ]; then
268 # save it for inspection
269 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
270 [ -d $dir ] || continue
271 tar -cvf $seq.inventory.tar $dir
272 ls -lR $dir >$seq.inventory.ls
276 # put inventory dir back
277 for dir in /var/xfsdump/inventory /var/lib/xfsdump/inventory; do
278 [ -d $dir.$seq ] || continue
279 rm -rf $dir # get rid of new one
283 if [ $status -ne $NOTRUNSTS ]; then
284 # Sleep added to stop _check_fs from complaining that the
285 # scratch_dev is still busy
288 _check_fs $SCRATCH_DEV
293 # ensure that bulkstat data will
294 # match with incore data
295 # by forcing disk data to be written out
299 _saveddir=`pwd`; cd /
300 umount $SCRATCH_MNT >>$seq.full ||\
301 _error "unmount failed"
302 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >>$seq.full ||\
303 _error "mount failed"
308 # Run src/fsstress to create a mixture of
309 # files,dirs,links,symlinks
311 # Pinched from test 013.
313 _create_dumpdir_stress()
315 echo "Creating directory system to dump using src/fsstress."
319 _param="-f link=10 -f creat=10 -f mkdir=10 -f truncate=5 -f symlink=10"
322 if ! mkdir $dump_dir; then
323 echo " failed to mkdir $dump_dir"
328 echo "-----------------------------------------------"
329 echo "fsstress : $_param"
330 echo "-----------------------------------------------"
331 if ! $here/src/fsstress $_param -s 1 $FSSTRESS_AVOID -n $_count -d $dump_dir >$tmp.out 2>&1
333 echo " fsstress (count=$_count) returned $? - see $seq.full"
335 echo "--------------------------------------" >>$here/$seq.full
336 echo "output from fsstress:" >>$here/$seq.full
337 echo "--------------------------------------" >>$here/$seq.full
338 cat $tmp.out >>$here/$seq.full
347 cat <<End-of-File >$tmp.config
348 # pathname size in bytes owner group
350 small 10 $nobody $nobody
351 big 102400 daemon sys
353 sub/big 102400 $nobody sys
355 sub/a 1 $nobody $nobody
356 sub/b 2 $nobody $nobody
357 sub/c 4 $nobody $nobody
358 sub/d 8 $nobody $nobody
359 sub/e 16 $nobody $nobody
360 sub/f 32 $nobody $nobody
361 sub/g 64 $nobody $nobody
362 sub/h 128 $nobody $nobody
363 sub/i 256 $nobody $nobody
364 sub/j 512 $nobody $nobody
365 sub/k 1024 $nobody $nobody
366 sub/l 2048 $nobody $nobody
367 sub/m 4096 $nobody $nobody
368 sub/n 8192 $nobody $nobody
370 sub/a00 100 $nobody $nobody
371 sub/b00 200 $nobody $nobody
372 sub/c00 400 $nobody $nobody
373 sub/d00 800 $nobody $nobody
374 sub/e00 1600 $nobody $nobody
375 sub/f00 3200 $nobody $nobody
376 sub/g00 6400 $nobody $nobody
377 sub/h00 12800 $nobody $nobody
378 sub/i00 25600 $nobody $nobody
379 sub/j00 51200 $nobody $nobody
380 sub/k00 102400 $nobody $nobody
381 sub/l00 204800 $nobody $nobody
382 sub/m00 409600 $nobody $nobody
383 sub/n00 819200 $nobody $nobody
385 sub/a000 1000 $nobody $nobody
386 sub/e000 16000 $nobody $nobody
387 sub/h000 128000 $nobody $nobody
388 sub/k000 1024000 $nobody $nobody
394 cat <<End-of-File >$tmp.config
395 # pathname size in bytes
397 smalll 10 $nobody $nobody
398 biggg 102400 $nobody $nobody
399 sub/smalll 10 $nobody $nobody
400 sub/biggg 102400 $nobody $nobody
404 _mk_fillconfig_perm()
406 # dir_guid: ugo=rwx,g+s on dir is for IRIX chmod(1)
408 cat <<End-of-File >$tmp.config
409 # pathname size/dir user group mode
411 file_suid 10 $nobody $nobody 04777
412 file_guid 10 $nobody $nobody 02777
413 file_sticky 10 $nobody $nobody 01777
414 file_mix1 10 $nobody $nobody 761
415 file_mix2 10 $nobody $nobody 642
416 dir_suid d $nobody $nobody 04777
417 dir_guid d $nobody $nobody ugo=rwx,g+s
418 dir_sticky d $nobody $nobody 01777
419 dir_mix1 d $nobody $nobody 761
420 dir_mix2 d $nobody $nobody 642
426 cat <<End-of-File >$tmp.config
427 # pathname size user group perm name value
429 smalll 10 $nobody $nobody 777 attr1 some_text
430 biggg 102400 $nobody $nobody 777 attr2 some_text2
431 sub/smalll 10 $nobody $nobody 777 attr3 some_text3
432 sub/biggg 102400 $nobody $nobody 777 attr4 some_text4
433 dir d $nobody $nobody 777 attr5 dir_text
435 # Add more files so that there are more than the number
437 # There are bugs in dump/restore for # non-dir files < # streams
438 # It can be tested in another configuration.
439 # It is a pathalogical case.
441 sub/a 1 $nobody $nobody
442 sub/b 2 $nobody $nobody
443 sub/c 4 $nobody $nobody
444 sub/d 8 $nobody $nobody
445 sub/e 16 $nobody $nobody
446 sub/f 32 $nobody $nobody
447 sub/g 64 $nobody $nobody
448 sub/h 128 $nobody $nobody
449 sub/i 256 $nobody $nobody
450 sub/j 512 $nobody $nobody
451 sub/k 1024 $nobody $nobody
452 sub/l 2048 $nobody $nobody
453 sub/m 4096 $nobody $nobody
454 sub/n 8192 $nobody $nobody
459 # Create a bunch of directories/files of different sizes
462 # Pinched from test 001.
464 _do_create_dumpdir_fill()
466 echo "Creating directory system to dump using src/fill."
468 mkdir -p $dump_dir ||\
469 _error "cannot mkdir \"$dump_dir\""
472 $verbose && echo -n "Setup "
473 sed -e '/^#/d' $tmp.config \
474 | while read file nbytes owner group perms ea_name ea_value
476 if [ $nbytes = "d" ]; then
486 echo "Error: cannot mkdir \"$dir\""
491 # create a directory/file
502 echo "Error: cannot mkdir \"$dir\""
508 if $here/src/fill $file $file $nbytes
513 echo "Error: cannot create \"$file\""
517 if [ -n "$owner" -a -n "$group" ]; then
518 chown $owner.$group $file
520 if [ -n "$perms" ]; then
523 if [ -n "$ea_name" -a -n "$ea_value" ]; then
524 attr -s $ea_name -V $ea_value $file
526 $verbose && echo -n "."
533 _create_dumpdir_largefile()
536 mkdir -p $dump_dir ||\
537 _error "cannot mkdir \"$dump_dir\""
538 _largesize=4294967297
539 _largefile=$dump_dir/largefile
540 echo "dd a largefile at offset $_largesize"
541 dd if=/dev/zero of=$_largefile bs=1 seek=$_largesize count=10 2>&1
545 _create_dumpdir_fill()
549 _do_create_dumpdir_fill
553 _create_dumpdir_fill2()
557 _do_create_dumpdir_fill
561 _create_dumpdir_fill_perm()
565 _do_create_dumpdir_fill
569 _create_dumpdir_fill_ea()
573 _do_create_dumpdir_fill
579 # Append a subset of the fill'ed files
580 # So we can see if just these get dumped on an incremental
582 _append_dumpdir_fill()
585 cat <<End-of-File >$tmp.config
595 sed -e '/^#/d' $tmp.config \
598 echo 'Extra text' >>$file
605 _do_create_dump_symlinks()
607 echo "Creating directory system of symlinks to dump."
609 mkdir -p $dump_dir ||\
610 _error "cannot mkdir \"$dump_dir\""
613 $verbose && echo -n "Setup "
614 sed -e '/^#/d' $tmp.config \
615 | while read file nbytes owner group owner2 group2 perms perms2
627 echo "Error: cannot mkdir \"$dir\""
635 # Do chmod on symlink using umask.
636 # This won't do the right thing as it subtracts permissions.
637 # However, I don't care, as long as I get some different perms
639 if [ -n "$perms2" ]; then
643 ln -s $file $file-link
644 if [ -n "$perms2" ]; then
648 if [ -n "$owner" -a -n "$group" ]; then
649 chown $owner.$group $file
651 if [ -n "$owner" -a -n "$group" ]; then
652 chown -h $owner.$group $file-link
654 if [ -n "$perms" ]; then
657 $verbose && echo -n "."
666 cat <<End-of-File >$tmp.config
667 # path size owner1 group1 owner2 group2 perm1 perm2
669 a 0 $nobody $nobody daemon sys 124 421
670 b 0 daemon sys bin bin 347 743
671 sub/a 0 bin bin $nobody sys 777 777
672 sub/b 0 $nobody sys $nobody $nobody 367 763
676 _create_dumpdir_symlinks()
680 _do_create_dump_symlinks
685 # create hardlinks of form $_fname, $_fname_h1 $_fname_h2 ...
694 while [ $_j -le $_numlinks ]; do
696 _hardlink=$_fname$_suffix
697 echo "creating hardlink $_hardlink to $_fname"
698 ln $_fname $_hardlink
704 # create a set of hardlinks
705 # create hardlinks of form file1, file1_h1 file1_h2 ...
706 # create hardlinks of form file2, file2_h1 file2_h2 ...
707 # create hardlinks of form file3, file3_h1 file3_h2 ...
713 while [ $_i -le $_numsets ]; do
714 _create_hardlinks file$_i 5
723 echo "mod level $_level" >$dump_dir/file$_level
726 _create_dumpdir_hardlinks()
730 echo "Creating directory system of hardlinks to incrementally dump."
732 mkdir -p $dump_dir ||\
733 _error "cannot mkdir \"$dump_dir\""
736 _create_hardset $_numsets
744 # Filter out dates on symlinks and char devices
749 /^l/ { date = $8; sub(date,"DATE"); print}
750 /^c/ { date = $9; sub(date,"DATE"); print}
752 | sed -e 's/total [0-9][0-9]*/total TOTAL/'
757 # Filter out the non-deterministic dump msgs from
758 # xfsdump and xfsrestore
763 -e "s/`hostname`/HOSTNAME/" \
764 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
765 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
766 -e "s#$dumptape#TAPE_DEV#" \
767 -e "s#$SCRATCH_MNT#SCRATCH_MNT#" \
768 -e "s#$dump_file#DUMP_FILE#" \
769 -e 's#/var/lib/xfsdump#/var/xfsdump#' \
770 -e 's/id:[ ]*[0-9a-f-]*/id: ID/' \
771 -e 's/time:[ ].*/time: TIME/' \
772 -e 's/date:[ ].*/date: DATE/' \
773 -e 's/dump begun .*/dump begun DATE/' \
774 -e 's/[0-9][0-9]* seconds/SECS seconds/' \
775 -e 's/restore.[0-9][0-9]*/restore.PID/' \
776 -e 's/ino [0-9][0-9]*/ino INO/' \
777 -e '/: dump size/s/[0-9][0-9]*/NUM/' \
778 -e '/dump size:/s/[0-9][0-9]*/NUM/' \
779 -e '/dump size per stream:/s/[0-9][0-9]*/NUM/' \
780 -e 's/\(media file size[ ]*\)[0-9][0-9]*/\1NUM/' \
781 -e 's/\(mfile size:[ ]*\)[0-9][0-9]*/\1NUM/' \
782 -e '/drive[ ]*[0-9][0-9]*:/d' \
784 -e '/inventory session uuid/d' \
785 -e '/ - Running single-threaded/d' \
786 -e '/^.*I\/O metrics: .*$/d' \
787 -e 's/1048576/BLOCKSZ/' \
788 -e 's/2097152/BLOCKSZ/' \
789 -e 's/(pid[ ]*[1-9][0-9]*)/\(pid PID\)/' \
791 if ($_ =~ /(?:Dump|Restore) Summary/) {
793 } elsif ($_ =~ /(?:Dump|Restore) Status/) {
803 _dump_filter_main | _check_quota_dumprestore | _check_quota_entries
813 -e 's/UUID[ ]*:[ ][0-9a-f-]*/UUID : ID/' \
814 -e 's/TIME OF DUMP[ ]*:.*/TIME OF DUMP : TIME/' \
815 -e 's/HOSTNAME:SCRATCH_MNT.*/HOSTNAME:SCRATCH_MNT/' \
816 -e 's#inventory/[0-9a-f-]*#inventory/UUID#' \
824 -e "s#$dump_file#DUMP_FILE#" \
825 -e "s#$SCRATCH_DEV#SCRATCH_DEV#" \
826 -e "s#$SCRATCH_RAWDEV#SCRATCH_DEV#" \
827 -e "s#$dumptape#TAPE_DEV#" \
828 -e "s#$dump_dir#DUMP_DIR#g" \
829 -e "s#$restore_dir#RESTORE_DIR#g" \
830 -e "s#$SCRATCH_MNT#SCRATCH_MNT#g" \
831 -e "s#$dump_sdir#DUMP_SUBDIR#g" \
832 -e "s#$restore_sdir#RESTORE_SUBDIR#g" \
838 # Note: requires a space between option letter and argument
849 [ -z "$2" ] && _error "missing argument for -f"
854 [ -z "$2" ] && _error "missing argument for -L"
859 dump_args="$dump_args -o"
862 dump_args="$dump_args -F"
875 [ -z "$2" ] && _error "missing argument for -l"
876 dump_args="$dump_args -l$2"
880 _error "invalid argument to common.dump function: $1"
895 echo "Dumping to tape..."
896 opts="$_dump_debug$dump_args -s $dump_sdir -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
897 echo "xfsdump $opts" | _dir_filter
898 xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
908 echo "Dumping to tape..."
909 opts="$_dump_debug$dump_args -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
910 echo "xfsdump $opts" | _dir_filter
911 xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
916 # Do full dump with -m
922 echo "Dumping to tape..."
924 opts="$_dump_debug$dump_args -m -b $onemeg -l0 -f $dumptape -M $media_label -L $session_label $SCRATCH_MNT"
925 echo "xfsdump $opts" | _dir_filter
926 xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
931 # Do full dump to file
937 echo "Dumping to file..."
938 opts="$_dump_debug$dump_args -f $dump_file -M $media_label -L $session_label $SCRATCH_MNT"
939 echo "xfsdump $opts" | _dir_filter
940 xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
944 # Do full dump to multiple files
946 _do_dump_multi_file()
953 while [ $i -lt $multi ]
955 multi_args="$multi_args -f $dump_file.$i -M $media_label.$i"
959 echo "Dumping to files..."
960 opts="$_dump_debug$dump_args $multi_args -L $session_label $SCRATCH_MNT"
961 echo "xfsdump $opts" | _dir_filter
962 xfsdump $opts 2>&1 | tee -a $seq.full | _dump_filter
966 _prepare_restore_dir()
969 mkdir $restore_dir ||\
970 _error "failed to mkdir $restore_dir"
975 # Get tape ready and restore dir
981 echo "Rewinding tape"
986 # Restore the tape into $restore_dir
994 echo "Restoring from tape..."
995 opts="$_restore_debug -f $dumptape -L $session_label $restore_dir"
996 echo "xfsrestore $opts" | _dir_filter
997 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
1001 # Restore the tape into $restore_dir using -m
1008 echo "Restoring from tape..."
1010 opts="$_restore_debug -m -b $onemeg -f $dumptape -L $session_label $restore_dir"
1011 echo "xfsrestore $opts" | _dir_filter
1012 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
1016 # Restore the tape from a dump file
1021 _prepare_restore_dir
1023 echo "Restoring from file..."
1024 opts="$_restore_debug -f $dump_file -L $session_label $restore_dir"
1025 echo "xfsrestore $opts" | _dir_filter
1026 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
1030 # Cumulative restore from a file
1031 # Need to specify the dump level e.g. "-l 0"
1033 _do_restore_file_cum()
1036 if echo $dump_args | grep '\-l0' >/dev/null; then
1037 _prepare_restore_dir
1040 echo "Restoring cumumlative from file..."
1041 opts="$_restore_debug -f $dump_file -r $restore_dir"
1042 echo "xfsrestore $opts" | _dir_filter
1043 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
1048 echo "Contents of dump ..."
1049 opts="$_restore_debug -f $dump_file -t"
1050 echo "xfsrestore $opts" | _dir_filter
1051 cd $SCRATCH_MNT # for IRIX which needs xfs cwd
1052 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter_main |\
1053 _check_quota_file |\
1054 _check_quota_entries |\
1055 $AWK_PROG 'NF != 1 { print; next }
1056 {files = sprintf("%s\n%s", files, $1)}
1057 END { print files | "sort" } '
1058 # the above awk code is to alpha sort only the output
1059 # of files (and not the verbose restore msgs)
1064 # Restore the tape from multiple dump files
1066 _do_restore_multi_file()
1069 _prepare_restore_dir
1074 while [ $i -lt $multi ]
1076 multi_args="$multi_args -f $dump_file.$i"
1080 echo "Restoring from file..."
1081 opts="$_restore_debug $multi_args -L $session_label $restore_dir"
1082 echo "xfsrestore $opts" | _dir_filter
1083 xfsrestore $opts 2>&1 | tee -a $seq.full | _dump_filter
1087 # Do xfsdump piped into xfsrestore - xfsdump | xfsrestore
1089 # Use -s as we want to dump and restore to the same xfs partition
1094 _prepare_restore_dir
1095 echo "xfsdump|xfsrestore ..."
1096 restore_opts="$_restore_debug - $restore_dir"
1097 dump_opts="$_dump_debug$dump_args -s $dump_sdir - $SCRATCH_MNT"
1098 echo "xfsdump $dump_opts | xfsrestore $restore_opts" | _dir_filter
1099 xfsdump $dump_opts 2>$tmp.dump.mlog | xfsrestore $restore_opts 2>&1 | tee -a $seq.full | _dump_filter
1100 _dump_filter <$tmp.dump.mlog
1104 # Compare dumped subdirectory with restored dir
1106 # Thus no contents are compared but permissions, sizes,
1107 # owners, etc... are.
1112 # verify we got back what we dumped
1114 echo "Comparing listing of dump directory with restore directory"
1115 ls -lR $dump_dir | tee -a $seq.full | _ls_filter >$tmp.dump_dir
1116 ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
1117 | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1119 diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1123 # filter out the date fields
1127 $AWK_PROG 'NF == 9 { print $1, $2, $3, $4, $9 }'
1131 # _ls_compare_sub but don't compare dates
1132 _ls_nodate_compare_sub()
1135 # verify we got back what we dumped
1137 echo "Comparing listing of dump directory with restore directory"
1138 ls -lR $dump_dir | tee -a $seq.full | _ls_filter | _ls_nodate_filter >$tmp.dump_dir
1139 ls -lR $restore_dir/$dump_sdir | tee -a $seq.full | _ls_filter \
1140 | _ls_nodate_filter | sed -e "s#$restore_sdir\/##" >$tmp.restore_dir
1142 diff -cs $tmp.dump_dir $tmp.restore_dir | sed -e "s#$tmp#TMP#g"
1146 # Compare using recursive diff the files of the dumped
1148 # This one will compare the contents.
1152 echo "Comparing dump directory with restore directory"
1153 diff -rs $dump_dir $restore_dir/$dump_sdir | _dir_filter
1160 # Tim - this is the IRIX way...
1161 # find $_path -exec attr -l {} \; |\
1162 # awk '{print $9, $2}' |\
1165 # and this is now the Linux way...
1166 getfattr --absolute-names -Rh $_path |\
1168 if (m/^# file: (\S+)/) { $file = $1 }
1169 elsif (m/^user\.(\w+)/) { print $file, " ",$1,"\n" }' |\
1171 while read file ea_name; do
1172 attr -g $ea_name $file
1177 # Compare the extended attributes of the files/dirs
1178 # b/w the dumped and restore dirs.
1181 # Attribute "attr5" had a 8 byte value for /spare1/dump.5460/dir:
1182 # Attribute "attr5" had a 8 byte value for /spare1/restore.5460/dump.5460/dir:
1186 echo "Comparing dump directory with restore directory"
1187 echo "Looking at the extended attributes (EAs)"
1189 _get_eas_on_path $dump_dir | tee $seq.ea1 | _dir_filter
1190 echo "EAs on restore"
1191 _get_eas_on_path $restore_dir/$dump_sdir \
1192 | sed -e "s#$restore_sdir\/##" \
1195 diff -s $seq.ea1 $seq.ea2
1200 # Compare using recursive diff the files of the dumped
1205 echo "Comparing dump directory with restore directory"
1206 diff -rs $SCRATCH_MNT $restore_dir | _dir_filter | _check_quota_diff
1210 # Check out the dump inventory
1214 xfsdump $_dump_debug -I | tee -a $seq.full | _dump_filter_main
1218 # Do the xfsinvutil cmd with debug and filters
1219 # Need to set variable: "$middate" to the invutil date
1224 echo "xfsinvutil $_invutil_debug -M $host:$SCRATCH_MNT \"$middate\" $*" >$seq.full
1225 xfsinvutil $_invutil_debug $* -M $host:$SCRATCH_MNT "$middate" \
1226 | tee -a $seq.full | _invutil_filter
1230 # ensure we can find the user quota msg if user quotas are on
1231 # ensure we can find the group quota msg if group quotas are on
1239 $here/src/feature -U $SCRATCH_DEV && uquota=1
1240 $here/src/feature -G $SCRATCH_DEV && gquota=1
1242 $AWK_PROG -v uquota=$uquota -v gquota=$gquota -v full=$seq.full \
1243 -v usermsg="$usermsg" -v groupmsg="$groupmsg" '
1245 print "Found group quota:", $0 >>full
1248 print "Found extra:", $0
1253 print "Found user quota:", $0 >>full
1256 print "Found extra:", $0
1262 if (uquota && !found_uquota) {
1263 print "Missing: ", usermsg
1265 if (gquota && !found_gquota) {
1266 print "Missing: ", groupmsg
1273 # xfsrestore: 3 directories and 40 entries processed
1275 # num entries needs to be reduced by num quota file(s)
1277 _check_quota_entries()
1281 $here/src/feature -U $SCRATCH_DEV && uquota=1
1282 $here/src/feature -G $SCRATCH_DEV && gquota=1
1283 $AWK_PROG -v uquota=$uquota -v gquota=$gquota '
1284 /entries processed/ {
1293 # xfsdump: saving user quota information for: SCRATCH_MNT
1294 # xfsdump: saving group quota information for: SCRATCH_MNT
1295 # xfsrestore: user quota information written to ...'
1296 # xfsrestore: group quota information written to ...'
1298 _check_quota_dumprestore()
1300 _check_quota 'user quota information' \
1301 'group quota information'
1306 # Only in RESTORE_DIR: xfsdump_quotas
1307 # Only in RESTORE_DIR: xfsdump_quotas_group
1311 _check_quota 'Only in RESTORE_DIR: xfsdump_quotas' \
1312 'Only in RESTORE_DIR: xfsdump_quotas_group'
1316 # Look for the quota file in the output
1317 # Ensure that it is there if it should be
1318 # Filter it out so that the output is always the same
1319 # even with no quotas
1323 _check_quota 'xfsdump_quotas' 'xfsdump_quotas_group'
1326 # make sure this script returns success