Got ext2 directory support working

This commit is contained in:
pjht 2019-04-08 11:24:03 -05:00
parent 04c8a3e4be
commit 0f406b1f01
2 changed files with 10 additions and 18 deletions

View File

@ -234,14 +234,15 @@ static char drv(fs_op op,FILE* stream,void* data1,void* data2) {
if (data) {
FILE* f=fopen(devs[data->num],"r");
uint32_t inode_num=2;
inode inode;
for (char* tok=strtok(stream->path,"/");tok!=NULL;tok=strtok(NULL,"/")) {
char got_inode;
inode_num=inode_for_fname(inode_num,tok,&got_inode,f,data->num);
if (got_inode) {
inode inode=read_inode(inode_num,f,data->num);
inode=read_inode(inode_num,f,data->num);
if ((inode.i_mode&EXT2_S_IFDIR)==0) {
char* next_tok=strtok(NULL,"/");
if (tok) {
if (next_tok) {
klog("INFO","%s: Not a directory",tok);
fclose(f);
return 0;
@ -255,18 +256,9 @@ static char drv(fs_op op,FILE* stream,void* data1,void* data2) {
return 0;
}
}
klog("INFO","File inode:%d",inode_num);
return 0;
// char got_inode;
// uint32_t inode_num=inode_for_fname(2,stream->path,&got_inode,f,data->num);
// if (got_inode) {
// data->inode=read_inode(inode_num,f,data->num);
// fclose(f);
// return 1;
// } else {
// fclose(f);
// return 0;
// }
data->inode=inode;
fclose(f);
return 1;
} else {
return 0;
}

View File

@ -117,10 +117,10 @@ static void init() {
init_ext2();
mount("/","/dev/hda","ext2");
FILE* f=fopen("/mydir/myfile","r");
// char str[256];
// fgets(str,256,f);
// str[strlen(str)-1]='\0';
// klog("INFO","Got string %s",str);
char str[256];
fgets(str,256,f);
str[strlen(str)-1]='\0';
klog("INFO","Got string %s",str);
// fgets(str,256,f);
// str[strlen(str)-1]='\0';
// klog("INFO","Got string %s",str);