]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/libsystemd/sd-bus/bus-kernel.h
tmpfiles: accurately report creation results
[thirdparty/systemd.git] / src / libsystemd / sd-bus / bus-kernel.h
CommitLineData
6629161f
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3#pragma once
4
5/***
6 This file is part of systemd.
7
8 Copyright 2013 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
f2769777
LP
24#include <stdbool.h>
25
6629161f
LP
26#include "sd-bus.h"
27
a8d4cac5 28#define KDBUS_ITEM_NEXT(item) \
c7819669
LP
29 (typeof(item))(((uint8_t *)item) + ALIGN8((item)->size))
30
a8d4cac5 31#define KDBUS_ITEM_FOREACH(part, head, first) \
9eb34e82 32 for (part = (head)->first; \
b629d098
DM
33 ((uint8_t *)(part) < (uint8_t *)(head) + (head)->size) && \
34 ((uint8_t *) part >= (uint8_t *) head); \
a8d4cac5 35 part = KDBUS_ITEM_NEXT(part))
c7819669 36
a8d4cac5
KS
37#define KDBUS_ITEM_HEADER_SIZE offsetof(struct kdbus_item, data)
38#define KDBUS_ITEM_SIZE(s) ALIGN8((s) + KDBUS_ITEM_HEADER_SIZE)
c7819669 39
bc7fd8cd 40#define MEMFD_CACHE_MAX 32
66b26c5c
LP
41
42/* When we cache a memfd block for reuse, we will truncate blocks
43 * longer than this in order not to keep too much data around. */
832d16a6 44#define MEMFD_CACHE_ITEM_SIZE_MAX (128*1024)
66b26c5c
LP
45
46/* This determines at which minimum size we prefer sending memfds over
47 * sending vectors */
1fa13293 48#define MEMFD_MIN_SIZE (512*1024)
bc7fd8cd 49
63edf05e
LP
50/* The size of the per-connection memory pool that we set up and where
51 * the kernel places our incoming messages */
52#define KDBUS_POOL_SIZE (16*1024*1024)
53
bc7fd8cd
LP
54struct memfd_cache {
55 int fd;
56 void *address;
8e959fbf
LP
57 size_t mapped;
58 size_t allocated;
bc7fd8cd
LP
59};
60
6629161f
LP
61int bus_kernel_connect(sd_bus *b);
62int bus_kernel_take_fd(sd_bus *b);
63
069f5e61 64int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call);
766c5809 65int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority);
6629161f 66
8f077bf9 67int bus_kernel_open_bus_fd(const char *bus, char **path);
a4152e3f 68
f2769777 69int bus_kernel_create_bus(const char *name, bool world, char **s);
e7d718af 70int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char **path);
bc7fd8cd 71
8e959fbf
LP
72int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *allocated);
73void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, size_t allocated);
bc7fd8cd
LP
74
75void bus_kernel_flush_memfd(sd_bus *bus);
c7819669
LP
76
77int bus_kernel_parse_unique_name(const char *s, uint64_t *id);
0253ddcc 78
b5dae4c7
LP
79uint64_t request_name_flags_to_kdbus(uint64_t sd_bus_flags);
80uint64_t attach_flags_to_kdbus(uint64_t sd_bus_flags);
ae095f86
LP
81
82int bus_kernel_try_close(sd_bus *bus);
ff975efb
LP
83
84int bus_kernel_drop_one(int fd);
b5dae4c7
LP
85
86int bus_kernel_realize_attach_flags(sd_bus *bus);
1a299299
LP
87
88int bus_kernel_fix_attach_mask(void);
52cfc037 89
3acc1daf
LP
90int bus_kernel_get_bus_name(sd_bus *bus, char **name);
91
52cfc037 92int bus_kernel_cmd_free(sd_bus *bus, uint64_t offset);