Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

write(2) OSS System Calls Reference Manual
NAME
write - Writes to a file
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
ssize_t write(
int filedes,
void *buffer,
size_t nbytes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the accept(),
creat(), creat64(), dup(), dup2( ), fcntl(), open(), open64(), pipe(), socket(),
or socketpair() function.
When the function is thread-aware, specifies an open file descriptor obtained
from a successful call to the creat(), creat64(), dup(), open(), open64(),
pipe( ), socket(),orsocketpair() function, or the thread-aware accept(),
dup2( ),orfcntl( ) function.
buffer Identifies the buffer containing the data to be written.
nbytes Specifies the number of bytes to write.
DESCRIPTION
The write() function attempts to write nbytes of data to the file associated with the filedes
parameter from the buffer pointed to by the buffer parameter.
To pass a 32-bit pointer from a 32-bit Guardian or OSS client, write ) or write64_() may be
called.
To pass a 64-bit pointer from a 32-bit Guardian or OSS client, write64_() must be called.
32-bit Guardian and 64-bit OSS clients can pass 32-bit pointers and 64-bit pointers to
write64_().
For all regular and non-regular files, if the value of the nbytes parameter is 0 (zero) and the value
of filedes is a valid file descriptor, the write( ) function returns 0 (zero).
The appropriate file time fields are updated unless nbytes is 0 (zero).
With regular files and devices capable of seeking, the actual writing of data proceeds from the
position in the file indicated by the file pointer. If this incremented le pointer is greater than the
length of the file, the length of the file is set to this file offset. Upon return from the write( ) func-
tion, the file pointer is incremented by the number of bytes actually written.
With devices incapable of seeking, writing always takes place starting at the current position.
For such devices, the value of the file pointer after a call to the write() function is always 0
(zero).
Fewer bytes than requested can be written if there is not enough room to satisfy the request. In
this case, the number of bytes written is returned. For example, suppose there is space for 20
1014 Hewlett-Packard Company 527186-023