ReactOS  0.4.14-dev-583-g2a1ba2c
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 ATTR_NORMAL   0x00
 
#define ATTR_READONLY   0x01
 
#define ATTR_HIDDEN   0x02
 
#define ATTR_SYSTEM   0x04
 
#define ATTR_VOLUMENAME   0x08
 
#define ATTR_DIRECTORY   0x10
 
#define ATTR_ARCHIVE   0x20
 
#define ATTR_LONG_NAME   (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | 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_INFOPFAT_FILE_INFO
 

Functions

const DEVVTBLFatMount (ULONG DeviceId)
 

Macro Definition Documentation

◆ ATTR_ARCHIVE

#define ATTR_ARCHIVE   0x20

Definition at line 164 of file fat.h.

◆ ATTR_DIRECTORY

#define ATTR_DIRECTORY   0x10

Definition at line 163 of file fat.h.

◆ ATTR_HIDDEN

#define ATTR_HIDDEN   0x02

Definition at line 160 of file fat.h.

◆ ATTR_LONG_NAME

Definition at line 165 of file fat.h.

◆ ATTR_NORMAL

#define ATTR_NORMAL   0x00

Definition at line 158 of file fat.h.

◆ ATTR_READONLY

#define ATTR_READONLY   0x01

Definition at line 159 of file fat.h.

◆ ATTR_SYSTEM

#define ATTR_SYSTEM   0x04

Definition at line 161 of file fat.h.

◆ ATTR_VOLUMENAME

#define ATTR_VOLUMENAME   0x08

Definition at line 162 of file fat.h.

◆ FAT12

#define FAT12   1

Definition at line 167 of file fat.h.

◆ FAT16

#define FAT16   2

Definition at line 168 of file fat.h.

◆ FAT32

#define FAT32   3

Definition at line 169 of file fat.h.

◆ FATX16

#define FATX16   4

Definition at line 170 of file fat.h.

◆ FATX32

#define FATX32   5

Definition at line 171 of file fat.h.

◆ ISFATX

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

Definition at line 173 of file fat.h.

Typedef Documentation

◆ FAT32_BOOTSECTOR

◆ FAT_BOOTSECTOR

◆ FATX_BOOTSECTOR

◆ PDIRENTRY

◆ PFAT32_BOOTSECTOR

◆ PFAT_BOOTSECTOR

◆ PFAT_FILE_INFO

◆ PFAT_VOLUME_INFO

Definition at line 146 of file fat.h.

◆ PFATX_BOOTSECTOR

◆ PFATX_DIRENTRY

◆ PLFN_DIRENTRY

Function Documentation

◆ FatMount()

const DEVVTBL* FatMount ( ULONG  DeviceId)

Definition at line 1552 of file fat.c.

1553 {
1555  UCHAR Buffer[512];
1558  PFATX_BOOTSECTOR BootSectorX = (PFATX_BOOTSECTOR)Buffer;
1561  ULONG Count;
1564 
1565  TRACE("Enter FatMount(%lu)\n", DeviceId);
1566 
1567  //
1568  // Allocate data for volume information
1569  //
1571  if (!Volume)
1572  return NULL;
1574 
1575  //
1576  // Read the BootSector
1577  //
1578  Position.QuadPart = 0;
1579  Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
1580  if (Status != ESUCCESS)
1581  {
1583  return NULL;
1584  }
1585  Status = ArcRead(DeviceId, Buffer, sizeof(Buffer), &Count);
1586  if (Status != ESUCCESS || Count != sizeof(Buffer))
1587  {
1589  return NULL;
1590  }
1591 
1592  //
1593  // Check if BootSector is valid. If no, return early
1594  //
1595  if (!RtlEqualMemory(BootSector->FileSystemType, "FAT12 ", 8) &&
1596  !RtlEqualMemory(BootSector->FileSystemType, "FAT16 ", 8) &&
1597  !RtlEqualMemory(BootSector32->FileSystemType, "FAT32 ", 8) &&
1598  !RtlEqualMemory(BootSectorX->FileSystemType, "FATX", 4))
1599  {
1601  return NULL;
1602  }
1603 
1604  //
1605  // Determine sector count
1606  //
1608  if (Status != ESUCCESS)
1609  {
1611  return NULL;
1612  }
1613  SectorCount.QuadPart = (FileInformation.EndingAddress.QuadPart - FileInformation.StartingAddress.QuadPart);
1614  SectorCount.QuadPart /= SECTOR_SIZE;
1615 
1616  //
1617  // Keep device id
1618  //
1619  Volume->DeviceId = DeviceId;
1620 
1621  //
1622  // Really open the volume
1623  //
1624  if (!FatOpenVolume(Volume, BootSector, SectorCount.QuadPart))
1625  {
1627  return NULL;
1628  }
1629 
1630  //
1631  // Remember FAT volume information
1632  //
1633  FatVolumes[DeviceId] = Volume;
1634 
1635  //
1636  // Return success
1637  //
1638  TRACE("FatMount(%lu) success\n", DeviceId);
1639  return &FatFuncTable;
1640 }
Definition: arc.h:32
static COORD Position
Definition: mouse.c:34
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
ULONG ARC_STATUS
Definition: arc.h:4
struct _FAT32_BOOTSECTOR * PFAT32_BOOTSECTOR
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI ULONG NTAPI RtlEqualMemory(CONST VOID *Source1, CONST VOID *Source2, ULONG Length)
PFAT_VOLUME_INFO FatVolumes[MAX_FDS]
Definition: fat.c:58
#define TAG_FAT_VOLUME
Definition: fat.c:33
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
struct _FAT_BOOTSECTOR * PFAT_BOOTSECTOR
unsigned char UCHAR
Definition: xmlstorage.h:181
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:243
const DEVVTBL FatFuncTable
Definition: fat.c:1542
ULONG SectorCount
Definition: part_xbox.c:32
BOOLEAN FatOpenVolume(PFAT_VOLUME_INFO Volume, PFAT_BOOTSECTOR BootSector, ULONGLONG PartitionSectorCount)
Definition: fat.c:138
Status
Definition: gdiplustypes.h:24
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SECTOR_SIZE
Definition: fs.h:22
CHAR FileSystemType[4]
Definition: fat.h:90
struct _FATX_BOOTSECTOR * PFATX_BOOTSECTOR
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:186