summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-07-10 14:49:45 +0200
committerSimon Rettberg2020-07-10 14:49:45 +0200
commit3a5a1e5ccb94ddeb6380ea570fa69d5d58d7aec4 (patch)
tree99be55d77dbb80e2a6f298fb4a542c19c8c9a614
parent[locationinfo] Support styling clients with special runmode (diff)
downloadslx-admin-3a5a1e5ccb94ddeb6380ea570fa69d5d58d7aec4.tar.gz
slx-admin-3a5a1e5ccb94ddeb6380ea570fa69d5d58d7aec4.tar.xz
slx-admin-3a5a1e5ccb94ddeb6380ea570fa69d5d58d7aec4.zip
[statistics] Improve fdisk parsing for goofy fdisk variants
-rw-r--r--modules-available/statistics/inc/parser.inc.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules-available/statistics/inc/parser.inc.php b/modules-available/statistics/inc/parser.inc.php
index d697c733..bdf021a6 100644
--- a/modules-available/statistics/inc/parser.inc.php
+++ b/modules-available/statistics/inc/parser.inc.php
@@ -199,6 +199,12 @@ class Parser {
} elseif (preg_match('/^Logical sector size:\s*(\d+)/i', $line, $out)) {
// --- GPT: Line that tells us the logical sector size used everywhere ---
$sectorToMbFactor = $out[1] / (1024 * 1024);
+ } elseif (isset($hdd) && preg_match('/^First usable sector.* is (\d+)$/i', $line, $out)) {
+ // --- Some fdisk versions are messed up and report 2^32 as the sector count in the first line,
+ // but the correct value in the "last usable sector is xxxx" line below ---
+ if ($out[1] > $hdd['sectors']) {
+ $hdd['sectors'] = $out[1];
+ }
} elseif (isset($hdd) && $mbrToMbFactor !== 0 && preg_match(',^/dev/(\S+)\s+.*\s(\d+)[\+\-]?\s+(\d+)[\+\-]?\s+\d+[\+\-]?\s+([0-9a-f]+)\s+(.*)$,i', $line, $out)) {
// --- MBR: Partition entry ---
// Some partition