From 60cce15a4d6e7df8ecb118f4324d3b5556f72919 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Wed, 13 Feb 2008 00:24:57 +0000 Subject: [PATCH] Some preliminary efforts to reading directory contents in fs0. Need to still decide whether content buffers are provided by mm0, whether need to return them back to mm0, and the read count. modified: tasks/fs0/src/memfs/vnode.c modified: tasks/fs0/src/syscalls.c --- tasks/fs0/src/memfs/vnode.c | 4 ++++ tasks/fs0/src/syscalls.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tasks/fs0/src/memfs/vnode.c b/tasks/fs0/src/memfs/vnode.c index 6532af4..f3d75d2 100644 --- a/tasks/fs0/src/memfs/vnode.c +++ b/tasks/fs0/src/memfs/vnode.c @@ -203,9 +203,13 @@ int memfs_write_vnode(struct superblock *sb, struct vnode *v) /* + * Given a non-zero dirbuf, uses it, otherwise it allocates one on its own. + * * Allocates and populates all dentries and their corresponding vnodes that are * the direct children of vnode v. This means that by each call to readdir, the vfs * layer increases its cache of filesystem tree by one level beneath that directory. + * + * TODO: Returns the list of posix-compliant dirent records in the buffer. */ void *memfs_vnode_readdir(struct vnode *v, void *dirbuf) { diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index eaeae41..4039de7 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -83,6 +83,31 @@ int sys_read(l4id_t sender, int fd, void *buf, int count) return 0; } +/* + * FIXME: Read count is not considered yet. Take that into account. + * FIXME: Do we pass this buf back to mm0. Do we get it from mm0??? + * Fix generic_vnode_lookup as well. + */ +int sys_readdir(l4id_t sender, int fd, void *buf, int count) +{ + struct vnode *v; + + /* Get the task */ + BUG_ON(!(t = find_task(sender))); + + /* Convert fd to vnode. */ + BUG_ON(!(v = t->fd[fd])); + + /* Ensure vnode is a directory */ + if (!vfs_isdir(v)) + return -ENOTDIR; + + /* Simply read its contents */ + v->ops.readdir(v, buf, count); +` + return 0; +} + int sys_write(l4id_t sender, int fd, const void *buf, int count) { return 0;