summaryrefslogtreecommitdiffstats
path: root/lib/utils_disk.c
diff options
context:
space:
mode:
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 a1181d3..468769b 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)
@@ -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)))