svn commit: r237082 - head/sys/kern
Pawel Jakub Dawidek
pjd at FreeBSD.org
Thu Jun 14 16:25:10 UTC 2012
Author: pjd
Date: Thu Jun 14 16:25:10 2012
New Revision: 237082
URL: http://svn.freebsd.org/changeset/base/237082
Log:
Remove fdtofp() function and use fget_locked(), which works exactly the same.
MFC after: 1 month
Modified:
head/sys/kern/kern_descrip.c
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Thu Jun 14 16:24:03 2012 (r237081)
+++ head/sys/kern/kern_descrip.c Thu Jun 14 16:25:10 2012 (r237082)
@@ -429,25 +429,13 @@ sys_fcntl(struct thread *td, struct fcnt
return (error);
}
-static inline struct file *
-fdtofp(int fd, struct filedesc *fdp)
-{
-
- FILEDESC_LOCK_ASSERT(fdp);
-
- if (fd < 0 || fd >= fdp->fd_nfiles)
- return (NULL);
-
- return (fdp->fd_ofiles[fd]);
-}
-
static inline int
fdunwrap(int fd, cap_rights_t rights, struct filedesc *fdp, struct file **fpp)
{
FILEDESC_LOCK_ASSERT(fdp);
- *fpp = fdtofp(fd, fdp);
+ *fpp = fget_locked(fdp, fd);
if (*fpp == NULL)
return (EBADF);
@@ -496,7 +484,7 @@ kern_fcntl(struct thread *td, int fd, in
case F_GETFD:
FILEDESC_SLOCK(fdp);
- if ((fp = fdtofp(fd, fdp)) == NULL) {
+ if ((fp = fget_locked(fdp, fd)) == NULL) {
FILEDESC_SUNLOCK(fdp);
error = EBADF;
break;
@@ -508,7 +496,7 @@ kern_fcntl(struct thread *td, int fd, in
case F_SETFD:
FILEDESC_XLOCK(fdp);
- if ((fp = fdtofp(fd, fdp)) == NULL) {
+ if ((fp = fget_locked(fdp, fd)) == NULL) {
FILEDESC_XUNLOCK(fdp);
error = EBADF;
break;
@@ -681,7 +669,7 @@ kern_fcntl(struct thread *td, int fd, in
vfslocked = 0;
/* Check for race with close */
FILEDESC_SLOCK(fdp);
- if (fdtofp(fd, fdp) != fp) {
+ if (fget_locked(fdp, fd) != fp) {
FILEDESC_SUNLOCK(fdp);
flp->l_whence = SEEK_SET;
flp->l_start = 0;
@@ -746,7 +734,7 @@ kern_fcntl(struct thread *td, int fd, in
/* FALLTHROUGH */
case F_READAHEAD:
FILEDESC_SLOCK(fdp);
- if ((fp = fdtofp(fd, fdp)) == NULL) {
+ if ((fp = fget_locked(fdp, fd)) == NULL) {
FILEDESC_SUNLOCK(fdp);
error = EBADF;
break;
@@ -823,7 +811,7 @@ do_dup(struct thread *td, int flags, int
return (flags & DUP_FCNTL ? EINVAL : EBADF);
FILEDESC_XLOCK(fdp);
- if (fdtofp(old, fdp) == NULL) {
+ if (fget_locked(fdp, old) == NULL) {
FILEDESC_XUNLOCK(fdp);
return (EBADF);
}
@@ -1202,7 +1190,7 @@ kern_close(td, fd)
AUDIT_SYSCLOSE(td, fd);
FILEDESC_XLOCK(fdp);
- if ((fp = fdtofp(fd, fdp)) == NULL) {
+ if ((fp = fget_locked(fdp, fd)) == NULL) {
FILEDESC_XUNLOCK(fdp);
return (EBADF);
}
@@ -2596,7 +2584,7 @@ dupfdopen(struct thread *td, struct file
* closed, then reject.
*/
FILEDESC_XLOCK(fdp);
- if ((fp = fdtofp(dfd, fdp)) == NULL) {
+ if ((fp = fget_locked(fdp, dfd)) == NULL) {
FILEDESC_XUNLOCK(fdp);
return (EBADF);
}
More information about the svn-src-all
mailing list