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