* 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. */
| 182 | * something other than ZPROP_CONT. |
| 183 | */ |
| 184 | int |
| 185 | zprop_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 | |
| 229 | static boolean_t |
| 230 | propname_match(const char *p, size_t len, zprop_desc_t *prop_entry) |
no test coverage detected