ld: send fs.open() message to bootstrap

This commit is contained in:
2026-02-23 21:57:46 +00:00
parent 418c426e83
commit 0183790af3
2 changed files with 14 additions and 13 deletions

View File

@@ -9,7 +9,7 @@ set_target_properties(ld PROPERTIES
OUTPUT_NAME "ld64"
SUFFIX ".so")
target_link_libraries(ld ulibc libmango)
target_link_libraries(ld ulibc libmango libmsg-fs)
target_compile_options(ld PRIVATE
-fPIC -fno-stack-protector -nostdlib -ffreestanding)

View File

@@ -1,6 +1,7 @@
#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>
@@ -35,21 +36,21 @@ int main(
#if 1
port_connect(port, 0, 0);
const char msg_buf[] = "Hello!";
struct iovec vec = IOVEC(msg_buf, 7);
struct msg msg = MSG(&vec, 1, NULL, 0);
const char *path = "/usr/lib/libc.so";
int flags = 4;
int err = 0;
char recv_buf[64];
struct iovec recv_vec = IOVEC(recv_buf, sizeof recv_buf);
struct msg recv_msg = MSG(&recv_vec, 1, NULL, 0);
kern_logf("calling open(%s, %d)", path, flags);
status = rosetta_msg_fs_open_send(port, path, flags, &err);
kern_logf("sending message...");
status = msg_send(port, 0, &msg, &recv_msg);
kern_logf("msg_send: %d", status);
if (status == KERN_OK) {
kern_logf("reply: %s", recv_buf);
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;
}