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