FD_READ(3H) — Pixar Programmer’s Manual — libfd
NAME
fd_read, fd_xread − read from the fast-disk
SYNOPSIS
int fd_read(d, buf, nbytes)
int d;
char ∗buf;
int nbytes;
int fd_xread(d, buf, nbytes)
int d;
char ∗buf;
int nbytes;
DESCRIPTION
Fd_read attempts to read nbytes of data, from the object referenced by the descriptor d on the Fast-Disk, into the buffer pointed to by buf. Fd_xread performs the same action, but assumes that the object pointed to by buf is a location in the data window of the Pixar High-Speed Interface, placed in the virtual address space of the process by mmap(2).
Fd_read and fd_xread start at a position given by the pointer associated with d (see fd_lseek(3H)). Upon successful return from fd_read or fd_xread, the pointer is incremented by the number of bytes actually read. Fd_xread transfers directly from the Fast-Disk into the first four bytes of buf, and it requires that both nbytes and the current position of d be multiples of FD_BLOCKSIZE (4096) bytes.
RETURN VALUE
Upon successful completion, fd_read and fd_xread return the number of bytes actually read and placed in the buffer; this number may be less than nbytes if end-of-file is encountered before the requested number of bytes have been read. Fd_read returns 0 if the file’s pointer was at or beyond end-of-file when it was called. Fd_xread returns 0 if the number of bytes beyond the file’s pointer are not enough for at least one complete 4096-byte block.
On failure, −1 is returned and the global variable errno is set to indicate the error.
ERRORS
Fd_read and fd_xread will fail if one or more of the following are true:
[EBADF] D is not a valid Fast-Disk file descriptor open for reading.
[EFAULT] Buf points outside the allocated address space.
[EIO] An I/O error occurred while reading from the file system.
[EINVAL] Fd_xread was called and either the file’s pointer or the nbytes argument was not an exact multiple of FD_BLOCKSIZE bytes.
SEE ALSO
fd_open(3H), fd_write(3H), fd_lseek(3H), fd(5)
Release β — Last change: 1/24/89