1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29#include <sys/types.h>
30#include <sys/param.h>
31
32extern int PEnvopen ( dev_t, int, int, struct proc * );
33extern int PEnvclose ( dev_t, int, int, struct proc * );
34extern int PEnvread ( long, int, unsigned char *);
35extern int PEnvwrite ( long, int, unsigned char * );
36
37
38nvopen(dev, flag, devtype, pp)
39 dev_t dev;
40 int flag, devtype;
41 struct proc *pp;
42{
43 return PEnvopen(dev,flag,devtype,pp);
44}
45
46
47
48nvclose(dev, flag, mode, pp)
49 dev_t dev;
50 int flag, mode;
51 struct proc *pp;
52{
53 return PEnvclose(dev,flag,mode,pp);
54}
55
56
57
58nvread(dev, uio, ioflag)
59 dev_t dev;
60 struct uio *uio;
61 int ioflag;
62{
63 long offset;
64 long size;
65 int c;
66 unsigned char cc;
67 long read = 0;
68 int error = 0;
69
70 offset = uio->uio_offset;
71 size = uio_resid(uio);
72
73 for (read = 0; read < size; read++, offset++) {
74 error = PEnvread(offset, 1, &cc);
75 if ( error ) {
76 return error;
77 }
78 c = (int)cc;
79 error = ureadc(c, uio);
80 if (error) {
81 return error;
82 }
83 }
84 return error;
85}
86
87
88
89nvwrite(dev_t dev, struct uio *uio, int ioflag)
90{
91 long offset;
92 long size;
93 int c;
94 unsigned char cc;
95 long wrote = 0;
96 int error = 0;
97
98 offset = uio->uio_offset;
99 size = uio_resid(uio);
100
101 for (wrote = 0; wrote < size; wrote++, offset++) {
102 c = uwritec(uio);
103 if (c < 0) {
104 return 0;
105 }
106 cc = (unsigned char)c;
107 error = PEnvwrite(offset, 1, &cc);
108 }
109 return error;
110}
111