[PATCH] grantpt errno values
Thorsten Kukuk
kukuk@suse.de
Mon Dec 10 06:52:00 GMT 2001
Hi,
That, was formerly was called "Austin Draft", requires that grantpt
returns EBADF for a bad file descriptor and EINVAL if it is not a
master pty.
Since we are allowed to define errno for __pts_name_r, I make a little
change to it: The errno value from isatty will not longer be overwritten,
instead we return EBADF if the file descriptor is not valid and
ENOTTY else. grantpt will change ENOTTY to EINVAL. With this, we
passes the test suite.
Thorsten
--
Thorsten Kukuk http://www.suse.de/~kukuk/ kukuk@suse.de
SuSE GmbH Deutschherrenstr. 15-19 D-90429 Nuernberg
--------------------------------------------------------------------
Key fingerprint = A368 676B 5E1B 3E46 CFCE 2D97 F8FD 4E23 56C6 FB4B
-------------- next part --------------
2001-12-10 Thorsten Kukuk <kukuk@suse.de>
* sysdeps/unix/sysv/linux/grantpt.c: Change ENOTTY errors
of pts_name to EINVAL.
* sysdeps/unix/sysv/linux/ptsname.c (__ptsname_r): Don't
overwrite errno value of isatty call (correct one is needed
by grantpt).
--- sysdeps/unix/sysv/linux/grantpt.c
+++ sysdeps/unix/sysv/linux/grantpt.c 2001/12/10 09:31:15
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <sys/statfs.h>
@@ -46,7 +47,11 @@
char *buf = _buf;
if (pts_name (fd, &buf, sizeof (_buf)))
- return -1;
+ {
+ if (errno == ENOTTY)
+ __set_errno (EINVAL);
+ return -1;
+ }
if (__statfs (buf, &fsbuf) < 0)
return -1;
--- sysdeps/unix/sysv/linux/ptsname.c
+++ sysdeps/unix/sysv/linux/ptsname.c 2001/12/10 09:31:15
@@ -85,8 +85,7 @@
if (!__isatty (fd))
{
- __set_errno (ENOTTY);
- return ENOTTY;
+ return errno;
}
#ifdef TIOCGPTN
More information about the Libc-hacker
mailing list