diff --git a/sys/bootstrap/CMakeLists.txt b/sys/bootstrap/CMakeLists.txt index 0903b22..5381979 100644 --- a/sys/bootstrap/CMakeLists.txt +++ b/sys/bootstrap/CMakeLists.txt @@ -5,7 +5,7 @@ set_property(SOURCE ${arch_sources} PROPERTY LANGUAGE C) add_executable(bootstrap ${c_sources} ${arch_sources}) -target_link_libraries(bootstrap libmango ulibc liblaunch) +target_link_libraries(bootstrap libmango ulibc liblaunch libmsg-fs) target_compile_options(bootstrap PRIVATE -fPIC -pie -fno-stack-protector -nostdlib -ffreestanding) diff --git a/sys/bootstrap/main.c b/sys/bootstrap/main.c index 7666fa9..56960e1 100644 --- a/sys/bootstrap/main.c +++ b/sys/bootstrap/main.c @@ -5,9 +5,10 @@ #include #include #include +#include +#include #include #include -#include #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