Deleted Added
full compact
read.c (84221) read.c (124811)
1/* $NetBSD: read.c,v 1.8 1997/01/22 00:38:12 cgd Exp $ */
2
3/*-
4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University.

--- 51 unchanged lines hidden (view full) ---

60 * Carnegie Mellon University
61 * Pittsburgh PA 15213-3890
62 *
63 * any improvements or extensions that they make and grant Carnegie the
64 * rights to redistribute these changes.
65 */
66
67#include <sys/cdefs.h>
1/* $NetBSD: read.c,v 1.8 1997/01/22 00:38:12 cgd Exp $ */
2
3/*-
4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University.

--- 51 unchanged lines hidden (view full) ---

60 * Carnegie Mellon University
61 * Pittsburgh PA 15213-3890
62 *
63 * any improvements or extensions that they make and grant Carnegie the
64 * rights to redistribute these changes.
65 */
66
67#include <sys/cdefs.h>
68__FBSDID("$FreeBSD: head/lib/libstand/read.c 84221 2001-09-30 22:28:01Z dillon $");
68__FBSDID("$FreeBSD: head/lib/libstand/read.c 124811 2004-01-21 20:12:23Z jhb $");
69
70#include <sys/param.h>
71#include "stand.h"
72
73ssize_t
74read(int fd, void *dest, size_t bcount)
75{
76 struct open_file *f = &files[fd];

--- 33 unchanged lines hidden (view full) ---

110 return(bcount);
111 dest += ccount;
112 }
113
114 /* will filling the readahead buffer again not help? */
115 if (resid >= SOPEN_RASIZE) {
116 /* bypass the rest of the request and leave the buffer empty */
117 if ((errno = (f->f_ops->fo_read)(f, dest, resid, &cresid)))
69
70#include <sys/param.h>
71#include "stand.h"
72
73ssize_t
74read(int fd, void *dest, size_t bcount)
75{
76 struct open_file *f = &files[fd];

--- 33 unchanged lines hidden (view full) ---

110 return(bcount);
111 dest += ccount;
112 }
113
114 /* will filling the readahead buffer again not help? */
115 if (resid >= SOPEN_RASIZE) {
116 /* bypass the rest of the request and leave the buffer empty */
117 if ((errno = (f->f_ops->fo_read)(f, dest, resid, &cresid)))
118 return(bcount - resid);
118 return (-1);
119 return(bcount - cresid);
120 }
121
122 /* fetch more data */
123 if ((errno = (f->f_ops->fo_read)(f, f->f_rabuf, SOPEN_RASIZE, &cresid)))
119 return(bcount - cresid);
120 }
121
122 /* fetch more data */
123 if ((errno = (f->f_ops->fo_read)(f, f->f_rabuf, SOPEN_RASIZE, &cresid)))
124 return(bcount - resid); /* behave like fread() */
124 return (-1);
125 f->f_raoffset = 0;
126 f->f_ralen = SOPEN_RASIZE - cresid;
127 /* no more data, return what we had */
128 if (f->f_ralen == 0)
129 return(bcount - resid);
130 }
131}
125 f->f_raoffset = 0;
126 f->f_ralen = SOPEN_RASIZE - cresid;
127 /* no more data, return what we had */
128 if (f->f_ralen == 0)
129 return(bcount - resid);
130 }
131}