Fix the VFS

This commit is contained in:
pjht 2019-07-31 17:45:14 -05:00
parent 823a255e1a
commit 207ddb890c
6 changed files with 117 additions and 57 deletions

View File

@ -1,15 +1,15 @@
set pagination off
target remote localhost:1234
symbol-file kernel/kernel.elf
add-symbol-file fsdrv/fsdrv
add-symbol-file vfs/vfs
b tasking.c:123
commands
silent
disable breakpoints
symbol-file kernel/kernel.elf
p task->pid
if task->pid==3
add-symbol-file fsdrv/fsdrv
if task->pid==2
add-symbol-file vfs/vfs
enable breakpoints
else
enable breakpoints 1

24
.gdbinit_dbg Normal file
View File

@ -0,0 +1,24 @@
set pagination off
target remote localhost:1234
symbol-file kernel/kernel.elf
add-symbol-file vfs/vfs
b tasking.c:123
commands
silent
disable breakpoints
symbol-file kernel/kernel.elf
p task->pid
if task->pid==2
add-symbol-file vfs/vfs
enable breakpoints
else
enable breakpoints 1
c
end
c
end
b main
commands
disable breakpoints 1
end

71
.gdbinit_logger Normal file
View File

@ -0,0 +1,71 @@
set pagination off
target remote localhost:1234
symbol-file kernel/kernel.elf
printf "Start at kernel\n"
b tasking.c:123
commands
silent
if task->pid==0
printf "Yield to the kernel\n"
else
if task->pid==1
printf "Yield to init\n"
else
if task->pid==2
printf "Yield to the VFS\n"
else
if task->pid==3
printf "Yield to fsdrv\n"
else
printf "Yield to unknown\n"
end
end
end
end
c
end
b tasking.c:35
commands
silent
if next_pid==0
printf "Kernel task registered\n"
else
if next_pid==1
printf "Init created\n"
else
if next_pid==2
printf "VFS created\n"
else
if next_pid==3
printf "fsdrv created\n"
else
printf "Unknown task created\n"
end
end
end
end
c
end
b mailboxes.c:14
commands
silent
printf "Mailbox %d created.\n",next_box
c
end
b mailboxes.c:27
commands
silent
printf "Message sent from box %d to box %d\n",user_msg->from,user_msg->to
c
end
b mailboxes.c:48
commands
silent
if mailbox.msg_store[mailbox.rd].size==0
printf "Box %d attempted to get a message, but there were none.\n",box
else
printf "Box %d got a message.\n",box
end
c
end
c

12
file
View File

@ -1,12 +0,0 @@
vfs/main.c: In function 'vfs_putc':
vfs/main.c:133:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
main.c: In function 'vfs_putc':
main.c:133:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
WARNING: Image format was not specified for 'ext2.img' and probing guessed raw.
Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
Specify the 'raw' format explicitly to remove the restrictions.
qemu-system-i386: terminating on signal 1 from pid 58353 (<unknown process>)

27
log
View File

