From e88843426b0c5de4c859eec4564e5159f79dc5a3 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Fri, 11 Sep 2015 04:33:24 +0000 Subject: [PATCH] [BOOTMGFW] - Hey Arch, your buddies gave you ETFS support for native EFI boot, of course reading sector 0 is all zeroes, you're not on FAT, you idiot! ETFS has data at sector 16 and 17. - Implement beginning of ETFS support. We correctly mount the reactOS boot cd as ETFS and open the root directory entry! svn path=/trunk/; revision=69181 --- reactos/boot/environ/CMakeLists.txt | 1 + reactos/boot/environ/include/bl.h | 31 +- reactos/boot/environ/lib/io/device.c | 8 +- reactos/boot/environ/lib/io/etfs.c | 433 +++++++++++++++++++++++++++ reactos/boot/environ/lib/io/fat.c | 8 +- reactos/boot/environ/lib/io/file.c | 50 ++-- 6 files changed, 494 insertions(+), 37 deletions(-) create mode 100644 reactos/boot/environ/lib/io/etfs.c diff --git a/reactos/boot/environ/CMakeLists.txt b/reactos/boot/environ/CMakeLists.txt index 3d8b77cbf7e..f5bf508ea67 100644 --- a/reactos/boot/environ/CMakeLists.txt +++ b/reactos/boot/environ/CMakeLists.txt @@ -20,6 +20,7 @@ list(APPEND BOOTLIB_SOURCE lib/mm/descriptor.c lib/platform/time.c lib/io/blkcache.c + lib/io/etfs.c lib/io/io.c lib/io/device.c lib/io/file.c diff --git a/reactos/boot/environ/include/bl.h b/reactos/boot/environ/include/bl.h index 0a444cf8dca..baace9c094e 100644 --- a/reactos/boot/environ/include/bl.h +++ b/reactos/boot/environ/include/bl.h @@ -269,9 +269,9 @@ struct _BL_FILE_ENTRY; typedef NTSTATUS (*PBL_FILE_OPEN) ( - _In_ struct _BL_FILE_ENTRY* ParentFileEntry, + _In_ struct _BL_FILE_ENTRY* Directory, _In_ PWCHAR FileName, - _In_ ULONG OpenFlags, + _In_ ULONG Flags, _Out_ struct _BL_FILE_ENTRY** FileEntry ); @@ -758,16 +758,17 @@ typedef struct _BL_FILE_CALLBACKS typedef struct _BL_FILE_ENTRY { - ULONG ReferenceCount; - ULONG FileId; - ULONG DeviceId; - ULONG Flags; PWCHAR FilePath; + ULONG DeviceId; + ULONG FileId; + ULONG Flags; + ULONG ReferenceCount; ULONG Unknown; - ULONG Unknown1; - ULONG Unknown2; + ULONGLONG Unknown1; + ULONGLONG Unknown2; BL_FILE_CALLBACKS Callbacks; - PBL_FILE_DESTROY_CALLBACK DestroyCallback; + //PBL_FILE_DESTROY_CALLBACK DestroyCallback; + PVOID FsSpecificData; } BL_FILE_ENTRY, *PBL_FILE_ENTRY; typedef struct _BL_FILE_SYSTEM_ENTRY @@ -1225,6 +1226,18 @@ FatMount ( _Out_ PBL_FILE_ENTRY* FileEntry ); +NTSTATUS +EtfsInitialize ( + VOID + ); + +NTSTATUS +EtfsMount ( + _In_ ULONG DeviceId, + _In_ ULONG Unknown, + _Out_ PBL_FILE_ENTRY* FileEntry + ); + /* UTILITY ROUTINES **********************************************************/ EFI_STATUS diff --git a/reactos/boot/environ/lib/io/device.c b/reactos/boot/environ/lib/io/device.c index 4b2be5ebf40..fdaf14ec9b0 100644 --- a/reactos/boot/environ/lib/io/device.c +++ b/reactos/boot/environ/lib/io/device.c @@ -130,8 +130,8 @@ BlockIoFirmwareRead ( break; } - EfiPrintf(L"EFI Reading BLOCK %d off media %lx (%d blocks)\r\n", - Block, BlockProtocol->Media->MediaId, BlockCount); + //EfiPrintf(L"EFI Reading BLOCK %d off media %lx (%d blocks)\r\n", + //Block, BlockProtocol->Media->MediaId, BlockCount); EfiStatus = BlockProtocol->ReadBlocks(BlockProtocol, BlockProtocol->Media->MediaId, Block, @@ -139,8 +139,8 @@ BlockIoFirmwareRead ( Buffer); if (EfiStatus == EFI_SUCCESS) { - EfiPrintf(L"EFI Read complete into buffer\r\n"); - EfiPrintf(L"Buffer data: %lx %lx %lx %lx\r\n", *(PULONG)Buffer, *((PULONG)Buffer + 1), *((PULONG)Buffer + 2), *((PULONG)Buffer + 3)); + //EfiPrintf(L"EFI Read complete into buffer\r\n"); + //EfiPrintf(L"Buffer data: %lx %lx %lx %lx\r\n", *(PULONG)Buffer, *((PULONG)Buffer + 1), *((PULONG)Buffer + 2), *((PULONG)Buffer + 3)); } if (OldMode != 1) diff --git a/reactos/boot/environ/lib/io/etfs.c b/reactos/boot/environ/lib/io/etfs.c new file mode 100644 index 00000000000..fe8d8dbe179 --- /dev/null +++ b/reactos/boot/environ/lib/io/etfs.c @@ -0,0 +1,433 @@ +/* + * COPYRIGHT: See COPYING.ARM in the top level directory + * PROJECT: ReactOS UEFI Boot Library + * FILE: boot/environ/lib/io/etfs.c + * PURPOSE: Boot Library El Torito File System Management Routines + * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "bl.h" +#include "../drivers/filesystems/cdfs_new/cd.h" +typedef struct _RAW_ET_VD +{ + UCHAR BootIndicator; + UCHAR StandardId[5]; + UCHAR Version; + UCHAR SystemId[32]; + UCHAR Reserved[32]; + ULONG BootCatalogOffset; + UCHAR Padding[1973]; +} RAW_ET_VD, *PRAW_ET_VD; + +/* DATA VARIABLES ************************************************************/ + +typedef struct _BL_ETFS_CONTEXT +{ + ULONG RootDirOffset; + ULONG RootDirSize; + ULONG BlockSize; + ULONG VolumeSize; + BOOLEAN IsIso; + PRAW_ISO_VD MemoryBlock; + ULONG Offset; +} BL_ETFS_CONTEXT, *PBL_ETFS_CONTEXT; + +typedef struct _BL_ETFS_FILE +{ + ULONG Flags; + ULONG DeviceId; + ULONG Offset; + ULONG Unknown; + ULONGLONG Size; + PWCHAR FsName; +} BL_ETFS_FILE, *PBL_ETFS_FILE; + +ULONG EtfsDeviceTableEntries; +PVOID* EtfsDeviceTable; + +NTSTATUS +EtfsOpen ( + _In_ PBL_FILE_ENTRY Directory, + _In_ PWCHAR FileName, + _In_ ULONG Flags, + _Out_ PBL_FILE_ENTRY *FileEntry + ); + +BL_FILE_CALLBACKS EtfsFunctionTable = +{ + EtfsOpen, +}; + +/* FUNCTIONS *****************************************************************/ + +NTSTATUS +EtfsOpen ( + _In_ PBL_FILE_ENTRY Directory, + _In_ PWCHAR FileName, + _In_ ULONG Flags, + _Out_ PBL_FILE_ENTRY *FileEntry + ) +{ + EfiPrintf(L"Attempting to open file %s in directory %s. Not yet supported\r\n", FileName, Directory->FilePath); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +EtfspCheckCdfs ( + _In_ PBL_ETFS_CONTEXT EtfsContext, + _In_ ULONG DeviceId, + _Out_ PRAW_ISO_VD *VolumeDescriptor, + _Out_ PBOOLEAN VolumeIsIso + ) +{ + EfiPrintf(L"Raw Cdfs not implemented\r\n"); + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +EtfspCheckEtfs ( + _In_ PBL_ETFS_CONTEXT EtfsContext, + _In_ ULONG DeviceId, + _Out_ PRAW_ISO_VD *VolumeDescriptor, + _Out_ PBOOLEAN VolumeIsIso + ) +{ + PRAW_ISO_VD IsoVd; + PRAW_ET_VD EtVd; + NTSTATUS Status; + BOOLEAN IsIso; + BL_DEVICE_INFORMATION DeviceInformation; + ULONG Unknown, BytesRead; + ANSI_STRING CompareString, String; + + /* Save our static buffer pointer */ + IsoVd = EtfsContext->MemoryBlock; + EtVd = (PRAW_ET_VD)IsoVd; + + /* First, read the El Torito Volume Descriptor */ + BlDeviceGetInformation(DeviceId, &DeviceInformation); + Unknown = DeviceInformation.BlockDeviceInfo.Unknown; + DeviceInformation.BlockDeviceInfo.Unknown |= 1; + BlDeviceSetInformation(DeviceId, &DeviceInformation); + Status = BlDeviceReadAtOffset(DeviceId, + CD_SECTOR_SIZE, + (FIRST_VD_SECTOR + 1) * CD_SECTOR_SIZE, + EtfsContext->MemoryBlock, + &BytesRead); + DeviceInformation.BlockDeviceInfo.Unknown = Unknown; + BlDeviceSetInformation(DeviceId, &DeviceInformation); + if (!NT_SUCCESS(Status)) + { + EfiPrintf(L" read failed\r\n"); + return Status; + } + + /* Remember that's where we last read */ + EtfsContext->Offset = (FIRST_VD_SECTOR + 1) * CD_SECTOR_SIZE; + + /* Check if it's EL TORITO! */ + RtlInitString(&String, "EL TORITO SPECIFICATION"); + CompareString.Buffer = (PCHAR)EtVd->SystemId; + CompareString.Length = 23; + CompareString.MaximumLength = 23; + if (!RtlEqualString(&CompareString, &String, TRUE)) + { + return STATUS_UNSUCCESSFUL; + } + + /* Check the version and boot indicator */ + if ((EtVd->Version != 1) || (EtVd->BootIndicator)) + { + return STATUS_UNSUCCESSFUL; + } + + /* Check if it has the CD0001 identifier */ + RtlInitString(&String, ISO_VOL_ID); + CompareString.Buffer = (PCHAR)EtVd->StandardId; + CompareString.Length = 5; + CompareString.MaximumLength = 5; + if (!RtlEqualString(&CompareString, &String, TRUE)) + { + return STATUS_UNSUCCESSFUL; + } + + /* Step two, we now want to read the ISO Volume Descriptor */ + DeviceInformation.BlockDeviceInfo.Unknown |= 1u; + BlDeviceSetInformation(DeviceId, &DeviceInformation); + Status = BlDeviceReadAtOffset(DeviceId, + CD_SECTOR_SIZE, + FIRST_VD_SECTOR * CD_SECTOR_SIZE, + EtfsContext->MemoryBlock, + &BytesRead); + DeviceInformation.BlockDeviceInfo.Unknown = Unknown; + BlDeviceSetInformation(DeviceId, &DeviceInformation); + if (!NT_SUCCESS(Status)) + { + return Status; + } + + /* Remember where we left off */ + EtfsContext->Offset = FIRST_VD_SECTOR * CD_SECTOR_SIZE; + + /* This should also say CD0001 */ + CompareString.Buffer = (PCHAR)IsoVd->StandardId; + CompareString.Length = 5; + CompareString.MaximumLength = 5; + IsIso = RtlEqualString(&CompareString, &String, TRUE); + if (!IsIso) + { + return STATUS_UNSUCCESSFUL; + } + + /* And should be a version we support */ + if ((IsoVd->Version != VERSION_1) || (IsoVd->DescType != VD_PRIMARY)) + { + return STATUS_UNSUCCESSFUL; + } + + /* Return back to the caller */ + *VolumeDescriptor = IsoVd; + *VolumeIsIso = IsIso; + EfiPrintf(L"Recognized!!!\r\n"); + return STATUS_SUCCESS; +} + +VOID +EtfspGetDirectoryInfo ( + _In_ PBL_ETFS_CONTEXT EtfsContext, + _In_ PRAW_DIR_REC DirEntry, + _Out_ PULONG FileOffset, + _Out_ PULONG FileSize, + _Out_opt_ PBOOLEAN IsDirectory + ) +{ + ULONG SectorOffset; + BOOLEAN IsDir; + + *FileOffset = *(PULONG)DirEntry->FileLoc * EtfsContext->BlockSize; + *FileOffset += (DirEntry->XarLen * EtfsContext->BlockSize); + + SectorOffset = ALIGN_DOWN_BY(*FileOffset, CD_SECTOR_SIZE); + + *FileSize = *(PULONG)DirEntry->DataLen; + + IsDir = DE_FILE_FLAGS(EtfsContext->IsIso, DirEntry) & ISO_ATTR_DIRECTORY; + if (IsDir) + { + *FileSize += ALIGN_UP_BY(SectorOffset, CD_SECTOR_SIZE) - SectorOffset; + } + + if (IsDirectory) + { + *IsDirectory = IsDir; + } +} + +NTSTATUS +EtfspDeviceContextDestroy ( + _In_ PBL_ETFS_CONTEXT EtfsContext + ) +{ + if (EtfsContext->MemoryBlock) + { + BlMmFreeHeap(EtfsContext->MemoryBlock); + } + BlMmFreeHeap(EtfsContext); + return 0; +} + +NTSTATUS +EtfspCreateContext ( + _In_ ULONG DeviceId, + _Out_ PBL_ETFS_CONTEXT *EtfsContext + ) +{ + PBL_ETFS_CONTEXT NewContext; + PVOID MemoryBlock; + NTSTATUS Status; + BOOLEAN IsIso; + PRAW_ISO_VD RawVd; + + NewContext = (PBL_ETFS_CONTEXT)BlMmAllocateHeap(sizeof(*NewContext)); + if (!NewContext) + { + return STATUS_NO_MEMORY; + } + RtlZeroMemory(NewContext, sizeof(*NewContext)); + + MemoryBlock = BlMmAllocateHeap(CD_SECTOR_SIZE); + NewContext->MemoryBlock = MemoryBlock; + if (!MemoryBlock) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + Status = EtfspCheckEtfs(NewContext, DeviceId, &RawVd, &IsIso); + if (!NT_SUCCESS(Status)) + { + EfiPrintf(L"Drive not EDFS. Checking for CDFS: %lx\r\n"); + Status = EtfspCheckCdfs(NewContext, DeviceId, &RawVd, &IsIso); + } + + if (!NT_SUCCESS(Status)) + { + EfiPrintf(L"Drive not CDFS. Failing: %lx\r\n"); + goto Quickie; + } + + NewContext->IsIso = IsIso; + NewContext->BlockSize = RVD_LB_SIZE(RawVd, IsIso); + NewContext->VolumeSize = RVD_VOL_SIZE(RawVd, IsIso); + + EtfspGetDirectoryInfo(NewContext, + (PRAW_DIR_REC)RVD_ROOT_DE(RawVd, IsIso), + &NewContext->RootDirOffset, + &NewContext->RootDirSize, + 0); + +Quickie: + EtfspDeviceContextDestroy(NewContext); + NewContext = NULL; + + *EtfsContext = NewContext; + return Status; +} + +NTSTATUS +EtfspDeviceTableDestroyEntry ( + _In_ PBL_ETFS_CONTEXT EtfsContext, + _In_ ULONG Index + ) +{ + EtfspDeviceContextDestroy(EtfsContext); + EtfsDeviceTable[Index] = NULL; + + return STATUS_SUCCESS; +} + +NTSTATUS +EtfsMount ( + _In_ ULONG DeviceId, + _In_ ULONG Unknown, + _Out_ PBL_FILE_ENTRY* FileEntry + ) +{ + PBL_ETFS_CONTEXT EtfsContext = NULL; + PBL_FILE_ENTRY RootEntry; + NTSTATUS Status; + PBL_ETFS_FILE EtfsFile; + + EfiPrintf(L"Trying to mount as ETFS...\r\n"); + + Status = EtfspCreateContext(DeviceId, &EtfsContext); + if (!NT_SUCCESS(Status)) + { + EfiPrintf(L"ETFS context failed: %lx\r\n"); + return Status; + } + + Status = BlTblSetEntry(&EtfsDeviceTable, + &EtfsDeviceTableEntries, + EtfsContext, + &DeviceId, + TblDoNotPurgeEntry); + if (!NT_SUCCESS(Status)) + { + EtfspDeviceContextDestroy(EtfsContext); + return Status; + } + + RootEntry = BlMmAllocateHeap(sizeof(*RootEntry)); + if (!RootEntry) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + RtlZeroMemory(RootEntry, sizeof(*RootEntry)); + + RootEntry->FilePath = BlMmAllocateHeap(4); + if (!RootEntry->FilePath) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + wcsncpy(RootEntry->FilePath, L"\\", 1); + + RootEntry->DeviceId = DeviceId; + RtlCopyMemory(&RootEntry->Callbacks, + &EtfsFunctionTable, + sizeof(RootEntry->Callbacks)); + + EtfsFile = (PBL_ETFS_FILE)BlMmAllocateHeap(sizeof(*EtfsFile)); + if (!EtfsFile) + { + Status = STATUS_NO_MEMORY; + goto Quickie; + } + + RootEntry->Flags |= 0x10000; + + RtlZeroMemory(EtfsFile, sizeof(*EtfsFile)); + RootEntry->FsSpecificData = EtfsFile; + EtfsFile->DeviceId = DeviceId; + EtfsFile->Flags |= 1; + EtfsFile->Offset = EtfsContext->RootDirOffset; + EtfsFile->Unknown = 0; + EtfsFile->Size = EtfsContext->RootDirSize; + EtfsFile->FsName = L"cdfs"; + *FileEntry = RootEntry; + + return STATUS_SUCCESS; + +Quickie: + if (RootEntry->FilePath) + { + BlMmFreeHeap(RootEntry->FilePath); + } + if (RootEntry->FsSpecificData) + { + BlMmFreeHeap(RootEntry->FsSpecificData); + } + if (RootEntry) + { + BlMmFreeHeap(RootEntry); + } + + EtfspDeviceTableDestroyEntry(EtfsContext, DeviceId); + + return Status; +} + +NTSTATUS +EtfsInitialize ( + VOID + ) +{ + NTSTATUS Status; + + /* Allocate the device table with 2 entries*/ + EtfsDeviceTableEntries = 2; + EtfsDeviceTable = BlMmAllocateHeap(sizeof(PBL_FILE_ENTRY) * + EtfsDeviceTableEntries); + if (EtfsDeviceTable) + { + /* Zero it out */ + RtlZeroMemory(EtfsDeviceTable, + sizeof(PBL_FILE_ENTRY) * EtfsDeviceTableEntries); + Status = STATUS_SUCCESS; + } + else + { + /* No memory, fail */ + Status = STATUS_NO_MEMORY; + } + + /* Return back to caller */ + return Status; +} + diff --git a/reactos/boot/environ/lib/io/fat.c b/reactos/boot/environ/lib/io/fat.c index 717ac4f3cb7..28ed72925d4 100644 --- a/reactos/boot/environ/lib/io/fat.c +++ b/reactos/boot/environ/lib/io/fat.c @@ -43,7 +43,6 @@ FatMount ( BlDeviceSetInformation(DeviceId, &DeviceInformation); /* Read the boot sector */ - EfiPrintf(L"Reading fat boot sector...\r\n"); Status = BlDeviceReadAtOffset(DeviceId, sizeof(FatBootSector), 0, @@ -61,7 +60,11 @@ FatMount ( FatUnpackBios(&BiosBlock, &FatBootSector.PackedBpb); - EfiPrintf(L"Drive read\r\n"); + /* For now, quickly fail if this isn't FAT */ + if (FatBootSector.Jump[0] != 0xE9) + { + return STATUS_UNSUCCESSFUL; + } 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", FatBootSector.Jump[0], @@ -74,7 +77,6 @@ FatMount ( BiosBlock.Media, BiosBlock.RootEntries); - EfiStall(3000000); return STATUS_NOT_IMPLEMENTED; } diff --git a/reactos/boot/environ/lib/io/file.c b/reactos/boot/environ/lib/io/file.c index fcf2564dc97..62a12b7665c 100644 --- a/reactos/boot/environ/lib/io/file.c +++ b/reactos/boot/environ/lib/io/file.c @@ -23,6 +23,14 @@ BL_FILE_SYSTEM_REGISTRATION_TABLE FatRegisterFunctionTable = FatMount, NULL }; +BL_FILE_SYSTEM_REGISTRATION_TABLE EtfsRegisterFunctionTable = +{ + EtfsInitialize, + NULL, + EtfsMount, + NULL +}; + extern ULONG DmTableEntries; extern PVOID* DmDeviceTable; @@ -106,7 +114,7 @@ FileTableCompareWithSubsetAttributes ( PBL_FILE_ENTRY FileEntry = (PBL_FILE_ENTRY)Entry; ULONG DeviceId = *(PULONG)Argument1; PWCHAR FilePath = (PWCHAR)Argument2; - ULONG OpenFlags = *(PULONG)Argument3; + ULONG Flags = *(PULONG)Argument3; ULONG Unknown = *(PULONG)Argument4; BOOLEAN Found; @@ -114,9 +122,9 @@ FileTableCompareWithSubsetAttributes ( if ((FileEntry->DeviceId == DeviceId) && !(_wcsicmp(FileEntry->FilePath, FilePath)) && (FileEntry->Unknown == Unknown)) { - if ((!(OpenFlags & 1) || (FileEntry->Flags & 2)) && (!(OpenFlags & 2) || (FileEntry->Flags & 4))) + if ((!(Flags & 1) || (FileEntry->Flags & 2)) && (!(Flags & 2) || (FileEntry->Flags & 4))) { - if ((!(OpenFlags & 4) || (FileEntry->Flags & 0x10000)) && ((OpenFlags & 4) || !(FileEntry->Flags & 0x10000))) + if ((!(Flags & 4) || (FileEntry->Flags & 0x10000)) && ((Flags & 4) || !(FileEntry->Flags & 0x10000))) { Found = TRUE; } @@ -137,7 +145,7 @@ FileTableCompareWithSameAttributes ( PBL_FILE_ENTRY FileEntry = (PBL_FILE_ENTRY)Entry; ULONG DeviceId = *(PULONG)Argument1; PWCHAR FilePath = (PWCHAR)Argument2; - ULONG OpenFlags = *(PULONG)Argument3; + ULONG Flags = *(PULONG)Argument3; ULONG Unknown = *(PULONG)Argument4; BOOLEAN Found; @@ -145,9 +153,9 @@ FileTableCompareWithSameAttributes ( if ((FileEntry->DeviceId == DeviceId) && !(_wcsicmp(FileEntry->FilePath, FilePath)) && (FileEntry->Unknown == Unknown)) { - if ((!(OpenFlags & 1) || (FileEntry->Flags & 2)) && ((OpenFlags & 1) || !(FileEntry->Flags & 2)) && (!(OpenFlags & 2) || (FileEntry->Flags & 4)) && ((OpenFlags & 2) || !(FileEntry->Flags & 4))) + if ((!(Flags & 1) || (FileEntry->Flags & 2)) && ((Flags & 1) || !(FileEntry->Flags & 2)) && (!(Flags & 2) || (FileEntry->Flags & 4)) && ((Flags & 2) || !(FileEntry->Flags & 4))) { - if ((!(OpenFlags & 4) || (FileEntry->Flags & 0x10000)) && ((OpenFlags & 4) || !(FileEntry->Flags & 0x10000))) + if ((!(Flags & 4) || (FileEntry->Flags & 0x10000)) && ((Flags & 4) || !(FileEntry->Flags & 0x10000))) { Found = TRUE; } @@ -240,7 +248,7 @@ NTSTATUS FileIoOpen ( _In_ ULONG DeviceId, _In_ PWCHAR FileName, - _In_ ULONG OpenFlags, + _In_ ULONG Flags, _In_ ULONG Unknown, _In_ PBL_TBL_LOOKUP_ROUTINE CompareRoutine, _Out_ PBL_FILE_ENTRY *ReturnFileEntry @@ -256,7 +264,7 @@ FileIoOpen ( ParentDirectoryEntry = NULL; FileNameCopy = NULL; - OpenFlags |= 1; + Flags |= 1; ParentFileName = NULL; Status = STATUS_SUCCESS; @@ -271,13 +279,13 @@ FileIoOpen ( return STATUS_ACCESS_DENIED; } - if ((OpenFlags & 1) && (!(DeviceEntry->Flags & 1) || !(DeviceEntry->Flags & 2))) + if ((Flags & 1) && (!(DeviceEntry->Flags & 1) || !(DeviceEntry->Flags & 2))) { EfiPrintf(L"Access denied\r\n"); return STATUS_ACCESS_DENIED; } - if ((OpenFlags & 2) && (!(DeviceEntry->Flags & 1) || !(DeviceEntry->Flags & 4))) + if ((Flags & 2) && (!(DeviceEntry->Flags & 1) || !(DeviceEntry->Flags & 4))) { EfiPrintf(L"Access denied2\r\n"); return STATUS_ACCESS_DENIED; @@ -289,7 +297,7 @@ FileIoOpen ( CompareRoutine, &DeviceId, FileName, - &OpenFlags, + &Flags, &Unknown); if (FileEntry) { @@ -326,7 +334,7 @@ FileIoOpen ( Status = ParentDirectoryEntry->Callbacks.Open(ParentDirectoryEntry, FileNameCopy, - OpenFlags, + Flags, &FileEntry); } else @@ -350,7 +358,7 @@ FileIoOpen ( NextEntry = NextEntry->Flink; } - FileNameCopy = 0; + FileNameCopy = NULL; } if (!NT_SUCCESS(Status)) @@ -361,12 +369,12 @@ FileIoOpen ( FileEntry->Unknown = Unknown; - if (OpenFlags & 1) + if (Flags & 1) { FileEntry->Flags |= 2u; } - if (OpenFlags & 2) + if (Flags & 2) { FileEntry->Flags |= 4u; } @@ -385,6 +393,7 @@ FileIoOpen ( ++DeviceEntry->ReferenceCount; Status = STATUS_SUCCESS; + EfiPrintf(L"File %s opened with ID: %lx\r\n", FileEntry->FilePath, FileId); FileEntry->FileId = FileId; FileOpened: @@ -396,7 +405,7 @@ FileOpened: FileEntry->Flags |= 1; - if (OpenFlags & 0x10) + if (Flags & 0x10) { FileEntry->Flags |= 0x10; } @@ -426,7 +435,7 @@ NTSTATUS BlFileOpen ( _In_ ULONG DeviceId, _In_ PWCHAR FileName, - _In_ ULONG OpenFlags, + _In_ ULONG Flags, _Out_ PULONG FileId ) { @@ -437,7 +446,7 @@ BlFileOpen ( if (!(FileName) || (*FileName != OBJ_NAME_PATH_SEPARATOR) || !(FileId) || - !(OpenFlags & 3)) + !(Flags & 3)) { EfiPrintf(L"Invalid file options\r\n"); return STATUS_INVALID_PARAMETER; @@ -460,7 +469,7 @@ BlFileOpen ( Status = FileIoOpen(DeviceId, FileName, - OpenFlags, + Flags, 0, FileTableCompareWithSameAttributes, &FileEntry); @@ -597,7 +606,7 @@ BlpFileInitialize ( UdfsRegisterFunctionTable.Purge, 0); } - +#endif if (NT_SUCCESS(Status)) { /* Initialize El-Torito CDFS */ @@ -607,7 +616,6 @@ BlpFileInitialize ( EtfsRegisterFunctionTable.Purge, 0); } -#endif /* Destroy the file manager if any of the file systems didn't initialize */ if (!NT_SUCCESS(Status))