diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2015-11-28 16:49:13 +0000 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-05-17 15:22:14 +0200 |
commit | 754a768833613e94527ef4403e62858bce189db4 (patch) | |
tree | 329c495b0d477aee3ee0b07242ac575fd068e839 /src/shared | |
parent | 4075ef68ba5e6fc39e3616835a3ac4da66599bda (diff) |
core: expose soft limits on the bus
This is a follow-up for https://github.com/elogind/elogind/pull/1994
See https://github.com/elogind/elogind/pull/1994#issuecomment-160087219
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/bus-util.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index eee8fca14..4b0337b34 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2380,23 +2380,28 @@ int bus_property_get_rlimit( struct rlimit *rl; uint64_t u; rlim_t x; + const char *is_soft; assert(bus); assert(reply); assert(userdata); + is_soft = endswith(property, "Soft"); rl = *(struct rlimit**) userdata; if (rl) - x = rl->rlim_max; + x = is_soft ? rl->rlim_cur : rl->rlim_max; else { struct rlimit buf = {}; int z; + const char *s; + + s = is_soft ? strndupa(property, is_soft - property) : property; - z = rlimit_from_string(strstr(property, "Limit")); + z = rlimit_from_string(strstr(s, "Limit")); assert(z >= 0); getrlimit(z, &buf); - x = buf.rlim_max; + x = is_soft ? buf.rlim_cur : buf.rlim_max; } /* rlim_t might have different sizes, let's map |