int nnpfs_getnewvnode(struct nnpfs *nnpfsp, struct vnode **vpp, struct nnpfs_handle *handle) { struct nnpfs_node *result, *check; int error; error = getnewvnode(VT_NNPFS, NNPFS_TO_VFS(nnpfsp), &nnpfs_vops, vpp); if (error) return error; result = nnpfs_alloc(sizeof(*result), M_NNPFS_NODE); bzero(result, sizeof(*result)); (*vpp)->v_data = result; result->vn = *vpp; result->handle = *handle; result->flags = 0; result->tokens = 0; result->offset = 0; #if defined(HAVE_KERNEL_LOCKMGR) || defined(HAVE_KERNEL_DEBUGLOCKMGR) lockinit (&result->lock, PVFS, "nnpfs_lock", 0, LK_NOPAUSE); #else result->vnlocks = 0; #endif result->anonrights = 0; result->rd_cred = NULL; result->wr_cred = NULL; #if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 105280000 genfs_node_init(*vpp, &nnpfs_genfsops); #endif check = nnpfs_node_find(&nnpfsp->nodehead, handle); if (check) { vput(*vpp); *vpp = result->vn; return 0; } nnpfs_insert(&nnpfs->nodehead, result); return 0; }
int nnpfs_update_handle(struct nnpfs_nodelist_head *head, nnpfs_handle *old_handlep, nnpfs_handle *new_handlep) { struct nnpfs_node *node; node = nnpfs_node_find(head, new_handlep); if (node) return EEXIST; node = nnpfs_node_find(head, old_handlep); if (node == NULL) return ENOENT; nnpfs_remove_node(head, node); node->handle = *new_handlep; nnpfs_insert(head, node); return 0; }