summaryrefslogtreecommitdiff
path: root/packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch
diff options
context:
space:
mode:
authorKoen Kooi <koen@openembedded.org>2005-06-30 08:19:37 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2005-06-30 08:19:37 +0000
commitc8e5702127e507e82e6f68a4b8c546803accea9d (patch)
tree00583491f40ecc640f2b28452af995e3a63a09d7 /packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch
parent87ec8ca4d2e2eb4d1c1e1e1a6b46a395d56805b9 (diff)
import clean BK tree at cset 1.3670
Diffstat (limited to 'packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch')
-rw-r--r--packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch225
1 files changed, 225 insertions, 0 deletions
diff --git a/packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch b/packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch
index e69de29bb2..902a1b7351 100644
--- a/packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch
+++ b/packages/glibc/glibc-2.3.2/glibc22-ttyname-devfs.patch
@@ -0,0 +1,225 @@
+--- sysdeps/unix/sysv/linux/ttyname_r.c~ 2001/07/06 04:56:13 1.14
++++ sysdeps/unix/sysv/linux/ttyname_r.c 2002/01/06 02:27:48
+@@ -28,21 +28,24 @@
+
+ #include <stdio-common/_itoa.h>
+
+-static int getttyname_r (char *buf, size_t buflen,
+- dev_t mydev, ino64_t myino, int save,
++static int getttyname_r (const char *prefix, char *buf, size_t buflen,
++ struct stat64 *mystat, int save,
+ int *dostat) internal_function;
+
+ static int
+ internal_function
+-getttyname_r (char *buf, size_t buflen, dev_t mydev, ino64_t myino,
++getttyname_r (const char *prefix, char *buf, size_t buflen, struct stat64 *mystat,
+ int save, int *dostat)
+ {
+ struct stat64 st;
+ DIR *dirstream;
+ struct dirent64 *d;
+- size_t devlen = strlen (buf);
++ size_t devlen = strlen (prefix);
+
+- dirstream = __opendir (buf);
++ memcpy (buf, prefix, devlen);
++ buflen -= devlen;
++
++ dirstream = __opendir (prefix);
+ if (dirstream == NULL)
+ {
+ *dostat = -1;
+@@ -50,7 +53,7 @@
+ }
+
+ while ((d = __readdir64 (dirstream)) != NULL)
+- if ((d->d_fileno == myino || *dostat)
++ if ((d->d_fileno == mystat->st_ino || *dostat)
+ && strcmp (d->d_name, "stdin")
+ && strcmp (d->d_name, "stdout")
+ && strcmp (d->d_name, "stderr"))
+@@ -71,9 +74,9 @@
+
+ if (__xstat64 (_STAT_VER, buf, &st) == 0
+ #ifdef _STATBUF_ST_RDEV
+- && S_ISCHR (st.st_mode) && st.st_rdev == mydev
++ && S_ISCHR (st.st_mode) && st.st_rdev == mystat->st_rdev
+ #else
+- && d->d_fileno == myino && st.st_dev == mydev
++ && d->d_fileno == mystat->st_ino && st.st_dev == mystat->st_dev
+ #endif
+ )
+ {
+@@ -99,7 +102,8 @@
+ struct stat64 st, st1;
+ int dostat = 0;
+ int save = errno;
+- int ret;
++ int ret, i;
++ const char *dirs[] = { "/dev/pts/", "/dev/vc/", "/dev/tts/", 0 };
+
+ /* Test for the absolute minimal size. This makes life easier inside
+ the loop. */
+@@ -139,50 +143,24 @@
+ if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+ return errno;
+
+- /* Prepare the result buffer. */
+- memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
+- buflen -= sizeof ("/dev/pts/") - 1;
++ ret = ENOTTY;
+
+- if (__xstat64 (_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,
+- &dostat);
+-#else
+- ret = getttyname_r (buf, buflen, st.st_dev, st.st_ino, save,
+- &dostat);
+-#endif
+- }
+- else
++ for (i = 0; ret && dirs[i]; i++)
+ {
+- __set_errno (save);
+- ret = ENOENT;
++ if (__xstat64 (_STAT_VER, dirs[i], &st1) == 0 && S_ISDIR (st1.st_mode))
++ ret = getttyname_r (dirs[i], buf, buflen, &st, save, &dostat);
++ else
++ __set_errno (save);
+ }
+
++
+ if (ret && dostat != -1)
+- {
+- buf[sizeof ("/dev/") - 1] = '\0';
+- buflen += sizeof ("pts/") - 1;
+-#ifdef _STATBUF_ST_RDEV
+- ret = getttyname_r (buf, buflen, st.st_rdev, st.st_ino, save,
+- &dostat);
+-#else
+- ret = getttyname_r (buf, buflen, st.st_dev, st.st_ino, save,
+- &dostat);
+-#endif
+- }
++ ret = getttyname_r ("/dev/", buf, buflen, &st, save, &dostat);
+
+ if (ret && dostat != -1)
+ {
+- buf[sizeof ("/dev/") - 1] = '\0';
+ dostat = 1;
+-#ifdef _STATBUF_ST_RDEV
+- ret = getttyname_r (buf, buflen, st.st_rdev, st.st_ino,
+- save, &dostat);
+-#else
+- ret = getttyname_r (buf, buflen, st.st_dev, st.st_ino,
+- save, &dostat);
+-#endif
++ ret = getttyname_r ("/dev/", buf, buflen, &st, save, &dostat);
+ }
+
+ return ret;
+--- sysdeps/unix/sysv/linux/ttyname.c~ 2001/07/06 04:56:13 1.16
++++ sysdeps/unix/sysv/linux/ttyname.c 2002/01/06 02:27:48
+@@ -30,8 +30,8 @@
+
+ char *__ttyname;
+
+-static char *getttyname (const char *dev, dev_t mydev,
+- ino64_t myino, int save, int *dostat)
++static char *getttyname (const char *dev, struct stat64 *mystat,
++ int save, int *dostat)
+ internal_function;
+
+
+@@ -39,7 +39,7 @@
+
+ static char *
+ internal_function
+-getttyname (const char *dev, dev_t mydev, ino64_t myino, int save, int *dostat)
++getttyname (const char *dev, struct stat64 *mystat, int save, int *dostat)
+ {
+ static size_t namelen;
+ struct stat64 st;
+@@ -55,7 +55,7 @@
+ }
+
+ while ((d = __readdir64 (dirstream)) != NULL)
+- if ((d->d_fileno == myino || *dostat)
++ if ((d->d_fileno == mystat->st_ino || *dostat)
+ && strcmp (d->d_name, "stdin")
+ && strcmp (d->d_name, "stdout")
+ && strcmp (d->d_name, "stderr"))
+@@ -78,9 +78,9 @@
+ memcpy (&getttyname_name[devlen], d->d_name, dlen);
+ if (__xstat64 (_STAT_VER, getttyname_name, &st) == 0
+ #ifdef _STATBUF_ST_RDEV
+- && S_ISCHR (st.st_mode) && st.st_rdev == mydev
++ && S_ISCHR (st.st_mode) && st.st_rdev == mystat->st_rdev
+ #else
+- && d->d_fileno == myino && st.st_dev == mydev
++ && d->d_fileno == mystat->st_ino && st.st_dev == mystat->st_dev
+ #endif
+ )
+ {
+@@ -110,9 +110,10 @@
+ char procname[30];
+ struct stat64 st, st1;
+ int dostat = 0;
+- char *name;
++ char *name = NULL;
+ int save = errno;
+- int len;
++ int len, i;
++ const char *dirs[] = { "/dev/pts", "/dev/vc", "/dev/tts", 0 };
+
+ if (!__isatty (fd))
+ return NULL;
+@@ -146,37 +147,21 @@
+ if (__fxstat64 (_STAT_VER, fd, &st) < 0)
+ return NULL;
+
+- if (__xstat64 (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode))
++ for (i = 0; !name && dirs[i]; i++)
+ {
+-#ifdef _STATBUF_ST_RDEV
+- name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat);
+-#else
+- name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat);
+-#endif
++ if (__xstat64 (_STAT_VER, dirs[i], &st1) == 0 && S_ISDIR (st1.st_mode))
++ name = getttyname (dirs[i], &st, save, &dostat);
++ else
++ __set_errno (save);
+ }
+- else
+- {
+- __set_errno (save);
+- name = NULL;
+- }
+-
++
+ if (!name && dostat != -1)
+- {
+-#ifdef _STATBUF_ST_RDEV
+- name = getttyname ("/dev", st.st_rdev, st.st_ino, save, &dostat);
+-#else
+- name = getttyname ("/dev", st.st_dev, st.st_ino, save, &dostat);
+-#endif
+- }
++ name = getttyname ("/dev", &st, save, &dostat);
+
+ if (!name && dostat != -1)
+ {
+ dostat = 1;
+-#ifdef _STATBUF_ST_RDEV
+- name = getttyname ("/dev", st.st_rdev, st.st_ino, save, &dostat);
+-#else
+- name = getttyname ("/dev", st.st_dev, st.st_ino, save, &dostat);
+-#endif
++ name = getttyname ("/dev", &st, save, &dostat);
+ }
+
+ return name;