diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-04-01 11:17:16 +0000 |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-04-01 11:17:16 +0000 |
commit | 5e7c9821be3aac6a76e701d78be6c578c80870ab (patch) | |
tree | 316f083b3ee92b89be9936ca7e4b562d901e128d /lib | |
parent | 7cf9e06bfcb41d5c0658fa705ef5c2b946b80f55 (diff) | |
download | monitoring-plugins-5e7c9821be3aac6a76e701d78be6c578c80870ab.tar.gz |
utils_disk: fixed handling if check_disk -p is a device (np_set_best_match())
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1668 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils_disk.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c index cfd6a979..96f5a306 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c | |||
@@ -98,25 +98,26 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list | |||
98 | size_t best_match_len = 0; | 98 | size_t best_match_len = 0; |
99 | struct mount_entry *best_match = NULL; | 99 | struct mount_entry *best_match = NULL; |
100 | 100 | ||
101 | /* set best match if path name exactly matches a mounted device name */ | ||
101 | for (me = mount_list; me; me = me->me_next) { | 102 | for (me = mount_list; me; me = me->me_next) { |
102 | size_t len = strlen (me->me_mountdir); | 103 | if (strcmp(me->me_devname, d->name)==0) |
103 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
104 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | ||
105 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) | ||
106 | { | ||
107 | best_match = me; | 104 | best_match = me; |
108 | best_match_len = len; | 105 | } |
109 | } else { | 106 | |
110 | len = strlen (me->me_devname); | 107 | /* set best match by directory name if no match was found by devname */ |
111 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | 108 | if (! best_match) { |
112 | (len == 1 || strncmp (me->me_devname, d->name, len) == 0))) | 109 | for (me = mount_list; me; me = me->me_next) { |
113 | || (exact == TRUE && strcmp(me->me_devname, d->name)==0)) | 110 | size_t len = strlen (me->me_mountdir); |
111 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
112 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | ||
113 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) | ||
114 | { | 114 | { |
115 | best_match = me; | 115 | best_match = me; |
116 | best_match_len = len; | 116 | best_match_len = len; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | |||
120 | if (best_match) { | 121 | if (best_match) { |
121 | d->best_match = best_match; | 122 | d->best_match = best_match; |
122 | } else { | 123 | } else { |