diff options
author | Mateusz Guzik <mjg@FreeBSD.org> | 2022-02-22 15:54:17 +0000 |
---|---|---|
committer | Mateusz Guzik <mjg@FreeBSD.org> | 2022-02-22 18:53:43 +0000 |
commit | f17ef28674f13bc2199d4819123248f5997b435a (patch) | |
tree | 0e73178c16634f363c4c2a372295a33f4225b1a4 /sys/kern/kern_descrip.c | |
parent | 0a2f498234023008d9a3b13ad7fc8fd81d384bab (diff) | |
download | src-f17ef28674f13bc2199d4819123248f5997b435a.tar.gz src-f17ef28674f13bc2199d4819123248f5997b435a.zip |
fd: rename fget*_locked to fget*_noref
This gets rid of the error prone naming where fget_unlocked returns with
a ref held, while fget_locked requires a lock but provides nothing in
terms of making sure the file lives past unlock.
No functional changes.
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 259be785f88d..ed9d0bc3c253 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -518,7 +518,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) case F_GETFD: error = EBADF; FILEDESC_SLOCK(fdp); - fde = fdeget_locked(fdp, fd); + fde = fdeget_noref(fdp, fd); if (fde != NULL) { td->td_retval[0] = (fde->fde_flags & UF_EXCLOSE) ? FD_CLOEXEC : 0; @@ -530,7 +530,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) case F_SETFD: error = EBADF; FILEDESC_XLOCK(fdp); - fde = fdeget_locked(fdp, fd); + fde = fdeget_noref(fdp, fd); if (fde != NULL) { fde->fde_flags = (fde->fde_flags & ~UF_EXCLOSE) | (arg & FD_CLOEXEC ? UF_EXCLOSE : 0); @@ -874,7 +874,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg) } kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK | M_ZERO); FILEDESC_SLOCK(fdp); - error = fget_cap_locked(fdp, fd, &cap_fcntl_rights, &fp, NULL); + error = fget_cap_noref(fdp, fd, &cap_fcntl_rights, &fp, NULL); if (error == 0 && fhold(fp)) { export_file_to_kinfo(fp, fd, NULL, kif, fdp, 0); FILEDESC_SUNLOCK(fdp); @@ -945,7 +945,7 @@ kern_dup(struct thread *td, u_int mode, int flags, int old, int new) error = EBADF; FILEDESC_XLOCK(fdp); - if (fget_locked(fdp, old) == NULL) + if (fget_noref(fdp, old) == NULL) goto unlock; if (mode == FDDUP_FIXED && old == new) { td->td_retval[0] = new; @@ -1383,7 +1383,7 @@ kern_close(struct thread *td, int fd) fdp = td->td_proc->p_fd; FILEDESC_XLOCK(fdp); - if ((fp = fget_locked(fdp, fd)) == NULL) { + if ((fp = fget_noref(fdp, fd)) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); } @@ -2812,7 +2812,7 @@ finit_vnode(struct file *fp, u_int flag, void *data, struct fileops *ops) } int -fget_cap_locked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, +fget_cap_noref(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, struct file **fpp, struct filecaps *havecapsp) { struct filedescent *fde; @@ -2821,7 +2821,7 @@ fget_cap_locked(struct filedesc *fdp, int fd, cap_rights_t *needrightsp, FILEDESC_LOCK_ASSERT(fdp); *fpp = NULL; - fde = fdeget_locked(fdp, fd); + fde = fdeget_noref(fdp, fd); if (fde == NULL) { error = EBADF; goto out; @@ -2877,7 +2877,7 @@ fget_cap(struct thread *td, int fd, cap_rights_t *needrightsp, get_locked: FILEDESC_SLOCK(fdp); - error = fget_cap_locked(fdp, fd, needrightsp, fpp, havecapsp); + error = fget_cap_noref(fdp, fd, needrightsp, fpp, havecapsp); if (error == 0 && !fhold(*fpp)) error = EBADF; FILEDESC_SUNLOCK(fdp); @@ -3587,7 +3587,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int dfd, int mode, * closed, then reject. */ FILEDESC_XLOCK(fdp); - if ((fp = fget_locked(fdp, dfd)) == NULL) { + if ((fp = fget_noref(fdp, dfd)) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); } |