Lines Matching +full:- +full:qe

3   Copyright (C) 2001-2007  Miklos Szeredi <[email protected]>
5 Implementation of the high-level FUSE API on top of the low-level
90 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
91 (type *)( (char *)__mptr - offsetof(type,member) );})
155 #define TREELOCK_WRITE -1
211 return -1; in fuse_register_module()
213 mod->name = strdup(name); in fuse_register_module()
214 if (!mod->name) { in fuse_register_module()
217 return -1; in fuse_register_module()
219 mod->factory = factory; in fuse_register_module()
220 mod->ctr = 0; in fuse_register_module()
221 mod->so = so; in fuse_register_module()
222 if (mod->so) in fuse_register_module()
223 mod->so->ctr++; in fuse_register_module()
224 mod->next = fuse_modules; in fuse_register_module()
233 for (mp = &fuse_modules; *mp; mp = &(*mp)->next) { in fuse_unregister_module()
235 *mp = (*mp)->next; in fuse_unregister_module()
239 free(m->name); in fuse_unregister_module()
245 int ret = -1; in fuse_load_so_module()
253 return -1; in fuse_load_so_module()
262 so->handle = dlopen(tmp, RTLD_NOW); in fuse_load_so_module()
263 if (so->handle == NULL) { in fuse_load_so_module()
270 factory = (fuse_module_factory_t*)dlsym(so->handle, tmp); in fuse_load_so_module()
285 dlclose(so->handle); in fuse_load_so_module()
294 for (m = fuse_modules; m; m = m->next) { in fuse_find_module()
295 if (strcmp(module, m->name) == 0) { in fuse_find_module()
296 m->ctr++; in fuse_find_module()
321 if (m->so) in fuse_put_module()
322 assert(m->ctr > 0); in fuse_put_module()
323 /* Builtin modules may already have m->ctr == 0 */ in fuse_put_module()
324 if (m->ctr > 0) in fuse_put_module()
325 m->ctr--; in fuse_put_module()
326 if (!m->ctr && m->so) { in fuse_put_module()
327 struct fusemod_so *so = m->so; in fuse_put_module()
328 assert(so->ctr > 0); in fuse_put_module()
329 so->ctr--; in fuse_put_module()
330 if (!so->ctr) { in fuse_put_module()
333 if ((*mp)->so == so) in fuse_put_module()
336 mp = &(*mp)->next; in fuse_put_module()
338 dlclose(so->handle); in fuse_put_module()
341 } else if (!m->ctr) { in fuse_put_module()
349 list->next = list; in init_list_head()
350 list->prev = list; in init_list_head()
355 return head->next == head; in list_empty()
361 next->prev = new; in list_add()
362 new->next = next; in list_add()
363 new->prev = prev; in list_add()
364 prev->next = new; in list_add()
369 list_add(new, head, head->next); in list_add_head()
374 list_add(new, head->prev, head); in list_add_tail()
379 struct list_head *prev = entry->prev; in list_del()
380 struct list_head *next = entry->next; in list_del()
382 next->prev = prev; in list_del()
383 prev->next = next; in list_del()
388 return f->conf.remember > 0; in lru_enabled()
412 return (struct node_slab *) (((uintptr_t) node) & ~((uintptr_t) f->pagesize - 1)); in node_to_slab()
424 mem = mmap(NULL, f->pagesize, PROT_READ | PROT_WRITE, in alloc_slab()
425 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); in alloc_slab()
428 return -1; in alloc_slab()
431 init_list_head(&slab->freelist); in alloc_slab()
432 slab->used = 0; in alloc_slab()
433 num = (f->pagesize - sizeof(struct node_slab)) / node_size; in alloc_slab()
435 start = (char *) mem + f->pagesize - num * node_size; in alloc_slab()
440 list_add_tail(n, &slab->freelist); in alloc_slab()
442 list_add_tail(&slab->list, &f->partial_slabs); in alloc_slab()
452 if (list_empty(&f->partial_slabs)) { in alloc_node()
457 slab = list_to_slab(f->partial_slabs.next); in alloc_node()
458 slab->used++; in alloc_node()
459 node = slab->freelist.next; in alloc_node()
461 if (list_empty(&slab->freelist)) { in alloc_node()
462 list_del(&slab->list); in alloc_node()
463 list_add_tail(&slab->list, &f->full_slabs); in alloc_node()
474 list_del(&slab->list); in free_slab()
475 res = munmap(slab, f->pagesize); in free_slab()
476 if (res == -1) in free_slab()
486 slab->used--; in free_node_mem()
487 if (slab->used) { in free_node_mem()
488 if (list_empty(&slab->freelist)) { in free_node_mem()
489 list_del(&slab->list); in free_node_mem()
490 list_add_tail(&slab->list, &f->partial_slabs); in free_node_mem()
492 list_add_head(n, &slab->freelist); in free_node_mem()
512 uint64_t hash = ((uint32_t) ino * 2654435761U) % f->id_table.size; in id_hash()
513 uint64_t oldhash = hash % (f->id_table.size / 2); in id_hash()
515 if (oldhash >= f->id_table.split) in id_hash()
526 for (node = f->id_table.array[hash]; node != NULL; node = node->id_next) in get_node_nocheck()
527 if (node->nodeid == nodeid) in get_node_nocheck()
551 list_del(&lnode->lru); in remove_node_lru()
552 init_list_head(&lnode->lru); in remove_node_lru()
559 list_del(&lnode->lru); in set_forget_time()
560 list_add_tail(&lnode->lru, &f->lru_table); in set_forget_time()
561 curr_time(&lnode->forget_time); in set_forget_time()
566 if (node->name != node->inline_name) in free_node()
567 free(node->name); in free_node()
573 size_t newsize = t->size / 2; in node_table_reduce()
579 newarray = realloc(t->array, sizeof(struct node *) * newsize); in node_table_reduce()
581 t->array = newarray; in node_table_reduce()
583 t->size = newsize; in node_table_reduce()
584 t->split = t->size / 2; in node_table_reduce()
589 struct node_table *t = &f->id_table; in remerge_id()
592 if (t->split == 0) in remerge_id()
595 for (iter = 8; t->split > 0 && iter; iter--) { in remerge_id()
598 t->split--; in remerge_id()
599 upper = &t->array[t->split + t->size / 2]; in remerge_id()
603 for (nodep = &t->array[t->split]; *nodep; in remerge_id()
604 nodep = &(*nodep)->id_next); in remerge_id()
615 struct node **nodep = &f->id_table.array[id_hash(f, node->nodeid)]; in unhash_id()
617 for (; *nodep != NULL; nodep = &(*nodep)->id_next) in unhash_id()
619 *nodep = node->id_next; in unhash_id()
620 f->id_table.use--; in unhash_id()
622 if(f->id_table.use < f->id_table.size / 4) in unhash_id()
630 size_t newsize = t->size * 2; in node_table_resize()
633 newarray = realloc(t->array, sizeof(struct node *) * newsize); in node_table_resize()
635 return -1; in node_table_resize()
637 t->array = newarray; in node_table_resize()
638 memset(t->array + t->size, 0, t->size * sizeof(struct node *)); in node_table_resize()
639 t->size = newsize; in node_table_resize()
640 t->split = 0; in node_table_resize()
647 struct node_table *t = &f->id_table; in rehash_id()
652 if (t->split == t->size / 2) in rehash_id()
655 hash = t->split; in rehash_id()
656 t->split++; in rehash_id()
657 for (nodep = &t->array[hash]; *nodep != NULL; nodep = next) { in rehash_id()
659 size_t newhash = id_hash(f, node->nodeid); in rehash_id()
663 *nodep = node->id_next; in rehash_id()
664 node->id_next = t->array[newhash]; in rehash_id()
665 t->array[newhash] = node; in rehash_id()
667 next = &node->id_next; in rehash_id()
670 if (t->split == t->size / 2) in rehash_id()
676 size_t hash = id_hash(f, node->nodeid); in hash_id()
677 node->id_next = f->id_table.array[hash]; in hash_id()
678 f->id_table.array[hash] = node; in hash_id()
679 f->id_table.use++; in hash_id()
681 if (f->id_table.use >= f->id_table.size / 2) in hash_id()
694 hash %= f->name_table.size; in name_hash()
695 oldhash = hash % (f->name_table.size / 2); in name_hash()
696 if (oldhash >= f->name_table.split) in name_hash()
706 struct node_table *t = &f->name_table; in remerge_name()
709 if (t->split == 0) in remerge_name()
712 for (iter = 8; t->split > 0 && iter; iter--) { in remerge_name()
715 t->split--; in remerge_name()
716 upper = &t->array[t->split + t->size / 2]; in remerge_name()
720 for (nodep = &t->array[t->split]; *nodep; in remerge_name()
721 nodep = &(*nodep)->name_next); in remerge_name()
732 if (node->name) { in unhash_name()
733 size_t hash = name_hash(f, node->parent->nodeid, node->name); in unhash_name()
734 struct node **nodep = &f->name_table.array[hash]; in unhash_name()
736 for (; *nodep != NULL; nodep = &(*nodep)->name_next) in unhash_name()
738 *nodep = node->name_next; in unhash_name()
739 node->name_next = NULL; in unhash_name()
740 unref_node(f, node->parent); in unhash_name()
741 if (node->name != node->inline_name) in unhash_name()
742 free(node->name); in unhash_name()
743 node->name = NULL; in unhash_name()
744 node->parent = NULL; in unhash_name()
745 f->name_table.use--; in unhash_name()
747 if (f->name_table.use < f->name_table.size / 4) in unhash_name()
753 (unsigned long long) node->nodeid); in unhash_name()
760 struct node_table *t = &f->name_table; in rehash_name()
765 if (t->split == t->size / 2) in rehash_name()
768 hash = t->split; in rehash_name()
769 t->split++; in rehash_name()
770 for (nodep = &t->array[hash]; *nodep != NULL; nodep = next) { in rehash_name()
772 size_t newhash = name_hash(f, node->parent->nodeid, node->name); in rehash_name()
776 *nodep = node->name_next; in rehash_name()
777 node->name_next = t->array[newhash]; in rehash_name()
778 t->array[newhash] = node; in rehash_name()
780 next = &node->name_next; in rehash_name()
783 if (t->split == t->size / 2) in rehash_name()
792 if (strlen(name) < sizeof(node->inline_name)) { in hash_name()
793 strcpy(node->inline_name, name); in hash_name()
794 node->name = node->inline_name; in hash_name()
796 node->name = strdup(name); in hash_name()
797 if (node->name == NULL) in hash_name()
798 return -1; in hash_name()
801 parent->refctr ++; in hash_name()
802 node->parent = parent; in hash_name()
803 node->name_next = f->name_table.array[hash]; in hash_name()
804 f->name_table.array[hash] = node; in hash_name()
805 f->name_table.use++; in hash_name()
807 if (f->name_table.use >= f->name_table.size / 2) in hash_name()
815 if (f->conf.debug) in delete_node()
817 (unsigned long long) node->nodeid); in delete_node()
819 assert(node->treelock == 0); in delete_node()
829 assert(node->refctr > 0); in unref_node()
830 node->refctr --; in unref_node()
831 if (!node->refctr) in unref_node()
838 f->ctr = (f->ctr + 1) & 0xffffffff; in next_id()
839 if (!f->ctr) in next_id()
840 f->generation ++; in next_id()
841 } while (f->ctr == 0 || f->ctr == FUSE_UNKNOWN_INO || in next_id()
842 get_node_nocheck(f, f->ctr) != NULL); in next_id()
843 return f->ctr; in next_id()
852 for (node = f->name_table.array[hash]; node != NULL; node = node->name_next) in lookup_node()
853 if (node->parent->nodeid == parent && in lookup_node()
854 strcmp(node->name, name) == 0) in lookup_node()
862 if (!node->nlookup) in inc_nlookup()
863 node->refctr++; in inc_nlookup()
864 node->nlookup++; in inc_nlookup()
872 pthread_mutex_lock(&f->lock); in find_node()
882 node->nodeid = next_id(f); in find_node()
883 node->generation = f->generation; in find_node()
884 if (f->conf.remember) in find_node()
887 if (hash_name(f, node, parent, name) == -1) { in find_node()
895 init_list_head(&lnode->lru); in find_node()
897 } else if (lru_enabled(f) && node->nlookup == 1) { in find_node()
902 pthread_mutex_unlock(&f->lock); in find_node()
911 return -ENOMEM; in lookup_path_in_cache()
913 pthread_mutex_lock(&f->lock); in lookup_path_in_cache()
922 err = -ENOENT; in lookup_path_in_cache()
925 ino = node->nodeid; in lookup_path_in_cache()
928 pthread_mutex_unlock(&f->lock); in lookup_path_in_cache()
940 if (s - len <= *buf) { in add_name()
941 unsigned pathlen = *bufsize - (s - *buf); in add_name()
957 s = newbuf + newbufsize - pathlen; in add_name()
958 memmove(s, newbuf + *bufsize - pathlen, pathlen); in add_name()
961 s -= len; in add_name()
963 s--; in add_name()
975 assert(wnode->treelock == TREELOCK_WRITE); in unlock_path()
976 wnode->treelock = 0; in unlock_path()
980 node != end && node->nodeid != FUSE_ROOT_ID; node = node->parent) { in unlock_path()
981 assert(node->treelock != 0); in unlock_path()
982 assert(node->treelock != TREELOCK_WAIT_OFFSET); in unlock_path()
983 assert(node->treelock != TREELOCK_WRITE); in unlock_path()
984 node->treelock--; in unlock_path()
985 if (node->treelock == TREELOCK_WAIT_OFFSET) in unlock_path()
986 node->treelock = 0; in unlock_path()
1002 err = -ENOMEM; in try_get_path()
1007 s = buf + bufsize - 1; in try_get_path()
1012 err = -ENOMEM; in try_get_path()
1021 if (wnode->treelock != 0) { in try_get_path()
1022 if (wnode->treelock > 0) in try_get_path()
1023 wnode->treelock += TREELOCK_WAIT_OFFSET; in try_get_path()
1024 err = -EAGAIN; in try_get_path()
1027 wnode->treelock = TREELOCK_WRITE; in try_get_path()
1031 for (node = get_node(f, nodeid); node->nodeid != FUSE_ROOT_ID; in try_get_path()
1032 node = node->parent) { in try_get_path()
1033 err = -ESTALE; in try_get_path()
1034 if (node->name == NULL || node->parent == NULL) in try_get_path()
1037 err = -ENOMEM; in try_get_path()
1038 s = add_name(&buf, &bufsize, s, node->name); in try_get_path()
1043 err = -EAGAIN; in try_get_path()
1044 if (node->treelock < 0) in try_get_path()
1047 node->treelock++; in try_get_path()
1052 memmove(buf, s, bufsize - (s - buf)); in try_get_path()
1093 static void queue_element_wakeup(struct fuse *f, struct lock_queue_element *qe) in queue_element_wakeup() argument
1097 if (!qe->path1) { in queue_element_wakeup()
1099 if (get_node(f, qe->nodeid1)->treelock == 0) in queue_element_wakeup()
1100 pthread_cond_signal(&qe->cond); in queue_element_wakeup()
1105 if (qe->done) in queue_element_wakeup()
1106 return; // Don't try to double-lock the element in queue_element_wakeup()
1108 if (!qe->path2) { in queue_element_wakeup()
1109 err = try_get_path(f, qe->nodeid1, qe->name1, qe->path1, in queue_element_wakeup()
1110 qe->wnode1, true); in queue_element_wakeup()
1112 err = try_get_path2(f, qe->nodeid1, qe->name1, qe->nodeid2, in queue_element_wakeup()
1113 qe->name2, qe->path1, qe->path2, qe->wnode1, in queue_element_wakeup()
1114 qe->wnode2); in queue_element_wakeup()
1117 if (err == -EAGAIN) in queue_element_wakeup()
1120 qe->err = err; in queue_element_wakeup()
1121 qe->done = true; in queue_element_wakeup()
1122 pthread_cond_signal(&qe->cond); in queue_element_wakeup()
1127 struct lock_queue_element *qe; in wake_up_queued() local
1129 for (qe = f->lockq; qe != NULL; qe = qe->next) in wake_up_queued()
1130 queue_element_wakeup(f, qe); in wake_up_queued()
1136 if (f->conf.debug) { in debug_path()
1144 msg, (unsigned long long) wnode->nodeid); in debug_path()
1152 static void queue_path(struct fuse *f, struct lock_queue_element *qe) in queue_path() argument
1156 qe->done = false; in queue_path()
1157 pthread_cond_init(&qe->cond, NULL); in queue_path()
1158 qe->next = NULL; in queue_path()
1159 for (qp = &f->lockq; *qp != NULL; qp = &(*qp)->next); in queue_path()
1160 *qp = qe; in queue_path()
1163 static void dequeue_path(struct fuse *f, struct lock_queue_element *qe) in dequeue_path() argument
1167 pthread_cond_destroy(&qe->cond); in dequeue_path()
1168 for (qp = &f->lockq; *qp != qe; qp = &(*qp)->next); in dequeue_path()
1169 *qp = qe->next; in dequeue_path()
1172 static int wait_path(struct fuse *f, struct lock_queue_element *qe) in wait_path() argument
1174 queue_path(f, qe); in wait_path()
1177 pthread_cond_wait(&qe->cond, &f->lock); in wait_path()
1178 } while (!qe->done); in wait_path()
1180 dequeue_path(f, qe); in wait_path()
1182 return qe->err; in wait_path()
1190 pthread_mutex_lock(&f->lock); in get_path_common()
1192 if (err == -EAGAIN) { in get_path_common()
1193 struct lock_queue_element qe = { in get_path_common() local
1200 err = wait_path(f, &qe); in get_path_common()
1203 pthread_mutex_unlock(&f->lock); in get_path_common()
1217 if (f->conf.nullpath_ok) { in get_path_nullok()
1221 if (err == -ESTALE) in get_path_nullok()
1253 id1 = node1 ? node1->nodeid : nodeid1; in check_dir_loop()
1256 id2 = node2 ? node2->nodeid : nodeid2; in check_dir_loop()
1258 for (node = get_node(f, id2); node->nodeid != FUSE_ROOT_ID; in check_dir_loop()
1259 node = node->parent) { in check_dir_loop()
1260 if (node->name == NULL || node->parent == NULL) in check_dir_loop()
1263 if (node->nodeid != id2 && node->nodeid == id1) in check_dir_loop()
1264 return -EINVAL; in check_dir_loop()
1269 for (node = get_node(f, id1); node->nodeid != FUSE_ROOT_ID; in check_dir_loop()
1270 node = node->parent) { in check_dir_loop()
1271 if (node->name == NULL || node->parent == NULL) in check_dir_loop()
1274 if (node->nodeid != id1 && node->nodeid == id2) in check_dir_loop()
1275 return -ENOTEMPTY; in check_dir_loop()
1290 pthread_mutex_lock(&f->lock); in get_path2()
1304 if (err == -EAGAIN) { in get_path2()
1305 struct lock_queue_element qe = { in get_path2() local
1318 err = wait_path(f, &qe); in get_path2()
1326 pthread_mutex_unlock(&f->lock); in get_path2()
1334 pthread_mutex_lock(&f->lock); in free_path_wrlock()
1336 if (f->lockq) in free_path_wrlock()
1338 pthread_mutex_unlock(&f->lock); in free_path_wrlock()
1352 pthread_mutex_lock(&f->lock); in free_path2()
1356 pthread_mutex_unlock(&f->lock); in free_path2()
1366 pthread_mutex_lock(&f->lock); in forget_node()
1373 while (node->nlookup == nlookup && node->treelock) { in forget_node()
1374 struct lock_queue_element qe = { in forget_node() local
1379 queue_path(f, &qe); in forget_node()
1382 pthread_cond_wait(&qe.cond, &f->lock); in forget_node()
1383 } while (node->nlookup == nlookup && node->treelock); in forget_node()
1385 dequeue_path(f, &qe); in forget_node()
1389 assert(node->nlookup >= nlookup); in forget_node()
1390 node->nlookup -= nlookup; in forget_node()
1391 if (!node->nlookup) { in forget_node()
1393 } else if (lru_enabled(f) && node->nlookup == 1) { in forget_node()
1396 pthread_mutex_unlock(&f->lock); in forget_node()
1401 if (f->conf.remember) { in unlink_node()
1402 assert(node->nlookup > 1); in unlink_node()
1403 node->nlookup--; in unlink_node()
1412 pthread_mutex_lock(&f->lock); in remove_node()
1416 pthread_mutex_unlock(&f->lock); in remove_node()
1426 pthread_mutex_lock(&f->lock); in rename_node()
1435 err = -EBUSY; in rename_node()
1442 if (hash_name(f, node, newdir, newname) == -1) { in rename_node()
1443 err = -ENOMEM; in rename_node()
1448 node->is_hidden = 1; in rename_node()
1451 pthread_mutex_unlock(&f->lock); in rename_node()
1462 pthread_mutex_lock(&f->lock); in exchange_node()
1471 err = -ENOMEM; in exchange_node()
1473 if (hash_name(f, oldnode, newdir, newname) == -1) in exchange_node()
1477 if (hash_name(f, newnode, olddir, oldname) == -1) in exchange_node()
1482 pthread_mutex_unlock(&f->lock); in exchange_node()
1488 if (!f->conf.use_ino) in set_stat()
1489 stbuf->st_ino = nodeid; in set_stat()
1490 if (f->conf.set_mode) in set_stat()
1491 stbuf->st_mode = (stbuf->st_mode & S_IFMT) | in set_stat()
1492 (0777 & ~f->conf.umask); in set_stat()
1493 if (f->conf.set_uid) in set_stat()
1494 stbuf->st_uid = f->conf.uid; in set_stat()
1495 if (f->conf.set_gid) in set_stat()
1496 stbuf->st_gid = f->conf.gid; in set_stat()
1521 if (d->id == pthread_self()) in fuse_interrupt()
1524 pthread_mutex_lock(&f->lock); in fuse_interrupt()
1525 while (!d->finished) { in fuse_interrupt()
1529 pthread_kill(d->id, f->conf.intr_signal); in fuse_interrupt()
1533 pthread_cond_timedwait(&d->cond, &f->lock, &timeout); in fuse_interrupt()
1535 pthread_mutex_unlock(&f->lock); in fuse_interrupt()
1541 pthread_mutex_lock(&f->lock); in fuse_do_finish_interrupt()
1542 d->finished = 1; in fuse_do_finish_interrupt()
1543 pthread_cond_broadcast(&d->cond); in fuse_do_finish_interrupt()
1544 pthread_mutex_unlock(&f->lock); in fuse_do_finish_interrupt()
1546 pthread_cond_destroy(&d->cond); in fuse_do_finish_interrupt()
1551 d->id = pthread_self(); in fuse_do_prepare_interrupt()
1552 pthread_cond_init(&d->cond, NULL); in fuse_do_prepare_interrupt()
1553 d->finished = 0; in fuse_do_prepare_interrupt()
1560 if (f->conf.intr) in fuse_finish_interrupt()
1567 if (f->conf.intr) in fuse_prepare_interrupt()
1576 snprintf(buf, len, "%llu", (unsigned long long) fi->fh); in file_info_string()
1583 fuse_get_context()->private_data = fs->user_data; in fuse_fs_getattr()
1584 if (fs->op.getattr) { in fuse_fs_getattr()
1585 if (fs->debug) { in fuse_fs_getattr()
1591 return fs->op.getattr(path, buf, fi); in fuse_fs_getattr()
1593 return -ENOSYS; in fuse_fs_getattr()
1600 fuse_get_context()->private_data = fs->user_data; in fuse_fs_rename()
1601 if (fs->op.rename) { in fuse_fs_rename()
1602 if (fs->debug) in fuse_fs_rename()
1606 return fs->op.rename(oldpath, newpath, flags); in fuse_fs_rename()
1608 return -ENOSYS; in fuse_fs_rename()
1614 fuse_get_context()->private_data = fs->user_data; in fuse_fs_unlink()
1615 if (fs->op.unlink) { in fuse_fs_unlink()
1616 if (fs->debug) in fuse_fs_unlink()
1619 return fs->op.unlink(path); in fuse_fs_unlink()
1621 return -ENOSYS; in fuse_fs_unlink()
1627 fuse_get_context()->private_data = fs->user_data; in fuse_fs_rmdir()
1628 if (fs->op.rmdir) { in fuse_fs_rmdir()
1629 if (fs->debug) in fuse_fs_rmdir()
1632 return fs->op.rmdir(path); in fuse_fs_rmdir()
1634 return -ENOSYS; in fuse_fs_rmdir()
1640 fuse_get_context()->private_data = fs->user_data; in fuse_fs_symlink()
1641 if (fs->op.symlink) { in fuse_fs_symlink()
1642 if (fs->debug) in fuse_fs_symlink()
1645 return fs->op.symlink(linkname, path); in fuse_fs_symlink()
1647 return -ENOSYS; in fuse_fs_symlink()
1653 fuse_get_context()->private_data = fs->user_data; in fuse_fs_link()
1654 if (fs->op.link) { in fuse_fs_link()
1655 if (fs->debug) in fuse_fs_link()
1658 return fs->op.link(oldpath, newpath); in fuse_fs_link()
1660 return -ENOSYS; in fuse_fs_link()
1667 fuse_get_context()->private_data = fs->user_data; in fuse_fs_release()
1668 if (fs->op.release) { in fuse_fs_release()
1669 if (fs->debug) in fuse_fs_release()
1671 fi->flush ? "+flush" : "", in fuse_fs_release()
1672 (unsigned long long) fi->fh, fi->flags); in fuse_fs_release()
1674 return fs->op.release(path, fi); in fuse_fs_release()
1683 fuse_get_context()->private_data = fs->user_data; in fuse_fs_opendir()
1684 if (fs->op.opendir) { in fuse_fs_opendir()
1687 if (fs->debug) in fuse_fs_opendir()
1688 fuse_log(FUSE_LOG_DEBUG, "opendir flags: 0x%x %s\n", fi->flags, in fuse_fs_opendir()
1691 err = fs->op.opendir(path, fi); in fuse_fs_opendir()
1693 if (fs->debug && !err) in fuse_fs_opendir()
1695 (unsigned long long) fi->fh, fi->flags, path); in fuse_fs_opendir()
1706 fuse_get_context()->private_data = fs->user_data; in fuse_fs_open()
1707 if (fs->op.open) { in fuse_fs_open()
1710 if (fs->debug) in fuse_fs_open()
1711 fuse_log(FUSE_LOG_DEBUG, "open flags: 0x%x %s\n", fi->flags, in fuse_fs_open()
1714 err = fs->op.open(path, fi); in fuse_fs_open()
1716 if (fs->debug && !err) in fuse_fs_open()
1718 (unsigned long long) fi->fh, fi->flags, path); in fuse_fs_open()
1731 for (i = 0; i < buf->count; i++) in fuse_free_buf()
1732 if (!(buf->buf[i].flags & FUSE_BUF_IS_FD)) in fuse_free_buf()
1733 free(buf->buf[i].mem); in fuse_free_buf()
1742 fuse_get_context()->private_data = fs->user_data; in fuse_fs_read_buf()
1743 if (fs->op.read || fs->op.read_buf) { in fuse_fs_read_buf()
1746 if (fs->debug) in fuse_fs_read_buf()
1749 (unsigned long long) fi->fh, in fuse_fs_read_buf()
1750 size, (unsigned long long) off, fi->flags); in fuse_fs_read_buf()
1752 if (fs->op.read_buf) { in fuse_fs_read_buf()
1753 res = fs->op.read_buf(path, bufp, size, off, fi); in fuse_fs_read_buf()
1760 return -ENOMEM; in fuse_fs_read_buf()
1765 return -ENOMEM; in fuse_fs_read_buf()
1768 buf->buf[0].mem = mem; in fuse_fs_read_buf()
1771 res = fs->op.read(path, mem, size, off, fi); in fuse_fs_read_buf()
1773 buf->buf[0].size = res; in fuse_fs_read_buf()
1776 if (fs->debug && res >= 0) in fuse_fs_read_buf()
1778 (unsigned long long) fi->fh, in fuse_fs_read_buf()
1789 return -ENOSYS; in fuse_fs_read_buf()
1796 fuse_get_context()->private_data = fs->user_data; in fuse_fs_read()
1797 if (fs->op.read || fs->op.read_buf) { in fuse_fs_read()
1800 if (fs->debug) in fuse_fs_read()
1803 (unsigned long long) fi->fh, in fuse_fs_read()
1804 size, (unsigned long long) off, fi->flags); in fuse_fs_read()
1806 if (fs->op.read_buf) { in fuse_fs_read()
1809 res = fs->op.read_buf(path, &buf, size, off, fi); in fuse_fs_read()
1818 res = fs->op.read(path, mem, size, off, fi); in fuse_fs_read()
1821 if (fs->debug && res >= 0) in fuse_fs_read()
1823 (unsigned long long) fi->fh, in fuse_fs_read()
1831 return -ENOSYS; in fuse_fs_read()
1839 fuse_get_context()->private_data = fs->user_data; in fuse_fs_write_buf()
1840 if (fs->op.write_buf || fs->op.write) { in fuse_fs_write_buf()
1844 assert(buf->idx == 0 && buf->off == 0); in fuse_fs_write_buf()
1845 if (fs->debug) in fuse_fs_write_buf()
1848 fi->writepage ? "page" : "", in fuse_fs_write_buf()
1849 (unsigned long long) fi->fh, in fuse_fs_write_buf()
1852 fi->flags); in fuse_fs_write_buf()
1854 if (fs->op.write_buf) { in fuse_fs_write_buf()
1855 res = fs->op.write_buf(path, buf, off, fi); in fuse_fs_write_buf()
1861 if (buf->count == 1 && in fuse_fs_write_buf()
1862 !(buf->buf[0].flags & FUSE_BUF_IS_FD)) { in fuse_fs_write_buf()
1863 flatbuf = &buf->buf[0]; in fuse_fs_write_buf()
1865 res = -ENOMEM; in fuse_fs_write_buf()
1879 res = fs->op.write(path, flatbuf->mem, flatbuf->size, in fuse_fs_write_buf()
1885 if (fs->debug && res >= 0) in fuse_fs_write_buf()
1887 fi->writepage ? "page" : "", in fuse_fs_write_buf()
1888 (unsigned long long) fi->fh, res, in fuse_fs_write_buf()
1895 return -ENOSYS; in fuse_fs_write_buf()
1912 fuse_get_context()->private_data = fs->user_data; in fuse_fs_fsync()
1913 if (fs->op.fsync) { in fuse_fs_fsync()
1914 if (fs->debug) in fuse_fs_fsync()
1916 (unsigned long long) fi->fh, datasync); in fuse_fs_fsync()
1918 return fs->op.fsync(path, datasync, fi); in fuse_fs_fsync()
1920 return -ENOSYS; in fuse_fs_fsync()
1927 fuse_get_context()->private_data = fs->user_data; in fuse_fs_fsyncdir()
1928 if (fs->op.fsyncdir) { in fuse_fs_fsyncdir()
1929 if (fs->debug) in fuse_fs_fsyncdir()
1931 (unsigned long long) fi->fh, datasync); in fuse_fs_fsyncdir()
1933 return fs->op.fsyncdir(path, datasync, fi); in fuse_fs_fsyncdir()
1935 return -ENOSYS; in fuse_fs_fsyncdir()
1942 fuse_get_context()->private_data = fs->user_data; in fuse_fs_flush()
1943 if (fs->op.flush) { in fuse_fs_flush()
1944 if (fs->debug) in fuse_fs_flush()
1946 (unsigned long long) fi->fh); in fuse_fs_flush()
1948 return fs->op.flush(path, fi); in fuse_fs_flush()
1950 return -ENOSYS; in fuse_fs_flush()
1956 fuse_get_context()->private_data = fs->user_data; in fuse_fs_statfs()
1957 if (fs->op.statfs) { in fuse_fs_statfs()
1958 if (fs->debug) in fuse_fs_statfs()
1961 return fs->op.statfs(path, buf); in fuse_fs_statfs()
1963 buf->f_namemax = 255; in fuse_fs_statfs()
1964 buf->f_bsize = 512; in fuse_fs_statfs()
1972 fuse_get_context()->private_data = fs->user_data; in fuse_fs_releasedir()
1973 if (fs->op.releasedir) { in fuse_fs_releasedir()
1974 if (fs->debug) in fuse_fs_releasedir()
1976 (unsigned long long) fi->fh, fi->flags); in fuse_fs_releasedir()
1978 return fs->op.releasedir(path, fi); in fuse_fs_releasedir()
1989 fuse_get_context()->private_data = fs->user_data; in fuse_fs_readdir()
1990 if (fs->op.readdir) { in fuse_fs_readdir()
1991 if (fs->debug) { in fuse_fs_readdir()
1994 (unsigned long long) fi->fh, in fuse_fs_readdir()
1998 return fs->op.readdir(path, buf, filler, off, fi, flags); in fuse_fs_readdir()
2000 return -ENOSYS; in fuse_fs_readdir()
2007 fuse_get_context()->private_data = fs->user_data; in fuse_fs_create()
2008 if (fs->op.create) { in fuse_fs_create()
2011 if (fs->debug) in fuse_fs_create()
2014 fi->flags, path, mode, in fuse_fs_create()
2015 fuse_get_context()->umask); in fuse_fs_create()
2017 err = fs->op.create(path, mode, fi); in fuse_fs_create()
2019 if (fs->debug && !err) in fuse_fs_create()
2021 (unsigned long long) fi->fh, fi->flags, path); in fuse_fs_create()
2025 return -ENOSYS; in fuse_fs_create()
2032 fuse_get_context()->private_data = fs->user_data; in fuse_fs_lock()
2033 if (fs->op.lock) { in fuse_fs_lock()
2034 if (fs->debug) in fuse_fs_lock()
2036 (unsigned long long) fi->fh, in fuse_fs_lock()
2040 (lock->l_type == F_RDLCK ? "F_RDLCK" : in fuse_fs_lock()
2041 (lock->l_type == F_WRLCK ? "F_WRLCK" : in fuse_fs_lock()
2042 (lock->l_type == F_UNLCK ? "F_UNLCK" : in fuse_fs_lock()
2044 (unsigned long long) lock->l_start, in fuse_fs_lock()
2045 (unsigned long long) lock->l_len, in fuse_fs_lock()
2046 (unsigned long long) lock->l_pid); in fuse_fs_lock()
2048 return fs->op.lock(path, fi, cmd, lock); in fuse_fs_lock()
2050 return -ENOSYS; in fuse_fs_lock()
2057 fuse_get_context()->private_data = fs->user_data; in fuse_fs_flock()
2058 if (fs->op.flock) { in fuse_fs_flock()
2059 if (fs->debug) { in fuse_fs_flock()
2063 (unsigned long long) fi->fh, in fuse_fs_flock()
2069 return fs->op.flock(path, fi, op); in fuse_fs_flock()
2071 return -ENOSYS; in fuse_fs_flock()
2078 fuse_get_context()->private_data = fs->user_data; in fuse_fs_chown()
2079 if (fs->op.chown) { in fuse_fs_chown()
2080 if (fs->debug) { in fuse_fs_chown()
2086 return fs->op.chown(path, uid, gid, fi); in fuse_fs_chown()
2088 return -ENOSYS; in fuse_fs_chown()
2095 fuse_get_context()->private_data = fs->user_data; in fuse_fs_truncate()
2096 if (fs->op.truncate) { in fuse_fs_truncate()
2097 if (fs->debug) { in fuse_fs_truncate()
2103 return fs->op.truncate(path, size, fi); in fuse_fs_truncate()
2105 return -ENOSYS; in fuse_fs_truncate()
2112 fuse_get_context()->private_data = fs->user_data; in fuse_fs_utimens()
2113 if (fs->op.utimens) { in fuse_fs_utimens()
2114 if (fs->debug) { in fuse_fs_utimens()
2121 return fs->op.utimens(path, tv, fi); in fuse_fs_utimens()
2123 return -ENOSYS; in fuse_fs_utimens()
2129 fuse_get_context()->private_data = fs->user_data; in fuse_fs_access()
2130 if (fs->op.access) { in fuse_fs_access()
2131 if (fs->debug) in fuse_fs_access()
2134 return fs->op.access(path, mask); in fuse_fs_access()
2136 return -ENOSYS; in fuse_fs_access()
2143 fuse_get_context()->private_data = fs->user_data; in fuse_fs_readlink()
2144 if (fs->op.readlink) { in fuse_fs_readlink()
2145 if (fs->debug) in fuse_fs_readlink()
2149 return fs->op.readlink(path, buf, len); in fuse_fs_readlink()
2151 return -ENOSYS; in fuse_fs_readlink()
2158 fuse_get_context()->private_data = fs->user_data; in fuse_fs_mknod()
2159 if (fs->op.mknod) { in fuse_fs_mknod()
2160 if (fs->debug) in fuse_fs_mknod()
2163 fuse_get_context()->umask); in fuse_fs_mknod()
2165 return fs->op.mknod(path, mode, rdev); in fuse_fs_mknod()
2167 return -ENOSYS; in fuse_fs_mknod()
2173 fuse_get_context()->private_data = fs->user_data; in fuse_fs_mkdir()
2174 if (fs->op.mkdir) { in fuse_fs_mkdir()
2175 if (fs->debug) in fuse_fs_mkdir()
2177 path, mode, fuse_get_context()->umask); in fuse_fs_mkdir()
2179 return fs->op.mkdir(path, mode); in fuse_fs_mkdir()
2181 return -ENOSYS; in fuse_fs_mkdir()
2188 fuse_get_context()->private_data = fs->user_data; in fuse_fs_setxattr()
2189 if (fs->op.setxattr) { in fuse_fs_setxattr()
2190 if (fs->debug) in fuse_fs_setxattr()
2194 return fs->op.setxattr(path, name, value, size, flags); in fuse_fs_setxattr()
2196 return -ENOSYS; in fuse_fs_setxattr()
2203 fuse_get_context()->private_data = fs->user_data; in fuse_fs_getxattr()
2204 if (fs->op.getxattr) { in fuse_fs_getxattr()
2205 if (fs->debug) in fuse_fs_getxattr()
2209 return fs->op.getxattr(path, name, value, size); in fuse_fs_getxattr()
2211 return -ENOSYS; in fuse_fs_getxattr()
2218 fuse_get_context()->private_data = fs->user_data; in fuse_fs_listxattr()
2219 if (fs->op.listxattr) { in fuse_fs_listxattr()
2220 if (fs->debug) in fuse_fs_listxattr()
2224 return fs->op.listxattr(path, list, size); in fuse_fs_listxattr()
2226 return -ENOSYS; in fuse_fs_listxattr()
2233 fuse_get_context()->private_data = fs->user_data; in fuse_fs_bmap()
2234 if (fs->op.bmap) { in fuse_fs_bmap()
2235 if (fs->debug) in fuse_fs_bmap()
2240 return fs->op.bmap(path, blocksize, idx); in fuse_fs_bmap()
2242 return -ENOSYS; in fuse_fs_bmap()
2248 fuse_get_context()->private_data = fs->user_data; in fuse_fs_removexattr()
2249 if (fs->op.removexattr) { in fuse_fs_removexattr()
2250 if (fs->debug) in fuse_fs_removexattr()
2253 return fs->op.removexattr(path, name); in fuse_fs_removexattr()
2255 return -ENOSYS; in fuse_fs_removexattr()
2263 fuse_get_context()->private_data = fs->user_data; in fuse_fs_ioctl()
2264 if (fs->op.ioctl) { in fuse_fs_ioctl()
2265 if (fs->debug) in fuse_fs_ioctl()
2267 (unsigned long long) fi->fh, cmd, flags); in fuse_fs_ioctl()
2269 return fs->op.ioctl(path, cmd, arg, fi, flags, data); in fuse_fs_ioctl()
2271 return -ENOSYS; in fuse_fs_ioctl()
2278 fuse_get_context()->private_data = fs->user_data; in fuse_fs_poll()
2279 if (fs->op.poll) { in fuse_fs_poll()
2282 if (fs->debug) in fuse_fs_poll()
2284 (unsigned long long) fi->fh, ph, in fuse_fs_poll()
2285 fi->poll_events); in fuse_fs_poll()
2287 res = fs->op.poll(path, fi, ph, reventsp); in fuse_fs_poll()
2289 if (fs->debug && !res) in fuse_fs_poll()
2291 (unsigned long long) fi->fh, *reventsp); in fuse_fs_poll()
2295 return -ENOSYS; in fuse_fs_poll()
2301 fuse_get_context()->private_data = fs->user_data; in fuse_fs_fallocate()
2302 if (fs->op.fallocate) { in fuse_fs_fallocate()
2303 if (fs->debug) in fuse_fs_fallocate()
2310 return fs->op.fallocate(path, mode, offset, length, fi); in fuse_fs_fallocate()
2312 return -ENOSYS; in fuse_fs_fallocate()
2321 fuse_get_context()->private_data = fs->user_data; in fuse_fs_copy_file_range()
2322 if (fs->op.copy_file_range) { in fuse_fs_copy_file_range()
2323 if (fs->debug) in fuse_fs_copy_file_range()
2332 return fs->op.copy_file_range(path_in, fi_in, off_in, path_out, in fuse_fs_copy_file_range()
2335 return -ENOSYS; in fuse_fs_copy_file_range()
2341 fuse_get_context()->private_data = fs->user_data; in fuse_fs_lseek()
2342 if (fs->op.lseek) { in fuse_fs_lseek()
2343 if (fs->debug) { in fuse_fs_lseek()
2349 return fs->op.lseek(path, off, whence, fi); in fuse_fs_lseek()
2351 return -ENOSYS; in fuse_fs_lseek()
2359 pthread_mutex_lock(&f->lock); in is_open()
2361 if (node && node->open_count > 0) in is_open()
2363 pthread_mutex_unlock(&f->lock); in is_open()
2378 pthread_mutex_lock(&f->lock); in hidden_name()
2381 pthread_mutex_unlock(&f->lock); in hidden_name()
2385 f->hidectr ++; in hidden_name()
2387 (unsigned int) node->nodeid, f->hidectr); in hidden_name()
2392 pthread_mutex_unlock(&f->lock); in hidden_name()
2397 res = fuse_fs_getattr(f->fs, newpath, &buf, NULL); in hidden_name()
2398 if (res == -ENOENT) in hidden_name()
2402 } while(res == 0 && --failctr); in hidden_name()
2412 int err = -EBUSY; in hide_node()
2416 err = fuse_fs_rename(f->fs, oldpath, newpath, 0); in hide_node()
2426 return stbuf->st_mtime == ts->tv_sec && in mtime_eq()
2427 ST_MTIM_NSEC(stbuf) == ts->tv_nsec; in mtime_eq()
2438 if (res == -1 && errno == EINVAL) { in curr_time()
2442 if (res == -1) { in curr_time()
2450 if (node->cache_valid && (!mtime_eq(stbuf, &node->mtime) || in update_stat()
2451 stbuf->st_size != node->size)) in update_stat()
2452 node->cache_valid = 0; in update_stat()
2453 node->mtime.tv_sec = stbuf->st_mtime; in update_stat()
2454 node->mtime.tv_nsec = ST_MTIM_NSEC(stbuf); in update_stat()
2455 node->size = stbuf->st_size; in update_stat()
2456 curr_time(&node->stat_updated); in update_stat()
2466 return -ENOMEM; in do_lookup()
2468 e->ino = node->nodeid; in do_lookup()
2469 e->generation = node->generation; in do_lookup()
2470 e->entry_timeout = f->conf.entry_timeout; in do_lookup()
2471 e->attr_timeout = f->conf.attr_timeout; in do_lookup()
2472 if (f->conf.auto_cache) { in do_lookup()
2473 pthread_mutex_lock(&f->lock); in do_lookup()
2474 update_stat(node, &e->attr); in do_lookup()
2475 pthread_mutex_unlock(&f->lock); in do_lookup()
2477 set_stat(f, e->ino, &e->attr); in do_lookup()
2488 res = fuse_fs_getattr(f->fs, path, &e->attr, fi); in lookup_path()
2491 if (res == 0 && f->conf.debug) { in lookup_path()
2493 (unsigned long long) e->ino); in lookup_path()
2522 c->ctx.fuse = f; in fuse_create_context()
2542 return -1; in fuse_create_context_key()
2553 fuse_context_ref--; in fuse_delete_context_key()
2565 c->req = req; in req_fuse_prepare()
2566 c->ctx.uid = ctx->uid; in req_fuse_prepare()
2567 c->ctx.gid = ctx->gid; in req_fuse_prepare()
2568 c->ctx.pid = ctx->pid; in req_fuse_prepare()
2569 c->ctx.umask = ctx->umask; in req_fuse_prepare()
2570 return c->ctx.fuse; in req_fuse_prepare()
2575 /* fuse_reply_err() uses non-negated errno values */ in reply_err()
2576 fuse_reply_err(req, -err); in reply_err()
2584 if (fuse_reply_entry(req, e) == -ENOENT) { in reply_entry()
2586 if (e->ino != 0) in reply_entry()
2587 forget_node(f, e->ino, 1); in reply_entry()
2596 fuse_get_context()->private_data = fs->user_data; in fuse_fs_init()
2597 if (!fs->op.write_buf) in fuse_fs_init()
2598 conn->want &= ~FUSE_CAP_SPLICE_READ; in fuse_fs_init()
2599 if (!fs->op.lock) in fuse_fs_init()
2600 conn->want &= ~FUSE_CAP_POSIX_LOCKS; in fuse_fs_init()
2601 if (!fs->op.flock) in fuse_fs_init()
2602 conn->want &= ~FUSE_CAP_FLOCK_LOCKS; in fuse_fs_init()
2603 if (fs->op.init) in fuse_fs_init()
2604 fs->user_data = fs->op.init(conn, cfg); in fuse_fs_init()
2612 if(conn->capable & FUSE_CAP_EXPORT_SUPPORT) in fuse_lib_init()
2613 conn->want |= FUSE_CAP_EXPORT_SUPPORT; in fuse_lib_init()
2614 fuse_fs_init(f->fs, conn, &f->conf); in fuse_lib_init()
2619 fuse_get_context()->private_data = fs->user_data; in fuse_fs_destroy()
2620 if (fs->op.destroy) in fuse_fs_destroy()
2621 fs->op.destroy(fs->user_data); in fuse_fs_destroy()
2629 fuse_fs_destroy(f->fs); in fuse_lib_destroy()
2645 pthread_mutex_lock(&f->lock); in fuse_lib_lookup()
2647 if (f->conf.debug) in fuse_lib_lookup()
2648 fuse_log(FUSE_LOG_DEBUG, "LOOKUP-DOT\n"); in fuse_lib_lookup()
2651 pthread_mutex_unlock(&f->lock); in fuse_lib_lookup()
2652 reply_entry(req, &e, -ESTALE); in fuse_lib_lookup()
2655 dot->refctr++; in fuse_lib_lookup()
2657 if (f->conf.debug) in fuse_lib_lookup()
2658 fuse_log(FUSE_LOG_DEBUG, "LOOKUP-DOTDOT\n"); in fuse_lib_lookup()
2659 parent = get_node(f, parent)->parent->nodeid; in fuse_lib_lookup()
2661 pthread_mutex_unlock(&f->lock); in fuse_lib_lookup()
2669 if (f->conf.debug) in fuse_lib_lookup()
2673 if (err == -ENOENT && f->conf.negative_timeout != 0.0) { in fuse_lib_lookup()
2675 e.entry_timeout = f->conf.negative_timeout; in fuse_lib_lookup()
2682 pthread_mutex_lock(&f->lock); in fuse_lib_lookup()
2684 pthread_mutex_unlock(&f->lock); in fuse_lib_lookup()
2691 if (f->conf.debug) in do_forget()
2733 err = fuse_fs_getattr(f->fs, path, &buf, fi); in fuse_lib_getattr()
2740 pthread_mutex_lock(&f->lock); in fuse_lib_getattr()
2742 if (node->is_hidden && buf.st_nlink > 0) in fuse_lib_getattr()
2743 buf.st_nlink--; in fuse_lib_getattr()
2744 if (f->conf.auto_cache) in fuse_lib_getattr()
2746 pthread_mutex_unlock(&f->lock); in fuse_lib_getattr()
2748 fuse_reply_attr(req, &buf, f->conf.attr_timeout); in fuse_lib_getattr()
2756 fuse_get_context()->private_data = fs->user_data; in fuse_fs_chmod()
2757 if (fs->op.chmod) { in fuse_fs_chmod()
2758 if (fs->debug) { in fuse_fs_chmod()
2764 return fs->op.chmod(path, mode, fi); in fuse_fs_chmod()
2767 return -ENOSYS; in fuse_fs_chmod()
2788 err = fuse_fs_chmod(f->fs, path, attr->st_mode, fi); in fuse_lib_setattr()
2791 attr->st_uid : (uid_t) -1; in fuse_lib_setattr()
2793 attr->st_gid : (gid_t) -1; in fuse_lib_setattr()
2794 err = fuse_fs_chown(f->fs, path, uid, gid, fi); in fuse_lib_setattr()
2797 err = fuse_fs_truncate(f->fs, path, in fuse_lib_setattr()
2798 attr->st_size, fi); in fuse_lib_setattr()
2813 tv[0] = attr->st_atim; in fuse_lib_setattr()
2818 tv[1] = attr->st_mtim; in fuse_lib_setattr()
2820 err = fuse_fs_utimens(f->fs, path, tv, fi); in fuse_lib_setattr()
2827 tv[0].tv_sec = attr->st_atime; in fuse_lib_setattr()
2829 tv[1].tv_sec = attr->st_mtime; in fuse_lib_setattr()
2831 err = fuse_fs_utimens(f->fs, path, tv, fi); in fuse_lib_setattr()
2834 err = fuse_fs_getattr(f->fs, path, &buf, fi); in fuse_lib_setattr()
2840 if (f->conf.auto_cache) { in fuse_lib_setattr()
2841 pthread_mutex_lock(&f->lock); in fuse_lib_setattr()
2843 pthread_mutex_unlock(&f->lock); in fuse_lib_setattr()
2846 fuse_reply_attr(req, &buf, f->conf.attr_timeout); in fuse_lib_setattr()
2862 err = fuse_fs_access(f->fs, path, mask); in fuse_lib_access()
2880 err = fuse_fs_readlink(f->fs, path, linkname, sizeof(linkname)); in fuse_lib_readlink()
2904 err = -ENOSYS; in fuse_lib_mknod()
2910 err = fuse_fs_create(f->fs, path, mode, &fi); in fuse_lib_mknod()
2914 fuse_fs_release(f->fs, path, &fi); in fuse_lib_mknod()
2917 if (err == -ENOSYS) { in fuse_lib_mknod()
2918 err = fuse_fs_mknod(f->fs, path, mode, rdev); in fuse_lib_mknod()
2942 err = fuse_fs_mkdir(f->fs, path, mode); in fuse_lib_mkdir()
2964 if (!f->conf.hard_remove && is_open(f, parent, name)) { in fuse_lib_unlink()
2968 if (!is_open(f, parent, wnode->name)) { in fuse_lib_unlink()
2972 if (try_get_path(f, wnode->nodeid, NULL, &unlinkpath, NULL, false) == 0) { in fuse_lib_unlink()
2973 err = fuse_fs_unlink(f->fs, unlinkpath); in fuse_lib_unlink()
2975 remove_node(f, parent, wnode->name); in fuse_lib_unlink()
2981 err = fuse_fs_unlink(f->fs, path); in fuse_lib_unlink()
3003 err = fuse_fs_rmdir(f->fs, path); in fuse_lib_rmdir()
3025 err = fuse_fs_symlink(f->fs, linkname, path); in fuse_lib_symlink()
3051 if (!f->conf.hard_remove && !(flags & RENAME_EXCHANGE) && in fuse_lib_rename()
3055 err = fuse_fs_rename(f->fs, oldpath, newpath, flags); in fuse_lib_rename()
3087 err = fuse_fs_link(f->fs, oldpath, newpath); in fuse_lib_link()
3103 fuse_fs_release(f->fs, path, fi); in fuse_do_release()
3105 pthread_mutex_lock(&f->lock); in fuse_do_release()
3107 assert(node->open_count > 0); in fuse_do_release()
3108 --node->open_count; in fuse_do_release()
3109 if (node->is_hidden && !node->open_count) { in fuse_do_release()
3111 node->is_hidden = 0; in fuse_do_release()
3113 pthread_mutex_unlock(&f->lock); in fuse_do_release()
3117 fuse_fs_unlink(f->fs, path); in fuse_do_release()
3118 } else if (f->conf.nullpath_ok) { in fuse_do_release()
3122 fuse_fs_unlink(f->fs, unlinkpath); in fuse_do_release()
3142 err = fuse_fs_create(f->fs, path, mode, fi); in fuse_lib_create()
3146 fuse_fs_release(f->fs, path, fi); in fuse_lib_create()
3148 err = -EIO; in fuse_lib_create()
3149 fuse_fs_release(f->fs, path, fi); in fuse_lib_create()
3152 if (f->conf.direct_io) in fuse_lib_create()
3153 fi->direct_io = 1; in fuse_lib_create()
3154 if (f->conf.kernel_cache) in fuse_lib_create()
3155 fi->keep_cache = 1; in fuse_lib_create()
3156 if (fi->direct_io && in fuse_lib_create()
3157 f->conf.parallel_direct_writes) in fuse_lib_create()
3158 fi->parallel_direct_writes = 1; in fuse_lib_create()
3164 pthread_mutex_lock(&f->lock); in fuse_lib_create()
3165 get_node(f, e.ino)->open_count++; in fuse_lib_create()
3166 pthread_mutex_unlock(&f->lock); in fuse_lib_create()
3167 if (fuse_reply_create(req, &e, fi) == -ENOENT) { in fuse_lib_create()
3183 return (t1->tv_sec - t2->tv_sec) + in diff_timespec()
3184 ((double) t1->tv_nsec - (double) t2->tv_nsec) / 1000000000.0; in diff_timespec()
3192 pthread_mutex_lock(&f->lock); in open_auto_cache()
3194 if (node->cache_valid) { in open_auto_cache()
3198 if (diff_timespec(&now, &node->stat_updated) > in open_auto_cache()
3199 f->conf.ac_attr_timeout) { in open_auto_cache()
3202 pthread_mutex_unlock(&f->lock); in open_auto_cache()
3203 err = fuse_fs_getattr(f->fs, path, &stbuf, fi); in open_auto_cache()
3204 pthread_mutex_lock(&f->lock); in open_auto_cache()
3208 node->cache_valid = 0; in open_auto_cache()
3211 if (node->cache_valid) in open_auto_cache()
3212 fi->keep_cache = 1; in open_auto_cache()
3214 node->cache_valid = 1; in open_auto_cache()
3215 pthread_mutex_unlock(&f->lock); in open_auto_cache()
3229 err = fuse_fs_open(f->fs, path, fi); in fuse_lib_open()
3231 if (f->conf.direct_io) in fuse_lib_open()
3232 fi->direct_io = 1; in fuse_lib_open()
3233 if (f->conf.kernel_cache) in fuse_lib_open()
3234 fi->keep_cache = 1; in fuse_lib_open()
3236 if (f->conf.auto_cache) in fuse_lib_open()
3239 if (f->conf.no_rofd_flush && in fuse_lib_open()
3240 (fi->flags & O_ACCMODE) == O_RDONLY) in fuse_lib_open()
3241 fi->noflush = 1; in fuse_lib_open()
3243 if (fi->direct_io && f->conf.parallel_direct_writes) in fuse_lib_open()
3244 fi->parallel_direct_writes = 1; in fuse_lib_open()
3250 pthread_mutex_lock(&f->lock); in fuse_lib_open()
3251 get_node(f, ino)->open_count++; in fuse_lib_open()
3252 pthread_mutex_unlock(&f->lock); in fuse_lib_open()
3253 if (fuse_reply_open(req, fi) == -ENOENT) { in fuse_lib_open()
3277 res = fuse_fs_read_buf(f->fs, path, &buf, size, off, fi); in fuse_lib_read()
3303 res = fuse_fs_write_buf(f->fs, path, buf, off, fi); in fuse_lib_write_buf()
3326 err = fuse_fs_fsync(f->fs, path, datasync, fi); in fuse_lib_fsync()
3336 struct fuse_dh *dh = (struct fuse_dh *) (uintptr_t) llfi->fh; in get_dirhandle()
3338 fi->fh = dh->fh; in get_dirhandle()
3354 reply_err(req, -ENOMEM); in fuse_lib_opendir()
3358 dh->fuse = f; in fuse_lib_opendir()
3359 dh->contents = NULL; in fuse_lib_opendir()
3360 dh->first = NULL; in fuse_lib_opendir()
3361 dh->len = 0; in fuse_lib_opendir()
3362 dh->filled = 0; in fuse_lib_opendir()
3363 dh->nodeid = ino; in fuse_lib_opendir()
3364 pthread_mutex_init(&dh->lock, NULL); in fuse_lib_opendir()
3366 llfi->fh = (uintptr_t) dh; in fuse_lib_opendir()
3369 fi.flags = llfi->flags; in fuse_lib_opendir()
3374 err = fuse_fs_opendir(f->fs, path, &fi); in fuse_lib_opendir()
3376 dh->fh = fi.fh; in fuse_lib_opendir()
3377 llfi->cache_readdir = fi.cache_readdir; in fuse_lib_opendir()
3378 llfi->keep_cache = fi.keep_cache; in fuse_lib_opendir()
3381 if (fuse_reply_open(req, llfi) == -ENOENT) { in fuse_lib_opendir()
3384 fuse_fs_releasedir(f->fs, path, &fi); in fuse_lib_opendir()
3385 pthread_mutex_destroy(&dh->lock); in fuse_lib_opendir()
3390 pthread_mutex_destroy(&dh->lock); in fuse_lib_opendir()
3398 if (minsize > dh->size) { in extend_contents()
3400 unsigned newsize = dh->size; in extend_contents()
3410 newptr = (char *) realloc(dh->contents, newsize); in extend_contents()
3412 dh->error = -ENOMEM; in extend_contents()
3413 return -1; in extend_contents()
3415 dh->contents = newptr; in extend_contents()
3416 dh->size = newsize; in extend_contents()
3428 dh->error = -ENOMEM; in fuse_add_direntry_to_dh()
3429 return -1; in fuse_add_direntry_to_dh()
3431 de->name = strdup(name); in fuse_add_direntry_to_dh()
3432 if (!de->name) { in fuse_add_direntry_to_dh()
3433 dh->error = -ENOMEM; in fuse_add_direntry_to_dh()
3435 return -1; in fuse_add_direntry_to_dh()
3437 de->stat = *st; in fuse_add_direntry_to_dh()
3438 de->next = NULL; in fuse_add_direntry_to_dh()
3440 *dh->last = de; in fuse_add_direntry_to_dh()
3441 dh->last = &de->next; in fuse_add_direntry_to_dh()
3452 pthread_mutex_lock(&f->lock); in lookup_nodeid()
3455 res = node->nodeid; in lookup_nodeid()
3456 pthread_mutex_unlock(&f->lock); in lookup_nodeid()
3468 dh->error = -EIO; in fill_dir()
3479 if (!dh->fuse->conf.use_ino) { in fill_dir()
3481 if (dh->fuse->conf.readdir_ino) { in fill_dir()
3483 lookup_nodeid(dh->fuse, dh->nodeid, name); in fill_dir()
3490 if (dh->filled) { in fill_dir()
3491 dh->error = -EIO; in fill_dir()
3495 if (dh->first) { in fill_dir()
3496 dh->error = -EIO; in fill_dir()
3500 if (extend_contents(dh, dh->needlen) == -1) in fill_dir()
3503 newlen = dh->len + in fill_dir()
3504 fuse_add_direntry(dh->req, dh->contents + dh->len, in fill_dir()
3505 dh->needlen - dh->len, name, in fill_dir()
3507 if (newlen > dh->needlen) in fill_dir()
3510 dh->len = newlen; in fill_dir()
3512 dh->filled = 1; in fill_dir()
3514 if (fuse_add_direntry_to_dh(dh, name, &stbuf) == -1) in fill_dir()
3534 struct fuse *f = dh->fuse; in fill_dir_plus()
3538 dh->error = -EIO; in fill_dir_plus()
3547 e.attr.st_mode = statp->st_mode; in fill_dir_plus()
3548 if (f->conf.use_ino) in fill_dir_plus()
3549 e.attr.st_ino = statp->st_ino; in fill_dir_plus()
3551 if (!f->conf.use_ino && f->conf.readdir_ino) { in fill_dir_plus()
3553 lookup_nodeid(f, dh->nodeid, name); in fill_dir_plus()
3560 if (dh->filled) { in fill_dir_plus()
3561 dh->error = -EIO; in fill_dir_plus()
3565 if (dh->first) { in fill_dir_plus()
3566 dh->error = -EIO; in fill_dir_plus()
3569 if (extend_contents(dh, dh->needlen) == -1) in fill_dir_plus()
3574 res = do_lookup(f, dh->nodeid, name, &e); in fill_dir_plus()
3576 dh->error = res; in fill_dir_plus()
3582 newlen = dh->len + in fill_dir_plus()
3583 fuse_add_direntry_plus(dh->req, dh->contents + dh->len, in fill_dir_plus()
3584 dh->needlen - dh->len, name, in fill_dir_plus()
3586 if (newlen > dh->needlen) in fill_dir_plus()
3588 dh->len = newlen; in fill_dir_plus()
3590 dh->filled = 1; in fill_dir_plus()
3592 if (fuse_add_direntry_to_dh(dh, name, &e.attr) == -1) in fill_dir_plus()
3602 struct fuse_direntry *next = de->next; in free_direntries()
3603 free(de->name); in free_direntries()
3617 if (f->fs->op.readdir) in readdir_fill()
3628 free_direntries(dh->first); in readdir_fill()
3629 dh->first = NULL; in readdir_fill()
3630 dh->last = &dh->first; in readdir_fill()
3631 dh->len = 0; in readdir_fill()
3632 dh->error = 0; in readdir_fill()
3633 dh->needlen = size; in readdir_fill()
3634 dh->filled = 0; in readdir_fill()
3635 dh->req = req; in readdir_fill()
3637 err = fuse_fs_readdir(f->fs, path, dh, filler, off, fi, flags); in readdir_fill()
3639 dh->req = NULL; in readdir_fill()
3641 err = dh->error; in readdir_fill()
3643 dh->filled = 0; in readdir_fill()
3653 struct fuse_direntry *de = dh->first; in readdir_fill_from_list()
3656 dh->len = 0; in readdir_fill_from_list()
3658 if (extend_contents(dh, dh->needlen) == -1) in readdir_fill_from_list()
3659 return dh->error; in readdir_fill_from_list()
3665 de = de->next; in readdir_fill_from_list()
3668 char *p = dh->contents + dh->len; in readdir_fill_from_list()
3669 unsigned rem = dh->needlen - dh->len; in readdir_fill_from_list()
3677 .attr = de->stat, in readdir_fill_from_list()
3680 if (!is_dot_or_dotdot(de->name)) { in readdir_fill_from_list()
3681 res = do_lookup(dh->fuse, dh->nodeid, in readdir_fill_from_list()
3682 de->name, &e); in readdir_fill_from_list()
3684 dh->error = res; in readdir_fill_from_list()
3690 de->name, &e, pos); in readdir_fill_from_list()
3693 de->name, &de->stat, pos); in readdir_fill_from_list()
3695 newlen = dh->len + thislen; in readdir_fill_from_list()
3696 if (newlen > dh->needlen) in readdir_fill_from_list()
3698 dh->len = newlen; in readdir_fill_from_list()
3699 de = de->next; in readdir_fill_from_list()
3713 pthread_mutex_lock(&dh->lock); in fuse_readdir_common()
3717 dh->filled = 0; in fuse_readdir_common()
3719 if (!dh->filled) { in fuse_readdir_common()
3726 if (dh->filled) { in fuse_readdir_common()
3727 dh->needlen = size; in fuse_readdir_common()
3734 fuse_reply_buf(req, dh->contents, dh->len); in fuse_readdir_common()
3736 pthread_mutex_unlock(&dh->lock); in fuse_readdir_common()
3763 fuse_fs_releasedir(f->fs, path, &fi); in fuse_lib_releasedir()
3767 pthread_mutex_lock(&dh->lock); in fuse_lib_releasedir()
3768 pthread_mutex_unlock(&dh->lock); in fuse_lib_releasedir()
3769 pthread_mutex_destroy(&dh->lock); in fuse_lib_releasedir()
3770 free_direntries(dh->first); in fuse_lib_releasedir()
3771 free(dh->contents); in fuse_lib_releasedir()
3790 err = fuse_fs_fsyncdir(f->fs, path, datasync, &fi); in fuse_lib_fsyncdir()
3811 err = fuse_fs_statfs(f->fs, path ? path : "/", &buf); in fuse_lib_statfs()
3833 err = fuse_fs_setxattr(f->fs, path, name, value, size, flags); in fuse_lib_setxattr()
3850 err = fuse_fs_getxattr(f->fs, path, name, value, size); in common_getxattr()
3866 reply_err(req, -ENOMEM); in fuse_lib_getxattr()
3894 err = fuse_fs_listxattr(f->fs, path, list, size); in common_listxattr()
3909 reply_err(req, -ENOMEM); in fuse_lib_listxattr()
3938 err = fuse_fs_removexattr(f->fs, path, name); in fuse_lib_removexattr()
3949 for (l = node->locks; l; l = l->next) in locks_conflict()
3950 if (l->owner != lock->owner && in locks_conflict()
3951 lock->start <= l->end && l->start <= lock->end && in locks_conflict()
3952 (l->type == F_WRLCK || lock->type == F_WRLCK)) in locks_conflict()
3961 *lockp = l->next; in delete_lock()
3967 lock->next = *pos; in insert_lock()
3977 if (lock->type != F_UNLCK || lock->start != 0 || in locks_insert()
3978 lock->end != OFFSET_MAX) { in locks_insert()
3985 return -ENOLCK; in locks_insert()
3989 for (lp = &node->locks; *lp;) { in locks_insert()
3991 if (l->owner != lock->owner) in locks_insert()
3994 if (lock->type == l->type) { in locks_insert()
3995 if (l->end < lock->start - 1) in locks_insert()
3997 if (lock->end < l->start - 1) in locks_insert()
3999 if (l->start <= lock->start && lock->end <= l->end) in locks_insert()
4001 if (l->start < lock->start) in locks_insert()
4002 lock->start = l->start; in locks_insert()
4003 if (lock->end < l->end) in locks_insert()
4004 lock->end = l->end; in locks_insert()
4007 if (l->end < lock->start) in locks_insert()
4009 if (lock->end < l->start) in locks_insert()
4011 if (lock->start <= l->start && l->end <= lock->end) in locks_insert()
4013 if (l->end <= lock->end) { in locks_insert()
4014 l->end = lock->start - 1; in locks_insert()
4017 if (lock->start <= l->start) { in locks_insert()
4018 l->start = lock->end + 1; in locks_insert()
4022 newl2->start = lock->end + 1; in locks_insert()
4023 l->end = lock->start - 1; in locks_insert()
4024 insert_lock(&l->next, newl2); in locks_insert()
4028 lp = &l->next; in locks_insert()
4034 if (lock->type != F_UNLCK) { in locks_insert()
4048 lock->type = flock->l_type; in flock_to_lock()
4049 lock->start = flock->l_start; in flock_to_lock()
4050 lock->end = in flock_to_lock()
4051 flock->l_len ? flock->l_start + flock->l_len - 1 : OFFSET_MAX; in flock_to_lock()
4052 lock->pid = flock->l_pid; in flock_to_lock()
4057 flock->l_type = lock->type; in lock_to_flock()
4058 flock->l_start = lock->start; in lock_to_flock()
4059 flock->l_len = in lock_to_flock()
4060 (lock->end == OFFSET_MAX) ? 0 : lock->end - lock->start + 1; in lock_to_flock()
4061 flock->l_pid = lock->pid; in lock_to_flock()
4077 err = fuse_fs_flush(f->fs, path, fi); in fuse_flush_common()
4078 errlock = fuse_fs_lock(f->fs, path, fi, F_SETLK, &lock); in fuse_flush_common()
4081 if (errlock != -ENOSYS) { in fuse_flush_common()
4083 l.owner = fi->lock_owner; in fuse_flush_common()
4084 pthread_mutex_lock(&f->lock); in fuse_flush_common()
4086 pthread_mutex_unlock(&f->lock); in fuse_flush_common()
4090 if (err == -ENOSYS) in fuse_flush_common()
4105 if (fi->flush) { in fuse_lib_release()
4107 if (err == -ENOSYS) in fuse_lib_release()
4145 err = fuse_fs_lock(f->fs, path, fi, cmd, lock); in fuse_lock_common()
4161 l.owner = fi->lock_owner; in fuse_lib_getlk()
4162 pthread_mutex_lock(&f->lock); in fuse_lib_getlk()
4166 pthread_mutex_unlock(&f->lock); in fuse_lib_getlk()
4188 l.owner = fi->lock_owner; in fuse_lib_setlk()
4189 pthread_mutex_lock(&f->lock); in fuse_lib_setlk()
4191 pthread_mutex_unlock(&f->lock); in fuse_lib_setlk()
4207 err = fuse_fs_flock(f->fs, path, fi, op); in fuse_lib_flock()
4225 err = fuse_fs_bmap(f->fs, path, blocksize, &idx); in fuse_lib_bmap()
4246 err = -EPERM; in fuse_lib_ioctl()
4256 err = -ENOMEM; in fuse_lib_ioctl()
4272 err = fuse_fs_ioctl(f->fs, path, cmd, arg, &fi, flags, in fuse_lib_ioctl()
4300 err = fuse_fs_poll(f->fs, path, fi, ph, &revents); in fuse_lib_poll()
4321 err = fuse_fs_fallocate(f->fs, path, mode, offset, length, fi); in fuse_lib_fallocate()
4354 res = fuse_fs_copy_file_range(f->fs, path_in, fi_in, off_in, path_out, in fuse_lib_copy_file_range()
4383 res = fuse_fs_lseek(f->fs, path, off, whence, fi); in fuse_lib_lseek()
4401 int sleep_time = f->conf.remember / 10; in clean_delay()
4417 pthread_mutex_lock(&f->lock); in fuse_clean_cache()
4421 for (curr = f->lru_table.next; curr != &f->lru_table; curr = next) { in fuse_clean_cache()
4424 next = curr->next; in fuse_clean_cache()
4426 node = &lnode->node; in fuse_clean_cache()
4428 age = diff_timespec(&now, &lnode->forget_time); in fuse_clean_cache()
4429 if (age <= f->conf.remember) in fuse_clean_cache()
4432 assert(node->nlookup == 1); in fuse_clean_cache()
4435 if (node->refctr > 1) in fuse_clean_cache()
4438 node->nlookup = 0; in fuse_clean_cache()
4442 pthread_mutex_unlock(&f->lock); in fuse_clean_cache()
4499 return f->se; in fuse_get_session()
4504 struct fuse_session *se = f->se; in fuse_session_loop_remember()
4509 .fd = se->fd, in fuse_session_loop_remember()
4523 timeout = next_clean - now.tv_sec; in fuse_session_loop_remember()
4528 if (res == -1) { in fuse_session_loop_remember()
4536 if (res == -EINTR) in fuse_session_loop_remember()
4551 return res < 0 ? -1 : 0; in fuse_session_loop_remember()
4557 return -1; in fuse_loop()
4562 return fuse_session_loop(f->se); in fuse_loop()
4569 return -1; in fuse_loop_mt_312()
4573 return -1; in fuse_loop_mt_312()
4618 fuse_session_exit(f->se); in fuse_exit()
4626 return &c->ctx; in fuse_get_context()
4635 return -EINVAL; in fuse_getgroups()
4637 return fuse_req_getgroups(c->req, size, list); in fuse_getgroups()
4645 return fuse_req_interrupted(c->req); in fuse_interrupted()
4657 return fuse_lowlevel_notify_inval_inode(f->se, ino, 0, 0); in fuse_invalidate_path()
4664 FUSE_OPT_KEY("-d", FUSE_OPT_KEY_KEEP),
4666 FUSE_LIB_OPT("-d", debug, 1),
4682 FUSE_LIB_OPT("noforget", remember, -1),
4709 if (fuse_opt_add_arg(&a, "") == -1 || in print_module_help()
4710 fuse_opt_add_arg(&a, "-h") == -1) in print_module_help()
4720 may be of interest to an end-user */ in fuse_lib_help()
4722 " -o kernel_cache cache files in kernel\n" in fuse_lib_help()
4723 " -o [no]auto_cache enable caching based on modification times (off)\n" in fuse_lib_help()
4724 " -o no_rofd_flush disable flushing of read-only fd on close (off)\n" in fuse_lib_help()
4725 " -o umask=M set file permissions (octal)\n" in fuse_lib_help()
4726 " -o uid=N set file owner\n" in fuse_lib_help()
4727 " -o gid=N set file group\n" in fuse_lib_help()
4728 " -o entry_timeout=T cache timeout for names (1.0s)\n" in fuse_lib_help()
4729 " -o negative_timeout=T cache timeout for deleted names (0.0s)\n" in fuse_lib_help()
4730 " -o attr_timeout=T cache timeout for attributes (1.0s)\n" in fuse_lib_help()
4731 " -o ac_attr_timeout=T auto cache timeout for attributes (attr_timeout)\n" in fuse_lib_help()
4732 " -o noforget never forget cached inodes\n" in fuse_lib_help()
4733 " -o remember=T remember cached inodes for T seconds (0s)\n" in fuse_lib_help()
4734 " -o modules=M1[:M2...] names of modules to push onto filesystem stack\n"); in fuse_lib_help()
4737 /* Print low-level help */ in fuse_lib_help()
4750 fuse_lib_opt_proc) == -1 in fuse_lib_help()
4767 print_module_help(module, &m->factory); in fuse_lib_help()
4777 if (sigaction(signum, NULL, &old_sa) == -1) { in fuse_init_intr_signal()
4779 return -1; in fuse_init_intr_signal()
4789 if (sigaction(signum, &sa, NULL) == -1) { in fuse_init_intr_signal()
4791 return -1; in fuse_init_intr_signal()
4811 struct fuse_fs *fs[2] = { f->fs, NULL }; in fuse_push_module()
4816 return -1; in fuse_push_module()
4818 newfs = m->factory(args, fs); in fuse_push_module()
4821 return -1; in fuse_push_module()
4823 f->fs = newfs; in fuse_push_module()
4843 fs->user_data = user_data; in fuse_fs_new()
4845 memcpy(&fs->op, op, op_size); in fuse_fs_new()
4851 t->size = NODE_TABLE_MIN_SIZE; in node_table_init()
4852 t->array = (struct node **) calloc(1, sizeof(struct node *) * t->size); in node_table_init()
4853 if (t->array == NULL) { in node_table_init()
4855 return -1; in node_table_init()
4857 t->use = 0; in node_table_init()
4858 t->split = 0; in node_table_init()
4878 return fuse_start_thread(&f->prune_thread, fuse_prune_nodes, f); in fuse_start_cleanup_thread()
4886 pthread_mutex_lock(&f->lock); in fuse_stop_cleanup_thread()
4887 pthread_cancel(f->prune_thread); in fuse_stop_cleanup_thread()
4888 pthread_mutex_unlock(&f->lock); in fuse_stop_cleanup_thread()
4889 pthread_join(f->prune_thread, NULL); in fuse_stop_cleanup_thread()
4918 f->conf.entry_timeout = 1.0; in _fuse_new_317()
4919 f->conf.attr_timeout = 1.0; in _fuse_new_317()
4920 f->conf.negative_timeout = 0.0; in _fuse_new_317()
4921 f->conf.intr_signal = FUSE_DEFAULT_INTR_SIGNAL; in _fuse_new_317()
4924 if (fuse_opt_parse(args, &f->conf, fuse_lib_opts, in _fuse_new_317()
4925 fuse_lib_opt_proc) == -1) in _fuse_new_317()
4941 if (fuse_create_context_key() == -1) in _fuse_new_317()
4948 f->fs = fs; in _fuse_new_317()
4951 if (!fs->op.lock) { in _fuse_new_317()
4956 f->pagesize = getpagesize(); in _fuse_new_317()
4957 init_list_head(&f->partial_slabs); in _fuse_new_317()
4958 init_list_head(&f->full_slabs); in _fuse_new_317()
4959 init_list_head(&f->lru_table); in _fuse_new_317()
4961 if (f->conf.modules) { in _fuse_new_317()
4965 for (module = f->conf.modules; module; module = next) { in _fuse_new_317()
4971 fuse_push_module(f, module, args) == -1) in _fuse_new_317()
4976 if (!f->conf.ac_attr_timeout_set) in _fuse_new_317()
4977 f->conf.ac_attr_timeout = f->conf.attr_timeout; in _fuse_new_317()
4984 f->conf.readdir_ino = 1; in _fuse_new_317()
4987 f->se = _fuse_session_new(args, &llop, sizeof(llop), version, f); in _fuse_new_317()
4988 if (f->se == NULL) in _fuse_new_317()
4991 if (f->conf.debug) { in _fuse_new_317()
4992 fuse_log(FUSE_LOG_DEBUG, "nullpath_ok: %i\n", f->conf.nullpath_ok); in _fuse_new_317()
4996 f->fs->debug = f->conf.debug; in _fuse_new_317()
4997 f->ctr = 0; in _fuse_new_317()
4998 f->generation = 0; in _fuse_new_317()
4999 if (node_table_init(&f->name_table) == -1) in _fuse_new_317()
5002 if (node_table_init(&f->id_table) == -1) in _fuse_new_317()
5005 pthread_mutex_init(&f->lock, NULL); in _fuse_new_317()
5014 init_list_head(&lnode->lru); in _fuse_new_317()
5017 strcpy(root->inline_name, "/"); in _fuse_new_317()
5018 root->name = root->inline_name; in _fuse_new_317()
5020 if (f->conf.intr && in _fuse_new_317()
5021 fuse_init_intr_signal(f->conf.intr_signal, in _fuse_new_317()
5022 &f->intr_installed) == -1) in _fuse_new_317()
5025 root->parent = NULL; in _fuse_new_317()
5026 root->nodeid = FUSE_ROOT_ID; in _fuse_new_317()
5035 free(f->id_table.array); in _fuse_new_317()
5037 free(f->name_table.array); in _fuse_new_317()
5039 fuse_session_destroy(f->se); in _fuse_new_317()
5041 free(f->fs); in _fuse_new_317()
5042 free(f->conf.modules); in _fuse_new_317()
5051 /* Emulates 3.0-style fuse_new(), which processes --help */
5066 FUSE_LIB_OPT("-h", show_help, 1), in _fuse_new_30()
5067 FUSE_LIB_OPT("--help", show_help, 1), in _fuse_new_30()
5072 fuse_lib_opt_proc) == -1) in _fuse_new_30()
5098 * Emulates 3.0-style fuse_new(), which processes --help
5110 FUSE_LIB_OPT("-h", show_help, 1), in fuse_new_30()
5111 FUSE_LIB_OPT("--help", show_help, 1), in fuse_new_30()
5116 fuse_lib_opt_proc) == -1) in fuse_new_30()
5131 if (f->conf.intr && f->intr_installed) in fuse_destroy()
5132 fuse_restore_intr_signal(f->conf.intr_signal); in fuse_destroy()
5134 if (f->fs) { in fuse_destroy()
5137 for (i = 0; i < f->id_table.size; i++) { in fuse_destroy()
5140 for (node = f->id_table.array[i]; node != NULL; in fuse_destroy()
5141 node = node->id_next) { in fuse_destroy()
5142 if (node->is_hidden) { in fuse_destroy()
5144 if (try_get_path(f, node->nodeid, NULL, &path, NULL, false) == 0) { in fuse_destroy()
5145 fuse_fs_unlink(f->fs, path); in fuse_destroy()
5152 for (i = 0; i < f->id_table.size; i++) { in fuse_destroy()
5156 for (node = f->id_table.array[i]; node != NULL; node = next) { in fuse_destroy()
5157 next = node->id_next; in fuse_destroy()
5159 f->id_table.use--; in fuse_destroy()
5162 assert(list_empty(&f->partial_slabs)); in fuse_destroy()
5163 assert(list_empty(&f->full_slabs)); in fuse_destroy()
5168 free(f->id_table.array); in fuse_destroy()
5169 free(f->name_table.array); in fuse_destroy()
5170 pthread_mutex_destroy(&f->lock); in fuse_destroy()
5171 fuse_session_destroy(f->se); in fuse_destroy()
5172 free(f->fs); in fuse_destroy()
5173 free(f->conf.modules); in fuse_destroy()