LCOV - code coverage report
Current view: top level - core - dbus-swap.c (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 0 24 0.0 %
Date: 2019-08-22 15:41:25 Functions: 0 7 0.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : /***
       3             :   Copyright © 2010 Maarten Lankhorst
       4             : ***/
       5             : 
       6             : #include "bus-util.h"
       7             : #include "dbus-cgroup.h"
       8             : #include "dbus-execute.h"
       9             : #include "dbus-swap.h"
      10             : #include "string-util.h"
      11             : #include "swap.h"
      12             : #include "unit.h"
      13             : 
      14           0 : static int swap_get_priority(Swap *s) {
      15           0 :         if (s->from_proc_swaps)
      16           0 :                 return s->parameters_proc_swaps.priority;
      17           0 :         if (s->from_fragment)
      18           0 :                 return s->parameters_fragment.priority;
      19           0 :         return -1;
      20             : }
      21             : 
      22           0 : static const char *swap_get_options(Swap *s) {
      23           0 :         if (s->from_fragment)
      24           0 :                 return s->parameters_fragment.options;
      25           0 :         return NULL;
      26             : }
      27             : 
      28           0 : static BUS_DEFINE_PROPERTY_GET(property_get_priority, "i", Swap, swap_get_priority);
      29           0 : static BUS_DEFINE_PROPERTY_GET(property_get_options, "s", Swap, swap_get_options);
      30           0 : static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, swap_result, SwapResult);
      31             : 
      32             : const sd_bus_vtable bus_swap_vtable[] = {
      33             :         SD_BUS_VTABLE_START(0),
      34             :         SD_BUS_PROPERTY("What", "s", NULL, offsetof(Swap, what), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      35             :         SD_BUS_PROPERTY("Priority", "i", property_get_priority, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      36             :         SD_BUS_PROPERTY("Options", "s", property_get_options, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      37             :         SD_BUS_PROPERTY("TimeoutUSec", "t", bus_property_get_usec, offsetof(Swap, timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
      38             :         SD_BUS_PROPERTY("ControlPID", "u", bus_property_get_pid, offsetof(Swap, control_pid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      39             :         SD_BUS_PROPERTY("Result", "s", property_get_result, offsetof(Swap, result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      40             :         SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(Unit, ref_uid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      41             :         SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(Unit, ref_gid), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
      42             :         BUS_EXEC_COMMAND_VTABLE("ExecActivate", offsetof(Swap, exec_command[SWAP_EXEC_ACTIVATE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
      43             :         BUS_EXEC_COMMAND_VTABLE("ExecDeactivate", offsetof(Swap, exec_command[SWAP_EXEC_DEACTIVATE]), SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
      44             :         SD_BUS_VTABLE_END
      45             : };
      46             : 
      47           0 : int bus_swap_set_property(
      48             :                 Unit *u,
      49             :                 const char *name,
      50             :                 sd_bus_message *message,
      51             :                 UnitWriteFlags flags,
      52             :                 sd_bus_error *error) {
      53             : 
      54           0 :         Swap *s = SWAP(u);
      55             : 
      56           0 :         assert(s);
      57           0 :         assert(name);
      58           0 :         assert(message);
      59             : 
      60           0 :         return bus_cgroup_set_property(u, &s->cgroup_context, name, message, flags, error);
      61             : }
      62             : 
      63           0 : int bus_swap_commit_properties(Unit *u) {
      64           0 :         assert(u);
      65             : 
      66           0 :         unit_invalidate_cgroup_members_masks(u);
      67           0 :         unit_realize_cgroup(u);
      68             : 
      69           0 :         return 0;
      70             : }

Generated by: LCOV version 1.14