- LOCK(&lock);
- for (; index < 1000000; index++) {
- snprintf(template+l-6, 6, "%06d", index);
- if (access(template, F_OK) != 0) {
- UNLOCK(&lock);
+
+ do {
+ __randname(template+l-6);
+ if (stat(template, &st)) {
+ if (errno != ENOENT) *template = 0;