Fix bug #167 - Build errors on OpenBSD.

- Don't link with -ldl, as it is not needed in most cases
- Don't compile plugins if USE_PLUGINS=NO
- Fix warning about missing newline at end of getopt.h
- Removed the O_NOATIME open() flag from the logging plugin.
- Removed the O_LARGEFILE open() flag. _FILE_OFFSET_BITS is 64.
- Use fsync() if fdatasync() is not available for log file writing.
- Replaced some sprintf() with snprintf() due to compiler warnings (though, they were length limited otherwise).
- Replaced two occurences of strcpy() with memcpy().
This commit is contained in:
Jan Vidar Krey
2011-11-30 12:19:37 +01:00
parent 9981acca08
commit 2396d8555c
6 changed files with 32 additions and 23 deletions

View File

@@ -40,7 +40,8 @@ static void set_error_message(struct plugin_handle* plugin, const char* msg)
static int log_open_file(struct plugin_handle* plugin, struct log_data* data)
{
data->fd = open(data->logfile, O_CREAT | O_APPEND | O_NOATIME | O_LARGEFILE | O_WRONLY, 0664);
int flags = O_CREAT | O_APPEND | O_WRONLY;
data->fd = open(data->logfile, flags, 0664);
return (data->fd != -1);
}
@@ -163,7 +164,12 @@ static void log_message(struct log_data* data, const char *format, ...)
va_end(args);
write(data->fd, logmsg, size + 20);
#ifdef _POSIX_SYNCHRONIZED_IO
fdatasync(data->fd);
#else
fsync(data->fd);
#endif
}
else
{