Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Oct 2008 14:10:26 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 151954 for review
Message-ID:  <200810261410.m9QEAQYM068197@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=151954

Change 151954 by ed@ed_mekker on 2008/10/26 14:09:48

	Give /dev/console its own cdevsw, instead of putting all the
	conditional checks inside the regular TTY routines.

Affected files ...

.. //depot/projects/mpsafetty/sys/kern/tty.c#58 edit

Differences ...

==== //depot/projects/mpsafetty/sys/kern/tty.c#58 (text+ko) ====

@@ -224,10 +224,6 @@
 		return (EPERM);
 	}
 
-	/* /dev/console without associated TTY. */
-	if (tp == NULL)
-		return (ENXIO);
-
 	tty_lock(tp);
 	if (tty_gone(tp)) {
 		/* Device is already gone. */
@@ -311,9 +307,6 @@
 {
 	struct tty *tp = dev->si_drv1;
 
-	if (TTY_CONSOLE(dev))
-		return (0);
-
 	tty_lock(tp);
 
 	/*
@@ -423,9 +416,6 @@
 	struct tty *tp = dev->si_drv1;
 	int error;
 
-	if (TTY_CONSOLE(dev))
-		log_console(uio);
-
 	error = ttydev_enter(tp);
 	if (error)
 		return (error);
@@ -1771,11 +1761,50 @@
  * /dev/console handling.
  */
 
+static int
+ttyconsdev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
+{
+	struct tty *tp = dev->si_drv1;
+
+	/* /dev/console without associated TTY. */
+	if (tp == NULL)
+		return (ENXIO);
+	
+	return (ttydev_open(dev, oflags, devtype, td));
+}
+
+static int
+ttyconsdev_write(struct cdev *dev, struct uio *uio, int ioflag)
+{
+
+	log_console(uio);
+
+	return (ttydev_write(dev, uio, ioflag));
+}
+
+/*
+ * /dev/console is a little different than normal TTY's. Unlike regular
+ * TTY device nodes, this device node will not revoke the entire TTY
+ * upon closure and all data written to it will be logged.
+ */
+static struct cdevsw ttyconsdev_cdevsw = {
+	.d_version	= D_VERSION,
+	.d_open		= ttyconsdev_open,
+	.d_read		= ttydev_read,
+	.d_write	= ttyconsdev_write,
+	.d_ioctl	= ttydev_ioctl,
+	.d_kqfilter	= ttydev_kqfilter,
+	.d_poll		= ttydev_poll,
+	.d_mmap		= ttydev_mmap,
+	.d_name		= "ttyconsdev",
+	.d_flags	= D_TTY,
+};
+
 static void
 ttyconsdev_init(void *unused)
 {
 
-	dev_console = make_dev(&ttydev_cdevsw, 0, UID_ROOT, GID_WHEEL,
+	dev_console = make_dev(&ttyconsdev_cdevsw, 0, UID_ROOT, GID_WHEEL,
 	    0600, "console");
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810261410.m9QEAQYM068197>