11 void usage(char *prog)
13 printf("usage: %s filenamefmt count\n", prog);
14 printf(" %s filenamefmt start count\n", prog);
17 int main(int argc, char ** argv)
19 int i, rc = 0, do_rmdir = 0;
20 char format[4096], *fmt;
23 long begin = 0, count;
25 if (argc < 3 || argc > 5) {
30 if (strcmp(argv[1], "-d") == 0) {
36 if (strlen(argv[1]) > 4080) {
37 printf("name too long\n");
41 start = last = time(0);
44 count = strtol(argv[2], NULL, 0);
46 printf("count must be at least one\n");
50 begin = strtol(argv[2], NULL, 0);
51 count = strtol(argv[3], NULL, 0);
54 if (strchr(argv[1], '%')) {
57 sprintf(format, "%s%%d", argv[1]);
60 for (i = 0; i < count; i++, begin++) {
61 sprintf(filename, fmt, begin);
65 rc = unlink(filename);
67 printf("%s(%s) error: %s\n",
68 do_rmdir ? "rmdir" : "unlink",
69 filename, strerror(errno));
73 if ((i % 10000) == 0) {
74 printf(" - unlinked %d (time %ld ; total %ld ; last "
75 "%ld)\n", i, time(0), time(0) - start,
80 printf("total: %d unlinks in %ld seconds: %f unlinks/second\n", i,
81 time(0) - start, ((float)i / (time(0) - start)));