From: Tim Shimmin Date: Fri, 9 Dec 2005 05:08:00 +0000 (+0000) Subject: Stop using ls for comparison with dump/restore for 065 and instead X-Git-Tag: v1.1.0~671 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=876970e2a2e0fa6572a3289fb3be6528e687bd81;p=xfstests-dev.git Stop using ls for comparison with dump/restore for 065 and instead use find with src/lstat64. Should convert other tests in the future. Merge of master-melb:xfs-cmds:24773a by kenmcd. Stop using ls for comparison with dump/restore for 065 and instead use find with src/lstat64. Should convert other tests in the future. --- diff --git a/065 b/065 index 33c35d58..61040ce8 100755 --- a/065 +++ b/065 @@ -26,24 +26,22 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 . ./common.filter . ./common.dump -# IRIX "ls -s" uses a block size of 512, for consistincy on linux use -# ls --block-size=512 -s -[ $HOSTOS == Linux ] && LS_BLOCKSIZE="--block-size=512" - -_my_ls_filter() +# +# list recursively the directory +# +# e.g. lstat output: src/lstat64 31056 -rwxr-xr-x 38403,0 +# Don't print out sizes of directories - which can vary - overwrite with XXX. +# +_list_dir() { - # - # Print size and fname. - # The size is significant since we add to the file as part - # of a file change for the incremental. - # - # Filter out the housekeeping files of xfsrestore - # Filter out toplevel "dumpdir/$" report. - grep -v total | grep -v "^$" | sed "s/^[ \t]*//g" | \ - sed -e 's/.*dumpdir/dumpdir/' |\ - egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree|dumpdir/$|dumpdir:$' |\ - egrep -v "$restore_dir:" -} + __dir=$1 + find $__dir -exec $here/src/lstat64 -t {} \; |\ + sed -e 's/.*dumpdir/dumpdir/' -e '/^dumpdir /d' |\ + sed -e 's/.*restoredir/restoredir/' -e '/^restoredir /d' |\ + egrep -v 'housekeeping|dirattr|dirextattr|namreg|state|tree' |\ + awk '$3 ~ /^d/ { $2 = "XXX" } {print}' |\ + sort +} # real QA test starts here _supported_fs xfs @@ -144,7 +142,7 @@ while [ $i -le $num_dumps ]; do _stable_fs echo "Listing of what files we have at level $i:" - ls -sRF $LS_BLOCKSIZE $dump_dir | _my_ls_filter | tee $tmp.ls.$i + _list_dir $dump_dir | tee $tmp.ls.$i dump_file=$tmp.df.level$i _do_dump_file -l $i @@ -168,9 +166,8 @@ while [ $i -le $num_dumps ]; do echo "" echo "restoring from df.level$i" _do_restore_file_cum -l $i - echo "ls -sRF restore_dir" - ls -sRF $LS_BLOCKSIZE $restore_dir | _my_ls_filter |\ - _check_quota_file | tee $tmp.restorals.$i + echo "list restore_dir" + _list_dir $restore_dir | _check_quota_file | tee $tmp.restorals.$i i=`expr $i + 1` done diff --git a/065.out b/065.out index 9bb1c94e..76d11d31 100644 --- a/065.out +++ b/065.out @@ -1,20 +1,16 @@ QA output created by 065 Do the incremental dumps Listing of what files we have at level 0: -0 addeddir1/ -0 addeddir2/ -0 addeddir3/ -0 addeddir4/ -8 addedfile0 -8 addedfile1 -8 addedfile2 -8 addedfile3 -dumpdir/addeddir1: -dumpdir/addeddir2: -dumpdir/addeddir3: -8 addedfile4 -dumpdir/addeddir4: -8 addedfile5 +dumpdir/addeddir1 XXX drwxr-xr-x 0,0 +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir3/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir3 XXX drwxr-xr-x 0,0 +dumpdir/addeddir4/addedfile5 5 -rw-r--r-- 0,0 +dumpdir/addeddir4 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile1 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l0 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -40,14 +36,12 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 1: -0 addeddir1/ -0 addeddir4/ -8 addedfile0 -8 addedfile1 -8 addedfile3 -dumpdir/addeddir1: -dumpdir/addeddir4: -8 addedfile5 +dumpdir/addeddir1 XXX drwxr-xr-x 0,0 +dumpdir/addeddir4/addedfile5 5 -rw-r--r-- 0,0 +dumpdir/addeddir4 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile1 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l1 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -72,14 +66,12 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 2: -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile2 -8 addedfile3 -dumpdir/addeddir2: -dumpdir/addeddir6: -8 addedfile4 +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l2 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -104,18 +96,16 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 3: -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile2 -8 addedfile3 -8 linkfile0 -8 linkfile0_1 -8 linkfile2 -8 linkfile64 -dumpdir/addeddir2: -dumpdir/addeddir6: -8 addedfile4 +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 +dumpdir/linkfile0_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile0 5 -rw-r--r-- 0,0 +dumpdir/linkfile2 5 -rw-r--r-- 0,0 +dumpdir/linkfile64 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l3 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -140,14 +130,12 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 4: -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile3 -8 linkfile0_1 -8 linkfile2 -dumpdir/addeddir2: -dumpdir/addeddir6: +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 +dumpdir/linkfile0_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile2 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l4 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -172,10 +160,10 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 5: -8 addedfile6 -8 linkfile6_1 -8 linkfile6_2 -8 linkfile6_3 +dumpdir/addedfile6 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l5 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -200,10 +188,10 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 6: -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l6 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -228,10 +216,10 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 7: -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l7 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -256,10 +244,10 @@ xfsdump: dump size (non-dir files) : NUM bytes xfsdump: dump complete: SECS seconds elapsed xfsdump: Dump Status: SUCCESS Listing of what files we have at level 8: -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 Dumping to file... xfsdump -l8 -f DUMP_FILE -M stress_tape_media -L stress_065 SCRATCH_MNT xfsdump: using file dump (drive_simple) strategy @@ -578,21 +566,17 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -0 addeddir1/ -0 addeddir2/ -0 addeddir3/ -0 addeddir4/ -8 addedfile0 -8 addedfile1 -8 addedfile2 -8 addedfile3 -dumpdir/addeddir1: -dumpdir/addeddir2: -dumpdir/addeddir3: -8 addedfile4 -dumpdir/addeddir4: -8 addedfile5 +list restore_dir +dumpdir/addeddir1 XXX drwxr-xr-x 0,0 +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir3/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir3 XXX drwxr-xr-x 0,0 +dumpdir/addeddir4/addedfile5 5 -rw-r--r-- 0,0 +dumpdir/addeddir4 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile1 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 restoring from df.level1 Restoring cumumlative from file... @@ -619,15 +603,13 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -0 addeddir1/ -0 addeddir4/ -8 addedfile0 -8 addedfile1 -8 addedfile3 -dumpdir/addeddir1: -dumpdir/addeddir4: -8 addedfile5 +list restore_dir +dumpdir/addeddir1 XXX drwxr-xr-x 0,0 +dumpdir/addeddir4/addedfile5 5 -rw-r--r-- 0,0 +dumpdir/addeddir4 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile1 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 restoring from df.level2 Restoring cumumlative from file... @@ -654,15 +636,13 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile2 -8 addedfile3 -dumpdir/addeddir2: -dumpdir/addeddir6: -8 addedfile4 +list restore_dir +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 restoring from df.level3 Restoring cumumlative from file... @@ -689,19 +669,17 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile2 -8 addedfile3 -8 linkfile0 -8 linkfile0_1 -8 linkfile2 -8 linkfile64 -dumpdir/addeddir2: -dumpdir/addeddir6: -8 addedfile4 +list restore_dir +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6/addedfile4 5 -rw-r--r-- 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile2 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 +dumpdir/linkfile0_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile0 5 -rw-r--r-- 0,0 +dumpdir/linkfile2 5 -rw-r--r-- 0,0 +dumpdir/linkfile64 5 -rw-r--r-- 0,0 restoring from df.level4 Restoring cumumlative from file... @@ -728,15 +706,13 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -0 addeddir2/ -0 addeddir6/ -8 addedfile0 -8 addedfile3 -8 linkfile0_1 -8 linkfile2 -dumpdir/addeddir2: -dumpdir/addeddir6: +list restore_dir +dumpdir/addeddir2 XXX drwxr-xr-x 0,0 +dumpdir/addeddir6 XXX drwxr-xr-x 0,0 +dumpdir/addedfile0 5 -rw-r--r-- 0,0 +dumpdir/addedfile3 5 -rw-r--r-- 0,0 +dumpdir/linkfile0_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile2 5 -rw-r--r-- 0,0 restoring from df.level5 Restoring cumumlative from file... @@ -763,11 +739,11 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -8 addedfile6 -8 linkfile6_1 -8 linkfile6_2 -8 linkfile6_3 +list restore_dir +dumpdir/addedfile6 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_3 5 -rw-r--r-- 0,0 restoring from df.level6 Restoring cumumlative from file... @@ -794,11 +770,11 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +list restore_dir +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 restoring from df.level7 Restoring cumumlative from file... @@ -825,11 +801,11 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +list restore_dir +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 restoring from df.level8 Restoring cumumlative from file... @@ -856,11 +832,11 @@ xfsrestore: directory post-processing xfsrestore: restoring non-directory files xfsrestore: restore complete: SECS seconds elapsed xfsrestore: Restore Status: SUCCESS -ls -sRF restore_dir -8 addedfile6_mv -8 linkfile6_mv_1 -8 linkfile6_mv_2 -8 linkfile6_mv_3 +list restore_dir +dumpdir/addedfile6_mv 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_1 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_2 5 -rw-r--r-- 0,0 +dumpdir/linkfile6_mv_3 5 -rw-r--r-- 0,0 Do the ls comparison Comparing ls of FS with restored FS at level 0 diff --git a/src/lstat64.c b/src/lstat64.c index 052ecfa5..12d1fe4e 100644 --- a/src/lstat64.c +++ b/src/lstat64.c @@ -16,6 +16,7 @@ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include @@ -45,24 +46,51 @@ timesince(long timesec) d_since, h_since, m_since, s_since); } +void +usage(void) +{ + fprintf(stderr, "Usage: lstat64 [-t] filename ...\n"); + exit(1); +} + int main(int argc, char **argv) { struct stat64 sbuf; char mode[10]; - int i; + int i, c; + int terse_flag = 0; + + while ((c = getopt(argc, argv, "t")) != EOF) { + switch (c) { + case 't': + terse_flag = 1; + break; + + case '?': + usage(); + } + } + if (optind == argc) { + usage(); + } time(&timebuf); - for (i = 1; i < argc; i++) { + for (i = optind; i < argc; i++) { if( lstat64(argv[i], &sbuf) < 0) { perror(argv[i]); continue; } - printf(" File: \"%s\"\n", argv[i]); - printf(" Size: %-10llu", (unsigned long long)sbuf.st_size); + if (terse_flag) { + printf("%s %llu ", argv[i], (unsigned long long)sbuf.st_size); + } + else { + printf(" File: \"%s\"\n", argv[i]); + printf(" Size: %-10llu", (unsigned long long)sbuf.st_size); + } strcpy(mode,"----------"); if (sbuf.st_mode & (S_IEXEC>>6)) @@ -90,41 +118,55 @@ main(int argc, char **argv) if (sbuf.st_mode & S_ISUID) mode[3] = 's'; - printf(" Filetype: "); + if (!terse_flag) + printf(" Filetype: "); switch (sbuf.st_mode & S_IFMT) { case S_IFSOCK: - puts("Socket"); + if (!terse_flag) + puts("Socket"); mode[0] = 's'; break; case S_IFDIR: - puts("Directory"); + if (!terse_flag) + puts("Directory"); mode[0] = 'd'; break; case S_IFCHR: - puts("Character Device"); + if (!terse_flag) + puts("Character Device"); mode[0] = 'c'; break; case S_IFBLK: - puts("Block Device"); + if (!terse_flag) + puts("Block Device"); mode[0] = 'b'; break; case S_IFREG: - puts("Regular File"); + if (!terse_flag) + puts("Regular File"); mode[0] = '-'; break; case S_IFLNK: - puts("Symbolic Link"); + if (!terse_flag) + puts("Symbolic Link"); mode[0] = 'l'; break; case S_IFIFO: - puts("Fifo File"); + if (!terse_flag) + puts("Fifo File"); mode[0] = 'f'; break; default: - puts("Unknown"); + if (!terse_flag) + puts("Unknown"); mode[0] = '?'; } + if (terse_flag) { + printf("%s %d,%d\n", mode, (int)sbuf.st_uid, (int)sbuf.st_gid); + continue; + } + printf(" Mode: (%04o/%s)", (unsigned int)(sbuf.st_mode & 07777), mode); printf(" Uid: (%d)", (int)sbuf.st_uid); printf(" Gid: (%d)\n", (int)sbuf.st_gid); @@ -150,9 +192,5 @@ main(int argc, char **argv) if (i+1 < argc) printf("\n"); } - if (i == 1) { - fprintf(stderr, "Usage: lstat64 filename...\n"); - exit(1); - } exit(0); }