aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2017-04-15 20:37:34 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2017-04-15 20:37:34 +0000
commit1af6dc18b9f21d9d5498066c4c095489d50d8880 (patch)
treeddfa13b6e178cb4ea5810a75f037267952951bc1
parentf739280524c29ec7279d84bb8292e3c4abbe78a2 (diff)
downloadsrc-1af6dc18b9f21d9d5498066c4c095489d50d8880.tar.gz
src-1af6dc18b9f21d9d5498066c4c095489d50d8880.zip
Add a new Y flag to newsyslog.conf
This makes newsyslog use zstandard to compress log files. Given Z is already taken for gzip and zstandard compression level stands in between gzip and xz (which has the X flag) chosing Y sounds ok :)
Notes
Notes: svn path=/head/; revision=316981
-rw-r--r--usr.sbin/newsyslog/newsyslog.83
-rw-r--r--usr.sbin/newsyslog/newsyslog.c13
-rw-r--r--usr.sbin/newsyslog/newsyslog.conf.58
-rw-r--r--usr.sbin/newsyslog/pathnames.h1
4 files changed, 21 insertions, 4 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index ba3db8a1f200..b7b20dcc9235 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -17,7 +17,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd September 23, 2014
+.Dd April 15, 2017
.Dt NEWSYSLOG 8
.Os
.Sh NAME
@@ -288,6 +288,7 @@ accepted for backwards compatibility.
.Xr bzip2 1 ,
.Xr gzip 1 ,
.Xr xz 1 ,
+.Xr zst 1 ,
.Xr syslog 3 ,
.Xr newsyslog.conf 5 ,
.Xr chown 8 ,
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 0fcc08c72f4e..2fb2ca5e4403 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -100,17 +100,22 @@ __FBSDID("$FreeBSD$");
#define COMPRESS_SUFFIX_XZ ".xz"
#endif
+#ifndef COMPRESS_SUFFIX_ZST
+#define COMPRESS_SUFFIX_ZST ".zst"
+#endif
+
#define COMPRESS_SUFFIX_MAXLEN MAX(MAX(sizeof(COMPRESS_SUFFIX_GZ),sizeof(COMPRESS_SUFFIX_BZ2)),sizeof(COMPRESS_SUFFIX_XZ))
/*
* Compression types
*/
-#define COMPRESS_TYPES 4 /* Number of supported compression types */
+#define COMPRESS_TYPES 5 /* Number of supported compression types */
#define COMPRESS_NONE 0
#define COMPRESS_GZIP 1
#define COMPRESS_BZIP2 2
#define COMPRESS_XZ 3
+#define COMPRESS_ZSTD 4
/*
* Bit-values for the 'flags' parsed from a config-file entry.
@@ -149,7 +154,8 @@ static const struct compress_types compress_type[COMPRESS_TYPES] = {
{ "", "", "" }, /* no compression */
{ "Z", COMPRESS_SUFFIX_GZ, _PATH_GZIP }, /* gzip compression */
{ "J", COMPRESS_SUFFIX_BZ2, _PATH_BZIP2 }, /* bzip2 compression */
- { "X", COMPRESS_SUFFIX_XZ, _PATH_XZ } /* xz compression */
+ { "X", COMPRESS_SUFFIX_XZ, _PATH_XZ }, /* xz compression */
+ { "Y", COMPRESS_SUFFIX_ZST, _PATH_ZSTD } /* zst compression */
};
struct conf_entry {
@@ -1299,6 +1305,9 @@ no_trimat:
case 'x':
working->compress = COMPRESS_XZ;
break;
+ case 'y':
+ working->compress = COMPRESS_ZSTD;
+ break;
case 'z':
working->compress = COMPRESS_GZIP;
break;
diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5
index 0d28aabb2e3a..451f1268b997 100644
--- a/usr.sbin/newsyslog/newsyslog.conf.5
+++ b/usr.sbin/newsyslog/newsyslog.conf.5
@@ -21,7 +21,7 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
-.Dd October 24, 2015
+.Dd April 15, 2017
.Dt NEWSYSLOG.CONF 5
.Os
.Sh NAME
@@ -303,6 +303,12 @@ indicates that
should attempt to save disk space by compressing the rotated
log file using
.Xr xz 1 .
+.It Cm Y
+indicates that
+.Xr newsyslog 8
+should attempt to save disk space by compressing the rotated
+log file using
+.Xr zstd 1 .
.It Cm N
indicates that there is no process which needs to be signaled
when this log file is rotated.
diff --git a/usr.sbin/newsyslog/pathnames.h b/usr.sbin/newsyslog/pathnames.h
index 9c4f8850605b..04c3086a48ef 100644
--- a/usr.sbin/newsyslog/pathnames.h
+++ b/usr.sbin/newsyslog/pathnames.h
@@ -27,3 +27,4 @@ provided "as is" without express or implied warranty.
#define _PATH_BZIP2 "/usr/bin/bzip2"
#define _PATH_GZIP "/usr/bin/gzip"
#define _PATH_XZ "/usr/bin/xz"
+#define _PATH_ZSTD "/usr/bin/zstd"