summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-03-11 19:14:41 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-03-11 19:14:41 +0000
commite137f0e944aac71bf17381c33466291251808f6c (patch)
tree5e6051e57986bb6b11bd8fff91aaa4c374aa105f /cpukit/libcsupport
parent2010-03-11 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-e137f0e944aac71bf17381c33466291251808f6c.tar.bz2
2010-03-11 Ken Peters <kptrs@yahoo.com>
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.
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r--cpukit/libcsupport/src/ttyname.c5
1 files changed, 4 insertions, 1 deletions
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 <rtems/libio_.h>
#include <rtems/seterr.h>
-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)