VFS updates, readme updates.

Separated vfs file as a specific file. vm file is not always a vfs file.
Updated the README
sys_open was not returning back to client, added that.
Added comments for future vfs additions.
This commit is contained in:
Bahadir Balban
2008-04-09 16:55:54 +01:00
parent dd3f35bbd4
commit 81ebffdc87
9 changed files with 96 additions and 35 deletions

View File

@@ -2,6 +2,7 @@
#define __MM0_FILE_H__
#include <l4/lib/list.h>
#include <l4lib/types.h>
#include <posix/sys/types.h>
void vmfile_init(void);
@@ -17,6 +18,15 @@ int sys_read(l4id_t sender, int fd, void *buf, int count);
int sys_write(l4id_t sender, int fd, void *buf, int count);
int sys_lseek(l4id_t sender, int fd, off_t offset, int whence);
#define vm_file_to_vnum(f) (*(unsigned long *)((f)->priv_data))
struct vfs_file_data {
unsigned long vnum;
};
#define vm_file_to_vnum(f) \
(((struct vfs_file_data *)((f)->priv_data))->vnum)
struct vm_file *vfs_file_create(void);
extern struct list_head vm_file_list;
#endif /* __MM0_FILE_H__ */

View File

@@ -40,7 +40,7 @@
/* Defines the type of file. A device file? Regular file? One used at boot? */
enum VM_FILE_TYPE {
VM_FILE_DEVZERO = 1,
VM_FILE_REGULAR,
VM_FILE_VFS,
VM_FILE_BOOTFILE,
VM_FILE_SHM,
};

View File

@@ -93,7 +93,9 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
/* Check if that vm_file is already in the list */
list_for_each_entry(vmfile, &vm_file_list, list) {
if (vm_file_to_vnum(vmfile) == vnum) {
/* Check it is a vfs file and if so vnums match. */
if ((vmfile->type & VM_FILE_VFS) &&
vm_file_to_vnum(vmfile) == vnum) {
/* Add a reference to it from the task */
t->fd[fd].vmfile = vmfile;
vmfile->vm_obj.refcnt++;
@@ -102,7 +104,7 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
}
/* Otherwise allocate a new one for this vnode */
if (IS_ERR(vmfile = vm_file_create()))
if (IS_ERR(vmfile = vfs_file_create()))
return (int)vmfile;
/* Initialise and add it to global list */

View File

@@ -3,6 +3,7 @@
*
* Copyright (C) 2008 Bahadir Balban
*/
#include <file.h>
#include <vm_area.h>
#include <l4/macros.h>
#include <l4/api/errno.h>
@@ -40,7 +41,7 @@ void vm_object_print(struct vm_object *vmo)
ftype = "bootfile";
else if (f->type == VM_FILE_SHM)
ftype = "shm file";
else if (f->type == VM_FILE_REGULAR)
else if (f->type == VM_FILE_VFS)
ftype = "regular";
else
BUG();
@@ -91,6 +92,23 @@ struct vm_file *vm_file_create(void)
return f;
}
/*
* Populates the priv_data with vfs-file-specific
* information.
*/
struct vm_file *vfs_file_create(void)
{
struct vm_file *f = vm_file_create();
if (IS_ERR(f))
return f;
f->priv_data = kzalloc(sizeof(struct vfs_file_data));
f->type = VM_FILE_VFS;
return f;
}
/* Deletes the object via its base, along with all its pages */
int vm_object_delete(struct vm_object *vmo)
{