int xfs_vptofh(struct vnode * vp, struct fid * fhp) { #ifdef ARLA_KNFS struct xfs_node *xn; NNPFSDEB(XDEBVFOPS, ("xfs_vptofh\n")); if (MAXFIDSZ < 16) return EOPNOTSUPP; xn = VNODE_TO_XNODE(vp); if (xn == NULL) return EINVAL; fhp->fid_len = 16; memcpy(fhp->fid_data, &xn->handle, 16); return 0; #else NNPFSDEB(XDEBVFOPS, ("xfs_vptofh\n")); return EOPNOTSUPP; #endif }
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; }
int xfs_filestat(struct vnode *vp, struct filestat *fsp) { struct xfs_node xfs_node; if (!KVM_READ(VNODE_TO_XNODE(vp), &xfs_node, sizeof (xfs_node))) { dprintf("can't read xfs_node at %p for pid %ld", VTOI(vp), (long)Pid); return 0; } fsp->fsid = xfs_node.attr.va_fsid; fsp->fileid = (long)xfs_node.attr.va_fileid; fsp->mode = xfs_node.attr.va_mode; fsp->size = xfs_node.attr.va_size; fsp->rdev = xfs_node.attr.va_rdev; return 1; }
static int remote_pioctl (d_thread_t *p, struct sys_pioctl_args *arg, struct ViceIoctl *vice_ioctl, struct vnode *vp) { int error = 0; struct nnpfs_message_pioctl *msg = NULL; struct nnpfs_message_wakeup_data *msg2; msg = malloc(sizeof(*msg), M_TEMP, M_WAITOK | M_CANFAIL | M_ZERO); if (msg == NULL) { error = ENOMEM; goto done; } if (vp != NULL) { struct nnpfs_node *xn; if (vp->v_tag != VT_NNPFS) { NNPFSDEB(XDEBSYS, ("nnpfs_syscall: file is not in afs\n")); vrele(vp); error = EINVAL; goto done; } xn = VNODE_TO_XNODE(vp); msg->handle = xn->handle; vrele(vp); } if (vice_ioctl->in_size < 0) { printf("nnpfs: remote pioctl: got a negative data size: opcode: %d", SCARG(arg, a_opcode)); error = EINVAL; goto done; } if (vice_ioctl->in_size > NNPFS_MSG_MAX_DATASIZE) { printf("nnpfs_pioctl_call: got a humongous in packet: opcode: %d", SCARG(arg, a_opcode)); error = EINVAL; goto done; } if (vice_ioctl->in_size != 0) { error = copyin(vice_ioctl->in, msg->msg, vice_ioctl->in_size); if (error) goto done; } msg->header.opcode = NNPFS_MSG_PIOCTL; msg->header.size = sizeof(*msg); msg->opcode = SCARG(arg, a_opcode); msg->insize = vice_ioctl->in_size; msg->outsize = vice_ioctl->out_size; #ifdef HAVE_FREEBSD_THREAD msg->cred.uid = nnpfs_thread_to_euid(p); msg->cred.pag = nnpfs_get_pag(nnpfs_thread_to_cred(p)); #else msg->cred.uid = nnpfs_proc_to_euid(p); msg->cred.pag = nnpfs_get_pag(nnpfs_proc_to_cred(p)); #endif error = nnpfs_message_rpc(0, &(msg->header), sizeof(*msg), p); /* XXX */ msg2 = (struct nnpfs_message_wakeup_data *) msg; if (error == 0) error = msg2->error; if (error == ENODEV) error = EINVAL; if (error == 0 && msg2->header.opcode == NNPFS_MSG_WAKEUP_DATA) { int len; len = msg2->len; if (len > vice_ioctl->out_size) len = vice_ioctl->out_size; if (len > NNPFS_MSG_MAX_DATASIZE) len = NNPFS_MSG_MAX_DATASIZE; if (len < 0) len = 0; error = copyout(msg2->msg, vice_ioctl->out, len); } done: if (msg != NULL) free(msg, M_TEMP); return error; }