Implemented custom filesystem and got it to compile. It seems that it isn't loading the 3rd stage bootloader though

This commit is contained in:
2024-08-12 16:30:45 +02:00
parent 044b1eceac
commit be6b65863f
7 changed files with 149 additions and 165 deletions
+12 -20
View File
@@ -1,44 +1,36 @@
#ifndef IMPL_H
#define IMPL_H
#include <disk/disk.h>
#include <fs/fs.h>
#include <memory/addresses.h>
#include <disk/disk.h>
#include <stdint.h>
#include <string.h>
char* currentDir;
inode_t currentDirINode;
char tempSector[FS_SECTOR_SIZE];
char tempBlock[FS_BLOCK_SIZE];
inode_t* getInode(char* path) {
dirEntry_t* dentry = (dirEntry_t*)SCRATCH_BLOCK_LOC;
inode_t rootINode;
inode_t* getINode(char* path) {
dirEntry_t* dirEntry = (dirEntry_t*)SCRATCH_BLOCK_LOC;
while (dirEntry->name[0] != '\0') {
if (strcmp(dirEntry->name, path) == 0) break;
dirEntry++;
while (dentry->name[0] != '\0') {
if (strcmp(dentry->name, path)) break;
dentry++;
}
if (dirEntry->name[0] == '\0') return NULL;
if (dentry->name[0] == '\0') return NULL;
inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC;
while (inode->id != dirEntry->id) {
inode++;
}
while (inode->id != dentry->id) { inode++; }
return inode;
}
uint8_t loadFile(inode_t* inode, void* dest) {
uint32_t totalBlocks = bytesToBlocks(inode->sizeBytes);
uint32_t addressOffset = 0;
uint32_t totalBlocks = BYTES2BLOCKS(inode->sizeBytes);
uint32_t offset = 0;
for (uint8_t i = 0; i < 4 && totalBlocks > 0; i++) {
diskRead(inode->extent[i].firstBlock * 8, inode->extent[i].length * 8, dest + addressOffset);
addressOffset += inode->extent[i].length * FS_BLOCK_SIZE;
diskRead(inode->extent[i].block * 8, inode->extent[i].length * 8, dest + offset);
offset += inode->extent[i].length * FS_BLOCK_SIZE;
totalBlocks -= inode->extent[i].length;
}