Files
rosetta/sys/ld/main.c

57 lines
1.1 KiB
C

#include <mango/log.h>
#include <mango/msg.h>
#include <mango/types.h>
#include <rosetta/msg/fs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(
int argc,
const char **argv,
kern_handle_t task,
kern_handle_t address_space,
uintptr_t bsp_base)
{
kern_log("ld!");
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");
}
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);
const char *path = "/usr/lib/libc.so";
int flags = 4;
int err = 0;
kern_logf("calling open(%s, %d)", path, flags);
status = rosetta_msg_fs_open_send(port, path, flags, &err);
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");
}
#endif
return 0;
}