]>
git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskFileExplorer.c
3a000389f033a6595d9b4d6b7d45c9e460bf6a47
2 Internal file explorer helper functions for RamDiskDxe driver.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "RamDiskImpl.h"
13 Helper function called as part of the code needed to allocate the proper
14 sized buffer for various EFI interfaces.
16 @param[in, out] Status Current status.
17 @param[in, out] Buffer Current allocated buffer, or NULL.
18 @param[in] BufferSize Current buffer size needed.
20 @retval TRUE If the buffer was reallocated and the caller should
22 @retval FALSE The caller should not call this function again.
27 IN OUT EFI_STATUS
*Status
,
35 // If this is an initial request, buffer will be null with a new buffer size
37 if ((*Buffer
== NULL
) && (BufferSize
!= 0)) {
38 *Status
= EFI_BUFFER_TOO_SMALL
;
41 // If the status code is "buffer too small", resize the buffer
44 if (*Status
== EFI_BUFFER_TOO_SMALL
) {
46 if (*Buffer
!= NULL
) {
50 *Buffer
= AllocateZeroPool (BufferSize
);
52 if (*Buffer
!= NULL
) {
55 *Status
= EFI_OUT_OF_RESOURCES
;
59 // If there's an error, free the buffer
61 if (!TryAgain
&& EFI_ERROR (*Status
) && (*Buffer
!= NULL
)) {
71 This function gets the file information from an open file descriptor,
72 and stores it in a buffer allocated from pool.
74 @param[in] FHand File Handle.
76 @return A pointer to a buffer with file information or NULL is returned.
81 IN EFI_FILE_HANDLE FHand
85 EFI_FILE_INFO
*Buffer
;
89 // Initialize for GrowBuffer loop
92 BufferSize
= SIZE_OF_EFI_FILE_INFO
+ 200;
95 // Call the real function
97 while (GrowBuffer (&Status
, (VOID
**) &Buffer
, BufferSize
)) {
98 Status
= FHand
->GetInfo (