~ubuntu-branches/ubuntu/precise/net-snmp/precise

« back to all changes in this revision

Viewing changes to debian/patches/60_libsensors_api.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-28 14:59:36 UTC
  • mfrom: (1.2.3 upstream) (1.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100628145936-cbiallic69pn044g
Tags: 5.4.3~dfsg-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/snmpd.postinst: source debconf before doing work, LP: #589056
  - debian/snmp.preinst, debian/snmp.prerm: kill any/all processes owned by
    snmp user before install/uninstall, LP: #573391
  - Add apport hook (LP: #533603):
  - debian/{snmp,snmpd}.apport: Added.
  - debian/control: Build-depends on dh-apport.
  - debian/rules: 
    + Add --with apport.
    + override_dh_apport to install hook on snmpd package only.
 * Dropped patches:
   - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff --git a/agent/mibgroup/ucd-snmp/lmSensors.c b/agent/mibgroup/ucd-snmp/lmSensors.c
2
 
index d7dbd98..8f9fcd2 100644
3
 
--- a/agent/mibgroup/ucd-snmp/lmSensors.c
4
 
+++ b/agent/mibgroup/ucd-snmp/lmSensors.c
5
 
@@ -390,7 +390,7 @@ static int
 
1
Index: net-snmp-5.4.3/agent/mibgroup/ucd-snmp/lmSensors.c
 
2
===================================================================
 
3
--- net-snmp-5.4.3.orig/agent/mibgroup/ucd-snmp/lmSensors.c     2010-06-04 18:04:58.000000000 +0200
 
4
+++ net-snmp-5.4.3/agent/mibgroup/ucd-snmp/lmSensors.c  2010-06-04 18:06:48.000000000 +0200
 
5
@@ -89,7 +89,6 @@
 
6
     #include </usr/platform/sun4u/include/sys/envctrl.h>
 
7
 #else
 
8
     #include <sensors/sensors.h>
 
9
-    #define CONFIG_FILE_NAME "/etc/sensors.conf"
 
10
 #endif
 
11
 
 
12
 #include "lmSensors.h"
 
13
@@ -247,7 +246,7 @@
 
14
                    size_t * var_len, WriteMethod ** write_method)
 
15
 {
 
16
     static long     long_ret;
 
17
-    static unsigned char string[SPRINT_MAX_LEN];
 
18
+    static char string[SPRINT_MAX_LEN];
 
19
 
 
20
     int             s_index;
 
21
     int             s_type = -1;
 
22
@@ -352,9 +351,7 @@
 
23
 {
 
24
     int             res;
 
25
 #ifndef solaris2
 
26
-    char            filename[] = CONFIG_FILE_NAME;
 
27
     time_t          t = time(NULL);
 
28
-    FILE            *fp = fopen(filename, "r");
 
29
     int             i = 0;
 
30
   
 
31
     DEBUGMSG(("ucd-snmp/lmSensors", "=> sensor_init\n"));
 
32
@@ -366,13 +363,7 @@
 
33
         sensor_array[i].sensor = NULL;
 
34
     }
 
35
 
 
36
-    if (!fp)
 
37
-    {
 
38
-        res = 1;
 
39
-        goto leaving;
 
40
-    }
 
41
-
 
42
-    if (sensors_init(fp))
 
43
+    if (sensors_init(NULL))
 
44
     {
 
45
         res = 2;
 
46
         goto leaving;
 
47
@@ -390,7 +381,7 @@
6
48
 sensor_load(void)
7
49
 {
8
50
     int rc = 0;
11
53
 
12
54
     if (t > timestamp + 7) /* this may require some tuning - currently 7 seconds*/
13
55
     {
14
 
@@ -962,77 +962,78 @@ else{
 
56
@@ -940,7 +931,8 @@
 
57
 #else /* end solaris2 only ie. ifdef everything else */
 
58
 
 
59
     const sensors_chip_name *chip;
 
60
-    const sensors_feature_data *data;
 
61
+    const sensors_feature *feature;
 
62
+    const sensors_subfeature *subfeature;
 
63
     int             chip_nr = 0;
 
64
     int             rc = 0;
 
65
     unsigned int    i = 0;
 
66
@@ -961,78 +953,80 @@
 
67
         sensor_array[i].current_len = DEFAULT_SENSORS;
15
68
     } /* end for */
16
69
 
17
 
     while ((chip = sensors_get_detected_chips(&chip_nr))) {
 
70
-    while ((chip = sensors_get_detected_chips(&chip_nr))) {
18
71
-       int             a = 0;
19
72
-       int             b = 0;
20
 
+        int             a = 0;
21
 
+            int             b = 0;
22
 
 
 
73
-
23
74
-        while ((data = sensors_get_all_features(*chip, &a, &b))) {
24
75
-            char           *label = NULL;
25
76
-            double          val;
26
 
+            while ((data = sensors_get_all_features(*chip, &a, &b))) {
27
 
+                char           *label = NULL;
28
 
+                double          val;
29
 
 
 
77
-
30
78
-            if ((data->mode & SENSORS_MODE_R) &&
31
79
-                (data->mapping == SENSORS_NO_MAPPING) &&
32
80
-                !sensors_get_label(*chip, data->number, &label) &&
34
82
-                int             type = -1;
35
83
-                float           mul;
36
84
-                _sensor_array  *array;
37
 
+                if ((data->mode & SENSORS_MODE_R) &&
38
 
+                    (data->mapping == SENSORS_NO_MAPPING) &&
39
 
+                    !sensors_get_label(*chip, data->number, &label) &&
40
 
+                    !sensors_get_feature(*chip, data->number, &val)) {
41
 
+                    int             type = -1;
42
 
+                    float           mul;
43
 
+                    _sensor_array  *array;
44
 
 
 
85
-
45
86
-                /* The label, as determined for a given chip in sensors.conf,
46
87
-                 * is used to place each sensor in the appropriate bucket.
47
88
-                 * Volt, Fan, Temp, and Misc.  If the text being looked for below
48
89
-                 * is not in the label of a given sensor (e.g., the temp1 sensor
49
90
-                 * has been labeled 'CPU' and not 'CPU temp') it will end up being
50
91
-                 * lumped in the MISC bucket. */
51
 
+                    /* The label, as determined for a given chip in
52
 
+                     * sensors.conf, is used to place each sensor in the
53
 
+                     * appropriate bucket.  Volt, Fan, Temp, and Misc.
54
 
+                     * If the text being looked for below is not in the
55
 
+                     * label of a given sensor (e.g., the temp1 sensor
56
 
+                     * has been labeled 'CPU' and not 'CPU temp') it
57
 
+                     * will end up being lumped in the MISC bucket. */
58
 
 
 
92
-
59
93
-                if (strstr(label, "V")) {
60
94
-                    type = VOLT_TYPE;
61
95
-                    mul = 1000.0;
72
106
-                    type = MISC_TYPE;
73
107
-                    mul = 1000.0;
74
108
-                }
75
 
+                    if (strstr(label, "V")) {
76
 
+                        type = VOLT_TYPE;
77
 
+                        mul = 1000.0;
78
 
+                    }
79
 
+                    if (strstr(label, "fan") || strstr(label, "Fan")) {
80
 
+                        type = FAN_TYPE;
81
 
+                        mul = 1.0;
82
 
+                    }
83
 
+                    if (strstr(label, "temp") || strstr(label, "Temp")) {
84
 
+                        type = TEMP_TYPE;
85
 
+                        mul = 1000.0;
86
 
+                    }
87
 
+                    if (type == -1) {
88
 
+                        type = MISC_TYPE;
89
 
+                        mul = 1000.0;
90
 
+                    }
91
 
 
 
109
-
92
110
-                array = &sensor_array[type];
93
111
-                if ( array->current_len <= array->n) {
94
112
-                    _sensor* old_buffer = array->sensor;
121
139
-               label = NULL;
122
140
-           } /* end if label */
123
141
-        } /* end while data */
 
142
+    while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
 
143
+        int             a = 0;
 
144
+        while ((feature = sensors_get_features(chip, &a))) {
 
145
+            int             b = 0;
 
146
+            while ((subfeature = sensors_get_all_subfeatures(chip,
 
147
+                    feature, &b))) {
 
148
+                char           *label = NULL;
 
149
+                double          val;
 
150
+
 
151
+                if ((subfeature->flags & SENSORS_MODE_R) &&
 
152
+                    (label = sensors_get_label(chip, feature)) &&
 
153
+                    !sensors_get_value(chip, subfeature->number, &val)) {
 
154
+                    int             type = -1;
 
155
+                    float           mul;
 
156
+                    _sensor_array  *array;
 
157
+
 
158
+                    /* The label, as determined for a given chip in
 
159
+                     * sensors.conf, is used to place each sensor in the
 
160
+                     * appropriate bucket.  Volt, Fan, Temp, and Misc.
 
161
+                     * If the text being looked for below is not in the
 
162
+                     * label of a given sensor (e.g., the temp1 sensor
 
163
+                     * has been labeled 'CPU' and not 'CPU temp') it
 
164
+                     * will end up being lumped in the MISC bucket. */
 
165
+
 
166
+                    if (strstr(label, "V")) {
 
167
+                        type = VOLT_TYPE;
 
168
+                        mul = 1000.0;
 
169
+                    }
 
170
+                    if (strstr(label, "fan") || strstr(label, "Fan")) {
 
171
+                        type = FAN_TYPE;
 
172
+                        mul = 1.0;
 
173
+                    }
 
174
+                    if (strstr(label, "temp") || strstr(label, "Temp")) {
 
175
+                        type = TEMP_TYPE;
 
176
+                        mul = 1000.0;
 
177
+                    }
 
178
+                    if (type == -1) {
 
179
+                        type = MISC_TYPE;
 
180
+                        mul = 1000.0;
 
181
+                    }
 
182
+
124
183
+                    array = &sensor_array[type];
125
184
+                    if ( array->current_len <= array->n) {
126
185
+                        _sensor* old_buffer = array->sensor;
152
211
+                    free(label);
153
212
+                    label = NULL;
154
213
+                } /* end if label */
155
 
+            } /* end while data */
156
 
     } /* end while chip */
157
 
     return rc;
158
 
 #endif  /* end else ie. ifdef everything else */
159
 
diff --git a/agent/mibgroup/ucd-snmp/lmSensors.c b/agent/mibgroup/ucd-snmp/lmSensors.c
160
 
index 8f9fcd2..e42e0e2 100644
161
 
--- a/agent/mibgroup/ucd-snmp/lmSensors.c
162
 
+++ b/agent/mibgroup/ucd-snmp/lmSensors.c
163
 
@@ -89,7 +89,6 @@
164
 
     #include </usr/platform/sun4u/include/sys/envctrl.h>
165
 
 #else
166
 
     #include <sensors/sensors.h>
167
 
-    #define CONFIG_FILE_NAME "/etc/sensors.conf"
168
 
 #endif
169
 
 
170
 
 #include "lmSensors.h"
171
 
@@ -247,7 +246,7 @@ var_lmSensorsTable(struct variable *vp,
172
 
                    size_t * var_len, WriteMethod ** write_method)
173
 
 {
174
 
     static long     long_ret;
175
 
-    static unsigned char string[SPRINT_MAX_LEN];
176
 
+    static char string[SPRINT_MAX_LEN];
177
 
 
178
 
     int             s_index;
179
 
     int             s_type = -1;
180
 
@@ -352,9 +351,7 @@ sensor_init(void)
181
 
 {
182
 
     int             res;
183
 
 #ifndef solaris2
184
 
-    char            filename[] = CONFIG_FILE_NAME;
185
 
     time_t          t = time(NULL);
186
 
-    FILE            *fp = fopen(filename, "r");
187
 
     int             i = 0;
188
 
   
189
 
     DEBUGMSG(("ucd-snmp/lmSensors", "=> sensor_init\n"));
190
 
@@ -366,13 +363,7 @@ sensor_init(void)
191
 
         sensor_array[i].sensor = NULL;
192
 
     }
193
 
 
194
 
-    if (!fp)
195
 
-    {
196
 
-        res = 1;
197
 
-        goto leaving;
198
 
-    }
199
 
-
200
 
-    if (sensors_init(fp))
201
 
+    if (sensors_init(NULL))
202
 
     {
203
 
         res = 2;
204
 
         goto leaving;
205
 
@@ -940,7 +931,8 @@ else{
206
 
 #else /* end solaris2 only ie. ifdef everything else */
207
 
 
208
 
     const sensors_chip_name *chip;
209
 
-    const sensors_feature_data *data;
210
 
+    const sensors_feature *feature;
211
 
+    const sensors_subfeature *subfeature;
212
 
     int             chip_nr = 0;
213
 
     int             rc = 0;
214
 
     unsigned int    i = 0;
215
 
@@ -961,18 +953,19 @@ else{
216
 
         sensor_array[i].current_len = DEFAULT_SENSORS;
217
 
     } /* end for */
218
 
 
219
 
-    while ((chip = sensors_get_detected_chips(&chip_nr))) {
220
 
+    while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
221
 
         int             a = 0;
222
 
+        while ((feature = sensors_get_features(chip, &a))) {
223
 
             int             b = 0;
224
 
-
225
 
-            while ((data = sensors_get_all_features(*chip, &a, &b))) {
226
 
+            while ((subfeature = sensors_get_all_subfeatures(chip,
227
 
+                    feature, &b))) {
228
 
                 char           *label = NULL;
229
 
                 double          val;
230
 
 
231
 
-                if ((data->mode & SENSORS_MODE_R) &&
232
 
-                    (data->mapping == SENSORS_NO_MAPPING) &&
233
 
-                    !sensors_get_label(*chip, data->number, &label) &&
234
 
-                    !sensors_get_feature(*chip, data->number, &val)) {
235
 
+                if ((subfeature->flags & SENSORS_MODE_R) &&
236
 
+                    (subfeature->mapping == 0) &&
237
 
+                    (label = sensors_get_label(chip, feature)) &&
238
 
+                    !sensors_get_value(chip, subfeature->number, &val)) {
239
 
                     int             type = -1;
240
 
                     float           mul;
241
 
                     _sensor_array  *array;
242
 
@@ -1033,7 +1026,8 @@ else{
243
 
                     free(label);
244
 
                     label = NULL;
245
 
                 } /* end if label */
246
 
-            } /* end while data */
247
214
+            } /* end while subfeature */
248
215
+        } /* end while feature */
249
216
     } /* end while chip */