145 CONST UINT8 *FuzzData,
150 EFI_FILE_PROTOCOL *VolumeRootDir;
154 EFI_FILE_PROTOCOL *NewHandle;
159 EFI_DISK_IO_PROTOCOL *DiskIo;
160 EFI_BLOCK_IO_PROTOCOL *BlockIo;
162 FAT_IFILE *FileInstance;
165 EFI_HANDLE DeviceHandle;
174 VolumeRootDir = NULL;
177 DeviceHandle = (EFI_HANDLE)0xDEADDEADULL;
182 FileName = AllocateZeroPool (BufferSize);
183 if (FileName == NULL) {
190 FreeAll (FileName, Volume, VolumeRootDir);
201 DiskIo = AllocateZeroPool (
sizeof (EFI_DISK_IO_PROTOCOL));
202 if (DiskIo == NULL) {
203 FreeAll (FileName, Volume, VolumeRootDir);
211 BlockIo = AllocateZeroPool (
sizeof (EFI_BLOCK_IO_PROTOCOL));
212 if (BlockIo == NULL) {
214 FreeAll (FileName, Volume, VolumeRootDir);
220 BlockIo->Media = AllocateZeroPool (
sizeof (EFI_BLOCK_IO_MEDIA));
221 if (BlockIo->Media == NULL) {
224 FreeAll (FileName, Volume, VolumeRootDir);
235 Status = FatAllocateVolume (DeviceHandle, DiskIo, NULL, BlockIo);
237 if (EFI_ERROR (Status)) {
238 FreePool (BlockIo->Media);
241 FreeAll (FileName, Volume, VolumeRootDir);
250 if (EFI_ERROR (Status)) {
251 FreeAll (FileName, Volume, VolumeRootDir);
260 Status = FatOpen (VolumeRootDir, &NewHandle, FileName, EFI_FILE_MODE_READ, 0);
261 if (Status == EFI_SUCCESS) {
265 Buffer = AllocateZeroPool (100);
268 FatClose (NewHandle);
269 FreeAll (FileName, Volume, VolumeRootDir);
273 Status = FatRead (NewHandle, &BufferSize,
Buffer);
274 if (Status == EFI_BUFFER_TOO_SMALL) {
275 TmpBuffer = ReallocatePool (100, BufferSize,
Buffer);
276 if (TmpBuffer == NULL) {
278 FatClose (NewHandle);
279 FreeAll (FileName, Volume, VolumeRootDir);
287 FatRead (NewHandle, &BufferSize,
Buffer);
290 FatWrite (NewHandle, &BufferSize,
Buffer);
292 FatFlush (NewHandle);
302 if (Status == EFI_BUFFER_TOO_SMALL) {
303 Info = AllocateZeroPool (
Len);
305 FatClose (NewHandle);
306 FreeAll (FileName, Volume, VolumeRootDir);
311 if (!EFI_ERROR (Status)) {
323 if (Status == EFI_BUFFER_TOO_SMALL) {
324 Info = AllocateZeroPool (
Len);
326 FatClose (NewHandle);
327 FreeAll (FileName, Volume, VolumeRootDir);
332 if (!EFI_ERROR (Status)) {
344 if (Status == EFI_BUFFER_TOO_SMALL) {
345 Info = AllocateZeroPool (
Len);
347 FatClose (NewHandle);
348 FreeAll (FileName, Volume, VolumeRootDir);
353 if (!EFI_ERROR (Status)) {
365 FatGetPosition (NewHandle, &Position);
366 FatSetPosition (NewHandle, Position);
371 Position = (UINT64)-1;
372 Status = FatSetPosition (NewHandle, Position);
373 if (!EFI_ERROR (Status)) {
374 Buffer = AllocateZeroPool (100);
378 FatClose (NewHandle);
379 FreeAll (FileName, Volume, VolumeRootDir);
383 Status = FatRead (NewHandle, &BufferSize,
Buffer);
384 if (Status == EFI_BUFFER_TOO_SMALL) {
385 TmpBuffer = ReallocatePool (100, BufferSize,
Buffer);
386 if (TmpBuffer == NULL) {
388 FatClose (NewHandle);
389 FreeAll (FileName, Volume, VolumeRootDir);
397 FatRead (NewHandle, &BufferSize,
Buffer);
400 FatWrite (NewHandle, &BufferSize,
Buffer);
402 FatFlush (NewHandle);
410 FileInstance = IFILE_FROM_FHAND (NewHandle);
411 FileSize = FileInstance->OFile->FileSize;
412 if (FileSize < (UINT64)-1 - 1) {
413 Position = FileSize + 1;
414 Status = FatSetPosition (NewHandle, Position);
415 if (!EFI_ERROR (Status)) {
416 Buffer = AllocateZeroPool (100);
419 FatClose (NewHandle);
420 FreeAll (FileName, Volume, VolumeRootDir);
424 Status = FatRead (NewHandle, &BufferSize,
Buffer);
426 ASSERT (Status == EFI_DEVICE_ERROR);
431 FatDelete (NewHandle);
434 FreeAll (FileName, Volume, VolumeRootDir);