Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdio Add checks for O_NDELAY [which indicates that...
details: https://anonhg.NetBSD.org/src/rev/cfbc9a8477eb
branches: trunk
changeset: 499794:cfbc9a8477eb
user: christos <christos%NetBSD.org@localhost>
date: Wed Nov 29 15:31:10 2000 +0000
description:
Add checks for O_NDELAY [which indicates that we only want plain files],
and return an error if the file was not plain.
diffstat:
lib/libc/stdio/freopen.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diffs (40 lines):
diff -r 0a1d61e385ed -r cfbc9a8477eb lib/libc/stdio/freopen.c
--- a/lib/libc/stdio/freopen.c Wed Nov 29 15:30:20 2000 +0000
+++ b/lib/libc/stdio/freopen.c Wed Nov 29 15:31:10 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: freopen.c,v 1.10 1999/09/20 04:39:28 lukem Exp $ */
+/* $NetBSD: freopen.c,v 1.11 2000/11/29 15:31:10 christos Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)freopen.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: freopen.c,v 1.10 1999/09/20 04:39:28 lukem Exp $");
+__RCSID("$NetBSD: freopen.c,v 1.11 2000/11/29 15:31:10 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -145,6 +145,21 @@
return (NULL);
}
+ if (oflags & O_NONBLOCK) {
+ struct stat st;
+ if (fstat(f, &st) == -1) {
+ sverrno = errno;
+ (void)close(f);
+ errno = sverrno;
+ return (NULL);
+ }
+ if (!S_ISREG(st.st_mode)) {
+ (void)close(f);
+ errno = EFTYPE;
+ return (NULL);
+ }
+ }
+
/*
* If reopening something that was open before on a real file, try
* to maintain the descriptor. Various C library routines (perror)
Home |
Main Index |
Thread Index |
Old Index