Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
int
new_nnpfs_node(struct nnpfs *nnpfsp,
	     struct nnpfs_msg_node *node,
	     struct nnpfs_node **xpp,
	     d_thread_t *p)
{
    struct nnpfs_node *result;

    NNPFSDEB(XDEBNODE, ("new_nnpfs_node (%d,%d,%d,%d)\n",
		      node->handle.a,
		      node->handle.b,
		      node->handle.c,
		      node->handle.d));

retry:
    /* Does not allow duplicates */
    result = nnpfs_node_find(&nnpfsp->nodehead, &node->handle);
    if (result == 0) {
	int error;
	struct vnode *v;

	error = nnpfs_getnewvnode(nnpfsp, &v, &node->handle);
	if (error)
	    return error;

	result = VNODE_TO_XNODE(v);
	result->anonrights = node->anonrights;

	nnpfsp->nnodes++;
    } else {
	/* Node is already cached */
	if(nnpfs_do_vget(XNODE_TO_VNODE(result), 0, p))
	    goto retry;
    }

    /* Init other fields */
    nnpfs_attr2vattr(&node->attr, &result->attr, 1);
    result->vn->v_type = result->attr.va_type;
    result->tokens = node->tokens;
    bcopy(node->id, result->id, sizeof(result->id));
    bcopy(node->rights, result->rights, sizeof(result->rights));

#ifdef __APPLE__
    if (result->vn->v_type == VREG && (!UBCINFOEXISTS(result->vn)))
	ubc_info_init(result->vn);
#endif

    *xpp = result;
    NNPFSDEB(XDEBNODE, ("return: new_nnpfs_node\n"));
    return 0;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
static int
common_fhtovp(struct mount * mp,
	   struct fid * fhp,
	   struct vnode ** vpp)
{
#ifdef ARLA_KNFS
    struct netcred *np = NULL;
    struct nnpfs_node *xn;
    struct vnode *vp;
    nnpfs_handle handle;
    int error;

    NNPFSDEB(XDEBVFOPS, ("nnpfs_fhtovp\n"));

    if (fhp->fid_len != 16) {
	printf("nnpfs_fhtovp: *PANIC* got a invalid length of a fid\n");
	return EINVAL;
    }

    memcpy(&handle, fhp->fid_data, sizeof(handle));
    NNPFSDEB(XDEBVFOPS, ("nnpfs_fhtovp: fid: %d.%d.%d.%d\n", 
		       handle.a, handle.d, handle.c, handle.d));

    NNPFSDEB(XDEBVFOPS, ("nnpfs_fhtovp: nnpfs_vnode_find\n"));
    xn = nnpfs_node_find(&nnpfs[0].nodehead, &handle);

    if (xn == NULL) {
	struct nnpfs_message_getattr msg;

        error = nnpfs_getnewvnode(nnpfs[0].mp, &vp, &handle);
        if (error)
            return error;
	
	nnpfs_do_vget(vp, 0, curproc);

    } else {
	/* XXX access ? */
	vp = XNODE_TO_VNODE(xn);

	/* XXX wrong ? (we tell arla below) */
        if (vp->v_usecount <= 0) 
	    nnpfs_do_vget(vp, 0, curproc);
	else
	    vref(vp);
	error = 0;
    }

    *vpp = vp;

    if (error == 0) {
	NNPFSDEB(XDEBVFOPS, ("nnpfs_fhtovp done\n"));

	/* 
	 * XXX tell arla about this node is hold by nfsd.
	 * There need to be code in nnpfs_write too.
	 */
    } else
	NNPFSDEB(XDEBVFOPS, ("nnpfs_fhtovp failed (%d)\n", error));

    return error;
#else /* !ARLA_KNFS */
    return EOPNOTSUPP;
#endif /* !ARLA_KNFS */
}