mirror of
https://github.com/systemd/systemd.git
synced 2026-07-11 18:13:31 +00:00
load-fragment: use DEFINE_CONFIG_PARSE_*() macros
This commit is contained in:
@@ -59,7 +59,7 @@ $1.SyslogLevelPrefix, config_parse_bool, 0,
|
||||
$1.LogLevelMax, config_parse_log_level, 0, offsetof($1, exec_context.log_level_max)
|
||||
$1.LogExtraFields, config_parse_log_extra_fields, 0, offsetof($1, exec_context)
|
||||
$1.Capabilities, config_parse_warn_compat, DISABLED_LEGACY, offsetof($1, exec_context)
|
||||
$1.SecureBits, config_parse_exec_secure_bits, 0, offsetof($1, exec_context)
|
||||
$1.SecureBits, config_parse_exec_secure_bits, 0, offsetof($1, exec_context.secure_bits)
|
||||
$1.CapabilityBoundingSet, config_parse_capability_set, 0, offsetof($1, exec_context.capability_bounding_set)
|
||||
$1.AmbientCapabilities, config_parse_capability_set, 0, offsetof($1, exec_context.capability_ambient_set)
|
||||
$1.TimerSlackNSec, config_parse_nsec, 0, offsetof($1, exec_context.timer_slack_nsec)
|
||||
@@ -116,7 +116,7 @@ $1.PrivateNetwork, config_parse_bool, 0,
|
||||
$1.PrivateUsers, config_parse_bool, 0, offsetof($1, exec_context.private_users)
|
||||
$1.ProtectSystem, config_parse_protect_system, 0, offsetof($1, exec_context.protect_system)
|
||||
$1.ProtectHome, config_parse_protect_home, 0, offsetof($1, exec_context.protect_home)
|
||||
$1.MountFlags, config_parse_exec_mount_flags, 0, offsetof($1, exec_context)
|
||||
$1.MountFlags, config_parse_exec_mount_flags, 0, offsetof($1, exec_context.mount_flags)
|
||||
$1.MountAPIVFS, config_parse_bool, 0, offsetof($1, exec_context.mount_apivfs)
|
||||
$1.Personality, config_parse_personality, 0, offsetof($1, exec_context.personality)
|
||||
$1.RuntimeDirectoryPreserve, config_parse_runtime_preserve_mode, 0, offsetof($1, exec_context.runtime_directory_preserve_mode)
|
||||
@@ -155,8 +155,8 @@ $1.KillSignal, config_parse_signal, 0,
|
||||
m4_define(`CGROUP_CONTEXT_CONFIG_ITEMS',
|
||||
`$1.Slice, config_parse_unit_slice, 0, 0
|
||||
$1.CPUAccounting, config_parse_bool, 0, offsetof($1, cgroup_context.cpu_accounting)
|
||||
$1.CPUWeight, config_parse_cpu_weight, 0, offsetof($1, cgroup_context.cpu_weight)
|
||||
$1.StartupCPUWeight, config_parse_cpu_weight, 0, offsetof($1, cgroup_context.startup_cpu_weight)
|
||||
$1.CPUWeight, config_parse_cg_weight, 0, offsetof($1, cgroup_context.cpu_weight)
|
||||
$1.StartupCPUWeight, config_parse_cg_weight, 0, offsetof($1, cgroup_context.startup_cpu_weight)
|
||||
$1.CPUShares, config_parse_cpu_shares, 0, offsetof($1, cgroup_context.cpu_shares)
|
||||
$1.StartupCPUShares, config_parse_cpu_shares, 0, offsetof($1, cgroup_context.startup_cpu_shares)
|
||||
$1.CPUQuota, config_parse_cpu_quota, 0, offsetof($1, cgroup_context)
|
||||
@@ -169,8 +169,8 @@ $1.MemoryLimit, config_parse_memory_limit, 0,
|
||||
$1.DeviceAllow, config_parse_device_allow, 0, offsetof($1, cgroup_context)
|
||||
$1.DevicePolicy, config_parse_device_policy, 0, offsetof($1, cgroup_context.device_policy)
|
||||
$1.IOAccounting, config_parse_bool, 0, offsetof($1, cgroup_context.io_accounting)
|
||||
$1.IOWeight, config_parse_io_weight, 0, offsetof($1, cgroup_context.io_weight)
|
||||
$1.StartupIOWeight, config_parse_io_weight, 0, offsetof($1, cgroup_context.startup_io_weight)
|
||||
$1.IOWeight, config_parse_cg_weight, 0, offsetof($1, cgroup_context.io_weight)
|
||||
$1.StartupIOWeight, config_parse_cg_weight, 0, offsetof($1, cgroup_context.startup_io_weight)
|
||||
$1.IODeviceWeight, config_parse_io_device_weight, 0, offsetof($1, cgroup_context)
|
||||
$1.IOReadBandwidthMax, config_parse_io_limit, 0, offsetof($1, cgroup_context)
|
||||
$1.IOWriteBandwidthMax, config_parse_io_limit, 0, offsetof($1, cgroup_context)
|
||||
|
||||
@@ -1252,42 +1252,7 @@ int config_parse_exec_cpu_affinity(const char *unit,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_exec_secure_bits(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) {
|
||||
|
||||
ExecContext *c = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
/* An empty assignment resets the field */
|
||||
c->secure_bits = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = secure_bits_from_string(rvalue);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to parse secure bits, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
c->secure_bits = r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
DEFINE_CONFIG_PARSE(config_parse_exec_secure_bits, secure_bits_from_string, "Failed to parse secure bits");
|
||||
|
||||
int config_parse_capability_set(
|
||||
const char *unit,
|
||||
@@ -1342,33 +1307,7 @@ int config_parse_capability_set(
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode, exec_utmp_mode, ExecUtmpMode, "Failed to parse utmp mode");
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode");
|
||||
|
||||
int config_parse_exec_mount_flags(
|
||||
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) {
|
||||
|
||||
ExecContext *c = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
assert(data);
|
||||
|
||||
r = mount_propagation_flags_from_string(rvalue, &c->mount_flags);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse mount flag %s, ignoring: %m", rvalue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DEFINE_CONFIG_PARSE_PTR(config_parse_exec_mount_flags, mount_propagation_flags_from_string, unsigned long, "Failed to parse mount flag");
|
||||
|
||||
int config_parse_exec_selinux_context(
|
||||
const char *unit,
|
||||
@@ -3068,62 +3007,8 @@ int config_parse_unit_slice(
|
||||
}
|
||||
|
||||
DEFINE_CONFIG_PARSE_ENUM(config_parse_device_policy, cgroup_device_policy, CGroupDevicePolicy, "Failed to parse device policy");
|
||||
|
||||
int config_parse_cpu_weight(
|
||||
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) {
|
||||
|
||||
uint64_t *weight = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
r = cg_weight_parse(rvalue, weight);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid CPU weight '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_cpu_shares(
|
||||
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) {
|
||||
|
||||
uint64_t *shares = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
r = cg_cpu_shares_parse(rvalue, shares);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid CPU shares '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
DEFINE_CONFIG_PARSE_PTR(config_parse_cg_weight, cg_weight_parse, uint64_t, "Invalid weight");
|
||||
DEFINE_CONFIG_PARSE_PTR(config_parse_cpu_shares, cg_cpu_shares_parse, uint64_t, "Invalid CPU shares");
|
||||
|
||||
int config_parse_cpu_quota(
|
||||
const char *unit,
|
||||
@@ -3402,34 +3287,6 @@ int config_parse_device_allow(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_io_weight(
|
||||
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) {
|
||||
|
||||
uint64_t *weight = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
r = cg_weight_parse(rvalue, weight);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid IO weight '%s', ignoring.", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_io_device_weight(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
@@ -3602,33 +3459,7 @@ int config_parse_io_limit(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_blockio_weight(
|
||||
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) {
|
||||
|
||||
uint64_t *weight = data;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
assert(lvalue);
|
||||
assert(rvalue);
|
||||
|
||||
r = cg_blkio_weight_parse(rvalue, weight);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid block IO weight '%s', ignoring: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
DEFINE_CONFIG_PARSE_PTR(config_parse_blockio_weight, cg_blkio_weight_parse, uint64_t, "Invalid block IO weight");
|
||||
|
||||
int config_parse_blockio_device_weight(
|
||||
const char *unit,
|
||||
@@ -4763,12 +4594,11 @@ void unit_dump_config_items(FILE *f) {
|
||||
{ config_parse_restrict_namespaces, "NAMESPACES" },
|
||||
#endif
|
||||
{ config_parse_cpu_shares, "SHARES" },
|
||||
{ config_parse_cpu_weight, "WEIGHT" },
|
||||
{ config_parse_cg_weight, "WEIGHT" },
|
||||
{ config_parse_memory_limit, "LIMIT" },
|
||||
{ config_parse_device_allow, "DEVICE" },
|
||||
{ config_parse_device_policy, "POLICY" },
|
||||
{ config_parse_io_limit, "LIMIT" },
|
||||
{ config_parse_io_weight, "WEIGHT" },
|
||||
{ config_parse_io_device_weight, "DEVICEWEIGHT" },
|
||||
{ config_parse_blockio_bandwidth, "BANDWIDTH" },
|
||||
{ config_parse_blockio_weight, "WEIGHT" },
|
||||
|
||||
@@ -67,14 +67,13 @@ CONFIG_PARSER_PROTOTYPE(config_parse_environ);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_pass_environ);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_unset_environ);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_unit_slice);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_cpu_weight);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_cg_weight);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_cpu_shares);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_memory_limit);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_tasks_max);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_delegate);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_device_policy);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_device_allow);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_io_weight);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_io_device_weight);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_io_limit);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_blockio_weight);
|
||||
|
||||
Reference in New Issue
Block a user