Whamcloud - gitweb
4d486af68366a01fe0e0fd711ac61b023c0080f4
[fs/lustre-release.git] / lustre / tests / test2.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <fcntl.h>
4 #include <errno.h>
5 #include <sys/stat.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8
9 /* Beware when setting FSROOT that I've not made any attempts to avoid buffer
10  * overruns below--this is a test program, it's a static buffer. */
11 #define FSROOT "/mnt"
12 #define OBD_ITERATIONS 10000
13
14 int main (int argc, char * argv[])
15 {
16         int fd, rc, err = -1;
17         struct stat stat_buf;
18
19         if (argc < 2) {
20                 printf("syntax: %s command\n", argv[0]);
21                 printf("Where command is one of \"setup\" or \"create\".\n");
22                 exit(1);
23         }
24
25         if (!strcmp(argv[1], "setup")) {
26                 printf("This is silly.\n");
27         } else if (!strcmp(argv[1], "create")) {
28                 int i, iter;
29
30                 if (argc < 3) {
31                         printf("create requires a nonzero argument.\n");
32                         exit(1);
33                 }
34
35                 iter = atoi(argv[2]);
36
37                 if (iter < 1) {
38                         printf("create requires a nonzero argument.\n");
39                         exit(1);
40                 }
41                 printf("creating %d files...\n", iter);
42
43                 for (i = 0; i < iter; i++) {
44                         fd = creat(FSROOT "/foo123", S_IRWXU);
45                         close(fd);
46                         unlink(FSROOT "/foo123");
47                 }
48         } else {
49                 printf("Invalid command, run with no arguments for help.\n");
50         }
51
52         return 0;
53 }