#!/usr/local/bin/perl
#
# showfusers - Kees Cook - April 1996
# Shows all the processes attached to a given mount point
#
# This script assumes:
#	-  SysV-style ps
#       -  fuser uses "-c" for mount-point checking
# some unices use "fuser -m" for mount-point checking
 
die
"Usage: showfuser pathname
" if ($ARGV[0] =~ /^-h/i);
 
$FUSER = "/usr/sbin/fuser -c";
$PS = "/usr/bin/ps -deaf";
 
die "See processes attatched to where?\n" if (!@ARGV);
$location = $ARGV[0];
 
@pids = split(/\s+/,`$FUSER $location 2>/dev/null`);
foreach $pid (@pids) {
        $got{$pid}=1;
}
open(PS,"$PS |");
while (<PS>) {
        push(@lines,$_)
                if (/^\s*\S+\s+(\d+)\s+/ && defined($got{$1})); 
}
close(PS);
print @lines;

