about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--sysdeps/unix/sysv/linux/ttyname.c11
-rw-r--r--sysdeps/unix/sysv/linux/ttyname_r.c8
3 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 055c01458b..435c18dca2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+1999-02-22  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/unix/sysv/linux/ttyname.c: Use __xstat and __fxstat
+	instead of stat and fstat.
+	* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
+
 1999-02-23  Andreas Schwab  <schwab@issan.cs.uni-dortmund.de>
 
 	* elf/dl-error.c (_dl_signal_cerror): New function.
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index 6ea406a8b8..a32d1a6605 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -79,7 +79,7 @@ getttyname (dev, mydev, myino, save, dostat)
 	    *((char *) __mempcpy (name, dev, devlen - 1)) = '/';
 	  }
 	memcpy (&name[devlen], d->d_name, dlen);
-	if (stat (name, &st) == 0
+	if (__xstat (_STAT_VER, name, &st) == 0
 #ifdef _STATBUF_ST_RDEV
 	    && S_ISCHR (st.st_mode) && st.st_rdev == mydev
 #else
@@ -107,6 +107,7 @@ ttyname (fd)
 {
   static char *buf;
   static size_t buflen = 0;
+  static int dev_pts_available = 1;
   char procname[30];
   struct stat st, st1;
   int dostat = 0;
@@ -135,10 +136,11 @@ ttyname (fd)
       && buf[0] != '[')
     return buf;
 
-  if (fstat (fd, &st) < 0)
+  if (__fxstat (_STAT_VER, fd, &st) < 0)
     return NULL;
 
-  if (stat ("/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (dev_pts_available
+      && __xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
     {
 #ifdef _STATBUF_ST_RDEV
       name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat);
@@ -150,6 +152,7 @@ ttyname (fd)
     {
       __set_errno (save);
       name = NULL;
+      dev_pts_available = 1;
     }
 
   if (!name && dostat != -1)
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index fe68e10b4d..b92c712fcc 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,95,96,97,98,99 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -74,7 +74,7 @@ getttyname_r (buf, buflen, mydev, myino, save, dostat)
 	cp = __stpncpy (buf + devlen, d->d_name, needed);
 	cp[0] = '\0';
 
-	if (stat (buf, &st) == 0
+	if (__xstat (_STAT_VER, buf, &st) == 0
 #ifdef _STATBUF_ST_RDEV
 	    && S_ISCHR (st.st_mode) && st.st_rdev == mydev
 #else
@@ -141,14 +141,14 @@ __ttyname_r (fd, buf, buflen)
       return ERANGE;
     }
 
-  if (fstat (fd, &st) < 0)
+  if (__fxstat (_STAT_VER, fd, &st) < 0)
     return errno;
 
   /* Prepare the result buffer.  */
   memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
   buflen -= sizeof ("/dev/pts/") - 1;
 
-  if (stat (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (__xstat (_STAT_VER, buf, &st1) == 0 && S_ISDIR (st1.st_mode))
     {
 #ifdef _STATBUF_ST_RDEV
       ret = getttyname_r (buf, buflen, st.st_rdev, st.st_ino, save,