summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-19 11:39:38 +0100
committerSimon Rettberg2023-01-19 11:39:38 +0100
commit7209f8a211de28a6b62c4532cc511a0cd70918f5 (patch)
tree0074eee8a40ffe0ef3d316c66571569719f5a4af
parent[bas-hw-collect] Add CD/DVD information (diff)
downloadsystemd-init-bas.tar.gz
systemd-init-bas.tar.xz
systemd-init-bas.zip
[hwinfo] Ignore duplicate links in /dev/disk/by-pathbas
-rwxr-xr-xmodules.d/bas-hw-collect/scripts/collect_hw_info_json.py9
1 files changed, 8 insertions, 1 deletions
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():