7#ifndef X86_KERNEL_FILESYSTEM_FAT32_HEADER
8#define X86_KERNEL_FILESYSTEM_FAT32_HEADER
17#define END_OF_DIRECTORY 0x00
18#define DELETED_DIR_ENTRY 0xE5
21#define FAT32_FAT_MASK 0x0FFFFFFFU
22#define FAT32_FREE_CLUSTER 0x00000000U
23#define FAT32_BAD_CLUSTER 0x0FFFFFF7U
24#define FAT32_EOC_MIN 0x0FFFFFF8U
25#define FAT32_EOC_MAX 0x0FFFFFFFU
31typedef struct _FAT32_BPB {
37 uint16_t bytes_per_sector;
38 uint8_t sectors_per_cluster;
39 uint16_t reserved_sector_count;
41 uint16_t root_entry_count;
42 uint16_t total_sectors_16;
45 uint16_t sectors_per_track;
47 uint32_t hidden_sectors;
48 uint32_t total_sectors_32;
52 uint32_t root_cluster;
53 uint16_t fs_info_sector;
54 uint16_t backup_root_sector;
62typedef struct _FAT32_DIR_ENTRY {
69 uint8_t crt_time_tenth;
72 uint16_t lst_acc_date;
125static inline uint16_t fat32_encode_date(uint16_t year, uint8_t month, uint8_t day) {
127 return ((year - 1980) << 9) | (month << 5) | (day);
130static inline uint16_t fat32_encode_time(uint8_t hour, uint8_t min, uint8_t sec) {
132 return (hour << 11) | (min << 5) | (sec / 2);
135static inline void fat32_decode_date(uint16_t date, uint16_t* year, uint8_t* month, uint8_t* day) {
136 *year = 1980 + ((date >> 9) & 0x7F);
137 *month = (date >> 5) & 0x0F;
141static inline void fat32_decode_time(uint16_t time, uint8_t* hour, uint8_t* min, uint8_t* sec) {
142 *hour = (time >> 11) & 0x1F;
143 *min = (time >> 5) & 0x3F;
144 *sec = (time & 0x1F) * 2;
149 IN uint64_t FileOffset,
151 IN size_t BufferSize,
169 IN uint64_t FileOffset,
171 IN size_t BufferSize,
MTSTATUS fat32_create_file(IN const char *path, OUT PFILE_OBJECT *FileObjectOut)
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(IN PFILE_OBJECT FileObject, IN uint64_t FileOffset, OUT void *Buffer, IN size_t BufferSize, _Out_Opt size_t *BytesRead)
MTSTATUS fat32_write_file(IN PFILE_OBJECT FileObject, IN uint64_t FileOffset, IN void *Buffer, IN size_t BufferSize, _Out_Opt size_t *BytesWritten)
MTSTATUS fat32_delete_file(const char *path)
This function deletes the file given to the function from the system.
void fat32_deletion_routine(void *Object)
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
struct _FILE_OBJECT * PFILE_OBJECT
uint32_t sectors_per_cluster
uint32_t first_data_sector
uint16_t reserved_sector_count
uint32_t bytes_per_sector