Files
rosetta/sys/ld/main.c

56 lines
1.1 KiB
C
Raw Normal View History

#define MSG_IMPLEMENTATION
2026-03-06 20:19:46 +00:00
#define MSG_NO_MALLOC
2026-03-06 20:19:46 +00:00
#include <heap/heap.h>
2026-02-19 19:30:07 +00:00
#include <mango/log.h>
#include <mango/msg.h>
2026-03-06 20:19:46 +00:00
#include <mango/task.h>
2026-02-19 19:30:07 +00:00
#include <mango/types.h>
2026-03-06 20:19:46 +00:00
#include <mango/vm.h>
#include <rosetta/bootstrap.h>
#include <rosetta/fs.h>
#include <stdio.h>
2026-02-23 18:46:13 +00:00
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
2026-02-19 19:30:07 +00:00
2026-03-06 20:19:46 +00:00
int main(const struct rosetta_bootstrap *bs)
2026-02-19 19:30:07 +00:00
{
2026-03-06 20:19:46 +00:00
kern_handle_t task, address_space;
task_self(&task);
task_get_address_space(task, &address_space);
2026-02-23 18:46:13 +00:00
2026-03-06 20:19:46 +00:00
for (size_t i = 0; i < bs->bs_argc; i++) {
kern_logf("argv[%zu]: %s", i, bs->bs_argv[i]);
2026-02-23 18:46:13 +00:00
}
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);
2026-03-06 20:19:46 +00:00
} else {
kern_logf(
"open(%s, %d) = %s (%s)",
path,
flags,
strerror_code(err),
strerror(err));
}
2026-02-19 19:30:07 +00:00
return 0;
}