From ebb980fc218bf055ee4a4369f492e5be7fea2a5e Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 29 Nov 2000 15:36:42 +0000 Subject: 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. --- lib/libc/stdio/fdopen.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib') 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; -- cgit