22 char *filename
= "pwrite_test_XXXXXXX";
27 if ((fd
= mkstemp(filename
)) < 0) e(1);
29 size
= 1 + rand() % 4096;
32 if((wbuf
= malloc(sizeof(char)*size
)) == NULL
) e(2);
34 for(i
= 0; i
< size
; i
++) {
35 wbuf
[i
] = 1 + rand()%127;
38 if ((nwritten
= pwrite(fd
, wbuf
, size
, off
)) < 0) e(3);
39 if ((rbuf
= malloc(sizeof(char)*nwritten
)) == NULL
) e(4);
40 if ((nread
= pread(fd
, rbuf
, nwritten
, off
)) < 0) e(5);
41 if (strncmp(rbuf
, wbuf
, nread
) != 0) e(6);
54 return(-1); /* Unreachable */