ld: send fs.open() message to bootstrap
This commit is contained in:
@@ -9,7 +9,7 @@ set_target_properties(ld PROPERTIES
|
|||||||
OUTPUT_NAME "ld64"
|
OUTPUT_NAME "ld64"
|
||||||
SUFFIX ".so")
|
SUFFIX ".so")
|
||||||
|
|
||||||
target_link_libraries(ld ulibc libmango)
|
target_link_libraries(ld ulibc libmango libmsg-fs)
|
||||||
|
|
||||||
target_compile_options(ld PRIVATE
|
target_compile_options(ld PRIVATE
|
||||||
-fPIC -fno-stack-protector -nostdlib -ffreestanding)
|
-fPIC -fno-stack-protector -nostdlib -ffreestanding)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <mango/log.h>
|
#include <mango/log.h>
|
||||||
#include <mango/msg.h>
|
#include <mango/msg.h>
|
||||||
#include <mango/types.h>
|
#include <mango/types.h>
|
||||||
|
#include <rosetta/msg/fs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -35,21 +36,21 @@ int main(
|
|||||||
#if 1
|
#if 1
|
||||||
port_connect(port, 0, 0);
|
port_connect(port, 0, 0);
|
||||||
|
|
||||||
const char msg_buf[] = "Hello!";
|
const char *path = "/usr/lib/libc.so";
|
||||||
struct iovec vec = IOVEC(msg_buf, 7);
|
int flags = 4;
|
||||||
struct msg msg = MSG(&vec, 1, NULL, 0);
|
int err = 0;
|
||||||
|
|
||||||
char recv_buf[64];
|
kern_logf("calling open(%s, %d)", path, flags);
|
||||||
struct iovec recv_vec = IOVEC(recv_buf, sizeof recv_buf);
|
status = rosetta_msg_fs_open_send(port, path, flags, &err);
|
||||||
struct msg recv_msg = MSG(&recv_vec, 1, NULL, 0);
|
|
||||||
|
|
||||||
kern_logf("sending message...");
|
if (status != KERN_OK) {
|
||||||
status = msg_send(port, 0, &msg, &recv_msg);
|
kern_logf("open call failed (status %d)", status);
|
||||||
kern_logf("msg_send: %d", status);
|
} else if (err != 0) {
|
||||||
|
kern_logf("open call returned error %d", err);
|
||||||
if (status == KERN_OK) {
|
} else {
|
||||||
kern_logf("reply: %s", recv_buf);
|
kern_logf("open call succeeded");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user