in reply to Check if home dir is mounted?
First off, you need to know where the user lives, ask the system with getpwnam and friends. Then try to mount the home dir. It's up to your system's /etc/fstab (and by fstab, nsswitch as you may use NIS+ or something)
use User::pwent; my $username = 'f00li5h'; my $user = getpwnam($username); printf "%s aka (%s) lives in %s $/", $user->name, $user->gecos, $user->dir; #f00li5h aka (f00li5h and5illy) lives in /home/f00li5h use File::Spec; my @paths = File::Spec->splitdir( $user->dir ); # start at the most specific directory (/home/f00li5h) head # to the lest specific (/) while( @paths ){ # get the system to mount (rather than just print) printf "mount %s $/", File::Spec->catdir( @paths ); last if -d $user->dir; # stop looking when the dir turns up pop @paths ; }
This has massive massive YMMV attached to it and I'm sure there's a better way than blindly mounting things until the homedir appears, particularly if the user's homedir is with a symlink of some sort.
/home/f00li5h -> /media/homes/big/f00li5h
|
|---|