GitOS
Operating system exercise
Loading...
Searching...
No Matches
fat16.h File Reference
#include <stdint.h>
#include "fs/file.h"
#include "drivers/disk/disk.h"
#include "drivers/disk/disk_streamer.h"

Go to the source code of this file.

Data Structures

struct  fat16_header_primary
 
struct  fat16_header_extended
 
struct  fat_header
 
union  fat_header::fat_header_extended
 
union  fat_header_extended
 
struct  fat_file
 
struct  fat_directory
 
struct  fat_item
 
struct  fat_file_descriptor
 
struct  fat_private
 

Macros

#define DEBUG_FAT16   0
 
#define FAT16_SIGNATURE   0x29
 
#define FAT16_FAT_ENTRY_SIZE   0x02
 
#define FAT16_BAD_SECTOR   0xFF7
 
#define FAT16_UNUSED   0x00
 
#define FAT_ITEM_TYPE_DIRECTORY   0
 
#define FAT_ITEM_TYPE_FILE   1
 
#define FAT_FILE_READONLY   0x01
 
#define FAT_FILE_HIDDEN   0x02
 
#define FAT_FILE_SYSTEM   0x04
 
#define FAT_FILE_VOLUME_LABEL   0x08
 
#define FAT_FILE_SUBDIRECTORY   0x10
 
#define FAT_FILE_ARCHVED   0x20
 
#define FAT_FILE_DEVICE   0x40
 
#define FAT_FILE_RESERVED   0x80
 
#define FAT_FILE_LONGNAME   (FAT_FILE_READONLY | FAT_FILE_HIDDEN | FAT_FILE_SYSTEM | FAT_FILE_VOLUME_LABEL)
 

Typedefs

typedef unsigned int FAT_ITEM_TYPE
 

Functions

struct fat16_header_primary __attribute__ ((packed))
 
struct filesystemfat16_init_filesystem ()
 Prepares filesystem struct for generic filesystem driver use.
 
int fat16_resolve (struct disk *disk)
 FAT16 filesystem resolver.
 
void * fat16_open (void *private_fs, struct path_part *path, FILE_MODE mode)
 FAT16 Implementation of fopen.
 
int fat16_read (void *private_fs, void *desc, uint32_t size, uint32_t nmemb, char *out)
 FAT16 Implementation of fread.
 
int fat16_write (void *private_fs, void *desc, uint32_t size, uint32_t nmemb, char *in)
 
int fat16_seek (void *desc, uint32_t offset, FILE_SEEK_MODE seek_mode)
 FAT16 Implementation of fseek.
 
int fat16_stat (void *desc, struct file_stat *stat)
 FAT16 Implementation of fstat.
 
int fat16_close (void *desc)
 FAT16 Implementation of fclose.
 

Variables

uint8_t jmp_short [3]
 
uint8_t oem_identifier [8]
 
uint16_t bytes_per_sector
 
uint8_t sectors_per_cluster
 
uint16_t reserved_sectors
 
uint8_t fat_copies
 
uint16_t root_dir_entries
 
uint16_t numeber_of_sectors
 
uint8_t media_type
 
uint16_t sectors_per_fat
 
uint16_t sectors_per_track
 
uint16_t number_of_heads
 
uint32_t hidden_sectors
 
uint32_t sectors_big
 
uint8_t drive_number
 
uint8_t win_nt_bit
 
uint8_t signature
 
uint32_t volume_id
 
uint8_t volume_id_string [11]
 
uint8_t system_id_string [8]
 
struct fat16_header_primary primary
 
union fat_header_extended shared
 
uint8_t filename [8]
 
uint8_t ext [3]
 
uint8_t attribute
 
uint8_t reserved
 
uint8_t creation_time_tenths_of_a_sec
 
uint16_t creation_time
 
uint16_t creation_date
 
uint16_t last_access
 
uint16_t high_16bits_first_cluster
 
uint16_t last_mod_time
 
uint16_t last_mod_date
 
uint16_t low_16bits_first_cluster
 
uint32_t filesize
 
struct fat_directory __attribute__
 

Macro Definition Documentation

◆ DEBUG_FAT16

#define DEBUG_FAT16   0

◆ FAT16_BAD_SECTOR

#define FAT16_BAD_SECTOR   0xFF7

◆ FAT16_FAT_ENTRY_SIZE

#define FAT16_FAT_ENTRY_SIZE   0x02

◆ FAT16_SIGNATURE

#define FAT16_SIGNATURE   0x29

◆ FAT16_UNUSED

#define FAT16_UNUSED   0x00

◆ FAT_FILE_ARCHVED

#define FAT_FILE_ARCHVED   0x20

◆ FAT_FILE_DEVICE

#define FAT_FILE_DEVICE   0x40

◆ FAT_FILE_HIDDEN

#define FAT_FILE_HIDDEN   0x02

◆ FAT_FILE_LONGNAME

◆ FAT_FILE_READONLY

#define FAT_FILE_READONLY   0x01

◆ FAT_FILE_RESERVED

#define FAT_FILE_RESERVED   0x80

◆ FAT_FILE_SUBDIRECTORY

#define FAT_FILE_SUBDIRECTORY   0x10

