1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

coredump: replace Compression= setting by simpler Compress= boolean setting

Let's move things closer to journald's configuration settings, which
knows Compress= already, as a boolean. This makes things more uniform,
but also gives us more freedom to possibly swap out the used compression
algorithm one day.
This commit is contained in:
Lennart Poettering 2014-06-27 19:09:22 +02:00
parent cf677ac1b7
commit 8c9571d0ae
3 changed files with 17 additions and 37 deletions

View File

@ -88,11 +88,11 @@
</varlistentry>
<varlistentry>
<term><varname>Compression=</varname></term>
<term><varname>Compress=</varname></term>
<listitem><para>Controls the type of compression for external
storage. One of <literal>xz</literal> or
<literal>none</literal>.</para>
storage. Takes a boolean argument, defaults to
<literal>yes</literal>.</para>
</listitem>
</varlistentry>

View File

@ -98,29 +98,10 @@ static const char* const coredump_storage_table[_COREDUMP_STORAGE_MAX] = {
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(coredump_storage, CoredumpStorage);
static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage,
CoredumpStorage,
"Failed to parse storage setting");
typedef enum CoredumpCompression {
COREDUMP_COMPRESSION_NONE,
COREDUMP_COMPRESSION_XZ,
_COREDUMP_COMPRESSION_MAX,
_COREDUMP_COMPRESSION_INVALID = -1
} CoredumpCompression;
static const char* const coredump_compression_table[_COREDUMP_COMPRESSION_MAX] = {
[COREDUMP_COMPRESSION_NONE] = "none",
[COREDUMP_COMPRESSION_XZ] = "xz",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(coredump_compression, CoredumpCompression);
static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_compression, coredump_compression,
CoredumpCompression,
"Failed to parse compression setting");
static DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage, CoredumpStorage, "Failed to parse storage setting");
static CoredumpStorage arg_storage = COREDUMP_STORAGE_EXTERNAL;
static CoredumpCompression arg_compression = COREDUMP_COMPRESSION_XZ;
static bool arg_compress = true;
static off_t arg_process_size_max = PROCESS_SIZE_MAX;
static off_t arg_external_size_max = EXTERNAL_SIZE_MAX;
static size_t arg_journal_size_max = JOURNAL_SIZE_MAX;
@ -129,13 +110,13 @@ static off_t arg_max_use = (off_t) -1;
static int parse_config(void) {
static const ConfigTableItem items[] = {
{ "Coredump", "Storage", config_parse_coredump_storage, 0, &arg_storage },
{ "Coredump", "Compression", config_parse_coredump_compression, 0, &arg_compression },
{ "Coredump", "ProcessSizeMax", config_parse_iec_off, 0, &arg_process_size_max },
{ "Coredump", "ExternalSizeMax", config_parse_iec_off, 0, &arg_external_size_max },
{ "Coredump", "JournalSizeMax", config_parse_iec_size, 0, &arg_journal_size_max },
{ "Coredump", "KeepFree", config_parse_iec_off, 0, &arg_keep_free },
{ "Coredump", "MaxUse", config_parse_iec_off, 0, &arg_max_use },
{ "Coredump", "Storage", config_parse_coredump_storage, 0, &arg_storage },
{ "Coredump", "Compress", config_parse_bool, 0, &arg_compress },
{ "Coredump", "ProcessSizeMax", config_parse_iec_off, 0, &arg_process_size_max },
{ "Coredump", "ExternalSizeMax", config_parse_iec_off, 0, &arg_external_size_max },
{ "Coredump", "JournalSizeMax", config_parse_iec_size, 0, &arg_journal_size_max },
{ "Coredump", "KeepFree", config_parse_iec_off, 0, &arg_keep_free },
{ "Coredump", "MaxUse", config_parse_iec_off, 0, &arg_max_use },
{}
};
@ -354,7 +335,7 @@ static int save_external_coredump(
#ifdef HAVE_XZ
/* If we will remove the coredump anyway, do not compress. */
if (maybe_remove_external_coredump(NULL, st.st_size) == 0
&& arg_compression == COREDUMP_COMPRESSION_XZ) {
&& arg_compress) {
_cleanup_free_ char *fn2 = NULL;
char *tmp2;
@ -493,10 +474,9 @@ int main(int argc, char* argv[]) {
/* Ignore all parse errors */
parse_config();
log_debug("Selected storage '%s'.",
coredump_storage_to_string(arg_storage));
log_debug("Selected compression %s.",
coredump_compression_to_string(arg_compression));
log_debug("Selected storage '%s'.", coredump_storage_to_string(arg_storage));
log_debug("Selected compression %s.", yes_no(arg_compress));
r = parse_uid(argv[INFO_UID + 1], &uid);
if (r < 0) {

View File

@ -9,7 +9,7 @@
[Coredump]
#Storage=external
#Compression=xz
#Compress=yes
#ProcessSizeMax=2G
#ExternalSizeMax=2G
#JournalSizeMax=767M