Back to index

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

Go to the source code of this file.

Defines

#define _PATH_DEVPTMX   _PATH_DEV "ptmx"
#define _PATH_DEVPTS   _PATH_DEV "pts"
#define PTYNAME1   "pqrstuvwxyzabcde";
#define PTYNAME2   "0123456789abcdef";
#define __getpt   __bsd_getpt
#define HAVE_POSIX_OPENPT

Functions

int __bsd_getpt (void)
int __posix_openpt (int oflag)
 weak_alias (__posix_openpt, posix_openpt)

Define Documentation

#define __getpt   __bsd_getpt

Definition at line 98 of file getpt.c.

#define _PATH_DEVPTMX   _PATH_DEV "ptmx"

Definition at line 30 of file getpt.c.

#define _PATH_DEVPTS   _PATH_DEV "pts"

Definition at line 32 of file getpt.c.

Definition at line 99 of file getpt.c.

#define PTYNAME1   "pqrstuvwxyzabcde";

Definition at line 95 of file getpt.c.

#define PTYNAME2   "0123456789abcdef";

Definition at line 96 of file getpt.c.


Function Documentation

int __bsd_getpt ( void  )

Here is the caller graph for this function:

int __posix_openpt ( int  oflag)

Definition at line 39 of file getpt.c.

{
  static int have_no_dev_ptmx;
  int fd;

  if (!have_no_dev_ptmx)
    {
      fd = __open (_PATH_DEVPTMX, oflag);
      if (fd != -1)
       {
         struct statfs fsbuf;
         static int devpts_mounted;

         /* Check that the /dev/pts filesystem is mounted
            or if /dev is a devfs filesystem (this implies /dev/pts).  */
         if (devpts_mounted
             || (__statfs (_PATH_DEVPTS, &fsbuf) == 0
                && fsbuf.f_type == DEVPTS_SUPER_MAGIC)
             || (__statfs (_PATH_DEV, &fsbuf) == 0
                && fsbuf.f_type == DEVFS_SUPER_MAGIC))
           {
             /* Everything is ok.  */
             devpts_mounted = 1;
             return fd;
           }

         /* If /dev/pts is not mounted then the UNIX98 pseudo terminals
             are not usable.  */
         __close (fd);
         have_no_dev_ptmx = 1;
       }
      else
       {
         if (errno == ENOENT || errno == ENODEV)
           have_no_dev_ptmx = 1;
         else
           return -1;
       }
    }

  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

weak_alias ( __posix_openpt  ,
posix_openpt   
)

Definition at line 82 of file getpt.c.

{
  int fd = __posix_openpt (O_RDWR);
  if (fd == -1)
    fd = __bsd_getpt ();
  return fd;
}

Here is the call graph for this function: