svn commit: r357470 - in head/sys: compat/linuxkpi/common/include/linux kern sys
Mateusz Guzik
mjg at FreeBSD.org
Mon Feb 3 22:27:57 UTC 2020
Author: mjg
Date: Mon Feb 3 22:27:55 2020
New Revision: 357470
URL: https://svnweb.freebsd.org/changeset/base/357470
Log:
fd: remove the seq argument from fget_unlocked
It is almost always NULL.
Modified:
head/sys/compat/linuxkpi/common/include/linux/file.h
head/sys/kern/kern_descrip.c
head/sys/kern/sys_generic.c
head/sys/kern/tty.c
head/sys/kern/vfs_syscalls.c
head/sys/sys/filedesc.h
Modified: head/sys/compat/linuxkpi/common/include/linux/file.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/file.h Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/compat/linuxkpi/common/include/linux/file.h Mon Feb 3 22:27:55 2020 (r357470)
@@ -54,7 +54,7 @@ linux_fget(unsigned int fd)
/* lookup file pointer by file descriptor index */
if (fget_unlocked(curthread->td_proc->p_fd, fd,
- &cap_no_rights, &file, NULL) != 0)
+ &cap_no_rights, &file) != 0)
return (NULL);
/* check if file handle really belongs to us */
@@ -90,7 +90,7 @@ put_unused_fd(unsigned int fd)
struct file *file;
if (fget_unlocked(curthread->td_proc->p_fd, fd,
- &cap_no_rights, &file, NULL) != 0) {
+ &cap_no_rights, &file) != 0) {
return;
}
/*
@@ -110,7 +110,7 @@ fd_install(unsigned int fd, struct linux_file *filp)
struct file *file;
if (fget_unlocked(curthread->td_proc->p_fd, fd,
- &cap_no_rights, &file, NULL) != 0) {
+ &cap_no_rights, &file) != 0) {
filp->_file = NULL;
} else {
filp->_file = file;
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/kern/kern_descrip.c Mon Feb 3 22:27:55 2020 (r357470)
@@ -619,7 +619,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
break;
}
- error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp, NULL);
+ error = fget_unlocked(fdp, fd, &cap_flock_rights, &fp);
if (error != 0)
break;
if (fp->f_type != DTYPE_VNODE) {
@@ -706,7 +706,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
* that the closing thread was a bit slower and that the
* 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) {
fdrop(fp, td);
break;
@@ -724,7 +724,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
break;
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)
break;
if (fp->f_type != DTYPE_VNODE) {
@@ -758,7 +758,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
break;
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)
break;
error = fo_add_seals(fp, arg);
@@ -766,7 +766,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
break;
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)
break;
if (fo_get_seals(fp, &seals) == 0)
@@ -780,7 +780,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
arg = arg ? 128 * 1024: 0;
/* FALLTHROUGH */
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)
break;
if (fp->f_type != DTYPE_VNODE) {
@@ -831,7 +831,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
* horrible kludge facilitates the current behavior in a much
* 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)
break;
if (fp->f_type != DTYPE_VNODE) {
@@ -2644,15 +2644,15 @@ fget_cap(struct thread *td, int fd, cap_rights_t *need
struct filedesc *fdp = td->td_proc->p_fd;
int error;
#ifndef CAPABILITIES
- error = fget_unlocked(fdp, fd, needrightsp, fpp, NULL);
- if (error == 0 && havecapsp != NULL)
+ error = fget_unlocked(fdp, fd, needrightsp, fpp);
+ if (havecapsp != NULL && error == 0)
filecaps_fill(havecapsp);
#else
struct file *fp;
seqc_t seq;
for (;;) {
- error = fget_unlocked(fdp, fd, needrightsp, &fp, &seq);
+ error = fget_unlocked_seq(fdp, fd, needrightsp, &fp, &seq);
if (error != 0)
return (error);
@@ -2683,7 +2683,7 @@ get_locked:
}
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)
{
#ifdef CAPABILITIES
@@ -2788,7 +2788,7 @@ _fget(struct thread *td, int fd, struct file **fpp, in
*fpp = NULL;
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))
return (error);
if (__predict_false(fp->f_ops == &badfileops)) {
@@ -2850,7 +2850,7 @@ fget_mmap(struct thread *td, int fd, cap_rights_t *rig
fdp = td->td_proc->p_fd;
MPASS(cap_rights_is_set(rightsp, CAP_MMAP));
for (;;) {
- error = fget_unlocked(fdp, fd, rightsp, fpp, &seq);
+ error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq);
if (__predict_false(error != 0))
return (error);
if (__predict_false((*fpp)->f_ops == &badfileops)) {
@@ -2893,14 +2893,14 @@ fget_fcntl(struct thread *td, int fd, cap_rights_t *ri
{
struct filedesc *fdp = td->td_proc->p_fd;
#ifndef CAPABILITIES
- return (fget_unlocked(fdp, fd, rightsp, fpp, NULL));
+ return (fget_unlocked(fdp, fd, rightsp, fpp));
#else
int error;
seqc_t seq;
MPASS(cap_rights_is_set(rightsp, CAP_FCNTL));
for (;;) {
- error = fget_unlocked(fdp, fd, rightsp, fpp, &seq);
+ error = fget_unlocked_seq(fdp, fd, rightsp, fpp, &seq);
if (error != 0)
return (error);
error = cap_fcntl_check(fdp, fd, needfcntl);
Modified: head/sys/kern/sys_generic.c
==============================================================================
--- head/sys/kern/sys_generic.c Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/kern/sys_generic.c Mon Feb 3 22:27:55 2020 (r357470)
@@ -1245,7 +1245,7 @@ static __inline int
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));
}
/*
Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/kern/tty.c Mon Feb 3 22:27:55 2020 (r357470)
@@ -2059,7 +2059,7 @@ ttyhook_register(struct tty **rtp, struct proc *p, int
/* Validate the file descriptor. */
fdp = p->p_fd;
error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK),
- &fp, NULL);
+ &fp);
if (error != 0)
return (error);
if (fp->f_ops == &badfileops) {
Modified: head/sys/kern/vfs_syscalls.c
==============================================================================
--- head/sys/kern/vfs_syscalls.c Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/kern/vfs_syscalls.c Mon Feb 3 22:27:55 2020 (r357470)
@@ -4173,7 +4173,7 @@ getvnode(struct thread *td, int fd, cap_rights_t *righ
struct file *fp;
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)
return (error);
Modified: head/sys/sys/filedesc.h
==============================================================================
--- head/sys/sys/filedesc.h Mon Feb 3 22:27:03 2020 (r357469)
+++ head/sys/sys/filedesc.h Mon Feb 3 22:27:55 2020 (r357470)
@@ -204,8 +204,10 @@ int fget_cap(struct thread *td, int fd, cap_rights_t *
struct file **fpp, struct filecaps *havecapsp);
/* 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);
+#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. */
static __inline struct file *
More information about the svn-src-all
mailing list