2026-02-19 19:30:07 +00:00
|
|
|
#include <mango/log.h>
|
2026-02-21 12:22:57 +00:00
|
|
|
#include <mango/msg.h>
|
2026-02-19 19:30:07 +00:00
|
|
|
#include <mango/types.h>
|
2026-02-23 21:57:46 +00:00
|
|
|
#include <rosetta/msg/fs.h>
|
2026-02-21 12:22:57 +00:00
|
|
|
#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
|
|
|
|
|
|
|
|
int main(
|
|
|
|
|
int argc,
|
|
|
|
|
const char **argv,
|
|
|
|
|
kern_handle_t task,
|
|
|
|
|
kern_handle_t address_space,
|
|
|
|
|
uintptr_t bsp_base)
|
|
|
|
|
{
|
|
|
|
|
kern_log("ld!");
|
2026-02-23 18:46:13 +00:00
|
|
|
void *brk = sbrk(0);
|
|
|
|
|
kern_logf("brk=%p", brk);
|
|
|
|
|
|
|
|
|
|
void *buf = malloc(64);
|
|
|
|
|
if (buf) {
|
|
|
|
|
memset(buf, 0x0, 64);
|
|
|
|
|
kern_logf("allocated 64 bytes at %p", buf);
|
|
|
|
|
} else {
|
|
|
|
|
kern_logf("malloc() failed");
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-21 12:22:57 +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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
port_connect(port, 0, 0);
|
|
|
|
|
|
2026-02-23 21:57:46 +00:00
|
|
|
const char *path = "/usr/lib/libc.so";
|
|
|
|
|
int flags = 4;
|
|
|
|
|
int err = 0;
|
2026-02-21 12:22:57 +00:00
|
|
|
|
2026-02-23 21:57:46 +00:00
|
|
|
kern_logf("calling open(%s, %d)", path, flags);
|
|
|
|
|
status = rosetta_msg_fs_open_send(port, path, flags, &err);
|
2026-02-21 12:22:57 +00:00
|
|
|
|
2026-02-23 21:57:46 +00:00
|
|
|
if (status != KERN_OK) {
|
|
|
|
|
kern_logf("open call failed (status %d)", status);
|
|
|
|
|
} else if (err != 0) {
|
|
|
|
|
kern_logf("open call returned error %d", err);
|
|
|
|
|
} else {
|
|
|
|
|
kern_logf("open call succeeded");
|
2026-02-21 12:22:57 +00:00
|
|
|
}
|
2026-02-23 21:57:46 +00:00
|
|
|
|
2026-02-21 12:22:57 +00:00
|
|
|
#endif
|
2026-02-19 19:30:07 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|