Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdio This is for completeness only (to make fdopen...



details:   https://anonhg.NetBSD.org/src/rev/53a49682bca2
branches:  trunk
changeset: 499795:53a49682bca2
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 29 15:36:42 2000 +0000

description:
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:

 lib/libc/stdio/fdopen.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r cfbc9a8477eb -r 53a49682bca2 lib/libc/stdio/fdopen.c
--- a/lib/libc/stdio/fdopen.c   Wed Nov 29 15:31:10 2000 +0000
+++ b/lib/libc/stdio/fdopen.c   Wed Nov 29 15:36:42 2000 +0000
@@ -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 @@
                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;



Home | Main Index | Thread Index | Old Index