tt_ioctl

John E Hein jhein at timing.com
Tue Apr 8 16:09:21 UTC 2008


Back in 2005-10, phk added the tt_{open,ioctl,etc.} inline calls in
sys/tty.h allowing drivers that hook into the tty layer a way to
override or supplement the basic tty functions with their own
flavoring.

They were also connected up in kern/tty.c - well most of them.

tt_ioctl remains unused.

What about the following:

Index: kern/tty.c
===================================================================
RCS file: /base/FreeBSD-CVS/src/sys/kern/tty.c,v
retrieving revision 1.275
diff -u -p -r1.275 tty.c
--- kern/tty.c	19 Mar 2008 06:19:00 -0000	1.275
+++ kern/tty.c	8 Apr 2008 05:37:22 -0000
@@ -3297,7 +3297,9 @@ ttyioctl(struct cdev *dev, u_long cmd, c
 		    dt->c_ospeed = tp->t_ospeed;
 	}
 
-	error = ttyld_ioctl(tp, cmd, data, flag, td);
+	error = tt_ioctl(tp, cmd, data, flag, td);
+	if (error == ENOIOCTL)
+		error = ttyld_ioctl(tp, cmd, data, flag);
 	if (error == ENOIOCTL)
 		error = ttioctl(tp, cmd, data, flag);
 	ttyldoptim(tp);
Index: sys/tty.h
===================================================================
RCS file: /base/FreeBSD-CVS/src/sys/sys/tty.h,v
retrieving revision 1.102
diff -u -p -r1.102 tty.h
--- sys/tty.h	16 Dec 2007 06:12:53 -0000	1.102
+++ sys/tty.h	8 Apr 2008 05:30:04 -0000
@@ -442,6 +442,8 @@ tt_ioctl(struct tty *t, u_long cmd, void
 		      int fflag, struct thread *td)
 {
 
+	if (t->t_ioctl == NULL)
+		return (ENOIOCTL);
 	return (t->t_ioctl(t, cmd, data, fflag, td));
 }
 


One thing I'm not sure about is whether ttyld_ioctl should
be called regardless of whether a driver's ioctl method
is used.  I opted for 'not' since it seems bogus for
two different ioctl layers to handle the same cmd.


More information about the freebsd-arch mailing list