vfs: add dirent parent pointer

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-12 10:47:58 -04:00
commit d2c698ac0a
7 changed files with 25 additions and 13 deletions

View file

@ -53,7 +53,7 @@ static int next_level(const char *path, dirent_t *dent, dirent_t **out_dirent)
if (c == '/' || c == '\0') {
dirent_t *dirent;
res = inode_find_dirent(dent->inode, build, &dirent);
res = dirent_lookup(dent, build, &dirent);
kfree(build);
if (res < 0)
return -ENOENT;
@ -174,7 +174,7 @@ int vfs_readdir(dirent_t *dir, struct dir_context *ctx, dirent_t **out)
if ((ino->mode & S_IFMT) != S_IFDIR)
return -ENOTDIR;
int res = inode_populate_dirents(ino);
int res = dirent_populate_children(dir);
if (res < 0)
return res;
@ -244,7 +244,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
}
dirent_t *test = NULL;
int res = inode_find_dirent_locked(ino, name, &test);
int res = dirent_lookup_locked(parent, name, &test);
if (res == 0) {
dirent_dec_ref(test);
write_unlock(&ino->rwlock);
@ -273,6 +273,7 @@ int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t
}
new_dirent->fs = fs;
new_dirent->parent = parent;
*out = new_dirent;
write_unlock(&ino->rwlock);
return 0;