SOURCES: net-snmp-lvm.patch (NEW) - lvm support by me
arekm
arekm at pld-linux.org
Wed Dec 12 16:00:15 CET 2007
Author: arekm Date: Wed Dec 12 15:00:15 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- lvm support by me
---- Files affected:
SOURCES:
net-snmp-lvm.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/net-snmp-lvm.patch
diff -u /dev/null SOURCES/net-snmp-lvm.patch:1.1
--- /dev/null Wed Dec 12 16:00:15 2007
+++ SOURCES/net-snmp-lvm.patch Wed Dec 12 16:00:10 2007
@@ -0,0 +1,92 @@
+--- net-snmp-5.4.1/agent/mibgroup/host/hr_disk.c.org 2007-12-12 13:20:44.349340358 +0100
++++ net-snmp-5.4.1/agent/mibgroup/host/hr_disk.c 2007-12-12 15:26:42.040513858 +0100
+@@ -61,6 +61,10 @@
+ # endif
+ #endif
+
++#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
++#include <regex.h>
++#endif
++
+ #if HAVE_LIMITS_H
+ #include <limits.h>
+ #endif
+@@ -172,6 +176,30 @@
+ Add_HR_Disk_entry("/dev/sd%c%d", -1, -1, 'a', 'p', "/dev/sd%c", 1, 15);
+ Add_HR_Disk_entry("/dev/md%d", -1, -1, 0, 3, "/dev/md%d", 0, 0);
+ Add_HR_Disk_entry("/dev/fd%d", -1, -1, 0, 1, "/dev/fd%d", 0, 0);
++#if defined(HAVE_REGEX_H) && defined(HAVE_REGCOMP)
++ /* LVM devices are harder because their name can be almost anything (see regexp below) */
++ {
++ regex_t lvol;
++
++ if (regcomp(&lvol, "[0-9a-zA-Z+_\\.-]+-[0-9a-zA-Z+_\\.-]+", REG_EXTENDED | REG_NOSUB) == 0) {
++ DIR *dir;
++ struct dirent *d;
++
++ dir = opendir("/dev/mapper/");
++ while ((d = readdir(dir)) != NULL) {
++ if (regexec(&lvol, d->d_name, 1, NULL, 0) == 0) {
++ char *path = malloc(PATH_MAX + 1); /* XXX: never freed; fortunately init_hr_disk is run only once(?) */
++ if (path == NULL)
++ continue; /* or some error? */
++ snprintf(path, PATH_MAX, "/dev/mapper/%s", d->d_name);
++ Add_HR_Disk_entry(path, -1, -1, 0, 0, path, 0, 0);
++ }
++ }
++ closedir(dir);
++ }
++ regfree(&lvol);
++ }
++#endif
+ #elif defined(hpux)
+ #if defined(hpux10) || defined(hpux11)
+ Add_HR_Disk_entry("/dev/rdsk/c%dt%xd%d", 0, 1, 0, 15,
+
+@@ -603,7 +629,7 @@
+
+ while (first_ctl <= last_ctl) {
+ for (lodev = first_dev;
+- lodev < last_dev && MAX_NUMBER_DISK_TYPES > HR_number_disk_types;
++ lodev <= last_dev && MAX_NUMBER_DISK_TYPES > HR_number_disk_types;
+ lodev += (1+MAX_DISKS_PER_TYPE), HR_number_disk_types++)
+ {
+ nbr_created++;
+@@ -658,7 +684,7 @@
+ int
+ Get_Next_HR_Disk(void)
+ {
+- char string[1024];
++ char string[PATH_MAX+1];
+ int fd, result;
+ int iindex;
+ int max_disks;
+@@ -699,6 +731,9 @@
+ disk_devices[HRD_type_index].disk_controller,
+ disk_devices[HRD_type_index].disk_device_first +
+ HRD_index);
++ } else if (disk_devices[HRD_type_index].disk_device_first == disk_devices[HRD_type_index].disk_device_last) {
++ /* exact device name */
++ snprintf(string, sizeof(string), "%s", disk_devices[HRD_type_index].disk_devfull_string);
+ } else {
+ snprintf(string, sizeof(string),
+ disk_devices[HRD_type_index].disk_devfull_string,
+@@ -877,7 +911,7 @@
+ #ifdef HAVE_LINUX_HDREG_H
+ if (HRD_type_index == 0) /* IDE hard disk */
+ result = ioctl(fd, HDIO_GET_IDENTITY, &HRD_info);
+- else if (HRD_type_index <= 2) { /* SCSI hard disk and md devices */
++ else if (HRD_type_index <= 2 || HRD_type_index == 4) { /* SCSI hard disk, md and LVM devices */
+ long h;
+ result = ioctl(fd, BLKGETSIZE, &h);
+ if (result != -1 && HRD_type_index == 2 && h == 0L)
+@@ -887,6 +921,9 @@
+ if (HRD_type_index == 1)
+ snprintf( HRD_info.model, sizeof(HRD_info.model)-1,
+ "SCSI disk (%s)", devfull);
++ else if (HRD_type_index == 4)
++ snprintf( HRD_info.model, sizeof(HRD_info.model)-1,
++ "LVM volume (%s)", devfull + strlen("/dev/mapper/"));
+ else
+ snprintf( HRD_info.model, sizeof(HRD_info.model)-1,
+ "RAID disk (%s)", devfull);
================================================================
More information about the pld-cvs-commit
mailing list