From ec0ba7bc40854eab6a1cdb41364f41f9c11407e1 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 23 Nov 2014 23:26:26 +0100 Subject: foolshell and syscalls improvememets --- fs/ext2.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'fs/ext2.c') diff --git a/fs/ext2.c b/fs/ext2.c index 6920b40..4db858f 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -3,6 +3,8 @@ #define FOOLOS_MODULE_NAME "ext2" +#include + #include "lib/int/stdint.h" #include "lib/logger/log.h" #include "fs.h" @@ -240,11 +242,53 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max) } -//TODO!!! -int ext2_filename_to_inode(char *path) +int ext2_filename_to_inode_traverse(uint8_t *ram, char *path,int inode_start) { + bool final=false; + + // skip leading slashes + while(*path=='/')path++; + char *first=path; + + while(*path!='/'&&*path!=0)path++; + char *last=path; + + if(*path==0)final=true; + else(*path=0); + + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"looking for %s '%s' in inode: %d",final?"file":"dir",first,inode_start); + + fs_dirent dirs[15]; + int count= ext2_read_dir(ram, inode_start,dirs,15); // get dir + + for(int i=0;i