>                                     has anyone written a script that will
> scan a given tree in AFS and return a map of the volumes and mount points
> within that section of the tree?

Give this one a whirl.

Bradley (once again, not speaking for Transarc)
-----
#!/usr/bin/perl

sub descend {
        local($dir) = @_;
        local(@names);

        return warn "$dir: $!\n" unless opendir(DIR, $dir);
        @names = readdir(DIR);
        closedir(DIR);
        for (@names) {
                &doname($dir . "/" . $_) unless $_ eq "." || $_ eq "..";
        }
        return $dir;
}

sub doname {
        local($name) = @_;
        local($dev, $ino, $vol);

        return warn "$name: $!\n" unless ($dev, $ino) = lstat($name);
        return &descend($name) if $ino & 1;
        return $name if -l $name || ! -d _;
        $vol = `fs lsmount $name`;
        die unless $vol =~ s/.*mount point for volume '(.*)'\n$/\1/;
        printf "%-${volwidth}s %s\n", $vol, $name;
        return $name if $vol =~ /.*\.backup$/;
        return &descend($name);
}

$volwidth = 24;

printf "%-${volwidth}s %s\n", "Volume Name", "Mounted-on";

foreach (@ARGV ? @ARGV : (".")) {
        s#(.)/+$#\1#;
        $msg = `fs examine $_ 2>&1`;
        $msg =~ s/fs:\s*//, warn($msg), next unless $? == 0;
        &doname($_);
}

exit 0

Reply via email to