summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-12-10 11:20:03 +0100
committerLennart Poettering <lennart@poettering.net>2015-12-10 11:20:03 +0100
commite4b0e862252ac5c50c533b46dfe839b7c45639ac (patch)
tree023a5eff1cf2b0cda4c9b4d6b7b4e01e920b7913 /src/shared
parent59c74f21751c5af2e6e5118a8d09c16e0e1efa0f (diff)
parent3c11da9d80e804801575a0a9f6db116e12fdd01d (diff)
Merge pull request #2056 from evverx/expose-soft-limits-on-the-bus
Expose soft limits on the bus
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/bus-util.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index e427cc1470..5c6dc34700 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -2381,23 +2381,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