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