core: initialize priority_set when parsing swap unit files
Fixes: #14524
This commit is contained in:
parent
6afc31615e
commit
eb34a981d6
|
@ -435,7 +435,7 @@ Automount.DirectoryMode, config_parse_mode, 0,
|
|||
Automount.TimeoutIdleSec, config_parse_sec_fix_0, 0, offsetof(Automount, timeout_idle_usec)
|
||||
m4_dnl
|
||||
Swap.What, config_parse_unit_path_printf, 0, offsetof(Swap, parameters_fragment.what)
|
||||
Swap.Priority, config_parse_int, 0, offsetof(Swap, parameters_fragment.priority)
|
||||
Swap.Priority, config_parse_swap_priority, 0, 0
|
||||
Swap.Options, config_parse_unit_string_printf, 0, offsetof(Swap, parameters_fragment.options)
|
||||
Swap.TimeoutSec, config_parse_sec_fix_0, 0, offsetof(Swap, timeout_usec)
|
||||
EXEC_CONTEXT_CONFIG_ITEMS(Swap)m4_dnl
|
||||
|
|
|
@ -5002,3 +5002,51 @@ int config_parse_crash_chvt(
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_swap_priority(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
Swap *s = userdata;
|
||||
int r, priority;
|
||||
|
||||
assert(s);
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
s->parameters_fragment.priority = -1;
|
||||
s->parameters_fragment.priority_set = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = safe_atoi(rvalue, &priority);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid swap pririty '%s', ignoring.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (priority < -1) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Sorry, swap priorities smaller than -1 may only be assigned by the kernel itself, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (priority > 32767) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, 0, "Swap priority out of range, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->parameters_fragment.priority = priority;
|
||||
s->parameters_fragment.priority_set = true;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_status_unit_format);
|
|||
CONFIG_PARSER_PROTOTYPE(config_parse_output_restricted);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_crash_chvt);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_timeout_abort);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_swap_priority);
|
||||
|
||||
/* gperf prototypes */
|
||||
const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
|
||||
|
|
Loading…
Reference in New Issue