Hack together open()

This commit is contained in:
Byron Lathi
2023-12-05 18:04:08 -08:00
parent 9ae1593957
commit 48b39eb92d
7 changed files with 130 additions and 31 deletions

View File

@@ -1,9 +1,17 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <process/process.h>
#define FILE_PATH "fs.fat"
struct pcb fake_pcb;
//TODO
struct pcb* get_pcb_ptr() {
return &fake_pcb;
}
uint32_t lmulii(uint16_t a, uint16_t b) {
printf("lmulii: %x * %x = %x\n", a, b, a*b);
return a * b;

View File

@@ -5,35 +5,11 @@
void fat32_init(void);
int main(void) {
struct fat32_directory_entry dentry;
int i;
uint32_t offset = 0;
uint32_t cluster;
uint8_t cluster_count;
int8_t fd;
fat32_init();
/* This is what is going to be part of open */
fat32_get_cluster_by_name("VERYLA~1TXT", &dentry);
cprintf("attr1: %x\n", dentry.attr1);
cprintf("cluster: %x%x\n", dentry.cluster_high, dentry.cluster_low);
cprintf("File Size: %lx\n", dentry.file_size);
fd = fat32_file_open("VERYLA~1TXT");
/* This will become part of read */
cluster = (dentry.cluster_high << 16) | dentry.cluster_low;
cluster++;
fat32_read_cluster(cluster + offset/512, sd_buf);
cluster_count = (dentry.file_size/512)/sectors_per_cluster;
cprintf("Cluster count: %x\n", cluster_count);
while (cluster < 0xffffff0) {
for (i = 0; i < dentry.file_size && i < 512; i++) {
cprintf("%c", sd_buf[i]);
}
cluster = fat32_next_cluster(cluster);
fat32_read_cluster(cluster + offset/512, sd_buf);
}
return 0;
cprintf("fd: %x\n", fd);
}