summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2008-12-13 21:17:46 +0000
committermav <mav@FreeBSD.org>2008-12-13 21:17:46 +0000
commit37aff7daa7032f0fb1c864a4f83d04aa3c7bf5ea (patch)
treed9e25fe3d039b5ca9124d8b071d6154220f8dcb3 /sys/kern/tty.c
parent1d585eec2563a0e5077fe0c6f7c32e6d74edc663 (diff)
downloadFreeBSD-src-37aff7daa7032f0fb1c864a4f83d04aa3c7bf5ea.zip
FreeBSD-src-37aff7daa7032f0fb1c864a4f83d04aa3c7bf5ea.tar.gz
Change ttyhook_register() second argument from thread to process pointer.
Thread was not really needed there, while previous ng_tty implementation that used thread pointer had locking issues (using sx while holding mutex).
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index e0045ce..30c2633 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/cons.h>
#include <sys/fcntl.h>
#include <sys/file.h>
+#include <sys/filedesc.h>
#include <sys/filio.h>
#ifdef COMPAT_43TTY
#include <sys/ioctl_compat.h>
@@ -1673,18 +1674,24 @@ ttyhook_defrint(struct tty *tp, char c, int flags)
}
int
-ttyhook_register(struct tty **rtp, struct thread *td, int fd,
+ttyhook_register(struct tty **rtp, struct proc *p, int fd,
struct ttyhook *th, void *softc)
{
struct tty *tp;
struct file *fp;
struct cdev *dev;
struct cdevsw *cdp;
+ struct filedesc *fdp;
int error;
/* Validate the file descriptor. */
- if (fget(td, fd, &fp) != 0)
- return (EINVAL);
+ if ((fdp = p->p_fd) == NULL)
+ return (EBADF);
+ FILEDESC_SLOCK(fdp);
+ if ((fp = fget_locked(fdp, fd)) == NULL || fp->f_ops == &badfileops) {
+ FILEDESC_SUNLOCK(fdp);
+ return (EBADF);
+ }
/* Make sure the vnode is bound to a character device. */
error = EINVAL;
@@ -1723,7 +1730,7 @@ ttyhook_register(struct tty **rtp, struct thread *td, int fd,
done3: tty_unlock(tp);
done2: dev_relthread(dev);
-done1: fdrop(fp, td);
+done1: FILEDESC_SUNLOCK(fdp);
return (error);
}
OpenPOWER on IntegriCloud