SdFat
Classes | Typedefs | Functions | Variables
FatStructs.h File Reference

FAT file structures. More...

This graph shows which files directly or indirectly include this file:

Classes

struct  biosParmBlock
 BIOS parameter block. More...
 
struct  directoryEntry
 FAT short directory entry. More...
 
struct  fat32_boot
 Boot sector for a FAT32 volume. More...
 
struct  fat32_fsinfo
 FSINFO sector for a FAT32 volume. More...
 
struct  fat_boot
 Boot sector for a FAT12/FAT16 volume. More...
 
struct  longDirectoryEntry
 FAT long directory entry. More...
 
struct  masterBootRecord
 Master Boot Record. More...
 
struct  partitionTable
 MBR partition table entry. More...
 

Typedefs

typedef struct biosParmBlock bpb_t
 
typedef struct directoryEntry dir_t
 
typedef struct fat32_boot fat32_boot_t
 
typedef struct fat32_fsinfo fat32_fsinfo_t
 
typedef struct fat_boot fat_boot_t
 
typedef struct longDirectoryEntry ldir_t
 
typedef struct masterBootRecord mbr_t
 
typedef struct partitionTable part_t
 

Functions

static uint8_t DIR_IS_FILE (const dir_t *dir)
 
static uint8_t DIR_IS_FILE_OR_SUBDIR (const dir_t *dir)
 
static uint8_t DIR_IS_HIDDEN (const dir_t *dir)
 
static uint8_t DIR_IS_LONG_NAME (const dir_t *dir)
 
static uint8_t DIR_IS_SUBDIR (const dir_t *dir)
 
static uint8_t DIR_IS_SYSTEM (const dir_t *dir)
 
static uint16_t FAT_DATE (uint16_t year, uint8_t month, uint8_t day)
 
static uint8_t FAT_DAY (uint16_t fatDate)
 
static uint8_t FAT_HOUR (uint16_t fatTime)
 
static uint8_t FAT_MINUTE (uint16_t fatTime)
 
static uint8_t FAT_MONTH (uint16_t fatDate)
 
static uint8_t FAT_SECOND (uint16_t fatTime)
 
static uint16_t FAT_TIME (uint8_t hour, uint8_t minute, uint8_t second)
 
static uint16_t FAT_YEAR (uint16_t fatDate)
 

Variables

uint8_t const BOOTSIG0 = 0X55
 
uint8_t const BOOTSIG1 = 0XAA
 
uint8_t const DIR_ATT_ARCHIVE = 0X20
 
uint8_t const DIR_ATT_DEFINED_BITS = 0X3F
 
uint8_t const DIR_ATT_DIRECTORY = 0X10
 
uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)
 
uint8_t const DIR_ATT_HIDDEN = 0X02
 
uint8_t const DIR_ATT_LONG_NAME = 0X0F
 
uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F
 
uint8_t const DIR_ATT_READ_ONLY = 0X01
 
uint8_t const DIR_ATT_SYSTEM = 0X04
 
uint8_t const DIR_ATT_VOLUME_ID = 0X08
 
uint8_t const DIR_NAME_0XE5 = 0X05
 
uint8_t const DIR_NAME_DELETED = 0XE5
 
uint8_t const DIR_NAME_FREE = 0X00
 
const uint8_t DIR_NT_LC_BASE = 0X08
 
const uint8_t DIR_NT_LC_EXT = 0X10
 
uint8_t const EXTENDED_BOOT_SIG = 0X29
 
uint16_t const FAT12EOC = 0XFFF
 
uint16_t const FAT12EOC_MIN = 0XFF8
 
uint16_t const FAT16EOC = 0XFFFF
 
uint16_t const FAT16EOC_MIN = 0XFFF8
 
uint32_t const FAT32EOC = 0X0FFFFFFF
 
uint32_t const FAT32EOC_MIN = 0X0FFFFFF8
 
