51 fd_t addrs =
open(
F(
"/net/%s/addrs", family));
117 const char* argv[] = {
"/sbin/boxd",
NULL};
126 printf(
"init: timeout waiting for boxd to create boxspawn socket (%s)\n",
strerror(
errno));
150 for (
uint64_t i = 0; i < amount; i++)
152 if (dirents[i].type !=
VDIR || dirents[i].path[0] ==
'.')
160 printf(
"init: failed to create launch symlink for box '%s' (%s)\n", dirents[i].path,
strerror(
errno));
181 printf(
"init: spawned service '%s'\n", services->
items[i]);
182 const char* argv[] = {services->
items[i],
NULL};
202 printf(
"init: spawn program '%s'\n", programs->
items[i]);
203 const char* argv[] = {programs->
items[i],
NULL};
235 printf(
"init: all startup tasks completed!\n");
config_array_t * config_get_array(config_t *config, const char *section, const char *key)
Get an array of strings from a configuration file.
config_t * config_open(const char *prefix, const char *name)
Open a configuration file.
void config_close(config_t *config)
Close a configuration file.
#define EEXIST
File exists.
#define errno
Error number variable.
fd_t dup2(fd_t oldFd, fd_t newFd)
System call for duplicating file descriptors, with a destination.
fd_t open(const char *path)
System call for opening files.
uint64_t close(fd_t fd)
System call for closing files.
char * readfiles(const char *path)
Wrapper for reading an entire file directly into a null-terminated string.
#define F(format,...)
Allocates a formatted string on the stack.
uint64_t mount(const char *mountpoint, const char *fs, const char *options)
System call for mounting a filesystem.
uint64_t symlink(const char *target, const char *linkpath)
System call for creating a symbolic link.
#define STDOUT_FILENO
Standard output file descriptor.
#define STDERR_FILENO
Standard error file descriptor.
size_t readdir(fd_t fd, dirent_t **buffer, uint64_t *count)
Helper for reading all directory entries.
pid_t spawn(const char **argv, spawn_flags_t flags)
System call for spawning new processes.
clock_t uptime(void)
System call for retreving the time since boot.
uint64_t nanosleep(clock_t timeout)
System call for sleeping.
@ SPAWN_EMPTY_GROUP
Don't inherit the parent's process group, instead create a new group.
@ SPAWN_EMPTY_FDS
Dont inherit the file descriptors of the parent process.
@ SPAWN_DEFAULT
Default spawn behaviour.
@ SPAWN_EMPTY_ENV
Don't inherit the parent's environment variables.
@ SPAWN_EMPTY_CWD
Don't inherit the parent's current working directory, starts at root (/).
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
File descriptor type.
__UINT64_TYPE__ clock_t
A nanosecond time.
static void init_config_load(void)
static void init_root_ns(void)
static uint64_t init_socket_addr_wait(const char *family, const char *addr)
static void init_create_pkg_links(void)
static void init_spawn_boxd(void)
_PUBLIC int printf(const char *_RESTRICT format,...)
_PUBLIC _NORETURN void abort(void)
_PUBLIC void free(void *ptr)
_PUBLIC char * strerror(int errnum)
_PUBLIC char * strstr(const char *s1, const char *s2)
Configuration array structure.
Opaque configuration structure.