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

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

Change 151956 by ed@ed_mekker on 2008/10/26 14:22:00

	Strip more dead code from tty_cons.c.

Affected files ...

.. //depot/projects/mpsafetty/sys/kern/tty_cons.c#5 edit

Differences ...

==== //depot/projects/mpsafetty/sys/kern/tty_cons.c#5 (text+ko) ====

@@ -68,12 +68,8 @@
 
 static MALLOC_DEFINE(M_TTYCONS, "tty console", "tty console handling");
 
-static	d_open_t	cnopen;
-static	d_close_t	cnclose;
-
 struct cn_device {
 	STAILQ_ENTRY(cn_device) cnd_next;
-	struct		vnode *cnd_vp;
 	struct		consdev *cnd_cn;
 };
 
@@ -83,10 +79,6 @@
 static STAILQ_HEAD(, cn_device) cn_devlist =
     STAILQ_HEAD_INITIALIZER(cn_devlist);
 
-#define CND_INVALID(cnd, td) 						\
-	(cnd == NULL || cnd->cnd_vp == NULL ||				\
-	    (cnd->cnd_vp->v_type == VBAD && !cn_devopen(cnd, td, 1)))
-
 static dev_t	cn_udev_t;
 SYSCTL_OPAQUE(_machdep, OID_AUTO, consdev, CTLFLAG_RD,
 	&cn_udev_t, sizeof cn_udev_t, "T,struct cdev *", "");
@@ -97,8 +89,6 @@
 				 * this bit cleared.
 				 */
 static int cn_mute;
-static int openflag;			/* how /dev/console was opened */
-static int cn_is_open;
 static char *consbuf;			/* buffer used by `consmsgbuf' */
 static struct callout conscallout;	/* callout for outputting to constty */
 struct msgbuf consmsgbuf;		/* message buffer for console tty */
@@ -213,9 +203,6 @@
 		if (cnd->cnd_cn != cn)
 			continue;
 		STAILQ_REMOVE(&cn_devlist, cnd, cn_device, cnd_next);
-		if (cnd->cnd_vp != NULL)
-			vn_close(cnd->cnd_vp, openflag, NOCRED, NULL);
-		cnd->cnd_vp = NULL;
 		cnd->cnd_cn = NULL;
 
 		/* Remove this device from available mask. */
@@ -350,85 +337,12 @@
 	error = sysctl_handle_int(oidp, &cn_mute, 0, req);
 	if (error != 0 || req->newptr == NULL)
 		return (error);
-	if (ocn_mute && !cn_mute && cn_is_open)
-		error = cnopen(NULL, openflag, 0, curthread);
-	else if (!ocn_mute && cn_mute && cn_is_open) {
-		error = cnclose(NULL, openflag, 0, curthread);
-		cn_is_open = 1;		/* XXX hack */
-	}
 	return (error);
 }
 
 SYSCTL_PROC(_kern, OID_AUTO, consmute, CTLTYPE_INT|CTLFLAG_RW,
 	0, sizeof(cn_mute), sysctl_kern_consmute, "I", "");
 
-static int
-cn_devopen(struct cn_device *cnd, struct thread *td, int forceopen)
-{
-	char path[CNDEVPATHMAX];
-	struct nameidata nd;
-	struct vnode *vp;
-	struct cdev *dev;
-	struct cdevsw *csw;
-	int error;
-
-	if ((vp = cnd->cnd_vp) != NULL) {
-		if (!forceopen && vp->v_type != VBAD) {
-			dev = vp->v_rdev;
-			csw = dev_refthread(dev);
-			if (csw == NULL)
-				return (ENXIO);
-			error = (*csw->d_open)(dev, openflag, 0, td);
-			dev_relthread(dev);
-			return (error);
-		}
-		cnd->cnd_vp = NULL;
-		vn_close(vp, openflag, td->td_ucred, td);
-	}
-	snprintf(path, sizeof(path), "/dev/%s", cnd->cnd_cn->cn_name);
-	NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
-	error = vn_open(&nd, &openflag, 0, NULL);
-	if (error == 0) {
-		NDFREE(&nd, NDF_ONLY_PNBUF);
-		VOP_UNLOCK(nd.ni_vp, 0);
-		if (nd.ni_vp->v_type == VCHR)
-			cnd->cnd_vp = nd.ni_vp;
-		else
-			vn_close(nd.ni_vp, openflag, td->td_ucred, td);
-	}
-	return (cnd->cnd_vp != NULL);
-}
-
-static int
-cnopen(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	struct cn_device *cnd;
-
-	openflag = flag | FWRITE;	/* XXX */
-	cn_is_open = 1;			/* console is logically open */
-	if (cn_mute)
-		return (0);
-	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next)
-		cn_devopen(cnd, td, 0);
-	return (0);
-}
-
-static int
-cnclose(struct cdev *dev, int flag, int mode, struct thread *td)
-{
-	struct cn_device *cnd;
-	struct vnode *vp;
-
-	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
-		if ((vp = cnd->cnd_vp) == NULL)
-			continue; 
-		cnd->cnd_vp = NULL;
-		vn_close(vp, openflag, td->td_ucred, td);
-	}
-	cn_is_open = 0;
-	return (0);
-}
-
 /*
  * Low level console routines.
  */



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