mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 12:28:58 +00:00
A log file name may now be prefixed by a '-' if it should not be
explicitly fsynced after kernel messages are logged. This option should be syntax compatible with a similar option in Linux syslogd. I've made some small changes to Pekka's patch, hoepfully I haven't goofed anything. PR: 66790 Submitted by: Pekka Savola <pekkas@netcore.fi> Obtained from: Martin Schulze's syslogd MFC after: 1 month
This commit is contained in:
parent
8b5cd5a662
commit
0f2ffc4e31
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=129865
@ -318,6 +318,22 @@ There are five forms:
|
||||
.It
|
||||
A pathname (beginning with a leading slash).
|
||||
Selected messages are appended to the file.
|
||||
.Pp
|
||||
To ensure that kernel messages are written to disk promptly,
|
||||
.Nm
|
||||
calls
|
||||
.Xr fsync 2
|
||||
after writing messages from the kernel.
|
||||
Other messages are not synced explicitly.
|
||||
You may prefix a pathname with the minus sign,
|
||||
.Dq - ,
|
||||
to forego syncing the specified file after every kernel message.
|
||||
Note that you might lose information if the system crashes
|
||||
immediately following a write attempt.
|
||||
Nevertheless, using the
|
||||
.Dq -
|
||||
option may improve performance,
|
||||
especially if the kernel is logging many messages.
|
||||
.It
|
||||
A hostname (preceded by an at
|
||||
.Pq Dq @
|
||||
@ -422,6 +438,10 @@ security.* /var/log/security
|
||||
|
||||
# Log all writes to /dev/console to a separate file.
|
||||
console.* /var/log/console.log
|
||||
|
||||
# Log ipfw messages without syncing after every message.
|
||||
!ipfw
|
||||
*.* -/var/log/ipfw
|
||||
.Ed
|
||||
.Sh IMPLEMENTATION NOTES
|
||||
The
|
||||
|
@ -186,6 +186,8 @@ struct filed {
|
||||
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; /* file-specific flags */
|
||||
#define FFLAG_SYNC 0x01
|
||||
};
|
||||
|
||||
/*
|
||||
@ -1150,7 +1152,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
|
||||
f->f_type = F_UNUSED;
|
||||
errno = e;
|
||||
logerror(f->f_un.f_fname);
|
||||
} else if (flags & SYNC_FILE)
|
||||
} else if ((flags & SYNC_FILE) && (f->f_flags & FFLAG_SYNC))
|
||||
(void)fsync(f->f_file);
|
||||
break;
|
||||
|
||||
@ -1635,7 +1637,7 @@ static void
|
||||
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];
|
||||
@ -1783,6 +1785,12 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
|
||||
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,
|
||||
@ -1806,6 +1814,8 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
|
||||
logerror(p);
|
||||
break;
|
||||
}
|
||||
if (syncfile)
|
||||
f->f_flags |= FFLAG_SYNC;
|
||||
if (isatty(f->f_file)) {
|
||||
if (strcmp(p, ctty) == 0)
|
||||
f->f_type = F_CONSOLE;
|
||||
|
Loading…
Reference in New Issue
Block a user