if (__xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode)) {
ttyname (fd)     int 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;  char *name = NULL;  int save = errno;  if (!__isatty (fd))    return NULL;  /* We try using the /proc filesystem.  */  *_fitoa_word (fd, __stpcpy (procname, "/proc/self/fd/"), 10, 0) = '\0';  if (buflen == 0)    {      buflen = 4095;      buf = (char *) malloc (buflen + 1);      if (buf == NULL)	{	  buflen = 0;	  return NULL;	}    }  if (__readlink (procname, buf, buflen) != -1      /* This is for Linux 2.0.  */      && buf[0] != '[')    return buf;  if (__fxstat (_STAT_VER, fd, &st) < 0)    return NULL;  if (dev_pts_available)    {      if (__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);#else	  name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat);#endif	}      else	{	  __set_errno (save);	  dev_pts_available = 0;	}    }  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    }  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    }  return name;}