|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
#include <sys/stat.h> |
|
|
|
|
|
|
|
|
|
#include "common.h" |
|
|
|
|
#include "log.h" |
|
|
|
|
#include "logfile.h" |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
@ -13,23 +12,17 @@ f2b_logfile_open(f2b_logfile_t *file, const char *filename) {
|
|
|
|
|
|
|
|
|
|
memset(file, 0x0, sizeof(f2b_logfile_t)); |
|
|
|
|
|
|
|
|
|
if (stat(filename, &st) != 0) { |
|
|
|
|
log_msg(log_error, "can't open file %s: %s", filename, strerror(errno)); |
|
|
|
|
if (stat(filename, &st) != 0) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
strncpy(file->path, filename, sizeof(file->path)); |
|
|
|
|
memcpy(&file->st, &st, sizeof(st)); |
|
|
|
|
|
|
|
|
|
if ((file->fd = fopen(filename, "r")) == NULL) { |
|
|
|
|
log_msg(log_error, "can't open file %s: %s", filename, strerror(errno)); |
|
|
|
|
if ((file->fd = fopen(filename, "r")) == NULL) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (fseek(file->fd, 0, SEEK_END) < 0) { |
|
|
|
|
log_msg(log_error, "can't seek to end of file %s: %s", filename, strerror(errno)); |
|
|
|
|
if (fseek(file->fd, 0, SEEK_END) < 0) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|