/* * Extract the information needed by the nlm from the nfs vnode. */ static void nfs_getnlminfo(struct vnode *vp, uint8_t *fhp, size_t *fhlenp, struct sockaddr_storage *sp, int *is_v3p, off_t *sizep, struct timeval *timeop) { struct nfsmount *nmp; struct nfsnode *np = VTONFS(vp); nmp = VFSTONFS(vp->v_mount); if (fhlenp != NULL) *fhlenp = (size_t)np->n_fhsize; if (fhp != NULL) bcopy(np->n_fhp, fhp, np->n_fhsize); if (sp != NULL) bcopy(nmp->nm_nam, sp, min(nmp->nm_nam->sa_len, sizeof(*sp))); if (is_v3p != NULL) *is_v3p = NFS_ISV3(vp); if (sizep != NULL) *sizep = np->n_size; if (timeop != NULL) { timeop->tv_sec = nmp->nm_timeo / NFS_HZ; timeop->tv_usec = (nmp->nm_timeo % NFS_HZ) * (1000000 / NFS_HZ); } }
* if there is no nfsowner table yet, allocate one. */ if (p->p_nlminfo == NULL) { MALLOC(p->p_nlminfo, struct nlminfo *, sizeof(struct nlminfo), M_LOCKF, M_WAITOK | M_ZERO); p->p_nlminfo->pid_start = p->p_stats->p_start; } msg.lm_msg_ident.pid_start = p->p_nlminfo->pid_start; msg.lm_msg_ident.msg_seq = ++(p->p_nlminfo->msg_seq); msg.lm_fl = *fl; msg.lm_wait = ap->a_flags & F_WAIT; msg.lm_getlk = ap->a_op == F_GETLK; bcopy(VFSTONFS(vp->v_mount)->nm_nam, &msg.lm_addr, min(sizeof msg.lm_addr, VFSTONFS(vp->v_mount)->nm_nam->sa_len)); msg.lm_fh_len = NFS_ISV3(vp) ? VTONFS(vp)->n_fhsize : NFSX_V2FH; bcopy(VTONFS(vp)->n_fhp, msg.lm_fh, msg.lm_fh_len); msg.lm_nfsv3 = NFS_ISV3(vp); cru2x(td->td_ucred, &msg.lm_cred); /* * Open the lock fifo. If for any reason we don't find the fifo, it * means that the lock daemon isn't running. Translate any missing * file error message for the user, otherwise the application will * complain that the user's file is missing, which isn't the case. * Note that we use proc0's cred, so the fifo is opened as root. * * XXX: Note that this behavior is relative to the root directory * of the current process, and this may result in a variety of * {functional, security} problems in chroot() environments. */