Lines Matching refs:ch

41 	struct cachekey_header	*ch;  member
106 static struct cachekey_header *remap_cache_file_ch(struct cachekey_header *ch,
109 static struct cachekey_header *cache_insert_ch(struct cachekey_header *ch,
115 static struct cachekey3_list *cache_retrieve_ch(struct cachekey_header *ch,
120 static int cache_remove_ch(struct cachekey_header *ch,
159 static struct cachekey3_list * copy_cl_item(struct cachekey_header *ch,
202 struct cachekey_header *ch; in create_cache_file_ch() local
281 if ((ch = (void *)mmap(0, sizeof (struct cachekey_header), in create_cache_file_ch()
290 if (ch->version != CACHEKEY_HEADER_VERSION || in create_cache_file_ch()
291 ch->headerlength != sizeof (struct cachekey_header) || in create_cache_file_ch()
292 ch->keylen != keylen || in create_cache_file_ch()
293 ch->algtype != algtype || in create_cache_file_ch()
294 ch->reclength != reclength || in create_cache_file_ch()
295 ch->length < sizeof (struct cachekey_header) || in create_cache_file_ch()
296 ch->maxsize < ch->length || in create_cache_file_ch()
297 INVALID_ADDRESS(ch->inuse, ch) || in create_cache_file_ch()
298 INVALID_ADDRESS(ch->free, ch)) { in create_cache_file_ch()
302 munmap((caddr_t)ch, sizeof (struct cachekey_header)); in create_cache_file_ch()
306 oldbase = (void *)ch->address; in create_cache_file_ch()
307 length = ch->length; in create_cache_file_ch()
308 if (munmap((caddr_t)ch, sizeof (struct cachekey_header)) < 0) { in create_cache_file_ch()
318 if ((ch = (void *)mmap((caddr_t)oldbase, length, in create_cache_file_ch()
327 ch->fd = fd; in create_cache_file_ch()
328 ch->maxsize = maxsize; in create_cache_file_ch()
331 ch->version = CACHEKEY_HEADER_VERSION; in create_cache_file_ch()
332 ch->headerlength = sizeof (struct cachekey_header); in create_cache_file_ch()
333 ch->keylen = keylen; in create_cache_file_ch()
334 ch->algtype = algtype; in create_cache_file_ch()
335 ch->reclength = reclength; in create_cache_file_ch()
336 ch->length = length; in create_cache_file_ch()
337 ch->address = (caddr_t)ch; in create_cache_file_ch()
338 ch->inuse_count = 0; in create_cache_file_ch()
339 ch->inuse = 0; in create_cache_file_ch()
340 ch->inuse_end = 0; in create_cache_file_ch()
341 ch->free = 0; in create_cache_file_ch()
342 ch->free_count = 0; in create_cache_file_ch()
344 ch->bucket[i] = 0; in create_cache_file_ch()
347 cd = &(ch->array[0]); in create_cache_file_ch()
348 for (i = 0; i < MAPRECS(ch); in create_cache_file_ch()
349 i++, cd = MOVE_ADDR(cd, ch->reclength)) { in create_cache_file_ch()
351 cd->prev = MOVE_ADDR(cd, -(ch->reclength)); in create_cache_file_ch()
352 cd->next = MOVE_ADDR(cd, +(ch->reclength)); in create_cache_file_ch()
360 cd = MOVE_ADDR(cd, -(ch->reclength)); in create_cache_file_ch()
362 cd = &(ch->array[0]); in create_cache_file_ch()
365 ch->free_count = MAPRECS(ch); in create_cache_file_ch()
366 ch->free = &(ch->array[0]); in create_cache_file_ch()
368 (void) msync((caddr_t)ch, ch->length, MS_SYNC); in create_cache_file_ch()
370 } else if (ch->length > maxsize) { in create_cache_file_ch()
372 if ((ch = remap_cache_file_ch(ch, MAXRECS(ch))) == 0) { in create_cache_file_ch()
385 cache_remap_addresses_ch(ch) == 0) { in create_cache_file_ch()
388 (void) munmap((caddr_t)ch, ch->length); in create_cache_file_ch()
393 (void) msync((caddr_t)ch, ch->length, MS_SYNC); in create_cache_file_ch()
395 return (ch); in create_cache_file_ch()
400 cache_remap_addresses_ch(struct cachekey_header *ch) in cache_remap_addresses_ch() argument
406 offset = (u_long)ch - (u_long)ch->address; in cache_remap_addresses_ch()
408 if (INVALID_ADDRESS(ch->inuse, ch) || in cache_remap_addresses_ch()
409 INVALID_ADDRESS(ch->inuse_end, ch) || in cache_remap_addresses_ch()
410 INVALID_ADDRESS(ch->free, ch)) { in cache_remap_addresses_ch()
414 ch->inuse = MOVE_ADDR(ch->inuse, offset); in cache_remap_addresses_ch()
415 ch->inuse_end = MOVE_ADDR(ch->inuse_end, offset); in cache_remap_addresses_ch()
416 ch->free = MOVE_ADDR(ch->free, offset); in cache_remap_addresses_ch()
418 cd = &(ch->array[0]); in cache_remap_addresses_ch()
419 for (i = 0; i < NUMRECS(ch); i++) { in cache_remap_addresses_ch()
420 if (INVALID_ADDRESS(cd->prev, ch) || in cache_remap_addresses_ch()
421 INVALID_ADDRESS(cd->next, ch) || in cache_remap_addresses_ch()
422 INVALID_ADDRESS(cd->prevhash, ch) || in cache_remap_addresses_ch()
423 INVALID_ADDRESS(cd->nexthash, ch)) { in cache_remap_addresses_ch()
430 cd = MOVE_ADDR(cd, ch->reclength); in cache_remap_addresses_ch()
434 if (INVALID_ADDRESS(ch->bucket[i], ch)) { in cache_remap_addresses_ch()
437 ch->bucket[i] = MOVE_ADDR(ch->bucket[i], offset); in cache_remap_addresses_ch()
445 ch->address = (caddr_t)ch; in cache_remap_addresses_ch()
456 remap_cache_file_ch(struct cachekey_header *ch, u_int newrecs) in remap_cache_file_ch() argument
465 if (ch == 0) in remap_cache_file_ch()
477 (ch->reclength)*newrecs; in remap_cache_file_ch()
478 currecs = NUMRECS(ch); in remap_cache_file_ch()
480 if (newsize > ch->maxsize) { in remap_cache_file_ch()
482 newsize = ch->maxsize; in remap_cache_file_ch()
486 oldsize = ch->length; in remap_cache_file_ch()
487 oldaddr = (caddr_t)ch; in remap_cache_file_ch()
488 fd = ch->fd; in remap_cache_file_ch()
490 if (newsize > ch->length) { in remap_cache_file_ch()
492 cd = &(ch->array[0]); in remap_cache_file_ch()
493 } else if (newsize == ch->length) { in remap_cache_file_ch()
495 return (ch); in remap_cache_file_ch()
504 if (cache_remap_addresses_ch(ch) == 0) { in remap_cache_file_ch()
506 ch->keylen, ch->algtype); in remap_cache_file_ch()
507 close(ch->fd); in remap_cache_file_ch()
508 munmap((caddr_t)ch, ch->length); in remap_cache_file_ch()
511 fcd = MOVE_ADDR(&(ch->array[0]), in remap_cache_file_ch()
512 ch->reclength*(MAPRECS(ch)-1)); in remap_cache_file_ch()
513 tmpsize = (u_long)fcd - (u_long)ch + ch->reclength; in remap_cache_file_ch()
514 while (tmpsize > newsize && fcd > &(ch->array[0])) { in remap_cache_file_ch()
516 list_remove(fcd, &(ch->free), 0, in remap_cache_file_ch()
517 &(ch->free_count)); in remap_cache_file_ch()
520 &(ch->bucket[hashval(fcd->uid)]), 0, 0); in remap_cache_file_ch()
521 list_remove(fcd, &(ch->inuse), &(ch->inuse_end), in remap_cache_file_ch()
522 &(ch->inuse_count)); in remap_cache_file_ch()
524 tmpsize -= ch->reclength; in remap_cache_file_ch()
525 fcd = MOVE_ADDR(fcd, -(ch->reclength)); in remap_cache_file_ch()
527 ch->length = newsize; in remap_cache_file_ch()
528 (void) msync((caddr_t)ch, ch->length, MS_SYNC); in remap_cache_file_ch()
535 ch = 0; in remap_cache_file_ch()
580 print_cache_ch(struct cachekey_header *ch) in print_cache_ch() argument
588 ch->keylen, ch->algtype, ch->version, ch->headerlength, in print_cache_ch()
589 ch->reclength); in print_cache_ch()
591 ch->fd, ch->address, ch->length, ch->maxsize); in print_cache_ch()
592 printf("inuse = %d, free = %d\n", ch->inuse_count, ch->free_count); in print_cache_ch()
597 cd = ch->bucket[i]; in print_cache_ch()
619 cd = ch->inuse; in print_cache_ch()
631 cd = ch->free; in print_cache_ch()
654 if (c->ch == 0) { in print_cache()
659 print_cache_ch(c->ch); in print_cache()
798 find_cache_item(struct cachekey_header **ch, uid_t uid, struct dhkey *public) in find_cache_item() argument
805 if ((ch == NULL) || ((*ch) == NULL)) { in find_cache_item()
808 for (cd = (*ch)->bucket[hash]; cd != 0; cd = cd->nexthash) { in find_cache_item()
813 list_remove_hash(cd, &((*ch)->bucket[hash]), 0, 0); in find_cache_item()
814 list_remove(cd, &((*ch)->inuse), &((*ch)->inuse_end), in find_cache_item()
815 &((*ch)->inuse_count)); in find_cache_item()
820 if ((cd = (*ch)->free) != 0) { in find_cache_item()
821 list_remove(cd, &((*ch)->free), 0, &((*ch)->free_count)); in find_cache_item()
826 if (((*ch) = remap_cache_file_ch(*ch, NUMRECS(*ch)+CHUNK_NUMREC)) == 0) in find_cache_item()
830 if ((cd = (*ch)->free) != 0) { in find_cache_item()
831 list_remove(cd, &((*ch)->free), 0, &((*ch)->free_count)); in find_cache_item()
836 if ((cd = (*ch)->inuse) == 0) in find_cache_item()
840 list_remove_hash(cd, &((*ch)->bucket[hashval(cd->uid)]), 0, 0); in find_cache_item()
842 list_remove(cd, &((*ch)->inuse), &((*ch)->inuse_end), in find_cache_item()
843 &((*ch)->inuse_count)); in find_cache_item()
851 struct cachekey_header *ch, in cache_insert_ch() argument
867 if (ch == 0 || uid == (uid_t)-1) { in cache_insert_ch()
877 newch = ch; in cache_insert_ch()
921 copy_cl_item(struct cachekey_header *ch, struct cachekey_disklist *cd, in copy_cl_item() argument
930 if ((cl = malloc(CACHEKEY3_LIST_SIZE(ch->keylen))) == 0) { in copy_cl_item()
935 if ((skck = malloc(SKCK_LEN(ch->keylen))) == 0) { in copy_cl_item()
942 memcpy(skck, skck_cd, SKCK_LEN(ch->keylen)); in copy_cl_item()
944 err = cbc_crypt(key.c, (char *)skck, SKCK_LEN(ch->keylen), in copy_cl_item()
961 ALIGN4(2*KEYLEN(ch->keylen)+1)); in copy_cl_item()
965 ALIGN4(2*KEYLEN(ch->keylen)+1)); in copy_cl_item()
989 cache_retrieve_ch(struct cachekey_header *ch, uid_t uid, keybuf3 *public, in cache_retrieve_ch() argument
1004 for (cd = ch->bucket[hash]; cd != 0; cd = cd->nexthash) { in cache_retrieve_ch()
1013 cl = copy_cl_item(ch, cd, key); in cache_retrieve_ch()
1017 *cltmp = copy_cl_item(ch, cd, key); in cache_retrieve_ch()
1039 cache_remove_ch(struct cachekey_header *ch, uid_t uid, keybuf3 *public) { in cache_remove_ch() argument
1053 for (cd = ch->bucket[hash]; cd != 0; ) { in cache_remove_ch()
1063 list_remove_hash(cd, &(ch->bucket[hash]), 0, 0); in cache_remove_ch()
1064 list_remove(cd, &(ch->inuse), &(ch->inuse_end), in cache_remove_ch()
1065 &(ch->inuse_count)); in cache_remove_ch()
1067 list_insert(cd, &(ch->free), 0, in cache_remove_ch()
1068 &(ch->free_count)); in cache_remove_ch()
1080 list_remove_hash(cd, &(ch->bucket[hash]), 0, 0); in cache_remove_ch()
1081 list_remove(cd, &(ch->inuse), &(ch->inuse_end), in cache_remove_ch()
1082 &(ch->inuse_count)); in cache_remove_ch()
1084 list_insert(cd, &(ch->free), 0, in cache_remove_ch()
1085 &(ch->free_count)); in cache_remove_ch()
1143 c->ch = 0; in get_cache_header()
1187 if (c->ch != 0) { in create_cache_file()
1193 ret = (c->ch = create_cache_file_ch(keylen, algtype, sizespec)) != 0; in create_cache_file()
1216 if (c->ch == 0) { in cache_insert()
1221 ret = (c->ch = in cache_insert()
1222 cache_insert_ch(c->ch, uid, common, key, public, secret)) != 0; in cache_insert()
1244 if (c->ch == 0) { in cache_retrieve()
1249 cl = cache_retrieve_ch(c->ch, uid, public, key); in cache_retrieve()
1265 if (c->ch == 0) { in cache_remove()
1270 ret = cache_remove_ch(c->ch, uid, public); in cache_remove()