2016-12-09 03:07:49 +01:00
|
|
|
/** @file
|
|
|
|
Main header file for EFI FAT file system driver.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2013-10-30 04:13:16 +01:00
|
|
|
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
|
2019-04-04 01:03:46 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
#ifndef _FAT_H_
|
|
|
|
#define _FAT_H_
|
|
|
|
|
|
|
|
#include <Uefi.h>
|
|
|
|
|
|
|
|
#include <Guid/FileInfo.h>
|
|
|
|
#include <Guid/FileSystemInfo.h>
|
|
|
|
#include <Guid/FileSystemVolumeLabelInfo.h>
|
|
|
|
#include <Protocol/BlockIo.h>
|
|
|
|
#include <Protocol/DiskIo.h>
|
2013-10-30 04:13:16 +01:00
|
|
|
#include <Protocol/DiskIo2.h>
|
2007-12-20 10:16:45 +01:00
|
|
|
#include <Protocol/SimpleFileSystem.h>
|
|
|
|
#include <Protocol/UnicodeCollation.h>
|
|
|
|
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
|
|
|
|
|
|
#include "FatFileSystem.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// The FAT signature
|
|
|
|
//
|
2008-12-16 16:18:27 +01:00
|
|
|
#define FAT_VOLUME_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'v')
|
|
|
|
#define FAT_IFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'i')
|
|
|
|
#define FAT_ODIR_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'd')
|
|
|
|
#define FAT_DIRENT_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'e')
|
|
|
|
#define FAT_OFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'o')
|
2013-10-30 04:13:16 +01:00
|
|
|
#define FAT_TASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'T')
|
|
|
|
#define FAT_SUBTASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'S')
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
#define ASSERT_VOLUME_LOCKED(a) ASSERT_LOCKED (&FatFsLock)
|
|
|
|
|
|
|
|
#define IFILE_FROM_FHAND(a) CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)
|
|
|
|
|
|
|
|
#define DIRENT_FROM_LINK(a) CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)
|
|
|
|
|
|
|
|
#define VOLUME_FROM_ROOT_DIRENT(a) CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)
|
|
|
|
|
|
|
|
#define VOLUME_FROM_VOL_INTERFACE(a) CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);
|
|
|
|
|
|
|
|
#define ODIR_FROM_DIRCACHELINK(a) CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)
|
|
|
|
|
|
|
|
#define OFILE_FROM_CHECKLINK(a) CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)
|
|
|
|
|
|
|
|
#define OFILE_FROM_CHILDLINK(a) CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Minimum sector size is 512B, Maximum sector size is 4096B
|
|
|
|
// Max sectors per cluster is 128
|
|
|
|
//
|
|
|
|
#define MAX_BLOCK_ALIGNMENT 12
|
|
|
|
#define MIN_BLOCK_ALIGNMENT 9
|
|
|
|
#define MAX_SECTORS_PER_CLUSTER_ALIGNMENT 7
|
|
|
|
|
|
|
|
//
|
|
|
|
// Efi Time Definition
|
|
|
|
//
|
|
|
|
#define IS_LEAP_YEAR(a) (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))
|
|
|
|
|
|
|
|
//
|
|
|
|
// Minimum fat page size is 8K, maximum fat page alignment is 32K
|
|
|
|
// Minimum data page size is 8K, maximum fat page alignment is 64K
|
|
|
|
//
|
|
|
|
#define FAT_FATCACHE_PAGE_MIN_ALIGNMENT 13
|
|
|
|
#define FAT_FATCACHE_PAGE_MAX_ALIGNMENT 15
|
|
|
|
#define FAT_DATACACHE_PAGE_MIN_ALIGNMENT 13
|
|
|
|
#define FAT_DATACACHE_PAGE_MAX_ALIGNMENT 16
|
|
|
|
#define FAT_DATACACHE_GROUP_COUNT 64
|
|
|
|
#define FAT_FATCACHE_GROUP_MIN_COUNT 1
|
|
|
|
#define FAT_FATCACHE_GROUP_MAX_COUNT 16
|
|
|
|
|
|
|
|
//
|
|
|
|
// Used in 8.3 generation algorithm
|
|
|
|
//
|
|
|
|
#define MAX_SPEC_RETRY 4
|
|
|
|
#define SPEC_BASE_TAG_LEN 6
|
|
|
|
#define HASH_BASE_TAG_LEN 2
|
|
|
|
#define HASH_VALUE_TAG_LEN (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Path name separator is back slash
|
|
|
|
//
|
|
|
|
#define PATH_NAME_SEPARATOR L'\\'
|
|
|
|
|
|
|
|
|
|
|
|
#define EFI_PATH_STRING_LENGTH 260
|
|
|
|
#define EFI_FILE_STRING_LENGTH 255
|
|
|
|
#define FAT_MAX_ALLOCATE_SIZE 0xA00000
|
|
|
|
#define LC_ISO_639_2_ENTRY_SIZE 3
|
|
|
|
#define MAX_LANG_CODE_SIZE 100
|
|
|
|
|
|
|
|
#define FAT_MAX_DIR_CACHE_COUNT 8
|
|
|
|
#define FAT_MAX_DIRENTRY_COUNT 0xFFFF
|
|
|
|
typedef CHAR8 LC_ISO_639_2;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The fat types we support
|
|
|
|
//
|
|
|
|
typedef enum {
|
2016-12-08 06:18:08 +01:00
|
|
|
Fat12,
|
|
|
|
Fat16,
|
|
|
|
Fat32,
|
2007-12-20 10:16:45 +01:00
|
|
|
FatUndefined
|
|
|
|
} FAT_VOLUME_TYPE;
|
|
|
|
|
|
|
|
typedef enum {
|
2016-12-08 06:18:08 +01:00
|
|
|
CacheFat,
|
|
|
|
CacheData,
|
|
|
|
CacheMaxType
|
2007-12-20 10:16:45 +01:00
|
|
|
} CACHE_DATA_TYPE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Used in FatDiskIo
|
|
|
|
//
|
|
|
|
typedef enum {
|
2016-12-08 06:18:08 +01:00
|
|
|
ReadDisk = 0, // raw disk read
|
|
|
|
WriteDisk = 1, // raw disk write
|
|
|
|
ReadFat = 2, // read fat cache
|
|
|
|
WriteFat = 3, // write fat cache
|
|
|
|
ReadData = 6, // read data cache
|
|
|
|
WriteData = 7 // write data cache
|
2007-12-20 10:16:45 +01:00
|
|
|
} IO_MODE;
|
|
|
|
|
|
|
|
#define CACHE_ENABLED(a) ((a) >= 2)
|
|
|
|
#define RAW_ACCESS(a) ((IO_MODE)((a) & 0x1))
|
|
|
|
#define CACHE_TYPE(a) ((CACHE_DATA_TYPE)((a) >> 2))
|
|
|
|
|
|
|
|
//
|
|
|
|
// Disk cache tag
|
|
|
|
//
|
|
|
|
typedef struct {
|
|
|
|
UINTN PageNo;
|
|
|
|
UINTN RealSize;
|
|
|
|
BOOLEAN Dirty;
|
|
|
|
} CACHE_TAG;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UINT64 BaseAddress;
|
|
|
|
UINT64 LimitAddress;
|
|
|
|
UINT8 *CacheBase;
|
|
|
|
BOOLEAN Dirty;
|
|
|
|
UINT8 PageAlignment;
|
|
|
|
UINTN GroupMask;
|
|
|
|
CACHE_TAG CacheTag[FAT_DATACACHE_GROUP_COUNT];
|
|
|
|
} DISK_CACHE;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hash table size
|
|
|
|
//
|
|
|
|
#define HASH_TABLE_SIZE 0x400
|
|
|
|
#define HASH_TABLE_MASK (HASH_TABLE_SIZE - 1)
|
|
|
|
|
|
|
|
//
|
|
|
|
// The directory entry for opened directory
|
|
|
|
//
|
2016-12-08 07:38:26 +01:00
|
|
|
|
|
|
|
typedef struct _FAT_DIRENT FAT_DIRENT;
|
|
|
|
typedef struct _FAT_ODIR FAT_ODIR;
|
|
|
|
typedef struct _FAT_OFILE FAT_OFILE;
|
|
|
|
typedef struct _FAT_VOLUME FAT_VOLUME;
|
|
|
|
|
|
|
|
struct _FAT_DIRENT {
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN Signature;
|
|
|
|
UINT16 EntryPos; // The position of this directory entry in the parent directory file
|
|
|
|
UINT8 EntryCount; // The count of the directory entry in the parent directory file
|
|
|
|
BOOLEAN Invalid; // Indicate whether this directory entry is valid
|
|
|
|
CHAR16 *FileString; // The unicode long file name for this directory entry
|
2016-12-08 07:38:26 +01:00
|
|
|
FAT_OFILE *OFile; // The OFile of the corresponding directory entry
|
|
|
|
FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename
|
|
|
|
FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename
|
2007-12-20 10:16:45 +01:00
|
|
|
LIST_ENTRY Link; // Connection of every directory entry
|
|
|
|
FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk
|
2016-12-08 07:38:26 +01:00
|
|
|
};
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-08 07:38:26 +01:00
|
|
|
struct _FAT_ODIR {
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN Signature;
|
|
|
|
UINT32 CurrentEndPos; // Current end position of the directory
|
|
|
|
UINT32 CurrentPos; // Current position of the directory
|
|
|
|
LIST_ENTRY *CurrentCursor; // Current directory entry pointer
|
|
|
|
LIST_ENTRY ChildList; // List of all directory entries
|
|
|
|
BOOLEAN EndOfDir; // Indicate whether we have reached the end of the directory
|
|
|
|
LIST_ENTRY DirCacheLink; // Linked in Volume->DirCacheList when discarded
|
|
|
|
UINTN DirCacheTag; // The identification of the directory when in directory cache
|
|
|
|
FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];
|
|
|
|
FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];
|
2016-12-08 07:38:26 +01:00
|
|
|
};
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UINTN Signature;
|
2009-09-22 04:48:17 +02:00
|
|
|
EFI_FILE_PROTOCOL Handle;
|
2007-12-20 10:16:45 +01:00
|
|
|
UINT64 Position;
|
|
|
|
BOOLEAN ReadOnly;
|
2016-12-08 07:38:26 +01:00
|
|
|
FAT_OFILE *OFile;
|
2013-10-30 04:13:16 +01:00
|
|
|
LIST_ENTRY Tasks; // List of all FAT_TASKs
|
|
|
|
LIST_ENTRY Link; // Link to other IFiles
|
2007-12-20 10:16:45 +01:00
|
|
|
} FAT_IFILE;
|
|
|
|
|
2013-10-30 04:13:16 +01:00
|
|
|
typedef struct {
|
|
|
|
UINTN Signature;
|
|
|
|
EFI_FILE_IO_TOKEN *FileIoToken;
|
|
|
|
FAT_IFILE *IFile;
|
|
|
|
LIST_ENTRY Subtasks; // List of all FAT_SUBTASKs
|
|
|
|
LIST_ENTRY Link; // Link to other FAT_TASKs
|
|
|
|
} FAT_TASK;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UINTN Signature;
|
|
|
|
EFI_DISK_IO2_TOKEN DiskIo2Token;
|
|
|
|
FAT_TASK *Task;
|
|
|
|
BOOLEAN Write;
|
|
|
|
UINT64 Offset;
|
|
|
|
VOID *Buffer;
|
|
|
|
UINTN BufferSize;
|
|
|
|
LIST_ENTRY Link;
|
|
|
|
} FAT_SUBTASK;
|
|
|
|
|
2007-12-20 10:16:45 +01:00
|
|
|
//
|
|
|
|
// FAT_OFILE - Each opened file
|
|
|
|
//
|
2016-12-08 07:38:26 +01:00
|
|
|
struct _FAT_OFILE {
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN Signature;
|
2016-12-08 07:38:26 +01:00
|
|
|
FAT_VOLUME *Volume;
|
2007-12-20 10:16:45 +01:00
|
|
|
//
|
2020-02-07 02:07:20 +01:00
|
|
|
// A permanent error code to return to all accesses to
|
2007-12-20 10:16:45 +01:00
|
|
|
// this opened file
|
|
|
|
//
|
|
|
|
EFI_STATUS Error;
|
|
|
|
//
|
|
|
|
// A list of the IFILE instances for this OFile
|
|
|
|
//
|
|
|
|
LIST_ENTRY Opens;
|
|
|
|
|
|
|
|
//
|
2020-02-07 02:07:20 +01:00
|
|
|
// The dynamic information
|
2007-12-20 10:16:45 +01:00
|
|
|
//
|
|
|
|
UINTN FileSize;
|
|
|
|
UINTN FileCluster;
|
|
|
|
UINTN FileCurrentCluster;
|
|
|
|
UINTN FileLastCluster;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dirty is set if there have been any updates to the
|
|
|
|
// file
|
2008-05-27 04:51:43 +02:00
|
|
|
// Archive is set if the archive attribute in the file's
|
2007-12-20 10:16:45 +01:00
|
|
|
// directory entry needs to be set when performing flush
|
|
|
|
// PreserveLastMod is set if the last modification of the
|
|
|
|
// file is specified by SetInfo API
|
|
|
|
//
|
|
|
|
BOOLEAN Dirty;
|
|
|
|
BOOLEAN IsFixedRootDir;
|
|
|
|
BOOLEAN PreserveLastModification;
|
|
|
|
BOOLEAN Archive;
|
|
|
|
//
|
|
|
|
// Set by an OFile SetPosition
|
|
|
|
//
|
|
|
|
UINTN Position; // within file
|
|
|
|
UINT64 PosDisk; // on the disk
|
|
|
|
UINTN PosRem; // remaining in this disk run
|
|
|
|
//
|
|
|
|
// The opened parent, full path length and currently opened child files
|
|
|
|
//
|
2016-12-08 07:38:26 +01:00
|
|
|
FAT_OFILE *Parent;
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN FullPathLen;
|
|
|
|
LIST_ENTRY ChildHead;
|
|
|
|
LIST_ENTRY ChildLink;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The opened directory structure for a directory; if this
|
|
|
|
// OFile represents a file, then ODir = NULL
|
|
|
|
//
|
|
|
|
FAT_ODIR *ODir;
|
|
|
|
//
|
|
|
|
// The directory entry for the Ofile
|
|
|
|
//
|
|
|
|
FAT_DIRENT *DirEnt;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Link in Volume's reference list
|
|
|
|
//
|
|
|
|
LIST_ENTRY CheckLink;
|
2016-12-08 07:38:26 +01:00
|
|
|
};
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-08 07:38:26 +01:00
|
|
|
struct _FAT_VOLUME {
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN Signature;
|
|
|
|
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
BOOLEAN Valid;
|
|
|
|
BOOLEAN DiskError;
|
|
|
|
|
|
|
|
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL VolumeInterface;
|
|
|
|
|
|
|
|
//
|
|
|
|
// If opened, the parent handle and BlockIo interface
|
|
|
|
//
|
|
|
|
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
|
|
EFI_DISK_IO_PROTOCOL *DiskIo;
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_DISK_IO2_PROTOCOL *DiskIo2;
|
2007-12-20 10:16:45 +01:00
|
|
|
UINT32 MediaId;
|
|
|
|
BOOLEAN ReadOnly;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Computed values from fat bpb info
|
|
|
|
//
|
|
|
|
UINT64 VolumeSize;
|
|
|
|
UINT64 FatPos; // Disk pos of fat tables
|
|
|
|
UINT64 RootPos; // Disk pos of root directory
|
|
|
|
UINT64 FirstClusterPos; // Disk pos of first cluster
|
|
|
|
UINTN FatSize; // Number of bytes in each fat
|
|
|
|
UINTN MaxCluster; // Max cluster number
|
|
|
|
UINTN ClusterSize; // Cluster size of fat partition
|
|
|
|
UINT8 ClusterAlignment; // Equal to log_2 (clustersize);
|
|
|
|
FAT_VOLUME_TYPE FatType;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Current part of fat table that's present
|
|
|
|
//
|
|
|
|
UINT64 FatEntryPos; // Location of buffer
|
|
|
|
UINTN FatEntrySize; // Size of buffer
|
|
|
|
UINT32 FatEntryBuffer; // The buffer
|
|
|
|
FAT_INFO_SECTOR FatInfoSector; // Free cluster info
|
|
|
|
UINTN FreeInfoPos; // Pos with the free cluster info
|
|
|
|
BOOLEAN FreeInfoValid; // If free cluster info is valid
|
|
|
|
//
|
|
|
|
// Unpacked Fat BPB info
|
|
|
|
//
|
|
|
|
UINTN NumFats;
|
|
|
|
UINTN RootEntries; // < FAT32, root dir is fixed size
|
|
|
|
UINTN RootCluster; // >= FAT32, root cluster chain head
|
|
|
|
//
|
|
|
|
// info for marking the volume dirty or not
|
|
|
|
//
|
|
|
|
BOOLEAN FatDirty; // If fat-entries have been updated
|
|
|
|
UINT32 DirtyValue;
|
|
|
|
UINT32 NotDirtyValue;
|
|
|
|
|
|
|
|
//
|
|
|
|
// The root directory entry and opened root file
|
|
|
|
//
|
|
|
|
FAT_DIRENT RootDirEnt;
|
|
|
|
//
|
|
|
|
// File Name of root OFile, it is empty string
|
|
|
|
//
|
|
|
|
CHAR16 RootFileString[1];
|
2016-12-08 07:38:26 +01:00
|
|
|
FAT_OFILE *Root;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// New OFiles are added to this list so they
|
|
|
|
// can be cleaned up if they aren't referenced.
|
|
|
|
//
|
|
|
|
LIST_ENTRY CheckRef;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Directory cache List
|
|
|
|
//
|
|
|
|
LIST_ENTRY DirCacheList;
|
|
|
|
UINTN DirCacheCount;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Disk Cache for this volume
|
|
|
|
//
|
|
|
|
VOID *CacheBuffer;
|
2016-12-08 06:18:08 +01:00
|
|
|
DISK_CACHE DiskCache[CacheMaxType];
|
2016-12-08 07:38:26 +01:00
|
|
|
};
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Function Prototypes
|
|
|
|
//
|
2016-12-09 03:07:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Implements Open() of Simple File System Protocol.
|
|
|
|
|
|
|
|
@param FHand - File handle of the file serves as a starting reference point.
|
|
|
|
@param NewHandle - Handle of the file that is newly opened.
|
|
|
|
@param FileName - File name relative to FHand.
|
|
|
|
@param OpenMode - Open mode.
|
|
|
|
@param Attributes - Attributes to set if the file is created.
|
|
|
|
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.
|
|
|
|
The OpenMode is not supported.
|
|
|
|
The Attributes is not the valid attributes.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
|
|
|
|
@retval EFI_SUCCESS - Open the file successfully.
|
|
|
|
@return Others - The status of open file.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatOpen (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
OUT EFI_FILE_PROTOCOL **NewHandle,
|
2007-12-20 10:16:45 +01:00
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN UINT64 OpenMode,
|
|
|
|
IN UINT64 Attributes
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Implements OpenEx() of Simple File System Protocol.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - File handle of the file serves as a starting reference point.
|
|
|
|
@param NewHandle - Handle of the file that is newly opened.
|
|
|
|
@param FileName - File name relative to FHand.
|
|
|
|
@param OpenMode - Open mode.
|
|
|
|
@param Attributes - Attributes to set if the file is created.
|
|
|
|
@param Token - A pointer to the token associated with the transaction.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.
|
2007-12-20 10:16:45 +01:00
|
|
|
The OpenMode is not supported.
|
|
|
|
The Attributes is not the valid attributes.
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.
|
|
|
|
@retval EFI_SUCCESS - Open the file successfully.
|
|
|
|
@return Others - The status of open file.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_STATUS
|
2013-11-04 03:20:37 +01:00
|
|
|
EFIAPI
|
2013-10-30 04:13:16 +01:00
|
|
|
FatOpenEx (
|
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
OUT EFI_FILE_PROTOCOL **NewHandle,
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN UINT64 OpenMode,
|
|
|
|
IN UINT64 Attributes,
|
|
|
|
IN OUT EFI_FILE_IO_TOKEN *Token
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Get the file's position of the file
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of file.
|
|
|
|
@param Position - The file's position of the file.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Get the info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
|
|
|
@retval EFI_UNSUPPORTED - The open file is not a file.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatGetPosition (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
2007-12-20 10:16:45 +01:00
|
|
|
OUT UINT64 *Position
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Get the some types info of the file into Buffer
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of file.
|
|
|
|
@param Type - The type of the info.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing volume info.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Get the info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatGetInfo (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN EFI_GUID *Type,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
OUT VOID *Buffer
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Set the some types info of the file into Buffer.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of file.
|
|
|
|
@param Type - The type of the info.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing volume info.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Set the info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatSetInfo (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
2007-12-20 10:16:45 +01:00
|
|
|
IN EFI_GUID *Type,
|
|
|
|
IN UINTN BufferSize,
|
|
|
|
IN VOID *Buffer
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Flushes all data associated with the file handle.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - Handle to file to flush
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Flushed the file successfully
|
|
|
|
@retval EFI_WRITE_PROTECTED - The volume is read only
|
|
|
|
@retval EFI_ACCESS_DENIED - The volume is not read only
|
|
|
|
but the file is read only
|
|
|
|
@return Others - Flushing of the file is failed
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatFlush (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Flushes all data associated with the file handle.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - Handle to file to flush.
|
|
|
|
@param Token - A pointer to the token associated with the transaction.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Flushed the file successfully.
|
|
|
|
@retval EFI_WRITE_PROTECTED - The volume is read only.
|
|
|
|
@retval EFI_ACCESS_DENIED - The file is read only.
|
|
|
|
@return Others - Flushing of the file failed.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatFlushEx (
|
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN EFI_FILE_IO_TOKEN *Token
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Flushes & Closes the file handle.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - Handle to the file to delete.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Closed the file successfully.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatClose (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Deletes the file & Closes the file handle.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - Handle to the file to delete.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Delete the file successfully.
|
|
|
|
@retval EFI_WARN_DELETE_FAILURE - Fail to delete the file.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatDelete (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Set the file's position of the file.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of file
|
|
|
|
@param Position - The file's position of the file
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Set the info successfully
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file
|
|
|
|
@retval EFI_UNSUPPORTED - Set a directory with a not-zero position
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatSetPosition (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
2007-12-20 10:16:45 +01:00
|
|
|
IN UINT64 Position
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Get the file info.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of the file.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing read data.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Get the file info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
|
|
|
@return other - An error occurred when operation the disk.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatRead (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
OUT VOID *Buffer
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
Get the file info.
|
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of the file.
|
|
|
|
@param Token - A pointer to the token associated with the transaction.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Get the file info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
|
|
|
@return other - An error occurred when operation the disk.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatReadEx (
|
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN OUT EFI_FILE_IO_TOKEN *Token
|
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Set the file info.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of the file.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing write data.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Set the file info successfully.
|
|
|
|
@retval EFI_WRITE_PROTECTED - The disk is write protected.
|
|
|
|
@retval EFI_ACCESS_DENIED - The file is read-only.
|
|
|
|
@retval EFI_DEVICE_ERROR - The OFile is not valid.
|
|
|
|
@retval EFI_UNSUPPORTED - The open file is not a file.
|
|
|
|
- The writing file size is larger than 4GB.
|
|
|
|
@return other - An error occurred when operation the disk.
|
2013-10-30 04:13:16 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatWrite (
|
2009-09-22 04:48:17 +02:00
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
IN VOID *Buffer
|
2007-12-20 10:16:45 +01:00
|
|
|
)
|
2016-12-09 03:07:49 +01:00
|
|
|
;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
/**
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
Get the file info.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@param FHand - The handle of the file.
|
|
|
|
@param Token - A pointer to the token associated with the transaction.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
@retval EFI_SUCCESS - Get the file info successfully.
|
|
|
|
@retval EFI_DEVICE_ERROR - Can not find the OFile for the file.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - The file type of open file is error.
|
|
|
|
@return other - An error occurred when operation the disk.
|
2007-12-20 10:16:45 +01:00
|
|
|
|
2016-12-09 03:07:49 +01:00
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatWriteEx (
|
|
|
|
IN EFI_FILE_PROTOCOL *FHand,
|
|
|
|
IN OUT EFI_FILE_IO_TOKEN *Token
|
|
|
|
)
|
|
|
|
;
|
|
|
|
|
2007-12-20 10:16:45 +01:00
|
|
|
//
|
|
|
|
// DiskCache.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Initialize the disk cache according to Volume's FatType.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The disk cache is successfully initialized.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Not enough memory to allocate disk cache.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatInitializeDiskCache (
|
|
|
|
IN FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Read BufferSize bytes from the position of Offset into Buffer,
|
|
|
|
or write BufferSize bytes from Buffer into the position of Offset.
|
|
|
|
|
|
|
|
Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into
|
|
|
|
the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):
|
|
|
|
|
|
|
|
1. Access of FAT cache (CACHE_FAT): Access the data in the FAT cache, if there is cache
|
|
|
|
page hit, just return the cache page; else update the related cache page and return
|
|
|
|
the right cache page.
|
|
|
|
2. Access of Data cache (CACHE_DATA):
|
|
|
|
The access data will be divided into UnderRun data, Aligned data and OverRun data;
|
|
|
|
The UnderRun data and OverRun data will be accessed by the Data cache,
|
|
|
|
but the Aligned data will be accessed with disk directly.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param CacheDataType - The type of cache: CACHE_DATA or CACHE_FAT.
|
|
|
|
@param IoMode - Indicate the type of disk access.
|
|
|
|
@param Offset - The starting byte offset to read from.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing cache data.
|
|
|
|
@param Task point to task instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The data was accessed correctly.
|
|
|
|
@retval EFI_MEDIA_CHANGED - The MediaId does not match the current device.
|
|
|
|
@return Others - An error occurred when accessing cache.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAccessCache (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN CACHE_DATA_TYPE CacheDataType,
|
|
|
|
IN IO_MODE IoMode,
|
|
|
|
IN UINT64 Offset,
|
|
|
|
IN UINTN BufferSize,
|
2013-10-30 04:13:16 +01:00
|
|
|
IN OUT UINT8 *Buffer,
|
|
|
|
IN FAT_TASK *Task
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Flush all the dirty cache back, include the FAT cache and the Data cache.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param Task point to task instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Flush all the dirty cache back successfully
|
|
|
|
@return other - An error occurred when writing the data into the disk
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatVolumeFlushCache (
|
2013-10-30 04:13:16 +01:00
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN FAT_TASK *Task
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Flush.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Flush the data associated with an open file.
|
|
|
|
In this implementation, only last Mod/Access time is updated.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The OFile is flushed successfully.
|
|
|
|
@return Others - An error occurred when flushing this OFile.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatOFileFlush (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Check the references of the OFile.
|
|
|
|
If the OFile (that is checked) is no longer
|
|
|
|
referenced, then it is freed.
|
|
|
|
|
|
|
|
@param OFile - The OFile to be checked.
|
|
|
|
|
|
|
|
@retval TRUE - The OFile is not referenced and freed.
|
|
|
|
@retval FALSE - The OFile is kept.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatCheckOFileRef (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the OFile and its child OFile with the error Status
|
|
|
|
|
|
|
|
@param OFile - The OFile whose permanent error code is to be set.
|
|
|
|
@param Status - Error code to be set.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatSetVolumeError (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN EFI_STATUS Status
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Close the open file instance.
|
|
|
|
|
|
|
|
@param IFile - Open file instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Closed the file successfully.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatIFileClose (
|
|
|
|
FAT_IFILE *IFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set error status for a specific OFile, reference checking the volume.
|
|
|
|
If volume is already marked as invalid, and all resources are freed
|
|
|
|
after reference checking, the file system protocol is uninstalled and
|
|
|
|
the volume structure is freed.
|
|
|
|
|
|
|
|
@param Volume - the Volume that is to be reference checked and unlocked.
|
|
|
|
@param OFile - the OFile whose permanent error code is to be set.
|
|
|
|
@param EfiStatus - error code to be set.
|
|
|
|
@param Task point to task instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Clean up the volume successfully.
|
|
|
|
@return Others - Cleaning up of the volume is failed.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatCleanupVolume (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN FAT_OFILE *OFile,
|
2013-10-30 04:13:16 +01:00
|
|
|
IN EFI_STATUS EfiStatus,
|
|
|
|
IN FAT_TASK *Task
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// FileSpace.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Shrink the end of the open file base on the file size.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - Shrinked successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatShrinkEof (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Grow the end of the open file base on the NewSizeInBytes.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
@param NewSizeInBytes - The new size in bytes of the open file.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - The file is grown successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@retval EFI_UNSUPPORTED - The file size is larger than 4GB.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.
|
|
|
|
@retval EFI_VOLUME_FULL - The volume is full and can not grow the file.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatGrowEof (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN UINT64 NewSizeInBytes
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get the size of directory of the open file.
|
|
|
|
|
|
|
|
@param Volume - The File System Volume.
|
|
|
|
@param Cluster - The Starting cluster.
|
|
|
|
|
|
|
|
@return The physical size of the file starting at the input cluster, if there is error in the
|
|
|
|
cluster chain, the return value is 0.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
UINTN
|
|
|
|
FatPhysicalDirSize (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN UINTN Cluster
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get the physical size of a file on the disk.
|
|
|
|
|
|
|
|
@param Volume - The file system volume.
|
|
|
|
@param RealSize - The real size of a file.
|
|
|
|
|
|
|
|
@return The physical size of a file on the disk.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
UINT64
|
|
|
|
FatPhysicalFileSize (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN UINTN RealSize
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Seek OFile to requested position, and calculate the number of
|
|
|
|
consecutive clusters from the position in the file
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
@param Position - The file's position which will be accessed.
|
|
|
|
@param PosLimit - The maximum length current reading/writing may access
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Set the info successfully.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - Cluster chain corrupt.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatOFilePosition (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN UINTN Position,
|
|
|
|
IN UINTN PosLimit
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Update the free cluster info of FatInfoSector of the volume.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatComputeFreeInfo (
|
|
|
|
IN FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Init.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Allocates volume structure, detects FAT file system, installs protocol,
|
|
|
|
and initialize cache.
|
|
|
|
|
|
|
|
@param Handle - The handle of parent device.
|
|
|
|
@param DiskIo - The DiskIo of parent device.
|
|
|
|
@param DiskIo2 - The DiskIo2 of parent device.
|
2019-10-09 07:38:15 +02:00
|
|
|
@param BlockIo - The BlockIo of parent device.
|
2016-12-08 09:01:15 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Allocate a new volume successfully.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
|
|
|
@return Others - Allocating a new volume failed.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAllocateVolume (
|
|
|
|
IN EFI_HANDLE Handle,
|
|
|
|
IN EFI_DISK_IO_PROTOCOL *DiskIo,
|
2013-10-30 04:13:16 +01:00
|
|
|
IN EFI_DISK_IO2_PROTOCOL *DiskIo2,
|
2007-12-20 10:16:45 +01:00
|
|
|
IN EFI_BLOCK_IO_PROTOCOL *BlockIo
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Detects FAT file system on Disk and set relevant fields of Volume.
|
|
|
|
|
|
|
|
@param Volume - The volume structure.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The Fat File System is detected successfully
|
|
|
|
@retval EFI_UNSUPPORTED - The volume is not FAT file system.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - The volume is corrupted.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatOpenDevice (
|
|
|
|
IN OUT FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Called by FatDriverBindingStop(), Abandon the volume.
|
|
|
|
|
|
|
|
@param Volume - The volume to be abandoned.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Abandoned the volume successfully.
|
|
|
|
@return Others - Can not uninstall the protocol interfaces.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAbandonVolume (
|
|
|
|
IN FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Misc.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Create the task
|
|
|
|
|
|
|
|
@param IFile - The instance of the open file.
|
|
|
|
@param Token - A pointer to the token associated with the transaction.
|
|
|
|
|
|
|
|
@return FAT_TASK * - Return the task instance.
|
|
|
|
|
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
FAT_TASK *
|
|
|
|
FatCreateTask (
|
|
|
|
FAT_IFILE *IFile,
|
|
|
|
EFI_FILE_IO_TOKEN *Token
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Destroy the task.
|
|
|
|
|
|
|
|
@param Task - The task to be destroyed.
|
|
|
|
|
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
VOID
|
|
|
|
FatDestroyTask (
|
|
|
|
FAT_TASK *Task
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Wait all non-blocking requests complete.
|
|
|
|
|
|
|
|
@param IFile - The instance of the open file.
|
|
|
|
|
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
VOID
|
|
|
|
FatWaitNonblockingTask (
|
|
|
|
FAT_IFILE *IFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Remove the subtask from subtask list.
|
|
|
|
|
|
|
|
@param Subtask - The subtask to be removed.
|
|
|
|
|
|
|
|
@return LIST_ENTRY * - The next node in the list.
|
|
|
|
|
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
LIST_ENTRY *
|
|
|
|
FatDestroySubtask (
|
|
|
|
FAT_SUBTASK *Subtask
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Execute the task.
|
|
|
|
|
|
|
|
@param IFile - The instance of the open file.
|
|
|
|
@param Task - The task to be executed.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - The task was executed successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@return other - An error occurred when executing the task.
|
|
|
|
|
|
|
|
**/
|
2013-10-30 04:13:16 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatQueueTask (
|
|
|
|
IN FAT_IFILE *IFile,
|
|
|
|
IN FAT_TASK *Task
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the volume as dirty or not.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param IoMode - The access mode.
|
|
|
|
@param DirtyValue - Set the volume as dirty or not.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - Set the new FAT entry value successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@return other - An error occurred when operation the FAT entries.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAccessVolumeDirty (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN IO_MODE IoMode,
|
|
|
|
IN VOID *DirtyValue
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
General disk access function.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param IoMode - The access mode (disk read/write or cache access).
|
|
|
|
@param Offset - The starting byte offset to read from.
|
|
|
|
@param BufferSize - Size of Buffer.
|
|
|
|
@param Buffer - Buffer containing read data.
|
|
|
|
@param Task point to task instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The operation is performed successfully.
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_VOLUME_CORRUPTED - The access is
|
2016-12-08 09:01:15 +01:00
|
|
|
@return Others - The status of read/write the disk
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatDiskIo (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN IO_MODE IoMode,
|
|
|
|
IN UINT64 Offset,
|
|
|
|
IN UINTN BufferSize,
|
2013-10-30 04:13:16 +01:00
|
|
|
IN OUT VOID *Buffer,
|
|
|
|
IN FAT_TASK *Task
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Lock the volume.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatAcquireLock (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Unlock the volume.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatReleaseLock (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Lock the volume.
|
|
|
|
If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.
|
|
|
|
Otherwise, EFI_SUCCESS is returned.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The volume is locked.
|
|
|
|
@retval EFI_ACCESS_DENIED - The volume could not be locked because it is already locked.
|
|
|
|
|
|
|
|
**/
|
2010-03-18 02:56:21 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAcquireLockOrFail (
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Free directory entry.
|
|
|
|
|
|
|
|
@param DirEnt - The directory entry to be freed.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatFreeDirEnt (
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Free volume structure (including the contents of directory cache and disk cache).
|
|
|
|
|
|
|
|
@param Volume - The volume structure to be freed.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatFreeVolume (
|
|
|
|
IN FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Translate EFI time to FAT time.
|
|
|
|
|
|
|
|
@param ETime - The time of EFI_TIME.
|
|
|
|
@param FTime - The time of FAT_DATE_TIME.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatEfiTimeToFatTime (
|
|
|
|
IN EFI_TIME *ETime,
|
|
|
|
OUT FAT_DATE_TIME *FTime
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Translate Fat time to EFI time.
|
|
|
|
|
|
|
|
@param FTime - The time of FAT_DATE_TIME.
|
|
|
|
@param ETime - The time of EFI_TIME..
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatFatTimeToEfiTime (
|
|
|
|
IN FAT_DATE_TIME *FTime,
|
|
|
|
OUT EFI_TIME *ETime
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get Current FAT time.
|
|
|
|
|
|
|
|
@param FatTime - Current FAT time.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatGetCurrentFatTime (
|
|
|
|
OUT FAT_DATE_TIME *FatTime
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Check whether a time is valid.
|
|
|
|
|
|
|
|
@param Time - The time of EFI_TIME.
|
|
|
|
|
|
|
|
@retval TRUE - The time is valid.
|
|
|
|
@retval FALSE - The time is not valid.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatIsValidTime (
|
|
|
|
IN EFI_TIME *Time
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// UnicodeCollation.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Initialize Unicode Collation support.
|
|
|
|
|
|
|
|
It tries to locate Unicode Collation 2 protocol and matches it with current
|
|
|
|
platform language code. If for any reason the first attempt fails, it then tries to
|
|
|
|
use Unicode Collation Protocol.
|
|
|
|
|
|
|
|
@param AgentHandle The handle used to open Unicode Collation (2) protocol.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Unicode Collation (2) protocol has been successfully located.
|
|
|
|
@retval Others The Unicode Collation (2) protocol has not been located.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
InitializeUnicodeCollationSupport (
|
|
|
|
IN EFI_HANDLE AgentHandle
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Convert FAT string to unicode string.
|
|
|
|
|
|
|
|
@param FatSize The size of FAT string.
|
|
|
|
@param Fat The FAT string.
|
|
|
|
@param String The unicode string.
|
|
|
|
|
|
|
|
@return None.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatFatToStr (
|
|
|
|
IN UINTN FatSize,
|
|
|
|
IN CHAR8 *Fat,
|
|
|
|
OUT CHAR16 *String
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Convert unicode string to Fat string.
|
|
|
|
|
|
|
|
@param String The unicode string.
|
|
|
|
@param FatSize The size of the FAT string.
|
|
|
|
@param Fat The FAT string.
|
|
|
|
|
|
|
|
@retval TRUE Convert successfully.
|
|
|
|
@retval FALSE Convert error.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatStrToFat (
|
|
|
|
IN CHAR16 *String,
|
|
|
|
IN UINTN FatSize,
|
|
|
|
OUT CHAR8 *Fat
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Lowercase a string
|
|
|
|
|
|
|
|
@param Str The string which will be lower-cased.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatStrLwr (
|
|
|
|
IN CHAR16 *Str
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Uppercase a string.
|
|
|
|
|
|
|
|
@param Str The string which will be upper-cased.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatStrUpr (
|
|
|
|
IN CHAR16 *Str
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
Performs a case-insensitive comparison of two Null-terminated Unicode strings.
|
|
|
|
|
|
|
|
@param Str1 A pointer to a Null-terminated Unicode string.
|
|
|
|
@param Str2 A pointer to a Null-terminated Unicode string.
|
|
|
|
|
|
|
|
@retval 0 S1 is equivalent to S2.
|
|
|
|
@retval >0 S1 is lexically greater than S2.
|
|
|
|
@retval <0 S1 is lexically less than S2.
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
INTN
|
|
|
|
FatStriCmp (
|
|
|
|
IN CHAR16 *Str1,
|
|
|
|
IN CHAR16 *Str2
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Open.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Open a file for a file name relative to an existing OFile.
|
|
|
|
The IFile of the newly opened file is passed out.
|
|
|
|
|
|
|
|
@param OFile - The file that serves as a starting reference point.
|
|
|
|
@param NewIFile - The newly generated IFile instance.
|
|
|
|
@param FileName - The file name relative to the OFile.
|
|
|
|
@param OpenMode - Open mode.
|
|
|
|
@param Attributes - Attributes to set if the file is created.
|
|
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Open the file successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER - The open mode is conflict with the attributes
|
|
|
|
or the file name is not valid.
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_NOT_FOUND - Conflicts between dir intention and attribute.
|
2016-12-08 09:01:15 +01:00
|
|
|
@retval EFI_WRITE_PROTECTED - Can't open for write if the volume is read only.
|
|
|
|
@retval EFI_ACCESS_DENIED - If the file's attribute is read only, and the
|
|
|
|
open is for read-write fail it.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatOFileOpen (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
OUT FAT_IFILE **NewIFile,
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN UINT64 OpenMode,
|
|
|
|
IN UINT8 Attributes
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Create an Open instance for the existing OFile.
|
|
|
|
The IFile of the newly opened file is passed out.
|
|
|
|
|
|
|
|
@param OFile - The file that serves as a starting reference point.
|
|
|
|
@param PtrIFile - The newly generated IFile instance.
|
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for the IFile
|
|
|
|
@retval EFI_SUCCESS - Create the new IFile for the OFile successfully
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAllocateIFile (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
OUT FAT_IFILE **PtrIFile
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// OpenVolume.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Implements Simple File System Protocol interface function OpenVolume().
|
|
|
|
|
|
|
|
@param This - Calling context.
|
|
|
|
@param File - the Root Directory of the volume.
|
|
|
|
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.
|
|
|
|
@retval EFI_VOLUME_CORRUPTED - The FAT type is error.
|
|
|
|
@retval EFI_SUCCESS - Open the volume successfully.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
FatOpenVolume (
|
|
|
|
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,
|
2009-09-22 04:48:17 +02:00
|
|
|
OUT EFI_FILE_PROTOCOL **File
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// ReadWrite.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
This function reads data from a file or writes data to a file.
|
|
|
|
It uses OFile->PosRem to determine how much data can be accessed in one time.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
@param IoMode - Indicate whether the access mode is reading or writing.
|
|
|
|
@param Position - The position where data will be accessed.
|
|
|
|
@param DataBufferSize - Size of Buffer.
|
|
|
|
@param UserBuffer - Buffer containing data.
|
|
|
|
@param Task point to task instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Access the data successfully.
|
|
|
|
@return other - An error occurred when operating on the disk.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatAccessOFile (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN IO_MODE IoMode,
|
|
|
|
IN UINTN Position,
|
|
|
|
IN UINTN *DataBufferSize,
|
2013-10-30 04:13:16 +01:00
|
|
|
IN UINT8 *UserBuffer,
|
|
|
|
IN FAT_TASK *Task
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Expand OFile by appending zero bytes at the end of OFile.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
@param ExpandedSize - The number of zero bytes appended at the end of the file.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The file is expanded successfully.
|
|
|
|
@return other - An error occurred when expanding file.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatExpandOFile (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN UINT64 ExpandedSize
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Write zero pool from the WritePos to the end of OFile.
|
|
|
|
|
|
|
|
@param OFile - The open file to write zero pool.
|
|
|
|
@param WritePos - The number of zero bytes written.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Write the zero pool successfully.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Not enough memory to perform the operation.
|
|
|
|
@return other - An error occurred when writing disk.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatWriteZeroPool (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN UINTN WritePos
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Truncate the OFile to smaller file size.
|
|
|
|
|
|
|
|
@param OFile - The open file.
|
|
|
|
@param TruncatedSize - The new file size.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The file is truncated successfully.
|
|
|
|
@return other - An error occurred when truncating file.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatTruncateOFile (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN UINTN TruncatedSize
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// DirectoryManage.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the OFile's current directory cursor to the list head.
|
|
|
|
|
|
|
|
@param OFile - The directory OFile whose directory cursor is reset.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatResetODirCursor (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the directory's cursor to the next and get the next directory entry.
|
|
|
|
|
|
|
|
@param OFile - The parent OFile.
|
|
|
|
@param PtrDirEnt - The next directory entry.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - We get the next directory entry successfully.
|
|
|
|
@return other - An error occurred when get next directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatGetNextDirEnt (
|
2016-12-08 06:18:08 +01:00
|
|
|
IN FAT_OFILE *OFile,
|
2007-12-20 10:16:45 +01:00
|
|
|
OUT FAT_DIRENT **PtrDirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Remove this directory entry node from the list of directory entries and hash table.
|
|
|
|
|
|
|
|
@param OFile - The parent OFile.
|
|
|
|
@param DirEnt - The directory entry to be removed.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The directory entry is successfully removed.
|
|
|
|
@return other - An error occurred when removing the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatRemoveDirEnt (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Save the directory entry to disk.
|
|
|
|
|
|
|
|
@param OFile - The parent OFile which needs to update.
|
|
|
|
@param DirEnt - The directory entry to be saved.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - Store the directory entry successfully.
|
|
|
|
@return other - An error occurred when writing the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatStoreDirEnt (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Create a directory entry in the parent OFile.
|
|
|
|
|
|
|
|
@param OFile - The parent OFile.
|
|
|
|
@param FileName - The filename of the newly-created directory entry.
|
|
|
|
@param Attributes - The attribute of the newly-created directory entry.
|
|
|
|
@param PtrDirEnt - The pointer to the newly-created directory entry.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The directory entry is successfully created.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - Not enough memory to create the directory entry.
|
|
|
|
@return other - An error occurred when creating the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatCreateDirEnt (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN UINT8 Attributes,
|
|
|
|
OUT FAT_DIRENT **PtrDirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Determine whether the directory entry is "." or ".." entry.
|
|
|
|
|
|
|
|
@param DirEnt - The corresponding directory entry.
|
|
|
|
|
|
|
|
@retval TRUE - The directory entry is "." or ".." directory entry
|
|
|
|
@retval FALSE - The directory entry is not "." or ".." directory entry
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatIsDotDirEnt (
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the OFile's cluster and size info in its directory entry.
|
|
|
|
|
|
|
|
@param OFile - The corresponding OFile.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatUpdateDirEntClusterSizeInfo (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.
|
|
|
|
|
|
|
|
@param DirEnt1 - The destination directory entry.
|
|
|
|
@param DirEnt2 - The source directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatCloneDirEnt (
|
|
|
|
IN FAT_DIRENT *DirEnt1,
|
|
|
|
IN FAT_DIRENT *DirEnt2
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get the directory entry's info into Buffer.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param DirEnt - The corresponding directory entry.
|
|
|
|
@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.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatGetDirEntInfo (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN FAT_DIRENT *DirEnt,
|
|
|
|
IN OUT UINTN *BufferSize,
|
|
|
|
OUT VOID *Buffer
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Open the directory entry to get the OFile.
|
|
|
|
|
|
|
|
@param Parent - The parent OFile.
|
|
|
|
@param DirEnt - The directory entry to be opened.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The directory entry is successfully opened.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES - not enough memory to allocate a new OFile.
|
|
|
|
@return other - An error occurred when opening the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatOpenDirEnt (
|
|
|
|
IN FAT_OFILE *OFile,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Create "." and ".." directory entries in the newly-created parent OFile.
|
|
|
|
|
|
|
|
@param OFile - The parent OFile.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS - The dot directory entries are successfully created.
|
|
|
|
@return other - An error occurred when creating the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatCreateDotDirEnts (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Close the directory entry and free the OFile.
|
|
|
|
|
|
|
|
@param DirEnt - The directory entry to be closed.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatCloseDirEnt (
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
@param PtrOFile - As input, the reference OFile; as output, the located OFile.
|
|
|
|
@param FileName - The file name relevant to the OFile.
|
|
|
|
@param Attributes - The attribute of the destination OFile.
|
|
|
|
@param NewFileName - The remaining file name.
|
|
|
|
|
|
|
|
@retval 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).
|
|
|
|
@retval EFI_INVALID_PARAMETER - The parameter is not valid.
|
|
|
|
@retval EFI_SUCCESS - Open the file successfully.
|
2019-10-09 07:38:15 +02:00
|
|
|
@return other - An error occurred when locating the OFile.
|
2016-12-08 09:01:15 +01:00
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatLocateOFile (
|
|
|
|
IN OUT FAT_OFILE **PtrOFile,
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
IN UINT8 Attributes,
|
|
|
|
OUT CHAR16 *NewFileName
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get the directory entry for the volume.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param Name - The file name of the volume.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - Update the volume with the directory entry successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@return others - An error occurred when getting volume label.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatGetVolumeEntry (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN CHAR16 *Name
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the relevant directory entry into disk for the volume.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
@param Name - The new file name of the volume.
|
|
|
|
|
2019-10-09 07:38:15 +02:00
|
|
|
@retval EFI_SUCCESS - Update the Volume successfully.
|
2016-12-08 09:01:15 +01:00
|
|
|
@retval EFI_UNSUPPORTED - The input label is not a valid volume label.
|
|
|
|
@return other - An error occurred when setting volume label.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
EFI_STATUS
|
|
|
|
FatSetVolumeEntry (
|
|
|
|
IN FAT_VOLUME *Volume,
|
|
|
|
IN CHAR16 *Name
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hash.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Search the long name hash table for the directory entry.
|
|
|
|
|
|
|
|
@param ODir - The directory to be searched.
|
|
|
|
@param LongNameString - The long name string to search.
|
|
|
|
|
|
|
|
@return The previous long name hash node of the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
FAT_DIRENT **
|
|
|
|
FatLongNameHashSearch (
|
|
|
|
IN FAT_ODIR *ODir,
|
|
|
|
IN CHAR16 *LongNameString
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Search the short name hash table for the directory entry.
|
|
|
|
|
|
|
|
@param ODir - The directory to be searched.
|
|
|
|
@param ShortNameString - The short name string to search.
|
|
|
|
|
|
|
|
@return The previous short name hash node of the directory entry.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
FAT_DIRENT **
|
|
|
|
FatShortNameHashSearch (
|
|
|
|
IN FAT_ODIR *ODir,
|
|
|
|
IN CHAR8 *ShortNameString
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Insert directory entry to hash table.
|
|
|
|
|
|
|
|
@param ODir - The parent directory.
|
|
|
|
@param DirEnt - The directory entry node.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatInsertToHashTable (
|
|
|
|
IN FAT_ODIR *ODir,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Delete directory entry from hash table.
|
|
|
|
|
|
|
|
@param ODir - The parent directory.
|
|
|
|
@param DirEnt - The directory entry node.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatDeleteFromHashTable (
|
|
|
|
IN FAT_ODIR *ODir,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// FileName.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
This function checks whether the input FileName is a valid 8.3 short name.
|
|
|
|
If the input FileName is a valid 8.3, the output is the 8.3 short name;
|
|
|
|
otherwise, the output is the base tag of 8.3 short name.
|
|
|
|
|
|
|
|
@param FileName - The input unicode filename.
|
|
|
|
@param File8Dot3Name - The output ascii 8.3 short name or base tag of 8.3 short name.
|
|
|
|
|
|
|
|
@retval TRUE - The input unicode filename is a valid 8.3 short name.
|
|
|
|
@retval FALSE - The input unicode filename is not a valid 8.3 short name.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatCheckIs8Dot3Name (
|
|
|
|
IN CHAR16 *FileName,
|
|
|
|
OUT CHAR8 *File8Dot3Name
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
This function generates 8Dot3 name from user specified name for a newly created file.
|
|
|
|
|
|
|
|
@param Parent - The parent directory.
|
|
|
|
@param DirEnt - The directory entry whose 8Dot3Name needs to be generated.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatCreate8Dot3Name (
|
|
|
|
IN FAT_OFILE *Parent,
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Convert the ascii fat name to the unicode string and strip trailing spaces,
|
|
|
|
and if necessary, convert the unicode string to lower case.
|
|
|
|
|
|
|
|
@param FatName - The Char8 string needs to be converted.
|
|
|
|
@param Len - The length of the fat name.
|
|
|
|
@param LowerCase - Indicate whether to convert the string to lower case.
|
2020-02-07 02:07:20 +01:00
|
|
|
@param Str - The result of the conversion.
|
2016-12-08 09:01:15 +01:00
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatNameToStr (
|
|
|
|
IN CHAR8 *FatName,
|
|
|
|
IN UINTN Len,
|
|
|
|
IN UINTN LowerCase,
|
|
|
|
IN CHAR16 *Str
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Set the caseflag value for the directory entry.
|
|
|
|
|
|
|
|
@param DirEnt - The logical directory entry whose caseflag value is to be set.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatSetCaseFlag (
|
|
|
|
IN FAT_DIRENT *DirEnt
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Convert the 8.3 ASCII fat name to cased Unicode string according to case flag.
|
|
|
|
|
|
|
|
@param DirEnt - The corresponding directory entry.
|
|
|
|
@param FileString - The output Unicode file name.
|
|
|
|
@param FileStringMax The max length of FileString.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatGetFileNameViaCaseFlag (
|
2015-07-06 03:41:45 +02:00
|
|
|
IN FAT_DIRENT *DirEnt,
|
|
|
|
IN OUT CHAR16 *FileString,
|
|
|
|
IN UINTN FileStringMax
|
2007-12-20 10:16:45 +01:00
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Get the Check sum for a short name.
|
|
|
|
|
|
|
|
@param ShortNameString - The short name for a file.
|
|
|
|
|
|
|
|
@retval Sum - UINT8 checksum.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
UINT8
|
|
|
|
FatCheckSum (
|
|
|
|
IN CHAR8 *ShortNameString
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Takes Path as input, returns the next name component
|
|
|
|
in Name, and returns the position after Name (e.g., the
|
|
|
|
start of the next name component)
|
|
|
|
|
|
|
|
@param Path - The path of one file.
|
|
|
|
@param Name - The next name component in Path.
|
|
|
|
|
|
|
|
The position after Name in the Path
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
CHAR16*
|
|
|
|
FatGetNextNameComponent (
|
|
|
|
IN CHAR16 *Path,
|
|
|
|
OUT CHAR16 *Name
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Check whether the IFileName is valid long file name. If the IFileName is a valid
|
|
|
|
long file name, then we trim the possible leading blanks and leading/trailing dots.
|
|
|
|
the trimmed filename is stored in OutputFileName
|
|
|
|
|
|
|
|
@param InputFileName - The input file name.
|
|
|
|
@param OutputFileName - The output file name.
|
|
|
|
|
|
|
|
@retval TRUE - The InputFileName is a valid long file name.
|
|
|
|
@retval FALSE - The InputFileName is not a valid long file name.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
BOOLEAN
|
|
|
|
FatFileNameIsValid (
|
|
|
|
IN CHAR16 *InputFileName,
|
|
|
|
OUT CHAR16 *OutputFileName
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// DirectoryCache.c
|
|
|
|
//
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Discard the directory structure when an OFile will be freed.
|
|
|
|
Volume will cache this directory if the OFile does not represent a deleted file.
|
|
|
|
|
|
|
|
@param OFile - The OFile whose directory structure is to be discarded.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatDiscardODir (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Request the directory structure when an OFile is newly generated.
|
|
|
|
If the directory structure is cached by volume, then just return this directory;
|
|
|
|
Otherwise, allocate a new one for OFile.
|
|
|
|
|
|
|
|
@param OFile - The OFile which requests directory structure.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatRequestODir (
|
|
|
|
IN FAT_OFILE *OFile
|
|
|
|
);
|
|
|
|
|
2016-12-08 09:01:15 +01:00
|
|
|
/**
|
|
|
|
|
|
|
|
Clean up all the cached directory structures when the volume is going to be abandoned.
|
|
|
|
|
|
|
|
@param Volume - FAT file system volume.
|
|
|
|
|
|
|
|
**/
|
2007-12-20 10:16:45 +01:00
|
|
|
VOID
|
|
|
|
FatCleanupODirCache (
|
|
|
|
IN FAT_VOLUME *Volume
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Global Variables
|
|
|
|
//
|
|
|
|
extern EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding;
|
|
|
|
extern EFI_COMPONENT_NAME_PROTOCOL gFatComponentName;
|
|
|
|
extern EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2;
|
|
|
|
extern EFI_LOCK FatFsLock;
|
2013-10-30 04:13:16 +01:00
|
|
|
extern EFI_LOCK FatTaskLock;
|
2009-09-22 04:48:17 +02:00
|
|
|
extern EFI_FILE_PROTOCOL FatFileInterface;
|
2007-12-20 10:16:45 +01:00
|
|
|
|
|
|
|
#endif
|