Fixed lookup return value. Now using generic_lookup directy, i.e.

not through a vnode, because it really isn't fs-specific.
This commit is contained in:
Bahadir Balban
2008-02-15 12:22:07 +00:00
parent 7bbc21d105
commit 5de93f707c
5 changed files with 36 additions and 30 deletions

View File

@@ -27,6 +27,12 @@
* either high-level vfs code, or the mm0 page cache.
* - readdir provides a posix-compliant dirent structure list in dirbuf.
* - memfs dentries should be identical to posix struct dirents.
*
* ALL DONE!!! But untested.
*
* - Add mkdir
* - Add create
* - Add read/write -> This will need page cache and mm0 involvement.
*/
/* TODO:

View File

@@ -57,7 +57,7 @@ struct vnode *lookup_dentry_children(struct dentry *parentdir, char *path)
return v;
/* Out of all children dentries, neither was a match, so we return 0 */
return 0;
return PTR_ERR(-ENOENT);
}
/* Lookup, recursive, assuming single-mountpoint */
@@ -68,7 +68,7 @@ struct vnode *generic_vnode_lookup(struct vnode *thisnode, char *path)
struct vnode *found;
int err;
/* Does this path component match with any of parent vnode's names? */
/* Does this path component match with any of this vnode's dentries? */
list_for_each_entry(d, &thisnode->dentries, vref) {
if (d->ops.compare(d, component)) {
/* Is this a directory? */

View File

@@ -205,11 +205,13 @@ int memfs_write_vnode(struct superblock *sb, struct vnode *v)
}
/*
* 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.
* Reads the vnode directory contents into vnode's buffer in a posix-compliant
* struct dirent format.
*
* TODO: Returns the list of posix-compliant dirent records in the buffer.
* Reading the buffer, 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.
*/
int memfs_vnode_readdir(struct vnode *v)
{
@@ -278,7 +280,6 @@ int memfs_vnode_readdir(struct vnode *v)
}
struct vnode_ops memfs_vnode_operations = {
.lookup = generic_vnode_lookup,
.readdir = memfs_vnode_readdir,
};

View File

@@ -78,15 +78,28 @@ int sys_open(l4id_t sender, const char *pathname, int flags, unsigned int mode)
return do_open(sender, pathname, flags, mode);
}
int sys_mkdir(l4id_t sender, const char *pathname, unsigned int mode)
{
return 0;
}
int sys_read(l4id_t sender, int fd, void *buf, int count)
{
return 0;
}
int sys_write(l4id_t sender, int fd, const void *buf, int count)
{
return 0;
}
int sys_lseek(l4id_t sender, int fd, int offset, int whence)
{
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.
* Reads @count bytes of posix struct dirents into @buf
*/
int sys_readdir(l4id_t sender, int fd, void *buf, int count)
{
@@ -119,20 +132,10 @@ int sys_readdir(l4id_t sender, int fd, void *buf, int count)
/* Do we have those bytes at hand? */
if (v->dirbuf.buffer && (v->dirbuf.npages * PAGE_SIZE) >= nbytes) {
memcpy(buf, v->dirbuf.buffer, nbytes); /* Finish the job */
memcpy(buf, v->dirbuf.buffer, nbytes);
return nbytes;
}
return 0;
}
int sys_write(l4id_t sender, int fd, const void *buf, int count)
{
return 0;
}
int sys_lseek(l4id_t sender, int fd, int offset, int whence)
{
return 0;
}

View File

@@ -30,7 +30,7 @@ struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum)
struct vnode *v;
int err;
/* Check the vnode cache by vnum */
/* Check the vnode flat list by vnum */
list_for_each_entry(v, &vnode_cache, cache_list)
if (v->vnum == vnum)
return v;
@@ -53,7 +53,7 @@ struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum)
return PTR_ERR(err);
}
/* Add the vnode back to vnode cache */
/* Add the vnode back to vnode flat list */
list_add(&v->cache_list, &vnode_cache);
return v;
@@ -70,14 +70,10 @@ struct vnode *vfs_lookup_bypath(struct superblock *sb, char *path)
if (!strcmp(path, "/"))
return sb->root;
/* TODO: Check the vnode cache by path component
*
* This should split the path into components and compare
* each of them with each vnode's dentry list.
/*
* This does vfs cache + fs lookup.
*/
/* It's not in the cache, look it up from filesystem. */
return sb->root->ops.lookup(sb->root, path);
return generic_vnode_lookup(sb->root, path);
}
int vfs_mount_root(struct superblock *sb)