Back to index

glibc  2.9
Functions | Variables
ptsname.c File Reference
#include <errno.h>
#include <paths.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

Go to the source code of this file.


char * ptsname (int fd)
int __ptsname_r (int fd, char *buf, size_t buflen)


static char buffer [sizeof(_PATH_TTY)+2]

Function Documentation

int __ptsname_r ( int  fd,
char *  buf,
size_t  buflen 

Definition at line 44 of file ptsname.c.

  int save_errno = errno;
  struct stat st;

  if (buf == NULL)
      __set_errno (EINVAL);
      return EINVAL;

  if (!__isatty (fd))
    /* We rely on isatty to set errno properly (i.e. EBADF or ENOTTY).  */
    return errno;

  if (buflen < strlen (_PATH_TTY) + 3)
      __set_errno (ERANGE);
      return ERANGE;

  if (__ttyname_r (fd, buf, buflen) != 0)
    return errno;

  buf[sizeof (_PATH_DEV) - 1] = 't';

  if (__stat (buf, &st) < 0)
    return errno;

  __set_errno (save_errno);
  return 0;

Here is the call graph for this function:

char* ptsname ( int  fd)

Definition at line 34 of file ptsname.c.

  return __ptsname_r (fd, buffer, sizeof (buffer)) != 0 ? NULL : buffer;

Here is the call graph for this function:

Variable Documentation

char buffer[sizeof(_PATH_TTY)+2] [static]

Definition at line 27 of file ptsname.c.