7#ifndef X86_KERNEL_FILESYSTEM_FAT32_HEADER
8#define X86_KERNEL_FILESYSTEM_FAT32_HEADER
16#define END_OF_DIRECTORY 0x00
17#define DELETED_DIR_ENTRY 0xE5
20#define FAT32_FAT_MASK 0x0FFFFFFFU
21#define FAT32_FREE_CLUSTER 0x00000000U
22#define FAT32_BAD_CLUSTER 0x0FFFFFF7U
23#define FAT32_EOC_MIN 0x0FFFFFF8U
24#define FAT32_EOC_MAX 0x0FFFFFFFU
30typedef struct _FAT32_BPB {
36 uint16_t bytes_per_sector;
37 uint8_t sectors_per_cluster;
38 uint16_t reserved_sector_count;
40 uint16_t root_entry_count;
41 uint16_t total_sectors_16;
44 uint16_t sectors_per_track;
46 uint32_t hidden_sectors;
47 uint32_t total_sectors_32;
51 uint32_t root_cluster;
52 uint16_t fs_info_sector;
53 uint16_t backup_root_sector;
61typedef struct _FAT32_DIR_ENTRY {
68 uint8_t crt_time_tenth;
71 uint16_t lst_acc_date;
124static inline uint16_t fat32_encode_date(uint16_t year, uint8_t month, uint8_t day) {
126 return ((year - 1980) << 9) | (month << 5) | (day);
129static inline uint16_t fat32_encode_time(uint8_t hour, uint8_t min, uint8_t sec) {
131 return (hour << 11) | (min << 5) | (sec / 2);
134static inline void fat32_decode_date(uint16_t date, uint16_t* year, uint8_t* month, uint8_t* day) {
135 *year = 1980 + ((date >> 9) & 0x7F);
136 *month = (date >> 5) & 0x0F;
140static inline void fat32_decode_time(uint16_t time, uint8_t* hour, uint8_t* min, uint8_t* sec) {
141 *hour = (time >> 11) & 0x1F;
142 *min = (time >> 5) & 0x3F;
143 *sec = (time & 0x1F) * 2;
MTSTATUS fat32_init(int disk_index)
MTSTATUS fat32_create_directory(const char *path)
Creates a new directory (/testdir/ or /testdir are both allowed to create 'testdir' inside of 'root')
MTSTATUS fat32_list_directory(const char *path, char *listings, size_t max_len)
Lists the directory given.
MTSTATUS fat32_delete_directory(const char *path)
This function deletes the directory given to the function from the system.
MTSTATUS fat32_read_file(const char *filename, uint32_t *file_size_out, void **buffer_out)
A FAT32 Function that reads the file requested into a dynamically allocated buffer.
MTSTATUS fat32_write_file(const char *path, const void *data, uint32_t size, uint32_t mode)
Creates a new file and writes data to it.
MTSTATUS fat32_delete_file(const char *path)
This function deletes the file given to the function from the system.
void fat32_list_root(void)
bool fat32_directory_is_empty(const char *path)
This function returns if the directory given to the function is empty (e.g, has only '....
enum _FAT32_ATTRIBUTES FAT32_ATTRIBUTES
struct _FAT32_FSINFO FAT32_FSINFO
uint32_t sectors_per_cluster
uint32_t first_data_sector
uint16_t reserved_sector_count
uint32_t bytes_per_sector