Author: oshogbo Date: Thu Sep 22 11:54:20 2016 New Revision: 306184 URL: https://svnweb.freebsd.org/changeset/base/306184
Log: fd: simplify fgetvp_rights by using fget_cap_locked Reviewed by: mjg Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Thu Sep 22 10:58:19 2016 (r306183) +++ head/sys/kern/kern_descrip.c Thu Sep 22 11:54:20 2016 (r306184) @@ -2781,30 +2781,31 @@ fgetvp_rights(struct thread *td, int fd, struct filecaps *havecaps, struct vnode **vpp) { struct filedesc *fdp; + struct filecaps caps; struct file *fp; -#ifdef CAPABILITIES int error; -#endif fdp = td->td_proc->p_fd; - fp = fget_locked(fdp, fd); - if (fp == NULL || fp->f_ops == &badfileops) - return (EBADF); - -#ifdef CAPABILITIES - error = cap_check(cap_rights(fdp, fd), needrightsp); + error = fget_cap_locked(fdp, fd, needrightsp, &fp, &caps); if (error != 0) return (error); -#endif - - if (fp->f_vnode == NULL) - return (EINVAL); + if (fp->f_ops == &badfileops) { + error = EBADF; + goto out; + } + if (fp->f_vnode == NULL) { + error = EINVAL; + goto out; + } + *havecaps = caps; *vpp = fp->f_vnode; vref(*vpp); - filecaps_copy(&fdp->fd_ofiles[fd].fde_caps, havecaps, true); return (0); +out: + filecaps_free(&caps); + return (error); } int _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"