aboutsummaryrefslogtreecommitdiff
path: root/man/man3/read.html
blob: 515c3f77b84ecab51ab7b4b0e0b82f0843d217df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<head>
<title>read(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>READ(3)</b><td align=right><b>READ(3)</b>
<tr><td width=20><td colspan=2>
    <br>
<p><font size=+1><b>NAME     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    read, readn, write, pread, pwrite &ndash; read or write file<br>
    
</table>
<p><font size=+1><b>SYNOPSIS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>#include &lt;u.h&gt;<br>
    #include &lt;libc.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long read(int fd, void *buf, long nbytes) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long readn(int fd, void *buf, long nbytes) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long write(int fd, void *buf, long nbytes) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long pread(int fd, void *buf, long nbytes, vlong offset) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    <tt><font size=+1>long pwrite(int fd, void *buf, long nbytes, vlong offset)<br>
    </font></tt>
</table>
<p><font size=+1><b>DESCRIPTION     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <i>Read</i> reads <i>nbytes</i> bytes of data from the offset in the file associated
    with <i>fd</i> into memory at <i>buf</i>. The offset is advanced by the number
    of bytes read. It is not guaranteed that all <i>nbytes</i> bytes will
    be read; for example if the file refers to the console, at most
    one line will be returned. In any event the number of bytes
    read is returned. A return value of 0 is conventionally interpreted
    as end of file. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Readn</i> is just like read, but does successive <i>read</i> calls until
    <i>nbytes</i> have been read, or a read system call returns a non-positive
    count. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Write</i> writes <i>nbytes</i> bytes of data starting at <i>buf</i> to the file
    associated with <i>fd</i> at the file offset. The offset is advanced
    by the number of bytes written. The number of characters actually
    written is returned. It should be regarded as an error if this
    is not the same as requested. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Pread</i> and <i>Pwrite</i> equivalent to a <a href="../man3/seek.html"><i>seek</i>(3)</a> to <i>offset</i> followed by
    a <i>read</i> or <i>write</i>. By combining the operations in a single atomic
    call, they more closely match the 9P protocol (see <i>intro</i>(9p))
    and, more important, permit multiprocess programs to execute multiple
    concurrent read and write operations on the same file
    descriptor without interference.<br>
    
</table>
<p><font size=+1><b>SOURCE     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>/usr/local/plan9/src/lib9/readn.c<br>
    </font></tt>
</table>
<p><font size=+1><b>SEE ALSO    </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <a href="../man3/intro.html"><i>intro</i>(3)</a>, <a href="../man3/open.html"><i>open</i>(3)</a>, <a href="../man3/dup.html"><i>dup</i>(3)</a>, <a href="../man3/pipe.html"><i>pipe</i>(3)</a><br>
    
</table>
<p><font size=+1><b>DIAGNOSTICS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    These functions set <i>errstr</i>.<br>
    
</table>

<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>