TianoCore EDK2 master
Loading...
Searching...
No Matches
DirectoryManage.c File Reference
#include "Fat.h"

Go to the source code of this file.

Functions

STATIC EFI_STATUS FatAccessEntry (IN FAT_OFILE *Parent, IN IO_MODE IoMode, IN UINTN EntryPos, IN OUT VOID *Entry)
 
EFI_STATUS FatStoreDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
BOOLEAN FatIsDotDirEnt (IN FAT_DIRENT *DirEnt)
 
STATIC VOID FatSetDirEntCluster (IN FAT_OFILE *OFile)
 
VOID FatUpdateDirEntClusterSizeInfo (IN FAT_OFILE *OFile)
 
VOID FatCloneDirEnt (IN FAT_DIRENT *DirEnt1, IN FAT_DIRENT *DirEnt2)
 
STATIC VOID FatLoadLongNameEntry (IN FAT_OFILE *Parent, IN FAT_DIRENT *DirEnt)
 
STATIC VOID FatAddDirEnt (IN FAT_ODIR *ODir, IN FAT_DIRENT *DirEnt)
 
STATIC EFI_STATUS FatLoadNextDirEnt (IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
 
EFI_STATUS FatGetDirEntInfo (IN FAT_VOLUME *Volume, IN FAT_DIRENT *DirEnt, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
 
STATIC EFI_STATUS FatSearchODir (IN FAT_OFILE *OFile, IN CHAR16 *FileNameString, OUT FAT_DIRENT **PtrDirEnt)
 
VOID FatResetODirCursor (IN FAT_OFILE *OFile)
 
EFI_STATUS FatGetNextDirEnt (IN FAT_OFILE *OFile, OUT FAT_DIRENT **PtrDirEnt)
 
STATIC VOID FatSetEntryCount (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
STATIC EFI_STATUS FatExpandODir (IN FAT_OFILE *OFile)
 
STATIC EFI_STATUS FatSeekVolumeId (IN FAT_OFILE *Root, OUT FAT_DIRENT *DirEnt)
 
STATIC EFI_STATUS FatFirstFitInsertDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
STATIC EFI_STATUS FatNewEntryPos (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatGetVolumeEntry (IN FAT_VOLUME *Volume, IN CHAR16 *Name)
 
EFI_STATUS FatSetVolumeEntry (IN FAT_VOLUME *Volume, IN CHAR16 *Name)
 
EFI_STATUS FatCreateDotDirEnts (IN FAT_OFILE *OFile)
 
EFI_STATUS FatCreateDirEnt (IN FAT_OFILE *OFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT FAT_DIRENT **PtrDirEnt)
 
EFI_STATUS FatRemoveDirEnt (IN FAT_OFILE *OFile, IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatOpenDirEnt (IN FAT_OFILE *Parent, IN FAT_DIRENT *DirEnt)
 
VOID FatCloseDirEnt (IN FAT_DIRENT *DirEnt)
 
EFI_STATUS FatLocateOFile (IN OUT FAT_OFILE **PtrOFile, IN CHAR16 *FileName, IN UINT8 Attributes, OUT CHAR16 *NewFileName)
 

Detailed Description

Functions for performing directory entry io.

Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DirectoryManage.c.

Function Documentation

◆ FatAccessEntry()

STATIC EFI_STATUS FatAccessEntry ( IN FAT_OFILE Parent,
IN IO_MODE  IoMode,
IN UINTN  EntryPos,
IN OUT VOID *  Entry 
)

Get a directory entry from disk for the Ofile.

Parameters
Parent- The parent of the OFile which need to update.
IoMode- Indicate whether to read directory entry or write directory entry.
EntryPos- The position of the directory entry to be accessed.
Entry- The directory entry read or written.
Return values
EFI_SUCCESS- Access the directory entry successfully.
Returns
other - An error occurred when reading the directory entry.

Definition at line 26 of file DirectoryManage.c.

◆ FatAddDirEnt()

STATIC VOID FatAddDirEnt ( IN FAT_ODIR ODir,
IN FAT_DIRENT DirEnt 
)

Add this directory entry node to the list of directory entries and hash table.

Parameters
ODir- The parent OFile which needs to be updated.
DirEnt- The directory entry to be added.

Definition at line 318 of file DirectoryManage.c.

◆ FatCloneDirEnt()

VOID FatCloneDirEnt ( IN FAT_DIRENT DirEnt1,
IN FAT_DIRENT DirEnt2 
)

Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.

Parameters
DirEnt1- The destination directory entry.
DirEnt2- The source directory entry.

Definition at line 205 of file DirectoryManage.c.

◆ FatCloseDirEnt()

VOID FatCloseDirEnt ( IN FAT_DIRENT DirEnt)

Close the directory entry and free the OFile.

Parameters
DirEnt- The directory entry to be closed.

Definition at line 1216 of file DirectoryManage.c.

◆ FatCreateDirEnt()

EFI_STATUS FatCreateDirEnt ( IN FAT_OFILE OFile,
IN CHAR16 *  FileName,
IN UINT8  Attributes,
OUT FAT_DIRENT **  PtrDirEnt 
)

Create a directory entry in the parent OFile.

Parameters
OFile- The parent OFile.
FileName- The filename of the newly-created directory entry.
Attributes- The attribute of the newly-created directory entry.
PtrDirEnt- The pointer to the newly-created directory entry.
Return values
EFI_SUCCESS- The directory entry is successfully created.
EFI_OUT_OF_RESOURCES- Not enough memory to create the directory entry.
Returns
other - An error occurred when creating the directory entry.

Definition at line 1040 of file DirectoryManage.c.

◆ FatCreateDotDirEnts()

EFI_STATUS FatCreateDotDirEnts ( IN FAT_OFILE OFile)

Create "." and ".." directory entries in the newly-created parent OFile.

Parameters
OFile- The parent OFile.
Return values
EFI_SUCCESS- The dot directory entries are successfully created.
Returns
other - An error occurred when creating the directory entry.

Definition at line 997 of file DirectoryManage.c.

◆ FatExpandODir()

STATIC EFI_STATUS FatExpandODir ( IN FAT_OFILE OFile)

Append a zero cluster to the current OFile.

Parameters
OFile- The directory OFile which needs to be updated.
Return values
EFI_SUCCESS- Append a zero cluster to the OFile successfully.
Returns
other - An error occurred when appending the zero cluster.

Definition at line 708 of file DirectoryManage.c.

◆ FatFirstFitInsertDirEnt()

STATIC EFI_STATUS FatFirstFitInsertDirEnt ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Use First Fit Algorithm to insert directory entry. Only this function will erase "E5" entries in a directory. In view of safest recovery, this function will only be triggered when maximum directory entry number has reached.

Parameters
OFile- The corresponding OFile.
DirEnt- The directory entry to be inserted.
Return values
EFI_SUCCESS- The directory entry has been successfully inserted.
EFI_VOLUME_FULL- The directory can not hold more directory entries.
Returns
Others - Some error occurred when inserting new directory entries.

Definition at line 776 of file DirectoryManage.c.

◆ FatGetDirEntInfo()

EFI_STATUS FatGetDirEntInfo ( IN FAT_VOLUME Volume,
IN FAT_DIRENT DirEnt,
IN OUT UINTN BufferSize,
OUT VOID *  Buffer 
)

Get the directory entry's info into Buffer.

Parameters
Volume- FAT file system volume.
DirEnt- The corresponding directory entry.
BufferSize- Size of Buffer.
Buffer- Buffer containing file info.
Return values
EFI_SUCCESS- Get the file info successfully.
EFI_BUFFER_TOO_SMALL- The buffer is too small.

Definition at line 448 of file DirectoryManage.c.

◆ FatGetNextDirEnt()

EFI_STATUS FatGetNextDirEnt ( IN FAT_OFILE OFile,
OUT FAT_DIRENT **  PtrDirEnt 
)

Set the directory's cursor to the next and get the next directory entry.

Parameters
OFile- The parent OFile.
PtrDirEnt- The next directory entry.
Return values
EFI_SUCCESS- We get the next directory entry successfully.
Returns
other - An error occurred when get next directory entry.

Definition at line 597 of file DirectoryManage.c.

◆ FatGetVolumeEntry()

EFI_STATUS FatGetVolumeEntry ( IN FAT_VOLUME Volume,
IN CHAR16 *  Name 
)

Get the directory entry for the volume.

Parameters
Volume- FAT file system volume.
Name- The file name of the volume.
Return values
EFI_SUCCESS- Update the volume with the directory entry successfully.
Returns
others - An error occurred when getting volume label.

Definition at line 916 of file DirectoryManage.c.

◆ FatIsDotDirEnt()

BOOLEAN FatIsDotDirEnt ( IN FAT_DIRENT DirEnt)

Determine whether the directory entry is "." or ".." entry.

Parameters
DirEnt- The corresponding directory entry.
Return values
TRUE- The directory entry is "." or ".." directory entry
FALSE- The directory entry is not "." or ".." directory entry

Definition at line 143 of file DirectoryManage.c.

◆ FatLoadLongNameEntry()

STATIC VOID FatLoadLongNameEntry ( IN FAT_OFILE Parent,
IN FAT_DIRENT DirEnt 
)

Get the LFN for the directory entry.

Parameters
Parent- The parent directory.
DirEnt- The directory entry to get LFN.

Definition at line 232 of file DirectoryManage.c.

◆ FatLoadNextDirEnt()

STATIC EFI_STATUS FatLoadNextDirEnt ( IN FAT_OFILE OFile,
OUT FAT_DIRENT **  PtrDirEnt 
)

Load from disk the next directory entry at current end of directory position.

Parameters
OFile- The parent OFile.
PtrDirEnt- The directory entry that is loaded.
Return values
EFI_SUCCESS- Load the directory entry successfully.
EFI_OUT_OF_RESOURCES- Out of resource.
Returns
other - An error occurred when reading the directory entries.

Definition at line 345 of file DirectoryManage.c.

◆ FatLocateOFile()

EFI_STATUS FatLocateOFile ( IN OUT FAT_OFILE **  PtrOFile,
IN CHAR16 *  FileName,
IN UINT8  Attributes,
OUT CHAR16 *  NewFileName 
)

Traverse filename and open all OFiles that can be opened. Update filename pointer to the component that can't be opened. If more than one name component remains, returns an error; otherwise, return the remaining name component so that the caller might choose to create it.

Parameters
PtrOFile- As input, the reference OFile; as output, the located OFile.
FileName- The file name relevant to the OFile.
Attributes- The attribute of the destination OFile.
NewFileName- The remaining file name.
Return values
EFI_NOT_FOUND- The file name can't be opened and there is more than one components within the name left (this means the name can not be created either).
EFI_INVALID_PARAMETER- The parameter is not valid.
EFI_SUCCESS- Open the file successfully.
Returns
other - An error occurred when locating the OFile.

Definition at line 1268 of file DirectoryManage.c.

◆ FatNewEntryPos()

STATIC EFI_STATUS FatNewEntryPos ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Find the new directory entry position for the directory entry.

Parameters
OFile- The corresponding OFile.
DirEnt- The directory entry whose new position is to be set.
Return values
EFI_SUCCESS- The new directory entry position is successfully found.
EFI_VOLUME_FULL- The directory has reach its maximum capacity.
Returns
other - An error occurred when reading the directory entry.

Definition at line 850 of file DirectoryManage.c.

◆ FatOpenDirEnt()

EFI_STATUS FatOpenDirEnt ( IN FAT_OFILE Parent,
IN FAT_DIRENT DirEnt 
)

Open the directory entry to get the OFile.

Parameters
Parent- The parent OFile.
DirEnt- The directory entry to be opened.
Return values
EFI_SUCCESS- The directory entry is successfully opened.
EFI_OUT_OF_RESOURCES- not enough memory to allocate a new OFile.
Returns
other - An error occurred when opening the directory entry.

Definition at line 1142 of file DirectoryManage.c.

◆ FatRemoveDirEnt()

EFI_STATUS FatRemoveDirEnt ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Remove this directory entry node from the list of directory entries and hash table.

Parameters
OFile- The parent OFile.
DirEnt- The directory entry to be removed.
Return values
EFI_SUCCESS- The directory entry is successfully removed.
Returns
other - An error occurred when removing the directory entry.

Definition at line 1101 of file DirectoryManage.c.

◆ FatResetODirCursor()

VOID FatResetODirCursor ( IN FAT_OFILE OFile)

Set the OFile's current directory cursor to the list head.

Parameters
OFile- The directory OFile whose directory cursor is reset.

Definition at line 573 of file DirectoryManage.c.

◆ FatSearchODir()

STATIC EFI_STATUS FatSearchODir ( IN FAT_OFILE OFile,
IN CHAR16 *  FileNameString,
OUT FAT_DIRENT **  PtrDirEnt 
)

Search the directory for the directory entry whose filename is FileNameString.

Parameters
OFile- The parent OFile whose directory is to be searched.
FileNameString- The filename to be searched.
PtrDirEnt- pointer to the directory entry if found.
Return values
EFI_SUCCESS- Find the directory entry or not found.
Returns
other - An error occurred when reading the directory entries.

Definition at line 512 of file DirectoryManage.c.

◆ FatSeekVolumeId()

STATIC EFI_STATUS FatSeekVolumeId ( IN FAT_OFILE Root,
OUT FAT_DIRENT DirEnt 
)

Search the Root OFile for the possible volume label.

Parameters
Root- The Root OFile.
DirEnt- The returned directory entry of volume label.
Return values
EFI_SUCCESS- The search process is completed successfully.
Returns
other - An error occurred when searching volume label.

Definition at line 728 of file DirectoryManage.c.

◆ FatSetDirEntCluster()

STATIC VOID FatSetDirEntCluster ( IN FAT_OFILE OFile)

Set the OFile's cluster info in its directory entry.

Parameters
OFile- The corresponding OFile.

Definition at line 166 of file DirectoryManage.c.

◆ FatSetEntryCount()

STATIC VOID FatSetEntryCount ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Set the directory entry count according to the filename.

Parameters
OFile- The corresponding OFile.
DirEnt- The directory entry to be set.

Definition at line 649 of file DirectoryManage.c.

◆ FatSetVolumeEntry()

EFI_STATUS FatSetVolumeEntry ( IN FAT_VOLUME Volume,
IN CHAR16 *  Name 
)

Set the relevant directory entry into disk for the volume.

Parameters
Volume- FAT file system volume.
Name- The new file name of the volume.
Return values
EFI_SUCCESS- Update the Volume successfully.
EFI_UNSUPPORTED- The input label is not a valid volume label.
Returns
other - An error occurred when setting volume label.

Definition at line 948 of file DirectoryManage.c.

◆ FatStoreDirEnt()

EFI_STATUS FatStoreDirEnt ( IN FAT_OFILE OFile,
IN FAT_DIRENT DirEnt 
)

Save the directory entry to disk.

Parameters
OFile- The parent OFile which needs to update.
DirEnt- The directory entry to be saved.
Return values
EFI_SUCCESS- Store the directory entry successfully.
Returns
other - An error occurred when writing the directory entry.

Definition at line 63 of file DirectoryManage.c.

◆ FatUpdateDirEntClusterSizeInfo()

VOID FatUpdateDirEntClusterSizeInfo ( IN FAT_OFILE OFile)

Set the OFile's cluster and size info in its directory entry.

Parameters
OFile- The corresponding OFile.

Definition at line 187 of file DirectoryManage.c.