bootstrap: replace bare string message with fs.open()
This commit is contained in:
@@ -5,9 +5,10 @@
|
||||
#include <mango/msg.h>
|
||||
#include <mango/task.h>
|
||||
#include <mango/types.h>
|
||||
#include <rosetta/msg.h>
|
||||
#include <rosetta/msg/fs.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define INIT_PATH "/usr/bin/test"
|
||||
|
||||
@@ -98,27 +99,47 @@ int main(
|
||||
kern_logf("launch result: %d", status);
|
||||
|
||||
#if 1
|
||||
char msg_buf[512];
|
||||
struct iovec vec = {
|
||||
.io_base = (virt_addr_t)msg_buf,
|
||||
.io_len = sizeof msg_buf,
|
||||
};
|
||||
struct msg msg = {.msg_data = &vec, .msg_data_count = 1};
|
||||
|
||||
while (1) {
|
||||
msgid_t id = 0;
|
||||
kern_status_t kstatus = msg_recv(channel, 0, &id, &msg);
|
||||
if (kstatus != KERN_OK) {
|
||||
kern_logf("msg_recv failed %d", kstatus);
|
||||
break;
|
||||
msgid_t id;
|
||||
struct rosetta_msg msg;
|
||||
kern_status_t status = rosetta_msg_recv(channel, &id, &msg);
|
||||
if (status != KERN_OK) {
|
||||
kern_logf("message recv error %d", status);
|
||||
continue;
|
||||
}
|
||||
|
||||
kern_logf("received message %zx: %s", id, msg_buf);
|
||||
if (msg.msg_protocol != ROSETTA_MSG_FS) {
|
||||
kern_logf(
|
||||
"unknown message protocol %u",
|
||||
msg.msg_protocol);
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t len = snprintf(msg_buf, sizeof msg_buf, "Goodbye!");
|
||||
vec.io_len = len + 1;
|
||||
if (msg.msg_id != ROSETTA_MSG_FS_OPEN) {
|
||||
kern_logf("unknown message function %u", msg.msg_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
msg_reply(channel, 0, id, &msg);
|
||||
char path[4096];
|
||||
int flags;
|
||||
struct rosetta_msg_string path_str = {
|
||||
.s_buf = path,
|
||||
.s_max = sizeof path,
|
||||
};
|
||||
status = rosetta_msg_fs_open_recv(
|
||||
channel,
|
||||
id,
|
||||
&path_str,
|
||||
&flags);
|
||||
if (status != KERN_OK) {
|
||||
kern_logf("rosetta.fs.open recv error %d", status);
|
||||
continue;
|
||||
}
|
||||
|
||||
kern_logf("open(%s, %d)", path, flags);
|
||||
|
||||
rosetta_msg_fs_open_reply(channel, id, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user