You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
643 B
36 lines
643 B
12 years ago
|
#!/usr/bin/perl
|
||
|
|
||
|
$first = 1;
|
||
|
|
||
|
print "{\n";
|
||
|
print "\t\"data\":[\n\n";
|
||
|
|
||
|
my $cmd;
|
||
|
my $re;
|
||
|
# On Linux, parse /proc/mounts
|
||
|
if (-e "/proc/mounts"){
|
||
|
$cmd = 'cat /proc/mounts';
|
||
|
$re = qr/\S+ (\S+) (\S+)/;
|
||
|
}
|
||
|
# On BSD (at least pfsense), there's no /proc/mounts
|
||
|
# parse the mount output
|
||
|
else{
|
||
|
$cmd = '/sbin/mount';
|
||
|
$re = qr/on (\S+) \((\S+), /;
|
||
|
}
|
||
|
for (`$cmd`){
|
||
|
($fsname, $fstype) = m/$re/;
|
||
|
$fsname =~ s!/!\\/!g;
|
||
|
|
||
|
print "\t,\n" if not $first;
|
||
|
$first = 0;
|
||
|
|
||
|
print "\t{\n";
|
||
|
print "\t\t\"{#FSNAME}\":\"$fsname\",\n";
|
||
|
print "\t\t\"{#FSTYPE}\":\"$fstype\"\n";
|
||
|
print "\t}\n";
|
||
|
}
|
||
|
|
||
|
print "\n\t]\n";
|
||
|
print "}\n";
|