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

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

Copyright (c) 2011-2018 Bill Greiman This file is part of the SdFat library for SD memory cards.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Typedef Documentation

◆ bpb_t

typedef struct biosParmBlock bpb_t

Type name for biosParmBlock

◆ dir_t

typedef struct directoryEntry dir_t

Type name for directoryEntry

◆ fat32_boot_t

typedef struct fat32_boot fat32_boot_t

Type name for FAT32 Boot Sector

◆ fat32_fsinfo_t

typedef struct fat32_fsinfo fat32_fsinfo_t

Type name for FAT32 FSINFO Sector

◆ fat_boot_t

typedef struct fat_boot fat_boot_t

Type name for FAT Boot Sector

◆ ldir_t

typedef struct longDirectoryEntry ldir_t

Type name for longDirectoryEntry

◆ mbr_t

typedef struct masterBootRecord mbr_t

Type name for masterBootRecord

◆ part_t

typedef struct partitionTable part_t

Type name for partitionTable

Function Documentation

◆ DIR_IS_FILE()

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.

◆ DIR_IS_FILE_OR_SUBDIR()

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.

◆ DIR_IS_HIDDEN()

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.

◆ DIR_IS_LONG_NAME()

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.

◆ DIR_IS_SUBDIR()

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.

◆ DIR_IS_SYSTEM()

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.

◆ FAT_DATE()

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.

◆ FAT_DAY()

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]

◆ FAT_HOUR()

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]

◆ FAT_MINUTE()

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]

◆ FAT_MONTH()

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]

◆ FAT_SECOND()

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]

◆ FAT_TIME()

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.

◆ FAT_YEAR()

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

◆ BOOTSIG0

const uint8_t BOOTSIG0 = 0X55

Value for byte 510 of boot block or MBR

◆ BOOTSIG1

const uint8_t BOOTSIG1 = 0XAA

Value for byte 511 of boot block or MBR

◆ DIR_ATT_ARCHIVE

const uint8_t DIR_ATT_ARCHIVE = 0X20

Old DOS archive bit for backup support

◆ DIR_ATT_DEFINED_BITS

const uint8_t DIR_ATT_DEFINED_BITS = 0X3F

defined attribute bits

◆ DIR_ATT_DIRECTORY

const uint8_t DIR_ATT_DIRECTORY = 0X10

Entry is for a directory

◆ DIR_ATT_FILE_TYPE_MASK

const uint8_t DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY)

Mask for file/subdirectory tests

◆ DIR_ATT_HIDDEN

const uint8_t DIR_ATT_HIDDEN = 0X02

File should e hidden in directory listings

◆ DIR_ATT_LONG_NAME

const uint8_t DIR_ATT_LONG_NAME = 0X0F

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

◆ DIR_ATT_LONG_NAME_MASK

const uint8_t DIR_ATT_LONG_NAME_MASK = 0X3F

Test mask for long name entry

◆ DIR_ATT_READ_ONLY

const uint8_t DIR_ATT_READ_ONLY = 0X01

file is read-only

◆ DIR_ATT_SYSTEM

const uint8_t DIR_ATT_SYSTEM = 0X04

Entry is for a system file

◆ DIR_ATT_VOLUME_ID

const uint8_t DIR_ATT_VOLUME_ID = 0X08

Directory entry contains the volume label

◆ DIR_NAME_0XE5

const uint8_t DIR_NAME_0XE5 = 0X05

escape for name[0] = 0XE5

◆ DIR_NAME_DELETED

const uint8_t DIR_NAME_DELETED = 0XE5

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

◆ DIR_NAME_FREE

const uint8_t DIR_NAME_FREE = 0X00

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

◆ DIR_NT_LC_BASE

const uint8_t DIR_NT_LC_BASE = 0X08

Filename base-name is all lower case

◆ DIR_NT_LC_EXT

const uint8_t DIR_NT_LC_EXT = 0X10

Filename extension is all lower case.

◆ EXTENDED_BOOT_SIG

const uint8_t EXTENDED_BOOT_SIG = 0X29

Value for bootSignature field int FAT/FAT32 boot sector

◆ FAT12EOC

const uint16_t FAT12EOC = 0XFFF

FAT12 end of chain value used by Microsoft.

◆ FAT12EOC_MIN

const uint16_t FAT12EOC_MIN = 0XFF8

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

◆ FAT16EOC

const uint16_t FAT16EOC = 0XFFFF

FAT16 end of chain value used by Microsoft.

◆ FAT16EOC_MIN

const uint16_t FAT16EOC_MIN = 0XFFF8

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

◆ FAT32EOC

const uint32_t FAT32EOC = 0X0FFFFFFF

FAT32 end of chain value used by Microsoft.

◆ FAT32EOC_MIN

const uint32_t FAT32EOC_MIN = 0X0FFFFFF8

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

◆ FAT32MASK

const uint32_t FAT32MASK = 0X0FFFFFFF

Mask a for FAT32 entry. Entries are 28 bits.

◆ FAT_DEFAULT_DATE

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

Default date for file timestamps is 1 Jan 2000

◆ FAT_DEFAULT_TIME

const uint16_t FAT_DEFAULT_TIME = (1 << 11)

Default time for file timestamp is 1 am

◆ FSINFO_LEAD_SIG

const uint32_t FSINFO_LEAD_SIG = 0x41615252

Lead signature for a FSINFO sector

◆ FSINFO_STRUCT_SIG

const uint32_t FSINFO_STRUCT_SIG = 0x61417272

Struct signature for a FSINFO sector

◆ LDIR_NAME1_DIM

const uint8_t LDIR_NAME1_DIM = 5

Dimension of first name field in long directory entry

◆ LDIR_NAME2_DIM

const uint8_t LDIR_NAME2_DIM = 6

Dimension of first name field in long directory entry

◆ LDIR_NAME3_DIM

const uint8_t LDIR_NAME3_DIM = 2

Dimension of first name field in long directory entry

◆ LDIR_ORD_LAST_LONG_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.