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