]> git.proxmox.com Git - mirror_edk2.git/blobdiff - FatPkg/EnhancedFatDxe/Info.c
BaseTools: Library hashing fix and optimization for --hash feature
[mirror_edk2.git] / FatPkg / EnhancedFatDxe / Info.c
index 2ef4e9c809f9a0fc1088ce15c62966ebe82797c6..1c9811cad0aad10a7c41a14f1e4c4164b62a6853 100644 (file)
@@ -1,29 +1,27 @@
-/*++\r
+/** @file\r
+  Routines dealing with setting/getting file/volume info\r
 \r
-Copyright (c) 2005 - 2007, Intel Corporation\r
-All rights reserved. This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
+Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
 \r
-Module Name:\r
+**/\r
 \r
-  Info.c\r
+#include "Fat.h"\r
 \r
-Abstract:\r
+/**\r
 \r
-  Routines dealing with setting/getting file/volume info\r
+  Get the volume's info into Buffer.\r
 \r
-Revision History\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing volume info.\r
 \r
---*/\r
-\r
-#include "Fat.h"\r
+  @retval EFI_SUCCESS           - Get the volume info successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
 \r
+**/\r
 EFI_STATUS\r
 FatGetVolumeInfo (\r
   IN FAT_VOLUME       *Volume,\r
@@ -31,74 +29,90 @@ FatGetVolumeInfo (
   OUT VOID            *Buffer\r
   );\r
 \r
+/**\r
+\r
+  Set the volume's info.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing the new volume info.\r
+\r
+  @retval EFI_SUCCESS           - Set the volume info successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
+  @retval EFI_WRITE_PROTECTED   - The volume is read only.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 FatSetVolumeInfo (\r
   IN FAT_VOLUME       *Volume,\r
-  IN OUT UINTN        BufferSize,\r
-  OUT VOID            *Buffer\r
+  IN UINTN            BufferSize,\r
+  IN VOID            *Buffer\r
   );\r
 \r
+/**\r
+\r
+  Set or Get the some types info of the file into Buffer.\r
+\r
+  @param  IsSet      - TRUE:The access is set, else is get\r
+  @param  FHand      - The handle of file\r
+  @param  Type       - The type of the info\r
+  @param  BufferSize - Size of Buffer\r
+  @param  Buffer     - Buffer containing volume info\r
+\r
+  @retval EFI_SUCCESS       - Get the info successfully\r
+  @retval EFI_DEVICE_ERROR  - Can not find the OFile for the file\r
+\r
+**/\r
 EFI_STATUS\r
 FatSetOrGetInfo (\r
-  IN BOOLEAN    IsSet,\r
-  IN EFI_FILE   *FHand,\r
-  IN EFI_GUID   *Type,\r
-  IN OUT UINTN  *BufferSize,\r
-  IN OUT VOID   *Buffer\r
+  IN BOOLEAN              IsSet,\r
+  IN EFI_FILE_PROTOCOL    *FHand,\r
+  IN EFI_GUID             *Type,\r
+  IN OUT UINTN            *BufferSize,\r
+  IN OUT VOID             *Buffer\r
   );\r
 \r
+/**\r
+\r
+  Get the open file's info into Buffer.\r
+\r
+  @param  OFile                 - The open file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing file info.\r
+\r
+  @retval EFI_SUCCESS           - Get the file info successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
+\r
+**/\r
 EFI_STATUS\r
 FatGetFileInfo (\r
   IN FAT_OFILE        *OFile,\r
   IN OUT UINTN        *BufferSize,\r
   OUT VOID            *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the open file's info into Buffer.\r
-\r
-Arguments:\r
+{\r
+  return FatGetDirEntInfo (OFile->Volume, OFile->DirEnt, BufferSize, Buffer);\r
+}\r
 \r
-  OFile                 - The open file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing file info.\r
+/**\r
 \r
-Returns:\r
+  Get the volume's info into Buffer.\r
 \r
-  EFI_SUCCESS           - Get the file info successfully.\r
-  EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing volume info.\r
 \r
---*/\r
-{\r
-  return FatGetDirEntInfo (OFile->Volume, OFile->DirEnt, BufferSize, Buffer);\r
-}\r
+  @retval EFI_SUCCESS           - Get the volume info successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
 \r
+**/\r
 EFI_STATUS\r
 FatGetVolumeInfo (\r
   IN     FAT_VOLUME     *Volume,\r
   IN OUT UINTN          *BufferSize,\r
      OUT VOID           *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the volume's info into Buffer.\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing volume info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the volume info successfully.\r
-  EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
-\r
---*/\r
 {\r
   UINTN                 Size;\r
   UINTN                 NameSize;\r
@@ -141,30 +155,24 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Get the volume's label info into Buffer.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing volume's label info.\r
+\r
+  @retval EFI_SUCCESS           - Get the volume's label info successfully.\r
+  @retval EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
+\r
+**/\r
 EFI_STATUS\r
 FatGetVolumeLabelInfo (\r
   IN FAT_VOLUME       *Volume,\r
   IN OUT UINTN        *BufferSize,\r
   OUT VOID            *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the volume's label info into Buffer.\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing volume's label info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the volume's label info successfully.\r
-  EFI_BUFFER_TOO_SMALL  - The buffer is too small.\r
-\r
---*/\r
 {\r
   UINTN                             Size;\r
   UINTN                             NameSize;\r
@@ -172,7 +180,7 @@ Returns:
   CHAR16                            Name[FAT_NAME_LEN + 1];\r
   EFI_STATUS                        Status;\r
 \r
-  Size        = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO;\r
+  Size        = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL;\r
   Status      = FatGetVolumeEntry (Volume, Name);\r
   NameSize    = StrSize (Name);\r
   ResultSize  = Size + NameSize;\r
@@ -187,32 +195,26 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Set the volume's info.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing the new volume info.\r
+\r
+  @retval EFI_SUCCESS           - Set the volume info successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
+  @retval EFI_WRITE_PROTECTED   - The volume is read only.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 FatSetVolumeInfo (\r
   IN FAT_VOLUME       *Volume,\r
   IN UINTN            BufferSize,\r
   IN VOID             *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set the volume's info.\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing the new volume info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Set the volume info successfully.\r
-  EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
-  EFI_WRITE_PROTECTED   - The volume is read only.\r
-  other                 - An error occurred when operation the disk.\r
-\r
---*/\r
 {\r
   EFI_FILE_SYSTEM_INFO  *Info;\r
 \r
@@ -225,44 +227,62 @@ Returns:
   return FatSetVolumeEntry (Volume, Info->VolumeLabel);\r
 }\r
 \r
+/**\r
+\r
+  Set the volume's label info.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing the new volume label info.\r
+\r
+  @retval EFI_SUCCESS           - Set the volume label info successfully.\r
+  @retval EFI_WRITE_PROTECTED   - The disk is write protected.\r
+  @retval EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 FatSetVolumeLabelInfo (\r
   IN FAT_VOLUME       *Volume,\r
   IN UINTN            BufferSize,\r
   IN VOID             *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set the volume's label info\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing the new volume label info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Set the volume label info successfully.\r
-  EFI_WRITE_PROTECTED   - The disk is write protected.\r
-  EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
-  other                 - An error occurred when operation the disk.\r
-\r
---*/\r
 {\r
-  EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *Info;\r
+  EFI_FILE_SYSTEM_VOLUME_LABEL *Info;\r
 \r
-  Info = (EFI_FILE_SYSTEM_VOLUME_LABEL_INFO *) Buffer;\r
+  Info = (EFI_FILE_SYSTEM_VOLUME_LABEL *) Buffer;\r
 \r
-  if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO + 2) {\r
+  if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL + 2) {\r
     return EFI_BAD_BUFFER_SIZE;\r
   }\r
 \r
   return FatSetVolumeEntry (Volume, Info->VolumeLabel);\r
 }\r
 \r
+/**\r
+\r
+  Set the file info.\r
+\r
+  @param  Volume                - FAT file system volume.\r
+  @param  IFile                 - The instance of the open file.\r
+  @param  OFile                 - The open file.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing the new file info.\r
+\r
+  @retval EFI_SUCCESS           - Set the file info successfully.\r
+  @retval EFI_ACCESS_DENIED     - It is the root directory\r
+                          or the directory attribute bit can not change\r
+                          or try to change a directory size\r
+                          or something else.\r
+  @retval EFI_UNSUPPORTED       - The new file size is larger than 4GB.\r
+  @retval EFI_WRITE_PROTECTED   - The disk is write protected.\r
+  @retval EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
+  @retval EFI_INVALID_PARAMETER - The time info or attributes info is error.\r
+  @retval EFI_OUT_OF_RESOURCES  - Can not allocate new memory.\r
+  @retval EFI_VOLUME_CORRUPTED  - The volume is corrupted.\r
+  @return other                 - An error occurred when operation the disk.\r
+\r
+**/\r
 EFI_STATUS\r
 FatSetFileInfo (\r
   IN FAT_VOLUME       *Volume,\r
@@ -271,36 +291,6 @@ FatSetFileInfo (
   IN UINTN            BufferSize,\r
   IN VOID             *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set the file info.\r
-\r
-Arguments:\r
-\r
-  Volume                - FAT file system volume.\r
-  IFile                 - The instance of the open file.\r
-  OFile                 - The open file.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing the new file info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Set the file info successfully.\r
-  EFI_ACCESS_DENIED     - It is the root directory\r
-                          or the directory attribute bit can not change\r
-                          or try to change a directory size\r
-                          or something else.\r
-  EFI_UNSUPPORTED       - The new file size is larger than 4GB.\r
-  EFI_WRITE_PROTECTED   - The disk is write protected.\r
-  EFI_BAD_BUFFER_SIZE   - The buffer size is error.\r
-  EFI_INVALID_PARAMETER - The time info or attributes info is error.\r
-  EFI_OUT_OF_RESOURCES  - Can not allocate new memory.\r
-  EFI_VOLUME_CORRUPTED  - The volume is corrupted.\r
-  other                 - An error occurred when operation the disk.\r
-\r
---*/\r
 {\r
   EFI_STATUS    Status;\r
   EFI_FILE_INFO *NewInfo;\r
@@ -472,34 +462,28 @@ Returns:
   return FatOFileFlush (OFile);\r
 }\r
 \r
-EFI_STATUS\r
-FatSetOrGetInfo (\r
-  IN     BOOLEAN        IsSet,\r
-  IN     EFI_FILE       *FHand,\r
-  IN     EFI_GUID       *Type,\r
-  IN OUT UINTN          *BufferSize,\r
-  IN OUT VOID           *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
-  Set or Get the some types info of the file into Buffer\r
+  Set or Get the some types info of the file into Buffer.\r
 \r
-Arguments:\r
+  @param  IsSet      - TRUE:The access is set, else is get\r
+  @param  FHand      - The handle of file\r
+  @param  Type       - The type of the info\r
+  @param  BufferSize - Size of Buffer\r
+  @param  Buffer     - Buffer containing volume info\r
 \r
-  IsSet      - TRUE:The access is set, else is get\r
-  FHand      - The handle of file\r
-  Type       - The type of the info\r
-  BufferSize - Size of Buffer\r
-  Buffer     - Buffer containing volume info\r
+  @retval EFI_SUCCESS       - Get the info successfully\r
+  @retval EFI_DEVICE_ERROR  - Can not find the OFile for the file\r
 \r
-Returns:\r
-\r
-  EFI_SUCCESS       - Get the info successfully\r
-  EFI_DEVICE_ERROR  - Can not find the OFile for the file\r
-\r
---*/\r
+**/\r
+EFI_STATUS\r
+FatSetOrGetInfo (\r
+  IN     BOOLEAN            IsSet,\r
+  IN     EFI_FILE_PROTOCOL  *FHand,\r
+  IN     EFI_GUID           *Type,\r
+  IN OUT UINTN              *BufferSize,\r
+  IN OUT VOID               *Buffer\r
+  )\r
 {\r
   FAT_IFILE   *IFile;\r
   FAT_OFILE   *OFile;\r
@@ -515,6 +499,8 @@ Returns:
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  FatWaitNonblockingTask (IFile);\r
+\r
   FatAcquireLock ();\r
 \r
   //\r
@@ -526,20 +512,16 @@ Returns:
     //\r
     Status = EFI_UNSUPPORTED;\r
     if (IsSet) {\r
-      if (Volume->ReadOnly) {\r
-        Status = EFI_WRITE_PROTECTED;\r
-      } else {\r
-        if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
-          Status = FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r
+      }\r
 \r
-        if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r
-          Status = FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r
+      }\r
 \r
-        if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
-          Status = FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r
-        }\r
+      if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r
+        Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r
       }\r
     } else {\r
       if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r
@@ -556,70 +538,58 @@ Returns:
     }\r
   }\r
 \r
-  Status = FatCleanupVolume (Volume, NULL, Status);\r
+  Status = FatCleanupVolume (Volume, NULL, Status, NULL);\r
 \r
   FatReleaseLock ();\r
   return Status;\r
 }\r
 \r
-EFI_STATUS\r
-EFIAPI\r
-FatGetInfo (\r
-  IN     EFI_FILE       *FHand,\r
-  IN     EFI_GUID       *Type,\r
-  IN OUT UINTN          *BufferSize,\r
-     OUT VOID           *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Get the some types info of the file into Buffer.\r
 \r
-Arguments:\r
+  @param  FHand                 - The handle of file.\r
+  @param  Type                  - The type of the info.\r
+  @param  BufferSize            - Size of Buffer.\r
+  @param  Buffer                - Buffer containing volume info.\r
 \r
-  FHand                 - The handle of file.\r
-  Type                  - The type of the info.\r
-  BufferSize            - Size of Buffer.\r
-  Buffer                - Buffer containing volume info.\r
-\r
-Returns:\r
-\r
-  EFI_SUCCESS           - Get the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-\r
---*/\r
-{\r
-  return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r
-}\r
+  @retval EFI_SUCCESS           - Get the info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
-FatSetInfo (\r
-  IN EFI_FILE  *FHand,\r
-  IN EFI_GUID  *Type,\r
-  IN UINTN     BufferSize,\r
-  IN VOID      *Buffer\r
+FatGetInfo (\r
+  IN     EFI_FILE_PROTOCOL   *FHand,\r
+  IN     EFI_GUID            *Type,\r
+  IN OUT UINTN               *BufferSize,\r
+     OUT VOID                *Buffer\r
   )\r
-/*++\r
+{\r
+  return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r
+}\r
 \r
-Routine Description:\r
+/**\r
 \r
   Set the some types info of the file into Buffer.\r
 \r
-Arguments:\r
-\r
-  FHand                 - The handle of file.\r
-  Type                  - The type of the info.\r
-  BufferSize            - Size of Buffer\r
-  Buffer                - Buffer containing volume info.\r
-\r
-Returns:\r
+  @param  FHand                 - The handle of file.\r
+  @param  Type                  - The type of the info.\r
+  @param  BufferSize            - Size of Buffer\r
+  @param  Buffer                - Buffer containing volume info.\r
 \r
-  EFI_SUCCESS           - Set the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
+  @retval EFI_SUCCESS           - Set the info successfully.\r
+  @retval EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
 \r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FatSetInfo (\r
+  IN EFI_FILE_PROTOCOL  *FHand,\r
+  IN EFI_GUID           *Type,\r
+  IN UINTN              BufferSize,\r
+  IN VOID               *Buffer\r
+  )\r
 {\r
   return FatSetOrGetInfo (TRUE, FHand, Type, &BufferSize, Buffer);\r
 }\r