diff --git a/init/main.c b/init/main.c index 5fbe701..3c34cf2 100644 --- a/init/main.c +++ b/init/main.c @@ -1,6 +1,7 @@ #include #include "vga.h" #include +#include #include typedef struct { @@ -88,19 +89,41 @@ int main(char* initrd, uint32_t initrd_sz) { vga_write_string("Loaded VFS into memory, creating task\n"); createTaskCr3((void*)header.entry,cr3); vga_write_string("Created VFS task, sending test message\n"); - send_msg(2,"hello",6); + vfs_message* msg=malloc(sizeof(vfs_message)+strlen("/dev/sda")+1); + msg->type=VFS_OPEN; + msg->id=1; + msg->mode[0]='r'; + msg->mode[1]='\0'; + strcpy(&msg->path,"/dev/sda"); + send_msg(2,msg,sizeof(vfs_message)+strlen("/dev/sda")+1); + free(msg); vga_write_string("Sent test message, yielding to task\n"); yield(); vga_write_string("Yielded and got control, getting message\n"); int sender; int size; - char* msg=get_msg(&sender,&size); - vga_write_string("Message of size "); + msg=get_msg(&sender,&size); + vga_write_string("Message of type "); char str[256]; - int_to_ascii(size,str); + str[0]='\0'; + int_to_ascii(msg->type,str); vga_write_string(str); - vga_write_string(": "); - vga_write_string(msg); + vga_write_string("\n"); + vga_write_string("ID "); + str[0]='\0'; + int_to_ascii(msg->id,str); + vga_write_string(str); + vga_write_string("\n"); + vga_write_string("Mode "); + vga_write_string(&msg->mode); + vga_write_string("\n"); + vga_write_string("FD "); + str[0]='\0'; + int_to_ascii(msg->fd,str); + vga_write_string(str); + vga_write_string("\n"); + vga_write_string("Path "); + vga_write_string(&msg->path); vga_write_string("\n"); } for(;;); diff --git a/sysroot/usr/include/ipc/vfs.h b/sysroot/usr/include/ipc/vfs.h new file mode 100644 index 0000000..07e9d21 --- /dev/null +++ b/sysroot/usr/include/ipc/vfs.h @@ -0,0 +1,16 @@ +#ifndef IPC_VFS_H +#define IPC_VFS_H + +typedef enum { + VFS_OPEN +} vfs_message_type; + +typedef struct { + vfs_message_type type; + uint32_t id; + char mode[10]; + uint32_t fd; + char path[0]; +} vfs_message; + +#endif diff --git a/vfs/main.c b/vfs/main.c index 63efb07..6856908 100644 --- a/vfs/main.c +++ b/vfs/main.c @@ -1,9 +1,11 @@ #include +#include int main() { int sender; int size; - char* msg=get_msg(&sender,&size); + vfs_message* msg=get_msg(&sender,&size); + msg->fd=2; send_msg(1,msg,size); yield(); for (;;);