summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/elf.c5
-rw-r--r--fs/elf.h1
-rw-r--r--fs/ext2.c22
-rw-r--r--fs/file.h2
-rw-r--r--fs/fs.h2
-rw-r--r--fs/mount.h2
6 files changed, 20 insertions, 14 deletions
diff --git a/fs/elf.c b/fs/elf.c
index 1a6fa89..bca527a 100644
--- a/fs/elf.c
+++ b/fs/elf.c
@@ -1,6 +1,7 @@
#include "kernel/kernel.h"
#include <stdint.h>
#include "ext2.h"
+#include "lib/string/string.h"
#define EI_NIDENT 16
@@ -149,14 +150,14 @@ uint32_t load_elf(char *name, uint32_t *alloc)
//uint8_t *data=vaddr+phdr->p_offset;
uint8_t *data=vaddr+phdr->p_offset+phdr->p_filesz-1;
- for(uint8_t *addr=phdr->p_vaddr+phdr->p_filesz-1; addr>=phdr->p_vaddr; addr--)
+ for(uint8_t *addr=phdr->p_vaddr+phdr->p_filesz-1; (uint32_t)addr>=phdr->p_vaddr; addr--)
{
*addr=*data;
data--;
}
// let's zero init bss and set alloc (heap) just right after it!
- for(uint8_t *addr=phdr->p_vaddr+phdr->p_filesz; addr<=phdr->p_vaddr+phdr->p_memsz; addr++)
+ for(uint8_t *addr=phdr->p_vaddr+phdr->p_filesz; (uint32_t)addr<=phdr->p_vaddr+phdr->p_memsz; addr++)
{
*addr=0;
}
diff --git a/fs/elf.h b/fs/elf.h
index fe3e952..bcbfc2d 100644
--- a/fs/elf.h
+++ b/fs/elf.h
@@ -1,2 +1 @@
-
uint32_t load_elf(char *name, uint32_t *alloc);
diff --git a/fs/ext2.c b/fs/ext2.c
index f1e368d..7562cf0 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -1,6 +1,9 @@
#include "kernel/kernel.h"
// ext2 minidriver
// based on osdev wiki article: http://wiki.osdev.org/Ext2
+//
+//
+#include "lib/string/string.h"
@@ -116,12 +119,13 @@ int ext2_check(uint8_t *ram)
ext2_superblock super;
ext2_superblock_ext super_ext;
uint8_t *ptr=ram+1024;
- ram_read(ptr,&super,sizeof(super),1);
+ ram_read((char*)ptr,&super,sizeof(super),1);
if(super.ext2_sig!=0xef53){
klog("addr: 0x%08X",ram);
kpanic("no ext2 signature found, where ram-image expected");
}
+ return 1;
}
ext2_inode ext2_get_inode(uint8_t *ram,int inode_num)
@@ -133,7 +137,7 @@ ext2_inode ext2_get_inode(uint8_t *ram,int inode_num)
ext2_inode inode;
uint8_t *ptr=ram+1024;
- ram_read(ptr,&super,sizeof(super),1);
+ ram_read((char*)ptr,&super,sizeof(super),1);
if(super.ext2_sig!=0xef53)
{
klog("addr: 0x%08X",ram);
@@ -150,13 +154,13 @@ ext2_inode ext2_get_inode(uint8_t *ram,int inode_num)
ptr=ram+block_size*descriptor_start_block;
ptr+=sizeof(desc)*block_group; // skip to our descriptor;
- ram_read(ptr,&desc,sizeof(desc),1); // read descriptor
+ ram_read((char*)ptr,&desc,sizeof(desc),1); // read descriptor
// read our inode;
ptr=ram+block_size*desc.addr_inode_table;
ptr+=128*((inode_num-1)%super.inodes_per_group);
- ram_read(ptr,&inode,sizeof(inode),1); //get inode 2 (rood-directory)
+ ram_read((char*)ptr,&inode,sizeof(inode),1); //get inode 2 (rood-directory)
return inode;
@@ -189,8 +193,8 @@ void* ext2_get_indirectstart_double(void *start, uint32_t block_size, uint32_t i
int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max)
{
- ext2_check(ram);
- ext2_inode inode=ext2_get_inode(ram,inode_nr);
+ ext2_check((uint8_t *)ram);
+ ext2_inode inode=ext2_get_inode((uint8_t*)ram,inode_nr);
int pos=0;
int block=0;
@@ -248,7 +252,7 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max)
}
klog("Fool Check Sum: 0x%08X for %d bytes",sum,count);
-
+ return 1;
}
int ext2_filename_to_inode_traverse(uint8_t *ram, char *path,int inode_start)
@@ -322,11 +326,11 @@ int ext2_read_dir(uint8_t *ram, int inode_nr,fs_dirent *dirs,int max)
// read dir data
ext2_dir dir;
- ram_read(ptr,&dir,sizeof(dir),1);
+ ram_read((char*)ptr,&dir,sizeof(dir),1);
// read name
ptr+=sizeof(dir);
- ram_read(ptr,&buf,sizeof(char),dir.name_length_low);
+ ram_read((char*)ptr,&buf,sizeof(char),dir.name_length_low);
ptr+=dir.name_length_low;
buf[dir.name_length_low]=0;
diff --git a/fs/file.h b/fs/file.h
index 7734393..53c96d8 100644
--- a/fs/file.h
+++ b/fs/file.h
@@ -13,7 +13,7 @@ typedef struct
int(* wrtie)(char *buf, int len);
int(* close)();
- int(* stat)(struct stat *buf);
+ int(* stat)(void *buf);
void *data; //opaque
diff --git a/fs/fs.h b/fs/fs.h
index aa38180..79583cf 100644
--- a/fs/fs.h
+++ b/fs/fs.h
@@ -20,6 +20,8 @@ typedef struct fs_dirent_struct
}fs_dirent;
int fs_readdir(const char *name,fs_dirent *dirs,int max);
+void fs_content(char *path, uint32_t dest, uint32_t max_bytes);
void fs_mount(multiboot_information *info); // mounts ext2 ramimage from module as root
+uint32_t fs_get_root_ext2_ramimage();
#endif
diff --git a/fs/mount.h b/fs/mount.h
index 0a330a6..1231fcd 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -12,7 +12,7 @@ typedef struct mount_struct
char path[256]; // where are we mounted
int (*getdents) (struct mount_struct*, uint32_t file_desciptor, fs_dirent *entries, uint32_t max_count);
file (*open) (struct mount_struct*,char *path);
- void *data //opaque
+ void *data; //opaque
}mount;