diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-04-20 20:49:37 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-04-20 20:49:37 +0000 |
commit | cd401f6732e8849ebd763413c6d53b1126b61a05 (patch) | |
tree | 39f328c491c012082094970eb0ffc6dfe4d07d1f /usr.sbin/snmpd/mib.c | |
parent | 5afe4381d46759178e7417c854cb9b517bb23955 (diff) |
Get rid of MAXSENSORDEVICES. Gaps in sensordev lists are now handled
by returning ENXIO instead of ENOENT, to essentially indicate hotplug
sensor that has gone away. Accessing beyond the end of the sensordev
list still returns ENOENT, so that you can see there are no further devices.
ok kettenis oga
Diffstat (limited to 'usr.sbin/snmpd/mib.c')
-rw-r--r-- | usr.sbin/snmpd/mib.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index 9a8cdb2dd51..3629bb472e3 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.37 2010/04/20 19:44:07 oga Exp $ */ +/* $OpenBSD: mib.c,v 1.38 2010/04/20 20:49:36 deraadt Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@vantronix.net> @@ -1246,13 +1246,15 @@ mib_sensornum(struct oid *oid, struct ber_oid *o, struct ber_element **elm) int mib[] = { CTL_HW, HW_SENSORS, 0 }; int i, c; - for (i = c = 0; i < MAXSENSORDEVICES; i++) { + for (i = c = 0; ; i++) { mib[2] = i; if (sysctl(mib, sizeofa(mib), &sensordev, &len, NULL, 0) == -1) { - if (errno != ENOENT) - return (-1); - continue; + if (errno = ENOENT) + break; + if (errno == ENXIO) + continue; + return (-1); } c += sensordev.sensors_count; } @@ -1277,12 +1279,14 @@ mib_sensors(struct oid *oid, struct ber_oid *o, struct ber_element **elm) /* Get and verify the current row index */ idx = o->bo_id[OIDIDX_sensorEntry]; - for (i = 0, n = 1; i < MAXSENSORDEVICES; i++) { + for (i = 0, n = 1; ; i++) { mib[2] = i; if (sysctl(mib, 3, &sensordev, &len, NULL, 0) == -1) { - if (errno != ENOENT) - return (-1); - continue; + if (errno == EINVAL) + break; + if (errno == ENOENT) + continue; + return (-1); } for (j = 0; j < SENSOR_MAX_TYPES; j++) { mib[3] = j; |