diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-09 16:55:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 16:55:10 +0100 |
commit | e0ada6f11a82ed6119836482b84c8ba5df491d8f (patch) | |
tree | 6ddcd5f7850169d82d88dca56a2e5c0dbda08b4e /lib/utils_disk.c | |
parent | c389aa4f918aab5cf181aa2cb9dec68b3bf34d4f (diff) | |
parent | 0899e41f5075d661153eb2c77ace1734a8f66bfa (diff) | |
download | monitoring-plugins-e0ada6f11a82ed6119836482b84c8ba5df491d8f.tar.gz |
Merge branch 'master' into rename_output_to_cmd_output
Diffstat (limited to 'lib/utils_disk.c')
-rw-r--r-- | lib/utils_disk.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c index c7c9126e..4f16068a 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 | ||
32 | void | 33 | void |
33 | np_add_name (struct name_list **list, const char *name) | 34 | np_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))) |