Syntax
#include <sys/types.h>
#include <sys/uio.h>
int writev(int descriptor,
struct iovec *io_vector[],
int vector_length)
|
The writev() function is used to write data to a file or socket descriptor. writev() provides a way for the data that is going to be written to be stored in several different buffers (scatter/gather I/O).
Note: When
the write completes successfully, the S_ISUID (set-user-ID) and S_ISGID (set-group-ID)
bits of the file mode will be cleared. If the write is unsuccessful,
the bits are undefined.
Parameters
struct iovec {
void *iov_base;
ssize_t iov_len;
}
iov_base and iov_len are the only fields in iovec used by sockets. iov_base contains the pointer to a buffer and iov_len contains the buffer length. The rest of the fields are reserved.
Authorities
No authorization is required.
Return Value
writev() returns an integer. Possible values are:
Error Conditions
If writev() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
An attempt was made to access an object in a way forbidden by its object access permissions.
The thread does not have access to the specified file, directory, component, or path.
If you are accessing a remote file through the Network File System, update operations to file permissions at the server are not reflected at the client until updates to data that is stored locally by the Network File System take place. (Several options on the Add Mounted File System (ADDMFS) command determine the time between refresh operations of local data.) Access to a remote file may also fail due to different mappings of user IDs (UID) or group IDs (GID) on the local and remote systems.
If writing to a socket, this error code indicates one of the following:
A file descriptor argument was out of range, referred to a file that was not open, or a read or write request was made to a file that is not open for that operation.
A given file descriptor or directory pointer is not valid for this operation. The specified descriptor is incorrect, or does not refer to an open file. Or this writev() request was made to a file that was only open for reading.
The file ID table is missing or damaged.
To recover from this error, run the Reclaim Storage (RCLSTG) command as soon as possible.
An attempt was made to use a system resource that is not available at this time.
A referenced object is damaged. The object cannot be used.
In attempting to use an argument in a call, the system detected an address that is not valid.
While attempting to access a parameter passed to this function, the system detected an address that is not valid.
The size of the object would exceed the system allowed maximum size.
The file is a regular file, nbyte is greater than 0, and the starting offset is greater than or equal to 2GB minus 2 bytes.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
The file resides in a file system that does not support large files, and the starting offset exceeds 2GB minus 2 bytes.
A physical I/O error occurred.
A referenced object may be damaged.
A function needed to allocate storage, but no storage is available.
There is not enough memory to perform the requested function.
The requested operations required additional space on the device and there is no space left. This could also be caused by exceeding the user profile storage limit when creating or transferring ownership of an object.
Insufficient space remains to hold the intended file, directory, or link.
If you are accessing a remote file through the Network File System, the file may have been deleted at the server.
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
When the descriptor refers to a socket, errno could indicate one of the following errors:
This error code can only be returned on sockets that use a connectionless transport service.
A destination address has not been associated with the socket pointed to by the fildes parameter. This error code can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connectionless transport service.
The data to be sent could not be sent atomically because the size specified by nbyte is too large.
This error code can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connectionless transport service.
This error code can only be returned on sockets that use a connection-oriented transport service.
If interaction with a file server is required to access the object, errno could indicate one of the following errors:
If you are accessing a remote file through the Network File System, the file may have been deleted at the server.
Error Messages
Usage Notes
QFileSvr.400 File System Differences
The largest buffer size allowed is 16 megabytes. If a larger buffer is
passed, the error EINVAL will be received.
Related Information
| Top | Integrated File System APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |