From 3a5a1e5ccb94ddeb6380ea570fa69d5d58d7aec4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 10 Jul 2020 14:49:45 +0200 Subject: [statistics] Improve fdisk parsing for goofy fdisk variants --- modules-available/statistics/inc/parser.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- cgit v1.2.3-55-g7522