Can one find a mount point just knowing the volume name?

Stephen Joyce stephen@physics.unc.edu
Thu, 8 Feb 2001 12:41:51 -0500 (EST)


You can recursively descend through your cell (or portions of it) to find
this; with a bit of creativity, you could even maintain a database of this
information.

Here's a script which will give you this information on stdout.  We call it
afsmounts and it takes one argument: the top level directory to
start with (this should at least be /afs/<your cell>; it is inadvisable to
run it on /afs... :-)  Depending on the size of your cell, you may wish to
run it when the impact will be minimal.  You need to run it with
administrator tokens (or make it able to traverse all directories on your
system by other nefarious means).

#!/usr/local/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




On Thu, 8 Feb 2001, Neulinger, Nathan R. wrote:

> mount "point" is the problem... There isn't just one mount point for a
> volume, there can be 0, 1, or hundreds...
> 
> If you feel like loading down your server, you can get that information from
> salvager, but it's slow. The alternative is to recursively descend through
> afs space looking for mount points.
> 
> -- Nathan
> 
> > -----Original Message-----
> > From: Morris Strongson [mailto:mms@bnl.gov]
> > Sent: Thursday, February 08, 2001 11:02 AM
> > To: info-afs@transarc.com
> > Subject: Can one find a mount point just knowing the volume name?
> > 
> > 
> > Hopefully a quick one; if I know a volume name,
> > is there any way to find out what its mount point is?
> > Thanks.
> > 
> > --
> > 
> > **************************************************************
> > ************
> >  Morris Strongson, RHIC, USAtlas Projects    Telephone:   
> > (631)344-4192
> >  Information Technology Division (fka CCD)   Facsimile:   
> > (631)344-7688
> >  Brookhaven National Laboratory              Internet:    mms@bnl.gov
> >  Building 515, Upton, NY 11973-5000          WWW:  
> > http://www.ccd.bnl.gov/
> > **************************************************************
> > ************
> > 
> > 
> > 
>