start messing with fat32
This commit is contained in:
@@ -7,9 +7,90 @@
|
||||
#include "../include/pic.h"
|
||||
#include "../include/pit.h"
|
||||
#include "../include/paging.h"
|
||||
#include "../include/fat.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
disk_ops_t ops =
|
||||
{
|
||||
.read = ata_read,
|
||||
.write = ata_write,
|
||||
};
|
||||
|
||||
static fat_t g_fat;
|
||||
static const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
static int cat(const char* path)
|
||||
{
|
||||
file_t file;
|
||||
int err = fat_fopen(&file, path, "r");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
uint8_t buf[512];
|
||||
for (;;)
|
||||
{
|
||||
int cnt = fat_fread(&file, buf, 512);
|
||||
if (cnt < 0)
|
||||
return cnt;
|
||||
|
||||
printf("%.*s\n", cnt, buf);
|
||||
if (cnt < 512)
|
||||
break;
|
||||
}
|
||||
|
||||
return fat_fclose(&file);
|
||||
}
|
||||
|
||||
static int ls(const char* path)
|
||||
{
|
||||
dir_t dir;
|
||||
dir_info_t info;
|
||||
|
||||
printf("\nListing items in %s:\n\n", path);
|
||||
|
||||
int err = fat_opendir(&dir, path);
|
||||
printf("opening %s\n", path);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
printf("reading dir...\n");
|
||||
|
||||
err = fat_readdir(&dir, &info);
|
||||
if (err == FAT_ERR_EOF)
|
||||
return FAT_ERR_NONE;
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
printf("%X %s %d %d:%d %s%c\n",
|
||||
info.size, months[info.modified.month], info.modified.day,
|
||||
info.modified.hour, info.modified.min,
|
||||
info.namelen, info.name, info.attr & FAT_ATTR_DIR ? '/' : ' ');
|
||||
|
||||
err = fat_nextdir(&dir);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
void file_fuckery()
|
||||
{
|
||||
int err;
|
||||
err = fat_mount(&ops, 0, &g_fat, "/");
|
||||
|
||||
if(err)
|
||||
printf("KATYAKATYAKATYAKATYAKATYA: %X\n", err);
|
||||
|
||||
printf("%X\n", FAT_ERR_NOFAT);
|
||||
|
||||
err = ls(".");
|
||||
//err = fat_fclose(&file);
|
||||
if(err)
|
||||
printf("ERROR! %X\n", err);
|
||||
}
|
||||
|
||||
void apply_pic_masks()
|
||||
{
|
||||
//0x21 is master pic, 0xa1 is slave pic
|
||||
@@ -37,6 +118,7 @@ void kmain()
|
||||
disk_info info;
|
||||
get_disk_info(&info);
|
||||
printf("CYL HEAD SECT: %X %X %X\n", info.cylinders, info.heads, info.sectors);
|
||||
file_fuckery();
|
||||
while(1)
|
||||
{
|
||||
/* if(inportb(0x64) & 0x1)
|
||||
|
||||
Reference in New Issue
Block a user