diff options
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 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 | ||
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))) |