|
|
|
@ -533,19 +533,19 @@ static int rotate_file(const char *filename)
|
|
|
|
for (which = 0; which < ARRAY_LEN(suffixes); which++) {
|
|
|
|
for (which = 0; which < ARRAY_LEN(suffixes); which++) {
|
|
|
|
snprintf(new, sizeof(new), "%s.%d%s", filename, x, suffixes[which]);
|
|
|
|
snprintf(new, sizeof(new), "%s.%d%s", filename, x, suffixes[which]);
|
|
|
|
fd = open(new, O_RDONLY);
|
|
|
|
fd = open(new, O_RDONLY);
|
|
|
|
if (fd > -1)
|
|
|
|
if (fd > -1) {
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
else {
|
|
|
|
|
|
|
|
found = 1;
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
if (!found) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Found an empty slot */
|
|
|
|
/* Found an empty slot */
|
|
|
|
for (y = x; y > -1; y--) {
|
|
|
|
for (y = x; y > 0; y--) {
|
|
|
|
for (which = 0; which < ARRAY_LEN(suffixes); which++) {
|
|
|
|
for (which = 0; which < ARRAY_LEN(suffixes); which++) {
|
|
|
|
snprintf(old, sizeof(old), "%s.%d%s", filename, y - 1, suffixes[which]);
|
|
|
|
snprintf(old, sizeof(old), "%s.%d%s", filename, y - 1, suffixes[which]);
|
|
|
|
fd = open(old, O_RDONLY);
|
|
|
|
fd = open(old, O_RDONLY);
|
|
|
|
|