From 55365e593c27b57c50a7369597bd14f110ba8cb6 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 22 Oct 2014 21:21:32 +0200 Subject: reading userprogramm from ext2 ramimage! --- fs/Makefile | 16 ------- fs/ext2.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- fs/fs.c | 2 + 3 files changed, 143 insertions(+), 18 deletions(-) delete mode 100644 fs/Makefile (limited to 'fs') diff --git a/fs/Makefile b/fs/Makefile deleted file mode 100644 index d339621..0000000 --- a/fs/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -run: a.out - ./a.out < ext2.img -a.out: ext2.c - gcc ext2.c -std=c11 -filesys: - dd if=/dev/zero of=ext2.img bs=512 count=10000 - sudo mkfs.ext2 -O none ext2.img - mkdir mnt - sudo mount ext2.img mnt - sudo chown miguel mnt - mkdir mnt/miguel - echo "hello one" > mnt/miguel/test1.txt - echo "hello two" > mnt/test2.txt - sync - - diff --git a/fs/ext2.c b/fs/ext2.c index bc83f55..bdfb80b 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -1,7 +1,10 @@ // ext2 minidriver // based on osdev wiki article: http://wiki.osdev.org/Ext2 +#define FOOLOS_MODULE_NAME "ext2" + #include "lib/int/stdint.h" +#include "lib/logger/log.h" typedef struct ext2_superblock_struct { @@ -95,13 +98,149 @@ typedef struct ext2_inode_struct }ext2_inode; +void ram_read(char *in,char *out,int size, int count) +{ + for(int i=0;i=block_size) + { + block++; + + if(block>=12) + { + int indirect_block=block-12; + uint32_t *indirect_ptr=ram+block_size*inode.indirect1; + ptr=ram+block_size*indirect_ptr[indirect_block]; + + } + else + { + ptr=ram+block_size*inode.direct_pointer[block]; + } + + block_counter=0; + } + + + + } +// if(block>=12)panic(FOOLOS_MODULE_NAME,"such big files unsupported yet"); + + +} + + + +int ext2_read_root_dir(uint8_t *ram) +{ + + ext2_inode inode=ext2_get_inode(ram,2); + + char buf[256]; + int block_size=1024; + uint8_t *ptr=ram+block_size*inode.direct_pointer[0]; //use other pointers in future! + + int pos=0; + while(pos