Spray randomly created/checksummed extended attributes across a filesystem.
[xfstests-dev.git] / src / fill2fs_check
1 #!/usr/bin/perl -w
2 #
3
4 #
5 #  Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
6 #  
7 #  This program is free software; you can redistribute it and/or modify it
8 #  under the terms of version 2 of the GNU General Public License as
9 #  published by the Free Software Foundation.
10 #  
11 #  This program is distributed in the hope that it would be useful, but
12 #  WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 #  
15 #  Further, this software is distributed without any warranty that it is
16 #  free of the rightful claim of any third person regarding infringement
17 #  or the like.  Any license provided herein, whether implied or
18 #  otherwise, applies only to this software file.  Patent licenses, if
19 #  any, provided herein do not apply to combinations of this program with
20 #  other software, or any other product whatsoever.
21 #  
22 #  You should have received a copy of the GNU General Public License along
23 #  with this program; if not, write the Free Software Foundation, Inc., 59
24 #  Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 #  
26 #  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 #  Mountain View, CA  94043, or:
28 #  
29 #  http://www.sgi.com 
30 #  
31 #  For further information regarding this notice, see: 
32 #  
33 #  http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #
35 #
36  
37 #
38 # fill2fs_check:
39 #   Read a manifest generated by fill2fs from the command
40 #   line or stdin, checksum every file listed
41 #
42 #   $Id$
43 #
44
45 use File::Basename;
46
47 while (<>) {
48   chomp;
49   if ( ! -e $_) {
50     print "$0: $_ not found\n";
51     exit(1);
52   }
53   (undef, $expected) = split(/\./, basename $_);
54   chomp($sum = `sum -r $_`);
55   ($actual) = split(/\s+/, $sum);
56   if ($actual != $expected) {
57     print "$0: checksum is wrong for \"$_\"\n";
58     exit(1);
59   }
60 }