Date: Thu, 12 Feb 2009 19:00:13 +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: r188534 - head/lib/libc/gen Message-ID: <200902121900.n1CJ0Dn8064701@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Thu Feb 12 19:00:13 2009 New Revision: 188534 URL: http://svn.freebsd.org/changeset/base/188534 Log: Make ttyslot(3) work with pts(4) devices. It seems ttyslot() calls rindex(), to strip the device name to the last slash, but this is obviously invalid. /dev/pts/0 should be stripped until pts/0. Because /etc/ttys only supports TTY names in /dev/, just strip this piece of the pathname. Modified: head/lib/libc/gen/ttyslot.c Modified: head/lib/libc/gen/ttyslot.c ============================================================================== --- head/lib/libc/gen/ttyslot.c Thu Feb 12 18:57:18 2009 (r188533) +++ head/lib/libc/gen/ttyslot.c Thu Feb 12 19:00:13 2009 (r188534) @@ -33,6 +33,7 @@ static char sccsid[] = "@(#)ttyslot.c 8. #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <paths.h> #include <ttyent.h> #include <stdio.h> #include <string.h> @@ -43,19 +44,17 @@ ttyslot() { struct ttyent *ttyp; int slot; - char *p; int cnt; char *name; setttyent(); for (cnt = 0; cnt < 3; ++cnt) if ( (name = ttyname(cnt)) ) { - if ( (p = rindex(name, '/')) ) - ++p; - else - p = name; + if (strncmp(name, _PATH_DEV, sizeof _PATH_DEV - 1) != 0) + break; + name += sizeof _PATH_DEV - 1; for (slot = 1; (ttyp = getttyent()); ++slot) - if (!strcmp(ttyp->ty_name, p)) { + if (!strcmp(ttyp->ty_name, name)) { endttyent(); return(slot); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902121900.n1CJ0Dn8064701>