The following is another perl script which lists mountpoints in directory
trees. It only runs "fs lsm" on paths identified as mountpoints by having
odd inodes, so it should run about a hundred times as fast as the previous
scripts posted. It also avoids looking in backup volumes.
Note that checking for nlink > 2 isn't a valid test, because having AFS
mountpoints as subdirectories doesn't increase the link count for a parent
directory.
Dan
Dan Bloch Transarc Corporation, Pittsburgh [EMAIL PROTECTED]
----------------------------------------------------------------------
#!/usr/bin/perl
#
# lsm - list mount points in a directory tree
#
# usage: lsm [directory]
#
# Dan Bloch <[EMAIL PROTECTED]>
#
$TRACE_MOUNTPOINTS = 1;
&dodir(shift || ".");
sub dodir {
local($dir) = @_;
local(@filenames, $file, $mountpoint);
local($dev,$inode,$mode,$nlink);
if (! opendir(DIR,$dir)) {
warn "Can't open $dir ($!)\n";
return;
}
@filenames = sort(readdir(DIR));
closedir(DIR);
foreach $file (@filenames) {
next if $file eq '.' || $file eq '..';
if (!-l "$dir/$file" && -d _) {
($dev,$inode,$mode,$nlink) = stat(_);
if ($inode & 1) { # odd inode => directory
&dodir("$dir/$file");
} else { # even inode => mountpoint
$mountpoint = `fs lsm $dir/$file`;
$mountpoint =~ s/.*for volume '#?(.*)'\n/\1/;
print("$dir/$file is a mountpoint for $mountpoint\n");
&dodir("$dir/$file")
if $TRACE_MOUNTPOINTS && $mountpoint !~ /\.backup$/;
}
}
}
}