From 367e4555060498081358ba25af06a7773011e319 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Sat, 12 Apr 2008 18:03:49 +0100 Subject: [PATCH] Fixed compilation errors for filldir/sys_readdir() changes. --- tasks/fs0/include/fs.h | 2 +- tasks/fs0/src/init.c | 4 ---- tasks/fs0/src/memfs/memfs.c | 9 +++++---- tasks/fs0/src/memfs/vnode.c | 9 +++++---- tasks/fs0/src/syscalls.c | 6 +++--- tasks/fs0/src/vfs.c | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/tasks/fs0/include/fs.h b/tasks/fs0/include/fs.h index d078fa6..fa186b1 100644 --- a/tasks/fs0/include/fs.h +++ b/tasks/fs0/include/fs.h @@ -48,7 +48,7 @@ struct vnode_ops { vnode_op_t create; struct vnode *(*lookup)(struct vnode *root, char *path); int (*readdir)(struct vnode *v); - int (*filldir)(struct vnode *v); + int (*filldir)(void *buf, struct vnode *v, int count); vnode_op_t link; vnode_op_t unlink; int (*mkdir)(struct vnode *parent, char *name); diff --git a/tasks/fs0/src/init.c b/tasks/fs0/src/init.c index bc0d9f9..c769ee4 100644 --- a/tasks/fs0/src/init.c +++ b/tasks/fs0/src/init.c @@ -72,10 +72,6 @@ int initialise(void) */ memfs_format_filesystem(rootdev_blocks); - INIT_LIST_HEAD(&vm_file_list); - INIT_LIST_HEAD(&vnode_cache); - INIT_LIST_HEAD(&dentry_cache); - /* Search for a filesystem on the root device */ BUG_ON(IS_ERR(root_sb = vfs_probe_filesystems(rootdev_blocks))); diff --git a/tasks/fs0/src/memfs/memfs.c b/tasks/fs0/src/memfs/memfs.c index 9f27a6b..61ed890 100644 --- a/tasks/fs0/src/memfs/memfs.c +++ b/tasks/fs0/src/memfs/memfs.c @@ -118,15 +118,14 @@ int memfs_init_rootdir(struct superblock *sb) struct memfs_superblock *msb = sb->fs_super; struct dentry *d; struct vnode *v; - int err; /* * Create the root vnode. Since this is memfs, root vnode is * not read-in but dynamically created here. We expect this * first vnode to have vnum = 0. */ - v = sb->root = vfs_sb->ops->alloc_vnode(vfs_sb); - msb->root_vnum = vfs_sb->root->vnum; + v = sb->root = sb->ops->alloc_vnode(sb); + msb->root_vnum = sb->root->vnum; BUG_ON(msb->root_vnum != 0); /* Initialise fields */ @@ -146,11 +145,13 @@ int memfs_init_rootdir(struct superblock *sb) list_add(&d->vref, &d->vnode->dentries); /* Associate dentry with its parent */ - list_add(&d->child, &parent->children); + list_add(&d->child, &d->children); /* Add both vnode and dentry to their flat caches */ list_add(&d->cache_list, &dentry_cache); list_add(&v->cache_list, &vnode_cache); + + return 0; } /* Copies fs-specific superblock into generic vfs superblock */ diff --git a/tasks/fs0/src/memfs/vnode.c b/tasks/fs0/src/memfs/vnode.c index 16d9628..12ddf1e 100644 --- a/tasks/fs0/src/memfs/vnode.c +++ b/tasks/fs0/src/memfs/vnode.c @@ -377,9 +377,10 @@ int memfs_vnode_readdir(struct vnode *v) } -int memfs_vnode_filldir(void *usrbuf, struct vnode *v, int count) +int memfs_vnode_filldir(void *userbuf, struct vnode *v, int count) { - int size; + int nbytes; + int err; /* Bytes to read, minimum of vnode size and count requested */ nbytes = (v->size <= count) ? v->size : count; @@ -390,11 +391,11 @@ int memfs_vnode_filldir(void *usrbuf, struct vnode *v, int count) /* Do we have those bytes at hand? */ if (v->dirbuf.buffer && (v->dirbuf.npages * PAGE_SIZE) >= nbytes) { - /* + /* * Memfs does a direct copy since memfs dirent format * is the same as generic dirent format. */ - memcpy(buf, v->dirbuf.buffer, nbytes); + memcpy(userbuf, v->dirbuf.buffer, nbytes); return nbytes; } return 0; diff --git a/tasks/fs0/src/syscalls.c b/tasks/fs0/src/syscalls.c index d9f9532..2d7b617 100644 --- a/tasks/fs0/src/syscalls.c +++ b/tasks/fs0/src/syscalls.c @@ -233,7 +233,7 @@ int fill_dirent(void *buf, unsigned long vnum, int offset, char *name) d->inum = (unsigned int)vnum; d->offset = offset; d->rlength = sizeof(struct dirent); - strncpy(d->name, name, DIRENT_NAME_MAX); + strncpy((char *)d->name, name, DIRENT_NAME_MAX); return d->rlength; } @@ -247,13 +247,12 @@ int fill_dirent(void *buf, unsigned long vnum, int offset, char *name) */ int sys_readdir(l4id_t sender, int fd, void *buf, int count) { - struct dentry *d = list_entry(v->dentries.next, struct dentry, vref); int dirent_size = sizeof(struct dirent); int total = 0, nbytes = 0; unsigned long vnum; struct vnode *v; + struct dentry *d; struct tcb *t; - int err; /* Get the task */ BUG_ON(!(t = find_task(sender))); @@ -266,6 +265,7 @@ int sys_readdir(l4id_t sender, int fd, void *buf, int count) l4_ipc_return(-EINVAL); return 0; /* No such vnode */ } + d = list_entry(v->dentries.next, struct dentry, vref); /* Ensure vnode is a directory */ if (!vfs_isdir(v)) { diff --git a/tasks/fs0/src/vfs.c b/tasks/fs0/src/vfs.c index 3be6f6a..7a703f6 100644 --- a/tasks/fs0/src/vfs.c +++ b/tasks/fs0/src/vfs.c @@ -69,9 +69,9 @@ struct vnode *vfs_lookup_bypath(struct tcb *task, char *path) /* Do we start from root or curdir? */ if (path[0] == '/') - vnstart = task->rootdir; + vstart = task->rootdir; else - vnstart = task->curdir; + vstart = task->curdir; /* * This does vfs cache + fs lookup.