9#define BUFFER_MAX 0x1000
19int main(
int argc,
char** argv)
32 char*
id =
sreadfile(
"/net/local/seqpacket");
39 if (
swritefile(
F(
"/net/local/%s/ctl",
id),
"connect boxspawn") ==
ERR)
68 printf(
"boxspawn: `/proc` does not appear to be mounted, foreground boxes will not work correctly\n");
80 snprintf(
buffer,
sizeof(
buffer),
"group=%s namespace=%s stdin=%s stdout=%s stderr=%s -- ", group,
namespace,
99 for (
int i = 1;
i < argc;
i++)
103 printf(
"boxspawn: arguments too long\n");
#define NOTE_MAX
Maximum size of a notes buffer.
#define ENOENT
No such file or directory.
#define errno
Error number variable.
#define UNUSED(x)
Mark a variable as unused.
#define KEY_128BIT
The size of a buffer needed to hold a 128-bit key.
fd_t open(const char *path)
System call for opening files.
#define KEY_MAX
Maximum size of a key generated by share().
uint64_t close(fd_t fd)
System call for closing files.
#define F(format,...)
Allocates a formatted string on the stack.
size_t read(fd_t fd, void *buffer, size_t count)
System call for reading from files.
size_t swrite(fd_t fd, const char *string)
Wrapper for writing a null-terminated string to a file.
size_t swritefile(const char *path, const char *string)
Wrapper for writing a null-terminated string directly to a file using a path.
fd_t claim(const char *key)
System call for claiming a shared file descriptor.
#define STDOUT_FILENO
Standard output file descriptor.
char * sreadfile(const char *path)
Wrapper for reading an entire file directly into a null-terminated string.
#define STDERR_FILENO
Standard error file descriptor.
uint64_t share(char *key, uint64_t size, fd_t fd, clock_t timeout)
System call for sharing a file descriptor with another process.
#define RETRY_EINTR(expr)
Macro to automatically retry a function that returns an integer if it errors and errno == EINTR.
uint64_t sharefile(char *key, uint64_t size, const char *path, clock_t timeout)
Helper for sharing a file by its path.
#define STDIN_FILENO
Standard input file descriptor.
int64_t wordcmp(const char *string, const char *word)
Helper for comparing the first word of a string.
uint64_t notify(note_func_t handler)
System call that sets the handler to be called when a note is received.
_NORETURN void _exit(const char *status)
System call that handles pending notes for the current thread.
_NORETURN void noted(void)
System call that notifies the kernel that the current note has been handled.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
A file descriptor.
EFI_PHYSICAL_ADDRESS buffer
void note_handler(char *note)
_PUBLIC int sscanf(const char *_RESTRICT s, const char *_RESTRICT format,...)
_PUBLIC int printf(const char *_RESTRICT format,...)
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
_PUBLIC void free(void *ptr)
_PUBLIC char * strerror(int errnum)
_PUBLIC size_t strlen(const char *s)
_PUBLIC char * strcat(char *_RESTRICT s1, const char *_RESTRICT s2)
_PUBLIC char * strrchr(const char *s, int c)
_PUBLIC void * memset(void *s, int c, size_t n)