diff options
author | mjg <mjg@FreeBSD.org> | 2015-06-14 14:08:52 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2015-06-14 14:08:52 +0000 |
commit | 98e752b84d7e81cbd426946b8caf6bdc96493ce4 (patch) | |
tree | 3e0c86c9640af4b5b6613549cd3eef0d3c398674 /sys/kern/kern_descrip.c | |
parent | a6700775099646c91999f6f66dad3ba25480ff99 (diff) | |
download | FreeBSD-src-98e752b84d7e81cbd426946b8caf6bdc96493ce4.zip FreeBSD-src-98e752b84d7e81cbd426946b8caf6bdc96493ce4.tar.gz |
fd: move out actual fp installation to _finstall
Use it in fd passing functions as the first step towards fd code cleanup.
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f6f8194..0ba507f 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1750,26 +1750,18 @@ falloc_noinstall(struct thread *td, struct file **resultfp) /* * Install a file in a file descriptor table. */ -int -finstall(struct thread *td, struct file *fp, int *fd, int flags, +void +_finstall(struct filedesc *fdp, struct file *fp, int fd, int flags, struct filecaps *fcaps) { - struct filedesc *fdp = td->td_proc->p_fd; struct filedescent *fde; - int error; - KASSERT(fd != NULL, ("%s: fd == NULL", __func__)); - KASSERT(fp != NULL, ("%s: fp == NULL", __func__)); + MPASS(fp != NULL); if (fcaps != NULL) filecaps_validate(fcaps, __func__); + FILEDESC_XLOCK_ASSERT(fdp); - FILEDESC_XLOCK(fdp); - if ((error = fdalloc(td, 0, fd))) { - FILEDESC_XUNLOCK(fdp); - return (error); - } - fhold(fp); - fde = &fdp->fd_ofiles[*fd]; + fde = &fdp->fd_ofiles[fd]; #ifdef CAPABILITIES seq_write_begin(&fde->fde_seq); #endif @@ -1783,6 +1775,24 @@ finstall(struct thread *td, struct file *fp, int *fd, int flags, #ifdef CAPABILITIES seq_write_end(&fde->fde_seq); #endif +} + +int +finstall(struct thread *td, struct file *fp, int *fd, int flags, + struct filecaps *fcaps) +{ + struct filedesc *fdp = td->td_proc->p_fd; + int error; + + MPASS(fd != NULL); + + FILEDESC_XLOCK(fdp); + if ((error = fdalloc(td, 0, fd))) { + FILEDESC_XUNLOCK(fdp); + return (error); + } + fhold(fp); + _finstall(fdp, fp, *fd, flags, fcaps); FILEDESC_XUNLOCK(fdp); return (0); } |