Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ write(2) — UTek W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

lseek(2)

open(2)

pipe(2)

read(2)



WRITE(2)                COMMAND REFERENCE                WRITE(2)



NAME
     write, writev - write on a file

SYNOPSIS
     cc = write(fd, buf, nbytes)
     int cc;
     int fd;
     char *buf;
     int nbytes;

     #include <sys/types.h>
     #include <sys/uio.h>

     cc = writev(fd, iov, iovcnt)
     int cc;
     int fd;
     struct iovec *iov;
     int iovcnt;

DESCRIPTION
     Write attempts to write nbytes of data to the object
     referenced by the descriptor fd from the buffer pointed to
     by buf.  Writev performs the same action, but gathers the
     output data from iovcnt buffers specified by the members of
     the iovec array: iov[0], iov[1], ..., iov[iovcnt-1].

     Writev is not supported for raw devices (for example, raw
     disks, terminals) nor is it supported for a file located on
     a remote host.

     Write and writev return the number of bytes written in cc.

     For writev, the iovec structure is defined in <sys/uio.h>
     as:

          struct iovec {
               caddr_t   iov_base;
               int  iov_len;
          };


     Each iovec entry specifies the base address and length of an
     area in memory where data is gathered.

     On objects capable of seeking, the write starts at a
     position given by the pointer associated with fd, see
     lseek(2).  Upon return from write, the pointer is
     incremented by the number of bytes actually written.

     Objects that are not capable of seeking always write from
     the current position.  The value of the pointer associated
     with such an object is undefined.



Printed 10/17/86                                                1





WRITE(2)                COMMAND REFERENCE                WRITE(2)



     If the real user is not the super-user, then write clears
     the set-user-id bit on a file.  This prevents penetration of
     system security by a user who "captures" a writable set-
     user-id file owned by the super-user.

DIAGNOSTICS
     Write and writev will fail and the file pointer will remain
     unchanged if one or more of the following are true:

     [EBADF]
         Fd is not a valid descriptor open for writing.

     [EPIPE]
         An attempt is made to write to a pipe that is not open
         for reading by any process.

     [EIO]
         An I/O error occurred while reading from or writing to
         the file system.

     [EPIPE]
         An attempt is made to write to a socket of type
         SOCK_STREAM which is not connected to a peer socket.

     [EFBIG]
         An attempt is made to write a file that exceeds the
         process's file size limit or the maximum file size.

     [EFAULT]
         Part of iov or data to be written to the file points
         outside the process's allocated address space.

     [EMSGSIZE]
         Fd is a socket, and the message sent on it was larger
         than the internal message buffer.

     [ENOTCONN]
         Fd is a socket which is not connected.

     [EDESTADDREQ]
         Fd is a socket, and a required address was omitted from
         the write request on the socket.

     [EWOULDBLOCK]
         Fd is in non-blocking mode, and the write would cause a
         process to block.

     [ENOBUFS]
         Fd is a socket, and the system lacks sufficient buffer
         space to do the write.





Printed 10/17/86                                                2





WRITE(2)                COMMAND REFERENCE                WRITE(2)



     In addition, writev will fail is one or more of the
     following are true:

     [EINVAL]
         One of the iov_len values in the iov array is negative.

     [EINVAL]
         The sum of the iov_len values in the iov array overflows
         a 32-bit integer.

     [EINVAL]
         Iovcnt is less than or equal to 0, or greater than 16.

     [ENXIO]
         Writev was attempted on an unsupported raw device (see
         above).

     [EDFSNOBUF]
         Malloc failed on remote system; try smaller (8k or less)
         write.

RETURN VALUE
     Upon successful completion the number of bytes actually
     written is returned in cc. Otherwise a -1 is returned and
     errno is set to indicate the error.

SEE ALSO
     lseek(2), open(2), pipe(2), read(2).



























Printed 10/17/86                                                3





































































%%index%%
na:72,67;
sy:139,1243;
de:1382,1632;3158,265;
di:3423,1622;5189,665;
rv:5854,259;
se:6113,159;
%%index%%000000000128

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026