XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
Fat.h File Reference
#include <stdint.h>
#include <Fs/vdisk.h>
#include <Fs/vfs.h>
Include dependency graph for Fat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _FAT_BPB_
 
struct  _fat_dir_
 
struct  _fat_lfn_
 
struct  _FatFS_
 

Macros

#define FAT_ATTRIBUTE_MASK   0x3F
 
#define FAT_ATTRIBUTE_READ_ONLY   0x01
 
#define FAT_ATTRIBUTE_HIDDEN   0x02
 
#define FAT_ATTRIBUTE_SYSTEM   0x04
 
#define FAT_ATTRIBUTE_VOLUME   0x08
 
#define FAT_ATTRIBUTE_DIRECTORY   0x10
 
#define FAT_ATTRIBUTE_ARCHIVE   0x20
 
#define FAT_ATTRIBUTE_LONG_NAME   0x0F
 
#define FAT_EOC_MARK   0xFFFFFFF8
 
#define FAT_BAD_CLUSTER   0xFFFFFFF7
 
#define FSTYPE_FAT12   1
 
#define FSTYPE_FAT16   2
 
#define FSTYPE_FAT32   3
 

Typedefs

typedef struct _FAT_BPB_ FatBPB
 
typedef struct _fat_dir_ FatDir
 
typedef struct _fat_lfn_ FatLFN
 
typedef struct _FatFS_ FatFS
 

Functions

AuVFSNodeFatInitialise (AuVDisk *vdisk, char *mountpoint)
 
uint64_t FatClusterToSector32 (FatFS *fs, uint64_t cluster)
 
void FatToDOSFilename (const char *filename, char *fname, unsigned int fname_length)
 
uint8_t FatCalculateCheckSum (uint8_t *filename)
 
uint8_t FatCheckDotCount (char *filename)
 
uint32_t FatFindFreeCluster (AuVFSNode *node)
 
void FatAllocCluster (AuVFSNode *fsys, int position, uint32_t n_value)
 
void FatClearCluster (AuVFSNode *node, uint32_t cluster)
 
uint32_t FatReadFAT (AuVFSNode *node, uint64_t cluster_index)
 
AuVFSNodeFatOpen (AuVFSNode *fsys, char *filename)
 
uint16_t FatFormatDate ()
 
uint16_t FatFormatTime ()
 
AuVFSNodeFatLocateDir (AuVFSNode *fsys, const char *dir)
 
AuVFSNodeFatLocateSubDir (AuVFSNode *fsys, AuVFSNode *kfile, const char *filename)
 
void FatFromDosToFilename (char *filename, char *dirfname)
 

Macro Definition Documentation

◆ FAT_ATTRIBUTE_ARCHIVE

#define FAT_ATTRIBUTE_ARCHIVE   0x20

◆ FAT_ATTRIBUTE_DIRECTORY

#define FAT_ATTRIBUTE_DIRECTORY   0x10

◆ FAT_ATTRIBUTE_HIDDEN

#define FAT_ATTRIBUTE_HIDDEN   0x02

◆ FAT_ATTRIBUTE_LONG_NAME

#define FAT_ATTRIBUTE_LONG_NAME   0x0F

◆ FAT_ATTRIBUTE_MASK

#define FAT_ATTRIBUTE_MASK   0x3F

BSD 2-Clause License

Copyright (c) 2022-2023, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

◆ FAT_ATTRIBUTE_READ_ONLY

#define FAT_ATTRIBUTE_READ_ONLY   0x01

◆ FAT_ATTRIBUTE_SYSTEM

#define FAT_ATTRIBUTE_SYSTEM   0x04

◆ FAT_ATTRIBUTE_VOLUME

#define FAT_ATTRIBUTE_VOLUME   0x08

◆ FAT_BAD_CLUSTER

#define FAT_BAD_CLUSTER   0xFFFFFFF7

◆ FAT_EOC_MARK

#define FAT_EOC_MARK   0xFFFFFFF8

◆ FSTYPE_FAT12

#define FSTYPE_FAT12   1

◆ FSTYPE_FAT16

#define FSTYPE_FAT16   2

◆ FSTYPE_FAT32

#define FSTYPE_FAT32   3

Typedef Documentation

◆ FatBPB

typedef struct _FAT_BPB_ FatBPB

◆ FatDir

typedef struct _fat_dir_ FatDir

fat32_dir – 32 byte fat directory structure

◆ FatFS

typedef struct _FatFS_ FatFS

◆ FatLFN

typedef struct _fat_lfn_ FatLFN

Function Documentation

◆ FatAllocCluster()

void FatAllocCluster ( AuVFSNode fsys,
int  position,
uint32_t  n_value 
)
extern

◆ FatCalculateCheckSum()

uint8_t FatCalculateCheckSum ( uint8_t filename)
extern

◆ FatCheckDotCount()

uint8_t FatCheckDotCount ( char *  filename)
extern

◆ FatClearCluster()

void FatClearCluster ( AuVFSNode node,
uint32_t  cluster 
)
extern

FatClearCluster – clears a cluster to 0

Parameters
cluster– cluster to clear

◆ FatClusterToSector32()

uint64_t FatClusterToSector32 ( FatFS fs,
uint64_t  cluster 
)
extern

◆ FatFindFreeCluster()

uint32_t FatFindFreeCluster ( AuVFSNode node)
extern

◆ FatFormatDate()

uint16_t FatFormatDate ( )
extern

◆ FatFormatTime()

uint16_t FatFormatTime ( )
extern

◆ FatFromDosToFilename()

void FatFromDosToFilename ( char *  filename,
char *  dirfname 
)
extern

◆ FatInitialise()

AuVFSNode * FatInitialise ( AuVDisk vdisk,
char *  mountpoint 
)
extern

◆ FatLocateDir()

AuVFSNode * FatLocateDir ( AuVFSNode fsys,
const char *  dir 
)

◆ FatLocateSubDir()

AuVFSNode * FatLocateSubDir ( AuVFSNode fsys,
AuVFSNode kfile,
const char *  filename 
)

◆ FatOpen()

AuVFSNode * FatOpen ( AuVFSNode fsys,
char *  filename 
)
extern

any '\'s in path ?

nope, must be in root directory, search it

found file ?

unable to find

go to next character after first '\'

get pathname

if another '\' or end of line is reached, we are done

copy character

open subdirectory or file

search root dir – open pathname

search a sub directory instead for pathname

found directory or file?

find next '\'

found file?

unable to find

any '\'s in path ?

nope, must be in root directory, search it

found file ?

unable to find

go to next character after first '\'

get pathname

if another '\' or end of line is reached, we are done

copy character

open subdirectory or file

search root dir – open pathname

search a sub directory instead for pathname

found directory or file?

find next '\'

found file?

unable to find

◆ FatReadFAT()

uint32_t FatReadFAT ( AuVFSNode node,
uint64_t  cluster_index 
)
extern

◆ FatToDOSFilename()

void FatToDOSFilename ( const char *  filename,
char *  fname,
unsigned int  fname_length 
)
extern

FatToDOSFilename – converts a given filename to MSDOS file name format

Parameters
filename– filename for conversion
fname– pointer to the buffer to store the conversion
fname_length– manly 11 buffer[0-8] – filename, buffer[9-11] – file extension