You can check if something is mounted by comparing which device
 a specific directory is on and comparing it to its parent directory.

$ cat chk_mount.pl
#!/usr/bin/perl -w

use strict;
use Fcntl ':mode';

my $A = $ARGV[0] // "/";
my $B = $ARGV[1] // "/var";

my @Ast = stat $A;
my @Bst = stat $B;

if ( S_ISDIR($Ast[2]) && S_ISDIR($Bst[2]) ) {
    if ($Ast[0] == $Bst[0]) {
        print "$Ast[0], $Bst[0]: same filesystem\n";
    } else {
        print "$Ast[0], $Bst[0]: different filesystem\n";
    }
} else {
    print "not directories\n";
}

$ ./chk_mount.pl / /usr
2306, 2308: different filesystem
$ ./chk_mount.pl /usr/bin /usr
2308, 2308: same filesystem
$

Regards,
/Karl Hammar



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to