//\r
// DiskCache.c\r
//\r
+/**\r
+\r
+ Initialize the disk cache according to Volume's FatType.\r
+\r
+ @param Volume - FAT file system volume.\r
+\r
+ @retval EFI_SUCCESS - The disk cache is successfully initialized.\r
+ @retval EFI_OUT_OF_RESOURCES - Not enough memory to allocate disk cache.\r
+\r
+**/\r
EFI_STATUS\r
FatInitializeDiskCache (\r
IN FAT_VOLUME *Volume\r
);\r
\r
+/**\r
+\r
+ Read BufferSize bytes from the position of Offset into Buffer,\r
+ or write BufferSize bytes from Buffer into the position of Offset.\r
+\r
+ Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into\r
+ the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):\r
+\r
+ 1. Access of FAT cache (CACHE_FAT): Access the data in the FAT cache, if there is cache\r
+ page hit, just return the cache page; else update the related cache page and return\r
+ the right cache page.\r
+ 2. Access of Data cache (CACHE_DATA):\r
+ The access data will be divided into UnderRun data, Aligned data and OverRun data;\r
+ The UnderRun data and OverRun data will be accessed by the Data cache,\r
+ but the Aligned data will be accessed with disk directly.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param CacheDataType - The type of cache: CACHE_DATA or CACHE_FAT.\r
+ @param IoMode - Indicate the type of disk access.\r
+ @param Offset - The starting byte offset to read from.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing cache data.\r
+ @param Task point to task instance.\r
+\r
+ @retval EFI_SUCCESS - The data was accessed correctly.\r
+ @retval EFI_MEDIA_CHANGED - The MediaId does not match the current device.\r
+ @return Others - An error occurred when accessing cache.\r
+\r
+**/\r
EFI_STATUS\r
FatAccessCache (\r
IN FAT_VOLUME *Volume,\r
IN FAT_TASK *Task\r
);\r
\r
+/**\r
+\r
+ Flush all the dirty cache back, include the FAT cache and the Data cache.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Task point to task instance.\r
+\r
+ @retval EFI_SUCCESS - Flush all the dirty cache back successfully\r
+ @return other - An error occurred when writing the data into the disk\r
+\r
+**/\r
EFI_STATUS\r
FatVolumeFlushCache (\r
IN FAT_VOLUME *Volume,\r
//\r
// Flush.c\r
//\r
+/**\r
+\r
+ Flush the data associated with an open file.\r
+ In this implementation, only last Mod/Access time is updated.\r
+\r
+ @param OFile - The open file.\r
+\r
+ @retval EFI_SUCCESS - The OFile is flushed successfully.\r
+ @return Others - An error occurred when flushing this OFile.\r
+\r
+**/\r
EFI_STATUS\r
FatOFileFlush (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Check the references of the OFile.\r
+ If the OFile (that is checked) is no longer\r
+ referenced, then it is freed.\r
+\r
+ @param OFile - The OFile to be checked.\r
+\r
+ @retval TRUE - The OFile is not referenced and freed.\r
+ @retval FALSE - The OFile is kept.\r
+\r
+**/\r
BOOLEAN\r
FatCheckOFileRef (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Set the OFile and its child OFile with the error Status\r
+\r
+ @param OFile - The OFile whose permanent error code is to be set.\r
+ @param Status - Error code to be set.\r
+\r
+**/\r
VOID\r
FatSetVolumeError (\r
IN FAT_OFILE *OFile,\r
IN EFI_STATUS Status\r
);\r
\r
+/**\r
+\r
+ Close the open file instance.\r
+\r
+ @param IFile - Open file instance.\r
+\r
+ @retval EFI_SUCCESS - Closed the file successfully.\r
+\r
+**/\r
EFI_STATUS\r
FatIFileClose (\r
FAT_IFILE *IFile\r
);\r
\r
+/**\r
+\r
+ Set error status for a specific OFile, reference checking the volume.\r
+ If volume is already marked as invalid, and all resources are freed\r
+ after reference checking, the file system protocol is uninstalled and\r
+ the volume structure is freed.\r
+\r
+ @param Volume - the Volume that is to be reference checked and unlocked.\r
+ @param OFile - the OFile whose permanent error code is to be set.\r
+ @param EfiStatus - error code to be set.\r
+ @param Task point to task instance.\r
+\r
+ @retval EFI_SUCCESS - Clean up the volume successfully.\r
+ @return Others - Cleaning up of the volume is failed.\r
+\r
+**/\r
EFI_STATUS\r
FatCleanupVolume (\r
IN FAT_VOLUME *Volume,\r
//\r
// FileSpace.c\r
//\r
+/**\r
+\r
+ Shrink the end of the open file base on the file size.\r
+\r
+ @param OFile - The open file.\r
+\r
+ @retval EFI_SUCCESS - Shrinked sucessfully.\r
+ @retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r
+\r
+**/\r
EFI_STATUS\r
FatShrinkEof (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Grow the end of the open file base on the NewSizeInBytes.\r
+\r
+ @param OFile - The open file.\r
+ @param NewSizeInBytes - The new size in bytes of the open file.\r
+\r
+ @retval EFI_SUCCESS - The file is grown sucessfully.\r
+ @retval EFI_UNSUPPORTED - The file size is larger than 4GB.\r
+ @retval EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.\r
+ @retval EFI_VOLUME_FULL - The volume is full and can not grow the file.\r
+\r
+**/\r
EFI_STATUS\r
FatGrowEof (\r
IN FAT_OFILE *OFile,\r
IN UINT64 NewSizeInBytes\r
);\r
\r
+/**\r
+\r
+ Get the size of directory of the open file.\r
+\r
+ @param Volume - The File System Volume.\r
+ @param Cluster - The Starting cluster.\r
+\r
+ @return The physical size of the file starting at the input cluster, if there is error in the\r
+ cluster chain, the return value is 0.\r
+\r
+**/\r
UINTN\r
FatPhysicalDirSize (\r
IN FAT_VOLUME *Volume,\r
IN UINTN Cluster\r
);\r
\r
+/**\r
+\r
+ Get the physical size of a file on the disk.\r
+\r
+ @param Volume - The file system volume.\r
+ @param RealSize - The real size of a file.\r
+\r
+ @return The physical size of a file on the disk.\r
+\r
+**/\r
UINT64\r
FatPhysicalFileSize (\r
IN FAT_VOLUME *Volume,\r
IN UINTN RealSize\r
);\r
\r
+/**\r
+\r
+ Seek OFile to requested position, and calculate the number of\r
+ consecutive clusters from the position in the file\r
+\r
+ @param OFile - The open file.\r
+ @param Position - The file's position which will be accessed.\r
+ @param PosLimit - The maximum length current reading/writing may access\r
+\r
+ @retval EFI_SUCCESS - Set the info successfully.\r
+ @retval EFI_VOLUME_CORRUPTED - Cluster chain corrupt.\r
+\r
+**/\r
EFI_STATUS\r
FatOFilePosition (\r
IN FAT_OFILE *OFile,\r
IN UINTN PosLimit\r
);\r
\r
+/**\r
+\r
+ Update the free cluster info of FatInfoSector of the volume.\r
+\r
+ @param Volume - FAT file system volume.\r
+\r
+**/\r
VOID\r
FatComputeFreeInfo (\r
IN FAT_VOLUME *Volume\r
//\r
// Init.c\r
//\r
+/**\r
+\r
+ Allocates volume structure, detects FAT file system, installs protocol,\r
+ and initialize cache.\r
+\r
+ @param Handle - The handle of parent device.\r
+ @param DiskIo - The DiskIo of parent device.\r
+ @param DiskIo2 - The DiskIo2 of parent device.\r
+ @param BlockIo - The BlockIo of parent devicel\r
+\r
+ @retval EFI_SUCCESS - Allocate a new volume successfully.\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r
+ @return Others - Allocating a new volume failed.\r
+\r
+**/\r
EFI_STATUS\r
FatAllocateVolume (\r
IN EFI_HANDLE Handle,\r
IN EFI_BLOCK_IO_PROTOCOL *BlockIo\r
);\r
\r
+/**\r
+\r
+ Detects FAT file system on Disk and set relevant fields of Volume.\r
+\r
+ @param Volume - The volume structure.\r
+\r
+ @retval EFI_SUCCESS - The Fat File System is detected successfully\r
+ @retval EFI_UNSUPPORTED - The volume is not FAT file system.\r
+ @retval EFI_VOLUME_CORRUPTED - The volume is corrupted.\r
+\r
+**/\r
EFI_STATUS\r
FatOpenDevice (\r
IN OUT FAT_VOLUME *Volume\r
);\r
\r
+/**\r
+\r
+ Called by FatDriverBindingStop(), Abandon the volume.\r
+\r
+ @param Volume - The volume to be abandoned.\r
+\r
+ @retval EFI_SUCCESS - Abandoned the volume successfully.\r
+ @return Others - Can not uninstall the protocol interfaces.\r
+\r
+**/\r
EFI_STATUS\r
FatAbandonVolume (\r
IN FAT_VOLUME *Volume\r
//\r
// Misc.c\r
//\r
+/**\r
+\r
+ Create the task\r
+\r
+ @param IFile - The instance of the open file.\r
+ @param Token - A pointer to the token associated with the transaction.\r
+\r
+ @return FAT_TASK * - Return the task instance.\r
+\r
+**/\r
FAT_TASK *\r
FatCreateTask (\r
FAT_IFILE *IFile,\r
EFI_FILE_IO_TOKEN *Token\r
);\r
\r
+/**\r
+\r
+ Destroy the task.\r
+\r
+ @param Task - The task to be destroyed.\r
+\r
+**/\r
VOID\r
FatDestroyTask (\r
FAT_TASK *Task\r
);\r
\r
+/**\r
+\r
+ Wait all non-blocking requests complete.\r
+\r
+ @param IFile - The instance of the open file.\r
+\r
+**/\r
VOID\r
FatWaitNonblockingTask (\r
FAT_IFILE *IFile\r
);\r
\r
+/**\r
+\r
+ Remove the subtask from subtask list.\r
+\r
+ @param Subtask - The subtask to be removed.\r
+\r
+ @return LIST_ENTRY * - The next node in the list.\r
+\r
+**/\r
LIST_ENTRY *\r
FatDestroySubtask (\r
FAT_SUBTASK *Subtask\r
);\r
\r
+/**\r
+\r
+ Execute the task.\r
+\r
+ @param IFile - The instance of the open file.\r
+ @param Task - The task to be executed.\r
+\r
+ @retval EFI_SUCCESS - The task was executed sucessfully.\r
+ @return other - An error occurred when executing the task.\r
+\r
+**/\r
EFI_STATUS\r
FatQueueTask (\r
IN FAT_IFILE *IFile,\r
IN FAT_TASK *Task\r
);\r
\r
+/**\r
+\r
+ Set the volume as dirty or not.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param IoMode - The access mode.\r
+ @param DirtyValue - Set the volume as dirty or not.\r
+\r
+ @retval EFI_SUCCESS - Set the new FAT entry value sucessfully.\r
+ @return other - An error occurred when operation the FAT entries.\r
+\r
+**/\r
EFI_STATUS\r
FatAccessVolumeDirty (\r
IN FAT_VOLUME *Volume,\r
IN VOID *DirtyValue\r
);\r
\r
+/**\r
+\r
+ General disk access function.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param IoMode - The access mode (disk read/write or cache access).\r
+ @param Offset - The starting byte offset to read from.\r
+ @param BufferSize - Size of Buffer.\r
+ @param Buffer - Buffer containing read data.\r
+ @param Task point to task instance.\r
+\r
+ @retval EFI_SUCCESS - The operation is performed successfully.\r
+ @retval EFI_VOLUME_CORRUPTED - The accesss is\r
+ @return Others - The status of read/write the disk\r
+\r
+**/\r
EFI_STATUS\r
FatDiskIo (\r
IN FAT_VOLUME *Volume,\r
IN FAT_TASK *Task\r
);\r
\r
+/**\r
+\r
+ Lock the volume.\r
+\r
+**/\r
VOID\r
FatAcquireLock (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Unlock the volume.\r
+\r
+**/\r
VOID\r
FatReleaseLock (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Lock the volume.\r
+ If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r
+ Otherwise, EFI_SUCCESS is returned.\r
+\r
+ @retval EFI_SUCCESS - The volume is locked.\r
+ @retval EFI_ACCESS_DENIED - The volume could not be locked because it is already locked.\r
+\r
+**/\r
EFI_STATUS\r
FatAcquireLockOrFail (\r
VOID\r
);\r
\r
+/**\r
+\r
+ Free directory entry.\r
+\r
+ @param DirEnt - The directory entry to be freed.\r
+\r
+**/\r
VOID\r
FatFreeDirEnt (\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Free volume structure (including the contents of directory cache and disk cache).\r
+\r
+ @param Volume - The volume structure to be freed.\r
+\r
+**/\r
VOID\r
FatFreeVolume (\r
IN FAT_VOLUME *Volume\r
);\r
\r
+/**\r
+\r
+ Translate EFI time to FAT time.\r
+\r
+ @param ETime - The time of EFI_TIME.\r
+ @param FTime - The time of FAT_DATE_TIME.\r
+\r
+**/\r
VOID\r
FatEfiTimeToFatTime (\r
IN EFI_TIME *ETime,\r
OUT FAT_DATE_TIME *FTime\r
);\r
\r
+/**\r
+\r
+ Translate Fat time to EFI time.\r
+\r
+ @param FTime - The time of FAT_DATE_TIME.\r
+ @param ETime - The time of EFI_TIME..\r
+\r
+**/\r
VOID\r
FatFatTimeToEfiTime (\r
IN FAT_DATE_TIME *FTime,\r
OUT EFI_TIME *ETime\r
);\r
\r
+/**\r
+\r
+ Get Current FAT time.\r
+\r
+ @param FatTime - Current FAT time.\r
+\r
+**/\r
VOID\r
FatGetCurrentFatTime (\r
OUT FAT_DATE_TIME *FatTime\r
);\r
\r
+/**\r
+\r
+ Check whether a time is valid.\r
+\r
+ @param Time - The time of EFI_TIME.\r
+\r
+ @retval TRUE - The time is valid.\r
+ @retval FALSE - The time is not valid.\r
+\r
+**/\r
BOOLEAN\r
FatIsValidTime (\r
IN EFI_TIME *Time\r
//\r
// UnicodeCollation.c\r
//\r
+/**\r
+ Initialize Unicode Collation support.\r
+\r
+ It tries to locate Unicode Collation 2 protocol and matches it with current\r
+ platform language code. If for any reason the first attempt fails, it then tries to\r
+ use Unicode Collation Protocol.\r
+\r
+ @param AgentHandle The handle used to open Unicode Collation (2) protocol.\r
+\r
+ @retval EFI_SUCCESS The Unicode Collation (2) protocol has been successfully located.\r
+ @retval Others The Unicode Collation (2) protocol has not been located.\r
+\r
+**/\r
EFI_STATUS\r
InitializeUnicodeCollationSupport (\r
IN EFI_HANDLE AgentHandle\r
);\r
\r
+/**\r
+ Convert FAT string to unicode string.\r
+\r
+ @param FatSize The size of FAT string.\r
+ @param Fat The FAT string.\r
+ @param String The unicode string.\r
+\r
+ @return None.\r
+\r
+**/\r
VOID\r
FatFatToStr (\r
IN UINTN FatSize,\r
OUT CHAR16 *String\r
);\r
\r
+/**\r
+ Convert unicode string to Fat string.\r
+\r
+ @param String The unicode string.\r
+ @param FatSize The size of the FAT string.\r
+ @param Fat The FAT string.\r
+\r
+ @retval TRUE Convert successfully.\r
+ @retval FALSE Convert error.\r
+\r
+**/\r
BOOLEAN\r
FatStrToFat (\r
IN CHAR16 *String,\r
OUT CHAR8 *Fat\r
);\r
\r
+/**\r
+ Lowercase a string\r
+\r
+ @param Str The string which will be lower-cased.\r
+\r
+**/\r
VOID\r
FatStrLwr (\r
IN CHAR16 *Str\r
);\r
\r
+/**\r
+ Uppercase a string.\r
+\r
+ @param Str The string which will be upper-cased.\r
+\r
+**/\r
VOID\r
FatStrUpr (\r
IN CHAR16 *Str\r
);\r
\r
+/**\r
+ Performs a case-insensitive comparison of two Null-terminated Unicode strings.\r
+\r
+ @param Str1 A pointer to a Null-terminated Unicode string.\r
+ @param Str2 A pointer to a Null-terminated Unicode string.\r
+\r
+ @retval 0 S1 is equivalent to S2.\r
+ @retval >0 S1 is lexically greater than S2.\r
+ @retval <0 S1 is lexically less than S2.\r
+**/\r
INTN\r
FatStriCmp (\r
IN CHAR16 *Str1,\r
//\r
// Open.c\r
//\r
+\r
+/**\r
+\r
+ Open a file for a file name relative to an existing OFile.\r
+ The IFile of the newly opened file is passed out.\r
+\r
+ @param OFile - The file that serves as a starting reference point.\r
+ @param NewIFile - The newly generated IFile instance.\r
+ @param FileName - The file name relative to the OFile.\r
+ @param OpenMode - Open mode.\r
+ @param Attributes - Attributes to set if the file is created.\r
+\r
+\r
+ @retval EFI_SUCCESS - Open the file successfully.\r
+ @retval EFI_INVALID_PARAMETER - The open mode is conflict with the attributes\r
+ or the file name is not valid.\r
+ @retval EFI_NOT_FOUND - Conficts between dir intention and attribute.\r
+ @retval EFI_WRITE_PROTECTED - Can't open for write if the volume is read only.\r
+ @retval EFI_ACCESS_DENIED - If the file's attribute is read only, and the\r
+ open is for read-write fail it.\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r
+\r
+**/\r
EFI_STATUS\r
FatOFileOpen (\r
IN FAT_OFILE *OFile,\r
IN UINT8 Attributes\r
);\r
\r
+/**\r
+\r
+ Create an Open instance for the existing OFile.\r
+ The IFile of the newly opened file is passed out.\r
+\r
+ @param OFile - The file that serves as a starting reference point.\r
+ @param PtrIFile - The newly generated IFile instance.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for the IFile\r
+ @retval EFI_SUCCESS - Create the new IFile for the OFile successfully\r
+\r
+**/\r
EFI_STATUS\r
FatAllocateIFile (\r
IN FAT_OFILE *OFile,\r
//\r
// OpenVolume.c\r
//\r
+/**\r
+\r
+ Implements Simple File System Protocol interface function OpenVolume().\r
+\r
+ @param This - Calling context.\r
+ @param File - the Root Directory of the volume.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r
+ @retval EFI_VOLUME_CORRUPTED - The FAT type is error.\r
+ @retval EFI_SUCCESS - Open the volume successfully.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
FatOpenVolume (\r
//\r
// ReadWrite.c\r
//\r
+/**\r
+\r
+ This function reads data from a file or writes data to a file.\r
+ It uses OFile->PosRem to determine how much data can be accessed in one time.\r
+\r
+ @param OFile - The open file.\r
+ @param IoMode - Indicate whether the access mode is reading or writing.\r
+ @param Position - The position where data will be accessed.\r
+ @param DataBufferSize - Size of Buffer.\r
+ @param UserBuffer - Buffer containing data.\r
+ @param Task point to task instance.\r
+\r
+ @retval EFI_SUCCESS - Access the data successfully.\r
+ @return other - An error occurred when operating on the disk.\r
+\r
+**/\r
EFI_STATUS\r
FatAccessOFile (\r
IN FAT_OFILE *OFile,\r
IN FAT_TASK *Task\r
);\r
\r
+/**\r
+\r
+ Expand OFile by appending zero bytes at the end of OFile.\r
+\r
+ @param OFile - The open file.\r
+ @param ExpandedSize - The number of zero bytes appended at the end of the file.\r
+\r
+ @retval EFI_SUCCESS - The file is expanded successfully.\r
+ @return other - An error occurred when expanding file.\r
+\r
+**/\r
EFI_STATUS\r
FatExpandOFile (\r
IN FAT_OFILE *OFile,\r
IN UINT64 ExpandedSize\r
);\r
\r
+/**\r
+\r
+ Write zero pool from the WritePos to the end of OFile.\r
+\r
+ @param OFile - The open file to write zero pool.\r
+ @param WritePos - The number of zero bytes written.\r
+\r
+ @retval EFI_SUCCESS - Write the zero pool successfully.\r
+ @retval EFI_OUT_OF_RESOURCES - Not enough memory to perform the operation.\r
+ @return other - An error occurred when writing disk.\r
+\r
+**/\r
EFI_STATUS\r
FatWriteZeroPool (\r
IN FAT_OFILE *OFile,\r
IN UINTN WritePos\r
);\r
\r
+/**\r
+\r
+ Truncate the OFile to smaller file size.\r
+\r
+ @param OFile - The open file.\r
+ @param TruncatedSize - The new file size.\r
+\r
+ @retval EFI_SUCCESS - The file is truncated successfully.\r
+ @return other - An error occurred when truncating file.\r
+\r
+**/\r
EFI_STATUS\r
FatTruncateOFile (\r
IN FAT_OFILE *OFile,\r
//\r
// DirectoryManage.c\r
//\r
+/**\r
+\r
+ Set the OFile's current directory cursor to the list head.\r
+\r
+ @param OFile - The directory OFile whose directory cursor is reset.\r
+\r
+**/\r
VOID\r
FatResetODirCursor (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Set the directory's cursor to the next and get the next directory entry.\r
+\r
+ @param OFile - The parent OFile.\r
+ @param PtrDirEnt - The next directory entry.\r
+\r
+ @retval EFI_SUCCESS - We get the next directory entry successfully.\r
+ @return other - An error occurred when get next directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatGetNextDirEnt (\r
IN FAT_OFILE *OFile,\r
OUT FAT_DIRENT **PtrDirEnt\r
);\r
\r
+/**\r
+\r
+ Remove this directory entry node from the list of directory entries and hash table.\r
+\r
+ @param OFile - The parent OFile.\r
+ @param DirEnt - The directory entry to be removed.\r
+\r
+ @retval EFI_SUCCESS - The directory entry is successfully removed.\r
+ @return other - An error occurred when removing the directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatRemoveDirEnt (\r
IN FAT_OFILE *OFile,\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Save the directory entry to disk.\r
+\r
+ @param OFile - The parent OFile which needs to update.\r
+ @param DirEnt - The directory entry to be saved.\r
+\r
+ @retval EFI_SUCCESS - Store the directory entry successfully.\r
+ @return other - An error occurred when writing the directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatStoreDirEnt (\r
IN FAT_OFILE *OFile,\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Create a directory entry in the parent OFile.\r
+\r
+ @param OFile - The parent OFile.\r
+ @param FileName - The filename of the newly-created directory entry.\r
+ @param Attributes - The attribute of the newly-created directory entry.\r
+ @param PtrDirEnt - The pointer to the newly-created directory entry.\r
+\r
+ @retval EFI_SUCCESS - The directory entry is successfully created.\r
+ @retval EFI_OUT_OF_RESOURCES - Not enough memory to create the directory entry.\r
+ @return other - An error occurred when creating the directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatCreateDirEnt (\r
IN FAT_OFILE *OFile,\r
OUT FAT_DIRENT **PtrDirEnt\r
);\r
\r
+/**\r
+\r
+ Determine whether the directory entry is "." or ".." entry.\r
+\r
+ @param DirEnt - The corresponding directory entry.\r
+\r
+ @retval TRUE - The directory entry is "." or ".." directory entry\r
+ @retval FALSE - The directory entry is not "." or ".." directory entry\r
+\r
+**/\r
BOOLEAN\r
FatIsDotDirEnt (\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Set the OFile's cluster and size info in its directory entry.\r
+\r
+ @param OFile - The corresponding OFile.\r
+\r
+**/\r
VOID\r
FatUpdateDirEntClusterSizeInfo (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.\r
+\r
+ @param DirEnt1 - The destination directory entry.\r
+ @param DirEnt2 - The source directory entry.\r
+\r
+**/\r
VOID\r
FatCloneDirEnt (\r
IN FAT_DIRENT *DirEnt1,\r
IN FAT_DIRENT *DirEnt2\r
);\r
\r
+/**\r
+\r
+ Get the directory entry's info into Buffer.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param DirEnt - The corresponding directory entry.\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
FatGetDirEntInfo (\r
IN FAT_VOLUME *Volume,\r
OUT VOID *Buffer\r
);\r
\r
+/**\r
+\r
+ Open the directory entry to get the OFile.\r
+\r
+ @param Parent - The parent OFile.\r
+ @param DirEnt - The directory entry to be opened.\r
+\r
+ @retval EFI_SUCCESS - The directory entry is successfully opened.\r
+ @retval EFI_OUT_OF_RESOURCES - not enough memory to allocate a new OFile.\r
+ @return other - An error occurred when opening the directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatOpenDirEnt (\r
IN FAT_OFILE *OFile,\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Create "." and ".." directory entries in the newly-created parent OFile.\r
+\r
+ @param OFile - The parent OFile.\r
+\r
+ @retval EFI_SUCCESS - The dot directory entries are successfully created.\r
+ @return other - An error occurred when creating the directory entry.\r
+\r
+**/\r
EFI_STATUS\r
FatCreateDotDirEnts (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Close the directory entry and free the OFile.\r
+\r
+ @param DirEnt - The directory entry to be closed.\r
+\r
+**/\r
VOID\r
FatCloseDirEnt (\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Traverse filename and open all OFiles that can be opened.\r
+ Update filename pointer to the component that can't be opened.\r
+ If more than one name component remains, returns an error;\r
+ otherwise, return the remaining name component so that the caller might choose to create it.\r
+\r
+ @param PtrOFile - As input, the reference OFile; as output, the located OFile.\r
+ @param FileName - The file name relevant to the OFile.\r
+ @param Attributes - The attribute of the destination OFile.\r
+ @param NewFileName - The remaining file name.\r
+\r
+ @retval EFI_NOT_FOUND - The file name can't be opened and there is more than one\r
+ components within the name left (this means the name can\r
+ not be created either).\r
+ @retval EFI_INVALID_PARAMETER - The parameter is not valid.\r
+ @retval EFI_SUCCESS - Open the file successfully.\r
+ @return other - An error occured when locating the OFile.\r
+\r
+**/\r
EFI_STATUS\r
FatLocateOFile (\r
IN OUT FAT_OFILE **PtrOFile,\r
OUT CHAR16 *NewFileName\r
);\r
\r
+/**\r
+\r
+ Get the directory entry for the volume.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Name - The file name of the volume.\r
+\r
+ @retval EFI_SUCCESS - Update the volume with the directory entry sucessfully.\r
+ @return others - An error occurred when getting volume label.\r
+\r
+**/\r
EFI_STATUS\r
FatGetVolumeEntry (\r
IN FAT_VOLUME *Volume,\r
IN CHAR16 *Name\r
);\r
\r
+/**\r
+\r
+ Set the relevant directory entry into disk for the volume.\r
+\r
+ @param Volume - FAT file system volume.\r
+ @param Name - The new file name of the volume.\r
+\r
+ @retval EFI_SUCCESS - Update the Volume sucessfully.\r
+ @retval EFI_UNSUPPORTED - The input label is not a valid volume label.\r
+ @return other - An error occurred when setting volume label.\r
+\r
+**/\r
EFI_STATUS\r
FatSetVolumeEntry (\r
IN FAT_VOLUME *Volume,\r
//\r
// Hash.c\r
//\r
+/**\r
+\r
+ Search the long name hash table for the directory entry.\r
+\r
+ @param ODir - The directory to be searched.\r
+ @param LongNameString - The long name string to search.\r
+\r
+ @return The previous long name hash node of the directory entry.\r
+\r
+**/\r
FAT_DIRENT **\r
FatLongNameHashSearch (\r
IN FAT_ODIR *ODir,\r
IN CHAR16 *LongNameString\r
);\r
\r
+/**\r
+\r
+ Search the short name hash table for the directory entry.\r
+\r
+ @param ODir - The directory to be searched.\r
+ @param ShortNameString - The short name string to search.\r
+\r
+ @return The previous short name hash node of the directory entry.\r
+\r
+**/\r
FAT_DIRENT **\r
FatShortNameHashSearch (\r
IN FAT_ODIR *ODir,\r
IN CHAR8 *ShortNameString\r
);\r
\r
+/**\r
+\r
+ Insert directory entry to hash table.\r
+\r
+ @param ODir - The parent directory.\r
+ @param DirEnt - The directory entry node.\r
+\r
+**/\r
VOID\r
FatInsertToHashTable (\r
IN FAT_ODIR *ODir,\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Delete directory entry from hash table.\r
+\r
+ @param ODir - The parent directory.\r
+ @param DirEnt - The directory entry node.\r
+\r
+**/\r
VOID\r
FatDeleteFromHashTable (\r
IN FAT_ODIR *ODir,\r
//\r
// FileName.c\r
//\r
+/**\r
+\r
+ This function checks whether the input FileName is a valid 8.3 short name.\r
+ If the input FileName is a valid 8.3, the output is the 8.3 short name;\r
+ otherwise, the output is the base tag of 8.3 short name.\r
+\r
+ @param FileName - The input unicode filename.\r
+ @param File8Dot3Name - The output ascii 8.3 short name or base tag of 8.3 short name.\r
+\r
+ @retval TRUE - The input unicode filename is a valid 8.3 short name.\r
+ @retval FALSE - The input unicode filename is not a valid 8.3 short name.\r
+\r
+**/\r
BOOLEAN\r
FatCheckIs8Dot3Name (\r
IN CHAR16 *FileName,\r
OUT CHAR8 *File8Dot3Name\r
);\r
\r
+/**\r
+\r
+ This function generates 8Dot3 name from user specified name for a newly created file.\r
+\r
+ @param Parent - The parent directory.\r
+ @param DirEnt - The directory entry whose 8Dot3Name needs to be generated.\r
+\r
+**/\r
VOID\r
FatCreate8Dot3Name (\r
IN FAT_OFILE *Parent,\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Convert the ascii fat name to the unicode string and strip trailing spaces,\r
+ and if necessary, convert the unicode string to lower case.\r
+\r
+ @param FatName - The Char8 string needs to be converted.\r
+ @param Len - The length of the fat name.\r
+ @param LowerCase - Indicate whether to convert the string to lower case.\r
+ @param Str - The result of the convertion.\r
+\r
+**/\r
VOID\r
FatNameToStr (\r
IN CHAR8 *FatName,\r
IN CHAR16 *Str\r
);\r
\r
+/**\r
+\r
+ Set the caseflag value for the directory entry.\r
+\r
+ @param DirEnt - The logical directory entry whose caseflag value is to be set.\r
+\r
+**/\r
VOID\r
FatSetCaseFlag (\r
IN FAT_DIRENT *DirEnt\r
);\r
\r
+/**\r
+\r
+ Convert the 8.3 ASCII fat name to cased Unicode string according to case flag.\r
+\r
+ @param DirEnt - The corresponding directory entry.\r
+ @param FileString - The output Unicode file name.\r
+ @param FileStringMax The max length of FileString.\r
+\r
+**/\r
VOID\r
FatGetFileNameViaCaseFlag (\r
IN FAT_DIRENT *DirEnt,\r
IN UINTN FileStringMax\r
);\r
\r
+/**\r
+\r
+ Get the Check sum for a short name.\r
+\r
+ @param ShortNameString - The short name for a file.\r
+\r
+ @retval Sum - UINT8 checksum.\r
+\r
+**/\r
UINT8\r
FatCheckSum (\r
IN CHAR8 *ShortNameString\r
);\r
\r
+/**\r
+\r
+ Takes Path as input, returns the next name component\r
+ in Name, and returns the position after Name (e.g., the\r
+ start of the next name component)\r
+\r
+ @param Path - The path of one file.\r
+ @param Name - The next name component in Path.\r
+\r
+ The position after Name in the Path\r
+\r
+**/\r
CHAR16*\r
FatGetNextNameComponent (\r
IN CHAR16 *Path,\r
OUT CHAR16 *Name\r
);\r
\r
+/**\r
+\r
+ Check whether the IFileName is valid long file name. If the IFileName is a valid\r
+ long file name, then we trim the possible leading blanks and leading/trailing dots.\r
+ the trimmed filename is stored in OutputFileName\r
+\r
+ @param InputFileName - The input file name.\r
+ @param OutputFileName - The output file name.\r
+\r
+ @retval TRUE - The InputFileName is a valid long file name.\r
+ @retval FALSE - The InputFileName is not a valid long file name.\r
+\r
+**/\r
BOOLEAN\r
FatFileNameIsValid (\r
IN CHAR16 *InputFileName,\r
//\r
// DirectoryCache.c\r
//\r
+/**\r
+\r
+ Discard the directory structure when an OFile will be freed.\r
+ Volume will cache this directory if the OFile does not represent a deleted file.\r
+\r
+ @param OFile - The OFile whose directory structure is to be discarded.\r
+\r
+**/\r
VOID\r
FatDiscardODir (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Request the directory structure when an OFile is newly generated.\r
+ If the directory structure is cached by volume, then just return this directory;\r
+ Otherwise, allocate a new one for OFile.\r
+\r
+ @param OFile - The OFile which requests directory structure.\r
+\r
+**/\r
VOID\r
FatRequestODir (\r
IN FAT_OFILE *OFile\r
);\r
\r
+/**\r
+\r
+ Clean up all the cached directory structures when the volume is going to be abandoned.\r
+\r
+ @param Volume - FAT file system volume.\r
+\r
+**/\r
VOID\r
FatCleanupODirCache (\r
IN FAT_VOLUME *Volume\r