Lines Matching full:vec
162 * @vec: vector of profiles to compare (NOT NULL)
163 * @n: length of @vec
165 * Returns: <0 if a < vec
166 * ==0 if a == vec
167 * >0 if a > vec
190 static bool vec_is_stale(struct aa_profile **vec, int n) in vec_is_stale() argument
194 AA_BUG(!vec); in vec_is_stale()
197 if (profile_is_stale(vec[i])) in vec_is_stale()
204 static bool vec_unconfined(struct aa_profile **vec, int n) in vec_unconfined() argument
208 AA_BUG(!vec); in vec_unconfined()
211 if (!profile_unconfined(vec[i])) in vec_unconfined()
224 * assumes vec is sorted
225 * Assumes @vec has null terminator at vec[n], and will null terminate
226 * vec[n - dups]
228 static inline int unique(struct aa_profile **vec, int n) in unique() argument
233 AA_BUG(!vec); in unique()
237 int res = profile_cmp(vec[pos], vec[i]); in unique()
239 AA_BUG(res > 0, "vec not sorted"); in unique()
242 aa_put_profile(vec[i]); in unique()
248 vec[pos] = vec[i]; in unique()
259 * @vec: list of profiles to sort and merge
263 * If @flags & VEC_FLAG_TERMINATE @vec has null terminator at vec[n], and will
264 * null terminate vec[n - dups]
266 int aa_vec_unique(struct aa_profile **vec, int n, int flags) in aa_vec_unique() argument
271 AA_BUG(!vec); in aa_vec_unique()
275 sort(vec, n, sizeof(struct aa_profile *), sort_cmp, NULL); in aa_vec_unique()
276 dups = unique(vec, n); in aa_vec_unique()
282 struct aa_profile *tmp = vec[i]; in aa_vec_unique()
286 int res = profile_cmp(vec[pos], tmp); in aa_vec_unique()
300 vec[j] = vec[j - 1]; in aa_vec_unique()
301 vec[pos] = tmp; in aa_vec_unique()
310 vec[n - dups] = NULL; in aa_vec_unique()
330 label->vec[i.i] = (struct aa_profile *) in label_destroy()
388 on_list_rcu(&label->vec[0]->base.profiles)); in aa_label_kref()
390 on_list_rcu(&label->vec[0]->base.list)); in aa_label_kref()
414 label->vec[size] = NULL; /* null terminate */ in aa_label_init()
436 /* + 1 for null terminator entry on vec */ in aa_label_alloc()
480 return vec_cmp(a->vec, a->size, b->vec, b->size); in label_cmp()
490 if (!profile_unconfined(label->vec[i])) in aa_label_next_confined()
519 int res = profile_cmp(sub->vec[I->j], set->vec[I->i]); in __aa_label_next_not_in_set()
527 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
531 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
718 * __vec_find - find label that matches @vec in label set
719 * @vec: vec of profiles to find matching label for (NOT NULL)
720 * @n: length of @vec
722 * Requires: @vec_labelset(vec) lock held
727 * else NULL if @vec equiv is not in tree
729 static struct aa_label *__vec_find(struct aa_profile **vec, int n) in __vec_find() argument
733 AA_BUG(!vec); in __vec_find()
734 AA_BUG(!*vec); in __vec_find()
737 node = vec_labelset(vec, n)->root.rb_node; in __vec_find()
740 int result = vec_cmp(this->vec, this->size, vec, n); in __vec_find()
768 return __vec_find(label->vec, label->size); in __label_find()
837 * @vec: array of profiles to find equiv label for (NOT NULL)
838 * @n: length of @vec
840 * Returns: refcounted label if @vec equiv is in tree
841 * else NULL if @vec equiv is not in tree
843 static struct aa_label *vec_find(struct aa_profile **vec, int n) in vec_find() argument
849 AA_BUG(!vec); in vec_find()
850 AA_BUG(!*vec); in vec_find()
853 ls = vec_labelset(vec, n); in vec_find()
855 label = __vec_find(vec, n); in vec_find()
862 static struct aa_label *vec_create_and_insert_label(struct aa_profile **vec, in vec_create_and_insert_label() argument
871 AA_BUG(!vec); in vec_create_and_insert_label()
874 return aa_get_label(&vec[0]->label); in vec_create_and_insert_label()
876 ls = labels_set(&vec[len - 1]->label); in vec_create_and_insert_label()
886 new->vec[i] = aa_get_profile(vec[i]); in vec_create_and_insert_label()
896 struct aa_label *aa_vec_find_or_create_label(struct aa_profile **vec, int len, in aa_vec_find_or_create_label() argument
899 struct aa_label *label = vec_find(vec, len); in aa_vec_find_or_create_label()
904 return vec_create_and_insert_label(vec, len, gfp); in aa_vec_find_or_create_label()
921 return vec_find(label->vec, label->size); in aa_label_find()
983 int res = profile_cmp(a->vec[I->i], b->vec[I->j]); in aa_label_next_in_merge()
986 return b->vec[(I->j)++]; in aa_label_next_in_merge()
991 return a->vec[(I->i)++]; in aa_label_next_in_merge()
995 return b->vec[(I->j)++]; in aa_label_next_in_merge()
1026 int res = profile_cmp(p, z->vec[k]); in label_merge_cmp()
1078 new->vec[k] = aa_get_newest_profile(next); in label_merge_insert()
1079 AA_BUG(!new->vec[k]->label.proxy); in label_merge_insert()
1080 AA_BUG(!new->vec[k]->label.proxy->label); in label_merge_insert()
1081 if (next->label.proxy != new->vec[k]->label.proxy) in label_merge_insert()
1086 new->vec[k++] = aa_get_profile(next); in label_merge_insert()
1090 new->vec[k] = NULL; in label_merge_insert()
1093 new->size -= aa_vec_unique(&new->vec[0], new->size, in label_merge_insert()
1097 label = aa_get_label(&new->vec[0]->label); in label_merge_insert()
1110 if (vec_unconfined(new->vec, new->size)) in label_merge_insert()
1898 DEFINE_VEC(profile, vec); in aa_label_strn_parse()
1920 error = vec_setup(profile, vec, len, gfp); in aa_label_strn_parse()
1925 vec[i] = aa_get_profile(base->vec[i]); in aa_label_strn_parse()
1929 vec[i] = fqlookupn_profile(base, currbase, str, split - str); in aa_label_strn_parse()
1930 if (!vec[i]) in aa_label_strn_parse()
1936 if (vec[i]->ns != labels_ns(currbase)) in aa_label_strn_parse()
1937 currbase = &vec[i]->label; in aa_label_strn_parse()
1943 vec[i] = fqlookupn_profile(base, currbase, str, end - str); in aa_label_strn_parse()
1944 if (!vec[i]) in aa_label_strn_parse()
1948 /* no need to free vec as len < LOCAL_VEC_ENTRIES */ in aa_label_strn_parse()
1949 return &vec[0]->label; in aa_label_strn_parse()
1951 len -= aa_vec_unique(vec, len, VEC_FLAG_TERMINATE); in aa_label_strn_parse()
1954 label = aa_get_label(&vec[0]->label); in aa_label_strn_parse()
1959 label = aa_vec_find_or_create_label(vec, len, gfp); in aa_label_strn_parse()
1961 label = vec_find(vec, len); in aa_label_strn_parse()
1967 vec_cleanup(profile, vec, len); in aa_label_strn_parse()
2033 vec_is_stale(label->vec, label->size)) && in labelset_next_stale()
2079 AA_BUG(!label->vec[i]); in __label_update()
2080 new->vec[i] = aa_get_newest_profile(label->vec[i]); in __label_update()
2081 AA_BUG(!new->vec[i]); in __label_update()
2082 AA_BUG(!new->vec[i]->label.proxy); in __label_update()
2083 AA_BUG(!new->vec[i]->label.proxy->label); in __label_update()
2084 if (new->vec[i]->label.proxy != label->vec[i]->label.proxy) in __label_update()
2090 new->size -= aa_vec_unique(&new->vec[0], new->size, in __label_update()
2094 tmp = aa_get_label(&new->vec[0]->label); in __label_update()