diff options
| author | christos <christos@NetBSD.org> | 2000-11-29 15:36:42 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2000-11-29 15:36:42 +0000 |
| commit | ebb980fc218bf055ee4a4369f492e5be7fea2a5e (patch) | |
| tree | a0d306fd5cd66844cbe0d2e1ddacf701775b341c /lib | |
| parent | 8955e88e2f4cf81570cdbf5155a66e04123d3eee (diff) | |
This is for completeness only (to make fdopen symmetric with fopen and freopen)
and to match the documentation. Return an error if "f" was specified and the
file descriptor does not refer to a plain file.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/stdio/fdopen.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libc/stdio/fdopen.c b/lib/libc/stdio/fdopen.c index 015a595cfd7..c0eb30779ca 100644 --- a/lib/libc/stdio/fdopen.c +++ b/lib/libc/stdio/fdopen.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdopen.c,v 1.11 2000/01/22 22:19:19 mycroft Exp $ */ +/* $NetBSD: fdopen.c,v 1.12 2000/11/29 15:36:42 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)fdopen.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: fdopen.c,v 1.11 2000/01/22 22:19:19 mycroft Exp $"); +__RCSID("$NetBSD: fdopen.c,v 1.12 2000/11/29 15:36:42 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -82,6 +82,17 @@ fdopen(fd, mode) return (NULL); } + if (oflags & O_NONBLOCK) { + struct stat st; + if (fstat(fd, &st) == -1) { + return (NULL); + } + if (!S_ISREG(st.st_mode)) { + errno = EFTYPE; + return (NULL); + } + } + if ((fp = __sfp()) == NULL) return (NULL); fp->_flags = flags; |
