Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jan 2009 08:27:11 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187680 - head/sys/kern
Message-ID:  <200901250827.n0P8RBcZ010845@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sun Jan 25 08:27:11 2009
New Revision: 187680
URL: http://svn.freebsd.org/changeset/base/187680

Log:
  Remove unneeded use of device unit numbers from pty(4).
  
  A much more simple approach to generate the slave device name, is to
  obtain the device name of the master and replace 'p' by 't'.

Modified:
  head/sys/kern/tty_pty.c

Modified: head/sys/kern/tty_pty.c
==============================================================================
--- head/sys/kern/tty_pty.c	Sun Jan 25 07:35:10 2009	(r187679)
+++ head/sys/kern/tty_pty.c	Sun Jan 25 08:27:11 2009	(r187680)
@@ -55,16 +55,15 @@ SYSCTL_UINT(_kern, OID_AUTO, tty_pty_war
 static int
 ptydev_fdopen(struct cdev *dev, int fflags, struct thread *td, struct file *fp)
 {
-	int u, error;
-	char name[] = "ttyXX";
+	int error;
+	char name[6]; /* "ttyXX" */
 
 	if (!atomic_cmpset_ptr((uintptr_t *)&dev->si_drv1, 0, 1))
 		return (EBUSY);
 
 	/* Generate device name and create PTY. */
-	u = dev2unit(dev);
-	name[3] = u >> 8;
-	name[4] = u;
+	strcpy(name, devtoname(dev));
+	name[0] = 't';
 
 	error = pts_alloc_external(fflags & (FREAD|FWRITE), td, fp, dev, name);
 	if (error != 0) {
@@ -93,7 +92,6 @@ static void
 pty_clone(void *arg, struct ucred *cr, char *name, int namelen,
     struct cdev **dev)
 {
-	int u;
 
 	/* Cloning is already satisfied. */
 	if (*dev != NULL)
@@ -114,8 +112,7 @@ pty_clone(void *arg, struct ucred *cr, c
 		return;
 
 	/* Create the controller device node. */
-	u = (unsigned int)name[3] << 8 | name[4];
-	*dev = make_dev_credf(MAKEDEV_REF, &ptydev_cdevsw, u,
+	*dev = make_dev_credf(MAKEDEV_REF, &ptydev_cdevsw, 0,
 	    NULL, UID_ROOT, GID_WHEEL, 0666, name);
 }
 



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