| /* SPDX-License-Identifier: GPL-2.0-only */ | |
| // Copyright (c) 2026 Jarkko Sakkinen | |
| #ifndef UCELLS_CELL_H | |
| #define UCELLS_CELL_H | |
| #include "bpf_lsm.h" | |
| #include "budget.h" | |
| #include "ids.h" | |
| #include "sandbox.h" | |
| #include "spawn.h" | |
| #include "tree.h" | |
| #include "uapi.h" | |
| struct cell_resources { | |
| struct id_block_pool id_pool; | |
| struct budget_registry budgets; | |
| struct bpf_lsm bpf_lsm; | |
| }; | |
| struct cell { | |
| uint64_t id; | |
| struct caller_cred creator; | |
| int runfd; | |
| uint32_t userns_inum; | |
| enum cell_state state; | |
| int32_t exit_status; | |
| bool has_init; | |
| enum id_shape id_shape; | |
| struct id_block_lease id_lease; | |
| uint64_t caps; | |
| bool has_caps; | |
| char hostname[UTS_HOSTNAME_MAX + 1]; | |
| bool has_hostname; | |
| enum net_slot_mode net_mode; | |
| uint64_t net_rights; | |
| bool has_net_rights; | |
| struct mount_tree root; | |
| bool root_installed; | |
| struct budget budget; | |
| uint64_t budget_cgroup_id; | |
| struct cell_sandbox sandbox; | |
| bool has_sandbox; | |
| }; | |
| struct embryo { | |
| char *exec; | |
| struct string_block argv; | |
| struct string_block envp; | |
| struct cred_spec cred; | |
| bool has_cred; | |
| struct staged_fd *staged_fds; | |
| size_t nr_staged_fds; | |
| size_t staged_capacity; | |
| int cgroup_fd; | |
| }; | |
| int cell_init(struct cell *cell, uint64_t id, | |
| const struct caller_cred *creator); | |
| int cell_configure(struct cell *cell, const struct slot_action *action, | |
| int *aux_fd, const struct caller_cred *caller, | |
| struct cell_resources *resources); | |
| int cell_open_net(struct cell *cell); | |
| int cell_idmap_fd(const struct cell *cell); | |
| int cell_seal(struct cell *cell, const struct caller_cred *caller, | |
| struct cell_resources *resources); | |
| void cell_snapshot(const struct cell *cell, uint64_t mask, | |
| struct cell_info *out); | |
| int cell_check_spawnable(const struct cell *cell); | |
| int cell_start_embryo(struct cell *cell, const struct embryo *embryo, | |
| struct cell_resources *resources); | |
| void cell_kill(struct cell *cell, struct cell_resources *resources); | |
| void cell_on_run_exit(struct cell *cell, struct cell_resources *resources); | |
| int embryo_configure(struct embryo *embryo, struct embryo_action *action, | |
| int *aux_fd); | |
| void embryo_destroy(struct embryo *embryo); | |
| #endif |