fd: simplify fgetvp_rights by using fget_cap_locked
Reviewed by: mjg
This commit is contained in:
parent
85b0f9de11
commit
6490bc6529
@ -2781,30 +2781,31 @@ fgetvp_rights(struct thread *td, int fd, cap_rights_t *needrightsp,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user