ReactOS  0.4.13-dev-39-g8b6696f
fat.c File Reference
#include <bl.h>
#include <fs_rec/fs_rec.h>
Include dependency graph for fat.c:

Go to the source code of this file.

Functions

NTSTATUS FatMount (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ PBL_FILE_ENTRY *FileEntry)
 
NTSTATUS FatInitialize (VOID)
 

Variables

PVOIDFatDeviceTable
 
ULONG FatDeviceTableEntries
 
PWCHAR FatpLongFileName
 

Function Documentation

◆ FatInitialize()

NTSTATUS FatInitialize ( VOID  )

Definition at line 81 of file fat.c.

84 {
86 
87  /* Allocate the device table with 2 entries*/
91  if (FatDeviceTable)
92  {
93  /* Zero it out */
96 
97  /* Allocate a 512 byte buffer for long file name conversion */
100  }
101  else
102  {
103  /* No memory, fail */
105  }
106 
107  /* Return back to caller */
108  return Status;
109 }
PVOID * FatDeviceTable
Definition: fat.c:16
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
PWCHAR FatpLongFileName
Definition: fat.c:18
Status
Definition: gdiplustypes.h:24
ULONG FatDeviceTableEntries
Definition: fat.c:17
Definition: bl.h:1038
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ FatMount()

NTSTATUS FatMount ( _In_ ULONG  DeviceId,
_In_ ULONG  Unknown,
_Out_ PBL_FILE_ENTRY FileEntry 
)

Definition at line 23 of file fat.c.

28 {
29  BL_DEVICE_INFORMATION DeviceInformation;
30  ULONG UnknownFlag;
32  PACKED_BOOT_SECTOR FatBootSector;
33  BIOS_PARAMETER_BLOCK BiosBlock;
34 
35  /* Capture thing */
36  BlDeviceGetInformation(DeviceId, &DeviceInformation);
37  UnknownFlag = DeviceInformation.BlockDeviceInfo.Unknown;
38 
39  /* Set thing to 1 */
40  DeviceInformation.BlockDeviceInfo.Unknown |= 1;
41  BlDeviceSetInformation(DeviceId, &DeviceInformation);
42 
43  /* Read the boot sector */
44  Status = BlDeviceReadAtOffset(DeviceId,
45  sizeof(FatBootSector),
46  0,
47  &FatBootSector,
48  NULL);
49 
50  /* Restore thing back */
51  DeviceInformation.BlockDeviceInfo.Unknown = UnknownFlag;
52  BlDeviceSetInformation(DeviceId, &DeviceInformation);
53  if (!NT_SUCCESS(Status))
54  {
55  EfiPrintf(L"Failed reading drive: %lx\r\n", Status);
56  return Status;
57  }
58 
59  FatUnpackBios(&BiosBlock, &FatBootSector.PackedBpb);
60 
61  /* For now, quickly fail if this isn't FAT */
62  if (FatBootSector.Jump[0] != 0xE9)
63  {
64  return STATUS_UNSUCCESSFUL;
65  }
66 
67  EfiPrintf(L"Jump: %lx Bytes Per Sector: %d Sectors Per Cluster: %d Reserved: %d Fats: %d Sectors: %d Large Sectors: %d Media: %lx RootEntries: %d\r\n",
68  FatBootSector.Jump[0],
69  BiosBlock.BytesPerSector,
70  BiosBlock.SectorsPerCluster,
71  BiosBlock.ReservedSectors,
72  BiosBlock.Fats,
73  BiosBlock.Sectors,
74  BiosBlock.LargeSectors,
75  BiosBlock.Media,
76  BiosBlock.RootEntries);
78 }
UCHAR Jump[3]
Definition: fat.h:163
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BlDeviceGetInformation(_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
Definition: device.c:682
USHORT Sectors
Definition: fat.h:109
smooth NULL
Definition: ftsmooth.c:416
BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo
Definition: bl.h:1229
NTSTATUS BlDeviceReadAtOffset(_In_ ULONG DeviceId, _In_ ULONG Size, _In_ ULONGLONG Offset, _In_ PVOID Buffer, _Out_ PULONG BytesRead)
Definition: device.c:773
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
USHORT BytesPerSector
Definition: fat.h:104
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
USHORT RootEntries
Definition: fat.h:108
static const WCHAR L[]
Definition: oid.c:1250
PACKED_BIOS_PARAMETER_BLOCK PackedBpb
Definition: fat.h:165
Status
Definition: gdiplustypes.h:24
USHORT ReservedSectors
Definition: fat.h:106
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
unsigned int ULONG
Definition: retypes.h:1
UCHAR SectorsPerCluster
Definition: fat.h:105
#define FatUnpackBios(Bios, Pbios)
Definition: fat.h:136
NTSTATUS BlDeviceSetInformation(_In_ ULONG DeviceId, _In_ PBL_DEVICE_INFORMATION DeviceInformation)
ULONG32 LargeSectors
Definition: fat.h:115

Referenced by ArcOpen().

Variable Documentation

◆ FatDeviceTable

PVOID* FatDeviceTable

Definition at line 16 of file fat.c.

Referenced by FatInitialize().

◆ FatDeviceTableEntries

ULONG FatDeviceTableEntries

Definition at line 17 of file fat.c.

Referenced by FatInitialize().

◆ FatpLongFileName

PWCHAR FatpLongFileName

Definition at line 18 of file fat.c.

Referenced by FatInitialize().