ext2: add ext2 driver v2
This driver is not yet feature complete, yet it is much cleaner than the old one.
This commit is contained in:
parent
1ae9bce778
commit
623cb5905a
5 changed files with 336 additions and 723 deletions
|
|
@ -90,8 +90,6 @@ struct fs *devfs_init()
|
||||||
devfs->ops->write = devfs_write;
|
devfs->ops->write = devfs_write;
|
||||||
devfs->ops->unlink = devfs_unlink;
|
devfs->ops->unlink = devfs_unlink;
|
||||||
devfs->ops->open_vno = devfs_open_vno;
|
devfs->ops->open_vno = devfs_open_vno;
|
||||||
devfs->ops->readdir = devfs_readdir;
|
|
||||||
devfs->ops->open_dir = devfs_open_dir;
|
|
||||||
|
|
||||||
devfs->root->flags = VFS_VNO_DIR;
|
devfs->root->flags = VFS_VNO_DIR;
|
||||||
devfs->root->fs = devfs;
|
devfs->root->fs = devfs;
|
||||||
|
|
|
||||||
18
fs/vfs.c
18
fs/vfs.c
|
|
@ -132,15 +132,6 @@ struct file *vfs_open(const char *pathname, int *err)
|
||||||
goto out_2;
|
goto out_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_vnode->flags & VFS_VNO_DIR) {
|
|
||||||
int res = fs->ops->open_dir(new_vnode->fs, new_vnode);
|
|
||||||
if (res < 0) {
|
|
||||||
ATTEMPT_WRITE(err, res);
|
|
||||||
slab_free(vnode_slab, new_vnode);
|
|
||||||
goto out_2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_vnode = new_vnode;
|
cur_vnode = new_vnode;
|
||||||
entry->vnode = cur_vnode;
|
entry->vnode = cur_vnode;
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +204,6 @@ ssize_t vfs_read(struct file *file, void *buf, off_t off, size_t count)
|
||||||
if (off + count > file->vnode->size)
|
if (off + count > file->vnode->size)
|
||||||
count = file->vnode->size - off;
|
count = file->vnode->size - off;
|
||||||
|
|
||||||
|
|
||||||
return file->vnode->fs->ops->read(file->vnode, buf, off, count);
|
return file->vnode->fs->ops->read(file->vnode, buf, off, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -456,14 +446,8 @@ struct fs *vfs_mount_root(const char *dev, const char *mount_point)
|
||||||
strcpy(fs->mount_point, mount_point);
|
strcpy(fs->mount_point, mount_point);
|
||||||
|
|
||||||
struct vnode *root = fs->root;
|
struct vnode *root = fs->root;
|
||||||
struct dirent *dirents = NULL;
|
|
||||||
int num_dirents = fs->ops->readdir(root, &dirents);
|
|
||||||
if (num_dirents < 0)
|
|
||||||
goto out_dealloc_fs;
|
|
||||||
|
|
||||||
root->dirents = dirents;
|
|
||||||
root->num_dirents = num_dirents;
|
|
||||||
root->no_free = true;
|
root->no_free = true;
|
||||||
|
|
||||||
return fs;
|
return fs;
|
||||||
|
|
||||||
out_dealloc_fs:
|
out_dealloc_fs:
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ struct ext2fs {
|
||||||
uint32_t bgdt_num_blocks;
|
uint32_t bgdt_num_blocks;
|
||||||
struct ext2_group_desc *bgdt;
|
struct ext2_group_desc *bgdt;
|
||||||
|
|
||||||
|
spinlock_t lock;
|
||||||
|
|
||||||
uint32_t indir_block_size;
|
uint32_t indir_block_size;
|
||||||
|
|
||||||
uint32_t block_size;
|
uint32_t block_size;
|
||||||
|
|
|
||||||
|
|
@ -117,10 +117,8 @@ struct file_descriptor {
|
||||||
struct fs_ops {
|
struct fs_ops {
|
||||||
int (*read)(struct vnode *vnode, void *buf, size_t offset, size_t size);
|
int (*read)(struct vnode *vnode, void *buf, size_t offset, size_t size);
|
||||||
int (*write)(struct vnode *vnode, void *buf, size_t offset, size_t size);
|
int (*write)(struct vnode *vnode, void *buf, size_t offset, size_t size);
|
||||||
int (*readdir)(struct vnode *vnode, struct dirent **dir);
|
|
||||||
int (*unlink)(struct fs *fs, const char *path); /* change to vno, not path) */
|
int (*unlink)(struct fs *fs, const char *path); /* change to vno, not path) */
|
||||||
int (*open_vno)(struct fs *vfs, struct vnode *out, ino_t ino_num);
|
int (*open_vno)(struct fs *vfs, struct vnode *out, ino_t ino_num);
|
||||||
int (*open_dir)(struct fs *vfs, struct vnode *out);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fs {
|
struct fs {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue