Deleted Added
full compact
hostres_diskstorage_tbl.c (154858) hostres_diskstorage_tbl.c (160341)
1/*-
2 * Copyright (c) 2005-2006 The FreeBSD Project
3 * All rights reserved.
4 *
5 * Author: Victor Cruceru <soc-victor@freebsd.org>
6 *
7 * Redistribution of this software and documentation and use in source and
8 * binary forms, with or without modification, are permitted provided that

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*-
2 * Copyright (c) 2005-2006 The FreeBSD Project
3 * All rights reserved.
4 *
5 * Author: Victor Cruceru <soc-victor@freebsd.org>
6 *
7 * Redistribution of this software and documentation and use in source and
8 * binary forms, with or without modification, are permitted provided that

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c 154858 2006-01-26 11:49:27Z harti $
29 * $FreeBSD: head/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c 160341 2006-07-14 09:07:56Z harti $
30 */
31
32/*
33 * Host Resources MIB for SNMPd. Implementation for the hrDiskStorageTable
34 */
35
36#include <sys/types.h>
37#include <sys/param.h>

--- 129 unchanged lines hidden (view full) ---

167}
168
169/**
170 * Delete a disk table entry.
171 */
172static void
173disk_entry_delete(struct disk_entry *entry)
174{
30 */
31
32/*
33 * Host Resources MIB for SNMPd. Implementation for the hrDiskStorageTable
34 */
35
36#include <sys/types.h>
37#include <sys/param.h>

--- 129 unchanged lines hidden (view full) ---

167}
168
169/**
170 * Delete a disk table entry.
171 */
172static void
173disk_entry_delete(struct disk_entry *entry)
174{
175 struct device_entry *devEntry;
175
176 assert(entry != NULL);
176
177 assert(entry != NULL);
177
178 TAILQ_REMOVE(&disk_tbl, entry, link);
178 TAILQ_REMOVE(&disk_tbl, entry, link);
179
180 devEntry = device_find_by_index(entry->index);
181
179 free(entry);
182 free(entry);
183
184 /*
185 * Also delete the respective device entry -
186 * this is needed for disk devices that are not
187 * detected by libdevinfo
188 */
189 if (devEntry != NULL &&
190 (devEntry->flags & HR_DEVICE_IMMUTABLE) == HR_DEVICE_IMMUTABLE)
191 device_entry_delete(devEntry);
180}
181
182/**
183 * Find a disk storage entry given its index.
184 */
185static struct disk_entry *
186disk_find_by_index(int32_t idx)
187{

--- 97 unchanged lines hidden (view full) ---

285 * adv(4) - they are not disks!
286 */
287 if (strlen(map->name_key) > strlen(found->dev_name) &&
288 !isdigit(map->name_key[strlen(found->dev_name)]))
289 continue;
290
291 /* First get the entry from the hrDeviceTbl */
292 entry = map->entry_p;
192}
193
194/**
195 * Find a disk storage entry given its index.
196 */
197static struct disk_entry *
198disk_find_by_index(int32_t idx)
199{

--- 97 unchanged lines hidden (view full) ---

297 * adv(4) - they are not disks!
298 */
299 if (strlen(map->name_key) > strlen(found->dev_name) &&
300 !isdigit(map->name_key[strlen(found->dev_name)]))
301 continue;
302
303 /* First get the entry from the hrDeviceTbl */
304 entry = map->entry_p;
293 entry->type = OIDX_hrDeviceDiskStorage_c;
305 entry->type = &OIDX_hrDeviceDiskStorage_c;
294
295 /* Then check hrDiskStorage table for this device */
296 disk_entry = disk_find_by_index(entry->index);
297 if (disk_entry == NULL) {
298 disk_entry = disk_entry_create(entry);
299 if (disk_entry == NULL)
300 continue;
301

--- 28 unchanged lines hidden (view full) ---

330
331 /* Look for md devices */
332 STAILQ_FOREACH(map, &device_map, link) {
333 if (sscanf(map->name_key, "md%d", &unit) != 1)
334 continue;
335
336 /* First get the entry from the hrDeviceTbl */
337 entry = device_find_by_index(map->hrIndex);
306
307 /* Then check hrDiskStorage table for this device */
308 disk_entry = disk_find_by_index(entry->index);
309 if (disk_entry == NULL) {
310 disk_entry = disk_entry_create(entry);
311 if (disk_entry == NULL)
312 continue;
313

--- 28 unchanged lines hidden (view full) ---

342
343 /* Look for md devices */
344 STAILQ_FOREACH(map, &device_map, link) {
345 if (sscanf(map->name_key, "md%d", &unit) != 1)
346 continue;
347
348 /* First get the entry from the hrDeviceTbl */
349 entry = device_find_by_index(map->hrIndex);
338 entry->type = OIDX_hrDeviceDiskStorage_c;
350 entry->type = &OIDX_hrDeviceDiskStorage_c;
339
340 /* Then check hrDiskStorage table for this device */
341 disk_entry = disk_find_by_index(entry->index);
342 if (disk_entry == NULL) {
343 disk_entry = disk_entry_create(entry);
344 if (disk_entry == NULL)
345 continue;
346

--- 74 unchanged lines hidden (view full) ---

421
422 snprintf(disk_device, sizeof(disk_device),
423 "%s%s", _PATH_DEV, disk);
424
425 /* First check if the disk is in the hrDeviceTable. */
426 if ((entry = device_find_by_name(disk)) == NULL) {
427 /*
428 * not found there - insert it as immutable
351
352 /* Then check hrDiskStorage table for this device */
353 disk_entry = disk_find_by_index(entry->index);
354 if (disk_entry == NULL) {
355 disk_entry = disk_entry_create(entry);
356 if (disk_entry == NULL)
357 continue;
358

--- 74 unchanged lines hidden (view full) ---

433
434 snprintf(disk_device, sizeof(disk_device),
435 "%s%s", _PATH_DEV, disk);
436
437 /* First check if the disk is in the hrDeviceTable. */
438 if ((entry = device_find_by_name(disk)) == NULL) {
439 /*
440 * not found there - insert it as immutable
429 * XXX somehow we should remove it if it disappears
430 */
431 syslog(LOG_WARNING, "%s: device '%s' not in "
432 "device list", __func__, disk);
433
434 if ((entry = device_entry_create(disk, "", "")) == NULL)
435 continue;
436
437 entry->flags |= HR_DEVICE_IMMUTABLE;
438 }
439
441 */
442 syslog(LOG_WARNING, "%s: device '%s' not in "
443 "device list", __func__, disk);
444
445 if ((entry = device_entry_create(disk, "", "")) == NULL)
446 continue;
447
448 entry->flags |= HR_DEVICE_IMMUTABLE;
449 }
450
440 entry->type = OIDX_hrDeviceDiskStorage_c;
451 entry->type = &OIDX_hrDeviceDiskStorage_c;
441
442 /* Then check hrDiskStorage table for this device */
443 disk_entry = disk_find_by_index(entry->index);
444 if (disk_entry == NULL) {
445 disk_entry = disk_entry_create(entry);
446 if (disk_entry == NULL)
447 continue;
448 }

--- 184 unchanged lines hidden ---
452
453 /* Then check hrDiskStorage table for this device */
454 disk_entry = disk_find_by_index(entry->index);
455 if (disk_entry == NULL) {
456 disk_entry = disk_entry_create(entry);
457 if (disk_entry == NULL)
458 continue;
459 }

--- 184 unchanged lines hidden ---