1 | /*
|
---|
2 | * $ZEL$
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "test_3100.h"
|
---|
6 |
|
---|
7 | int
|
---|
8 | check_w_block(struct path* path, u_int32_t start, u_int32_t max)
|
---|
9 | {
|
---|
10 | int i, res, first, count;
|
---|
11 | u_int32_t x=0xa5a55a5a;
|
---|
12 |
|
---|
13 | printf("check_w_block: max=0x%08x buf=%p\n", max, buf);
|
---|
14 | for (i=0; i<max; i++) {
|
---|
15 | buf[i]=i;
|
---|
16 | }
|
---|
17 | /*
|
---|
18 | if (lseek(path->p, start, SEEK_SET)!=start) {
|
---|
19 | printf("\nlseek(%s, 0x%08x, SEEK_SET): %s\n",
|
---|
20 | path->name, start, strerror(errno));
|
---|
21 | return -1;
|
---|
22 | }
|
---|
23 |
|
---|
24 | for (i=0; i<max; i++) {
|
---|
25 | res=write(path->p, &x, 4);
|
---|
26 | if (res!=4) {
|
---|
27 | printf("\nwrite(%s, start+%d): %s\n", path->name, i, strerror(errno));
|
---|
28 | return -1;
|
---|
29 | }
|
---|
30 | }
|
---|
31 | */
|
---|
32 | if (lseek(path->p, start, SEEK_SET)!=start) {
|
---|
33 | printf("\nlseek(%s, 0x%08x, SEEK_SET): %s\n",
|
---|
34 | path->name, start, strerror(errno));
|
---|
35 | return -1;
|
---|
36 | }
|
---|
37 |
|
---|
38 | res=write(path->p, buf, 4*max);
|
---|
39 | if (res!=4*max) {
|
---|
40 | printf("\nwrite(%s, ..., 4*%d): %s\n", path->name, max, strerror(errno));
|
---|
41 | return -1;
|
---|
42 | }
|
---|
43 | return -1;
|
---|
44 |
|
---|
45 | for (i=0; i<max; i++) {
|
---|
46 | buf[i]=~i;
|
---|
47 | }
|
---|
48 | if (lseek(path->p, start, SEEK_SET)!=start) {
|
---|
49 | printf("\nlseek(%s, 0x%08x, SEEK_SET): %s\n",
|
---|
50 | path->name, start, strerror(errno));
|
---|
51 | return -1;
|
---|
52 | }
|
---|
53 | for (i=0; i<max; i++) {
|
---|
54 | res=read(path->p, buf+i, 4);
|
---|
55 | if (res!=4) {
|
---|
56 | printf("\nread(%s, start+%d): %s", path->name, i, strerror(errno));
|
---|
57 | return -1;
|
---|
58 | }
|
---|
59 | }
|
---|
60 | first=1; count=0;
|
---|
61 | for (i=0; i<max; i++) {
|
---|
62 | if (buf[i]!=i) {
|
---|
63 | if (first) {
|
---|
64 | printf("\n%s: check_w_block (max=%d):\n",
|
---|
65 | path->name, max);
|
---|
66 | first=0;
|
---|
67 | }
|
---|
68 | if (count<10) printf("[%3d/%p]: %08x --> %08x\n", i, buf+i, i, buf[i]);
|
---|
69 | count++;
|
---|
70 | }
|
---|
71 | }
|
---|
72 | if (count) return -1;
|
---|
73 | return 0;
|
---|
74 | }
|
---|