vfs: add vfs stubs

this also adds a small compatibility layer to the ext2 functions
This commit is contained in:
Michael Shaw 2023-10-19 01:03:27 -04:00
commit 5ebafca2e6
4 changed files with 108 additions and 11 deletions

View file

@ -3,6 +3,7 @@
#include <dev/console.h>
#include <fs/ext2.h>
#include <fs/vfs.h>
static int ext2_read_super(struct block_device *bdev, struct ext2_superblock *sb_struct)
{
@ -113,7 +114,7 @@ int ext2_write_inode(struct ext2fs *fs, struct ext2_inode *in, uint32_t inode)
return 0;
}
int ext2_open_file(struct ext2fs *fs, struct ext2_file *file, const char *path)
int ext2_open_file(struct ext2fs *fs, struct file *file, const char *path)
{
/* find the inode of the file */
struct ext2_inode *inode = kmalloc(sizeof(struct ext2_inode), ALLOC_KERN);
@ -137,6 +138,7 @@ int ext2_open_file(struct ext2fs *fs, struct ext2_file *file, const char *path)
spinlock_acquire(&strtok_lock);
char *token = strtok(path_copy, "/");
uint32_t inode_no = 2;
while (token) {
struct ext2_dir_entry *entry = kmalloc(fs->block_size, ALLOC_DMA);
if (!entry) {
@ -166,6 +168,7 @@ int ext2_open_file(struct ext2fs *fs, struct ext2_file *file, const char *path)
kfree(name);
inode_no = entry->inode;
entry = (void *)entry + entry->rec_len;
}
@ -185,9 +188,9 @@ int ext2_open_file(struct ext2fs *fs, struct ext2_file *file, const char *path)
kfree(path_copy);
file->inode = *inode;
file->offset = 0;
memcpy(&file->inode, inode, sizeof(struct inode));
file->size = inode->size;
file->inode_num = inode_no;
/* check for long filesize */
if (fs->sb.feature_ro_compat & EXT2_FLAG_LONG_FILESIZE)
@ -196,6 +199,21 @@ int ext2_open_file(struct ext2fs *fs, struct ext2_file *file, const char *path)
return 0;
}
int ext2_close_file(struct ext2fs *fs, struct file *file)
{
return 0;
}
int ext2_write_file(struct ext2fs *fs, struct file *file, const void *buf, size_t count)
{
return 0;
}
int ext2_read_file(struct ext2fs *fs, struct file *file, const void *buf, size_t count)
{
return 0;
}
#ifdef KDEBUG
static void ext2_print_dir(struct ext2fs *fs, struct ext2_inode *inode, int indent)
{