diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-09 17:02:12 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-09 17:02:12 +0100 |
commit | dfa1f158749161ca671e8aa589b62019ad9c4e2a (patch) | |
tree | fbea4f87f85b2f834d6ec2b233e54f3df848f59c /src/core/load-fragment.c | |
parent | f094cb287ed535a8f45e0ce61a57a06bec642876 (diff) | |
parent | 412ea7a936ebaa5342a4c2abf48b9e408e6ba5dc (diff) |
Merge pull request #1794 from karelzak/size_limit
core: support IEC suffixes for RLIMIT stuff
Diffstat (limited to 'src/core/load-fragment.c')
-rw-r--r-- | src/core/load-fragment.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 631c49fa65..7f12f26b08 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -1082,6 +1082,49 @@ int config_parse_limit(const char *unit, return 0; } +int config_parse_bytes_limit(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; + uint64_t bytes; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + rl += ltype; + + if (streq(rvalue, "infinity")) + bytes = (uint64_t) RLIM_INFINITY; + else { + int r; + + r = parse_size(rvalue, 1024, &bytes); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue); + return 0; + } + } + + if (!*rl) { + *rl = new(struct rlimit, 1); + if (!*rl) + return log_oom(); + } + + (*rl)->rlim_cur = (*rl)->rlim_max = (rlim_t) bytes; + return 0; +} + #ifdef HAVE_SYSV_COMPAT int config_parse_sysv_priority(const char *unit, const char *filename, |