Deleted Added
full compact
write.c (329145) write.c (332138)
1/* $NetBSD: write.c,v 1.7 1996/06/21 20:29:30 pk 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: write.c,v 1.7 1996/06/21 20:29:30 pk 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: stable/11/stand/libsa/write.c 329132 2018-02-11 19:51:29Z kevans $");
64__FBSDID("$FreeBSD: stable/11/stand/libsa/write.c 332138 2018-04-06 19:21:36Z kevans $");
65
66#include <sys/param.h>
67#include "stand.h"
68
69ssize_t
70write(fd, dest, bcount)
71 int fd;
65
66#include <sys/param.h>
67#include "stand.h"
68
69ssize_t
70write(fd, dest, bcount)
71 int fd;
72 void *dest;
72 const void *dest;
73 size_t bcount;
74{
75 struct open_file *f = &files[fd];
76 size_t resid;
77
78 if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) {
79 errno = EBADF;
80 return (-1);
81 }
82 if (f->f_flags & F_RAW) {
83 twiddle(4);
84 errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
73 size_t bcount;
74{
75 struct open_file *f = &files[fd];
76 size_t resid;
77
78 if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) {
79 errno = EBADF;
80 return (-1);
81 }
82 if (f->f_flags & F_RAW) {
83 twiddle(4);
84 errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
85 btodb(f->f_offset), bcount, dest, &resid);
85 btodb(f->f_offset), bcount, __DECONST(void *, dest),
86 &resid);
86 if (errno)
87 return (-1);
88 f->f_offset += resid;
89 return (resid);
90 }
91 resid = bcount;
92 if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid)))
93 return (-1);
94 return (bcount - resid);
95}
87 if (errno)
88 return (-1);
89 f->f_offset += resid;
90 return (resid);
91 }
92 resid = bcount;
93 if ((errno = (f->f_ops->fo_write)(f, dest, bcount, &resid)))
94 return (-1);
95 return (bcount - resid);
96}