Skip to content

Commit ef5924a

Browse files
committed
coredump: add zstandard support for coredumps
this will hook libzstd into coredump, using this format as default.
1 parent 2d4f8cf commit ef5924a

File tree

11 files changed

+347
-58
lines changed

11 files changed

+347
-58
lines changed

README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ REQUIREMENTS:
150150
libselinux (optional)
151151
liblzma (optional)
152152
liblz4 >= 1.3.0 / 130 (optional)
153+
libzstd >= 1.4.0 (optional)
153154
libgcrypt (optional)
154155
libqrencode (optional)
155156
libmicrohttpd (optional)

meson.build

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,18 @@ else
11951195
endif
11961196
conf.set10('HAVE_LZ4', have)
11971197

1198+
want_zstd = get_option('zstd')
1199+
if want_zstd != 'false' and not skip_deps
1200+
libzstd = dependency('libzstd',
1201+
required : want_zstd == 'true',
1202+
version : '>= 1.4.0')
1203+
have = libzstd.found()
1204+
else
1205+
have = false
1206+
libzstd = []
1207+
endif
1208+
conf.set10('HAVE_ZSTD', have)
1209+
11981210
want_xkbcommon = get_option('xkbcommon')
11991211
if want_xkbcommon != 'false' and not skip_deps
12001212
libxkbcommon = dependency('xkbcommon',
@@ -1543,6 +1555,7 @@ libsystemd = shared_library(
15431555
dependencies : [threads,
15441556
librt,
15451557
libxz,
1558+
libzstd,
15461559
liblz4],
15471560
link_depends : libsystemd_sym,
15481561
install : true,
@@ -1566,6 +1579,7 @@ install_libsystemd_static = static_library(
15661579
dependencies : [threads,
15671580
librt,
15681581
libxz,
1582+
libzstd,
15691583
liblz4,
15701584
libcap,
15711585
libblkid,
@@ -1727,7 +1741,8 @@ executable(
17271741
dependencies : [threads,
17281742
libxz,
17291743
liblz4,
1730-
libselinux],
1744+
libselinux,
1745+
libzstd],
17311746
install_rpath : rootlibexecdir,
17321747
install : true,
17331748
install_dir : rootlibexecdir)
@@ -1751,7 +1766,8 @@ public_programs += executable(
17511766
libqrencode,
17521767
libxz,
17531768
liblz4,
1754-
libpcre2],
1769+
libpcre2,
1770+
libzstd],
17551771
install_rpath : rootlibexecdir,
17561772
install : true,
17571773
install_dir : rootbindir)
@@ -1906,7 +1922,8 @@ if conf.get('ENABLE_LOGIND') == 1
19061922
link_with : [libshared],
19071923
dependencies : [threads,
19081924
liblz4,
1909-
libxz],
1925+
libxz,
1926+
libzstd],
19101927
install_rpath : rootlibexecdir,
19111928
install : true,
19121929
install_dir : rootbindir)
@@ -2036,7 +2053,8 @@ public_programs += executable(
20362053
libcap,
20372054
libselinux,
20382055
libxz,
2039-
liblz4],
2056+
liblz4,
2057+
libzstd],
20402058
install_rpath : rootlibexecdir,
20412059
install : true,
20422060
install_dir : rootbindir)
@@ -2386,7 +2404,8 @@ if conf.get('ENABLE_MACHINED') == 1
23862404
link_with : [libshared],
23872405
dependencies : [threads,
23882406
libxz,
2389-
liblz4],
2407+
liblz4,
2408+
libzstd],
23902409
install_rpath : rootlibexecdir,
23912410
install : true,
23922411
install_dir : rootbindir)
@@ -2467,7 +2486,8 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_LIBCURL') == 1
24672486
libcurl,
24682487
libgnutls,
24692488
libxz,
2470-
liblz4],
2489+
liblz4,
2490+
libzstd],
24712491
install_rpath : rootlibexecdir,
24722492
install : true,
24732493
install_dir : rootlibexecdir)
@@ -2484,7 +2504,8 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
24842504
libmicrohttpd,
24852505
libgnutls,
24862506
libxz,
2487-
liblz4],
2507+
liblz4,
2508+
libzstd],
24882509
install_rpath : rootlibexecdir,
24892510
install : true,
24902511
install_dir : rootlibexecdir)
@@ -2498,7 +2519,8 @@ if conf.get('ENABLE_REMOTE') == 1 and conf.get('HAVE_MICROHTTPD') == 1
24982519
libmicrohttpd,
24992520
libgnutls,
25002521
libxz,
2501-
liblz4],
2522+
liblz4,
2523+
libzstd],
25022524
install_rpath : rootlibexecdir,
25032525
install : true,
25042526
install_dir : rootlibexecdir)
@@ -2514,7 +2536,8 @@ if conf.get('ENABLE_COREDUMP') == 1
25142536
libacl,
25152537
libdw,
25162538
libxz,
2517-
liblz4],
2539+
liblz4,
2540+
libzstd],
25182541
install_rpath : rootlibexecdir,
25192542
install : true,
25202543
install_dir : rootlibexecdir)
@@ -2526,7 +2549,8 @@ if conf.get('ENABLE_COREDUMP') == 1
25262549
link_with : [libshared],
25272550
dependencies : [threads,
25282551
libxz,
2529-
liblz4],
2552+
liblz4,
2553+
libzstd],
25302554
install_rpath : rootlibexecdir,
25312555
install : true)
25322556
endif
@@ -2541,7 +2565,8 @@ if conf.get('ENABLE_PSTORE') == 1
25412565
libacl,
25422566
libdw,
25432567
libxz,
2544-
liblz4],
2568+
liblz4,
2569+
libzstd],
25452570
install_rpath : rootlibexecdir,
25462571
install : true,
25472572
install_dir : rootlibexecdir)
@@ -3496,6 +3521,7 @@ foreach tuple : [
34963521
['SMACK'],
34973522
['zlib'],
34983523
['xz'],
3524+
['zstd'],
34993525
['lz4'],
35003526
['bzip2'],
35013527
['ACL'],

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ option('xz', type : 'combo', choices : ['auto', 'true', 'false'],
316316
description : 'xz compression support')
317317
option('lz4', type : 'combo', choices : ['auto', 'true', 'false'],
318318
description : 'lz4 compression support')
319+
option('zstd', type : 'combo', choices : ['auto', 'true', 'false'],
320+
description : 'zstd compression support')
319321
option('xkbcommon', type : 'combo', choices : ['auto', 'true', 'false'],
320322
description : 'xkbcommon keymap support')
321323
option('pcre2', type : 'combo', choices : ['auto', 'true', 'false'],

src/basic/build.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@
8787
#define _LZ4_FEATURE_ "-LZ4"
8888
#endif
8989

90+
#if HAVE_ZSTD
91+
#define _ZSTD_FEATURE_ "+ZSTD"
92+
#else
93+
#define _ZSTD_FEATURE_ "-ZSTD"
94+
#endif
95+
9096
#if HAVE_SECCOMP
9197
#define _SECCOMP_FEATURE_ "+SECCOMP"
9298
#else
@@ -146,6 +152,7 @@
146152
_ACL_FEATURE_ " " \
147153
_XZ_FEATURE_ " " \
148154
_LZ4_FEATURE_ " " \
155+
_ZSTD_FEATURE_ " " \
149156
_SECCOMP_FEATURE_ " " \
150157
_BLKID_FEATURE_ " " \
151158
_ELFUTILS_FEATURE_ " " \

src/coredump/coredump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static int save_external_coredump(
420420
goto fail;
421421
}
422422

423-
#if HAVE_XZ || HAVE_LZ4
423+
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
424424
/* If we will remove the coredump anyway, do not compress. */
425425
if (arg_compress && !maybe_remove_external_coredump(NULL, st.st_size)) {
426426

src/coredump/coredumpctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
765765
if (access(filename, R_OK) < 0)
766766
return log_error_errno(errno, "File \"%s\" is not readable: %m", filename);
767767

768-
if (path && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) {
768+
if (path && !ENDSWITH_SET(filename, ".xz", ".lz4", ".zst")) {
769769
*path = TAKE_PTR(filename);
770770

771771
return 0;
@@ -824,7 +824,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
824824
}
825825

826826
if (filename) {
827-
#if HAVE_XZ || HAVE_LZ4
827+
#if HAVE_XZ || HAVE_LZ4 || HAVE_ZSTD
828828
_cleanup_close_ int fdf;
829829

830830
fdf = open(filename, O_RDONLY | O_CLOEXEC);

0 commit comments

Comments
 (0)