5 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
26 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 # Mountain View, CA 94043, or:
31 # For further information regarding this notice, see:
33 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
46 # returns numbers with a normal distribution
52 for (my $i = 0; $i < 12; $i++) {
56 $x = $mean + $stddev * $x;
62 # determine script location and find fill2
65 chomp($_ = `which fill2 2>&1 | head -1`);
71 # in the same directory - get absolute path
72 chomp($dirname = dirname $0);
73 if ($dirname =~ m!^/.*!) {
74 $fill2 = $dirname . "/fill2";
78 $fill2 = $cwd . "/" . $dirname . "/fill2";
81 die("Error: $0: can't find fill2, tried \"$fill2\"\n");
86 # for each file attach a random number of attributes
87 # each filled with a random amount of data
88 # attribute name is the checksum of the data stored within
91 $status = 0; # return status
96 die("Error: $0: $file not found\n")
99 if ($0 =~ /fill2attr$/) {
101 # attach attributes to this file
102 my $num = abs(int(normal(3, 1)));
105 my $tmp = "/tmp/fill2attr$$";
107 for (my $i = 0; $i < $num; $i++) {
108 my $size = abs(int(normal(256, 200)));
109 my $cmd = "$fill2 -d nbytes=$size,linelength=72,seed=$seed -b 4k $tmp";
110 $cmd .= " > /dev/null 2>&1" if (! $verbose);
112 if (system($cmd) != 0) {
113 die("Error $0: can't create $tmp\n");
116 chomp($_ = `sum -r $tmp`);
117 ($sum) = split(/\s+/);
118 if (system("cat $tmp | attr -s $sum $file > /dev/null 2>&1") != 0) {
119 die("Error $0: could not attach attribute:\n" . `cat $tmp` . "\n");
123 elsif ($0 =~ /fill2attr_check/) {
125 # get the attributes for this file
126 $cmd = "attr -q -l $file |";
129 close LIST or die("Error listing attributes: $!");
132 # check attribute contents
133 foreach my $label (@labels) {
134 ($sum) = split(/\s+/, `attr -q -g $label $file | sum -r`);
135 if ($sum ne $label) {
136 warn("Attribute \"$label\" does not match " .
137 "attribute contents for file $file\n");