| 2948 | } |
| 2949 | |
| 2950 | int |
| 2951 | fget_cap_locked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, |
| 2952 | struct file **fpp, struct filecaps *havecapsp) |
| 2953 | { |
| 2954 | struct filedescent *fde; |
| 2955 | int error; |
| 2956 | |
| 2957 | FILEDESC_LOCK_ASSERT(fdp); |
| 2958 | |
| 2959 | fde = fdeget_locked(fdp, fd); |
| 2960 | if (fde == NULL) { |
| 2961 | error = EBADF; |
| 2962 | goto out; |
| 2963 | } |
| 2964 | |
| 2965 | #ifdef CAPABILITIES |
| 2966 | error = cap_check(cap_rights_fde_inline(fde), needrightsp); |
| 2967 | if (error != 0) |
| 2968 | goto out; |
| 2969 | #endif |
| 2970 | |
| 2971 | if (havecapsp != NULL) |
| 2972 | filecaps_copy(&fde->fde_caps, havecapsp, true); |
| 2973 | |
| 2974 | *fpp = fde->fde_file; |
| 2975 | |
| 2976 | error = 0; |
| 2977 | out: |
| 2978 | return (error); |
| 2979 | } |
| 2980 | |
| 2981 | int |
| 2982 | fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, |
no test coverage detected