88 static uint64_t value;
89 uint64_t random_time_bits;
91 int save_errno = errno;
93 static const char letters[] =
94 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
96#define ATTEMPTS_MIN (62 * 62 * 62)
98#if ATTEMPTS_MIN < TMP_MAX
99 unsigned int attempts = TMP_MAX;
101 unsigned int attempts = ATTEMPTS_MIN;
104 len = strlen(
template);
105 if (len < 6 || memcmp(&
template[len - 6],
"XXXXXX", 6)) {
111 XXXXXX = &
template[len - 6];
114 random_time_bits = time(NULL);
117 value += random_time_bits ^ (pid * pid);
118 for (count = 0; count < attempts; value += 7777, ++count) {
122 XXXXXX[0] = letters[v % 62];
124 XXXXXX[1] = letters[v % 62];
126 XXXXXX[2] = letters[v % 62];
128 XXXXXX[3] = letters[v % 62];
130 XXXXXX[4] = letters[v % 62];
132 XXXXXX[5] = letters[v % 62];
139 if (__lxstat64(_STAT_VER,
template, &st) < 0) {
140 if (errno == ENOENT) {
141 __set_errno(save_errno);