PatchworkOS  621ae6b
A non-POSIX operating system.
Loading...
Searching...
No Matches
manifest.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5/**
6 * @brief Box Manifest Files.
7 * @defgroup programs_boxd_manifest Manifests.
8 * @ingroup programs_boxd
9 *
10 * All boxes must include a manifest file located at `/box/<box>/manifest` using the below format.
11 *
12 * ## Format
13 *
14 * ```
15 * [meta]
16 * description = <short description of the box>
17 * version = <version string>
18 * author = <author name>
19 * license = <license>
20 *
21 * [exec]
22 * bin = <path to the main executable, specified in the boxes namespace>
23 * priority = <scheduler priority [`PRIORITY_MIN`, `PRIORITY_MAX_USER`]>
24 *
25 * [sandbox]
26 * profile = <empty|inherit>
27 * foreground = <true|false>
28 *
29 * [env]
30 * KEY = VALUE ; Environment variable key-value pairs.
31 * ...
32 *
33 * [namespace]
34 * <target> = <source> ; Flags should be specified with the target, the source is specified in the root namespace.
35 * ```
36 *
37 * ## Sandbox Profiles
38 *
39 * There are four possible sandbox profiles:
40 * - `empty`: Start with an empty namespace, meaning the process will by default not have access to any files or
41 * devices.
42 * - `inherit`: Inherit the caller's namespace. This is useful for system utilities like `ls` or `grep` that need to
43 * operate on the user's current environment.
44 *
45 * ## Foreground Mode
46 *
47 * If `foreground` is set to `true`, then the box will receive stdio from the creator, be in the same process-group
48 * as the creator and start with the same cwd as the creator. Finally, the creator will receive a key to the boxes
49 * `/proc/[pid]/wait` file to retrieve its exit status.
50 *
51 * In short, in foreground mode the box will, as far as the creator is concerned, behave like a child process.
52 *
53 * ## Macros
54 *
55 * The following macros can be used in a manifest for substitution, a macro should be prefixed with `$`:
56 *
57 * - `BOX`: The path to the box's directory in the root namespace, e.g. `/box/<box>`.
58 *
59 * @see programs_init for information on the root namespaces filesystem heirarchy.
60 *
61 * @{
62 */
63
64#define MANIFEST_STRING_MAX 128
65
66#define MANIFEST_SECTION_MAX 64
67
68typedef struct
69{
73
79
89
90typedef struct
91{
94
95uint64_t manifest_parse(manifest_t* manifest, const char* path);
96
97typedef struct
98{
99 char* key;
100 char* value;
102
104
105char* manifest_get_value(section_t* section, const char* key);
106
108
109/** @} */
int64_t y
Definition main.c:153
uint64_t manifest_parse(manifest_t *manifest, const char *path)
Definition manifest.c:35
section_type_t
Definition manifest.h:81
char * manifest_get_value(section_t *section, const char *key)
Definition manifest.c:168
void manifest_substitute(manifest_t *manifest, substitution_t *substitutions, uint64_t amount)
Definition manifest.c:124
#define MANIFEST_SECTION_MAX
Definition manifest.h:66
#define MANIFEST_STRING_MAX
Definition manifest.h:64
uint64_t manifest_get_integer(section_t *section, const char *key)
Definition manifest.c:180
@ SECTION_META
Definition manifest.h:82
@ SECTION_TYPE_MAX
Definition manifest.h:87
@ SECTION_EXEC
Definition manifest.h:83
@ SECTION_NAMESPACE
Definition manifest.h:86
@ SECTION_ENV
Definition manifest.h:85
@ SECTION_SANDBOX
Definition manifest.h:84
static start_entry_t entries[START_ENTRY_MAX]
Definition start_menu.c:22
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Definition manifest.h:69
uint64_t amount
Definition manifest.h:77