[Nagiosplug-checkins] nagiosplug/lib utils_disk.c,1.5,1.6

Matthias Eble psychotrahe at users.sourceforge.net
Sun Apr 1 13:17:18 CEST 2007


Update of /cvsroot/nagiosplug/nagiosplug/lib
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv17029/lib

Modified Files:
	utils_disk.c 
Log Message:
utils_disk: fixed handling if check_disk -p is a device (np_set_best_match())


Index: utils_disk.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/lib/utils_disk.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- utils_disk.c	30 Mar 2007 08:53:58 -0000	1.5
+++ utils_disk.c	1 Apr 2007 11:17:16 -0000	1.6
@@ -98,25 +98,26 @@
       size_t best_match_len = 0;
       struct mount_entry *best_match = NULL;
 
+      /* set best match if path name exactly matches a mounted device name */
       for (me = mount_list; me; me = me->me_next) {
-        size_t len = strlen (me->me_mountdir);
-        if ((exact == FALSE && (best_match_len <= len && len <= name_len && 
-          (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
-      || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
-        {
+        if (strcmp(me->me_devname, d->name)==0)
           best_match = me;
-          best_match_len = len;
-        } else {
-          len = strlen (me->me_devname);
-          if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
-            (len == 1 || strncmp (me->me_devname, d->name, len) == 0)))
-            || (exact == TRUE && strcmp(me->me_devname, d->name)==0))
+      }
+
+      /* set best match by directory name if no match was found by devname */
+      if (! best_match) {
+        for (me = mount_list; me; me = me->me_next) {
+          size_t len = strlen (me->me_mountdir);
+          if ((exact == FALSE && (best_match_len <= len && len <= name_len && 
+             (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
+             || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0))
           {
             best_match = me;
             best_match_len = len;
           }
         }
       }
+
       if (best_match) {
         d->best_match = best_match;
       } else {





More information about the Commits mailing list