vfs: add initial ramfs driver
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
dec9b2c715
commit
e4122d1c65
5 changed files with 244 additions and 8 deletions
10
fs/vfs/vfs.c
10
fs/vfs/vfs.c
|
|
@ -44,9 +44,9 @@ static char *path_trim(const char *name)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int next_level(const char *path, inode_t *dir, dirent_t **out_dirent)
|
||||
static int next_level(const char *path, dirent_t *dent, dirent_t **out_dirent)
|
||||
{
|
||||
if (!dir || !out_dirent)
|
||||
if (!dent || !out_dirent)
|
||||
return -EINVAL;
|
||||
|
||||
int res;
|
||||
|
|
@ -57,14 +57,14 @@ static int next_level(const char *path, inode_t *dir, dirent_t **out_dirent)
|
|||
|
||||
if (c == '/' || c == '\0') {
|
||||
dirent_t *dirent;
|
||||
res = inode_find_dirent(dir, build, &dirent);
|
||||
res = inode_find_dirent(dent->inode, build, &dirent);
|
||||
if (res < 0)
|
||||
return -ENOENT;
|
||||
|
||||
spinlock_acquire(&dirent->lock);
|
||||
|
||||
if (!dirent->inode) {
|
||||
fs_t *fs = dir->dentry->fs;
|
||||
fs_t *fs = dent->fs;
|
||||
u64 inum = dirent->ino_num;
|
||||
res = fs->fs_ops.open_inode(fs, inum, dirent, &dirent->inode);
|
||||
if (res < 0) {
|
||||
|
|
@ -116,7 +116,7 @@ int vfs_open(const char *abs_path, dirent_t **out)
|
|||
while (1) {
|
||||
dirent_t *next_dir;
|
||||
|
||||
int res = next_level(cur_path, current_dir->inode, &next_dir);
|
||||
int res = next_level(cur_path, current_dir, &next_dir);
|
||||
|
||||
if (res < 0) {
|
||||
dirent_dec_ref(current_dir);
|
||||
|
|
|
|||
Loading…
Reference in a new issue