chiark / gitweb /
bus: instead of exposing the dbus1 flags when acquiring a name use our own that are...
authorLennart Poettering <lennart@poettering.net>
Thu, 12 Dec 2013 04:55:58 +0000 (05:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Dec 2013 04:55:58 +0000 (05:55 +0100)
This turns around DO_NOT_QUEUE into QUEUE which implies a more useful
default. (And negative options are awful anyway.)

12 files changed:
src/core/dbus.c
src/hostname/hostnamed.c
src/libsystemd-bus/bus-control.c
src/libsystemd-bus/bus-kernel.c
src/libsystemd-bus/bus-protocol.h
src/locale/localed.c
src/login/logind.c
src/machine/machined.c
src/systemd/sd-bus-protocol.h
src/systemd/sd-bus-vtable.h
src/systemd/sd-bus.h
src/timedate/timedated.c

index 580bdf3..df50138 100644 (file)
@@ -801,7 +801,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
          * after the new connection is set up and the name installed
          * to allow clients to synchronously wait for reexecution to
          * finish */
-        r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE|SD_BUS_NAME_ALLOW_REPLACEMENT);
+        r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_ALLOW_REPLACEMENT);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;
index ece2b41..3f08d1c 100644 (file)
@@ -574,7 +574,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
                 return r;
         }
 
-        r = sd_bus_request_name(bus, "org.freedesktop.hostname1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE);
+        r = sd_bus_request_name(bus, "org.freedesktop.hostname1", 0);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;
index b970006..2682439 100644 (file)
@@ -49,7 +49,7 @@ _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
         return 0;
 }
 
-static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags) {
+static int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags) {
         struct kdbus_cmd_name *n;
         size_t l;
         int r;
@@ -77,14 +77,21 @@ static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags
         return 1;
 }
 
-static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) {
+static int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags) {
         _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-        uint32_t ret;
+        uint32_t ret, param = 0;
         int r;
 
         assert(bus);
         assert(name);
 
+        if (flags & SD_BUS_NAME_ALLOW_REPLACEMENT)
+                param |= BUS_NAME_ALLOW_REPLACEMENT;
+        if (flags & SD_BUS_NAME_REPLACE_EXISTING)
+                param |= BUS_NAME_REPLACE_EXISTING;
+        if (!(flags & SD_BUS_NAME_QUEUE))
+                param |= BUS_NAME_DO_NOT_QUEUE;
+
         r = sd_bus_call_method(
                         bus,
                         "org.freedesktop.DBus",
@@ -95,7 +102,7 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags)
                         &reply,
                         "su",
                         name,
-                        flags);
+                        param);
         if (r < 0)
                 return r;
 
@@ -115,13 +122,13 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags)
         return -EIO;
 }
 
-_public_ int sd_bus_request_name(sd_bus *bus, const char *name, unsigned flags) {
+_public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) {
         assert_return(bus, -EINVAL);
         assert_return(name, -EINVAL);
         assert_return(bus->bus_client, -EINVAL);
         assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
         assert_return(!bus_pid_changed(bus), -ECHILD);
-        assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE)), -EINVAL);
+        assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL);
 
         if (bus->is_kernel)
                 return bus_request_name_kernel(bus, name, flags);
