kernel
Loading...
Searching...
No Matches
fat32.h File Reference
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include "../../drivers/gop/gop.h"
#include "../../mtstatus.h"
#include "../../includes/fs.h"

Go to the source code of this file.

Data Structures

struct  FAT32_LFN_ENTRY
struct  _FAT32_FSINFO

Macros

#define END_OF_DIRECTORY   0x00
#define DELETED_DIR_ENTRY   0xE5
#define FAT32_FAT_MASK   0x0FFFFFFFU
#define FAT32_FREE_CLUSTER   0x00000000U
#define FAT32_BAD_CLUSTER   0x0FFFFFF7U
#define FAT32_EOC_MIN   0x0FFFFFF8U /* inclusive */
#define FAT32_EOC_MAX   0x0FFFFFFFU /* inclusive */

Typedefs

typedef struct _FAT32_FSINFO FAT32_FSINFO
typedef enum _FAT32_ATTRIBUTES FAT32_ATTRIBUTES

Enumerations

enum  _FAT32_ATTRIBUTES {
  ATTR_READ_ONLY = 0x01 , ATTR_HIDDEN = 0x02 , ATTR_SYSTEM = 0x04 , ATTR_VOLUME_ID = 0x08 ,
  ATTR_DIRECTORY = 0x10 , ATTR_ARCHIVE = 0x20 , ATTR_LONG_NAME = 0x0F
}

Functions

struct __attribute__ ((packed)) _FAT32_BPB
MTSTATUS fat32_init (int disk_index)
void fat32_list_root (void)
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_create_directory (const char *path)
 Creates a new directory (/testdir/ or /testdir are both allowed to create 'testdir' inside of 'root')
MTSTATUS fat32_create_file (IN const char *path, OUT PFILE_OBJECT *FileObjectOut)
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_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_delete_file (const char *path)
 This function deletes the file given to the function from the system.
bool fat32_directory_is_empty (const char *path)
 This function returns if the directory given to the function is empty (e.g, has only '.' and '..' entries / deleted / nonexistent)
void fat32_deletion_routine (void *Object)

Variables

 FAT32_BPB
 FAT32_DIR_ENTRY

Macro Definition Documentation

◆ DELETED_DIR_ENTRY

#define DELETED_DIR_ENTRY   0xE5

Definition at line 18 of file fat32.h.

◆ END_OF_DIRECTORY

#define END_OF_DIRECTORY   0x00

Definition at line 17 of file fat32.h.

◆ FAT32_BAD_CLUSTER

#define FAT32_BAD_CLUSTER   0x0FFFFFF7U

Definition at line 23 of file fat32.h.

◆ FAT32_EOC_MAX

#define FAT32_EOC_MAX   0x0FFFFFFFU /* inclusive */

Definition at line 25 of file fat32.h.

◆ FAT32_EOC_MIN

#define FAT32_EOC_MIN   0x0FFFFFF8U /* inclusive */

Definition at line 24 of file fat32.h.

◆ FAT32_FAT_MASK

#define FAT32_FAT_MASK   0x0FFFFFFFU

Definition at line 21 of file fat32.h.

◆ FAT32_FREE_CLUSTER

#define FAT32_FREE_CLUSTER   0x00000000U

Definition at line 22 of file fat32.h.

Typedef Documentation

◆ FAT32_ATTRIBUTES

◆ FAT32_FSINFO

typedef struct _FAT32_FSINFO FAT32_FSINFO

Enumeration Type Documentation

◆ _FAT32_ATTRIBUTES

Enumerator
ATTR_READ_ONLY 
ATTR_HIDDEN 
ATTR_SYSTEM 
ATTR_VOLUME_ID 
ATTR_DIRECTORY 
ATTR_ARCHIVE 
ATTR_LONG_NAME 

Definition at line 114 of file fat32.h.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed) )

Definition at line 1 of file fat32.h.

◆ fat32_create_directory()

MTSTATUS fat32_create_directory ( const char * path)

Creates a new directory (/testdir/ or /testdir are both allowed to create 'testdir' inside of 'root')

Parameters
pathThe full path to the new directory
Returns
MTSTATUS Status code.

Definition at line 1136 of file fat32.c.

◆ fat32_create_file()

MTSTATUS fat32_create_file ( IN const char * path,
OUT PFILE_OBJECT * FileObjectOut )

Definition at line 1525 of file fat32.c.

◆ fat32_delete_directory()

MTSTATUS fat32_delete_directory ( const char * path)

This function deletes the directory given to the function from the system.

Parameters
pathFull path to delete directory.
Returns
MTSTATUS Status code.

Definition at line 2037 of file fat32.c.

◆ fat32_delete_file()

MTSTATUS fat32_delete_file ( const char * path)

This function deletes the file given to the function from the system.

Parameters
pathFull path to delete file.
Returns
MTSTATUS Status code.

Definition at line 2069 of file fat32.c.

◆ fat32_deletion_routine()

void fat32_deletion_routine ( void * Object)

Definition at line 2146 of file fat32.c.

◆ fat32_directory_is_empty()

bool fat32_directory_is_empty ( const char * path)

This function returns if the directory given to the function is empty (e.g, has only '.' and '..' entries / deleted / nonexistent)

Parameters
pathFull path to dir
Returns
True or false based if empty or not.

Definition at line 1778 of file fat32.c.

◆ fat32_init()

MTSTATUS fat32_init ( int disk_index)

Definition at line 853 of file fat32.c.

◆ fat32_list_directory()

MTSTATUS fat32_list_directory ( const char * path,
char * listings,
size_t max_len )

Lists the directory given.

Parameters
pathPath to directory, e.g "mydir/"
listings[OUT] Pointer to directory listing. (each seperated with a newline character)
max_len[IN] Max size of listings buffer.
Returns
MTSTATUS Status code.

Definition at line 1694 of file fat32.c.

◆ fat32_list_root()

void fat32_list_root ( void )

Definition at line 877 of file fat32.c.

◆ fat32_read_file()

MTSTATUS fat32_read_file ( IN PFILE_OBJECT FileObject,
IN uint64_t FileOffset,
OUT void * Buffer,
IN size_t BufferSize,
_Out_Opt size_t * BytesRead )

Definition at line 1029 of file fat32.c.

◆ fat32_write_file()

MTSTATUS fat32_write_file ( IN PFILE_OBJECT FileObject,
IN uint64_t FileOffset,
IN void * Buffer,
IN size_t BufferSize,
_Out_Opt size_t * BytesWritten )

Definition at line 1364 of file fat32.c.

Variable Documentation

◆ FAT32_BPB

FAT32_BPB

Definition at line 55 of file fat32.h.

◆ FAT32_DIR_ENTRY

FAT32_DIR_ENTRY

Definition at line 78 of file fat32.h.