Deleted Added
full compact
read.c (276079) read.c (298230)
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.

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

56 * Carnegie Mellon University
57 * Pittsburgh PA 15213-3890
58 *
59 * any improvements or extensions that they make and grant Carnegie the
60 * rights to redistribute these changes.
61 */
62
63#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.

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

56 * Carnegie Mellon University
57 * Pittsburgh PA 15213-3890
58 *
59 * any improvements or extensions that they make and grant Carnegie the
60 * rights to redistribute these changes.
61 */
62
63#include <sys/cdefs.h>
64__FBSDID("$FreeBSD: head/lib/libstand/read.c 276079 2014-12-22 20:42:36Z ian $");
64__FBSDID("$FreeBSD: head/lib/libstand/read.c 298230 2016-04-18 23:09:22Z allanjude $");
65
66#include <sys/param.h>
67#include "stand.h"
68
69ssize_t
70read(int fd, void *dest, size_t bcount)
71{
72 struct open_file *f = &files[fd];
73 size_t resid;
74
75 if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) {
76 errno = EBADF;
77 return (-1);
78 }
79 if (f->f_flags & F_RAW) {
80 twiddle(4);
81 errno = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
65
66#include <sys/param.h>
67#include "stand.h"
68
69ssize_t
70read(int fd, void *dest, size_t bcount)
71{
72 struct open_file *f = &files[fd];
73 size_t resid;
74
75 if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) {
76 errno = EBADF;
77 return (-1);
78 }
79 if (f->f_flags & F_RAW) {
80 twiddle(4);
81 errno = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
82 btodb(f->f_offset), bcount, dest, &resid);
82 btodb(f->f_offset), 0, bcount, dest, &resid);
83 if (errno)
84 return (-1);
85 f->f_offset += resid;
86 return (resid);
87 }
88
89 /*
90 * Optimise reads from regular files using a readahead buffer.

--- 37 unchanged lines hidden ---
83 if (errno)
84 return (-1);
85 f->f_offset += resid;
86 return (resid);
87 }
88
89 /*
90 * Optimise reads from regular files using a readahead buffer.

--- 37 unchanged lines hidden ---