ReactOS 0.4.16-dev-1946-g52006dd
fat.h File Reference
#include <pshpack1.h>
#include <poppack.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_BOOTSECTOR
 
struct  _FAT32_BOOTSECTOR
 
struct  _FATX_BOOTSECTOR
 
struct  DIRENTRY
 
struct  LFN_DIRENTRY
 
struct  FATX_DIRENTRY
 
struct  _FAT_FILE_INFO
 

Macros

#define FAT_ATTR_NORMAL   0x00
 
#define FAT_ATTR_READONLY   0x01
 
#define FAT_ATTR_HIDDEN   0x02
 
#define FAT_ATTR_SYSTEM   0x04
 
#define FAT_ATTR_VOLUMENAME   0x08
 
#define FAT_ATTR_DIRECTORY   0x10
 
#define FAT_ATTR_ARCHIVE   0x20
 
#define FAT_ATTR_LONG_NAME   (FAT_ATTR_READONLY | FAT_ATTR_HIDDEN | FAT_ATTR_SYSTEM | FAT_ATTR_VOLUMENAME)
 
#define FAT12   1
 
#define FAT16   2
 
#define FAT32   3
 
#define FATX16   4
 
#define FATX32   5
 
#define ISFATX(FT)   ((FT) == FATX16 || (FT) == FATX32)
 

Typedefs

typedef struct _FAT_BOOTSECTOR FAT_BOOTSECTOR
 
typedef struct _FAT_BOOTSECTORPFAT_BOOTSECTOR
 
typedef struct _FAT32_BOOTSECTOR FAT32_BOOTSECTOR
 
typedef struct _FAT32_BOOTSECTORPFAT32_BOOTSECTOR
 
typedef struct _FATX_BOOTSECTOR FATX_BOOTSECTOR
 
typedef struct _FATX_BOOTSECTORPFATX_BOOTSECTOR
 
typedef struct DIRENTRYPDIRENTRY
 
typedef struct LFN_DIRENTRYPLFN_DIRENTRY
 
typedef struct FATX_DIRENTRYPFATX_DIRENTRY
 
typedef struct _FAT_VOLUME_INFOPFAT_VOLUME_INFO
 
typedef struct _FAT_FILE_INFO FAT_FILE_INFO
 
typedef struct _FAT_FILE_INFOPFAT_FILE_INFO
 

Functions

ULONGLONG FatGetVolumeSize (_In_ ULONG DeviceId)
 Returns the size of the FAT volume laid on the storage media device opened via DeviceId.
 
const DEVVTBLFatMount (ULONG DeviceId)
 

Macro Definition Documentation

◆ FAT12

#define FAT12   1

Definition at line 155 of file fat.h.

◆ FAT16

#define FAT16   2

Definition at line 156 of file fat.h.

◆ FAT32

#define FAT32   3

Definition at line 157 of file fat.h.

◆ FAT_ATTR_ARCHIVE

#define FAT_ATTR_ARCHIVE   0x20

Definition at line 152 of file fat.h.

◆ FAT_ATTR_DIRECTORY

#define FAT_ATTR_DIRECTORY   0x10

Definition at line 151 of file fat.h.

◆ FAT_ATTR_HIDDEN

#define FAT_ATTR_HIDDEN   0x02

Definition at line 148 of file fat.h.

◆ FAT_ATTR_LONG_NAME

Definition at line 153 of file fat.h.

◆ FAT_ATTR_NORMAL

#define FAT_ATTR_NORMAL   0x00

Definition at line 146 of file fat.h.

◆ FAT_ATTR_READONLY

#define FAT_ATTR_READONLY   0x01

Definition at line 147 of file fat.h.

◆ FAT_ATTR_SYSTEM

#define FAT_ATTR_SYSTEM   0x04

Definition at line 149 of file fat.h.

◆ FAT_ATTR_VOLUMENAME

#define FAT_ATTR_VOLUMENAME   0x08

Definition at line 150 of file fat.h.

◆ FATX16

#define FATX16   4

Definition at line 158 of file fat.h.

◆ FATX32

#define FATX32   5

Definition at line 159 of file fat.h.

◆ ISFATX

#define ISFATX (   FT)    ((FT) == FATX16 || (FT) == FATX32)

Definition at line 161 of file fat.h.

Typedef Documentation

◆ FAT32_BOOTSECTOR

◆ FAT_BOOTSECTOR

◆ FAT_FILE_INFO

◆ FATX_BOOTSECTOR

◆ PDIRENTRY

◆ PFAT32_BOOTSECTOR

