]> sourceware.org Git - glibc.git/commitdiff
Don't make ttyname* fail if proc filesystem is not available
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Wed, 29 Aug 2012 04:33:39 +0000 (10:03 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Wed, 29 Aug 2012 04:34:23 +0000 (10:04 +0530)
The ttyname and ttyname_r functions on Linux now fall back to
searching for the tty file descriptor in /dev/pts or /dev if /proc is
not available.  This allows creation of chroots without the procfs
mounted on /proc.

Fixes BZ #14516.

ChangeLog
NEWS
sysdeps/unix/sysv/linux/ttyname.c
sysdeps/unix/sysv/linux/ttyname_r.c

index f72f4b41b3fe436385ebb816ba9174e44cd128c2..249045670352d8f26e4699e4ad746c9b3b1162dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-08-29  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       [BZ #14516]
+       * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Don't return
+       failure if reading from procfs failed.
+       * sysdeps/unix/sysv/linux/ttyname_r.c (ttyname_r): Likewise.
+
 2012-08-27  Joseph Myers  <joseph@codesourcery.com>
 
        * sysdeps/unix/sysv/linux/kernel-features.h
diff --git a/NEWS b/NEWS
index 247139018d50ebea020d089eddbb103207aac8ca..6abc6eab805ff0fdcecbe18ba9961030f407d0e6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,7 @@ Version 2.17
   3479, 5400, 6778, 6808, 9685, 11607, 13717, 13696, 13939, 14042, 14090,
   14166, 14150, 14151, 14154, 14157, 14166, 14173, 14195, 14252, 14283,
   14298, 14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459,
-  14505, 14519
+  14505, 14516, 14519
 
 * Support for STT_GNU_IFUNC symbols added for s390 and s390x.
   Optimized versions of memcpy, memset, and memcmp added for System z10 and
@@ -40,6 +40,10 @@ Version 2.17
   New configure option --disable-build-nscd avoids building nscd itself;
   this is the default if --disable-nscd is used.
 
+* The ttyname and ttyname_r functions on Linux now fall back to searching for
+  the tty file descriptor in /dev/pts or /dev if /proc is not available.  This
+  allows creation of chroots without the procfs mounted on /proc.
+
 \f
 Version 2.16
 
index 3dacd40c2395a4102450e12e39135074b75a4ea0..d3070c3ba8a2c6d790a2d99754d7ad175b48be5a 100644 (file)
@@ -148,12 +148,6 @@ ttyname (int fd)
     }
 
   ssize_t len = __readlink (procname, ttyname_buf, buflen);
-  if (__builtin_expect (len == -1 && errno == ENOENT, 0))
-    {
-      __set_errno (EBADF);
-      return NULL;
-    }
-
   if (__builtin_expect (len != -1, 1))
     {
       if ((size_t) len >= buflen)
index 2dd67813482dfbaec0d450b3d31bab1de2db392b..211ed189bb2b165c4f558bcbaad780cb186041e6 100644 (file)
@@ -128,12 +128,6 @@ __ttyname_r (int fd, char *buf, size_t buflen)
   *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';
 
   ssize_t ret = __readlink (procname, buf, buflen - 1);
-  if (__builtin_expect (ret == -1 && errno == ENOENT, 0))
-    {
-      __set_errno (EBADF);
-      return EBADF;
-    }
-
   if (__builtin_expect (ret == -1 && errno == ENAMETOOLONG, 0))
     {
       __set_errno (ERANGE);
This page took 0.11318 seconds and 5 git commands to generate.