1 /* @(#)ffileread.c	1.13 09/06/30 Copyright 1986, 1996-2009 J. Schilling */
2 /*
3  *	Copyright (c) 1986, 1996-2009 J. Schilling
4  */
5 /*
6  * The contents of this file are subject to the terms of the
7  * Common Development and Distribution License, Version 1.0 only
8  * (the "License").  You may not use this file except in compliance
9  * with the License.
10  *
11  * See the file CDDL.Schily.txt in this distribution for details.
12  * A copy of the CDDL is also available via the Internet at
13  * http://www.opensource.org/licenses/cddl1.txt
14  *
15  * When distributing Covered Code, include this CDDL HEADER in each
16  * file and include the License file CDDL.Schily.txt from this distribution.
17  */
18 
19 #include "schilyio.h"
20 
21 EXPORT ssize_t
ffileread(f,buf,len)22 ffileread(f, buf, len)
23 	register FILE	*f;
24 	void	*buf;
25 	size_t	len;
26 {
27 	register int		fd;
28 	register ssize_t	ret;
29 		int		oerrno = geterrno();
30 
31 	down2(f, _IOREAD, _IORW);
32 	fd = fileno(f);
33 
34 	while ((ret = read(fd, buf, len)) < 0 && geterrno() == EINTR) {
35 		/*
36 		 * Set back old 'errno' so we don't change the errno visible
37 		 * to the outside if we did not fail.
38 		 */
39 		seterrno(oerrno);
40 	}
41 	return (ret);
42 }
43