diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-05-03 19:01:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-05-17 20:36:52 +0200 |
commit | 4f424df760117caa461252b89e9c6680eaee2568 (patch) | |
tree | 1e4e9f716e74b503b644107fc878fb58a5eee129 /src/shared/conf-parser.c | |
parent | 6550c24c7f21ee398a1ca0ab43603b23a3414108 (diff) | |
download | systemd-4f424df760117caa461252b89e9c6680eaee2568.tar.gz |
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.
Diffstat (limited to 'src/shared/conf-parser.c')
-rw-r--r-- | src/shared/conf-parser.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 9b822dd49a..7e5fba4330 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -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; +} |