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

spt_writez(2) OSS System Calls Reference Manual
NAME
spt_writez - Writes to a file (thread-aware version)
LIBRARY
H-series and J series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
#include <spthread.h>
ssize_t spt_writez(
int filedes,
void *buffer,
size_t nbytes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the
spt_acceptx(), creat(), creat64(), dup(), spt_dup2x(), spt_fcntlx(), open(),
open64(), pipe(), socket(),orsocketpair() function.
buffer Identifies the buffer containing the data to be written.
nbytes Specifies the number of bytes to write.
DESCRIPTION
The spt_writez() function is a thread-aware version of the write() function.
The spt_writez() function attempts to write nbytes of data to the file associated with the filedes
parameter from the buffer pointed to by the buffer parameter.
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 spt_writez() 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 spt_writez()
function, 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 spt_writez() 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
bytes more in a file before reaching a limit. A write request of 512 bytes returns a value of 20.
The limit reached can be either the end of the physical medium or the value that has been set by
the ulimit() function. The next write of a nonzero number of bytes gives a failure return (except
as noted later).
Upon successful completion, the spt_writez() function returns the number of bytes actually writ-
ten to the file associated with filedes. This number is never greater than the value of nbytes.
If the O_APPEND flag of the file status is set, the file offset is set to the end of the file prior to
each write.
Write requests to a pipe or a FIFO file are handled the same as writes to a regular le with these
exceptions:
7488 Hewlett-Packard Company 527186-023