]> 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 ae85cce85976096ce3300142275485572e2d8040..1c9811cad0aad10a7c41a14f1e4c4164b62a6853 100644 (file)
@@ -1,29 +1,27 @@
-/*++\r
+/** @file\r
+  Routines dealing with setting/getting file/volume info\r
 \r
-Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r
-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,13 +29,41 @@ 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
@@ -47,58 +73,46 @@ FatSetOrGetInfo (
   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
@@ -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,32 +227,26 @@ 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;\r
 \r
@@ -263,6 +259,30 @@ Returns:
   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,6 +462,20 @@ Returns:
   return FatOFileFlush (OFile);\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
@@ -480,26 +484,6 @@ FatSetOrGetInfo (
   IN OUT UINTN              *BufferSize,\r
   IN OUT VOID               *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Set or Get the some types info of the file into Buffer\r
-\r
-Arguments:\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
-\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
   FAT_IFILE   *IFile;\r
   FAT_OFILE   *OFile;\r
@@ -528,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
@@ -564,6 +544,19 @@ Returns:
   return Status;\r
 }\r
 \r
+/**\r
+\r
+  Get the some types info of the file into Buffer.\r
+\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
 EFIAPI\r
 FatGetInfo (\r
@@ -572,29 +565,23 @@ FatGetInfo (
   IN OUT UINTN               *BufferSize,\r
      OUT VOID                *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Get the some types info of the file into Buffer.\r
-\r
-Arguments:\r
+{\r
+  return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r
+}\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
 \r
-Returns:\r
+  Set the some types info of the file into Buffer.\r
 \r
-  EFI_SUCCESS           - Get the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\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
---*/\r
-{\r
-  return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r
-}\r
+  @retval EFI_SUCCESS           - Set 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
@@ -603,25 +590,6 @@ FatSetInfo (
   IN UINTN              BufferSize,\r
   IN VOID               *Buffer\r
   )\r
-/*++\r
-\r
-Routine Description:\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
-\r
-  EFI_SUCCESS           - Set the info successfully.\r
-  EFI_DEVICE_ERROR      - Can not find the OFile for the file.\r
-\r
---*/\r
 {\r
   return FatSetOrGetInfo (TRUE, FHand, Type, &BufferSize, Buffer);\r
 }\r