Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/newsyslog Implement 'E' flag that prevents newsyslog...
details: https://anonhg.NetBSD.org/src/rev/41036430a559
branches: trunk
changeset: 959947:41036430a559
user: otis <otis%NetBSD.org@localhost>
date: Mon Mar 01 21:37:10 2021 +0000
description:
Implement 'E' flag that prevents newsyslog from rotating empty log files.
diffstat:
usr.bin/newsyslog/newsyslog.8 | 11 +++++++++--
usr.bin/newsyslog/newsyslog.c | 16 ++++++++++++++--
2 files changed, 23 insertions(+), 4 deletions(-)
diffs (83 lines):
diff -r 3340d3a91d7d -r 41036430a559 usr.bin/newsyslog/newsyslog.8
--- a/usr.bin/newsyslog/newsyslog.8 Mon Mar 01 21:01:39 2021 +0000
+++ b/usr.bin/newsyslog/newsyslog.8 Mon Mar 01 21:37:10 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: newsyslog.8,v 1.41 2017/10/23 01:06:52 wiz Exp $
+.\" $NetBSD: newsyslog.8,v 1.42 2021/03/01 21:37:10 otis Exp $
.\"
.\" Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
.\" All rights reserved.
@@ -40,7 +40,7 @@
.\"
.\" from FreeBSD: newsyslog.8,v 1.14.2.1 1999/02/25 18:38:33 wollman Exp
.\"
-.Dd June 16, 2012
+.Dd March 1, 2021
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@@ -313,6 +313,13 @@
inserts to indicate that the logs have been trimmed should not be included.
.It Sy c
Create an empty log file if none currently exists.
+.It Sy e
+Do not rotate log file with zero size (empty).
+This flag is mostly usable in conjunction with
+.Ar b
+flag that prevents
+.Nm
+from inserting an ASCII informational message.
.It Sy n
No signal should be sent when the log is trimmed.
.It Sy p
diff -r 3340d3a91d7d -r 41036430a559 usr.bin/newsyslog/newsyslog.c
--- a/usr.bin/newsyslog/newsyslog.c Mon Mar 01 21:01:39 2021 +0000
+++ b/usr.bin/newsyslog/newsyslog.c Mon Mar 01 21:37:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: newsyslog.c,v 1.61 2013/09/05 11:34:40 prlw1 Exp $ */
+/* $NetBSD: newsyslog.c,v 1.62 2021/03/01 21:37:10 otis Exp $ */
/*
* Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
@@ -55,7 +55,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: newsyslog.c,v 1.61 2013/09/05 11:34:40 prlw1 Exp $");
+__RCSID("$NetBSD: newsyslog.c,v 1.62 2021/03/01 21:37:10 otis Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -94,6 +94,7 @@
#define CE_PLAIN0 0x10 /* Do not compress zero'th history file */
#define CE_SYSLPROTOCOL 0x20 /* log in syslog-protocol format,
not configurable but detected at runtime */
+#define CE_NOEMPTY 0x40 /* Do not rotate empty log file */
struct conf_entry {
uid_t uid; /* Owner of log */
@@ -372,6 +373,9 @@
case 'C':
log->flags |= CE_CREATE;
break;
+ case 'E':
+ log->flags |= CE_NOEMPTY;
+ break;
case 'N':
log->flags |= CE_NOSIGNAL;
break;
@@ -462,6 +466,14 @@
return;
}
+ /* Skip rotation of empty log file when flag
+ * E is specified
+ */
+ if (sb.st_size == 0 && (log->flags & CE_NOEMPTY) != 0) {
+ PRHDRINFO(("empty file --> skip log\n"));
+ return;
+ }
+
/* Size of the log file in kB. */
size = ((size_t)sb.st_blocks * S_BLKSIZE) >> 10;
Home |
Main Index |
Thread Index |
Old Index