Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / tests / rmdirmany.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 = 0, count;
14         char dirname[4096];
15
16         if (argc < 3) {
17                 printf("Usage %s dirnamebase 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         for (i = 0; i < count; i++) {
29                 sprintf(dirname, "%s-%d", argv[1], i);
30                 rc = rmdir(dirname);
31                 if (rc) {
32                         printf("rmdir(%s) error: %s\n",
33                                dirname, strerror(errno));
34                         break;
35                 }
36                 if ((i % 10000) == 0)
37                     printf(" - deleted %d (time %ld)\n", i, time(0));
38         }
39         return rc;
40 }