OpenVolume.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*++
  2. Copyright (c) 2005, Intel Corporation
  3. All rights reserved. This program and the accompanying materials are licensed and made available
  4. under the terms and conditions of the BSD License which accompanies this
  5. distribution. The full text of the license may be found at
  6. http://opensource.org/licenses/bsd-license.php
  7. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  9. Module Name:
  10. OpenVolume.c
  11. Abstract:
  12. OpenVolume() function of Simple File System Protocol
  13. Revision History
  14. --*/
  15. #include "Fat.h"
  16. EFI_STATUS
  17. EFIAPI
  18. FatOpenVolume (
  19. IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
  20. OUT EFI_FILE **File
  21. )
  22. /*++
  23. Routine Description:
  24. Implements Simple File System Protocol interface function OpenVolume().
  25. Arguments:
  26. This - Calling context.
  27. File - the Root Directory of the volume.
  28. Returns:
  29. EFI_OUT_OF_RESOURCES - Can not allocate the memory.
  30. EFI_VOLUME_CORRUPTED - The FAT type is error.
  31. EFI_SUCCESS - Open the volume successfully.
  32. --*/
  33. {
  34. EFI_STATUS Status;
  35. FAT_VOLUME *Volume;
  36. FAT_IFILE *IFile;
  37. Volume = VOLUME_FROM_VOL_INTERFACE (This);
  38. FatAcquireLock ();
  39. //
  40. // Open Root file
  41. //
  42. Status = FatOpenDirEnt (NULL, &Volume->RootDirEnt);
  43. if (EFI_ERROR (Status)) {
  44. goto Done;
  45. }
  46. //
  47. // Open a new instance to the root
  48. //
  49. Status = FatAllocateIFile (Volume->Root, &IFile);
  50. if (!EFI_ERROR (Status)) {
  51. *File = &IFile->Handle;
  52. }
  53. Done:
  54. Status = FatCleanupVolume (Volume, Volume->Root, Status);
  55. FatReleaseLock ();
  56. return Status;
  57. }