diff options
Diffstat (limited to 'plugins/utils_disk.c')
-rw-r--r-- | plugins/utils_disk.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/plugins/utils_disk.c b/plugins/utils_disk.c index 6380df35..0a71d792 100644 --- a/plugins/utils_disk.c +++ b/plugins/utils_disk.c | |||
@@ -43,6 +43,60 @@ np_add_name (struct name_list **list, const char *name) | |||
43 | *list = new_entry; | 43 | *list = new_entry; |
44 | } | 44 | } |
45 | 45 | ||
46 | void | ||
47 | np_add_parameter(struct parameter_list **list, const char *name) | ||
48 | { | ||
49 | struct parameter_list *new_path; | ||
50 | new_path = (struct parameter_list *) malloc (sizeof *new_path); | ||
51 | new_path->name = (char *) name; | ||
52 | new_path->found = 0; | ||
53 | new_path->found_len = 0; | ||
54 | new_path->w_df = 0; | ||
55 | new_path->c_df = 0; | ||
56 | new_path->w_dfp = -1.0; | ||
57 | new_path->c_dfp = -1.0; | ||
58 | new_path->w_idfp = -1.0; | ||
59 | new_path->c_idfp = -1.0; | ||
60 | new_path->name_next = *list; | ||
61 | *list = new_path; | ||
62 | } | ||
63 | |||
64 | void | ||
65 | np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact) | ||
66 | { | ||
67 | struct parameter_list *d; | ||
68 | for (d = desired; d; d= d->name_next) { | ||
69 | struct mount_entry *me; | ||
70 | size_t name_len = strlen(d->name); | ||
71 | size_t best_match_len = 0; | ||
72 | struct mount_entry *best_match = NULL; | ||
73 | |||
74 | for (me = mount_list; me; me = me->me_next) { | ||
75 | size_t len = strlen (me->me_mountdir); | ||
76 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
77 | (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) | ||
78 | || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) | ||
79 | { | ||
80 | best_match = me; | ||
81 | best_match_len = len; | ||
82 | } else { | ||
83 | len = strlen (me->me_devname); | ||
84 | if ((exact == FALSE && (best_match_len <= len && len <= name_len && | ||
85 | (len == 1 || strncmp (me->me_devname, d->name, len) == 0))) | ||
86 | || (exact == TRUE && strcmp(me->me_devname, d->name)==0)) | ||
87 | { | ||
88 | best_match = me; | ||
89 | best_match_len = len; | ||
90 | } | ||
91 | } | ||
92 | } | ||
93 | if (best_match) { | ||
94 | d->best_match = best_match; | ||
95 | d->found = TRUE; | ||
96 | } | ||
97 | } | ||
98 | } | ||
99 | |||
46 | /* Returns TRUE if name is in list */ | 100 | /* Returns TRUE if name is in list */ |
47 | int | 101 | int |
48 | np_find_name (struct name_list *list, const char *name) | 102 | np_find_name (struct name_list *list, const char *name) |