/* Create an Open instance for the existing OFile. The IFile of the newly opened file is passed out. */
EFI_STATUS FatAllocateIFile(IN FAT_OFILE *OFile, OUT FAT_IFILE **PtrIFile)
/* Create an Open instance for the existing OFile. The IFile of the newly opened file is passed out. */
EFI_STATUS FatAllocateIFile(IN FAT_OFILE *OFile, OUT FAT_IFILE **PtrIFile)
{
  FAT_IFILE  *IFile;
  ASSERT_VOLUME_LOCKED (OFile->Volume);
  IFile = AllocateZeroPool (sizeof (FAT_IFILE));
  if (IFile == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }
  IFile->Signature = FAT_IFILE_SIGNATURE;
  CopyMem (&(IFile->Handle), &FatFileInterface, sizeof (EFI_FILE_PROTOCOL));
  if (OFile->Volume->DiskIo2 != NULL) {
    IFile->Handle.Revision = EFI_FILE_PROTOCOL_REVISION2;
  } else {
    IFile->Handle.Revision = EFI_FILE_PROTOCOL_REVISION;
  }
  IFile->OFile = OFile;
  InsertTailList (&OFile->Opens, &IFile->Link);
  InitializeListHead (&IFile->Tasks);
  *PtrIFile = IFile;
  return EFI_SUCCESS;
}