Operating System - Linux
1752393 Members
6416 Online
108788 Solutions
New Discussion

check if file system is mounted - perl

 
itai weisman
Super Advisor

check if file system is mounted - perl

hello,
does anyone know how can I check wheter a file system is mounted, on a perl script ? without involving any operating system commands - I need to write something which is operating system independed (including windows)
thanks
Itai
1 REPLY 1
James R. Ferguson
Acclaimed Contributor

Re: check if file system is mounted - perl

Hi:

At least in UNIX, a mountpoint will always have its inode equal to two (2):

# perl -le '$dir=shift or die;die "not a dir\n" unless -d $dir;printf "%s a mountpoint\n",(stat _)[1]==2 ? "is":"not"' /path

Regards!

...JRF...