◆ FAT_FILE_SYSTEM

#define FAT_FILE_SYSTEM   0x04

◆ FAT_FILE_VOLUME_LABEL

#define FAT_FILE_VOLUME_LABEL   0x08

◆ FAT_ITEM_TYPE_DIRECTORY

#define FAT_ITEM_TYPE_DIRECTORY   0

◆ FAT_ITEM_TYPE_FILE

#define FAT_ITEM_TYPE_FILE   1

Typedef Documentation

◆ FAT_ITEM_TYPE

typedef unsigned int FAT_ITEM_TYPE

Function Documentation

◆ __attribute__()

struct fat16_header_primary __attribute__ ( (packed)  )

◆ fat16_close()

int fat16_close ( void *  desc)

FAT16 Implementation of fclose.

Parameters
descInternal file descriptor
Returns
int Status

References ALL_OK, and kdebug.

◆ fat16_init_filesystem()

struct filesystem * fat16_init_filesystem ( )

Prepares filesystem struct for generic filesystem driver use.

Returns
struct filesystem*

References fat16_fs, filesystem::name, and strcpy().

◆ fat16_open()

void * fat16_open ( void *  private_fs,
struct path_part path,
FILE_MODE  mode 
)

FAT16 Implementation of fopen.

Parameters
private_fsPrivate filesystem data
pathPath to file
modeOpen mode (FILE_MODE_READ for readonly)
Returns
void* Pointer to private file descriptor

References fat_file_descriptor::cached_cluster, fat_file_descriptor::cached_offset_bytes, fat_file_descriptor::file, FILE_MODE_READ, kdebug, kzalloc(), path_part::part, and fat_file_descriptor::pos.

◆ fat16_read()

int fat16_read ( void *  private_fs,
void *  desc,
uint32_t  size,
uint32_t  nmemb,
char *  out 
)

FAT16 Implementation of fread.

Parameters
private_fsPrivate filesystem data
descInternal file descriptor
sizeSize of block
nmembNumber of blocks to read
outOutput buffer
Returns
int Status

References ALL_OK, fat_private::cluster_read_stream, fat_item::file, fat_file_descriptor::file, kdebug, offset, fat_file_descriptor::pos, and size.

◆ fat16_resolve()

◆ fat16_seek()

int fat16_seek ( void *  desc,
uint32_t  offset,
FILE_SEEK_MODE  seek_mode 
)

FAT16 Implementation of fseek.

Parameters
descInternal file descriptor
offsetOffset
seek_modeSeek mode (SEEK_SET for absolute, SEEK_CUR for relative)
Returns
int Status

References ALL_OK, EINVARG, FAT_ITEM_TYPE_FILE, fat_item::file, fat_file_descriptor::file, fat_file::filesize, kdebug, offset, fat_file_descriptor::pos, SEEK_CUR, SEEK_END, SEEK_SET, and fat_item::type.

◆ fat16_stat()

int fat16_stat ( void *  desc,
struct file_stat stat 
)

◆ fat16_write()

int fat16_write ( void *  private_fs,
void *  desc,
uint32_t  size,
uint32_t  nmemb,
char *  in 
)

References ENOTIMPL, kdebug, and size.

Variable Documentation

◆ __attribute__

struct window_message_framebuffer_data __attribute__

◆ attribute

uint8_t attribute

◆ bytes_per_sector

uint16_t bytes_per_sector

◆ creation_date

uint16_t creation_date

◆ creation_time

uint16_t creation_time

◆ creation_time_tenths_of_a_sec

uint8_t creation_time_tenths_of_a_sec

◆ drive_number

uint8_t drive_number

◆ ext

uint8_t ext[3]

◆ fat_copies

uint8_t fat_copies

◆ filename

uint8_t filename[8]

◆ filesize

uint32_t filesize

◆ hidden_sectors

uint32_t hidden_sectors

◆ high_16bits_first_cluster

uint16_t high_16bits_first_cluster

◆ jmp_short

uint8_t jmp_short[3]

◆ last_access

uint16_t last_access

◆ last_mod_date

uint16_t last_mod_date

◆ last_mod_time

uint16_t last_mod_time

◆ low_16bits_first_cluster

uint16_t low_16bits_first_cluster

◆ media_type

uint8_t media_type

◆ number_of_heads

uint16_t number_of_heads

◆ numeber_of_sectors

uint16_t numeber_of_sectors

◆ oem_identifier

uint8_t oem_identifier[8]

◆ primary

struct fat16_header_primary primary

◆ reserved

uint8_t reserved

◆ reserved_sectors

uint16_t reserved_sectors

◆ root_dir_entries

uint16_t root_dir_entries

◆ sectors_big

uint32_t sectors_big

◆ sectors_per_cluster

uint8_t sectors_per_cluster

◆ sectors_per_fat

uint16_t sectors_per_fat

◆ sectors_per_track

uint16_t sectors_per_track

◆ shared

union fat_header_extended shared

◆ signature

uint8_t signature

◆ system_id_string

uint8_t system_id_string[8]

◆ volume_id

uint32_t volume_id

◆ volume_id_string

uint8_t volume_id_string[11]

◆ win_nt_bit

uint8_t win_nt_bit