X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fkdbus.h;h=10102d43358623379f449904b5efb4a715a5786f;hb=1ffee377ee6d7ad0d365368b5461748f580296d7;hp=601d0188d3841409700e6cb4a4f67c5226b7f0d9;hpb=9597086027a937edfd7a3f5e5999796d2b34c8ad;p=elogind.git diff --git a/src/libsystemd/kdbus.h b/src/libsystemd/kdbus.h index 601d0188d..10102d433 100644 --- a/src/libsystemd/kdbus.h +++ b/src/libsystemd/kdbus.h @@ -137,7 +137,7 @@ struct kdbus_vec { * struct kdbus_memfd - a kdbus memfd * @size: The memfd's size * @fd: The file descriptor number - * @__pad: Padding to make the struct aligned + * @__pad: Padding to ensure proper alignement and size * * Attached to: * KDBUS_ITEM_PAYLOAD_MEMFD @@ -205,6 +205,7 @@ struct kdbus_policy { * @KDBUS_ITEM_BLOOM_SIZE: Desired bloom size, used by KDBUS_CMD_BUS_MAKE * @KDBUS_ITEM_DST_NAME: Destination's well-known name * @KDBUS_ITEM_MAKE_NAME: Name of namespace, bus, endpoint + * @KDBUS_ITEM_MEMFD_NAME: The human readable name of a memfd (debugging) * @_KDBUS_ITEM_POLICY_BASE: Start of policy items * @KDBUS_ITEM_POLICY_NAME: Policy in struct kdbus_policy * @KDBUS_ITEM_POLICY_ACCESS: Policy in struct kdbus_policy @@ -221,6 +222,7 @@ struct kdbus_policy { * @KDBUS_ITEM_CAPS: The process capabilities * @KDBUS_ITEM_SECLABEL: The security label * @KDBUS_ITEM_AUDIT: The audit IDs + * @KDBUS_ITEM_CONN_NAME: The connection's human-readable name (debugging) * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items * @KDBUS_ITEM_NAME_ADD: Notify in struct kdbus_notify_name_change * @KDBUS_ITEM_NAME_REMOVE: Notify in struct kdbus_notify_name_change @@ -241,12 +243,13 @@ enum kdbus_item_type { KDBUS_ITEM_BLOOM_SIZE, KDBUS_ITEM_DST_NAME, KDBUS_ITEM_MAKE_NAME, + KDBUS_ITEM_MEMFD_NAME, - _KDBUS_ITEM_POLICY_BASE = 0x400, + _KDBUS_ITEM_POLICY_BASE = 0x1000, KDBUS_ITEM_POLICY_NAME = _KDBUS_ITEM_POLICY_BASE, KDBUS_ITEM_POLICY_ACCESS, - _KDBUS_ITEM_ATTACH_BASE = 0x600, + _KDBUS_ITEM_ATTACH_BASE = 0x2000, KDBUS_ITEM_NAME = _KDBUS_ITEM_ATTACH_BASE, KDBUS_ITEM_ID, KDBUS_ITEM_TIMESTAMP, @@ -259,8 +262,9 @@ enum kdbus_item_type { KDBUS_ITEM_CAPS, KDBUS_ITEM_SECLABEL, KDBUS_ITEM_AUDIT, + KDBUS_ITEM_CONN_NAME, - _KDBUS_ITEM_KERNEL_BASE = 0x800, + _KDBUS_ITEM_KERNEL_BASE = 0x3000, KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE, KDBUS_ITEM_NAME_REMOVE, KDBUS_ITEM_NAME_CHANGE, @@ -345,34 +349,72 @@ enum kdbus_payload_type { * struct kdbus_msg - the representation of a kdbus message * @size: Total size of the message * @flags: Message flags (KDBUS_MSG_FLAGS_*) + * @priority: Message queue priority value * @dst_id: 64-bit ID of the destination connection * @src_id: 64-bit ID of the source connection * @payload_type: Payload type (KDBUS_PAYLOAD_*) * @cookie: Userspace-supplied cookie, for the connection * to identify its messages - * @cookie_reply: A reply to the requesting message with the same - * cookie. The requesting connection can match its - * request and the reply with this value * @timeout_ns: The time to wait for a message reply from the peer. * If there is no reply, a kernel-generated message * with an attached KDBUS_ITEM_REPLY_TIMEOUT item * is sent to @src_id. + * @cookie_reply: A reply to the requesting message with the same + * cookie. The requesting connection can match its + * request and the reply with this value * @items: A list of kdbus_items containing the message payload */ struct kdbus_msg { __u64 size; __u64 flags; + __s64 priority; __u64 dst_id; __u64 src_id; __u64 payload_type; __u64 cookie; union { - __u64 cookie_reply; __u64 timeout_ns; + __u64 cookie_reply; }; struct kdbus_item items[0]; } __attribute__((aligned(8))); +/** + * enum kdbus_recv_flags - flags for de-queuing messages + * @KDBUS_RECV_PEEK: Return the next queued message without + * actually de-queuing it, and without installing + * any file descriptors or other resources. It is + * usually used to determine the activating + * connection of a bus name. + * @KDBUS_RECV_DROP: Drop and free the next queued message and all + * its resources without actually receiving it. + * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or + * higher priority (lowest values); if not set, + * the priority value is ignored. + */ +enum kdbus_recv_flags { + KDBUS_RECV_PEEK = 1 << 0, + KDBUS_RECV_DROP = 1 << 1, + KDBUS_RECV_USE_PRIORITY = 1 << 2, +}; + +/** + * kdbus_cmd_recv - struct to de-queue a buffered message + * @flags: KDBUS_RECV_* flags + * @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 + * stored. The user must use KDBUS_CMD_FREE to free + * the allocated memory. + * + * This struct is used with the KDBUS_CMD_MSG_RECV ioctl. + */ +struct kdbus_cmd_recv { + __u64 flags; + __s64 priority; + __u64 offset; +} __attribute__((aligned(8))); + /** * enum kdbus_policy_access_type - permissions of a policy record * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid @@ -441,6 +483,7 @@ enum kdbus_hello_flags { * @KDBUS_ATTACH_CAPS: The process capabilities * @KDBUS_ATTACH_SECLABEL: The security label * @KDBUS_ATTACH_AUDIT: The audit IDs + * @KDBUS_ATTACH_CONN_NAME: The human-readable connection name */ enum kdbus_attach_flags { KDBUS_ATTACH_TIMESTAMP = 1 << 0, @@ -453,6 +496,7 @@ enum kdbus_attach_flags { KDBUS_ATTACH_CAPS = 1 << 7, KDBUS_ATTACH_SECLABEL = 1 << 8, KDBUS_ATTACH_AUDIT = 1 << 9, + KDBUS_ATTACH_CONN_NAME = 1 << 10, }; /** @@ -474,8 +518,7 @@ enum kdbus_attach_flags { * @id128: Unique 128-bit ID of the bus (kernel → userspace) * @items: A list of items * - * This struct is used with the KDBUS_CMD_HELLO ioctl. See the ioctl - * documentation for more information. + * This struct is used with the KDBUS_CMD_HELLO ioctl. */ struct kdbus_cmd_hello { __u64 size; @@ -649,6 +692,24 @@ struct kdbus_cmd_match { struct kdbus_item items[0]; } __attribute__((aligned(8))); +/** + * struct kdbus_cmd_memfd_make - create a kdbus memfd + * @size: The total size of the struct + * @file_size: The initial file size + * @fd: The returned file descriptor number + * @__pad: Padding to ensure proper alignement + * @items: A list of items for additional information + * + * This structure is used with the KDBUS_CMD_MEMFD_NEW ioctl. + */ +struct kdbus_cmd_memfd_make { + __u64 size; + __u64 file_size; + int fd; + __u32 __pad; + struct kdbus_item items[0]; +} __attribute__((aligned(8))); + /** * enum kdbus_ioctl_type - Ioctl API * @KDBUS_CMD_BUS_MAKE: After opening the "control" device node, this @@ -676,10 +737,6 @@ struct kdbus_cmd_match { * placed in the receiver's pool. * @KDBUS_CMD_FREE: Release the allocated memory in the receiver's * pool. - * @KDBUS_CMD_DROP: Drop and free the next queued message and all - * its ressources without actually receiveing it. - * @KDBUS_CMD_SRC: Return the sender's connection ID of the next - * queued message. * @KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with * the connection. Well-known names are used to * address a peer on the bus. @@ -734,10 +791,8 @@ enum kdbus_ioctl_type { KDBUS_CMD_BYEBYE = _IO (KDBUS_IOC_MAGIC, 0x31), KDBUS_CMD_MSG_SEND = _IOW (KDBUS_IOC_MAGIC, 0x40, struct kdbus_msg), - KDBUS_CMD_MSG_RECV = _IOR (KDBUS_IOC_MAGIC, 0x41, __u64 *), + KDBUS_CMD_MSG_RECV = _IOWR(KDBUS_IOC_MAGIC, 0x41, struct kdbus_cmd_recv), KDBUS_CMD_FREE = _IOW (KDBUS_IOC_MAGIC, 0x42, __u64 *), - KDBUS_CMD_MSG_DROP = _IO (KDBUS_IOC_MAGIC, 0x43), - KDBUS_CMD_MSG_SRC = _IOR (KDBUS_IOC_MAGIC, 0x44, __u64 *), KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOC_MAGIC, 0x50, struct kdbus_cmd_name), KDBUS_CMD_NAME_RELEASE = _IOW (KDBUS_IOC_MAGIC, 0x51, struct kdbus_cmd_name), @@ -750,11 +805,11 @@ enum kdbus_ioctl_type { KDBUS_CMD_EP_POLICY_SET = _IOW (KDBUS_IOC_MAGIC, 0x80, struct kdbus_cmd_policy), - KDBUS_CMD_MEMFD_NEW = _IOR (KDBUS_IOC_MAGIC, 0x90, int *), - KDBUS_CMD_MEMFD_SIZE_GET = _IOR (KDBUS_IOC_MAGIC, 0x91, __u64 *), - KDBUS_CMD_MEMFD_SIZE_SET = _IOW (KDBUS_IOC_MAGIC, 0x92, __u64 *), - KDBUS_CMD_MEMFD_SEAL_GET = _IOR (KDBUS_IOC_MAGIC, 0x93, int *), - KDBUS_CMD_MEMFD_SEAL_SET = _IO (KDBUS_IOC_MAGIC, 0x94), + KDBUS_CMD_MEMFD_NEW = _IOWR(KDBUS_IOC_MAGIC, 0xc0, struct kdbus_cmd_memfd_make), + KDBUS_CMD_MEMFD_SIZE_GET = _IOR (KDBUS_IOC_MAGIC, 0xc1, __u64 *), + KDBUS_CMD_MEMFD_SIZE_SET = _IOW (KDBUS_IOC_MAGIC, 0xc2, __u64 *), + KDBUS_CMD_MEMFD_SEAL_GET = _IOR (KDBUS_IOC_MAGIC, 0xc3, int *), + KDBUS_CMD_MEMFD_SEAL_SET = _IO (KDBUS_IOC_MAGIC, 0xc4), }; /* @@ -802,6 +857,8 @@ enum kdbus_ioctl_type { * @ENOENT: The name to query information about is currently not on * the bus. * @ENOMEM: Out of memory. + * @ENOMSG: The queue is not empty, but no message with a matching + * priority is currently queued. * @ENOSYS: The requested functionality is not available. * @ENOTSUPP: The feature negotiation failed, a not supported feature * was requested, or an unknown item type was received.