Commit eb27ad00 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Filter mountpoints in camogmgui

parent 47834f84
...@@ -349,6 +349,8 @@ else ...@@ -349,6 +349,8 @@ else
case "listdevices": case "listdevices":
exec ("cat /proc/partitions", $arr1); exec ("cat /proc/partitions", $arr1);
exec ("cat /proc/mounts", $arr2); exec ("cat /proc/mounts", $arr2);
$ret = get_mnt_dev();
$mnt_dev = $ret["devices"];
$j = 0; $j = 0;
// first two lines are header and empty line separator, skip them // first two lines are header and empty line separator, skip them
$i = 2; $i = 2;
...@@ -372,33 +374,40 @@ else ...@@ -372,33 +374,40 @@ else
} }
$j = 0; $j = 0;
foreach ($partitions as $partition) { foreach ($partitions as $partition) {
echo "<item>"; $include = false;
echo "<partition>/dev/".$partition."</partition>"; foreach ($mnt_dev as $dev) {
echo "<size>".round($size[$j]/1024/1024, 2) ." GB</size>"; if (strpos($dev, $partition))
$j++; $include = true;
$i = 0;
while($i < count($arr2)) {
if(strpos($arr2[$i], $partition))
{
$parts = explode(" ", $arr2[$i]);
$mountpoint = $parts[1];
$filesystem = $parts[2];
}
$i++;
} }
if ($mountpoint != "") { if ($include) {
echo "<mountpoint>".$mountpoint."</mountpoint>"; echo "<item>";
$mountpoint = ""; echo "<partition>/dev/".$partition."</partition>";
} else { echo "<size>".round($size[$j]/1024/1024, 2) ." GB</size>";
echo "<mountpoint>none</mountpoint>"; $j++;
} $i = 0;
if ($filesystem != "") { while($i < count($arr2)) {
echo "<filesystem>".$filesystem."</filesystem>"; if(strpos($arr2[$i], $partition))
$filesystem = ""; {
} else { $parts = explode(" ", $arr2[$i]);
echo "<filesystem>none</filesystem>"; $mountpoint = $parts[1];
$filesystem = $parts[2];
}
$i++;
}
if ($mountpoint != "") {
echo "<mountpoint>".$mountpoint."</mountpoint>";
$mountpoint = "";
} else {
echo "<mountpoint>none</mountpoint>";
}
if ($filesystem != "") {
echo "<filesystem>".$filesystem."</filesystem>";
$filesystem = "";
} else {
echo "<filesystem>none</filesystem>";
}
echo "</item>";
} }
echo "</item>";
} }
break; break;
case "list_raw_devices": case "list_raw_devices":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment