11 void usage(char *prog)
13 printf("usage: %s {-o|-m} filenamefmt count\n", prog);
14 printf(" %s {-o|-m} filenamefmt -seconds\n", prog);
15 printf(" %s {-o|-m} filenamefmt start count\n", prog);
18 int main(int argc, char ** argv)
20 int i, rc = 0, do_open;
21 char format[4096], *fmt;
23 long start, last, end;
24 long begin = 0, count;
26 if (argc < 4 || argc > 5) {
31 if (strcmp(argv[1], "-o") == 0) {
33 } else if (strcmp(argv[1], "-m") == 0) {
40 if (strlen(argv[2]) > 4080) {
41 printf("name too long\n");
45 start = last = time(0);
48 end = strtol(argv[3], NULL, 0);
58 begin = strtol(argv[3], NULL, 0);
59 count = strtol(argv[4], NULL, 0);
62 if (strchr(argv[2], '%'))
65 sprintf(format, "%s%%d", argv[2]);
68 for (i = 0; i < count && time(0) < end; i++, begin++) {
69 sprintf(filename, fmt, begin);
71 int fd = open(filename, O_CREAT|O_RDWR, 0644);
73 printf("open(%s) error: %s\n", filename,
80 rc = mknod(filename, S_IFREG| 0444, 0);
82 printf("mknod(%s) error: %s\n",
83 filename, strerror(errno));
88 if ((i % 10000) == 0) {
89 printf(" - created %d (time %ld ; total %ld ; last %ld)\n",
90 i, time(0), time(0) - start, time(0) - last);
94 printf("total: %d creates in %ld seconds: %f creates/second\n", i,
95 time(0) - start, ((float)i / (time(0) - start)));