2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
5 # traverse the entire filesystem dumping info.
18 unless (@stat=lstat("$file")) {
19 printf("%-" . ($opt{v}?65:32) . "s $file\n", "!!! could not lstat");
23 $stat[0]=$stat[8]=""; # wipe the device and access time
25 $md5->add(join(" ",@stat));
27 print join(" ",@stat), "\n";
30 print $md5->hexdigest . " ";
35 if (!defined($link = readlink $file)) {
36 printf("%-32s $file\n", "!!! could not readlink");
40 } elsif (-f "$file") {
41 if (!open(FILE, "$file")) {
42 printf("%-32s $file\n", "!!! could not read");
48 print $md5->hexdigest . " $file\n";
53 die "Usage: $0 <dir>\n" unless (@ARGV == 1);
56 die "can't read $dir\n" unless (-r $dir);
57 die "$dir is not a directory\n" unless (-d _);
59 chomp($HOST = `hostname -s`);
61 print "*** fs-walk host $HOST dir $dir\n";
64 while ($dir = shift @todo) {
66 unless (opendir(DIR,$dir)) {
67 printf("%-" . ($opt{v}?65:32) . "s $dir\n", "!!! could not opendir");
70 unless (@all=readdir(DIR)) {
71 printf("%-" . ($opt{v}?65:32) . "s $dir\n", "!!! could not readdir");
75 @dirs=grep(-d "$dir/$_" && !-l "$dir/$_", @all);
81 foreach (grep(!/^\.\.?$/, @dirs)) {
82 push (@todo,"$dir/$_");