summaryrefslogtreecommitdiffstats
path: root/lib/utils_disk.c
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-02-19 13:39:08 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-02-19 13:39:08 (GMT)
commit74b6984047d330a3cc7cb7f63645849fe7676c63 (patch)
tree65a26800103d8d66f7e6cb4acfbfc9f315ec750b /lib/utils_disk.c
parent423284edfa980fc3fdb51ab20af96685a988ba97 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-74b6984047d330a3cc7cb7f63645849fe7676c63.tar.gz
Merge branch 'master' into check_icmp_cleanuprefs/pull/1807/head
Diffstat (limited to 'lib/utils_disk.c')
-rw-r--r--lib/utils_disk.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index c7c9126..4f16068 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -28,6 +28,7 @@
28 28
29#include "common.h" 29#include "common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h"
31 32
32void 33void
33np_add_name (struct name_list **list, const char *name) 34np_add_name (struct name_list **list, const char *name)
@@ -127,9 +128,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
127 size_t name_len = strlen(d->name); 128 size_t name_len = strlen(d->name);
128 size_t best_match_len = 0; 129 size_t best_match_len = 0;
129 struct mount_entry *best_match = NULL; 130 struct mount_entry *best_match = NULL;
131 struct fs_usage fsp;
130 132
131 /* set best match if path name exactly matches a mounted device name */ 133 /* set best match if path name exactly matches a mounted device name */
132 for (me = mount_list; me; me = me->me_next) { 134 for (me = mount_list; me; me = me->me_next) {
135 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
136 continue; /* skip if permissions do not suffice for accessing device */
133 if (strcmp(me->me_devname, d->name)==0) 137 if (strcmp(me->me_devname, d->name)==0)
134 best_match = me; 138 best_match = me;
135 } 139 }
@@ -137,6 +141,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
137 /* set best match by directory name if no match was found by devname */ 141 /* set best match by directory name if no match was found by devname */
138 if (! best_match) { 142 if (! best_match) {
139 for (me = mount_list; me; me = me->me_next) { 143 for (me = mount_list; me; me = me->me_next) {
144 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0)
145 continue; /* skip if permissions do not suffice for accessing device */
140 size_t len = strlen (me->me_mountdir); 146 size_t len = strlen (me->me_mountdir);
141 if ((exact == FALSE && (best_match_len <= len && len <= name_len && 147 if ((exact == FALSE && (best_match_len <= len && len <= name_len &&
142 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) 148 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))