libbb: introduce and use xrename and rename_or_warn.

This commit is contained in:
Denis Vlasenko
2008-02-17 14:28:53 +00:00
parent ffae845cfd
commit cb448fe01b
10 changed files with 33 additions and 39 deletions

View File

@@ -344,10 +344,10 @@ static void log_locally(time_t now, char *msg)
sprintf(newFile, "%s.%d", G.logFilePath, i);
if (i == 0) break;
sprintf(oldFile, "%s.%d", G.logFilePath, --i);
rename(oldFile, newFile);
xrename(oldFile, newFile);
}
/* newFile == "f.0" now */
rename(G.logFilePath, newFile);
xrename(G.logFilePath, newFile);
fl.l_type = F_UNLCK;
fcntl(G.logFD, F_SETLKW, &fl);
close(G.logFD);