summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-07-10 14:49:45 +0200
committerSimon Rettberg2020-07-30 13:29:54 +0200
commit4754a84cbc3886c5e6cd4c1a82f29f6b4f5d31a7 (patch)
treed2c97648447b1525865ec57237ed09e5c5dc2d51
parent[locationinfo] Support styling clients with special runmode (diff)
downloadslx-admin-4754a84cbc3886c5e6cd4c1a82f29f6b4f5d31a7.tar.gz
slx-admin-4754a84cbc3886c5e6cd4c1a82f29f6b4f5d31a7.tar.xz
slx-admin-4754a84cbc3886c5e6cd4c1a82f29f6b4f5d31a7.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