bootstrap: update tarfs driver with libfs support

This commit is contained in:
2026-03-10 19:16:22 +00:00
parent ea6ec785a9
commit b7452a449b
6 changed files with 591 additions and 30 deletions

View File

@@ -53,7 +53,8 @@ static enum launch_status resolve_dependency(
}
static kern_status_t open(
const struct msg_endpoint *sender,
xpc_context_t *ctx,
const xpc_endpoint_t *sender,
const char *path,
int flags,
int *out_err,
@@ -178,51 +179,46 @@ int main(
.fs_arg = &heap,
};
struct fs_context *fs = fs_context_create(&fs_allocator, NULL);
struct fs_context *fs = fs_context_create(&fs_allocator);
if (!fs) {
kern_logf("cannot initialise fs");
return -1;
}
enum fs_status fs_status = fs_context_mount_filesystem(
fs,
tar_mount,
(void *)bsp_base,
0);
if (fs_status != FS_SUCCESS) {
kern_logf("cannot mount filesustem (%d)", fs_status);
return -1;
}
while (1) {
struct msg_endpoint sender;
struct msg_header hdr;
kern_msg_handle_t handles[KERN_MSG_MAX_HANDLES] = {0};
kern_status_t status = msg_recv_generic(
channel,
&sender,
&hdr,
handles,
KERN_MSG_MAX_HANDLES);
xpc_msg_t msg;
kern_status_t status = xpc_msg_recv(channel, &msg);
if (status != KERN_OK) {
kern_logf("message recv error %d", status);
msg_reply_generic(
channel,
&sender,
&hdr,
KERN_UNSUPPORTED);
continue;
}
switch (hdr.hdr_protocol) {
case PROTOCOL_FS:
status = fs_context_dispatch_msg(
fs,
channel,
&sender,
&hdr);
switch (msg.msg_header.hdr_interface) {
case INTERFACE_FS:
status = fs_context_dispatch_msg(fs, &msg);
break;
default:
kern_logf(
"unknown message protocol %u",
hdr.hdr_protocol);
msg_reply_generic(
channel,
&sender,
&hdr,
KERN_UNSUPPORTED);
msg.msg_header.hdr_interface);
xpc_msg_reply_error(&msg, KERN_UNSUPPORTED);
break;
}
if (status != KERN_OK) {
kern_logf("message reply error %d", status);
continue;
}
}
return 0;