From a46e358d68027289cffaffeb7a4b32ababb2105b Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Wed, 12 Jul 2006 22:53:27 +0000 Subject: Added -E option for exact match of filesystem. Restructured main filesystem loop. Added extra tests for possible duplicate filesystems. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1449 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/utils_disk.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'plugins/utils_disk.c') diff --git a/plugins/utils_disk.c b/plugins/utils_disk.c index 0a71d792..31284d5d 100644 --- a/plugins/utils_disk.c +++ b/plugins/utils_disk.c @@ -43,9 +43,11 @@ np_add_name (struct name_list **list, const char *name) *list = new_entry; } -void +/* Initialises a new parameter at the end of list */ +struct parameter_list * np_add_parameter(struct parameter_list **list, const char *name) { + struct parameter_list *current = *list; struct parameter_list *new_path; new_path = (struct parameter_list *) malloc (sizeof *new_path); new_path->name = (char *) name; @@ -57,8 +59,17 @@ np_add_parameter(struct parameter_list **list, const char *name) new_path->c_dfp = -1.0; new_path->w_idfp = -1.0; new_path->c_idfp = -1.0; - new_path->name_next = *list; - *list = new_path; + new_path->best_match = NULL; + + if (current == NULL) { + *list = new_path; + } else { + while (current->name_next) { + current = current->name_next; + } + current->name_next = new_path; + } + return new_path; } void @@ -93,6 +104,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list if (best_match) { d->best_match = best_match; d->found = TRUE; + } else { + d->best_match = NULL; /* Not sure why this is needed as it should be null on initialisation */ } } } @@ -114,3 +127,15 @@ np_find_name (struct name_list *list, const char *name) return FALSE; } +int +np_seen_name(struct name_list *list, const char *name) +{ + const struct name_list *s; + for (s = list; s; s=s->next) { + if (!strcmp(s->name, name)) { + return TRUE; + } + } + return FALSE; +} + -- cgit v1.2.3