Whamcloud - gitweb
- add something that prints the time every 10,000 creates
[fs/lustre-release.git] / lustre / tests / createmany.c
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <time.h>
5 #include <errno.h>
6 #include <string.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include <stdlib.h>
10
11 int main(int argc, char ** argv)
12 {
13         int i, rc, count;
14         char filename[4096];
15
16         if (argc < 3) { 
17                 printf("Usage %s filenamebase count\n", argv[0]);
18                 return 1;
19         }
20
21         if (strlen(argv[1]) > 4080) { 
22                 printf("name too long\n");
23                 return 1;
24         }
25
26         count = strtoul(argv[2], NULL, 0);
27
28             
29         for (i=0 ; i < count ; i++) { 
30                 sprintf(filename, "%s-%d", argv[1], i); 
31                 rc = mknod(filename, S_IFREG| 0444, 0);
32                 if (rc) { 
33                         printf("mknod(%s) error: %s\n", 
34                                filename, strerror(errno));
35                         break;
36                 }
37                 if ( (i%10000) == 0 )
38                     printf(" - created %d (time %d)\n", i, time(0));
39         }
40         return rc;
41