Revert (partial) "tree-wide: remove various unused functions"
authorAdrian Szyndela <adrian.s@samsung.com>
Thu, 5 Mar 2020 09:52:04 +0000 (10:52 +0100)
committerŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 25 Jan 2024 12:36:08 +0000 (13:36 +0100)
This partially reverts commit 5dd9527883e0aa8705cf81448bc4bdb0456382fb.

bus_get_root_path() and sd_bus.cgroup_root are brought back.

Change-Id: Iad7b25472b3d877b1610b37e5473d9213fd661fc

src/libsystemd/sd-bus/bus-internal.h
src/libsystemd/sd-bus/sd-bus.c

index a14e264..10bf7fc 100644 (file)
@@ -323,6 +323,8 @@ struct sd_bus {
         struct kdbus_pids fake_pids;
         char *fake_label;
 
+        char *cgroup_root;
+
         char *description;
         char *patch_sender;
 
@@ -415,6 +417,8 @@ int bus_set_address_user(sd_bus *bus);
 int bus_set_address_system_remote(sd_bus *b, const char *host);
 int bus_set_address_system_machine(sd_bus *b, const char *machine);
 
+int bus_get_root_path(sd_bus *bus);
+
 int bus_maybe_reply_error(sd_bus_message *m, int r, sd_bus_error *error);
 
 #define bus_assert_return(expr, r, error)                               \
index 6a84060..ee2282f 100644 (file)
@@ -200,6 +200,7 @@ static sd_bus* bus_free(sd_bus *b) {
         free(b->kernel);
         free(b->machine);
         free(b->fake_label);
+        free(b->cgroup_root);
         free(b->description);
         free(b->patch_sender);
 
@@ -4174,6 +4175,24 @@ _public_ int sd_bus_get_description(sd_bus *bus, const char **description) {
         return 0;
 }
 
+int bus_get_root_path(sd_bus *bus) {
+        int r;
+
+        if (bus->cgroup_root)
+                return 0;
+
+        r = cg_get_root_path(&bus->cgroup_root);
+        if (r == -ENOENT) {
+                bus->cgroup_root = strdup("/");
+                if (!bus->cgroup_root)
+                        return -ENOMEM;
+
+                r = 0;
+        }
+
+        return r;
+}
+
 _public_ int sd_bus_get_scope(sd_bus *bus, const char **scope) {
         int r;