Got ext2 directory support working
This commit is contained in:
parent
04c8a3e4be
commit
0f406b1f01
20
fs/ext2.c
20
fs/ext2.c
@ -234,14 +234,15 @@ static char drv(fs_op op,FILE* stream,void* data1,void* data2) {
|
|||||||
if (data) {
|
if (data) {
|
||||||
FILE* f=fopen(devs[data->num],"r");
|
FILE* f=fopen(devs[data->num],"r");
|
||||||
uint32_t inode_num=2;
|
uint32_t inode_num=2;
|
||||||
|
inode inode;
|
||||||
for (char* tok=strtok(stream->path,"/");tok!=NULL;tok=strtok(NULL,"/")) {
|
for (char* tok=strtok(stream->path,"/");tok!=NULL;tok=strtok(NULL,"/")) {
|
||||||
char got_inode;
|
char got_inode;
|
||||||
inode_num=inode_for_fname(inode_num,tok,&got_inode,f,data->num);
|
inode_num=inode_for_fname(inode_num,tok,&got_inode,f,data->num);
|
||||||
if (got_inode) {
|
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) {
|
if ((inode.i_mode&EXT2_S_IFDIR)==0) {
|
||||||
char* next_tok=strtok(NULL,"/");
|
char* next_tok=strtok(NULL,"/");
|
||||||
if (tok) {
|
if (next_tok) {
|
||||||
klog("INFO","%s: Not a directory",tok);
|
klog("INFO","%s: Not a directory",tok);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 0;
|
return 0;
|
||||||
@ -255,18 +256,9 @@ static char drv(fs_op op,FILE* stream,void* data1,void* data2) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
klog("INFO","File inode:%d",inode_num);
|
data->inode=inode;
|
||||||
return 0;
|
fclose(f);
|
||||||
// char got_inode;
|
return 1;
|
||||||
// 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;
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -117,10 +117,10 @@ static void init() {
|
|||||||
init_ext2();
|
init_ext2();
|
||||||
mount("/","/dev/hda","ext2");
|
mount("/","/dev/hda","ext2");
|
||||||
FILE* f=fopen("/mydir/myfile","r");
|
FILE* f=fopen("/mydir/myfile","r");
|
||||||
// char str[256];
|
char str[256];
|
||||||
// fgets(str,256,f);
|
fgets(str,256,f);
|
||||||
// str[strlen(str)-1]='\0';
|
str[strlen(str)-1]='\0';
|
||||||
// klog("INFO","Got string %s",str);
|
klog("INFO","Got string %s",str);
|
||||||
// fgets(str,256,f);
|
// fgets(str,256,f);
|
||||||
// str[strlen(str)-1]='\0';
|
// str[strlen(str)-1]='\0';
|
||||||
// klog("INFO","Got string %s",str);
|
// klog("INFO","Got string %s",str);
|
||||||
|
Loading…
Reference in New Issue
Block a user