◆ PFAT_BOOTSECTOR

◆ PFAT_FILE_INFO

◆ PFAT_VOLUME_INFO

Definition at line 163 of file fat.h.

◆ PFATX_BOOTSECTOR

◆ PFATX_DIRENTRY

◆ PLFN_DIRENTRY

Function Documentation

◆ FatGetVolumeSize()

ULONGLONG FatGetVolumeSize ( _In_ ULONG  DeviceId)

Returns the size of the FAT volume laid on the storage media device opened via DeviceId.

Definition at line 1616 of file fat.c.

1618{
1620 ASSERT(Volume);
1621 return (ULONGLONG)Volume->TotalSectors * Volume->BytesPerSector;
1622}
PFAT_VOLUME_INFO FatVolumes[MAX_FDS]
Definition: fat.c:59
UNICODE_STRING Volume
Definition: fltkernel.h:1172
#define ASSERT(a)
Definition: mode.c:44
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by FsGetVolumeSize().

◆ FatMount()

const DEVVTBL * FatMount ( ULONG  DeviceId)

Definition at line 1645 of file fat.c.

1646{
1654 ULONG Count;
1657
1658 TRACE("Enter FatMount(%lu)\n", DeviceId);
1659
1660 //
1661 // Allocate data for volume information
1662 //
1664 if (!Volume)
1665 return NULL;
1667
1668 //
1669 // Read the BootSector
1670 //
1671 Position.QuadPart = 0;
1672 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
1673 if (Status != ESUCCESS)
1674 {
1676 return NULL;
1677 }
1678 Status = ArcRead(DeviceId, Buffer, sizeof(Buffer), &Count);
1679 if (Status != ESUCCESS || Count != sizeof(Buffer))
1680 {
1682 return NULL;
1683 }
1684
1685 //
1686 // Check if BootSector is valid. If no, return early
1687 //
1688 if (!RtlEqualMemory(BootSector->FileSystemType, "FAT12 ", 8) &&
1689 !RtlEqualMemory(BootSector->FileSystemType, "FAT16 ", 8) &&
1690 !RtlEqualMemory(BootSector32->FileSystemType, "FAT32 ", 8) &&
1691 !RtlEqualMemory(BootSectorX->FileSystemType, "FATX", 4))
1692 {
1694 return NULL;
1695 }
1696
1697 //
1698 // Determine sector count
1699 //
1701 if (Status != ESUCCESS)
1702 {
1704 return NULL;
1705 }
1706 SectorCount.QuadPart = (FileInformation.EndingAddress.QuadPart - FileInformation.StartingAddress.QuadPart);
1707 SectorCount.QuadPart /= SECTOR_SIZE;
1708
1709 //
1710 // Keep device id
1711 //
1712 Volume->DeviceId = DeviceId;
1713
1714 //
1715 // Really open the volume
1716 //
1717 if (!FatOpenVolume(Volume, BootSector, SectorCount.QuadPart))
1718 {
1720 return NULL;
1721 }
1722
1723 //
1724 // Remember FAT volume information
1725 //
1726 FatVolumes[DeviceId] = Volume;
1727
1728 //
1729 // Return success
1730 //
1731 TRACE("FatMount(%lu) success\n", DeviceId);
1732 return (ISFATX(Volume->FatType) ? &FatXFuncTable : &FatFuncTable);
1733}
struct _FATX_BOOTSECTOR * PFATX_BOOTSECTOR
#define ISFATX(FT)
Definition: fat.h:161
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:462
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:455
#define SECTOR_SIZE
Definition: fs.h:22
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:448
VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: heap.c:553
PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: heap.c:545
#define TAG_FAT_VOLUME
Definition: fat.c:32
const DEVVTBL FatXFuncTable
Definition: fat.c:1635
BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR BootSector, ULONGLONG PartitionSectorCount)
Definition: fat.c:160
const DEVVTBL FatFuncTable
Definition: fat.c:1625
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
int Count
Definition: noreturn.cpp:7
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
ULONG SectorCount
Definition: part_xbox.c:31
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
@ SeekAbsolute
Definition: arc.h:59
struct _FAT32_BOOTSECTOR * PFAT32_BOOTSECTOR
struct _FAT_BOOTSECTOR * PFAT_BOOTSECTOR
#define TRACE(s)
Definition: solgame.cpp:4
CHAR FileSystemType[4]
Definition: fat.h:90
static COORD Position
Definition: mouse.c:34
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
unsigned char UCHAR
Definition: xmlstorage.h:181