Note: this is just a simple port from Martin Schulze's Linux syslogd to FreeBSD 5.2.1. All the credit goes to him, and flames to me ;-) Note: I didn't port the support for buffered pipes. --- syslog.conf.5.orig Thu Feb 13 02:08:56 2003 +++ syslog.conf.5 Sun May 30 09:04:23 2004 @@ -318,6 +318,16 @@ .It A pathname (beginning with a leading slash). Selected messages are appended to the file. +.Pp +FreeBSD by default syncs after writing a message from the kernel; +non-kernel messages are never sync'ed. +You may prefix each entry with the minus ``-'' sign to omit +syncing the file after every logging from the kernel. +Note that you might lose information if the system +crashes right behind a write attempt. +Nevertheless this might give you back some performance, +especially if you log from the kernel +in a very verbose manner. .It A hostname (preceded by an at .Pq Dq @ --- syslogd.c.orig Sun Nov 16 23:51:06 2003 +++ syslogd.c Sun May 30 09:08:24 2004 @@ -184,6 +184,7 @@ int f_prevlen; /* length of f_prevline */ int f_prevcount; /* repetition cnt of prevline */ u_int f_repeatcount; /* number of "repeated" msgs */ + int f_flags; /* store file-specific sync flag */ }; /* @@ -738,7 +739,7 @@ { int pri, flags; - flags = ISKERNEL | SYNC_FILE | ADDDATE; /* fsync after write */ + flags = ISKERNEL | ADDDATE; pri = DEFSPRI; if (*p == '<') { pri = 0; @@ -1130,7 +1131,7 @@ f->f_type = F_UNUSED; errno = e; logerror(f->f_un.f_fname); - } else if (flags & SYNC_FILE) + } else if (flags && f->f_flags & SYNC_FILE) /* never sync non-kernel files */ (void)fsync(f->f_file); break; @@ -1611,7 +1612,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) { struct addrinfo hints, *res; - int error, i, pri; + int error, i, pri, syncfile; const char *p, *q; char *bp; char buf[MAXLINE], ebuf[100]; @@ -1755,6 +1756,12 @@ while (*p == '\t' || *p == ' ') p++; + if (*p == '-') { + syncfile = 0; + p++; + } else + syncfile = 1; + switch (*p) { case '@': (void)strlcpy(f->f_un.f_forw.f_hname, ++p, @@ -1778,6 +1785,8 @@ logerror(p); break; } + if (syncfile) + f->f_flags |= SYNC_FILE; if (isatty(f->f_file)) { if (strcmp(p, ctty) == 0) f->f_type = F_CONSOLE;