static int parse_config(void) { static const ConfigTableItem items[] = { { "Coredump", "Storage", config_parse_coredump_storage, 0, &arg_storage }, { "Coredump", "Compress", config_parse_bool, 0, &arg_compress }, { "Coredump", "ProcessSizeMax", config_parse_iec_uint64, 0, &arg_process_size_max }, { "Coredump", "ExternalSizeMax", config_parse_iec_uint64, 0, &arg_external_size_max }, { "Coredump", "JournalSizeMax", config_parse_iec_size, 0, &arg_journal_size_max }, { "Coredump", "KeepFree", config_parse_iec_uint64, 0, &arg_keep_free }, { "Coredump", "MaxUse", config_parse_iec_uint64, 0, &arg_max_use }, {} }; return config_parse_many("/etc/systemd/coredump.conf", CONF_DIRS_NULSTR("systemd/coredump.conf"), "Coredump\0", config_item_table_lookup, items, false, NULL); }
#include <limits.h> #include <getopt.h> #include "log.h" #include "strv.h" #include "util.h" #include "hashmap.h" #include "path-util.h" #include "conf-files.h" #include "fileio.h" #include "build.h" #include "sysctl-util.h" static char **arg_prefixes = NULL; static const char conf_file_dirs[] = CONF_DIRS_NULSTR("sysctl"); static int apply_all(Hashmap *sysctl_options) { char *property, *value; Iterator i; int r = 0; HASHMAP_FOREACH_KEY(value, property, sysctl_options, i) { int k; k = sysctl_write(property, value); if (k < 0) { log_full_errno(k == -ENOENT ? LOG_INFO : LOG_WARNING, k, "Couldn't write '%s' to '%s', ignoring: %m", value, property); if (r == 0 && k != -ENOENT)
#include <getopt.h> #include <libkmod.h> #include <limits.h> #include <string.h> #include <sys/stat.h> #include "conf-files.h" #include "fd-util.h" #include "log.h" #include "string-util.h" #include "strv.h" #include "util.h" static char **arg_proc_cmdline_modules = NULL; static const char conf_file_dirs[] = CONF_DIRS_NULSTR("modules-load"); static void systemd_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { DISABLE_WARNING_FORMAT_NONLITERAL; log_internalv(priority, 0, file, line, fn, format, args); REENABLE_WARNING; } static int add_modules(const char *p) { _cleanup_strv_free_ char **k = NULL; k = strv_split(p, ","); if (!k) return log_oom();
int parse_sleep_config(const char *verb, char ***_modes, char ***_states) { _cleanup_strv_free_ char **suspend_mode = NULL, **suspend_state = NULL, **hibernate_mode = NULL, **hibernate_state = NULL, **hybrid_mode = NULL, **hybrid_state = NULL; char **modes, **states; const ConfigTableItem items[] = { { "Sleep", "SuspendMode", config_parse_strv, 0, &suspend_mode }, { "Sleep", "SuspendState", config_parse_strv, 0, &suspend_state }, { "Sleep", "HibernateMode", config_parse_strv, 0, &hibernate_mode }, { "Sleep", "HibernateState", config_parse_strv, 0, &hibernate_state }, { "Sleep", "HybridSleepMode", config_parse_strv, 0, &hybrid_mode }, { "Sleep", "HybridSleepState", config_parse_strv, 0, &hybrid_state }, {} }; config_parse_many(PKGSYSCONFDIR "/sleep.conf", CONF_DIRS_NULSTR("systemd/sleep.conf"), "Sleep\0", config_item_table_lookup, items, false, NULL); if (streq(verb, "suspend")) { /* empty by default */ USE(modes, suspend_mode); if (suspend_state) USE(states, suspend_state); else states = strv_new("mem", "standby", "freeze", NULL); } else if (streq(verb, "hibernate")) { if (hibernate_mode) USE(modes, hibernate_mode); else modes = strv_new("platform", "shutdown", NULL); if (hibernate_state) USE(states, hibernate_state); else states = strv_new("disk", NULL); } else if (streq(verb, "hybrid-sleep")) { if (hybrid_mode) USE(modes, hybrid_mode); else modes = strv_new("suspend", "platform", "shutdown", NULL); if (hybrid_state) USE(states, hybrid_state); else states = strv_new("disk", NULL); } else assert_not_reached("what verb"); if ((!modes && !streq(verb, "suspend")) || !states) { strv_free(modes); strv_free(states); return log_oom(); } *_modes = modes; *_states = states; return 0; }
#include <errno.h> #include <getopt.h> #include <limits.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "conf-files.h" #include "fileio.h" #include "log.h" #include "strv.h" #include "util.h" static const char conf_file_dirs[] = CONF_DIRS_NULSTR("binfmt"); static int delete_rule(const char *rule) { _cleanup_free_ char *x = NULL, *fn = NULL; char *e; assert(rule[0]); x = strdup(rule); if (!x) return log_oom(); e = strchrnul(x+1, x[0]); *e = 0; fn = strappend("/proc/sys/fs/binfmt_misc/", x+1);