mirror of
https://github.com/drasko/codezero.git
synced 2026-07-20 22:25:24 +02:00
Root was a child of itself, removed that relationship.
Root is only a parent of itself, it shouldn't show up in its children.
This commit is contained in:
@@ -46,10 +46,8 @@ struct vnode *generic_vnode_lookup(struct vnode *thisnode,
|
|||||||
struct vnode *found;
|
struct vnode *found;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
printf("looking up: %s\n", component);
|
|
||||||
/* Does this path component match with any of this vnode's dentries? */
|
/* Does this path component match with any of this vnode's dentries? */
|
||||||
list_for_each_entry(d, &thisnode->dentries, vref) {
|
list_for_each_entry(d, &thisnode->dentries, vref) {
|
||||||
printf("comparing dentry %s with %s\n", d->name, component);
|
|
||||||
if (d->ops.compare(d, component)) {
|
if (d->ops.compare(d, component)) {
|
||||||
/* Is this a directory? */
|
/* Is this a directory? */
|
||||||
if (vfs_isdir(thisnode)) {
|
if (vfs_isdir(thisnode)) {
|
||||||
|
|||||||
@@ -136,8 +136,12 @@ int memfs_init_rootdir(struct superblock *sb)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise it.
|
* Initialise root dentry.
|
||||||
* NOTE: On root, parent is itself.
|
*
|
||||||
|
* NOTE: Root's parent is itself.
|
||||||
|
* Here's how it looks like in structures:
|
||||||
|
* root's parent is root. But root's child is not root.
|
||||||
|
*
|
||||||
* NOTE: Root has no name. This helps since splitpath
|
* NOTE: Root has no name. This helps since splitpath
|
||||||
* cuts out the '/' and "" is left for root name search.
|
* cuts out the '/' and "" is left for root name search.
|
||||||
*/
|
*/
|
||||||
@@ -149,9 +153,6 @@ int memfs_init_rootdir(struct superblock *sb)
|
|||||||
/* Associate dentry with its vnode */
|
/* Associate dentry with its vnode */
|
||||||
list_add(&d->vref, &d->vnode->dentries);
|
list_add(&d->vref, &d->vnode->dentries);
|
||||||
|
|
||||||
/* Associate dentry with its parent */
|
|
||||||
list_add(&d->child, &d->children);
|
|
||||||
|
|
||||||
/* Add both vnode and dentry to their flat caches */
|
/* Add both vnode and dentry to their flat caches */
|
||||||
list_add(&d->cache_list, &dentry_cache);
|
list_add(&d->cache_list, &dentry_cache);
|
||||||
list_add(&v->cache_list, &vnode_cache);
|
list_add(&v->cache_list, &vnode_cache);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void print_vnode(struct vnode *v)
|
|||||||
{
|
{
|
||||||
struct dentry *d, *c;
|
struct dentry *d, *c;
|
||||||
|
|
||||||
printf("Vnode name:\n");
|
printf("Vnode names:\n");
|
||||||
list_for_each_entry(d, &v->dentries, vref) {
|
list_for_each_entry(d, &v->dentries, vref) {
|
||||||
printf("%s\n", d->name);
|
printf("%s\n", d->name);
|
||||||
printf("Children dentries:\n");
|
printf("Children dentries:\n");
|
||||||
@@ -79,7 +79,7 @@ int vfs_create(struct tcb *task, struct pathdata *pdata, unsigned int mode)
|
|||||||
if ((err = vparent->ops.mknod(vparent, nodename, mode)) < 0)
|
if ((err = vparent->ops.mknod(vparent, nodename, mode)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
// print_vnode(vparent);
|
print_vnode(vparent);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user