Files
rosetta/sys/ld/main.c
2026-03-06 20:19:46 +00:00

56 lines
1.1 KiB
C

#define MSG_IMPLEMENTATION
#define MSG_NO_MALLOC
#include <heap/heap.h>
#include <mango/log.h>
#include <mango/msg.h>
#include <mango/task.h>
#include <mango/types.h>
#include <mango/vm.h>
#include <rosetta/bootstrap.h>
#include <rosetta/fs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(const struct rosetta_bootstrap *bs)
{
kern_handle_t task, address_space;
task_self(&task);
task_get_address_space(task, &address_space);
for (size_t i = 0; i < bs->bs_argc; i++) {
kern_logf("argv[%zu]: %s", i, bs->bs_argv[i]);
}
kern_handle_t port;
kern_status_t status = port_create(&port);
if (status != KERN_OK) {
kern_logf("port creation failed %d", status);
return -1;
}
port_connect(port, 0, 0);
const char *path = "/usr/lib/libc.so";
int flags = 4;
int err = 0;
kern_logf("sending msg: open(%s, %d)", path, flags);
status = fs_open(port, path, flags, &err);
if (status != KERN_OK) {
kern_logf("open call failed (status %d)", status);
} else {
kern_logf(
"open(%s, %d) = %s (%s)",
path,
flags,
strerror_code(err),
strerror(err));
}
return 0;
}