121 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			121 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!--
 | 
						|
Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2013
 | 
						|
	The President and Fellows of Harvard College.
 | 
						|
 | 
						|
Redistribution and use in source and binary forms, with or without
 | 
						|
modification, are permitted provided that the following conditions
 | 
						|
are met:
 | 
						|
1. Redistributions of source code must retain the above copyright
 | 
						|
   notice, this list of conditions and the following disclaimer.
 | 
						|
2. Redistributions in binary form must reproduce the above copyright
 | 
						|
   notice, this list of conditions and the following disclaimer in the
 | 
						|
   documentation and/or other materials provided with the distribution.
 | 
						|
3. Neither the name of the University nor the names of its contributors
 | 
						|
   may be used to endorse or promote products derived from this software
 | 
						|
   without specific prior written permission.
 | 
						|
 | 
						|
THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
 | 
						|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
						|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 | 
						|
ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
 | 
						|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
						|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 | 
						|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 | 
						|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 | 
						|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 | 
						|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
						|
SUCH DAMAGE.
 | 
						|
-->
 | 
						|
<html>
 | 
						|
<head>
 | 
						|
<title>write</title>
 | 
						|
<link rel="stylesheet" type="text/css" media="all" href="../man.css">
 | 
						|
</head>
 | 
						|
<body bgcolor=#ffffff>
 | 
						|
<h2 align=center>write</h2>
 | 
						|
<h4 align=center>OS/161 Reference Manual</h4>
 | 
						|
 | 
						|
<h3>Name</h3>
 | 
						|
<p>
 | 
						|
write - write data to file
 | 
						|
</p>
 | 
						|
 | 
						|
<h3>Library</h3>
 | 
						|
<p>
 | 
						|
Standard C Library (libc, -lc)
 | 
						|
</p>
 | 
						|
 | 
						|
<h3>Synopsis</h3>
 | 
						|
<p>
 | 
						|
<tt>#include <unistd.h></tt><br>
 | 
						|
<br>
 | 
						|
<tt>ssize_t</tt><br>
 | 
						|
<tt>write(int </tt><em>fd</em><tt>, const void *</tt><em>buf</em><tt>,
 | 
						|
size_t </tt><em>nbytes</em><tt>);</tt>
 | 
						|
</p>
 | 
						|
 | 
						|
<h3>Description</h3>
 | 
						|
<p>
 | 
						|
<tt>write</tt> writes up to <em>buflen</em> bytes to the file
 | 
						|
specified by <em>fd</em>, at the location in the file specified by the
 | 
						|
current seek position of the file, taking the data from the space
 | 
						|
pointed to by <em>buf</em>. The file must be open for writing.
 | 
						|
</p>
 | 
						|
 | 
						|
<p>
 | 
						|
The current seek position of the file is advanced by the number of
 | 
						|
bytes written.
 | 
						|
</p>
 | 
						|
 | 
						|
<p>
 | 
						|
Each write (or <A HREF=read.html>read</A>) operation is atomic
 | 
						|
relative to other I/O to the same file.
 | 
						|
Note that the kernel is not obliged to (and generally cannot) make the
 | 
						|
write atomic with respect to other threads in the same process
 | 
						|
accessing the I/O buffer during the write.
 | 
						|
</p>
 | 
						|
 | 
						|
<h3>Return Values</h3>
 | 
						|
<p>
 | 
						|
The count of bytes written is returned. This count should be
 | 
						|
positive. A return value of 0 means that nothing could be written,
 | 
						|
but that no error occurred; this only occurs at end-of-file on
 | 
						|
fixed-size objects. On error, <tt>write</tt> returns -1 and sets
 | 
						|
<A HREF=errno.html>errno</A> to a suitable error code for the error
 | 
						|
condition encountered.
 | 
						|
</p>
 | 
						|
 | 
						|
<p>
 | 
						|
Note that in some cases, particularly on devices, fewer than
 | 
						|
<em>buflen</em> (but greater than zero) bytes may be written. This
 | 
						|
depends on circumstances and does not necessarily signify
 | 
						|
end-of-file. In most cases, one should loop to make sure that all
 | 
						|
output has actually been written.
 | 
						|
</p>
 | 
						|
 | 
						|
<h3>Errors</h3>
 | 
						|
<p>
 | 
						|
The following error codes should be returned under the conditions
 | 
						|
given. Other error codes may be returned for other cases not
 | 
						|
mentioned here.
 | 
						|
 | 
						|
<table width=90%>
 | 
						|
<tr><td width=5% rowspan=4> </td>
 | 
						|
    <td width=10% valign=top>EBADF</td>
 | 
						|
			<td><em>fd</em> is not a valid file descriptor, or was
 | 
						|
			not opened for writing.</td></tr>
 | 
						|
<tr><td valign=top>EFAULT</td>
 | 
						|
			<td>Part or all of the address space pointed to by
 | 
						|
			<em>buf</em> is invalid.</td></tr>
 | 
						|
<tr><td valign=top>ENOSPC</td>
 | 
						|
			<td>There is no free space remaining on the filesystem
 | 
						|
			containing the file.</td></tr>
 | 
						|
<tr><td valign=top>EIO</td>
 | 
						|
			<td>A hardware I/O error occurred writing
 | 
						|
			the data.</td></tr>
 | 
						|
</table>
 | 
						|
</p>
 | 
						|
 | 
						|
</body>
 | 
						|
</html>
 |