miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
fat32.c File Reference
#include <miniOS/io.h>
#include <miniOS/fs/fat32.h>
#include <miniOS/fs/vfs.h>
#include <miniOS/drivers/block_layer.h>
#include <miniOS/drivers/block_device.h>
#include <string.h>
Include dependency graph for fat32.c:

Classes

struct  find_ctx
struct  readdir_ctx

Typedefs

typedef int(* fat32_scan_cb_t) (const char *name, uint8_t name_len, uint32_t cluster, uint8_t is_dir, uint32_t filesize, void *ud)

Functions

static int read_part_sector (uint32_t part_sector, void *buf)
static uint32_t fat_entry (uint32_t cluster)
static uint32_t cluster_to_part_sector (uint32_t cluster)
static uint32_t entry_cluster (const fat32_dir_entry_t *e)
static uint8_t lfn_checksum (const char *name11)
static uint32_t lfn_decode (const uint16_t *lfn, int slot_count, char *out, uint32_t out_size)
static uint32_t short_name (const fat32_dir_entry_t *e, char *out, uint32_t out_size)
static int fat32_scan_dir (uint32_t dir_cluster, uint64_t *offset_p, fat32_scan_cb_t cb, void *ud)
static int find_entry_cb (const char *name, uint8_t name_len, uint32_t cluster, uint8_t is_dir, uint32_t filesize, void *ud)
static int fat32_lookup (const char *path, vfs_inode_info_t *out)
static int readdir_adapter (const char *name, uint8_t name_len, uint32_t cluster, uint8_t is_dir, uint32_t filesize, void *ud)
static int fat32_readdir (uint32_t ino, uint64_t *offset, vfs_dirent_cb_t cb, void *ud)
static int fat32_read (uint32_t ino, uint64_t off, void *buf, uint32_t len)
static int fat32_statfs (vfs_statfs_t *out)
int fat32_mount (uint64_t part_lba_start, uint64_t part_lba_end)
static int fat32_fs_mount (const char *source, const char *target, const void *data)
void fat32_init (void)

Variables

static uint64_t g_part_start
static uint64_t g_part_end
static uint32_t g_bytes_per_sector
static uint32_t g_sectors_per_cluster
static uint32_t g_first_data_sector
static uint32_t g_fat_start_sector
static uint32_t g_root_cluster
static uint8_t g_fat_buf [512]
static uint8_t g_dir_buf [512]
static vfs_ops_t g_fat32_ops

Typedef Documentation

◆ fat32_scan_cb_t

typedef int(* fat32_scan_cb_t) (const char *name, uint8_t name_len, uint32_t cluster, uint8_t is_dir, uint32_t filesize, void *ud)

Function Documentation

◆ cluster_to_part_sector()

uint32_t cluster_to_part_sector ( uint32_t cluster)
static
Here is the caller graph for this function:

◆ entry_cluster()

uint32_t entry_cluster ( const fat32_dir_entry_t * e)
static
Here is the caller graph for this function:

◆ fat32_fs_mount()

int fat32_fs_mount ( const char * source,
const char * target,
const void * data )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fat32_init()

void fat32_init ( void )

fat32_init() - Register the FAT32 filesystem type with the VFS registry.

After this call, vfs_mount_fstype("fat32", source, target, data) can be used to mount any FAT32 partition by passing a vfs_mount_data_t as @data. fat32_init() does NOT mount anything itself; it only registers the type. Call once during kernel startup, before the first FAT32 mount.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fat32_lookup()

int fat32_lookup ( const char * path,
vfs_inode_info_t * out )
static
Here is the call graph for this function:

◆ fat32_mount()

int fat32_mount ( uint64_t part_lba_start,
uint64_t part_lba_end )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fat32_read()

int fat32_read ( uint32_t ino,
uint64_t off,
void * buf,
uint32_t len )
static
Here is the call graph for this function:

◆ fat32_readdir()

int fat32_readdir ( uint32_t ino,
uint64_t * offset,
vfs_dirent_cb_t cb,
void * ud )
static
Here is the call graph for this function:

◆ fat32_scan_dir()

int fat32_scan_dir ( uint32_t dir_cluster,
uint64_t * offset_p,
fat32_scan_cb_t cb,
void * ud )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fat32_statfs()

int fat32_statfs ( vfs_statfs_t * out)
static
Here is the call graph for this function:

◆ fat_entry()

uint32_t fat_entry ( uint32_t cluster)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_entry_cb()

int find_entry_cb ( const char * name,
uint8_t name_len,
uint32_t cluster,
uint8_t is_dir,
uint32_t filesize,
void * ud )
static
Here is the call graph for this function:

◆ lfn_checksum()

uint8_t lfn_checksum ( const char * name11)
static
Here is the caller graph for this function:

◆ lfn_decode()

uint32_t lfn_decode ( const uint16_t * lfn,
int slot_count,
char * out,
uint32_t out_size )
static
Here is the caller graph for this function:

◆ read_part_sector()

int read_part_sector ( uint32_t part_sector,
void * buf )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdir_adapter()

int readdir_adapter ( const char * name,
uint8_t name_len,
uint32_t cluster,
uint8_t is_dir,
uint32_t filesize,
void * ud )
static
Here is the caller graph for this function:

◆ short_name()

uint32_t short_name ( const fat32_dir_entry_t * e,
char * out,
uint32_t out_size )
static
Here is the caller graph for this function:

Variable Documentation

◆ g_bytes_per_sector

uint32_t g_bytes_per_sector
static

◆ g_dir_buf

uint8_t g_dir_buf[512]
static

◆ g_fat32_ops

vfs_ops_t g_fat32_ops
static
Initial value:
= {
.lookup = fat32_lookup,
.read = fat32_read,
.readdir = fat32_readdir,
.statfs = fat32_statfs,
}
static int fat32_readdir(uint32_t ino, uint64_t *offset, vfs_dirent_cb_t cb, void *ud)
Definition fat32.c:352
static int fat32_lookup(const char *path, vfs_inode_info_t *out)
Definition fat32.c:283
static int fat32_statfs(vfs_statfs_t *out)
Definition fat32.c:406
static int fat32_read(uint32_t ino, uint64_t off, void *buf, uint32_t len)
Definition fat32.c:359

◆ g_fat_buf

uint8_t g_fat_buf[512]
static

◆ g_fat_start_sector

uint32_t g_fat_start_sector
static

◆ g_first_data_sector

uint32_t g_first_data_sector
static

◆ g_part_end

uint64_t g_part_end
static

◆ g_part_start

uint64_t g_part_start
static

◆ g_root_cluster

uint32_t g_root_cluster
static

◆ g_sectors_per_cluster

uint32_t g_sectors_per_cluster
static