From 06e6e427c76bdb88a7f72dd04411d95a4bda3270 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sun, 16 Sep 2018 23:46:30 +0200 Subject: starting to create sysfs --- fs/ext2.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'fs/ext2.c') diff --git a/fs/ext2.c b/fs/ext2.c index 659edda..b518bd9 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -1,6 +1,7 @@ #include #include +#include "mount.h" #include "kernel.h" #include "ext2.h" @@ -303,3 +304,27 @@ int ext2_read_dir(uint32_t ext2_start_addr, int inode_nr, fs_dirent *dirs, uint3 } return 0; } + +/* mount interface */ + +fd ext2_mount_file_open(mount *m,char *path) +{ + return fd_from_path(path); +} + +int ext2_mount_read_dir(mount *m,char *path, fs_dirent *dirs, uint32_t *pos) +{ + uint32_t inode= ext2_filename_to_inode(VMEM_EXT2_RAMIMAGE,path); + return ext2_read_dir(m->data, inode, dirs, pos); +} + +void ext2_mount(char *path) +{ + mount m; + m.type=MOUNT_TYPE_EXT2; + memcpy(m.path,path,strlen(path)+1); + m.mount_file_open=ext2_mount_file_open; + m.mount_read_dir=ext2_mount_read_dir; + m.data=VMEM_EXT2_RAMIMAGE; + mount_add(m); +} -- cgit v1.2.3