OpenVolume.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /** @file
  2. OpenVolume() function of Simple File System Protocol.
  3. Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include "Fat.h"
  7. /**
  8. Implements Simple File System Protocol interface function OpenVolume().
  9. @param This - Calling context.
  10. @param File - the Root Directory of the volume.
  11. @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
  12. @retval EFI_VOLUME_CORRUPTED - The FAT type is error.
  13. @retval EFI_SUCCESS - Open the volume successfully.
  14. **/
  15. EFI_STATUS
  16. EFIAPI
  17. FatOpenVolume (
  18. IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
  19. OUT EFI_FILE_PROTOCOL **File
  20. )
  21. {
  22. EFI_STATUS Status;
  23. FAT_VOLUME *Volume;
  24. FAT_IFILE *IFile;
  25. Volume = VOLUME_FROM_VOL_INTERFACE (This);
  26. FatAcquireLock ();
  27. //
  28. // Open Root file
  29. //
  30. Status = FatOpenDirEnt (NULL, &Volume->RootDirEnt);
  31. if (EFI_ERROR (Status)) {
  32. goto Done;
  33. }
  34. //
  35. // Open a new instance to the root
  36. //
  37. Status = FatAllocateIFile (Volume->Root, &IFile);
  38. if (!EFI_ERROR (Status)) {
  39. *File = &IFile->Handle;
  40. }
  41. Done:
  42. Status = FatCleanupVolume (Volume, Volume->Root, Status, NULL);
  43. FatReleaseLock ();
  44. return Status;
  45. }