Browse Source

Merge pull request #18066 from TDT-AG/pr/20220315-collectd

collectd: update smart plugin
lilik-openwrt-22.03
Florian Eckert 3 years ago
committed by GitHub
parent
commit
fe4f165b8e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 10 deletions
  1. +0
    -10
      utils/collectd/patches/933-fix-smart-detection.patch
  2. +61
    -0
      utils/collectd/patches/941-Check-udev_enumerate_scan_devices-return-value.patch

+ 0
- 10
utils/collectd/patches/933-fix-smart-detection.patch View File

@ -1,10 +0,0 @@
--- a/src/smart.c
+++ b/src/smart.c
@@ -610,7 +610,6 @@ static int smart_read(void) {
return -1;
}
udev_enumerate_add_match_subsystem(enumerate, "block");
- udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
if (devices == NULL) {

+ 61
- 0
utils/collectd/patches/941-Check-udev_enumerate_scan_devices-return-value.patch View File

@ -0,0 +1,61 @@
From 289f58c9c96d5478cf200f7a3e62b82e86b12d32 Mon Sep 17 00:00:00 2001
From: Florian Eckert <fe@dev.tdt.de>
Date: Tue, 15 Mar 2022 14:56:19 +0100
Subject: [PATCH] Check udev_enumerate_scan_devices return value
This change checks the return value of the function and cancels the call
if the returned integer is not greater than or equal to 0.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
src/smart.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
--- a/src/smart.c
+++ b/src/smart.c
@@ -104,6 +104,7 @@ static int create_ignorelist_by_serial(i
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;
+ int r;
if (ignorelist_by_serial == NULL)
ignorelist_by_serial = ignorelist_create(invert_ignorelist);
@@ -127,7 +128,13 @@ static int create_ignorelist_by_serial(i
}
udev_enumerate_add_match_subsystem(enumerate, "block");
udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk");
- udev_enumerate_scan_devices(enumerate);
+
+ r = udev_enumerate_scan_devices(enumerate);
+ if (r < 0) {
+ WARNING("smart plugin: udev scan devices failed");
+ return -1;
+ }
+
devices = udev_enumerate_get_list_entry(enumerate);
if (devices == NULL) {
ERROR("udev returned an empty list deviecs");
@@ -597,6 +604,7 @@ static int smart_read(void) {
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
struct udev_device *dev;
+ int r;
/* Use udev to get a list of disks */
handle_udev = udev_new();
@@ -611,7 +619,13 @@ static int smart_read(void) {
}
udev_enumerate_add_match_subsystem(enumerate, "block");
udev_enumerate_add_match_property(enumerate, "DEVTYPE", "disk");
- udev_enumerate_scan_devices(enumerate);
+
+ r = udev_enumerate_scan_devices(enumerate);
+ if (r < 0) {
+ WARNING("smart plugin: udev scan devices failed");
+ return -1;
+ }
+
devices = udev_enumerate_get_list_entry(enumerate);
if (devices == NULL) {
ERROR("udev returned an empty list deviecs");

Loading…
Cancel
Save