VROOT flag is set in union_allocvp
[unix-history] / usr / src / sys / stand.att / write.c
CommitLineData
b0e33720 1/*-
80409bdc
KB
2 * Copyright (c) 1982, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
b0e33720
KB
4 *
5 * %sccs.include.proprietary.c%
6 *
80409bdc 7 * @(#)write.c 8.1 (Berkeley) %G%
b0e33720
KB
8 */
9
10#include <sys/param.h>
38a01dbe 11
61ef809e 12#include <stand.att/saio.h>
b0e33720
KB
13
14#ifndef SMALL
15write(fdesc, buf, count)
16 int fdesc, count;
17 char *buf;
18{
19 register i;
20 register struct iob *file;
21
22 errno = 0;
23 if (fdesc >= 0 && fdesc <= 2) {
24 i = count;
25 while (i--)
26 putchar(*buf++);
27 return (count);
28 }
29 fdesc -= 3;
30 if (fdesc < 0 || fdesc >= SOPEN_MAX ||
31 ((file = &iob[fdesc])->i_flgs&F_ALLOC) == 0) {
32 errno = EBADF;
33 return (-1);
34 }
35 if ((file->i_flgs&F_WRITE) == 0) {
36 errno = EBADF;
37 return (-1);
38 }
39 file->i_cc = count;
40 file->i_ma = buf;
41 file->i_bn = file->i_boff + (file->i_offset / DEV_BSIZE);
42 i = devwrite(file);
43 file->i_offset += count;
44 if (i < 0)
45 errno = file->i_error;
46 return (i);
47}
48#endif