From 73058dc2499afe834bcc90e95c39e2385249fdd0 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Thu, 17 Apr 2008 21:47:37 +0100 Subject: [PATCH] Added sys_close() but its not done yet. close() needs to flush dirty buffers. pager needs to have read/write support properly implemented. open() needs to record mode and access times. The need for access times means we need rtc and time implementation. Also need to add stat() access() etc. --- tasks/fs0/include/path.h | 1 - tasks/fs0/src/syscalls.c | 17 +++++++++++++++++ tasks/fs0/src/vfs.c | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tasks/fs0/include/path.h b/tasks/fs0/include/path.h index ea6ad52..92a5c5d 100644 --- a/tasks/fs0/include/path.h +++ b/tasks/fs0/include/path.h @@ -23,7 +23,6 @@ struct pathdata { struct list_head list; struct vnode *vstart; - int root; }; struct pathcomp { diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index 2d93c35..e6e50b1 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -136,6 +136,23 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode) int sys_close(l4id_t sender, int fd) { + struct tcb *task; + + /* Get the task */ + BUG_ON(!(task = find_task(sender))); + + /* Validate file descriptor */ + if (fd < 0 || fd > TASK_OFILES_MAX) { + l4_ipc_return(-EBADF); + return 0; + } + if (!task->fd[fd]) { + l4_ipc_return(-EBADF); + return 0; + } + + /* Finish I/O on file */ + return 0; } diff --git a/tasks/fs0/src/vfs.c b/tasks/fs0/src/vfs.c index 9afde6a..bf9396c 100644 --- a/tasks/fs0/src/vfs.c +++ b/tasks/fs0/src/vfs.c @@ -66,7 +66,7 @@ struct vnode *vfs_lookup_bypath(struct pathdata *pdata) * This does vfs cache + fs lookup. */ BUG_ON(list_empty(&pdata->list)); - firstcomp = pathdata_next_component(pdata); + firstcomp = pathdata_next_component(pdata); return pdata->vstart->ops.lookup(pdata->vstart, pdata, firstcomp); }