This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][BZ #14516] Don't make ttyname fail if procfs isunavailable
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: Masahiro Matsuya <mmatsuya at redhat dot com>
- Date: Fri, 24 Aug 2012 20:05:41 +0530
- Subject: Re: [PATCH][BZ #14516] Don't make ttyname fail if procfs isunavailable
- References: <20120824145037.4611785a@spoyarek>
Ugh, sorry, I forgot to make an analogous change to ttyname_r. Here's
an updated patch with it. I have the testsuite running right now. OK to
commit if there are no regressions?
Regards,
Siddhesh
ChangeLog:
[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.
diff --git a/NEWS b/NEWS
index e16618f..d3d2282 100644
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ Version 2.17
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, 14505
+ 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14505, 14516
* Support for STT_GNU_IFUNC symbols added for s390 and s390x.
Optimized versions of memcpy, memset, and memcmp added for System z10 and
@@ -39,6 +39,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.
+
Version 2.16
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index 3dacd40..d3070c3 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -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)
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index 2dd6781..211ed18 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -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);