예제 #1
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;
}
예제 #2
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 */
}