bootstrap: switch to ifc-generated ipc interface

This commit is contained in:
2026-02-26 19:47:58 +00:00
parent 3b50715559
commit 285a80530d
3 changed files with 42 additions and 33 deletions

View File

@@ -1,3 +1,5 @@
#define MSG_IMPLEMENTATION
#define MSG_NO_MALLOC
#include "tar.h"
#include <launch.h>
@@ -5,8 +7,7 @@
#include <mango/msg.h>
#include <mango/task.h>
#include <mango/types.h>
#include <rosetta/msg.h>
#include <rosetta/msg/fs.h>
#include <rosetta/fs.h>
#include <stdint.h>
#include <stdio.h>
@@ -46,6 +47,31 @@ static enum launch_status resolve_dependency(
return LAUNCH_OK;
}
static kern_status_t open(const char *path, int flags, int *out_err)
{
kern_logf("received msg: open(%s, %d)", path, flags);
*out_err = 13;
return KERN_OK;
}
static kern_status_t uppercase(const char *old, struct msg_string *new)
{
kern_logf("received msg: uppercase(%s)", old);
size_t i;
for (i = 0; old[i] && i < new->str_max - 1; i++) {
char c = old[i];
if (c >= 'a' && c <= 'z') {
new->str_buf[i] = old[i] - 'a' + 'A';
} else {
new->str_buf[i] = old[i];
}
}
new->str_len = i - 1;
new->str_buf[i] = 0;
return KERN_OK;
}
int main(
int argc,
const char **argv,
@@ -98,48 +124,29 @@ int main(
= launch_ctx_execute(&launch, &params, LAUNCH_F_NONE, &result);
kern_logf("launch result: %d", status);
const struct fs_vtable fs_vtable = {
.open = open,
.uppercase = uppercase,
};
#if 1
while (1) {
msgid_t id;
struct rosetta_msg msg;
kern_status_t status = rosetta_msg_recv(channel, &id, &msg);
struct msg_header hdr;
kern_status_t status = msg_recv_generic(channel, &id, &hdr);
if (status != KERN_OK) {
kern_logf("message recv error %d", status);
continue;
}
if (msg.msg_protocol != ROSETTA_MSG_FS) {
if (hdr.hdr_protocol != PROTOCOL_FS) {
kern_logf(
"unknown message protocol %u",
msg.msg_protocol);
hdr.hdr_protocol);
continue;
}
if (msg.msg_id != ROSETTA_MSG_FS_OPEN) {
kern_logf("unknown message function %u", msg.msg_id);
continue;
}
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);
status = fs_dispatch(channel, &fs_vtable, id, &hdr);
}
#endif