@ -1,27 +0,0 @@
kernel/cpu/i386/isr.c:91:14: warning: 'exception_messages' defined but not used [-Wunused-variable]
static char *exception_messages[] = {
^~~~~~~~~~~~~~~~~~
kernel/cpu/i386/pmem.c: In function 'pmem_alloc':
kernel/cpu/i386/pmem.c:72:16: warning: comparison is always true due to limited range of data type [-Wtype-limits]
if (bmap[i]!=0xFF) {
^~
libc/stdlib.c: In function 'malloc':
libc/stdlib.c:68:20: warning: comparison is always true due to limited range of data type [-Wtype-limits]
if (bmap[i]!=0xFF) {
^~
grub-mkrescue: warning: cannot open directory `/usr/local/Cellar/i386-elf-grub/2.02/share/locale': No such file or directory.
GNU xorriso 1.4.8 : RockRidge filesystem manipulator, libburnia project.
Drive current: -outdev 'stdio:os.iso'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 33.5g free
Added to ISO image: directory '/'='/tmp/grub.i7L624'
xorriso : UPDATE : 279 files added in 1 seconds
Added to ISO image: directory '/'='/Users/peterterpstra/Desktop/projects/os/iso'
xorriso : UPDATE : 286 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/local/Cellar/i386-elf-grub/2.02/lib/grub/i386-pc/boot_hybrid.img'
ISO image produced: 1294 sectors
Written to medium : 1294 sectors at LBA 0
Writing to 'stdio:os.iso' completed successfully.

View File

@ -33,8 +33,8 @@ vfs_message* get_message(Message* msg) {
msg->msg=malloc(sizeof(vfs_message));
mailbox_get_msg(box,msg,sizeof(vfs_message));
while (msg->from==0 && msg->size==0) {
mailbox_get_msg(box,msg,sizeof(vfs_message));
yield();
mailbox_get_msg(box,msg,sizeof(vfs_message));
}
vfs_message* vfs_msg=(vfs_message*)msg->msg;
return vfs_msg;
@ -74,7 +74,7 @@ uint32_t register_fs(uint32_t drv,const char* type) {
return next_drv_indx-1;
}
char vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
void vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
vfs_mapping* mnt=head_mapping;
vfs_mapping* mntpnt=NULL;
uint32_t mntpnt_len=0;
@ -87,7 +87,7 @@ char vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
}
}
}
if (mntpnt) {
if (mntpnt) { // was if (mntpnt)
Message msg;
char* path_buf=malloc(sizeof(char)*4096);
strcpy(path_buf,&(vfs_msg->path[0]));
@ -102,16 +102,16 @@ char vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
msg.msg=vfs_msg;
mailbox_send_msg(&msg);
yield();
vfs_message* vfs_msg=get_message(&msg);
if (vfs_msg->flags!=0) {
return vfs_msg->flags;
vfs_message* resp_msg=get_message(&msg);
if (resp_msg->flags!=0) {
return;
}
if (fd_tables[from]==NULL) {
fd_tables[from]=malloc(PROC_FD_LIMIT*sizeof(vfs_file));
open_fds[from]=1;
} else {
if (open_fds[from]==PROC_FD_LIMIT) {
return 4;
vfs_msg->flags=4;
}
}
uint16_t fd=open_fds[from];
@ -124,12 +124,13 @@ char vfs_fopen(vfs_message* vfs_msg,uint32_t from) {
fd_tables[from][fd].pos=0;
fd_tables[from][fd].error=0;
vfs_msg->fd=fd;
return 0;
vfs_msg->flags=0;
return;
}
return 1;
vfs_msg->flags=1;
}
char vfs_putc(vfs_message* vfs_msg,uint32_t from) {
void vfs_putc(vfs_message* vfs_msg,uint32_t from) {
uint32_t fd=vfs_msg->fd;
vfs_file file_info=fd_tables[from][fd];
strcpy(&vfs_msg->path[0],file_info.path);
@ -138,16 +139,17 @@ char vfs_putc(vfs_message* vfs_msg,uint32_t from) {
Message msg;
msg.from=box;
msg.to=file_info.mntpnt->type;
msg.to=5;
msg.size=sizeof(vfs_message);
msg.msg=vfs_msg;
mailbox_send_msg(&msg);
yield();
vfs_msg=get_message(&msg);
if (vfs_msg->flags!=0) {
return vfs_msg->flags;
return;
}
fd_tables[from][fd].pos++;
return 0;
vfs_msg->flags=0;
}
int main() {
@ -157,13 +159,13 @@ int main() {
while (1) {
Message msg;
vfs_message* vfs_msg=get_message(&msg);
uint32_t sender=msg.from;
switch (vfs_msg->type) {
case VFS_OPEN:
vfs_msg->flags=vfs_fopen(vfs_msg,msg.from);
vfs_fopen(vfs_msg,msg.from);
break;
case VFS_PUTC:
vfs_msg->flags=vfs_putc(vfs_msg,msg.from);
vfs_msg->flags=1;
vfs_putc(vfs_msg,msg.from);
break;
case VFS_GETC:
vfs_msg->flags=1;
@ -181,6 +183,8 @@ int main() {
vfs_msg->flags=2;
break;
}
msg.from=box;
msg.to=sender;
mailbox_send_msg(&msg);
yield();
}