Whamcloud - gitweb
corrected an error made in setepall in test-framework.sh, which affects
[fs/lustre-release.git] / lustre / tests / writeme.c
1 #include <fcntl.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6
7 void usage(char *prog)
8 {
9         printf("usage: %s [-s] filename\n", prog);
10 }
11
12 int main(int argc, char **argv)
13 {
14         int fd, rc;
15         int do_sync = 0;
16         int i = 0;
17         int file_arg = 1;
18         char buf[4096];
19
20         memset(buf, 0, 4096);
21
22         if (argc < 2 || argc > 3) {
23                 usage(argv[0]);
24                 exit(1);
25         }
26
27         if (strcmp(argv[1], "-s") == 0) {
28                 do_sync = 1;
29                 file_arg++;
30         }
31
32         fd = open(argv[file_arg], O_RDWR | O_CREAT, 0600);
33         if (fd == -1) {
34                 printf("Error opening %s\n", argv[1]);
35                 exit(1);
36         }
37
38         while (1) {
39                 sprintf(buf, "write %d\n", i);
40                 rc = write(fd, buf, sizeof(buf));
41                 if (do_sync)
42                         sync();
43                 sleep(1);
44         }
45         return 0;
46 }