From 1af6dc18b9f21d9d5498066c4c095489d50d8880 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sat, 15 Apr 2017 20:37:34 +0000 Subject: [PATCH] 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 :) --- usr.sbin/newsyslog/newsyslog.8 | 3 ++- usr.sbin/newsyslog/newsyslog.c | 13 +++++++++++-- usr.sbin/newsyslog/newsyslog.conf.5 | 8 +++++++- usr.sbin/newsyslog/pathnames.h | 1 + 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"