diff options
author | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
---|---|---|
committer | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 23:49:18 +0100 |
commit | a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch) | |
tree | 8effe94c57b2f9796ba36090b07551baa8f1e1cb /lib/utils_disk.c | |
parent | ca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-a0d4277.tar.gz |
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
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 a1181d37..468769b1 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) |
@@ -142,9 +143,12 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list | |||
142 | size_t name_len = strlen(d->name); | 143 | size_t name_len = strlen(d->name); |
143 | size_t best_match_len = 0; | 144 | size_t best_match_len = 0; |
144 | struct mount_entry *best_match = NULL; | 145 | struct mount_entry *best_match = NULL; |
146 | struct fs_usage fsp; | ||
145 | 147 | ||
146 | /* set best match if path name exactly matches a mounted device name */ | 148 | /* set best match if path name exactly matches a mounted device name */ |
147 | for (me = mount_list; me; me = me->me_next) { | 149 | for (me = mount_list; me; me = me->me_next) { |
150 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0) | ||
151 | continue; /* skip if permissions do not suffice for accessing device */ | ||
148 | if (strcmp(me->me_devname, d->name)==0) | 152 | if (strcmp(me->me_devname, d->name)==0) |
149 | best_match = me; | 153 | best_match = me; |
150 | } | 154 | } |
@@ -152,6 +156,8 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list | |||
152 | /* set best match by directory name if no match was found by devname */ | 156 | /* set best match by directory name if no match was found by devname */ |
153 | if (! best_match) { | 157 | if (! best_match) { |
154 | for (me = mount_list; me; me = me->me_next) { | 158 | for (me = mount_list; me; me = me->me_next) { |
159 | if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) < 0) | ||
160 | continue; /* skip if permissions do not suffice for accessing device */ | ||
155 | size_t len = strlen (me->me_mountdir); | 161 | size_t len = strlen (me->me_mountdir); |
156 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | 162 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && |
157 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | 163 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) |