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 JSON document mapping
10 * unit ids to arrays of fd store entries:
11 *
12 * {
13 * "unit-name.service": [
14 * { "type": "fd", "name": "fdname1", "token": 1 },
15 * { "type": "fd", "name": "fdname2", "token": 2 },
16 * { "type": "luo_session", "name": "fdname3", "sessionName": "unit.service/myapp" }
17 * ],
18 * "other-unit.service": [
19 * { "type": "fd", "name": "stored", "token": 3 }
20 * ]
21 * }
22 *
23 * type=fd: the fd was preserved in the "systemd" LUO session with the given token.
24 * type=luo_session: a service-owned LUO session that survives kexec independently,
25 * retrieved by session_name on the next boot.
26 */
27 #define LUO_MAPPING_INDEX UINT64_C(0)
28
29 int luo_open_device(void);
30 int luo_create_session(int device_fd, const char *name);
31 int luo_retrieve_session(int device_fd, const char *name);
32 int luo_session_preserve_fd(int session_fd, int fd, uint64_t token);
33 int luo_session_retrieve_fd(int session_fd, uint64_t token);
34 int luo_session_finish(int session_fd);
35
36 int luo_parse_serialization(sd_json_variant **ret, int **ret_fds, size_t *ret_n_fds);
37 int luo_preserve_fd_stores(sd_json_variant *serialization, int *ret_session_fd);
38
39 int fd_is_luo_session(int fd);
40 int fd_get_luo_session_name(int fd, char **ret);