1read(9E)                      Driver Entry Points                     read(9E)
2
3
4

NAME

6       read - read data from a device
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/errno.h>
11       #include <sys/open.h>
12       #include <sys/uio.h>
13       #include <sys/cred.h>
14       #include <sys/ddi.h>
15       #include <sys/sunddi.h>
16
17
18
19       int prefixread(dev_t dev, struct uio *uio_p, cred_t *cred_p);
20
21

INTERFACE LEVEL

23       Architecture  independent  level  1  (DDI/DKI).  This  entry  point  is
24       optional.
25

PARAMETERS

27       dev        Device number.
28
29
30       uio_p      Pointer to the  uio(9S) structure that describes  where  the
31                  data is to be stored in user space.
32
33
34       cred_p     Pointer to the  user credential structure for the I/O trans‐
35                  action.
36
37

DESCRIPTION

39       The driver  read() routine is called indirectly through  cb_ops(9S)  by
40       the  read(2) system call. The  read() routine should check the validity
41       of the minor number component of dev and the user credential  structure
42       pointed to by  cred_p (if pertinent). The  read() routine should super‐
43       vise the data transfer into the user space described  by  the   uio(9S)
44       structure.
45

RETURN VALUES

47       The   read()  routine  should return  0 for success, or the appropriate
48       error number.
49

EXAMPLES

51       Example 1 read() routine using physio()
52
53
54       The following is an example of a read()  routine  using  physio(9F)  to
55       perform reads from a non-seekable device:
56
57
58               static int
59               xxread(dev_t dev, struct uio *uiop, cred_t *credp)
60               {
61                        int                 rval;
62                        offset_t            off;
63                        int                 instance;
64                        xx_t                xx;
65
66                        instance = getminor(dev);
67                        xx = ddi_get_soft_state(xxstate, instance);
68                        if (xx == NULL)
69                                  return (ENXIO);
70                        off = uiop->uio_loffset;
71                        rval = physio(xxstrategy, NULL, dev, B_READ,
72                                  xxmin, uiop);
73                        uiop->uio_loffset = off;
74                        return (rval);
75               }
76
77

SEE ALSO

79       read(2), write(9E), physio(9F), cb_ops(9S), uio(9S)
80
81
82       Writing Device Drivers
83
84
85
86SunOS 5.11                        19 Nov 1997                         read(9E)
Impressum