10 #define BUFSIZE (4096)
12 #define min(a,b) ((a) < (b) ? (a) : (b))
14 int main(int argc, char *argv[])
20 int line, delta, next;
23 const char ok_chars[] = "MonTueWedThuFriSatSun"
24 "JanFebMarAprMayJunJulAugSepOctNovDec"
25 "Line 0123456789 of file, written at:\n";
29 char pathname[256] = "/mnt/lustre/linetest_";
33 strncpy(pathname, argv[1], 255);
37 host = getenv("HOSTNAME");
39 strcat(pathname, host);
42 sleeptime = strtoul(argv[2], NULL, 0);
47 printf("Test file used is: %s at %ds intervals\n", pathname, sleeptime);
49 w_str = fopen(pathname, "wb");
54 read_fd = open(pathname, O_RDONLY);
68 now = time((time_t *)NULL);
70 now_time = asctime(t);
72 printf("iter: %d\n", iter);
74 for (line=next; line<(next+delta); line++) {
75 rc = fprintf(w_str, "Line %8d of file, written at: %s",
77 /* \n comes from ctime() result */
90 /* Check for corruption */
91 offset = ftell(w_str);
92 rc = lseek(read_fd, offset & ~4095, SEEK_SET);
93 if (rc != (offset & ~4095)) {
98 rc = read(read_fd, buf_r, min(100, offset & 4095));
99 if (rc != min(100, offset & 4095)) {
100 printf("rc: %d, off %lu buf: '%s'\n", rc,offset,buf_r);
104 /* Chars from "C" days/months, and above Line */
105 if (strspn(buf_r, ok_chars) != rc) {
106 printf("Corruption detected at %lu on %s",
107 offset & ~4095, now_time);