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.c43
1 files changed, 16 insertions, 27 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 5e95aef..483be06 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -170,9 +170,7 @@ np_find_parameter(struct parameter_list *list, const char *name)
170 return NULL; 170 return NULL;
171} 171}
172 172
173void 173void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, bool exact) {
174np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact)
175{
176 struct parameter_list *d; 174 struct parameter_list *d;
177 for (d = desired; d; d= d->name_next) { 175 for (d = desired; d; d= d->name_next) {
178 if (! d->best_match) { 176 if (! d->best_match) {
@@ -195,9 +193,9 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
195 if (! best_match) { 193 if (! best_match) {
196 for (me = mount_list; me; me = me->me_next) { 194 for (me = mount_list; me; me = me->me_next) {
197 size_t len = strlen (me->me_mountdir); 195 size_t len = strlen (me->me_mountdir);
198 if ((exact == FALSE && (best_match_len <= len && len <= name_len && 196 if ((!exact && (best_match_len <= len && len <= name_len &&
199 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) 197 (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0)))
200 || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) 198 || (exact && strcmp(me->me_mountdir, d->name)==0))
201 { 199 {
202 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) { 200 if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) {
203 best_match = me; 201 best_match = me;
@@ -216,27 +214,23 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list
216 } 214 }
217} 215}
218 216
219/* Returns TRUE if name is in list */ 217/* Returns true if name is in list */
220int 218bool np_find_name (struct name_list *list, const char *name) {
221np_find_name (struct name_list *list, const char *name)
222{
223 const struct name_list *n; 219 const struct name_list *n;
224 220
225 if (list == NULL || name == NULL) { 221 if (list == NULL || name == NULL) {
226 return FALSE; 222 return false;
227 } 223 }
228 for (n = list; n; n = n->next) { 224 for (n = list; n; n = n->next) {
229 if (!strcmp(name, n->name)) { 225 if (!strcmp(name, n->name)) {
230 return TRUE; 226 return true;
231 } 227 }
232 } 228 }
233 return FALSE; 229 return false;
234} 230}
235 231
236/* Returns TRUE if name is in list */ 232/* Returns true if name is in list */
237bool 233bool np_find_regmatch (struct regex_list *list, const char *name) {
238np_find_regmatch (struct regex_list *list, const char *name)
239{
240 int len; 234 int len;
241 regmatch_t m; 235 regmatch_t m;
242 236
@@ -257,25 +251,20 @@ np_find_regmatch (struct regex_list *list, const char *name)
257 return false; 251 return false;
258} 252}
259 253
260int 254bool np_seen_name(struct name_list *list, const char *name) {
261np_seen_name(struct name_list *list, const char *name)
262{
263 const struct name_list *s; 255 const struct name_list *s;
264 for (s = list; s; s=s->next) { 256 for (s = list; s; s=s->next) {
265 if (!strcmp(s->name, name)) { 257 if (!strcmp(s->name, name)) {
266 return TRUE; 258 return true;
267 } 259 }
268 } 260 }
269 return FALSE; 261 return false;
270} 262}
271 263
272int 264bool np_regex_match_mount_entry (struct mount_entry* me, regex_t* re) {
273np_regex_match_mount_entry (struct mount_entry* me, regex_t* re)
274{
275 if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 || 265 if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 ||
276 regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) { 266 regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) {
277 return TRUE; 267 return true;
278 } else {
279 return FALSE;
280 } 268 }
269 return false;
281} 270}