<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
.style2 {font-size: 14px}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">sys_write <span class="style2">[fs/read_write.c] </span></span></td>
</tr>
<tr>
<td><p style="margin-left:22px;margin-top:0px"><br />
Writes number of bytes to a device (file, socket, etc.) while advancing the file offset position accordingly. </p>
<p style="margin-left:10px"><strong>Arguments</strong></p>
<table width="100%" border="0" style="margin-left:20px; margin-right:20px">
<tr>
<td width="6%" valign="top"><em>eax</em></td>
<td width="94%">4</td>
</tr>
<tr>
<td valign="top"><em>ebx</em></td>
<td>Device descriptor.</td>
</tr>
<tr>
<td valign="top"><em>ecx</em></td>
<td>Pointer to the buffer containing the data to be written. </td>
</tr>
<tr>
<td valign="top"><em>edx</em></td>
<td>Number of bytes to be written.</td>
</tr>
</table>
<p style="margin-left:10px" ><strong>Return values</strong></p>
<p style="margin-left:22px;margin-right:10px" >If the system call succeeds the return value is the number of bytes written.<br />
If the system call fails the return value is one of the following <em>errno</em> values:</p>
<table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
<tr>
<td><table width="100%" border="0">
<tr>
<td width="10%" valign="top"><code>-EAGAIN </code></td>
<td width="90%"><code>Non-blocking I/O has been selected using O_NONBLOCK and the write would block. </code></td>
</tr>
<tr>
<td valign="top"><code>-EBADF </code></td>
<td><code><em>ebx</em> is not a valid file descriptor or is not open for writing. </code></td>
</tr>
<tr>
<td valign="top"><code>-EFAULT </code></td>
<td><code><em>ecx</em> is outside your accessible address space. </code></td>
</tr>
<tr>
<td valign="top"><code>-EFBIG </code></td>
<td><code>An attempt was made to write a file that exceeds the implementation-defined maximum file size or the process' file size limit, or to write at a position past the maximum allowed offset. </code></td>
</tr>
<tr>
<td valign="top"><code>-EINTR </code></td>
<td><code>The call was interrupted by a signal before any data was written. </code></td>
</tr>
<tr>
<td valign="top"><code>-EINVAL </code></td>
<td><code><em>ebx</em> is attached to an object which is unsuitable for writing; or the file was opened with the O_DIRECT flag, and either the address specified in <em>ecx</em>, the value specified in <em>edx</em>, or the current file offset is not suitably aligned. </code></td>
</tr>
<tr>
<td valign="top"><code>-EIO</code></td>
<td><code>A low-level I/O error occurred while modifying the inode. </code></td>
</tr>
<tr>
<td valign="top"><code>-ENOSPC</code></td>
<td><code>The device containing the file referred to by <em>ebx</em> has no room for the data. </code></td>
</tr>
<tr>
<td height="21" valign="top"><code>-EPIPE </code></td>
<td><code><em>ebx</em> is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive a SIGPIPE signal. (Thus, the write return value is seen only if the program catches, blocks or ignores this signal.) </code></td>
</tr>
</table></td>
</tr>
</table>
<p style="margin-left:10px"><strong>Remarks</strong></p>
<p style="margin-left:22px">A successful return from sys_write does not make any guarantee that data has been committed to disk. In fact, on some buggy implementations, it does not even guarantee that space has successfully been reserved for the data. The only way to be sure is to call <a href="118.html">sys_fsync</a> after you are done writing all your data. </p>
<p style="margin-left:10px"><strong>Compatibility</strong></p>
<p style="margin-left:22px">n/a</p></td>
</tr>
</table></body></html>