From 7209f8a211de28a6b62c4532cc511a0cd70918f5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 Jan 2023 11:39:38 +0100 Subject: [hwinfo] Ignore duplicate links in /dev/disk/by-path --- modules.d/bas-hw-collect/scripts/collect_hw_info_json.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py b/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py index 4e4a4f39..95f96378 100755 --- a/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py +++ b/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py @@ -119,6 +119,7 @@ def get_cdrom(): def get_disk_info(): diskdir = '/dev/disk/by-path/' disk_informations = {} + dupcheck = {} cdrom = get_cdrom() # Get and filter all disks @@ -129,8 +130,14 @@ def get_disk_info(): # Call all disk specific tools for d in filtered_disks: disk_path = diskdir + d + devpath = get_readlink(disk_path).rstrip() + # Sometimes there are multiple links to the same disk, e.g. named + # pci-0000:00:1f.2-ata-1.0 and pci-0000:00:1f.2-ata-1 + if devpath in dupcheck: + continue + dupcheck[devpath] = 1 disk_info = {} - disk_info['readlink'] = get_readlink(disk_path).rstrip() + disk_info['readlink'] = devpath # Check if it's a cd/dvd if disk_info['readlink'].split('/')[-1] in cdrom.keys(): -- cgit v1.2.3-55-g7522