core: move config_parse_limit() to the generic conf-parser.[ch]
That way we can use it in nspawn. Also, while we are at it, let's rename the call config_parse_rlimit(), i.e. insert the "r", to clarify what kind of limit this is about.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "syslog-util.h"
|
||||
#include "time-util.h"
|
||||
#include "utf8.h"
|
||||
#include "rlimit-util.h"
|
||||
|
||||
int config_item_table_lookup(
|
||||
const void *table,
|
||||
@@ -1214,3 +1215,42 @@ int config_parse_mtu(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_rlimit(
|
||||
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) {
|
||||
|
||||
struct rlimit **rl = data, d = {};
|
||||
int r;
|
||||
|
||||
assert(rvalue);
|
||||
assert(rl);
|
||||
|
||||
r = rlimit_parse(ltype, rvalue, &d);
|
||||
if (r == -EILSEQ) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Soft resource limit chosen higher than hard limit, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rl[ltype])
|
||||
*rl[ltype] = d;
|
||||
else {
|
||||
rl[ltype] = newdup(struct rlimit, &d, 1);
|
||||
if (!rl[ltype])
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ int config_parse_ifname(GENERIC_PARSER_ARGS);
|
||||
int config_parse_ip_port(GENERIC_PARSER_ARGS);
|
||||
int config_parse_join_controllers(GENERIC_PARSER_ARGS);
|
||||
int config_parse_mtu(GENERIC_PARSER_ARGS);
|
||||
int config_parse_rlimit(GENERIC_PARSER_ARGS);
|
||||
|
||||
typedef enum Disabled {
|
||||
DISABLED_CONFIGURATION,
|
||||
|
||||
Reference in New Issue
Block a user