| 334 | } |
| 335 | |
| 336 | static boolean_t |
| 337 | zap_leaf_array_match(zap_leaf_t *l, zap_name_t *zn, |
| 338 | int chunk, int array_numints) |
| 339 | { |
| 340 | int bseen = 0; |
| 341 | |
| 342 | if (zap_getflags(zn->zn_zap) & ZAP_FLAG_UINT64_KEY) { |
| 343 | uint64_t *thiskey = |
| 344 | kmem_alloc(array_numints * sizeof (*thiskey), KM_SLEEP); |
| 345 | ASSERT(zn->zn_key_intlen == sizeof (*thiskey)); |
| 346 | |
| 347 | zap_leaf_array_read(l, chunk, sizeof (*thiskey), array_numints, |
| 348 | sizeof (*thiskey), array_numints, thiskey); |
| 349 | boolean_t match = bcmp(thiskey, zn->zn_key_orig, |
| 350 | array_numints * sizeof (*thiskey)) == 0; |
| 351 | kmem_free(thiskey, array_numints * sizeof (*thiskey)); |
| 352 | return (match); |
| 353 | } |
| 354 | |
| 355 | ASSERT(zn->zn_key_intlen == 1); |
| 356 | if (zn->zn_matchtype & MT_NORMALIZE) { |
| 357 | char *thisname = kmem_alloc(array_numints, KM_SLEEP); |
| 358 | |
| 359 | zap_leaf_array_read(l, chunk, sizeof (char), array_numints, |
| 360 | sizeof (char), array_numints, thisname); |
| 361 | boolean_t match = zap_match(zn, thisname); |
| 362 | kmem_free(thisname, array_numints); |
| 363 | return (match); |
| 364 | } |
| 365 | |
| 366 | /* |
| 367 | * Fast path for exact matching. |
| 368 | * First check that the lengths match, so that we don't read |
| 369 | * past the end of the zn_key_orig array. |
| 370 | */ |
| 371 | if (array_numints != zn->zn_key_orig_numints) |
| 372 | return (B_FALSE); |
| 373 | while (bseen < array_numints) { |
| 374 | struct zap_leaf_array *la = &ZAP_LEAF_CHUNK(l, chunk).l_array; |
| 375 | int toread = MIN(array_numints - bseen, ZAP_LEAF_ARRAY_BYTES); |
| 376 | ASSERT3U(chunk, <, ZAP_LEAF_NUMCHUNKS(l)); |
| 377 | if (bcmp(la->la_array, (char *)zn->zn_key_orig + bseen, toread)) |
| 378 | break; |
| 379 | chunk = la->la_next; |
| 380 | bseen += toread; |
| 381 | } |
| 382 | return (bseen == array_numints); |
| 383 | } |
| 384 | |
| 385 | /* |
| 386 | * Routines which manipulate leaf entries. |
no test coverage detected