diff options
author | phk <phk@FreeBSD.org> | 2004-11-07 22:16:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-11-07 22:16:07 +0000 |
commit | 52da2f8e345a7de465e7604b8712493ea0fedebd (patch) | |
tree | a14848a9cd0a6a02b8bde301a11a3f8c51e8bdf7 /sys/kern/vfs_extattr.c | |
parent | 878fd8dde724c338fc81887b50b0a93faf7495cd (diff) | |
download | FreeBSD-src-52da2f8e345a7de465e7604b8712493ea0fedebd.zip FreeBSD-src-52da2f8e345a7de465e7604b8712493ea0fedebd.tar.gz |
Introduce fdclose() which will clean an entry in a filedesc.
Replace homerolled versions with call to fdclose().
Make fdunused() static to kern_descrip.c
Diffstat (limited to 'sys/kern/vfs_extattr.c')
-rw-r--r-- | sys/kern/vfs_extattr.c | 31 |
1 files changed, 4 insertions, 27 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 38d6de6..d98a885 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -990,15 +990,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags, * Clean up the descriptor, but only if another thread hadn't * replaced or closed it. */ - FILEDESC_LOCK(fdp); - if (fdp->fd_ofiles[indx] == fp) { - fdp->fd_ofiles[indx] = NULL; - fdunused(fdp, indx); - FILEDESC_UNLOCK(fdp); - fdrop(fp, td); - } else { - FILEDESC_UNLOCK(fdp); - } + fdclose(fdp, fp, indx, td); if (error == ERESTART) error = EINTR; @@ -1091,15 +1083,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags, return (0); bad: mtx_unlock(&Giant); - FILEDESC_LOCK(fdp); - if (fdp->fd_ofiles[indx] == fp) { - fdp->fd_ofiles[indx] = NULL; - fdunused(fdp, indx); - FILEDESC_UNLOCK(fdp); - fdrop(fp, td); - } else { - FILEDESC_UNLOCK(fdp); - } + fdclose(fdp, fp, indx, td); fdrop(fp, td); return (error); } @@ -4018,15 +4002,8 @@ fhopen(td, uap) * descriptor but handle the case where someone might * have dup()d or close()d it when we weren't looking. */ - FILEDESC_LOCK(fdp); - if (fdp->fd_ofiles[indx] == fp) { - fdp->fd_ofiles[indx] = NULL; - fdunused(fdp, indx); - FILEDESC_UNLOCK(fdp); - fdrop(fp, td); - } else { - FILEDESC_UNLOCK(fdp); - } + fdclose(fdp, fp, indx, td); + /* * release our private reference */ |