From owner-svn-src-all@FreeBSD.ORG Sun Jan 25 08:27:12 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F84D106564A; Sun, 25 Jan 2009 08:27:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DE248FC13; Sun, 25 Jan 2009 08:27:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0P8RBOE010846; Sun, 25 Jan 2009 08:27:11 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0P8RBcZ010845; Sun, 25 Jan 2009 08:27:11 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200901250827.n0P8RBcZ010845@svn.freebsd.org> From: Ed Schouten Date: Sun, 25 Jan 2009 08:27:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187680 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2009 08:27:12 -0000 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); }