Back to index

glibc  2.9
Defines | Functions
grantpt.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/statfs.h>
#include "linux_fsinfo.h"
#include <sysdeps/unix/grantpt.c>

Go to the source code of this file.


#define grantpt   static __unix_grantpt


static int __unix_grantpt (int fd)
static int pts_name (int fd, char **pts, size_t buf_len)
int grantpt (int fd)

Define Documentation

#define grantpt   static __unix_grantpt

Definition at line 80 of file grantpt.c.

Function Documentation

static int __unix_grantpt ( int  fd) [static]

Here is the caller graph for this function:

int grantpt ( int  fd)

Definition at line 40 of file grantpt.c.

  struct statfs fsbuf;
#ifdef PATH_MAX
  char _buf[PATH_MAX];
  char _buf[512];
  char *buf = _buf;

  if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf)), 0))
      int save_errno = errno;

      /* Check, if the file descriptor is valid. pts_name returns the
        wrong errno number, so we cannot use that.  */
      if (__libc_fcntl (fd, F_GETFD) == -1 && errno == EBADF)
       return -1;

       /* If the filedescriptor is no TTY, grantpt has to set errno
          to EINVAL.  */
       if (save_errno == ENOTTY)
         __set_errno (EINVAL);
        __set_errno (save_errno);

       return -1;

  if (__statfs (buf, &fsbuf) < 0)
    return -1;

  /* If the slave pseudo terminal lives on a `devpts' filesystem, the
     ownership and access permission are already set.  */
  if (fsbuf.f_type == DEVPTS_SUPER_MAGIC || fsbuf.f_type == DEVFS_SUPER_MAGIC)
    return 0;

  return __unix_grantpt (fd);

Here is the call graph for this function:

static int pts_name ( int  fd,
char **  pts,
size_t  buf_len 
) [static]

Here is the caller graph for this function: