Fixed compilation errors for filldir/sys_readdir() changes.

This commit is contained in:
Bahadir Balban
2008-04-12 18:03:49 +01:00
parent d7b06b5304
commit 367e455506
6 changed files with 16 additions and 18 deletions

View File

@@ -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);

View File

@@ -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)));

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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)) {

View File

@@ -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.