Checking Current File System with Perl
I need my perl script to check the file system 开发者_高级运维type of the computer it's running on. What is the easiest way to do this? (on Linux)
There is a linux command df -T
to determine filesystem
You can invoke it from your script and parse the output:
my $filesystem_info = `df -T`;
The only reliable way to do what you want is (a) decide which mount you are talking about and (b) find its entry in /proc/mounts
.
On Linux, /proc/mounts
lists all mounted file systems. The format of each line is "device mount-point fs-type mount-options'. It is human-readable; cat /proc/mounts
and you should get the idea.
(Note that /etc/fstab
only lists the file systems that get auto-mounted at boot time. That can be different than what is mounted at the time the script runs for all sorts of reasons, most notably automounters. /proc/mounts
is what you want.)
You can try parsing the /etc/fstab
file to find it out.
Beware there might be multiple filesystems in this file, you have to pick the one you want.
精彩评论