mirror of
https://github.com/drasko/codezero.git
synced 2026-04-03 10:39:04 +02:00
More updates to vm object handling.
Added a list of links for vm objects so they can follow the links that point at them. More succinct handling of the case where a vm object is dropped. Now depending on the object's number of link references and shadow references, upon a drop it could either be merged, deleted or kept. Added opener reference count for vm files. Now files have opener count, objects have shadow and link count. Link count is also meaningful for how many tasks have mmap'ed that object.
This commit is contained in:
@@ -121,7 +121,7 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
|
||||
vm_file_to_vnum(vmfile) == vnum) {
|
||||
/* Add a reference to it from the task */
|
||||
t->fd[fd].vmfile = vmfile;
|
||||
vmfile->vm_obj.refcnt++;
|
||||
vmfile->openers++;
|
||||
l4_ipc_return(0);
|
||||
return 0;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
|
||||
vmfile->length = length;
|
||||
vmfile->vm_obj.pager = &file_pager;
|
||||
t->fd[fd].vmfile = vmfile;
|
||||
vmfile->vm_obj.refcnt++;
|
||||
vmfile->openers++;
|
||||
|
||||
/* Add to global list */
|
||||
list_add(&vmfile->vm_obj.list, &vm_file_list);
|
||||
@@ -365,6 +365,9 @@ int fd_close(l4id_t sender, int fd)
|
||||
if ((err = vfs_close(task->tid, fd)) < 0)
|
||||
return err;
|
||||
|
||||
/* Reduce file's opener count */
|
||||
task->fd[fd].vmfile->openers--;
|
||||
|
||||
task->fd[fd].vnum = 0;
|
||||
task->fd[fd].cursor = 0;
|
||||
task->fd[fd].vmfile = 0;
|
||||
|
||||
Reference in New Issue
Block a user