summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-07-12 12:15:42 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-07-12 12:15:42 (GMT)
commitee03f1415acc9f4f8901593d9045244fbb3bbbb0 (patch)
tree32faccd0a0ac25373fec4823499969e62c2541ae /plugins
parentdf23fd75267c830f85a74cfde3020981c37e82a5 (diff)
downloadmonitoring-plugins-ee03f1415acc9f4f8901593d9045244fbb3bbbb0.tar.gz
Moving check_disk functions into utils_disk.c and testing them
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1447 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Makefile.am4
-rw-r--r--plugins/check_disk.c108
-rw-r--r--plugins/tests/Makefile.am9
-rw-r--r--plugins/tests/test_disk.c85
-rwxr-xr-xplugins/tests/test_disk.t6
-rw-r--r--plugins/utils_disk.c62
-rw-r--r--plugins/utils_disk.h12
7 files changed, 205 insertions, 81 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 81645b8..28793cd 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -55,7 +55,7 @@ AM_INSTALL_PROGRAM_FLAGS = @INSTALL_OPTS@
55 55
56check_apt_LDADD = $(BASEOBJS) runcmd.o 56check_apt_LDADD = $(BASEOBJS) runcmd.o
57check_dig_LDADD = $(NETLIBS) runcmd.o 57check_dig_LDADD = $(NETLIBS) runcmd.o
58check_disk_LDADD = $(BASEOBJS) popen.o 58check_disk_LDADD = $(BASEOBJS) popen.o utils_disk.o
59check_dns_LDADD = $(NETLIBS) runcmd.o 59check_dns_LDADD = $(NETLIBS) runcmd.o
60check_dummy_LDADD = $(BASEOBJS) 60check_dummy_LDADD = $(BASEOBJS)
61check_fping_LDADD = $(NETLIBS) popen.o 61check_fping_LDADD = $(NETLIBS) popen.o
@@ -98,7 +98,7 @@ urlize_LDADD = $(BASEOBJS) popen.o
98 98
99check_apt_DEPENDENCIES = check_apt.c $(BASEOBJS) runcmd.o $(DEPLIBS) 99check_apt_DEPENDENCIES = check_apt.c $(BASEOBJS) runcmd.o $(DEPLIBS)
100check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) runcmd.o $(DEPLIBS) 100check_dig_DEPENDENCIES = check_dig.c $(NETOBJS) runcmd.o $(DEPLIBS)
101check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o $(DEPLIBS) 101check_disk_DEPENDENCIES = check_disk.c $(BASEOBJS) popen.o utils_disk.o $(DEPLIBS)
102check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) runcmd.o $(DEPLIBS) 102check_dns_DEPENDENCIES = check_dns.c $(NETOBJS) runcmd.o $(DEPLIBS)
103check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS) 103check_dummy_DEPENDENCIES = check_dummy.c $(DEPLIBS)
104check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS) 104check_fping_DEPENDENCIES = check_fping.c $(NETOBJS) popen.o $(DEPLIBS)
diff --git a/plugins/check_disk.c b/plugins/check_disk.c
index 8a824c1..f0a679d 100644
--- a/plugins/check_disk.c
+++ b/plugins/check_disk.c
@@ -37,10 +37,6 @@ const char *revision = "$Revision$";
37const char *copyright = "1999-2006"; 37const char *copyright = "1999-2006";
38const char *email = "nagiosplug-devel@lists.sourceforge.net"; 38const char *email = "nagiosplug-devel@lists.sourceforge.net";
39 39
40 /*
41 * Additional inode code by Jorgen Lundman <lundman@lundman.net>
42 */
43
44 40
45#include "common.h" 41#include "common.h"
46#if HAVE_INTTYPES_H 42#if HAVE_INTTYPES_H
@@ -50,12 +46,14 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
50#include "popen.h" 46#include "popen.h"
51#include "utils.h" 47#include "utils.h"
52#include <stdarg.h> 48#include <stdarg.h>
53#include "../lib/fsusage.h" 49#include "fsusage.h"
54#include "../lib/mountlist.h" 50#include "mountlist.h"
55#if HAVE_LIMITS_H 51#if HAVE_LIMITS_H
56# include <limits.h> 52# include <limits.h>
57#endif 53#endif
58 54
55#include "utils_disk.h"
56
59/* If nonzero, show inode information. */ 57/* If nonzero, show inode information. */
60static int inode_format; 58static int inode_format;
61 59
@@ -77,8 +75,7 @@ static int show_local_fs = 0;
77/* static int require_sync = 0; */ 75/* static int require_sync = 0; */
78 76
79/* A filesystem type to display. */ 77/* A filesystem type to display. */
80 78struct parameter_list
81struct name_list
82{ 79{
83 char *name; 80 char *name;
84 int found; 81 int found;
@@ -89,7 +86,7 @@ struct name_list
89 double c_dfp; 86 double c_dfp;
90 double w_idfp; 87 double w_idfp;
91 double c_idfp; 88 double c_idfp;
92 struct name_list *name_next; 89 struct parameter_list *name_next;
93}; 90};
94 91
95/* Linked list of filesystem types to display. 92/* Linked list of filesystem types to display.
@@ -103,7 +100,7 @@ struct name_list
103 Some filesystem types: 100 Some filesystem types:
104 4.2 4.3 ufs nfs swap ignore io vm efs dbg */ 101 4.2 4.3 ufs nfs swap ignore io vm efs dbg */
105 102
106/* static struct name_list *fs_select_list; */ 103/* static struct parameter_list *fs_select_list; */
107 104
108/* Linked list of filesystem types to omit. 105/* Linked list of filesystem types to omit.
109 If the list is empty, don't exclude any types. */ 106 If the list is empty, don't exclude any types. */
@@ -112,9 +109,7 @@ static struct name_list *fs_exclude_list;
112 109
113static struct name_list *dp_exclude_list; 110static struct name_list *dp_exclude_list;
114 111
115static struct name_list *path_select_list; 112static struct parameter_list *path_select_list;
116
117static struct name_list *dev_select_list;
118 113
119/* Linked list of mounted filesystems. */ 114/* Linked list of mounted filesystems. */
120static struct mount_entry *mount_list; 115static struct mount_entry *mount_list;
@@ -132,11 +127,14 @@ enum
132 #pragma alloca 127 #pragma alloca
133#endif 128#endif
134 129
130/* Linked list of mounted filesystems. */
131static struct mount_entry *mount_list;
132
135int process_arguments (int, char **); 133int process_arguments (int, char **);
136void print_path (const char *mypath); 134void print_path (const char *mypath);
137int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *); 135int validate_arguments (uintmax_t, uintmax_t, double, double, double, double, char *);
138int check_disk (double usp, uintmax_t free_disk, double uisp); 136int check_disk (double usp, uintmax_t free_disk, double uisp);
139int walk_name_list (struct name_list *list, const char *name); 137int walk_parameter_list (struct parameter_list *list, const char *name);
140void print_help (void); 138void print_help (void);
141void print_usage (void); 139void print_usage (void);
142 140
@@ -154,9 +152,6 @@ int verbose = 0;
154int erronly = FALSE; 152int erronly = FALSE;
155int display_mntp = FALSE; 153int display_mntp = FALSE;
156 154
157/* Linked list of mounted filesystems. */
158static struct mount_entry *mount_list;
159
160 155
161 156
162int 157int
@@ -174,7 +169,7 @@ main (int argc, char **argv)
174 169
175 struct mount_entry *me; 170 struct mount_entry *me;
176 struct fs_usage fsp; 171 struct fs_usage fsp;
177 struct name_list *temp_list; 172 struct parameter_list *temp_list;
178 173
179 output = strdup (" - free space:"); 174 output = strdup (" - free space:");
180 details = strdup (""); 175 details = strdup ("");
@@ -199,8 +194,8 @@ main (int argc, char **argv)
199 */ 194 */
200 if(path_select_list){ 195 if(path_select_list){
201 for (me = mount_list; me; me = me->me_next) { 196 for (me = mount_list; me; me = me->me_next) {
202 walk_name_list(path_select_list, me->me_mountdir); 197 walk_parameter_list(path_select_list, me->me_mountdir);
203 walk_name_list(path_select_list, me->me_devname); 198 walk_parameter_list(path_select_list, me->me_devname);
204 } 199 }
205 /* now pretend we never saw anything, but keep found_len. 200 /* now pretend we never saw anything, but keep found_len.
206 * thus future searches will only match the best match */ 201 * thus future searches will only match the best match */
@@ -214,12 +209,12 @@ main (int argc, char **argv)
214 /* if there's a list of paths to select, the current mount 209 /* if there's a list of paths to select, the current mount
215 * entry matches in path or device name, get fs usage */ 210 * entry matches in path or device name, get fs usage */
216 if (path_select_list && 211 if (path_select_list &&
217 (walk_name_list (path_select_list, me->me_mountdir) || 212 (walk_parameter_list (path_select_list, me->me_mountdir) ||
218 walk_name_list (path_select_list, me->me_devname) ) ) { 213 walk_parameter_list (path_select_list, me->me_devname) ) ) {
219 get_fs_usage (me->me_mountdir, me->me_devname, &fsp); 214 get_fs_usage (me->me_mountdir, me->me_devname, &fsp);
220 /* else if there's a list of paths/devices to select (but 215 /* else if there's a list of paths/devices to select (but
221 * we didn't match above) skip to the next mount entry */ 216 * we didn't match above) skip to the next mount entry */
222 } else if (dev_select_list || path_select_list) { 217 } else if (path_select_list) {
223 continue; 218 continue;
224 /* skip remote filesystems if we're not interested in them */ 219 /* skip remote filesystems if we're not interested in them */
225 } else if (me->me_remote && show_local_fs) { 220 } else if (me->me_remote && show_local_fs) {
@@ -228,12 +223,12 @@ main (int argc, char **argv)
228 } else if (me->me_dummy && !show_all_fs) { 223 } else if (me->me_dummy && !show_all_fs) {
229 continue; 224 continue;
230 /* skip excluded fstypes */ 225 /* skip excluded fstypes */
231 } else if (fs_exclude_list && walk_name_list (fs_exclude_list, me->me_type)) { 226 } else if (fs_exclude_list && np_find_name (fs_exclude_list, me->me_type)) {
232 continue; 227 continue;
233 /* skip excluded fs's */ 228 /* skip excluded fs's */
234 } else if (dp_exclude_list && 229 } else if (dp_exclude_list &&
235 (walk_name_list (dp_exclude_list, me->me_devname) || 230 (np_find_name (dp_exclude_list, me->me_devname) ||
236 walk_name_list (dp_exclude_list, me->me_mountdir))) { 231 np_find_name (dp_exclude_list, me->me_mountdir))) {
237 continue; 232 continue;
238 /* otherwise, get fs usage */ 233 /* otherwise, get fs usage */
239 } else { 234 } else {
@@ -312,11 +307,9 @@ int
312process_arguments (int argc, char **argv) 307process_arguments (int argc, char **argv)
313{ 308{
314 int c; 309 int c;
315 struct name_list *se; 310 struct parameter_list *se;
316 struct name_list **pathtail = &path_select_list; 311 struct parameter_list **pathtail = &path_select_list;
317 struct name_list **fstail = &fs_exclude_list; 312 struct parameter_list *temp_list;
318 struct name_list **dptail = &dp_exclude_list;
319 struct name_list *temp_list;
320 int result = OK; 313 int result = OK;
321 struct stat *stat_buf; 314 struct stat *stat_buf;
322 315
@@ -351,13 +344,7 @@ process_arguments (int argc, char **argv)
351 if (argc < 2) 344 if (argc < 2)
352 return ERROR; 345 return ERROR;
353 346
354 se = (struct name_list *) malloc (sizeof (struct name_list)); 347 np_add_name(&fs_exclude_list, "iso9660");
355 se->name = strdup ("iso9660");
356 se->name_next = NULL;
357 se->found = 0;
358 se->found_len = 0;
359 *fstail = se;
360 fstail = &se->name_next;
361 348
362 for (c = 1; c < argc; c++) 349 for (c = 1; c < argc; c++)
363 if (strcmp ("-to", argv[c]) == 0) 350 if (strcmp ("-to", argv[c]) == 0)
@@ -468,7 +455,7 @@ process_arguments (int argc, char **argv)
468 show_local_fs = 1; 455 show_local_fs = 1;
469 break; 456 break;
470 case 'p': /* select path */ 457 case 'p': /* select path */
471 se = (struct name_list *) malloc (sizeof (struct name_list)); 458 se = (struct parameter_list *) malloc (sizeof (struct parameter_list));
472 se->name = optarg; 459 se->name = optarg;
473 se->name_next = NULL; 460 se->name_next = NULL;
474 se->w_df = w_df; 461 se->w_df = w_df;
@@ -483,43 +470,10 @@ process_arguments (int argc, char **argv)
483 pathtail = &se->name_next; 470 pathtail = &se->name_next;
484 break; 471 break;
485 case 'x': /* exclude path or partition */ 472 case 'x': /* exclude path or partition */
486 se = (struct name_list *) malloc (sizeof (struct name_list)); 473 np_add_name(&dp_exclude_list, optarg);
487 se->name = optarg;
488 se->name_next = NULL;
489
490 /* If you don't clear the w_fd etc values here, they
491 * get processed when you walk the list and assigned
492 * to the global w_df!
493 */
494 se->w_df = 0;
495 se->c_df = 0;
496 se->w_dfp = 0;
497 se->c_dfp = 0;
498 se->w_idfp = 0;
499 se->c_idfp = 0;
500 se->found = 0;
501 se->found_len = 0;
502 *dptail = se;
503 dptail = &se->name_next;
504 break; 474 break;
505 case 'X': /* exclude file system type */ 475 case 'X': /* exclude file system type */
506 se = (struct name_list *) malloc (sizeof (struct name_list)); 476 np_add_name(&fs_exclude_list, optarg);
507 se->name = optarg;
508 se->name_next = NULL;
509 /* If you don't clear the w_fd etc values here, they
510 * get processed when you walk the list and assigned
511 * to the global w_df!
512 */
513 se->w_df = 0;
514 se->c_df = 0;
515 se->w_dfp = 0;
516 se->c_dfp = 0;
517 se->w_idfp = 0;
518 se->c_idfp = 0;
519 se->found = 0;
520 se->found_len = 0;
521 *fstail = se;
522 fstail = &se->name_next;
523 break; 477 break;
524 case 'v': /* verbose */ 478 case 'v': /* verbose */
525 verbose++; 479 verbose++;
@@ -561,7 +515,7 @@ process_arguments (int argc, char **argv)
561 c_dfp = (100.0 - atof (argv[c++])); 515 c_dfp = (100.0 - atof (argv[c++]));
562 516
563 if (argc > c && path == NULL) { 517 if (argc > c && path == NULL) {
564 se = (struct name_list *) malloc (sizeof (struct name_list)); 518 se = (struct parameter_list *) malloc (sizeof (struct parameter_list));
565 se->name = strdup (argv[c++]); 519 se->name = strdup (argv[c++]);
566 se->name_next = NULL; 520 se->name_next = NULL;
567 se->w_df = w_df; 521 se->w_df = w_df;
@@ -683,7 +637,7 @@ check_disk (double usp, uintmax_t free_disk, double uisp)
683 637
684 638
685int 639int
686walk_name_list (struct name_list *list, const char *name) 640walk_parameter_list (struct parameter_list *list, const char *name)
687{ 641{
688 int name_len; 642 int name_len;
689 name_len = strlen(name); 643 name_len = strlen(name);
@@ -695,7 +649,7 @@ walk_name_list (struct name_list *list, const char *name)
695 ! strncmp(list->name, name, name_len)) { 649 ! strncmp(list->name, name, name_len)) {
696 list->found = 1; 650 list->found = 1;
697 list->found_len = name_len; 651 list->found_len = name_len;
698 /* if required for name_lists that have not saved w_df, etc (eg exclude lists) */ 652 /* if required for parameter_lists that have not saved w_df, etc (eg exclude lists) */
699 if (list->w_df) w_df = list->w_df; 653 if (list->w_df) w_df = list->w_df;
700 if (list->c_df) c_df = list->c_df; 654 if (list->c_df) c_df = list->c_df;
701 if (list->w_dfp>=0.0) w_dfp = list->w_dfp; 655 if (list->w_dfp>=0.0) w_dfp = list->w_dfp;
diff --git a/plugins/tests/Makefile.am b/plugins/tests/Makefile.am
index 8ed3fc1..741499d 100644
--- a/plugins/tests/Makefile.am
+++ b/plugins/tests/Makefile.am
@@ -7,9 +7,9 @@ check_PROGRAMS = @EXTRA_TEST@
7 7
8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl 8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl
9 9
10EXTRA_PROGRAMS = test_utils 10EXTRA_PROGRAMS = test_utils test_disk
11 11
12EXTRA_DIST = test_utils.t 12EXTRA_DIST = test_utils.t test_disk.t
13 13
14LIBS = @LIBINTL@ 14LIBS = @LIBINTL@
15 15
@@ -18,6 +18,11 @@ test_utils_CFLAGS = -g -I..
18test_utils_LDFLAGS = -L/usr/local/lib -ltap 18test_utils_LDFLAGS = -L/usr/local/lib -ltap
19test_utils_LDADD = ../utils.o 19test_utils_LDADD = ../utils.o
20 20
21test_disk_SOURCES = test_disk.c
22test_disk_CFLAGS = -g -I..
23test_disk_LDFLAGS = -L/usr/local/lib -ltap
24test_disk_LDADD = ../utils_disk.o
25
21test: ${noinst_PROGRAMS} 26test: ${noinst_PROGRAMS}
22 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) 27 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
23 28
diff --git a/plugins/tests/test_disk.c b/plugins/tests/test_disk.c
new file mode 100644
index 0000000..19cc3ac
--- /dev/null
+++ b/plugins/tests/test_disk.c
@@ -0,0 +1,85 @@
1/******************************************************************************
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17 $Id$
18
19******************************************************************************/
20
21#include "common.h"
22#include "utils_disk.h"
23#include "tap.h"
24
25int
26main (int argc, char **argv)
27{
28 struct name_list *exclude_filesystem=NULL;
29 struct name_list *exclude_fstype=NULL;
30
31 plan_tests(8);
32
33 ok( np_find_name(exclude_filesystem, "/var") == FALSE, "/var not in list");
34 np_add_name(&exclude_filesystem, "/var");
35 ok( np_find_name(exclude_filesystem, "/var") == TRUE, "is in list now");
36 ok( np_find_name(exclude_filesystem, "/home") == FALSE, "/home not in list");
37 np_add_name(&exclude_filesystem, "/home");
38 ok( np_find_name(exclude_filesystem, "/home") == TRUE, "is in list now");
39 ok( np_find_name(exclude_filesystem, "/var") == TRUE, "/var still in list");
40
41 ok( np_find_name(exclude_fstype, "iso9660") == FALSE, "iso9660 not in list");
42 np_add_name(&exclude_fstype, "iso9660");
43 ok( np_find_name(exclude_fstype, "iso9660") == TRUE, "is in list now");
44
45 ok( np_find_name(exclude_filesystem, "iso9660") == FALSE, "Make sure no clashing in variables");
46
47
48
49
50 /*
51 range = parse_range_string("6");
52 ok( range != NULL, "'6' is valid range");
53 ok( range->start == 0, "Start correct");
54 ok( range->start_infinity == FALSE, "Not using negative infinity");
55 ok( range->end == 6, "End correct");
56 ok( range->end_infinity == FALSE, "Not using infinity");
57 free(range);
58
59 range = parse_range_string("-7:23");
60 ok( range != NULL, "'-7:23' is valid range");
61 ok( range->start == -7, "Start correct");
62 ok( range->start_infinity == FALSE, "Not using negative infinity");
63 ok( range->end == 23, "End correct");
64 ok( range->end_infinity == FALSE, "Not using infinity");
65 free(range);
66
67 range = parse_range_string(":5.75");
68 ok( range != NULL, "':5.75' is valid range");
69 ok( range->start == 0, "Start correct");
70 ok( range->start_infinity == FALSE, "Not using negative infinity");
71 ok( range->end == 5.75, "End correct");
72 ok( range->end_infinity == FALSE, "Not using infinity");
73 free(range);
74
75 range = parse_range_string("~:-95.99");
76 ok( range != NULL, "~:-95.99' is valid range");
77 ok( range->start_infinity == TRUE, "Using negative infinity");
78 ok( range->end == -95.99, "End correct (with rounding errors)");
79 ok( range->end_infinity == FALSE, "Not using infinity");
80 free(range);
81 */
82
83 return exit_status();
84}
85
diff --git a/plugins/tests/test_disk.t b/plugins/tests/test_disk.t
new file mode 100755
index 0000000..d32567a
--- /dev/null
+++ b/plugins/tests/test_disk.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_disk") {
4 plan skip_all => "./test_disk not compiled - please install tap library to test";
5}
6exec "./test_disk";
diff --git a/plugins/utils_disk.c b/plugins/utils_disk.c
new file mode 100644
index 0000000..6380df3
--- /dev/null
+++ b/plugins/utils_disk.c
@@ -0,0 +1,62 @@
1/****************************************************************************
2* Utils for check_disk
3*
4* License: GPL
5* Copyright (c) 1999-2006 nagios-plugins team
6*
7* Last Modified: $Date$
8*
9* Description:
10*
11* This file contains utilities for check_disk. These are tested by libtap
12*
13* License Information:
14*
15* This program is free software; you can redistribute it and/or modify
16* it under the terms of the GNU General Public License as published by
17* the Free Software Foundation; either version 2 of the License, or
18* (at your option) any later version.
19*
20* This program is distributed in the hope that it will be useful,
21* but WITHOUT ANY WARRANTY; without even the implied warranty of
22* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23* GNU General Public License for more details.
24*
25* You should have received a copy of the GNU General Public License
26* along with this program; if not, write to the Free Software
27* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28*
29* $Id$
30*
31*****************************************************************************/
32
33#include "common.h"
34#include "utils_disk.h"
35
36void
37np_add_name (struct name_list **list, const char *name)
38{
39 struct name_list *new_entry;
40 new_entry = (struct name_list *) malloc (sizeof *new_entry);
41 new_entry->name = (char *) name;
42 new_entry->next = *list;
43 *list = new_entry;
44}
45
46/* Returns TRUE if name is in list */
47int
48np_find_name (struct name_list *list, const char *name)
49{
50 const struct name_list *n;
51
52 if (list == NULL || name == NULL) {
53 return FALSE;
54 }
55 for (n = list; n; n = n->next) {
56 if (!strcmp(name, n->name)) {
57 return TRUE;
58 }
59 }
60 return FALSE;
61}
62
diff --git a/plugins/utils_disk.h b/plugins/utils_disk.h
new file mode 100644
index 0000000..f173c91
--- /dev/null
+++ b/plugins/utils_disk.h
@@ -0,0 +1,12 @@
1/* Header file for utils_disk */
2
3
4struct name_list
5{
6 char *name;
7 struct name_list *next;
8};
9
10void np_add_name (struct name_list **list, const char *name);
11int np_find_name (struct name_list *list, const char *name);
12