diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-09-28 22:13:07 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-09-29 11:08:12 -0400 |
commit | 4afbccded23f5144e39a7f7b243393799186ba39 (patch) | |
tree | ae4c23ac79f027b6ad7d511467439a69c364c700 /src/core/dbus-swap.c | |
parent | cdc8982030271785d650af410230397bbb5a4be9 (diff) |
core/swap: advertise Discard over dbus
Diffstat (limited to 'src/core/dbus-swap.c')
-rw-r--r-- | src/core/dbus-swap.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c index 93eae53c29..c854716b48 100644 --- a/src/core/dbus-swap.c +++ b/src/core/dbus-swap.c @@ -55,12 +55,36 @@ static int property_get_priority( return sd_bus_message_append(reply, "i", p); } +static int property_get_discard( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + Swap *s = SWAP(userdata); + const char *p; + + assert(bus); + assert(reply); + assert(s); + + if (s->from_fragment) + p = s->parameters_fragment.discard ?: "none"; + else + p = "none"; + return sd_bus_message_append(reply, "s", p); +} + static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult); const sd_bus_vtable bus_swap_vtable[] = { SD_BUS_VTABLE_START(0), SD_BUS_PROPERTY("What", "s", NULL, offsetof(Swap, what), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Priority", "i", property_get_priority, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), + SD_BUS_PROPERTY("Discard", "s", property_get_discard, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("TimeoutUSec", "t", bus_property_get_usec, offsetof(Swap, timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Swap, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Swap, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), |