fd: remove the seq argument from fget_unlocked
It is almost always NULL.
This commit is contained in:
parent
7f1566f884
commit
52604ed792
@ -54,7 +54,7 @@ linux_fget(unsigned int fd)
|
|||||||
|
|
||||||
/* lookup file pointer by file descriptor index */
|
/* lookup file pointer by file descriptor index */
|
||||||
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
||||||
&cap_no_rights, &file, NULL) != 0)
|
&cap_no_rights, &file) != 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
/* check if file handle really belongs to us */
|
/* check if file handle really belongs to us */
|
||||||
@ -90,7 +90,7 @@ put_unused_fd(unsigned int fd)
|
|||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
||||||
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
||||||
&cap_no_rights, &file, NULL) != 0) {
|
&cap_no_rights, &file) != 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -110,7 +110,7 @@ fd_install(unsigned int fd, struct linux_file *filp)
|
|||||||
struct file *file;
|
struct file *file;
|
||||||
|
|
||||||
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
if (fget_unlocked(curthread->td_proc->p_fd, fd,
|
||||||
&cap_no_rights, &file, NULL) != 0) {
|
&cap_no_rights, &file) != 0) {
|
||||||
filp->_file = NULL;
|
filp->_file = NULL;
|
||||||
} else {
|
} else {
|
||||||
filp->_file = file;
|
filp->_file = file;
|
||||||
|
@ -619,7 +619,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
if (fp->f_type != DTYPE_VNODE) {
|
if (fp->f_type != DTYPE_VNODE) {
|
||||||
@ -706,7 +706,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
* that the closing thread was a bit slower and that the
|
* that the closing thread was a bit slower and that the
|
||||||
* advisory lock succeeded before the close.
|
* advisory lock succeeded before the close.
|
||||||
*/
|
*/
|
||||||
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2, NULL);
|
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp2);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
fdrop(fp, td);
|
fdrop(fp, td);
|
||||||
break;
|
break;
|
||||||
@ -724,7 +724,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case F_GETLK:
|
case F_GETLK:
|
||||||
error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
if (fp->f_type != DTYPE_VNODE) {
|
if (fp->f_type != DTYPE_VNODE) {
|
||||||
@ -758,7 +758,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case F_ADD_SEALS:
|
case F_ADD_SEALS:
|
||||||
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
error = fo_add_seals(fp, arg);
|
error = fo_add_seals(fp, arg);
|
||||||
@ -766,7 +766,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case F_GET_SEALS:
|
case F_GET_SEALS:
|
||||||
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
if (fo_get_seals(fp, &seals) == 0)
|
if (fo_get_seals(fp, &seals) == 0)
|
||||||
@ -780,7 +780,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
arg = arg ? 128 * 1024: 0;
|
arg = arg ? 128 * 1024: 0;
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case F_READAHEAD:
|
case F_READAHEAD:
|
||||||
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
if (fp->f_type != DTYPE_VNODE) {
|
if (fp->f_type != DTYPE_VNODE) {
|
||||||
@ -831,7 +831,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
|||||||
* horrible kludge facilitates the current behavior in a much
|
* horrible kludge facilitates the current behavior in a much
|
||||||
* cheaper manner until someone(tm) sorts this out.
|
* cheaper manner until someone(tm) sorts this out.
|
||||||
*/
|
*/
|
||||||
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp, NULL);
|
error = fget_unlocked(fdp, fd, &cap_no_rights, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
break;
|
break;
|
||||||
if (fp->f_type != DTYPE_VNODE) {
|
if (fp->f_type != DTYPE_VNODE) {
|
||||||
@ -2644,15 +2644,15 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
|
|||||||
struct filedesc *fdp = td->td_proc->p_fd;
|
struct filedesc *fdp = td->td_proc->p_fd;
|
||||||
int error;
|
int error;
|
||||||
#ifndef CAPABILITIES
|
#ifndef CAPABILITIES
|
||||||
error = fget_unlocked(fdp, fd, needrightsp, fpp, NULL);
|
error = fget_unlocked(fdp, fd, needrightsp, fpp);
|
||||||
if (error == 0 && havecapsp != NULL)
|
if (havecapsp != NULL && error == 0)
|
||||||
filecaps_fill(havecapsp);
|
filecaps_fill(havecapsp);
|
||||||
#else
|
#else
|
||||||
struct file *fp;
|
struct file *fp;
|
||||||
seqc_t seq;
|
seqc_t seq;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = fget_unlocked(fdp, fd, needrightsp, &fp, &seq);
|
error = fget_unlocked_seq(fdp, fd, needrightsp, &fp, &seq);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
@ -2683,7 +2683,7 @@ get_locked:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
||||||
struct file **fpp, seqc_t *seqp)
|
struct file **fpp, seqc_t *seqp)
|
||||||
{
|
{
|
||||||
#ifdef CAPABILITIES
|
#ifdef CAPABILITIES
|
||||||
@ -2788,7 +2788,7 @@ _fget(struct thread *td, int fd, struct file **fpp, int flags,
|
|||||||
|
|
||||||
*fpp = NULL;
|
*fpp = NULL;
|
||||||
fdp = td->td_proc->p_fd;
|
fdp = td->td_proc->p_fd;
|
||||||
error = fget_unlocked(fdp, fd, needrightsp, &fp, NULL);
|
error = fget_unlocked(fdp, fd, needrightsp, &fp);
|
||||||
if (__predict_false(error != 0))
|
if (__predict_false(error != 0))
|
||||||
return (error);
|
return (error);
|
||||||
if (__predict_false(fp->f_ops == &badfileops)) {
|
if (__predict_false(fp->f_ops == &badfileops)) {
|
||||||
@ -2850,7 +2850,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rightsp, u_char *maxprotp,
|
|||||||
fdp = td->td_proc->p_fd;
|
fdp = td->td_proc->p_fd;
|
||||||
MPASS(cap_rights_is_set(rightsp, CAP_MMAP));
|
MPASS(cap_rights_is_set(rightsp, CAP_MMAP));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = fget_unlocked(fdp, fd, rightsp, fpp, &seq);
|
error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq);
|
||||||
if (__predict_false(error != 0))
|
if (__predict_false(error != 0))
|
||||||
return (error);
|
return (error);
|
||||||
if (__predict_false((*fpp)->f_ops == &badfileops)) {
|
if (__predict_false((*fpp)->f_ops == &badfileops)) {
|
||||||
@ -2893,14 +2893,14 @@ fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp, int needfcntl,
|
|||||||
{
|
{
|
||||||
struct filedesc *fdp = td->td_proc->p_fd;
|
struct filedesc *fdp = td->td_proc->p_fd;
|
||||||
#ifndef CAPABILITIES
|
#ifndef CAPABILITIES
|
||||||
return (fget_unlocked(fdp, fd, rightsp, fpp, NULL));
|
return (fget_unlocked(fdp, fd, rightsp, fpp));
|
||||||
#else
|
#else
|
||||||
int error;
|
int error;
|
||||||
seqc_t seq;
|
seqc_t seq;
|
||||||
|
|
||||||
MPASS(cap_rights_is_set(rightsp, CAP_FCNTL));
|
MPASS(cap_rights_is_set(rightsp, CAP_FCNTL));
|
||||||
for (;;) {
|
for (;;) {
|
||||||
error = fget_unlocked(fdp, fd, rightsp, fpp, &seq);
|
error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
error = cap_fcntl_check(fdp, fd, needfcntl);
|
error = cap_fcntl_check(fdp, fd, needfcntl);
|
||||||
|
@ -1245,7 +1245,7 @@ static __inline int
|
|||||||
getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp)
|
getselfd_cap(struct filedesc *fdp, int fd, struct file **fpp)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (fget_unlocked(fdp, fd, &cap_event_rights, fpp, NULL));
|
return (fget_unlocked(fdp, fd, &cap_event_rights, fpp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2059,7 +2059,7 @@ ttyhook_register(struct tty **rtp, struct proc *p, int fd, struct ttyhook *th,
|
|||||||
/* Validate the file descriptor. */
|
/* Validate the file descriptor. */
|
||||||
fdp = p->p_fd;
|
fdp = p->p_fd;
|
||||||
error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK),
|
error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK),
|
||||||
&fp, NULL);
|
&fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
if (fp->f_ops == &badfileops) {
|
if (fp->f_ops == &badfileops) {
|
||||||
|
@ -4173,7 +4173,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *rightsp, struct file **fpp)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL);
|
error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
@ -204,8 +204,10 @@ int fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp,
|
|||||||
struct file **fpp, struct filecaps *havecapsp);
|
struct file **fpp, struct filecaps *havecapsp);
|
||||||
|
|
||||||
/* Return a referenced file from an unlocked descriptor. */
|
/* Return a referenced file from an unlocked descriptor. */
|
||||||
int fget_unlocked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
int fget_unlocked_seq(struct filedesc *fdp, int fd, cap_rights_t *needrightsp,
|
||||||
struct file **fpp, seqc_t *seqp);
|
struct file **fpp, seqc_t *seqp);
|
||||||
|
#define fget_unlocked(fdp, fd, needrightsp, fpp) \
|
||||||
|
fget_unlocked_seq(fdp, fd, needrightsp, fpp, NULL)
|
||||||
|
|
||||||
/* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */
|
/* Requires a FILEDESC_{S,X}LOCK held and returns without a ref. */
|
||||||
static __inline struct file *
|
static __inline struct file *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user