mirror of
https://github.com/troglobit/finit.git
synced 2026-10-14 10:19:36 +00:00
Finit had no way to answer the question every service manager gets asked: what is running, and change it. D-Bus is how the rest of userspace asks, but linking libdbus, sd-bus or GIO into PID 1 buys a dependency, an allocator and a main loop we do not control. So libink: the wire format, an object tree, and a bus of Finit's own at /run/finit/bus, gated like INIT_SOCKET. It speaks the standard org.freedesktop.DBus, .Peer, .Introspectable interfaces, and Finit's own Manager1, Service1 and Cond1 on top. Methods that change something are marked privileged and answered only for a caller the kernel vouched for, via SO_PEERCRED. Server and client both, since initctl is the first thing that needs to talk to it, and its Start/Stop/Restart/Reload now go over the bus rather than the legacy socket. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
49 lines
1.9 KiB
C
49 lines
1.9 KiB
C
/* libink — D-Bus body marshalling (writer side).
|
|
*
|
|
* Copyright (c) 2026 Joachim Wiberg <troglobit@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
#ifndef LIBINK_MARSHAL_H_
|
|
#define LIBINK_MARSHAL_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
/* struct link_writer is defined in ink.h (public). Field layout is
|
|
* "opaque" per the public contract; this file's helpers manipulate
|
|
* the fields directly. */
|
|
#include "link.h"
|
|
|
|
void __w_init (struct link_writer *w, uint8_t *buf, size_t cap);
|
|
ssize_t __w_finish(struct link_writer *w);
|
|
|
|
void __w_byte (struct link_writer *w, uint8_t v);
|
|
void __w_bool (struct link_writer *w, int v);
|
|
void __w_u32 (struct link_writer *w, uint32_t v);
|
|
void __w_string (struct link_writer *w, const char *s); /* "s" */
|
|
void __w_path (struct link_writer *w, const char *s); /* "o" */
|
|
void __w_sig (struct link_writer *w, const char *s); /* "g" */
|
|
|
|
/* element_sig_first_char drives the alignment padding inserted
|
|
* between the array length prefix and the first element. */
|
|
void __w_array_begin (struct link_writer *w, char element_sig_first_char);
|
|
void __w_array_end (struct link_writer *w);
|
|
|
|
void __w_struct_begin(struct link_writer *w);
|
|
void __w_struct_end (struct link_writer *w);
|
|
|
|
/* ---- reader ----
|
|
*
|
|
* Reads from a message body pointer + length, advancing a cursor.
|
|
* struct link_reader is defined in link.h (public, opaque); the
|
|
* helpers here manipulate the fields directly. */
|
|
void __r_init (struct link_reader *r, const uint8_t *body, size_t len);
|
|
int __r_byte (struct link_reader *r, uint8_t *out);
|
|
int __r_bool (struct link_reader *r, int *out);
|
|
int __r_u32 (struct link_reader *r, uint32_t *out);
|
|
int __r_string(struct link_reader *r, const char **out); /* "s" */
|
|
int __r_path (struct link_reader *r, const char **out); /* "o" */
|
|
int __r_done (const struct link_reader *r);
|
|
|
|
#endif /* LIBINK_MARSHAL_H_ */
|