2019-06-22 11:11:12 -05:00
|
|
|
#include <tasking.h>
|
2019-06-22 16:11:44 -05:00
|
|
|
#include <ipc/vfs.h>
|
2019-06-27 17:00:23 -05:00
|
|
|
#include <mailboxes.h>
|
2019-06-29 09:04:34 -05:00
|
|
|
#include <stdlib.h>
|
2019-07-01 15:30:00 -05:00
|
|
|
#include <string.h>
|
2019-08-25 13:53:44 -05:00
|
|
|
#include <dbg.h>
|
2019-06-22 11:11:12 -05:00
|
|
|
|
2019-06-29 09:55:02 -05:00
|
|
|
#define PROC_FD_LIMIT 1024
|
2019-09-02 06:58:23 -05:00
|
|
|
#define ID_LIMIT 256
|
2019-06-29 09:55:02 -05:00
|
|
|
|
2019-06-29 09:27:41 -05:00
|
|
|
typedef struct _vfs_mapping_struct {
|
|
|
|
char* mntpnt;
|
|
|
|
uint32_t type;
|
|
|
|
struct _vfs_mapping_struct* next;
|
|
|
|
} vfs_mapping;
|
|
|
|
|
2019-06-29 09:55:02 -05:00
|
|
|
typedef struct {
|
2019-07-20 11:03:27 -05:00
|
|
|
vfs_mapping* mntpnt;
|
2019-06-29 09:55:02 -05:00
|
|
|
char* path;
|
2019-07-20 11:03:27 -05:00
|
|
|
char* mode;
|
2019-06-29 09:55:02 -05:00
|
|
|
uint32_t pos;
|
|
|
|
char error;
|
2019-08-31 16:46:52 -05:00
|
|
|
void* fs_data;
|
2019-06-29 09:55:02 -05:00
|
|
|
} vfs_file;
|
|
|
|
|
2019-09-02 06:58:23 -05:00
|
|
|
typedef struct {
|
|
|
|
uint32_t fd;
|
|
|
|
int max_len;
|
|
|
|
} gets_data;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char* path;
|
|
|
|
uint32_t type;
|
|
|
|
} mount_data;
|
|
|
|
|
2019-06-29 09:27:41 -05:00
|
|
|
static const char** drv_names;
|
|
|
|
static uint32_t* drvs;
|
|
|
|
static uint32_t max_drvs;
|
2019-08-25 13:53:44 -05:00
|
|
|
static uint32_t num_drvs;
|
2019-06-29 09:27:41 -05:00
|
|
|
static vfs_mapping* head_mapping;
|
|
|
|
static vfs_mapping* tail_mapping;
|
2019-07-20 11:03:27 -05:00
|
|
|
vfs_file* fd_tables[32768];
|
2019-06-29 09:55:02 -05:00
|
|
|
uint16_t open_fds[32768];
|
2019-07-27 11:11:28 -05:00
|
|
|
uint32_t box;
|
2019-09-02 06:58:23 -05:00
|
|
|
void** in_progress_data[32768];
|
2019-07-27 11:11:28 -05:00
|
|
|
vfs_message* get_message(Message* msg) {
|
2019-06-29 09:14:59 -05:00
|
|
|
msg->msg=malloc(sizeof(vfs_message));
|
|
|
|
mailbox_get_msg(box,msg,sizeof(vfs_message));
|
2019-07-01 15:13:47 -05:00
|
|
|
while (msg->from==0 && msg->size==0) {
|
|
|
|
yield();
|
2019-07-31 17:45:14 -05:00
|
|
|
mailbox_get_msg(box,msg,sizeof(vfs_message));
|
2019-07-01 15:13:47 -05:00
|
|
|
}
|
2019-06-29 09:14:59 -05:00
|
|
|
vfs_message* vfs_msg=(vfs_message*)msg->msg;
|
|
|
|
return vfs_msg;
|
|
|
|
}
|
|
|
|
|
2019-06-29 09:27:41 -05:00
|
|
|
static int vfsstrcmp(const char* s1,const char* s2) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; s1[i] == s2[i]; i++) {
|
|
|
|
if (s1[i] == '\0') return 0;
|
|
|
|
}
|
|
|
|
if (s1[i] == '\0') return 0;
|
|
|
|
return s1[i] - s2[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_vfs() {
|
|
|
|
drv_names=malloc(sizeof(const char**)*32);
|
2019-08-05 14:25:46 -05:00
|
|
|
drvs=malloc(sizeof(uint32_t)*32);
|
2019-06-29 09:27:41 -05:00
|
|
|
max_drvs=32;
|
2019-08-25 13:53:44 -05:00
|
|
|
num_drvs=0;
|
2019-08-03 15:50:23 -05:00
|
|
|
head_mapping=NULL;
|
2019-06-29 09:27:41 -05:00
|
|
|
tail_mapping=NULL;
|
|
|
|
}
|
|
|
|
|
2019-08-03 15:50:23 -05:00
|
|
|
uint32_t register_fs_intern(uint32_t drv,const char* type) {
|
2019-08-25 13:53:44 -05:00
|
|
|
if (num_drvs==max_drvs) {
|
2019-06-29 09:27:41 -05:00
|
|
|
drvs=realloc(drvs,sizeof(uint32_t)*(max_drvs+32));
|
|
|
|
drv_names=realloc(drv_names,sizeof(char*)*(max_drvs+32));
|
|
|
|
max_drvs+=32;
|
|
|
|
}
|
2019-08-25 13:53:44 -05:00
|
|
|
drvs[num_drvs]=drv;
|
|
|
|
drv_names[num_drvs]=type;
|
|
|
|
num_drvs++;
|
|
|
|
return num_drvs-1;
|
2019-06-29 09:27:41 -05:00
|
|
|
}
|
|
|
|
|
2019-07-31 17:45:14 -05:00
|
|
|
void vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
|
2019-09-02 06:58:23 -05:00
|
|
|
if (fd_tables[from]!=NULL&&open_fds[from]==PROC_FD_LIMIT) {
|
|
|
|
vfs_msg->flags=2;
|
|
|
|
}
|
2019-07-01 15:13:47 -05:00
|
|
|
vfs_mapping* mnt=head_mapping;
|
|
|
|
vfs_mapping* mntpnt=NULL;
|
|
|
|
uint32_t mntpnt_len=0;
|
|
|
|
for (;mnt!=NULL;mnt=mnt->next) {
|
|
|
|
char* root=mnt->mntpnt;
|
|
|
|
if (strlen(root)>mntpnt_len) {
|
|
|
|
if (vfsstrcmp(root,vfs_msg->path)==0) {
|
|
|
|
mntpnt=mnt;
|
|
|
|
mntpnt_len=strlen(root);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
if (mntpnt) {
|
2019-07-01 15:13:47 -05:00
|
|
|
Message msg;
|
|
|
|
char* path_buf=malloc(sizeof(char)*4096);
|
|
|
|
strcpy(path_buf,&(vfs_msg->path[0]));
|
|
|
|
memset(&(vfs_msg->path[0]),0,sizeof(char)*4096);
|
2019-07-01 15:30:00 -05:00
|
|
|
for (size_t i=0;i<strlen(path_buf)+1-mntpnt_len;i++) {
|
2019-07-01 15:13:47 -05:00
|
|
|
vfs_msg->path[i]=path_buf[i+mntpnt_len];
|
|
|
|
}
|
|
|
|
free(path_buf);
|
2019-07-27 11:11:28 -05:00
|
|
|
msg.from=box;
|
2019-07-01 15:13:47 -05:00
|
|
|
msg.to=drvs[mntpnt->type];
|
|
|
|
msg.size=sizeof(vfs_message);
|
|
|
|
msg.msg=vfs_msg;
|
|
|
|
mailbox_send_msg(&msg);
|
2019-09-02 06:58:23 -05:00
|
|
|
in_progress_data[from][vfs_msg->id]=mntpnt;
|
|
|
|
} else {
|
|
|
|
vfs_msg->flags=2;
|
|
|
|
}
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
void vfs_fopen_finish(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
vfs_mapping* mntpnt=in_progress_data[vfs_msg->orig_mbox][vfs_msg->id];
|
|
|
|
if (fd_tables[vfs_msg->orig_mbox]==NULL) {
|
|
|
|
fd_tables[vfs_msg->orig_mbox]=malloc(PROC_FD_LIMIT*sizeof(vfs_file));
|
|
|
|
open_fds[vfs_msg->orig_mbox]=0;
|
2019-06-29 09:55:02 -05:00
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
uint16_t fd=open_fds[vfs_msg->orig_mbox];
|
|
|
|
open_fds[vfs_msg->orig_mbox]++;
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].mntpnt=mntpnt;
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].path=malloc(sizeof(char)*(strlen(&vfs_msg->path[0])+1));
|
|
|
|
strcpy(fd_tables[vfs_msg->orig_mbox][fd].path,&vfs_msg->path[0]);
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].mode=malloc(sizeof(char)*(strlen(&vfs_msg->mode[0])+1));
|
|
|
|
strcpy(fd_tables[vfs_msg->orig_mbox][fd].mode,&vfs_msg->mode[0]);
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].pos=0;
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].error=0;
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].fs_data=vfs_msg->fs_data;
|
|
|
|
vfs_msg->fd=fd;
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
free(mntpnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_fopen_abort(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
free(in_progress_data[from][vfs_msg->id]);
|
2019-06-29 09:55:02 -05:00
|
|
|
}
|
|
|
|
|
2019-08-28 20:32:14 -05:00
|
|
|
void vfs_puts(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
char* data=malloc(sizeof(char)*vfs_msg->data);
|
|
|
|
Message msg;
|
|
|
|
msg.msg=data;
|
|
|
|
mailbox_get_msg(box,&msg,vfs_msg->data);
|
|
|
|
while (msg.from==0 && msg.size==0) {
|
|
|
|
yield();
|
|
|
|
mailbox_get_msg(box,&msg,sizeof(vfs_message));
|
|
|
|
}
|
|
|
|
if (msg.from==0) {
|
|
|
|
vfs_msg->flags=2;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
uint32_t fd=vfs_msg->fd;
|
|
|
|
vfs_file file_info=fd_tables[from][fd];
|
|
|
|
strcpy(&vfs_msg->path[0],file_info.path);
|
|
|
|
strcpy(&vfs_msg->mode[0],file_info.mode);
|
|
|
|
vfs_msg->pos=file_info.pos;
|
2019-08-31 16:46:52 -05:00
|
|
|
vfs_msg->fs_data=fd_tables[from][fd].fs_data;
|
2019-08-28 20:32:14 -05:00
|
|
|
msg.from=box;
|
|
|
|
msg.to=drvs[file_info.mntpnt->type];
|
|
|
|
msg.size=sizeof(vfs_message);
|
|
|
|
msg.msg=vfs_msg;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
msg.size=vfs_msg->data;
|
|
|
|
msg.msg=data;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
free(data);
|
2019-09-02 06:58:23 -05:00
|
|
|
in_progress_data[from][vfs_msg->id]=malloc(sizeof(uint32_t));
|
|
|
|
*((uint32_t*)in_progress_data[from][vfs_msg->id])=fd;
|
2019-08-28 20:32:14 -05:00
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
|
2019-09-02 06:58:23 -05:00
|
|
|
void vfs_puts_finish(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
uint32_t fd=*((uint32_t*)in_progress_data[vfs_msg->orig_mbox][vfs_msg->id]);
|
|
|
|
free(in_progress_data[vfs_msg->orig_mbox][vfs_msg->id]);
|
|
|
|
fd_tables[vfs_msg->orig_mbox][fd].pos+=vfs_msg->data;
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_puts_abort(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
free(in_progress_data[vfs_msg->orig_mbox][vfs_msg->id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_gets(vfs_message* vfs_msg,uint32_t from) {
|
2019-09-01 10:06:33 -05:00
|
|
|
uint32_t fd=vfs_msg->fd;
|
|
|
|
vfs_file file_info=fd_tables[from][fd];
|
|
|
|
strcpy(&vfs_msg->path[0],file_info.path);
|
|
|
|
strcpy(&vfs_msg->mode[0],file_info.mode);
|
|
|
|
vfs_msg->pos=file_info.pos;
|
|
|
|
vfs_msg->fs_data=fd_tables[from][fd].fs_data;
|
|
|
|
Message msg;
|
|
|
|
msg.from=box;
|
|
|
|
msg.to=drvs[file_info.mntpnt->type];
|
|
|
|
msg.size=sizeof(vfs_message);
|
|
|
|
msg.msg=vfs_msg;
|
|
|
|
mailbox_send_msg(&msg);
|
2019-09-02 06:58:23 -05:00
|
|
|
gets_data* data=malloc(sizeof(gets_data));
|
|
|
|
in_progress_data[from][vfs_msg->id]=data;
|
|
|
|
data->fd=fd;
|
|
|
|
data->max_len=vfs_msg->data;
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* vfs_gets_finish(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
char* buf=malloc(sizeof(char)*vfs_msg->data);
|
|
|
|
Message msg;
|
|
|
|
msg.msg=buf;
|
|
|
|
mailbox_get_msg(box,&msg,vfs_msg->data);
|
2019-09-01 10:06:33 -05:00
|
|
|
while (msg.from==0 && msg.size==0) {
|
|
|
|
yield();
|
|
|
|
mailbox_get_msg(box,&msg,sizeof(vfs_message));
|
|
|
|
}
|
|
|
|
if (msg.from==0) {
|
|
|
|
vfs_msg->flags=2;
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
gets_data* data=(gets_data*)in_progress_data[vfs_msg->orig_mbox][vfs_msg->id];
|
|
|
|
if (vfs_msg->data>data->max_len) {
|
2019-09-01 10:06:33 -05:00
|
|
|
vfs_msg->flags=2;
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
vfs_msg->data=data->max_len;
|
|
|
|
uint32_t fd=data->fd;
|
|
|
|
free(in_progress_data[vfs_msg->orig_mbox][vfs_msg->id]);
|
2019-09-01 10:06:33 -05:00
|
|
|
fd_tables[from][fd].pos+=vfs_msg->data;
|
|
|
|
vfs_msg->flags=0;
|
2019-09-02 06:58:23 -05:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_gets_abort(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
free(in_progress_data[vfs_msg->orig_mbox][vfs_msg->id]);
|
2019-09-01 10:06:33 -05:00
|
|
|
}
|
|
|
|
|
2019-08-28 20:32:14 -05:00
|
|
|
|
2019-08-03 15:50:23 -05:00
|
|
|
void vfs_register_fs(vfs_message* vfs_msg, uint32_t from) {
|
2019-08-05 14:26:20 -05:00
|
|
|
char* name=malloc(sizeof(char)*(strlen(vfs_msg->mode)+1));
|
2019-08-03 15:50:23 -05:00
|
|
|
name[0]='\0';
|
2019-08-05 14:26:20 -05:00
|
|
|
strcpy(name,&vfs_msg->mode[0]);
|
2019-08-25 13:53:44 -05:00
|
|
|
register_fs_intern(vfs_msg->fd,name);
|
2019-08-03 15:50:23 -05:00
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
|
2019-08-25 13:53:44 -05:00
|
|
|
void vfs_mount(vfs_message* vfs_msg, uint32_t from) {
|
|
|
|
char* path=malloc(sizeof(char)*(strlen(vfs_msg->path)+1));
|
|
|
|
path[0]='\0';
|
|
|
|
strcpy(path,&vfs_msg->path[0]);
|
|
|
|
char* type=malloc(sizeof(char)*(strlen(vfs_msg->mode)+1));
|
|
|
|
type[0]='\0';
|
|
|
|
strcpy(type,&vfs_msg->mode[0]);
|
|
|
|
char* disk_file=malloc(sizeof(char)*(vfs_msg->data));
|
|
|
|
Message msg;
|
|
|
|
msg.msg=disk_file;
|
|
|
|
mailbox_get_msg(box,&msg,vfs_msg->data);
|
|
|
|
while (msg.from==0 && msg.size==0) {
|
|
|
|
yield();
|
|
|
|
mailbox_get_msg(box,&msg,sizeof(vfs_message));
|
|
|
|
}
|
|
|
|
if (msg.from==0) {
|
2019-09-02 06:58:23 -05:00
|
|
|
free(path);
|
|
|
|
free(type);
|
|
|
|
free(disk_file);
|
2019-08-28 20:12:15 -05:00
|
|
|
vfs_msg->flags=2;
|
2019-08-25 13:53:44 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
char found=0;
|
|
|
|
uint32_t i;
|
|
|
|
for (i=0;i<num_drvs;i++) {
|
|
|
|
if (strcmp(type,drv_names[i])==0) {
|
|
|
|
found=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
2019-09-02 06:58:23 -05:00
|
|
|
free(path);
|
|
|
|
free(type);
|
|
|
|
free(disk_file);
|
2019-08-28 20:12:15 -05:00
|
|
|
vfs_msg->flags=2;
|
2019-08-25 13:53:44 -05:00
|
|
|
return;
|
|
|
|
}
|
2019-08-31 10:37:49 -05:00
|
|
|
msg.from=box;
|
|
|
|
msg.to=drvs[i];
|
|
|
|
msg.size=sizeof(vfs_message);
|
|
|
|
msg.msg=vfs_msg;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
msg.size=vfs_msg->data;
|
|
|
|
msg.msg=disk_file;
|
|
|
|
mailbox_send_msg(&msg);
|
2019-09-02 06:58:23 -05:00
|
|
|
mount_data* data=malloc(sizeof(mount_data));
|
|
|
|
in_progress_data[from][vfs_msg->id]=data;
|
|
|
|
data->path=path;
|
|
|
|
data->type=i;
|
|
|
|
free(type);
|
|
|
|
free(disk_file);
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vfs_mount_finish(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
mount_data* data=in_progress_data[vfs_msg->orig_mbox][vfs_msg->id];
|
2019-08-25 13:53:44 -05:00
|
|
|
if (head_mapping==NULL) {
|
|
|
|
vfs_mapping* mapping=malloc(sizeof(vfs_mapping));
|
2019-09-02 06:58:23 -05:00
|
|
|
mapping->mntpnt=malloc(sizeof(char)*(strlen(data->path)+1));
|
|
|
|
strcpy(mapping->mntpnt,data->path);
|
|
|
|
mapping->type=data->type;
|
2019-08-25 13:53:44 -05:00
|
|
|
mapping->next=NULL;
|
|
|
|
head_mapping=mapping;
|
|
|
|
tail_mapping=mapping;
|
|
|
|
} else {
|
|
|
|
vfs_mapping* mapping=malloc(sizeof(vfs_mapping));
|
2019-09-02 06:58:23 -05:00
|
|
|
mapping->mntpnt=malloc(sizeof(char)*(strlen(data->path)+1));
|
|
|
|
strcpy(mapping->mntpnt,data->path);
|
|
|
|
mapping->type=data->type;
|
2019-08-25 13:53:44 -05:00
|
|
|
mapping->next=NULL;
|
|
|
|
tail_mapping->next=mapping;
|
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
free(data->path);
|
|
|
|
free(data);
|
|
|
|
vfs_msg->flags=0;
|
2019-08-25 13:53:44 -05:00
|
|
|
}
|
|
|
|
|
2019-09-02 06:58:23 -05:00
|
|
|
void vfs_mount_abort(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
mount_data* data=in_progress_data[vfs_msg->orig_mbox][vfs_msg->id];
|
|
|
|
free(data->path);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
2019-09-10 19:15:02 -05:00
|
|
|
void vfs_seek(vfs_message* vfs_msg,uint32_t from) {
|
|
|
|
char str[256];
|
|
|
|
int_to_ascii(fd_tables[vfs_msg->orig_mbox][vfs_msg->fd].pos,str);
|
|
|
|
serial_print("Prev pos:");
|
|
|
|
serial_print(str);
|
|
|
|
serial_print("\n");
|
|
|
|
int_to_ascii(vfs_msg->pos,str);
|
|
|
|
serial_print("New in vfs msg:");
|
|
|
|
serial_print(str);
|
|
|
|
serial_print("\n");
|
|
|
|
fd_tables[vfs_msg->orig_mbox][vfs_msg->fd].pos=vfs_msg->pos;
|
|
|
|
int_to_ascii(fd_tables[vfs_msg->orig_mbox][vfs_msg->fd].pos,str);
|
|
|
|
serial_print("New in fd table:");
|
|
|
|
serial_print(str);
|
|
|
|
serial_print("\n");
|
|
|
|
vfs_msg->flags=0;
|
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
|
2019-05-24 11:52:13 -05:00
|
|
|
int main() {
|
2019-06-29 09:27:41 -05:00
|
|
|
init_vfs();
|
2019-09-01 13:52:32 -05:00
|
|
|
box=mailbox_new(16,"vfs");
|
2019-06-27 17:00:23 -05:00
|
|
|
yield();
|
2019-06-29 09:55:02 -05:00
|
|
|
while (1) {
|
|
|
|
Message msg;
|
2019-07-27 11:11:28 -05:00
|
|
|
vfs_message* vfs_msg=get_message(&msg);
|
2019-07-31 17:45:14 -05:00
|
|
|
uint32_t sender=msg.from;
|
2019-09-02 06:58:23 -05:00
|
|
|
char* data=NULL;
|
|
|
|
if (vfs_msg->in_progress) {
|
|
|
|
if (vfs_msg->flags) {
|
|
|
|
serial_print("ABORT\n");
|
|
|
|
switch (vfs_msg->type) {
|
|
|
|
case VFS_OPEN:
|
|
|
|
vfs_fopen_abort(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_PUTS:
|
|
|
|
vfs_puts_abort(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_GETS:
|
|
|
|
vfs_gets_abort(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_MOUNT:
|
|
|
|
vfs_mount_abort(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vfs_msg->flags=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
serial_print("FINISH\n");
|
|
|
|
switch (vfs_msg->type) {
|
|
|
|
case VFS_OPEN:
|
|
|
|
vfs_fopen_finish(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_PUTS:
|
|
|
|
vfs_puts_finish(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_GETS:
|
|
|
|
data=vfs_gets_finish(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_MOUNT:
|
|
|
|
vfs_mount_finish(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vfs_msg->flags=1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
msg.from=box;
|
|
|
|
msg.to=vfs_msg->orig_mbox;
|
2019-09-01 10:06:33 -05:00
|
|
|
mailbox_send_msg(&msg);
|
2019-09-02 06:58:23 -05:00
|
|
|
if (vfs_msg->type==VFS_GETS && data!=NULL) {
|
|
|
|
msg.size=vfs_msg->data;
|
|
|
|
msg.msg=data;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vfs_msg->in_progress=1;
|
|
|
|
if (in_progress_data[msg.from]==NULL) {
|
|
|
|
in_progress_data[msg.from]=malloc(sizeof(void*)*ID_LIMIT);
|
|
|
|
}
|
|
|
|
serial_print("NEW\n");
|
|
|
|
switch (vfs_msg->type) {
|
|
|
|
case VFS_OPEN:
|
|
|
|
vfs_fopen(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_PUTS:
|
|
|
|
vfs_puts(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_GETS:
|
|
|
|
vfs_gets(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_MOUNT:
|
|
|
|
vfs_mount(vfs_msg,msg.from);
|
|
|
|
break;
|
|
|
|
case VFS_REGISTER_FS:
|
|
|
|
vfs_register_fs(vfs_msg,msg.from);
|
|
|
|
serial_print("REGISTER_FS DONE\n");
|
|
|
|
break;
|
2019-09-10 19:15:02 -05:00
|
|
|
case VFS_SEEK:
|
|
|
|
vfs_seek(vfs_msg,msg.from);
|
|
|
|
break;
|
2019-09-02 06:58:23 -05:00
|
|
|
default:
|
|
|
|
vfs_msg->flags=1;
|
|
|
|
break;
|
|
|
|
}
|
2019-09-10 19:15:02 -05:00
|
|
|
if (vfs_msg->flags || vfs_msg->type==VFS_REGISTER_FS || vfs_msg->type==VFS_SEEK) {
|
2019-09-02 06:58:23 -05:00
|
|
|
msg.from=box;
|
|
|
|
msg.to=sender;
|
|
|
|
mailbox_send_msg(&msg);
|
|
|
|
}
|
2019-09-01 10:06:33 -05:00
|
|
|
}
|
2019-09-02 06:58:23 -05:00
|
|
|
free(vfs_msg);
|
2019-06-29 09:55:02 -05:00
|
|
|
yield();
|
2019-06-29 09:21:08 -05:00
|
|
|
}
|
2019-05-24 11:52:13 -05:00
|
|
|
for (;;);
|
|
|
|
}
|