MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zprop_iter_common

Function zprop_iter_common

freebsd/contrib/openzfs/module/zcommon/zprop_common.c:184–227  ·  view source on GitHub ↗

* Iterate over all properties in the given property table, calling back * into the specified function for each property. We will continue to * iterate until we either reach the end or the callback function returns * something other than ZPROP_CONT. */

Source from the content-addressed store, hash-verified

182 * something other than ZPROP_CONT.
183 */
184int
185zprop_iter_common(zprop_func func, void *cb, boolean_t show_all,
186 boolean_t ordered, zfs_type_t type)
187{
188 int i, num_props, size, prop;
189 zprop_desc_t *prop_tbl;
190 zprop_desc_t **order;
191
192 prop_tbl = zprop_get_proptable(type);
193 num_props = zprop_get_numprops(type);
194 size = num_props * sizeof (zprop_desc_t *);
195
196#if defined(_KERNEL)
197 order = kmem_alloc(size, KM_SLEEP);
198#else
199 if ((order = malloc(size)) == NULL)
200 return (ZPROP_CONT);
201#endif
202
203 for (int j = 0; j < num_props; j++)
204 order[j] = &prop_tbl[j];
205
206 if (ordered) {
207 qsort((void *)order, num_props, sizeof (zprop_desc_t *),
208 zprop_compare);
209 }
210
211 prop = ZPROP_CONT;
212 for (i = 0; i < num_props; i++) {
213 if ((order[i]->pd_visible || show_all) &&
214 order[i]->pd_zfs_mod_supported &&
215 (func(order[i]->pd_propnum, cb) != ZPROP_CONT)) {
216 prop = order[i]->pd_propnum;
217 break;
218 }
219 }
220
221#if defined(_KERNEL)
222 kmem_free(order, size);
223#else
224 free(order);
225#endif
226 return (prop);
227}
228
229static boolean_t
230propname_match(const char *p, size_t len, zprop_desc_t *prop_entry)

Callers 4

zprop_name_to_propFunction · 0.85
zprop_expand_listFunction · 0.85
zprop_iterFunction · 0.85

Calls 6

zprop_get_proptableFunction · 0.85
zprop_get_numpropsFunction · 0.85
mallocFunction · 0.85
qsortFunction · 0.85
kmem_freeFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected