10 $prog =~ s/^.*\/(\S+)$/$1/;
14 my $do_empty_dirs = 0;
22 while ($ARGV[0] =~ /^-\S+/) {
23 if ($ARGV[0] eq "-d" || $ARGV[0] eq "-debug") {
25 } elsif ($ARGV[0] eq "-dirs") {
27 } elsif ($ARGV[0] eq "-empty_dirs") {
29 } elsif ($ARGV[0] eq "-i") {
31 } elsif ($ARGV[0] eq "-fhinfo") {
34 print STDERR "Unknown switch $ARGV[0]\n";
40 print STDERR "Usage: $prog [-d|-debug] [-dirs] [-i] [-fhinfo] <index file>\n";
47 my $idxfile = $ARGV[0];
48 open(IDXFILE, $idxfile) ||
49 die "$prog: can not open '$idxfile': $!";
60 print "find_path called on $i\n" if $debug;
63 if ($i == $root_node) {
67 # find the inode of the directory that refers to this inode
68 if (!exists $first_ino_ref{$i}) {
69 print "find_path failed first_ino_ref on $i\n";
72 my $dir_i = $first_ino_ref{$i};
74 # find the directory entry that refers to this inode
76 if (exists $dir_inode{$dir_i}) {
77 $ilist = $dir_inode{$dir_i};
79 print "find_path failed dir_inode for $dir_i on $i\n";
83 # search through the directory for the name entry
84 my $inode_entry_name = "";
85 foreach my $nam (keys %$ilist) {
86 if (($nam eq ".") || ($nam eq "..")) {
89 if ($ilist->{$nam} == $i) {
91 $inode_entry_name = $nam;
95 print "find_path found name '$inode_entry_name' for $i\n" if $debug;
97 # get the path for the directory
99 my $path = &find_path ($dir_i);
101 return "$path/$inode_entry_name";
104 return $inode_entry_name;
107 # Pass #1: get directory information
110 # emacs sucks with perl
117 if (/^DE\s+(.+)\s*$/) {
118 print "Environment: $1\n" if $debug;
121 if (/^DHr\s+(.+)\s*$/) {
127 if (/^DHd\s+([0-9]+)\s+(\S+)\s+UNIX+\s+([0-9]+)\s*$/) {
128 # directory entry inode $1 has name $2 pointing to inode $3
129 print "$1 => $2 $3\n" if $debug;
132 if (exists $dir_inode{$1}) {
133 $ilist = $dir_inode{$1};
138 $dir_inode{$1} = $ilist;
140 # if not "." or ".." then record the first reference to the inode
141 if (($2 eq ".") || ($2 eq "..")) {
145 # count the directory entry
146 if (exists $dir_entry_count{$1}) {
147 $dir_entry_count{$1}++;
149 $dir_entry_count{$1} = 1;
152 if (!exists $first_ino_ref{$3}) {
153 $first_ino_ref{$3} = $1;
160 if (/^DHn\s+([0-9]+)\s+UNIX\s+f([dc])\s+m(\S+)\s+u(\S+)\s+g(\S+)\s+tm(\S+)\s*$/) {
171 if (/^DHn\s+([0-9]+)\s+UNIX\s+f([dc])\s+m(\S+)\s+u(\S+)\s+g(\S+)\s+tm(\S+)\s+@([-0-9]+)\s*$/) {
182 if (/^DHn\s+([0-9]+)\s+UNIX\s+f(\S+)\s+m(\S+)\s+u(\S+)\s+g(\S+)\s+s(\S+)\s+tm(\S+)\s*$/) {
194 if (/^DHn\s+([0-9]+)\s+UNIX\s+f(\S+)\s+m(\S+)\s+u(\S+)\s+g(\S+)\s+s(\S+)\s+tm(\S+)\s+@([-0-9]+)\s*$/) {
206 print "Unknown keyword line: $_\n";
209 print "Root node: '$root_node'\n" if $debug;
212 seek (IDXFILE, 0, 0);
214 # Pass 2: get file information including multiple names (hard links) for the
222 # emacs sucks with perl
226 if (/^DHd\s+([0-9]+)\s+(\S+)\s+UNIX+\s+([0-9]+)\s*$/) {
227 # directory entry inode $1 has name $2 pointing to inode $3
228 print "$1 => $2 $3\n" if $debug;
230 if (($2 eq ".") || ($2 eq "..")) {
234 # find the pathname for this directory
236 if ($last_inode == $1) {
239 $last_path = $path = &find_path ($1);
244 # see if it is a directory
245 if ($inode{$3}{TYPE} eq "d") {
246 if ($do_empty_dirs && !$do_dirs) {
247 if (exists $dir_entry_count{$3}) {
250 } elsif (!$do_dirs) {
257 # print out path name for this entry
262 $full_path = "$path/$2";
265 # translate "=" into %3d".
266 $full_path =~ s/=/%3d/g;
268 if ($do_inode != 0 || $debug) {
270 print "$inode{$3}{FHINFO} " . "$3" . ": $full_path\n";
272 print "$3" . ": $full_path\n";
276 print "$inode{$3}{FHINFO} " . "$full_path\n";
278 print "$full_path\n";