modern syntax for asgops & inits cause Donn's latest ccom rejects the old.
[unix-history] / usr / src / old / man / vread.2v
CommitLineData
1f431a5b
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)vread.2v 4.1 (Berkeley) %G%
6.\"
7.TH VREAD 2V deprecated
8.UC 4
9.SH NAME
10vread \- read virtually
11.SH SYNOPSIS
12.nf
13.B vread(fildes, buffer, nbytes)
14.B char *buffer;
15.fi
16.SH DESCRIPTION
17.B N.B.:
18This call is likely to be replaced by more general virtual memory facilities
19in the near future.
20.PP
21A file descriptor is a word returned from a successful
22.I open,
23.I creat,
24.I dup
25or
26.I pipe
27call.
28.I Buffer
29is the location of
30.I nbytes
31contiguous bytes into which the input will be placed.
32It is not guaranteed that all
33.I nbytes
34will be read (see
35.IR read (2)).
36In particular, if the returned value is 0, then end-of-file has been reached.
37.PP
38Unlike
39.IR read (2),
40.I vread
41does not necessarily or immediately fetch the data requested from
42.I fildes,
43but merely insures that the data will be fetched from the file descriptor
44.I "sometime before"
45the first reference to the data, at the system's discretion.
46Thus
47.I vread
48allows the system, among other possibilities,
49to choose to read data on demand,
50with whatever granularity is allowed by the memory management hardware,
51or to just read it in immediately as with
52.I read.
53A companion
54.IR vwrite (2)
55call may be used with
56.I vread
57to provide an efficient mechanism for updating large files.
58The behavior of
59.I vread
60if other processes are writing to
61.I fildes
62is not defined.
63.PP
64Both the address of
65.I buffer
66and the current offset in
67.I fildes
68(as told by
69.IR tell (2))
70must be aligned to a multiple of VALSIZ (defined in
71.B <valign.h> ).
72The library routine
73.IR valloc (3)
74allocates properly aligned blocks from the free list.
75.PP
76Note for non-virtual systems: the
77.I vread
78system call can be simulated (exactly, if less efficiently) by
79.I read.
80If the unit on which a
81.I vread
82is done is not capable of supporting efficient demand initialization
83(e.g. a terminal or a pipe), then the system may choose to treat a call to
84.I vread
85as if it were a call to
86.I read
87at its discretion.
88.SH SEE ALSO
89read(2), write(2), vwrite (2), valloc(3)
90.SH DIAGNOSTICS
91A 0 is returned at end-of-file. If the read was otherwise unsuccessful,
92a -1 is returned. Physical I/O errors, non-aligned or bad buffer addresses,
93preposterous
94.I nbytes,
95file descriptor not that of an input file, and file offset not properly
96aligned can all generate errors.
97.SH BUGS
98You can't
99.I close
100a file descriptor which you have
101.I vread
102from while there are still pages in the file which haven't been fetched by the
103system into your address space. In no case can a file descriptor which had
104such pages at the point of a
105.I vfork
106be closed during the
107.I vfork.
108.PP
109The system refuses to truncate a file to which any process has a pending
110.I vread.
111.PP
112There is no primitive inverting
113.I vread
114to release the binding
115.I vread
116sets up so that the file may be closed.
117This can be only be done, clumsily, by reading another (plain) file onto the
118buffer area, or pulling the break back with
119.IR break (2)
120to completely release the pages.
121.PP
122This call is peculiar to this version of UNIX.
123It will be superseded by more general
124virtual memory facilities in future versions of the system.