index 81dfba7..0437c96 100644 (file)
@@ -1020,7 +1020,7 @@ int kdbus_translate_request_name_flags(uint64_t flags, uint64_t *kdbus_flags) {
         if (flags & SD_BUS_NAME_REPLACE_EXISTING)
                 f |= KDBUS_NAME_REPLACE_EXISTING;
 
-        if (!(flags & SD_BUS_NAME_DO_NOT_QUEUE))
+        if (!(flags & SD_BUS_NAME_QUEUE))
                 f |= KDBUS_NAME_QUEUE;
 
         *kdbus_flags = f;
index 982461b..4726d93 100644 (file)
@@ -60,6 +60,14 @@ enum {
         _BUS_MESSAGE_HEADER_MAX
 };
 
+/* RequestName parameters */
+
+enum  {
+        BUS_NAME_ALLOW_REPLACEMENT = 1,
+        BUS_NAME_REPLACE_EXISTING = 2,
+        BUS_NAME_DO_NOT_QUEUE = 4
+};
+
 /* RequestName returns */
 enum  {
         BUS_NAME_PRIMARY_OWNER = 1,
index 7c41822..65318b6 100644 (file)
@@ -1094,7 +1094,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
                 return r;
         }
 
-        r = sd_bus_request_name(bus, "org.freedesktop.locale1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE);
+        r = sd_bus_request_name(bus, "org.freedesktop.locale1", 0);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;
index 5ce79b2..2226087 100644 (file)
@@ -727,7 +727,7 @@ static int manager_connect_bus(Manager *m) {
                 return r;
         }
 
-        r = sd_bus_request_name(m->bus, "org.freedesktop.login1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE);
+        r = sd_bus_request_name(m->bus, "org.freedesktop.login1", 0);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;
index d639603..6550075 100644 (file)
@@ -219,7 +219,7 @@ static int manager_connect_bus(Manager *m) {
                 return r;
         }
 
-        r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE);
+        r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", 0);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;
index b2db7e4..1967fa8 100644 (file)
@@ -22,8 +22,6 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <endian.h>
-
 #include "_sd-common.h"
 
 _SD_BEGIN_DECLARATIONS;
@@ -66,14 +64,6 @@ enum {
         SD_BUS_TYPE_DICT_ENTRY_END   = '}',
 };
 
-/* RequestName parameters */
-
-enum  {
-        SD_BUS_NAME_ALLOW_REPLACEMENT = 1,
-        SD_BUS_NAME_REPLACE_EXISTING = 2,
-        SD_BUS_NAME_DO_NOT_QUEUE = 4
-};
-
 /* Well-known errors. Note that this is only a sanitized subset of the
  * errors that the reference implementation generates. */
 
index 5400e9a..cc029eb 100644 (file)
@@ -37,7 +37,6 @@ enum {
         _SD_BUS_VTABLE_SIGNAL            = 'S',
         _SD_BUS_VTABLE_PROPERTY          = 'P',
         _SD_BUS_VTABLE_WRITABLE_PROPERTY = 'W',
-        _SD_BUS_VTABLE_CHILDREN          = 'C',
 };
 
 enum {
index 402fc55..3c3cea0 100644 (file)
@@ -75,6 +75,12 @@ enum {
         _SD_BUS_CREDS_ALL             = (1ULL << 24) -1,
 };
 
+enum {
+        SD_BUS_NAME_REPLACE_EXISTING  = 1ULL << 0,
+        SD_BUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1,
+        SD_BUS_NAME_QUEUE             = 1ULL << 2,
+};
+
 /* Callbacks */
 
 typedef int (*sd_bus_message_handler_t)(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
@@ -234,7 +240,7 @@ int sd_bus_message_rewind(sd_bus_message *m, int complete);
 /* Bus management */
 
 int sd_bus_get_unique_name(sd_bus *bus, const char **unique);
-int sd_bus_request_name(sd_bus *bus, const char *name, unsigned flags);
+int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags);
 int sd_bus_release_name(sd_bus *bus, const char *name);
 int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatable); /* free the results */
 int sd_bus_get_owner(sd_bus *bus, const char *name, uint64_t mask, sd_bus_creds **creds); /* unref the result! */
index e3421c2..37173a2 100644 (file)
@@ -791,7 +791,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
                 return r;
         }
 
-        r = sd_bus_request_name(bus, "org.freedesktop.timedate1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE);
+        r = sd_bus_request_name(bus, "org.freedesktop.timedate1", 0);
         if (r < 0) {
                 log_error("Failed to register name: %s", strerror(-r));
                 return r;