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 :)
This commit is contained in:
Baptiste Daroussin 2017-04-15 20:37:34 +00:00
parent f739280524
commit 1af6dc18b9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316981
4 changed files with 21 additions and 4 deletions

View File

@ -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 ,

View File

@ -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;

View File

@ -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.

View File

@ -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"