Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ readv(2) — UTek W2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

dup(2)

lseek(2)

open(2)

pipe(2)

socket(2)

socketpair(2)



READ(2)                 COMMAND REFERENCE                 READ(2)



NAME
     read, readv - read input

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

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

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

DESCRIPTION
     Read attempts to read nbytes of data from the object
     referenced by the descriptor fd into the buffer pointed to
     by buf.  Readv performs the same action, but scatters the
     input data into iovcnt buffers specified by the members of
     the iovec array: iov[0], iov[1], ..., iov[iovcnt-1].

     Readv is not supported for raw devices (e.g. raw disks,
     terminals) nor is it supported for reading files on remote
     hosts.

     Read and readv return in cc the number of bytes read.

     For readv, 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 should be placed.  Readv will
     always fill an area completely before proceeding to the
     next.

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

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





Printed 10/17/86                                                1





READ(2)                 COMMAND REFERENCE                 READ(2)



     Upon successful completion, read and readv return the number
     of bytes actually read and placed in the buffer.  The system
     guarantees to read the number of bytes requested if the
     descriptor references a file which has that many bytes left
     before the end-of-file, but in no other cases.

     If cc = 0, then end-of-file has been reached.

DIAGNOSTICS
     Read and readv will fail if one or more of the following are
     true:

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

     [EFAULT]
         Buf points outside the allocated address space.

     [EINTR]
         A read from a slow device was interrupted before any
         data arrived by the delivery of a signal.

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

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

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

     In addition, readv may return one of the following errors:

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

     [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
         overflowed a 32-bit integer.

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

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



Printed 10/17/86                                                2





READ(2)                 COMMAND REFERENCE                 READ(2)



RETURN VALUE
     If successful, the number of bytes actually read is returned
     in cc. Otherwise, a -1 is returned and the global variable
     errno is set to indicate the error.

SEE ALSO
     dup(2), lseek(2), open(2), pipe(2), socket(2),
     socketpair(2).















































Printed 10/17/86                                                3





































































%%index%%
na:72,60;
sy:132,1175;
de:1307,1679;3130,421;
di:3551,1486;
rv:5181,265;
se:5446,243;
%%index%%000000000119

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