mirror of
https://github.com/drasko/codezero.git
synced 2026-01-13 19:33:15 +01:00
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
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user