blob: 546b1eb69a735b3cf4bb39419295140894b4cb13 (
plain) (
blame)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* Reads from the file and checks consistency.
* The buffer should all contain the same character!!
*/
#include <syscall.h>
#include <stdio.h>
#include "pfs.h"
char buffer[BIG];
int main(void)
{
int bytes, j;
int id;
int fsize;
printf("-\n");
id = open("file.1");
fsize = filesize(id);
if (fsize < BIG * TIMES) {
printf("Invalid filesize\n");
close(id);
exit(-1);
}
while (tell(id) <= (fsize-BIG))
{
bytes = read(id, buffer, BIG);
if (bytes != BIG)
{
printf("Buffer not filled, read %d\n", bytes);
close(id);
exit(-1);
}
/* now check for consistency */
for (j = 1; j < BIG; ++j)
{
if (buffer[0] != buffer[j])
{
/* Ooops, inconsistency */
printf("INCONSISTENCY\n");
close(id);
exit(-1);
}
}
}
printf("*-\n");
close(id);
exit(0);
}
|