In kdbus.h, the following details changed:
* All commands gained a 'kernel_flags' field to report the flags supported
by the driver. Before, this was done in the 'flags' field in a
bidirectional way, which turned out to be a problem for the code in
sd-bus, as many parts of it reuse the same ioctl struct more than once
and consider them to be owned by userspace.
* Name listings are now returned by a new struct instead of reusing struct
kdbus_cmd_name for that matter. This way, we don't add more unneeded
fields to it and make the API cleaner.
* 'conn_flags' was renamed to 'flags' in struct kdbus_cmd_hello to make
the API a bit more unified.
struct kdbus_cmd_name_list cmd = {};
struct kdbus_name_list *name_list;
struct kdbus_cmd_free cmd_free;
struct kdbus_cmd_name_list cmd = {};
struct kdbus_name_list *name_list;
struct kdbus_cmd_free cmd_free;
- struct kdbus_cmd_name *name;
+ struct kdbus_name_info *name;
_cleanup_strv_free_ char **owners = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
char *arg0;
_cleanup_strv_free_ char **owners = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
char *arg0;
static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
struct kdbus_cmd_name_list cmd = {};
struct kdbus_name_list *name_list;
static int kernel_get_list(sd_bus *bus, uint64_t flags, char ***x) {
struct kdbus_cmd_name_list cmd = {};
struct kdbus_name_list *name_list;
- struct kdbus_cmd_name *name;
+ struct kdbus_name_info *name;
uint64_t previous_id = 0;
int r;
uint64_t previous_id = 0;
int r;
hello = alloca0_align(sz, 8);
hello->size = sz;
hello = alloca0_align(sz, 8);
hello->size = sz;
- hello->conn_flags = b->hello_flags;
+ hello->flags = b->hello_flags;
hello->attach_flags = b->attach_flags;
hello->pool_size = KDBUS_POOL_SIZE;
hello->attach_flags = b->attach_flags;
hello->pool_size = KDBUS_POOL_SIZE;
b->is_kernel = true;
b->bus_client = true;
b->is_kernel = true;
b->bus_client = true;
- b->can_fds = !!(hello->conn_flags & KDBUS_HELLO_ACCEPT_FD);
+ b->can_fds = !!(hello->flags & KDBUS_HELLO_ACCEPT_FD);
b->message_version = 2;
b->message_endian = BUS_NATIVE_ENDIAN;
b->message_version = 2;
b->message_endian = BUS_NATIVE_ENDIAN;
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call) {
int r;
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call) {
int r;
if (hint_sync_call)
m->kdbus->flags |= KDBUS_MSG_FLAGS_EXPECT_REPLY|KDBUS_MSG_FLAGS_SYNC_REPLY;
if (hint_sync_call)
m->kdbus->flags |= KDBUS_MSG_FLAGS_EXPECT_REPLY|KDBUS_MSG_FLAGS_SYNC_REPLY;
- /* The kernel will return the set of supported flags in m->kdbus->flags.
- * Save the current message flags before issuing the ioctl, and restore them
- * afterwards */
- flags = m->kdbus->flags;
r = ioctl(bus->output_fd, KDBUS_CMD_MSG_SEND, m->kdbus);
r = ioctl(bus->output_fd, KDBUS_CMD_MSG_SEND, m->kdbus);
- m->kdbus->flags = flags;
if (r < 0) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *reply;
if (r < 0) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *reply;
(activating ? KDBUS_HELLO_ACTIVATOR : KDBUS_HELLO_POLICY_HOLDER) |
(accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
hello->pool_size = KDBUS_POOL_SIZE;
(activating ? KDBUS_HELLO_ACTIVATOR : KDBUS_HELLO_POLICY_HOLDER) |
(accept_fd ? KDBUS_HELLO_ACCEPT_FD : 0);
hello->pool_size = KDBUS_POOL_SIZE;
/**
* struct kdbus_msg - the representation of a kdbus message
* @size: Total size of the message
/**
* struct kdbus_msg - the representation of a kdbus message
* @size: Total size of the message
- * @flags: Message flags (KDBUS_MSG_FLAGS_*)
+ * @flags: Message flags (KDBUS_MSG_FLAGS_*), userspace → kernel
+ * @kernel_flags: Supported message flags, kernel → userspace
* @priority: Message queue priority value
* @dst_id: 64-bit ID of the destination connection
* @src_id: 64-bit ID of the source connection
* @priority: Message queue priority value
* @dst_id: 64-bit ID of the destination connection
* @src_id: 64-bit ID of the source connection
struct kdbus_msg {
__u64 size;
__u64 flags;
struct kdbus_msg {
__u64 size;
__u64 flags;
__s64 priority;
__u64 dst_id;
__u64 src_id;
__s64 priority;
__u64 dst_id;
__u64 src_id;
/**
* struct kdbus_cmd_recv - struct to de-queue a buffered message
/**
* struct kdbus_cmd_recv - struct to de-queue a buffered message
- * @flags: KDBUS_RECV_* flags
+ * @flags: KDBUS_RECV_* flags, userspace → kernel
+ * @kernel_flags: Supported KDBUS_RECV_* flags, kernel → userspace
* @priority: Minimum priority of the messages to de-queue. Lowest
* values have the highest priority.
* @offset: Returned offset in the pool where the message is
* @priority: Minimum priority of the messages to de-queue. Lowest
* values have the highest priority.
* @offset: Returned offset in the pool where the message is
*/
struct kdbus_cmd_recv {
__u64 flags;
*/
struct kdbus_cmd_recv {
__u64 flags;
__s64 priority;
__u64 offset;
} __attribute__((aligned(8)));
__s64 priority;
__u64 offset;
} __attribute__((aligned(8)));
/**
* struct kdbus_cmd_free - struct to free a slice of memory in the pool
/**
* struct kdbus_cmd_free - struct to free a slice of memory in the pool
- * @offset The offset of the memory slice, as returned by other
+ * @offset: The offset of the memory slice, as returned by other
- * @flags Flags for the free command. Currently unused.
+ * @flags: Flags for the free command, userspace → kernel
+ * @kernel_flags: Supported flags of the free command, userspace → kernel
*
* This struct is used with the KDBUS_CMD_FREE ioctl.
*/
struct kdbus_cmd_free {
__u64 offset;
__u64 flags;
*
* This struct is used with the KDBUS_CMD_FREE ioctl.
*/
struct kdbus_cmd_free {
__u64 offset;
__u64 flags;
} __attribute__((aligned(8)));
/**
} __attribute__((aligned(8)));
/**
/**
* struct kdbus_cmd_hello - struct to say hello to kdbus
* @size: The total size of the structure
/**
* struct kdbus_cmd_hello - struct to say hello to kdbus
* @size: The total size of the structure
- * @conn_flags: Connection flags (KDBUS_HELLO_*).
+ * @flags: Connection flags (KDBUS_HELLO_*), userspace → kernel
+ * @kernel_flags: Supported connection flags, kernel → userspace
* @attach_flags: Mask of metadata to attach to each message sent
* (KDBUS_ATTACH_*)
* @bus_flags: The flags field copied verbatim from the original
* @attach_flags: Mask of metadata to attach to each message sent
* (KDBUS_ATTACH_*)
* @bus_flags: The flags field copied verbatim from the original
*/
struct kdbus_cmd_hello {
__u64 size;
*/
struct kdbus_cmd_hello {
__u64 size;
+ __u64 flags;
+ __u64 kernel_flags;
__u64 attach_flags;
__u64 bus_flags;
__u64 id;
__u64 attach_flags;
__u64 bus_flags;
__u64 id;
/**
* struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
* @size: The total size of the struct
/**
* struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
* @size: The total size of the struct
- * @flags: Properties for the bus/ep/domain to create
+ * @flags: Properties for the bus/ep/domain to create,
+ * userspace → kernel
+ * @kernel_flags: Supported flags for the used command, kernel → userspace
* @items: Items describing details
*
* This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_ENDPOINT_MAKE
* @items: Items describing details
*
* This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_ENDPOINT_MAKE
struct kdbus_cmd_make {
__u64 size;
__u64 flags;
struct kdbus_cmd_make {
__u64 size;
__u64 flags;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
struct kdbus_item items[0];
} __attribute__((aligned(8)));
/**
* struct kdbus_cmd_name - struct to describe a well-known name
* @size: The total size of the struct
/**
* struct kdbus_cmd_name - struct to describe a well-known name
* @size: The total size of the struct
- * @flags: Flags for a name entry (KDBUS_NAME_*)
- * @owner_id: The current owner of the name
- * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
+ * @flags: Flags for a name entry (KDBUS_NAME_*),
+ * userspace → kernel, kernel → userspace
+ * @kernel_flags: Supported flags for a name entry, kernel → userspace
* @items: Item list, containing the well-known name as
* KDBUS_ITEM_NAME
*
* @items: Item list, containing the well-known name as
* KDBUS_ITEM_NAME
*
struct kdbus_cmd_name {
__u64 size;
__u64 flags;
struct kdbus_cmd_name {
__u64 size;
__u64 flags;
+ __u64 kernel_flags;
+ struct kdbus_item items[0];
+} __attribute__((aligned(8)));
+
+/**
+ * struct kdbus_name_info - struct to describe a well-known name
+ * @size: The total size of the struct
+ * @flags: Flags for a name entry (KDBUS_NAME_*),
+ * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
+ * @owner_id: The current owner of the name
+ * @items: Item list, containing the well-known name as
+ * KDBUS_ITEM_NAME
+ *
+ * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl.
+ */
+struct kdbus_name_info {
+ __u64 size;
+ __u64 flags;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
struct kdbus_item items[0];
} __attribute__((aligned(8)));
/**
* struct kdbus_cmd_name_list - request a list of name entries
/**
* struct kdbus_cmd_name_list - request a list of name entries
- * @flags: Flags for the query (KDBUS_NAME_LIST_*)
+ * @flags: Flags for the query (KDBUS_NAME_LIST_*),
+ * userspace → kernel
+ * @kernel_flags: Supported flags for queries, kernel → userspace
* @offset: The returned offset in the caller's pool buffer.
* The user must use KDBUS_CMD_FREE to free the
* allocated memory.
* @offset: The returned offset in the caller's pool buffer.
* The user must use KDBUS_CMD_FREE to free the
* allocated memory.
*/
struct kdbus_cmd_name_list {
__u64 flags;
*/
struct kdbus_cmd_name_list {
__u64 flags;
__u64 offset;
} __attribute__((aligned(8)));
__u64 offset;
} __attribute__((aligned(8)));
*/
struct kdbus_name_list {
__u64 size;
*/
struct kdbus_name_list {
__u64 size;
- struct kdbus_cmd_name names[0];
+ struct kdbus_name_info names[0];
};
/**
* struct kdbus_cmd_conn_info - struct used for KDBUS_CMD_CONN_INFO ioctl
* @size: The total size of the struct
};
/**
* struct kdbus_cmd_conn_info - struct used for KDBUS_CMD_CONN_INFO ioctl
* @size: The total size of the struct
- * @flags: KDBUS_ATTACH_* flags
+ * @flags: KDBUS_ATTACH_* flags, userspace → kernel
+ * @kernel_flags: Supported KDBUS_ATTACH_* flags, kernel → userspace
* @id: The 64-bit ID of the connection. If set to zero, passing
* @name is required. kdbus will look up the name to
* determine the ID in this case.
* @id: The 64-bit ID of the connection. If set to zero, passing
* @name is required. kdbus will look up the name to
* determine the ID in this case.
struct kdbus_cmd_conn_info {
__u64 size;
__u64 flags;
struct kdbus_cmd_conn_info {
__u64 size;
__u64 flags;
__u64 id;
__u64 offset;
struct kdbus_item items[0];
__u64 id;
__u64 offset;
struct kdbus_item items[0];
/**
* struct kdbus_cmd_update - update flags of a connection
* @size: The total size of the struct
/**
* struct kdbus_cmd_update - update flags of a connection
* @size: The total size of the struct
+ * @flags: Flags for the update command, userspace → kernel
+ * @kernel_flags: Supported flags for this command, kernel → userspace
* @items: A list of struct kdbus_item
*
* This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
* @items: A list of struct kdbus_item
*
* This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
struct kdbus_cmd_update {
__u64 size;
__u64 flags;
struct kdbus_cmd_update {
__u64 size;
__u64 flags;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
struct kdbus_item items[0];
} __attribute__((aligned(8)));
* @size: The total size of the struct
* @cookie: Userspace supplied cookie. When removing, the cookie
* identifies the match to remove
* @size: The total size of the struct
* @cookie: Userspace supplied cookie. When removing, the cookie
* identifies the match to remove
+ * @flags: Flags for match command (KDBUS_MATCH_*),
+ * userspace → kernel
+ * @kernel_flags: Supported flags of the used command, kernel → userspace
* @items: A list of items for additional information
*
* This structure is used with the KDBUS_CMD_ADD_MATCH and
* @items: A list of items for additional information
*
* This structure is used with the KDBUS_CMD_ADD_MATCH and
__u64 size;
__u64 cookie;
__u64 flags;
__u64 size;
__u64 cookie;
__u64 flags;
struct kdbus_item items[0];
} __attribute__((aligned(8)));
struct kdbus_item items[0];
} __attribute__((aligned(8)));