From 7b0f469abcac8ce238a05610853d65c23fc8004e Mon Sep 17 00:00:00 2001 From: Hans Holmberg Date: Tue, 20 Jan 2026 17:10:51 +0100 Subject: [PATCH] Resolve the correct block device name when not a partition Only look up the parent block device if the block device is a partition Without this fix i get the following report for a fs mounted on /dev/sda: Queue and I/O settings: queue_depth: (not found: /sys/block/block/device/queue_depth) nr_requests: (not found: /sys/block/block/queue/nr_requests) max_sectors_kb: (not found: /sys/block/block/queue/max_sectors_kb) scheduler: (not found: /sys/block/block/queue/scheduler) write_cache (sys) : (not found: /sys/block/block/queue/write_cache) Signed-off-by: Hans Holmberg --- run-report.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/run-report.sh b/run-report.sh index 7e0e05c..0c499b0 100755 --- a/run-report.sh +++ b/run-report.sh @@ -223,12 +223,13 @@ def main(): sys.exit(1) dev, mount, write_jpg, update_jpg, pdf_out, device_path, ts, host = sys.argv[1:9] - dev_base = os.path.basename(device_path) + dev_block = os.path.basename(device_path) + # Resolve parent block device via sysfs to handle partitions (e.g., sdh1 -> sdh, nvme0n1p2 -> nvme0n1) - sys_class_path = os.path.realpath(f"/sys/class/block/{dev_base}") - dev_block = os.path.basename(os.path.dirname(sys_class_path)) - if not dev_block: - dev_block = dev_base + if os.path.isfile(f"/sys/class/block/{dev_block}/partition"): + sys_class_path = os.path.realpath(f"/sys/class/block/{dev_block}") + dev_block = os.path.basename(os.path.dirname(sys_class_path)) + sysfs_base = f"/sys/block/{dev_block}" dev_block_path = f"/dev/{dev_block}"