*/
char *logfile;
int fd;
+ /* inode number of the logfile to detect logfile rotation */
+ ino_t ino;
};
static const char *default_classname_table[] = {
{
int old_fd = config->fd;
const char *logfile = config->logfile;
+ struct stat st;
int new_fd;
+ int ret;
if (logfile == NULL) {
debug_close_fd(old_fd);
smb_set_close_on_exec(new_fd);
config->fd = new_fd;
+ ret = fstat(new_fd, &st);
+ if (ret != 0) {
+ log_overflow = true;
+ DBG_ERR("Unable to fstat() new log file '%s': %s\n",
+ logfile, strerror(errno));
+ log_overflow = false;
+ return false;
+ }
+
+ config->ino = st.st_ino;
return true;
}
char name[strlen(config->logfile) + 5];
struct stat st;
int ret;
+ bool reopen = false;
bool ok;
if (maxlog == 0) {
return;
}
- ret = fstat(config->fd, &st);
+ ret = stat(config->logfile, &st);
if (ret != 0) {
return;
}
- if (st.st_size < maxlog ) {
+ if (st.st_size >= maxlog ) {
+ reopen = true;
+ }
+
+ if (st.st_ino != config->ino) {
+ reopen = true;
+ }
+
+ if (!reopen) {
return;
}
}
ret = fstat(config->fd, &st);
if (ret != 0) {
+ config->ino = (ino_t)0;
return;
}
+
+ config->ino = st.st_ino;
+
if (st.st_size < maxlog) {
return;
}