Debian Codegraph @

src/shared/luo-util.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "basic-forward.h"
5 #include "sd-forward.h"
6
7 #define LUO_SESSION_NAME "systemd"
8
9 /* Index (token) 0 in the LUO session is always the mapping memfd, which contains a versioned JSON document
10 * with manager-level state and a "units" object mapping unit ids to per-unit objects with an "fdstore" array
11 * of fd store entries:
12 *
13 * {
14 * "version": 1,
15 * "units": {
16 * "unit-name.service": {
17 * "fdstore": [
18 * { "type": "fd", "name": "fdname1", "token": 1 },
19 * { "type": "luo_session", "name": "fdname3", "sessionName": "unit.service/myapp" }
20 * ]
21 * }
22 * }
23 * }
24 *
25 * type=fd: the fd was preserved in the "systemd" LUO session with the given token.
26 * type=luo_session: a service-owned LUO session that survives kexec independently,
27 * retrieved by session_name on the next boot.
28 */
29 #define LUO_MAPPING_INDEX UINT64_C(0)
30 #define LUO_PROTOCOL_VERSION UINT64_C(1)
31
32 int luo_open_device(void);
33 int luo_create_session(int device_fd, const char *name);
34 int luo_retrieve_session(int device_fd, const char *name);
35 int luo_session_preserve_fd(int session_fd, int fd, uint64_t token);
36 int luo_session_retrieve_fd(int session_fd, uint64_t token);
37 int luo_session_finish(int session_fd);
38
39 int luo_parse_serialization(sd_json_variant **ret, int **ret_fds, size_t *ret_n_fds);
40 int luo_preserve_fd_stores(sd_json_variant *serialization, int *ret_session_fd);
41
42 int fd_is_luo_session(int fd);
43 int fd_get_luo_session_name(int fd, char **ret);