From 430112c8d7224bf9d1e192adfc9fb55e7a044f83 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 22 Oct 2014 09:51:03 +0200 Subject: started abstraction for filesystems --- fs/Makefile | 9 ++++++++- fs/ext2.c | 5 ++--- fs/fs.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 fs/fs.c diff --git a/fs/Makefile b/fs/Makefile index c88dda4..d339621 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -4,6 +4,13 @@ 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 ^large_file ext2.img + 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 38ea06b..90897e9 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -96,6 +96,7 @@ typedef struct ext2_inode_struct }ext2_inode; + int main() { ext2_superblock super; @@ -142,6 +143,7 @@ int main() int block_size=1024; int descriptor_start_block=2; fseek(stdin,block_size*descriptor_start_block,SEEK_SET); + fread(&desc,sizeof(desc),1,stdin); printf("block usage bitmap: 0x%x\n",desc.addr_block_bitmap); printf("inode usage bitmap: 0x%x\n",desc.addr_inode_bitmap); @@ -188,9 +190,6 @@ int main() puts(""); puts(""); - - - } diff --git a/fs/fs.c b/fs/fs.c new file mode 100644 index 0000000..a213861 --- /dev/null +++ b/fs/fs.c @@ -0,0 +1,32 @@ +// abstraction layer for filesystems +#include + +enum FS_FILE_TYPE{ + + FS_FILE_TYPE_DIR = 1, + FS_FILE_TYPE_FILE = 2 +}; + +typedef struct fs_file_struct +{ + int type; + char name[256]; + +}fs_file; + +int fs_list(char *path, fs_file *list); +{ + +} + +int fs_read(char *path, uint8_t *buf) +{ + +} + +int fs_mount(char *dev, char *dir) +{ + +} + + -- cgit v1.2.3