void fuse_exit_handler_internal_np(void) { pthread_mutex_lock(&mount_lock); hash_traverse(mount_hash, (int(*)())schedule_umount, NULL); pthread_mutex_unlock(&mount_lock); }
int hash_insert(hash *hash, const char *key, void *item) { hashitem *p; size_t i; switch(hash_traverse(hash, key, &p, NULL)) { case AVAILABLE: p->key = key; p->data = item; break; case FOUND: p->data = item; break; case COLLISION: hash->overflow->key = key; hash->overflow->data = item; p->next = hash->overflow; for(i = 0; i < hash->size && hash->data[i].key; i++); if(i < hash->size) { hash->overflow = &hash->data[i]; } break; default: return -1; } return 0; }
void fuse_unset_fuse_internal_np(struct fuse *f) { pthread_mutex_lock(&mount_lock); hash_traverse(mount_hash, (int(*)())unset_fuse_helper, f); pthread_mutex_unlock(&mount_lock); }
void fuse_set_fuse_internal_np(int fd, struct fuse *f) { struct mount_info mi; mi.fd = fd; mi.fuse = f; pthread_mutex_lock(&mount_lock); hash_traverse(mount_hash, (int(*)())set_fuse_helper, &mi); pthread_mutex_unlock(&mount_lock); }
void * hash_search(hash *hash, const char *key) { hashitem *p; if(hash_traverse(hash, key, &p, NULL) == FOUND) { return p->data; } return NULL; }
void table_str(mnhash_t *v, mnbytestream_t *bs) { off_t eod; bytestream_cat(bs, 1, "{"); eod = SEOD(bs); hash_traverse(v, (hash_traverser_t)table_str_cb, bs); if (eod < SEOD(bs)) { SADVANCEEOD(bs, -1); } bytestream_cat(bs, 2, "} "); }
void hash_delete(hash *hash, const char *key) { hashitem *p, *pp; if(hash_traverse(hash, key, &p, &pp) == FOUND) { pp->next = p->next; p->key = NULL; p->data = NULL; p->next = NULL; hash->overflow = p; } }
void pack_table(mnbytestream_t *bs, mnhash_t *v) { struct { mnbytestream_t *bs; } params; off_t seod0, seod1; union { uint32_t *i; char *c; } u; params.bs = bs; seod0 = SEOD(bs); pack_long(bs, 0); // placeholder seod1 = SEOD(bs); (void)hash_traverse(v, (hash_traverser_t)pack_table_cb, ¶ms); u.c = SDATA(bs, seod0); *u.i = htobe32((uint32_t)SEOD(bs) - seod1); }