5 #include <lunaix/status.h>
7 static char alphabets[] = "abcdefghijklmnopqrstuvwxyz"
8 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
11 #define NR_BUFSIZE 4096
17 unsigned int buf[NR_BUFSIZE];
18 char name[NR_NAME_LEN + 1];
19 int fd = open("/dev/rand", O_RDONLY);
21 if (mkdir("testdir") && errno != EEXIST)
23 printf("Unable to mkdir %d\n", errno);
29 printf("Unable to chdir %d\n", errno);
33 int nr_total = NR_REPEAT * NR_BUFSIZE / NR_NAME_LEN;
36 for (int i = 0; i < NR_REPEAT; i++)
38 int n = read(fd, buf, 4096 * sizeof(int));
41 name[k++] = alphabets[buf[j++] % 63];
43 if (k < NR_NAME_LEN) {
49 name[NR_NAME_LEN] = 0;
51 printf("[%04d/%04d] creating: %s\r", cnt, nr_total, name);
52 int fd2 = open(name, O_RDONLY | O_CREAT);
57 if (errno == EDQUOT) {
58 printf("Out of quota\n");
62 printf("Unable to open %d\n", errno);