mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Commited some old changes, idk what they were
This commit is contained in:
+6
-7
@@ -27,11 +27,11 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint32_t inodeCount;
|
||||
|
||||
uint16_t firstInodeBitmapBlock;
|
||||
uint16_t firstINodeBitmapBlock;
|
||||
uint16_t firstDataBitmapBlock;
|
||||
uint16_t inodeBitmapBlockCount;
|
||||
uint16_t dataBitmapBlockCount;
|
||||
uint32_t firstInodeBlock;
|
||||
uint32_t firstINodeBlock;
|
||||
uint32_t firstDataBlock;
|
||||
uint16_t inodeBlockCount;
|
||||
uint16_t dataBlockCount;
|
||||
@@ -40,14 +40,14 @@ typedef struct {
|
||||
uint16_t blockSize; // in bytes
|
||||
uint8_t inodeSize; // in bytes
|
||||
|
||||
uint32_t rootInodePtr;
|
||||
uint32_t rootINodePtr;
|
||||
uint8_t inodesPerBlock;
|
||||
uint8_t directExtentsPerInode;
|
||||
uint8_t directExtentsPerINode;
|
||||
uint16_t extentsPerIndirectBlock;
|
||||
uint32_t firstFreeInodeBit;
|
||||
uint32_t firstFreeINodeBit;
|
||||
uint32_t firstFreeDataBit;
|
||||
uint16_t deviceNumber;
|
||||
uint8_t firstUnreservedInode;
|
||||
uint8_t firstUnreservedINode;
|
||||
|
||||
uint8_t reserved[14];
|
||||
} __attribute__ ((packed)) superBlock_t;
|
||||
@@ -87,5 +87,4 @@ uint32_t bytesToSectors(uint32_t bytes) {
|
||||
if (bytes <= FS_SECTOR_SIZE) return 1;
|
||||
return (bytes / FS_SECTOR_SIZE) + ((bytes % FS_SECTOR_SIZE) > 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#ifndef IMPL_H
|
||||
#define IMPL_H
|
||||
|
||||
#include <disk/disk.h>
|
||||
#include <fs/fs.h>
|
||||
#include <memory/addresses.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
char* currentDir;
|
||||
inode_t currentDirINode;
|
||||
|
||||
char tempSector[FS_SECTOR_SIZE];
|
||||
char tempBlock[FS_BLOCK_SIZE];
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
if (dirEntry->name[0] == '\0') return NULL;
|
||||
|
||||
inode_t* inode = (inode_t*)BOOT_FIRST_INODE_LOC;
|
||||
while (inode->id != dirEntry->id) {
|
||||
inode++;
|
||||
}
|
||||
|
||||
return inode;
|
||||
}
|
||||
|
||||
uint8_t loadFile(inode_t* inode, void* dest) {
|
||||
uint32_t totalBlocks = bytesToBlocks(inode->sizeBytes);
|
||||
uint32_t addressOffset = 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;
|
||||
totalBlocks -= inode->extent[i].length;
|
||||
}
|
||||
|
||||
if (totalBlocks > 0) {
|
||||
// TODO: Indirect extents
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user