Create a structure for VFS messages and make init send one to the VFS

This commit is contained in:
pjht 2019-06-22 16:11:44 -05:00
parent ade1521bc4
commit d13980109f
3 changed files with 48 additions and 7 deletions

View File

@ -1,6 +1,7 @@
#include <string.h>
#include "vga.h"
#include <grub/text_fb_info.h>
#include <ipc/vfs.h>
#include <elf.h>
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(;;);

View File

@ -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

View File

@ -1,9 +1,11 @@
#include <tasking.h>
#include <ipc/vfs.h>
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 (;;);