1 /* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include <sys/statfs.h>
27 #include "linux_fsinfo.h"
29 /* Path to the master pseudo terminal cloning device. */
30 #define _PATH_DEVPTMX _PATH_DEV "ptmx"
31 /* Directory containing the UNIX98 pseudo terminals. */
32 #define _PATH_DEVPTS _PATH_DEV "pts"
34 /* Prototype for function that opens BSD-style master pseudo-terminals. */
35 int __bsd_getpt (void);
37 /* Open a master pseudo terminal and return its file descriptor. */
39 __posix_openpt (oflag
)
42 static int have_no_dev_ptmx
;
45 if (!have_no_dev_ptmx
)
47 fd
= __open (_PATH_DEVPTMX
, oflag
);
51 static int devpts_mounted
;
53 /* Check that the /dev/pts filesystem is mounted
54 or if /dev is a devfs filesystem (this implies /dev/pts). */
56 || (__statfs (_PATH_DEVPTS
, &fsbuf
) == 0
57 && fsbuf
.f_type
== DEVPTS_SUPER_MAGIC
)
58 || (__statfs (_PATH_DEV
, &fsbuf
) == 0
59 && fsbuf
.f_type
== DEVFS_SUPER_MAGIC
))
61 /* Everything is ok. */
66 /* If /dev/pts is not mounted then the UNIX98 pseudo terminals
73 if (errno
== ENOENT
|| errno
== ENODEV
)
82 weak_alias (__posix_openpt
, posix_openpt
)
88 int fd
= __posix_openpt (O_RDWR
);
95 #define PTYNAME1 "pqrstuvwxyzabcde";
96 #define PTYNAME2 "0123456789abcdef";
98 #define __getpt __bsd_getpt
99 #define HAVE_POSIX_OPENPT
100 #include <sysdeps/unix/bsd/getpt.c>