DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

read(D2)


read -- read data from a character device

Synopsis (Not in current DDI version)

   #include <sys/types.h>
   #include <sys/errno.h>
   #include <sys/uio.h>
   #include <sys/cred.h>
   #include <sys/ddi.h>
   

int prefixread(dev_t dev, uio_t *uiop, cred_t *crp);

Description

The driver's read( ) entry point routine is called during the read system call. The read( ) routine is responsible for transferring data from the device to the user data area; it is a named entry point and must be defined as a global symbol.

Arguments


dev
Device number.

uiop
Pointer to the uio(D4) structure that describes where the data is to be stored in user space.

crp
Pointer to the user credential structure for the I/O transaction.

Return values

The read( ) routine should return 0 for success, or the appropriate error number from those listed on the errnos(D5) manual page.

Usage

This entry point is optional, and is valid for non-STREAMS character device drivers only. If this entry point routine is not provided, all read I/O requests will fail with the ENODEV error number. This entry point is called only when the device is open.

The pointer to the user credentials, crp, is available so the driver can check for required privileges. The uio(D4) structure provides the information necessary to determine how much data should be transferred. The uiomove(D3) function provides a convenient way to copy data using the uio structure.

Block drivers that provide a character interface can use physiock(D3) to perform the data transfer with the driver's strategy(D2) routine.

Context and synchronization

User context. The driver can block and can do operations such as copyout(D3) that require access to the requesting process's user-level address space.

Hardware applicability

All

Version applicability

ddi: 1, 2, 3, 4, 5, 5mp, 6, 6mp, 7, 7mp, 7.1, 7.1mp

Differences between versions

Starting with DDI version 8, the read( ) entry point routine is replaced by the biostart(D2) entry point routine.

External dependencies

Named entry point routines must be declared in the driver's Master(DSP/4dsp) file. The declaration for this entry point is $entry read.

References

biostart(D2), drv_priv(D3), errnos(D5), physiock(D3), strategy(D2), uio(D4), uiomove(D3), ureadc(D3), write(D2)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005