- LOCK(&lock);
- for (; index < 1000000; index++) {
- snprintf(template+l-6, 6, "%06d", index);
- if (access(template, F_OK) != 0) {
- UNLOCK(&lock);
- return template;
- }
+ while (retries--) {
+ __randname(template+l-6);
+ if (access(template, F_OK) < 0) return template;