uint32_t const FAT32MASK = 0X0FFFFFFF
 
uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1
 
uint16_t const FAT_DEFAULT_TIME = (1 << 11)
 
uint32_t const FSINFO_LEAD_SIG = 0x41615252
 
uint32_t const FSINFO_STRUCT_SIG = 0x61417272
 
const uint8_t LDIR_NAME1_DIM = 5
 
const uint8_t LDIR_NAME2_DIM = 6
 
const uint8_t LDIR_NAME3_DIM = 2
 
const uint8_t LDIR_ORD_LAST_LONG_ENTRY = 0X40
 

Detailed Description

FAT file structures.

Typedef Documentation

typedef struct biosParmBlock bpb_t

Type name for biosParmBlock

typedef struct directoryEntry dir_t

Type name for directoryEntry

typedef struct fat32_boot fat32_boot_t

Type name for FAT32 Boot Sector

typedef struct fat32_fsinfo fat32_fsinfo_t

Type name for FAT32 FSINFO Sector

typedef struct fat_boot fat_boot_t

Type name for FAT Boot Sector

typedef struct longDirectoryEntry ldir_t

Type name for longDirectoryEntry

typedef struct masterBootRecord mbr_t

Type name for masterBootRecord

typedef struct partitionTable part_t

Type name for partitionTable

Function Documentation

static uint8_t DIR_IS_FILE ( const dir_t dir)
inlinestatic

Directory entry is for a file

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is for a normal file else false.
static uint8_t DIR_IS_FILE_OR_SUBDIR ( const dir_t dir)
inlinestatic

Directory entry is for a file or subdirectory

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is for a normal file or subdirectory else false.
static uint8_t DIR_IS_HIDDEN ( const dir_t dir)
inlinestatic

Directory entry is hidden

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is hidden else false.
static uint8_t DIR_IS_LONG_NAME ( const dir_t dir)
inlinestatic

Directory entry is part of a long name

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is for part of a long name else false.
static uint8_t DIR_IS_SUBDIR ( const dir_t dir)
inlinestatic

Directory entry is for a subdirectory

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is for a subdirectory else false.
static uint8_t DIR_IS_SYSTEM ( const dir_t dir)
inlinestatic

Directory entry is system type

Parameters
[in]dirPointer to a directory entry.
Returns
true if the entry is system else false.
static uint16_t FAT_DATE ( uint16_t  year,
uint8_t  month,
uint8_t  day 
)
inlinestatic

date field for FAT directory entry

Parameters
[in]year[1980,2107]
[in]month[1,12]
[in]day[1,31]
Returns
Packed date for dir_t entry.
static uint8_t FAT_DAY ( uint16_t  fatDate)
inlinestatic

day part of FAT directory date field

Parameters
[in]fatDateDate in packed dir format.
Returns
Extracted day [1,31]
static uint8_t FAT_HOUR ( uint16_t  fatTime)
inlinestatic

hour part of FAT directory time field

Parameters
[in]fatTimeTime in packed dir format.
Returns
Extracted hour [0,23]
static uint8_t FAT_MINUTE ( uint16_t  fatTime)
inlinestatic

minute part of FAT directory time field

Parameters
[in]fatTimeTime in packed dir format.
Returns
Extracted minute [0,59]
static uint8_t FAT_MONTH ( uint16_t  fatDate)
inlinestatic

month part of FAT directory date field

Parameters
[in]fatDateDate in packed dir format.
Returns
Extracted month [1,12]
static uint8_t FAT_SECOND ( uint16_t  fatTime)
inlinestatic

second part of FAT directory time field Note second/2 is stored in packed time.

Parameters
[in]fatTimeTime in packed dir format.
Returns
Extracted second [0,58]
static uint16_t FAT_TIME ( uint8_t  hour,
uint8_t  minute,
uint8_t  second 
)
inlinestatic

time field for FAT directory entry

