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);
                                }
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to