diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-07-07 12:14:17 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-07-07 12:14:17 +0000 |
commit | d7807bfa57f8d164e86816e030da4aa601affd89 (patch) | |
tree | 4f46669c92819a46d8498a162af074f2b6c96012 /sysdeps/unix/sysv | |
parent | a381d207f5ffe5d7816ebaeec862ed0904f1a082 (diff) | |
download | glibc-d7807bfa57f8d164e86816e030da4aa601affd89.tar glibc-d7807bfa57f8d164e86816e030da4aa601affd89.tar.gz glibc-d7807bfa57f8d164e86816e030da4aa601affd89.tar.bz2 glibc-d7807bfa57f8d164e86816e030da4aa601affd89.zip |
Update
1999-07-07 Andreas Schwab <schwab@suse.de>
* sysdeps/unix/sysv/linux/getpt.c: Check that /dev/pts is mounted.
(_PATH_DEVPTS, DEVPTS_SUPER_MAGIC): New definitions.
(_PATH_DEVPTMX): Use _PATH_DEV.
1999-07-07 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* malloc/tst-malloc.c: New file. Tests some basic functionality.
* malloc/Makefile (tests): Add tst-malloc.
* sysdeps/unix/sysv/linux/sparc/ldd-rewrite.sed: New file.
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r-- | sysdeps/unix/sysv/linux/getpt.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c index d2e0f1a7b8..511b9004c0 100644 --- a/sysdeps/unix/sysv/linux/getpt.c +++ b/sysdeps/unix/sysv/linux/getpt.c @@ -20,9 +20,17 @@ #include <errno.h> #include <fcntl.h> #include <stdlib.h> +#include <unistd.h> +#include <paths.h> +#include <sys/statfs.h> + +/* Constant that identifies the `devpts' filesystem. */ +#define DEVPTS_SUPER_MAGIC 0x1cd1 /* Path to the master pseudo terminal cloning device. */ -#define _PATH_DEVPTMX "/dev/ptmx" +#define _PATH_DEVPTMX _PATH_DEV "ptmx" +/* Directory containing the UNIX98 pseudo terminals. */ +#define _PATH_DEVPTS _PATH_DEV "pts" /* Prototype for function that opens BSD-style master pseudo-terminals. */ int __bsd_getpt (void); @@ -38,7 +46,25 @@ __getpt (void) { fd = __open (_PATH_DEVPTMX, O_RDWR); if (fd != -1) - return fd; + { + struct statfs fsbuf; + static int devpts_mounted; + + /* Check that the /dev/pts filesystem is mounted. */ + if (devpts_mounted + || (__statfs (_PATH_DEVPTS, &fsbuf) == 0 + && fsbuf.f_type == DEVPTS_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) |