From e137f0e944aac71bf17381c33466291251808f6c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 11 Mar 2010 19:14:41 +0000 Subject: 2010-03-11 Ken Peters PR 1456/cpukit * libcsupport/src/ttyname.c: ttyname_r() when called directly (not via ttyname()) does not prefix the caller provided buffer with the predefined _PATH_DEV string (/dev/). Thus the directory search fails and no tty name is returned to the caller. --- cpukit/libcsupport/src/ttyname.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/src/ttyname.c b/cpukit/libcsupport/src/ttyname.c index 9b86997caf..ed0b5cbdc1 100644 --- a/cpukit/libcsupport/src/ttyname.c +++ b/cpukit/libcsupport/src/ttyname.c @@ -55,7 +55,7 @@ #include #include -static char ttyname_buf[sizeof (_PATH_DEV) + MAXNAMLEN] = _PATH_DEV; +static char ttyname_buf[sizeof (_PATH_DEV) + MAXNAMLEN]; /* * ttyname_r() - POSIX 1003.1b 4.7.2 - Demetermine Terminal Device Name @@ -84,6 +84,9 @@ int ttyname_r( if ((dp = opendir (_PATH_DEV)) == NULL) rtems_set_errno_and_return_minus_one(EBADF); + /* Place the base directory in the path. */ + strncpy (name, _PATH_DEV, namesize); + for (rval = NULL; (dirp = readdir (dp)) != NULL ;) { if (dirp->d_ino != sb.st_ino) -- cgit v1.2.3