summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fvwrite.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>2004-03-02 19:43:51 +0000
committerjkh <jkh@FreeBSD.org>2004-03-02 19:43:51 +0000
commit5a199c908b108f81b40e48ab96db24a3da66d864 (patch)
tree76f7bde5d1cde5faa6c2c322c4edcf9613c618c0 /lib/libc/stdio/fvwrite.c
parent26048a44af4590e43ca7214985e0a738085767f4 (diff)
downloadFreeBSD-src-5a199c908b108f81b40e48ab96db24a3da66d864.zip
FreeBSD-src-5a199c908b108f81b40e48ab96db24a3da66d864.tar.gz
If handed a file pointer we can't write to, set errno properly to EBADF
in order to get SUSv2 conformant behavior in higher level calls like fputs() and puts(). Reviewed by: bde
Diffstat (limited to 'lib/libc/stdio/fvwrite.c')
-rw-r--r--lib/libc/stdio/fvwrite.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 192edf8..cacad7f 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -40,6 +40,7 @@ static char sccsid[] = "@(#)fvwrite.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -67,8 +68,10 @@ __sfvwrite(fp, uio)
if ((len = uio->uio_resid) == 0)
return (0);
/* make sure we can write */
- if (cantwrite(fp))
+ if (cantwrite(fp)) {
+ errno = EBADF;
return (EOF);
+ }
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))
OpenPOWER on IntegriCloud