Parameters
[in]hour[0,23]
[in]minute[0,59]
[in]second[0,59]
Returns
Packed time for dir_t entry.
static uint16_t FAT_YEAR ( uint16_t  fatDate)
inlinestatic

year part of FAT directory date field

Parameters
[in]fatDateDate in packed dir format.
Returns
Extracted year [1980,2107]

Variable Documentation

uint8_t const BOOTSIG0 = 0X55

Value for byte 510 of boot block or MBR

uint8_t const BOOTSIG1 = 0XAA

Value for byte 511 of boot block or MBR

uint8_t const DIR_ATT_ARCHIVE = 0X20

Old DOS archive bit for backup support

uint8_t const DIR_ATT_DEFINED_BITS = 0X3F

defined attribute bits

uint8_t const DIR_ATT_DIRECTORY = 0X10

Entry is for a directory

uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)

Mask for file/subdirectory tests

uint8_t const DIR_ATT_HIDDEN = 0X02

File should e hidden in directory listings

uint8_t const DIR_ATT_LONG_NAME = 0X0F

Test value for long name entry. Test is (d->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME.

uint8_t const DIR_ATT_LONG_NAME_MASK = 0X3F

Test mask for long name entry

uint8_t const DIR_ATT_READ_ONLY = 0X01

file is read-only

uint8_t const DIR_ATT_SYSTEM = 0X04

Entry is for a system file

uint8_t const DIR_ATT_VOLUME_ID = 0X08

Directory entry contains the volume label

uint8_t const DIR_NAME_0XE5 = 0X05

escape for name[0] = 0XE5

uint8_t const DIR_NAME_DELETED = 0XE5

name[0] value for entry that is free after being "deleted"

uint8_t const DIR_NAME_FREE = 0X00

name[0] value for entry that is free and no allocated entries follow

const uint8_t DIR_NT_LC_BASE = 0X08

Filename base-name is all lower case

const uint8_t DIR_NT_LC_EXT = 0X10

Filename extension is all lower case.

uint8_t const EXTENDED_BOOT_SIG = 0X29

Value for bootSignature field int FAT/FAT32 boot sector

uint16_t const FAT12EOC = 0XFFF

FAT12 end of chain value used by Microsoft.

uint16_t const FAT12EOC_MIN = 0XFF8

Minimum value for FAT12 EOC. Use to test for EOC.

uint16_t const FAT16EOC = 0XFFFF

FAT16 end of chain value used by Microsoft.

uint16_t const FAT16EOC_MIN = 0XFFF8

Minimum value for FAT16 EOC. Use to test for EOC.

uint32_t const FAT32EOC = 0X0FFFFFFF

FAT32 end of chain value used by Microsoft.

uint32_t const FAT32EOC_MIN = 0X0FFFFFF8

Minimum value for FAT32 EOC. Use to test for EOC.

uint32_t const FAT32MASK = 0X0FFFFFFF

Mask a for FAT32 entry. Entries are 28 bits.

uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1

Default date for file timestamps is 1 Jan 2000

uint16_t const FAT_DEFAULT_TIME = (1 << 11)

Default time for file timestamp is 1 am

uint32_t const FSINFO_LEAD_SIG = 0x41615252

Lead signature for a FSINFO sector

uint32_t const FSINFO_STRUCT_SIG = 0x61417272

Struct signature for a FSINFO sector

const uint8_t LDIR_NAME1_DIM = 5

Dimension of first name field in long directory entry

const uint8_t LDIR_NAME2_DIM = 6

Dimension of first name field in long directory entry

const uint8_t LDIR_NAME3_DIM = 2

Dimension of first name field in long directory entry

const uint8_t LDIR_ORD_LAST_LONG_ENTRY = 0X40

Ord mast that indicates the entry is the last long dir entry in a set of long dir entries. All valid sets of long dir entries must begin with an entry having this mask.