2026-02-26 19:48:06 +00:00
|
|
|
#define MSG_IMPLEMENTATION
|
2026-03-06 20:19:46 +00:00
|
|
|
#define MSG_NO_MALLOC
|
2026-02-26 19:48:06 +00:00
|
|
|
|
2026-03-10 19:16:46 +00:00
|
|
|
#include <errno.h>
|
2026-03-06 20:19:46 +00:00
|
|
|
#include <heap/heap.h>
|
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-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>
|
2026-02-26 19:48:06 +00:00
|
|
|
#include <rosetta/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>
|
2026-03-10 19:16:46 +00:00
|
|
|
#include <sys/remote.h>
|
2026-02-23 18:46:13 +00:00
|
|
|
#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
|
|
|
}
|
|
|
|
|
|
2026-03-10 19:16:46 +00:00
|
|
|
sys_remote_set(SYS_REMOTE_NSD, 0, 0);
|
2026-02-23 21:57:46 +00:00
|
|
|
const char *path = "/usr/lib/libc.so";
|
|
|
|
|
int flags = 4;
|
2026-03-10 19:16:46 +00:00
|
|
|
int fd = open(path, flags);
|
2026-02-21 12:22:57 +00:00
|
|
|
|
2026-02-26 19:48:06 +00:00
|
|
|
kern_logf("sending msg: open(%s, %d)", path, flags);
|
2026-02-21 12:22:57 +00:00
|
|
|
|
2026-03-10 19:16:46 +00:00
|
|
|
if (fd < 0) {
|
2026-03-06 20:19:46 +00:00
|
|
|
kern_logf(
|
|
|
|
|
"open(%s, %d) = %s (%s)",
|
|
|
|
|
path,
|
|
|
|
|
flags,
|
2026-03-10 19:16:46 +00:00
|
|
|
strerror_code(fd),
|
|
|
|
|
strerror(fd));
|
|
|
|
|
return -1;
|
2026-02-21 12:22:57 +00:00
|
|
|
}
|
2026-02-23 21:57:46 +00:00
|
|
|
|
2026-03-10 19:16:46 +00:00
|
|
|
kern_logf(
|
|
|
|
|
"open(%s, %d) = %s (%s)",
|
|
|
|
|
path,
|
|
|
|
|
flags,
|
|
|
|
|
strerror_code(SUCCESS),
|
|
|
|
|
strerror(SUCCESS));
|
|
|
|
|
|
|
|
|
|
unsigned char buf[32] = {0};
|
|
|
|
|
int nr = read(fd, buf, sizeof buf);
|
|
|
|
|
|
|
|
|
|
if (nr < 0) {
|
|
|
|
|
kern_logf("read call failed (%s)", strerror(nr));
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kern_logf("data: %x %c %c %c", buf[0], buf[1], buf[2], buf[3]);
|
|
|
|
|
|
2026-02-19 19:30:07 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|