]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Main header file for EFI FAT file system driver.\r | |
3 | \r | |
4 | Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #ifndef _FAT_H_\r | |
10 | #define _FAT_H_\r | |
11 | \r | |
12 | #include <Uefi.h>\r | |
13 | \r | |
14 | #include <Guid/FileInfo.h>\r | |
15 | #include <Guid/FileSystemInfo.h>\r | |
16 | #include <Guid/FileSystemVolumeLabelInfo.h>\r | |
17 | #include <Protocol/BlockIo.h>\r | |
18 | #include <Protocol/DiskIo.h>\r | |
19 | #include <Protocol/DiskIo2.h>\r | |
20 | #include <Protocol/SimpleFileSystem.h>\r | |
21 | #include <Protocol/UnicodeCollation.h>\r | |
22 | \r | |
23 | #include <Library/PcdLib.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/UefiLib.h>\r | |
26 | #include <Library/BaseLib.h>\r | |
27 | #include <Library/BaseMemoryLib.h>\r | |
28 | #include <Library/MemoryAllocationLib.h>\r | |
29 | #include <Library/UefiDriverEntryPoint.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/UefiRuntimeServicesTableLib.h>\r | |
32 | \r | |
33 | #include "FatFileSystem.h"\r | |
34 | \r | |
35 | //\r | |
36 | // The FAT signature\r | |
37 | //\r | |
38 | #define FAT_VOLUME_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'v')\r | |
39 | #define FAT_IFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'i')\r | |
40 | #define FAT_ODIR_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'd')\r | |
41 | #define FAT_DIRENT_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'e')\r | |
42 | #define FAT_OFILE_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'o')\r | |
43 | #define FAT_TASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'T')\r | |
44 | #define FAT_SUBTASK_SIGNATURE SIGNATURE_32 ('f', 'a', 't', 'S')\r | |
45 | \r | |
46 | #define ASSERT_VOLUME_LOCKED(a) ASSERT_LOCKED (&FatFsLock)\r | |
47 | \r | |
48 | #define IFILE_FROM_FHAND(a) CR (a, FAT_IFILE, Handle, FAT_IFILE_SIGNATURE)\r | |
49 | \r | |
50 | #define DIRENT_FROM_LINK(a) CR (a, FAT_DIRENT, Link, FAT_DIRENT_SIGNATURE)\r | |
51 | \r | |
52 | #define VOLUME_FROM_ROOT_DIRENT(a) CR (a, FAT_VOLUME, RootDirEnt, FAT_VOLUME_SIGNATURE)\r | |
53 | \r | |
54 | #define VOLUME_FROM_VOL_INTERFACE(a) CR (a, FAT_VOLUME, VolumeInterface, FAT_VOLUME_SIGNATURE);\r | |
55 | \r | |
56 | #define ODIR_FROM_DIRCACHELINK(a) CR (a, FAT_ODIR, DirCacheLink, FAT_ODIR_SIGNATURE)\r | |
57 | \r | |
58 | #define OFILE_FROM_CHECKLINK(a) CR (a, FAT_OFILE, CheckLink, FAT_OFILE_SIGNATURE)\r | |
59 | \r | |
60 | #define OFILE_FROM_CHILDLINK(a) CR (a, FAT_OFILE, ChildLink, FAT_OFILE_SIGNATURE)\r | |
61 | \r | |
62 | //\r | |
63 | // Minimum sector size is 512B, Maximum sector size is 4096B\r | |
64 | // Max sectors per cluster is 128\r | |
65 | //\r | |
66 | #define MAX_BLOCK_ALIGNMENT 12\r | |
67 | #define MIN_BLOCK_ALIGNMENT 9\r | |
68 | #define MAX_SECTORS_PER_CLUSTER_ALIGNMENT 7\r | |
69 | \r | |
70 | //\r | |
71 | // Efi Time Definition\r | |
72 | //\r | |
73 | #define IS_LEAP_YEAR(a) (((a) % 4 == 0) && (((a) % 100 != 0) || ((a) % 400 == 0)))\r | |
74 | \r | |
75 | //\r | |
76 | // Minimum fat page size is 8K, maximum fat page alignment is 32K\r | |
77 | // Minimum data page size is 8K, maximum fat page alignment is 64K\r | |
78 | //\r | |
79 | #define FAT_FATCACHE_PAGE_MIN_ALIGNMENT 13\r | |
80 | #define FAT_FATCACHE_PAGE_MAX_ALIGNMENT 15\r | |
81 | #define FAT_DATACACHE_PAGE_MIN_ALIGNMENT 13\r | |
82 | #define FAT_DATACACHE_PAGE_MAX_ALIGNMENT 16\r | |
83 | #define FAT_DATACACHE_GROUP_COUNT 64\r | |
84 | #define FAT_FATCACHE_GROUP_MIN_COUNT 1\r | |
85 | #define FAT_FATCACHE_GROUP_MAX_COUNT 16\r | |
86 | \r | |
87 | //\r | |
88 | // Used in 8.3 generation algorithm\r | |
89 | //\r | |
90 | #define MAX_SPEC_RETRY 4\r | |
91 | #define SPEC_BASE_TAG_LEN 6\r | |
92 | #define HASH_BASE_TAG_LEN 2\r | |
93 | #define HASH_VALUE_TAG_LEN (SPEC_BASE_TAG_LEN - HASH_BASE_TAG_LEN)\r | |
94 | \r | |
95 | //\r | |
96 | // Path name separator is back slash\r | |
97 | //\r | |
98 | #define PATH_NAME_SEPARATOR L'\\'\r | |
99 | \r | |
100 | #define EFI_PATH_STRING_LENGTH 260\r | |
101 | #define EFI_FILE_STRING_LENGTH 255\r | |
102 | #define FAT_MAX_ALLOCATE_SIZE 0xA00000\r | |
103 | #define LC_ISO_639_2_ENTRY_SIZE 3\r | |
104 | #define MAX_LANG_CODE_SIZE 100\r | |
105 | \r | |
106 | #define FAT_MAX_DIR_CACHE_COUNT 8\r | |
107 | #define FAT_MAX_DIRENTRY_COUNT 0xFFFF\r | |
108 | typedef CHAR8 LC_ISO_639_2;\r | |
109 | \r | |
110 | //\r | |
111 | // The fat types we support\r | |
112 | //\r | |
113 | typedef enum {\r | |
114 | Fat12,\r | |
115 | Fat16,\r | |
116 | Fat32,\r | |
117 | FatUndefined\r | |
118 | } FAT_VOLUME_TYPE;\r | |
119 | \r | |
120 | typedef enum {\r | |
121 | CacheFat,\r | |
122 | CacheData,\r | |
123 | CacheMaxType\r | |
124 | } CACHE_DATA_TYPE;\r | |
125 | \r | |
126 | //\r | |
127 | // Used in FatDiskIo\r | |
128 | //\r | |
129 | typedef enum {\r | |
130 | ReadDisk = 0, // raw disk read\r | |
131 | WriteDisk = 1, // raw disk write\r | |
132 | ReadFat = 2, // read fat cache\r | |
133 | WriteFat = 3, // write fat cache\r | |
134 | ReadData = 6, // read data cache\r | |
135 | WriteData = 7 // write data cache\r | |
136 | } IO_MODE;\r | |
137 | \r | |
138 | #define CACHE_ENABLED(a) ((a) >= 2)\r | |
139 | #define RAW_ACCESS(a) ((IO_MODE)((a) & 0x1))\r | |
140 | #define CACHE_TYPE(a) ((CACHE_DATA_TYPE)((a) >> 2))\r | |
141 | \r | |
142 | //\r | |
143 | // Disk cache tag\r | |
144 | //\r | |
145 | typedef struct {\r | |
146 | UINTN PageNo;\r | |
147 | UINTN RealSize;\r | |
148 | BOOLEAN Dirty;\r | |
149 | } CACHE_TAG;\r | |
150 | \r | |
151 | typedef struct {\r | |
152 | UINT64 BaseAddress;\r | |
153 | UINT64 LimitAddress;\r | |
154 | UINT8 *CacheBase;\r | |
155 | BOOLEAN Dirty;\r | |
156 | UINT8 PageAlignment;\r | |
157 | UINTN GroupMask;\r | |
158 | CACHE_TAG CacheTag[FAT_DATACACHE_GROUP_COUNT];\r | |
159 | } DISK_CACHE;\r | |
160 | \r | |
161 | //\r | |
162 | // Hash table size\r | |
163 | //\r | |
164 | #define HASH_TABLE_SIZE 0x400\r | |
165 | #define HASH_TABLE_MASK (HASH_TABLE_SIZE - 1)\r | |
166 | \r | |
167 | //\r | |
168 | // The directory entry for opened directory\r | |
169 | //\r | |
170 | \r | |
171 | typedef struct _FAT_DIRENT FAT_DIRENT;\r | |
172 | typedef struct _FAT_ODIR FAT_ODIR;\r | |
173 | typedef struct _FAT_OFILE FAT_OFILE;\r | |
174 | typedef struct _FAT_VOLUME FAT_VOLUME;\r | |
175 | \r | |
176 | struct _FAT_DIRENT {\r | |
177 | UINTN Signature;\r | |
178 | UINT16 EntryPos; // The position of this directory entry in the parent directory file\r | |
179 | UINT8 EntryCount; // The count of the directory entry in the parent directory file\r | |
180 | BOOLEAN Invalid; // Indicate whether this directory entry is valid\r | |
181 | CHAR16 *FileString; // The unicode long file name for this directory entry\r | |
182 | FAT_OFILE *OFile; // The OFile of the corresponding directory entry\r | |
183 | FAT_DIRENT *ShortNameForwardLink; // Hash successor link for short filename\r | |
184 | FAT_DIRENT *LongNameForwardLink; // Hash successor link for long filename\r | |
185 | LIST_ENTRY Link; // Connection of every directory entry\r | |
186 | FAT_DIRECTORY_ENTRY Entry; // The physical directory entry stored in disk\r | |
187 | };\r | |
188 | \r | |
189 | struct _FAT_ODIR {\r | |
190 | UINTN Signature;\r | |
191 | UINT32 CurrentEndPos; // Current end position of the directory\r | |
192 | UINT32 CurrentPos; // Current position of the directory\r | |
193 | LIST_ENTRY *CurrentCursor; // Current directory entry pointer\r | |
194 | LIST_ENTRY ChildList; // List of all directory entries\r | |
195 | BOOLEAN EndOfDir; // Indicate whether we have reached the end of the directory\r | |
196 | LIST_ENTRY DirCacheLink; // Linked in Volume->DirCacheList when discarded\r | |
197 | UINTN DirCacheTag; // The identification of the directory when in directory cache\r | |
198 | FAT_DIRENT *LongNameHashTable[HASH_TABLE_SIZE];\r | |
199 | FAT_DIRENT *ShortNameHashTable[HASH_TABLE_SIZE];\r | |
200 | };\r | |
201 | \r | |
202 | typedef struct {\r | |
203 | UINTN Signature;\r | |
204 | EFI_FILE_PROTOCOL Handle;\r | |
205 | UINT64 Position;\r | |
206 | BOOLEAN ReadOnly;\r | |
207 | FAT_OFILE *OFile;\r | |
208 | LIST_ENTRY Tasks; // List of all FAT_TASKs\r | |
209 | LIST_ENTRY Link; // Link to other IFiles\r | |
210 | } FAT_IFILE;\r | |
211 | \r | |
212 | typedef struct {\r | |
213 | UINTN Signature;\r | |
214 | EFI_FILE_IO_TOKEN *FileIoToken;\r | |
215 | FAT_IFILE *IFile;\r | |
216 | LIST_ENTRY Subtasks; // List of all FAT_SUBTASKs\r | |
217 | LIST_ENTRY Link; // Link to other FAT_TASKs\r | |
218 | } FAT_TASK;\r | |
219 | \r | |
220 | typedef struct {\r | |
221 | UINTN Signature;\r | |
222 | EFI_DISK_IO2_TOKEN DiskIo2Token;\r | |
223 | FAT_TASK *Task;\r | |
224 | BOOLEAN Write;\r | |
225 | UINT64 Offset;\r | |
226 | VOID *Buffer;\r | |
227 | UINTN BufferSize;\r | |
228 | LIST_ENTRY Link;\r | |
229 | } FAT_SUBTASK;\r | |
230 | \r | |
231 | //\r | |
232 | // FAT_OFILE - Each opened file\r | |
233 | //\r | |
234 | struct _FAT_OFILE {\r | |
235 | UINTN Signature;\r | |
236 | FAT_VOLUME *Volume;\r | |
237 | //\r | |
238 | // A permanent error code to return to all accesses to\r | |
239 | // this opened file\r | |
240 | //\r | |
241 | EFI_STATUS Error;\r | |
242 | //\r | |
243 | // A list of the IFILE instances for this OFile\r | |
244 | //\r | |
245 | LIST_ENTRY Opens;\r | |
246 | \r | |
247 | //\r | |
248 | // The dynamic information\r | |
249 | //\r | |
250 | UINTN FileSize;\r | |
251 | UINTN FileCluster;\r | |
252 | UINTN FileCurrentCluster;\r | |
253 | UINTN FileLastCluster;\r | |
254 | \r | |
255 | //\r | |
256 | // Dirty is set if there have been any updates to the\r | |
257 | // file\r | |
258 | // Archive is set if the archive attribute in the file's\r | |
259 | // directory entry needs to be set when performing flush\r | |
260 | // PreserveLastMod is set if the last modification of the\r | |
261 | // file is specified by SetInfo API\r | |
262 | //\r | |
263 | BOOLEAN Dirty;\r | |
264 | BOOLEAN IsFixedRootDir;\r | |
265 | BOOLEAN PreserveLastModification;\r | |
266 | BOOLEAN Archive;\r | |
267 | //\r | |
268 | // Set by an OFile SetPosition\r | |
269 | //\r | |
270 | UINTN Position; // within file\r | |
271 | UINT64 PosDisk; // on the disk\r | |
272 | UINTN PosRem; // remaining in this disk run\r | |
273 | //\r | |
274 | // The opened parent, full path length and currently opened child files\r | |
275 | //\r | |
276 | FAT_OFILE *Parent;\r | |
277 | UINTN FullPathLen;\r | |
278 | LIST_ENTRY ChildHead;\r | |
279 | LIST_ENTRY ChildLink;\r | |
280 | \r | |
281 | //\r | |
282 | // The opened directory structure for a directory; if this\r | |
283 | // OFile represents a file, then ODir = NULL\r | |
284 | //\r | |
285 | FAT_ODIR *ODir;\r | |
286 | //\r | |
287 | // The directory entry for the Ofile\r | |
288 | //\r | |
289 | FAT_DIRENT *DirEnt;\r | |
290 | \r | |
291 | //\r | |
292 | // Link in Volume's reference list\r | |
293 | //\r | |
294 | LIST_ENTRY CheckLink;\r | |
295 | };\r | |
296 | \r | |
297 | struct _FAT_VOLUME {\r | |
298 | UINTN Signature;\r | |
299 | \r | |
300 | EFI_HANDLE Handle;\r | |
301 | BOOLEAN Valid;\r | |
302 | BOOLEAN DiskError;\r | |
303 | \r | |
304 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL VolumeInterface;\r | |
305 | \r | |
306 | //\r | |
307 | // If opened, the parent handle and BlockIo interface\r | |
308 | //\r | |
309 | EFI_BLOCK_IO_PROTOCOL *BlockIo;\r | |
310 | EFI_DISK_IO_PROTOCOL *DiskIo;\r | |
311 | EFI_DISK_IO2_PROTOCOL *DiskIo2;\r | |
312 | UINT32 MediaId;\r | |
313 | BOOLEAN ReadOnly;\r | |
314 | \r | |
315 | //\r | |
316 | // Computed values from fat bpb info\r | |
317 | //\r | |
318 | UINT64 VolumeSize;\r | |
319 | UINT64 FatPos; // Disk pos of fat tables\r | |
320 | UINT64 RootPos; // Disk pos of root directory\r | |
321 | UINT64 FirstClusterPos; // Disk pos of first cluster\r | |
322 | UINTN FatSize; // Number of bytes in each fat\r | |
323 | UINTN MaxCluster; // Max cluster number\r | |
324 | UINTN ClusterSize; // Cluster size of fat partition\r | |
325 | UINT8 ClusterAlignment; // Equal to log_2 (clustersize);\r | |
326 | FAT_VOLUME_TYPE FatType;\r | |
327 | \r | |
328 | //\r | |
329 | // Current part of fat table that's present\r | |
330 | //\r | |
331 | UINT64 FatEntryPos; // Location of buffer\r | |
332 | UINTN FatEntrySize; // Size of buffer\r | |
333 | UINT32 FatEntryBuffer; // The buffer\r | |
334 | FAT_INFO_SECTOR FatInfoSector; // Free cluster info\r | |
335 | UINTN FreeInfoPos; // Pos with the free cluster info\r | |
336 | BOOLEAN FreeInfoValid; // If free cluster info is valid\r | |
337 | //\r | |
338 | // Unpacked Fat BPB info\r | |
339 | //\r | |
340 | UINTN NumFats;\r | |
341 | UINTN RootEntries; // < FAT32, root dir is fixed size\r | |
342 | UINTN RootCluster; // >= FAT32, root cluster chain head\r | |
343 | //\r | |
344 | // info for marking the volume dirty or not\r | |
345 | //\r | |
346 | BOOLEAN FatDirty; // If fat-entries have been updated\r | |
347 | UINT32 DirtyValue;\r | |
348 | UINT32 NotDirtyValue;\r | |
349 | \r | |
350 | //\r | |
351 | // The root directory entry and opened root file\r | |
352 | //\r | |
353 | FAT_DIRENT RootDirEnt;\r | |
354 | //\r | |
355 | // File Name of root OFile, it is empty string\r | |
356 | //\r | |
357 | CHAR16 RootFileString[1];\r | |
358 | FAT_OFILE *Root;\r | |
359 | \r | |
360 | //\r | |
361 | // New OFiles are added to this list so they\r | |
362 | // can be cleaned up if they aren't referenced.\r | |
363 | //\r | |
364 | LIST_ENTRY CheckRef;\r | |
365 | \r | |
366 | //\r | |
367 | // Directory cache List\r | |
368 | //\r | |
369 | LIST_ENTRY DirCacheList;\r | |
370 | UINTN DirCacheCount;\r | |
371 | \r | |
372 | //\r | |
373 | // Disk Cache for this volume\r | |
374 | //\r | |
375 | VOID *CacheBuffer;\r | |
376 | DISK_CACHE DiskCache[CacheMaxType];\r | |
377 | };\r | |
378 | \r | |
379 | //\r | |
380 | // Function Prototypes\r | |
381 | //\r | |
382 | \r | |
383 | /**\r | |
384 | \r | |
385 | Implements Open() of Simple File System Protocol.\r | |
386 | \r | |
387 | @param FHand - File handle of the file serves as a starting reference point.\r | |
388 | @param NewHandle - Handle of the file that is newly opened.\r | |
389 | @param FileName - File name relative to FHand.\r | |
390 | @param OpenMode - Open mode.\r | |
391 | @param Attributes - Attributes to set if the file is created.\r | |
392 | \r | |
393 | \r | |
394 | @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r | |
395 | The OpenMode is not supported.\r | |
396 | The Attributes is not the valid attributes.\r | |
397 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r | |
398 | @retval EFI_SUCCESS - Open the file successfully.\r | |
399 | @return Others - The status of open file.\r | |
400 | \r | |
401 | **/\r | |
402 | EFI_STATUS\r | |
403 | EFIAPI\r | |
404 | FatOpen (\r | |
405 | IN EFI_FILE_PROTOCOL *FHand,\r | |
406 | OUT EFI_FILE_PROTOCOL **NewHandle,\r | |
407 | IN CHAR16 *FileName,\r | |
408 | IN UINT64 OpenMode,\r | |
409 | IN UINT64 Attributes\r | |
410 | )\r | |
411 | ;\r | |
412 | \r | |
413 | /**\r | |
414 | \r | |
415 | Implements OpenEx() of Simple File System Protocol.\r | |
416 | \r | |
417 | @param FHand - File handle of the file serves as a starting reference point.\r | |
418 | @param NewHandle - Handle of the file that is newly opened.\r | |
419 | @param FileName - File name relative to FHand.\r | |
420 | @param OpenMode - Open mode.\r | |
421 | @param Attributes - Attributes to set if the file is created.\r | |
422 | @param Token - A pointer to the token associated with the transaction.\r | |
423 | \r | |
424 | @retval EFI_INVALID_PARAMETER - The FileName is NULL or the file string is empty.\r | |
425 | The OpenMode is not supported.\r | |
426 | The Attributes is not the valid attributes.\r | |
427 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for file string.\r | |
428 | @retval EFI_SUCCESS - Open the file successfully.\r | |
429 | @return Others - The status of open file.\r | |
430 | \r | |
431 | **/\r | |
432 | EFI_STATUS\r | |
433 | EFIAPI\r | |
434 | FatOpenEx (\r | |
435 | IN EFI_FILE_PROTOCOL *FHand,\r | |
436 | OUT EFI_FILE_PROTOCOL **NewHandle,\r | |
437 | IN CHAR16 *FileName,\r | |
438 | IN UINT64 OpenMode,\r | |
439 | IN UINT64 Attributes,\r | |
440 | IN OUT EFI_FILE_IO_TOKEN *Token\r | |
441 | )\r | |
442 | ;\r | |
443 | \r | |
444 | /**\r | |
445 | \r | |
446 | Get the file's position of the file\r | |
447 | \r | |
448 | @param FHand - The handle of file.\r | |
449 | @param Position - The file's position of the file.\r | |
450 | \r | |
451 | @retval EFI_SUCCESS - Get the info successfully.\r | |
452 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
453 | @retval EFI_UNSUPPORTED - The open file is not a file.\r | |
454 | \r | |
455 | **/\r | |
456 | EFI_STATUS\r | |
457 | EFIAPI\r | |
458 | FatGetPosition (\r | |
459 | IN EFI_FILE_PROTOCOL *FHand,\r | |
460 | OUT UINT64 *Position\r | |
461 | )\r | |
462 | ;\r | |
463 | \r | |
464 | /**\r | |
465 | \r | |
466 | Get the some types info of the file into Buffer\r | |
467 | \r | |
468 | @param FHand - The handle of file.\r | |
469 | @param Type - The type of the info.\r | |
470 | @param BufferSize - Size of Buffer.\r | |
471 | @param Buffer - Buffer containing volume info.\r | |
472 | \r | |
473 | @retval EFI_SUCCESS - Get the info successfully.\r | |
474 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
475 | \r | |
476 | **/\r | |
477 | EFI_STATUS\r | |
478 | EFIAPI\r | |
479 | FatGetInfo (\r | |
480 | IN EFI_FILE_PROTOCOL *FHand,\r | |
481 | IN EFI_GUID *Type,\r | |
482 | IN OUT UINTN *BufferSize,\r | |
483 | OUT VOID *Buffer\r | |
484 | )\r | |
485 | ;\r | |
486 | \r | |
487 | /**\r | |
488 | \r | |
489 | Set the some types info of the file into Buffer.\r | |
490 | \r | |
491 | @param FHand - The handle of file.\r | |
492 | @param Type - The type of the info.\r | |
493 | @param BufferSize - Size of Buffer.\r | |
494 | @param Buffer - Buffer containing volume info.\r | |
495 | \r | |
496 | @retval EFI_SUCCESS - Set the info successfully.\r | |
497 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
498 | \r | |
499 | **/\r | |
500 | EFI_STATUS\r | |
501 | EFIAPI\r | |
502 | FatSetInfo (\r | |
503 | IN EFI_FILE_PROTOCOL *FHand,\r | |
504 | IN EFI_GUID *Type,\r | |
505 | IN UINTN BufferSize,\r | |
506 | IN VOID *Buffer\r | |
507 | )\r | |
508 | ;\r | |
509 | \r | |
510 | /**\r | |
511 | \r | |
512 | Flushes all data associated with the file handle.\r | |
513 | \r | |
514 | @param FHand - Handle to file to flush\r | |
515 | \r | |
516 | @retval EFI_SUCCESS - Flushed the file successfully\r | |
517 | @retval EFI_WRITE_PROTECTED - The volume is read only\r | |
518 | @retval EFI_ACCESS_DENIED - The volume is not read only\r | |
519 | but the file is read only\r | |
520 | @return Others - Flushing of the file is failed\r | |
521 | \r | |
522 | **/\r | |
523 | EFI_STATUS\r | |
524 | EFIAPI\r | |
525 | FatFlush (\r | |
526 | IN EFI_FILE_PROTOCOL *FHand\r | |
527 | )\r | |
528 | ;\r | |
529 | \r | |
530 | /**\r | |
531 | \r | |
532 | Flushes all data associated with the file handle.\r | |
533 | \r | |
534 | @param FHand - Handle to file to flush.\r | |
535 | @param Token - A pointer to the token associated with the transaction.\r | |
536 | \r | |
537 | @retval EFI_SUCCESS - Flushed the file successfully.\r | |
538 | @retval EFI_WRITE_PROTECTED - The volume is read only.\r | |
539 | @retval EFI_ACCESS_DENIED - The file is read only.\r | |
540 | @return Others - Flushing of the file failed.\r | |
541 | \r | |
542 | **/\r | |
543 | EFI_STATUS\r | |
544 | EFIAPI\r | |
545 | FatFlushEx (\r | |
546 | IN EFI_FILE_PROTOCOL *FHand,\r | |
547 | IN EFI_FILE_IO_TOKEN *Token\r | |
548 | )\r | |
549 | ;\r | |
550 | \r | |
551 | /**\r | |
552 | \r | |
553 | Flushes & Closes the file handle.\r | |
554 | \r | |
555 | @param FHand - Handle to the file to delete.\r | |
556 | \r | |
557 | @retval EFI_SUCCESS - Closed the file successfully.\r | |
558 | \r | |
559 | **/\r | |
560 | EFI_STATUS\r | |
561 | EFIAPI\r | |
562 | FatClose (\r | |
563 | IN EFI_FILE_PROTOCOL *FHand\r | |
564 | )\r | |
565 | ;\r | |
566 | \r | |
567 | /**\r | |
568 | \r | |
569 | Deletes the file & Closes the file handle.\r | |
570 | \r | |
571 | @param FHand - Handle to the file to delete.\r | |
572 | \r | |
573 | @retval EFI_SUCCESS - Delete the file successfully.\r | |
574 | @retval EFI_WARN_DELETE_FAILURE - Fail to delete the file.\r | |
575 | \r | |
576 | **/\r | |
577 | EFI_STATUS\r | |
578 | EFIAPI\r | |
579 | FatDelete (\r | |
580 | IN EFI_FILE_PROTOCOL *FHand\r | |
581 | )\r | |
582 | ;\r | |
583 | \r | |
584 | /**\r | |
585 | \r | |
586 | Set the file's position of the file.\r | |
587 | \r | |
588 | @param FHand - The handle of file\r | |
589 | @param Position - The file's position of the file\r | |
590 | \r | |
591 | @retval EFI_SUCCESS - Set the info successfully\r | |
592 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file\r | |
593 | @retval EFI_UNSUPPORTED - Set a directory with a not-zero position\r | |
594 | \r | |
595 | **/\r | |
596 | EFI_STATUS\r | |
597 | EFIAPI\r | |
598 | FatSetPosition (\r | |
599 | IN EFI_FILE_PROTOCOL *FHand,\r | |
600 | IN UINT64 Position\r | |
601 | )\r | |
602 | ;\r | |
603 | \r | |
604 | /**\r | |
605 | \r | |
606 | Get the file info.\r | |
607 | \r | |
608 | @param FHand - The handle of the file.\r | |
609 | @param BufferSize - Size of Buffer.\r | |
610 | @param Buffer - Buffer containing read data.\r | |
611 | \r | |
612 | @retval EFI_SUCCESS - Get the file info successfully.\r | |
613 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
614 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r | |
615 | @return other - An error occurred when operation the disk.\r | |
616 | \r | |
617 | **/\r | |
618 | EFI_STATUS\r | |
619 | EFIAPI\r | |
620 | FatRead (\r | |
621 | IN EFI_FILE_PROTOCOL *FHand,\r | |
622 | IN OUT UINTN *BufferSize,\r | |
623 | OUT VOID *Buffer\r | |
624 | )\r | |
625 | ;\r | |
626 | \r | |
627 | /**\r | |
628 | \r | |
629 | Get the file info.\r | |
630 | \r | |
631 | @param FHand - The handle of the file.\r | |
632 | @param Token - A pointer to the token associated with the transaction.\r | |
633 | \r | |
634 | @retval EFI_SUCCESS - Get the file info successfully.\r | |
635 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
636 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r | |
637 | @return other - An error occurred when operation the disk.\r | |
638 | \r | |
639 | **/\r | |
640 | EFI_STATUS\r | |
641 | EFIAPI\r | |
642 | FatReadEx (\r | |
643 | IN EFI_FILE_PROTOCOL *FHand,\r | |
644 | IN OUT EFI_FILE_IO_TOKEN *Token\r | |
645 | )\r | |
646 | ;\r | |
647 | \r | |
648 | /**\r | |
649 | \r | |
650 | Set the file info.\r | |
651 | \r | |
652 | @param FHand - The handle of the file.\r | |
653 | @param BufferSize - Size of Buffer.\r | |
654 | @param Buffer - Buffer containing write data.\r | |
655 | \r | |
656 | @retval EFI_SUCCESS - Set the file info successfully.\r | |
657 | @retval EFI_WRITE_PROTECTED - The disk is write protected.\r | |
658 | @retval EFI_ACCESS_DENIED - The file is read-only.\r | |
659 | @retval EFI_DEVICE_ERROR - The OFile is not valid.\r | |
660 | @retval EFI_UNSUPPORTED - The open file is not a file.\r | |
661 | - The writing file size is larger than 4GB.\r | |
662 | @return other - An error occurred when operation the disk.\r | |
663 | \r | |
664 | **/\r | |
665 | EFI_STATUS\r | |
666 | EFIAPI\r | |
667 | FatWrite (\r | |
668 | IN EFI_FILE_PROTOCOL *FHand,\r | |
669 | IN OUT UINTN *BufferSize,\r | |
670 | IN VOID *Buffer\r | |
671 | )\r | |
672 | ;\r | |
673 | \r | |
674 | /**\r | |
675 | \r | |
676 | Get the file info.\r | |
677 | \r | |
678 | @param FHand - The handle of the file.\r | |
679 | @param Token - A pointer to the token associated with the transaction.\r | |
680 | \r | |
681 | @retval EFI_SUCCESS - Get the file info successfully.\r | |
682 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
683 | @retval EFI_VOLUME_CORRUPTED - The file type of open file is error.\r | |
684 | @return other - An error occurred when operation the disk.\r | |
685 | \r | |
686 | **/\r | |
687 | EFI_STATUS\r | |
688 | EFIAPI\r | |
689 | FatWriteEx (\r | |
690 | IN EFI_FILE_PROTOCOL *FHand,\r | |
691 | IN OUT EFI_FILE_IO_TOKEN *Token\r | |
692 | )\r | |
693 | ;\r | |
694 | \r | |
695 | //\r | |
696 | // DiskCache.c\r | |
697 | //\r | |
698 | \r | |
699 | /**\r | |
700 | \r | |
701 | Initialize the disk cache according to Volume's FatType.\r | |
702 | \r | |
703 | @param Volume - FAT file system volume.\r | |
704 | \r | |
705 | @retval EFI_SUCCESS - The disk cache is successfully initialized.\r | |
706 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to allocate disk cache.\r | |
707 | \r | |
708 | **/\r | |
709 | EFI_STATUS\r | |
710 | FatInitializeDiskCache (\r | |
711 | IN FAT_VOLUME *Volume\r | |
712 | );\r | |
713 | \r | |
714 | /**\r | |
715 | \r | |
716 | Read BufferSize bytes from the position of Offset into Buffer,\r | |
717 | or write BufferSize bytes from Buffer into the position of Offset.\r | |
718 | \r | |
719 | Base on the parameter of CACHE_DATA_TYPE, the data access will be divided into\r | |
720 | the access of FAT cache (CACHE_FAT) and the access of Data cache (CACHE_DATA):\r | |
721 | \r | |
722 | 1. Access of FAT cache (CACHE_FAT): Access the data in the FAT cache, if there is cache\r | |
723 | page hit, just return the cache page; else update the related cache page and return\r | |
724 | the right cache page.\r | |
725 | 2. Access of Data cache (CACHE_DATA):\r | |
726 | The access data will be divided into UnderRun data, Aligned data and OverRun data;\r | |
727 | The UnderRun data and OverRun data will be accessed by the Data cache,\r | |
728 | but the Aligned data will be accessed with disk directly.\r | |
729 | \r | |
730 | @param Volume - FAT file system volume.\r | |
731 | @param CacheDataType - The type of cache: CACHE_DATA or CACHE_FAT.\r | |
732 | @param IoMode - Indicate the type of disk access.\r | |
733 | @param Offset - The starting byte offset to read from.\r | |
734 | @param BufferSize - Size of Buffer.\r | |
735 | @param Buffer - Buffer containing cache data.\r | |
736 | @param Task point to task instance.\r | |
737 | \r | |
738 | @retval EFI_SUCCESS - The data was accessed correctly.\r | |
739 | @retval EFI_MEDIA_CHANGED - The MediaId does not match the current device.\r | |
740 | @return Others - An error occurred when accessing cache.\r | |
741 | \r | |
742 | **/\r | |
743 | EFI_STATUS\r | |
744 | FatAccessCache (\r | |
745 | IN FAT_VOLUME *Volume,\r | |
746 | IN CACHE_DATA_TYPE CacheDataType,\r | |
747 | IN IO_MODE IoMode,\r | |
748 | IN UINT64 Offset,\r | |
749 | IN UINTN BufferSize,\r | |
750 | IN OUT UINT8 *Buffer,\r | |
751 | IN FAT_TASK *Task\r | |
752 | );\r | |
753 | \r | |
754 | /**\r | |
755 | \r | |
756 | Flush all the dirty cache back, include the FAT cache and the Data cache.\r | |
757 | \r | |
758 | @param Volume - FAT file system volume.\r | |
759 | @param Task point to task instance.\r | |
760 | \r | |
761 | @retval EFI_SUCCESS - Flush all the dirty cache back successfully\r | |
762 | @return other - An error occurred when writing the data into the disk\r | |
763 | \r | |
764 | **/\r | |
765 | EFI_STATUS\r | |
766 | FatVolumeFlushCache (\r | |
767 | IN FAT_VOLUME *Volume,\r | |
768 | IN FAT_TASK *Task\r | |
769 | );\r | |
770 | \r | |
771 | //\r | |
772 | // Flush.c\r | |
773 | //\r | |
774 | \r | |
775 | /**\r | |
776 | \r | |
777 | Flush the data associated with an open file.\r | |
778 | In this implementation, only last Mod/Access time is updated.\r | |
779 | \r | |
780 | @param OFile - The open file.\r | |
781 | \r | |
782 | @retval EFI_SUCCESS - The OFile is flushed successfully.\r | |
783 | @return Others - An error occurred when flushing this OFile.\r | |
784 | \r | |
785 | **/\r | |
786 | EFI_STATUS\r | |
787 | FatOFileFlush (\r | |
788 | IN FAT_OFILE *OFile\r | |
789 | );\r | |
790 | \r | |
791 | /**\r | |
792 | \r | |
793 | Check the references of the OFile.\r | |
794 | If the OFile (that is checked) is no longer\r | |
795 | referenced, then it is freed.\r | |
796 | \r | |
797 | @param OFile - The OFile to be checked.\r | |
798 | \r | |
799 | @retval TRUE - The OFile is not referenced and freed.\r | |
800 | @retval FALSE - The OFile is kept.\r | |
801 | \r | |
802 | **/\r | |
803 | BOOLEAN\r | |
804 | FatCheckOFileRef (\r | |
805 | IN FAT_OFILE *OFile\r | |
806 | );\r | |
807 | \r | |
808 | /**\r | |
809 | \r | |
810 | Set the OFile and its child OFile with the error Status\r | |
811 | \r | |
812 | @param OFile - The OFile whose permanent error code is to be set.\r | |
813 | @param Status - Error code to be set.\r | |
814 | \r | |
815 | **/\r | |
816 | VOID\r | |
817 | FatSetVolumeError (\r | |
818 | IN FAT_OFILE *OFile,\r | |
819 | IN EFI_STATUS Status\r | |
820 | );\r | |
821 | \r | |
822 | /**\r | |
823 | \r | |
824 | Close the open file instance.\r | |
825 | \r | |
826 | @param IFile - Open file instance.\r | |
827 | \r | |
828 | @retval EFI_SUCCESS - Closed the file successfully.\r | |
829 | \r | |
830 | **/\r | |
831 | EFI_STATUS\r | |
832 | FatIFileClose (\r | |
833 | FAT_IFILE *IFile\r | |
834 | );\r | |
835 | \r | |
836 | /**\r | |
837 | \r | |
838 | Set error status for a specific OFile, reference checking the volume.\r | |
839 | If volume is already marked as invalid, and all resources are freed\r | |
840 | after reference checking, the file system protocol is uninstalled and\r | |
841 | the volume structure is freed.\r | |
842 | \r | |
843 | @param Volume - the Volume that is to be reference checked and unlocked.\r | |
844 | @param OFile - the OFile whose permanent error code is to be set.\r | |
845 | @param EfiStatus - error code to be set.\r | |
846 | @param Task point to task instance.\r | |
847 | \r | |
848 | @retval EFI_SUCCESS - Clean up the volume successfully.\r | |
849 | @return Others - Cleaning up of the volume is failed.\r | |
850 | \r | |
851 | **/\r | |
852 | EFI_STATUS\r | |
853 | FatCleanupVolume (\r | |
854 | IN FAT_VOLUME *Volume,\r | |
855 | IN FAT_OFILE *OFile,\r | |
856 | IN EFI_STATUS EfiStatus,\r | |
857 | IN FAT_TASK *Task\r | |
858 | );\r | |
859 | \r | |
860 | //\r | |
861 | // FileSpace.c\r | |
862 | //\r | |
863 | \r | |
864 | /**\r | |
865 | \r | |
866 | Shrink the end of the open file base on the file size.\r | |
867 | \r | |
868 | @param OFile - The open file.\r | |
869 | \r | |
870 | @retval EFI_SUCCESS - Shrinked successfully.\r | |
871 | @retval EFI_VOLUME_CORRUPTED - There are errors in the file's clusters.\r | |
872 | \r | |
873 | **/\r | |
874 | EFI_STATUS\r | |
875 | FatShrinkEof (\r | |
876 | IN FAT_OFILE *OFile\r | |
877 | );\r | |
878 | \r | |
879 | /**\r | |
880 | \r | |
881 | Grow the end of the open file base on the NewSizeInBytes.\r | |
882 | \r | |
883 | @param OFile - The open file.\r | |
884 | @param NewSizeInBytes - The new size in bytes of the open file.\r | |
885 | \r | |
886 | @retval EFI_SUCCESS - The file is grown successfully.\r | |
887 | @retval EFI_UNSUPPORTED - The file size is larger than 4GB.\r | |
888 | @retval EFI_VOLUME_CORRUPTED - There are errors in the files' clusters.\r | |
889 | @retval EFI_VOLUME_FULL - The volume is full and can not grow the file.\r | |
890 | \r | |
891 | **/\r | |
892 | EFI_STATUS\r | |
893 | FatGrowEof (\r | |
894 | IN FAT_OFILE *OFile,\r | |
895 | IN UINT64 NewSizeInBytes\r | |
896 | );\r | |
897 | \r | |
898 | /**\r | |
899 | \r | |
900 | Get the size of directory of the open file.\r | |
901 | \r | |
902 | @param Volume - The File System Volume.\r | |
903 | @param Cluster - The Starting cluster.\r | |
904 | \r | |
905 | @return The physical size of the file starting at the input cluster, if there is error in the\r | |
906 | cluster chain, the return value is 0.\r | |
907 | \r | |
908 | **/\r | |
909 | UINTN\r | |
910 | FatPhysicalDirSize (\r | |
911 | IN FAT_VOLUME *Volume,\r | |
912 | IN UINTN Cluster\r | |
913 | );\r | |
914 | \r | |
915 | /**\r | |
916 | \r | |
917 | Get the physical size of a file on the disk.\r | |
918 | \r | |
919 | @param Volume - The file system volume.\r | |
920 | @param RealSize - The real size of a file.\r | |
921 | \r | |
922 | @return The physical size of a file on the disk.\r | |
923 | \r | |
924 | **/\r | |
925 | UINT64\r | |
926 | FatPhysicalFileSize (\r | |
927 | IN FAT_VOLUME *Volume,\r | |
928 | IN UINTN RealSize\r | |
929 | );\r | |
930 | \r | |
931 | /**\r | |
932 | \r | |
933 | Seek OFile to requested position, and calculate the number of\r | |
934 | consecutive clusters from the position in the file\r | |
935 | \r | |
936 | @param OFile - The open file.\r | |
937 | @param Position - The file's position which will be accessed.\r | |
938 | @param PosLimit - The maximum length current reading/writing may access\r | |
939 | \r | |
940 | @retval EFI_SUCCESS - Set the info successfully.\r | |
941 | @retval EFI_VOLUME_CORRUPTED - Cluster chain corrupt.\r | |
942 | \r | |
943 | **/\r | |
944 | EFI_STATUS\r | |
945 | FatOFilePosition (\r | |
946 | IN FAT_OFILE *OFile,\r | |
947 | IN UINTN Position,\r | |
948 | IN UINTN PosLimit\r | |
949 | );\r | |
950 | \r | |
951 | /**\r | |
952 | \r | |
953 | Update the free cluster info of FatInfoSector of the volume.\r | |
954 | \r | |
955 | @param Volume - FAT file system volume.\r | |
956 | \r | |
957 | **/\r | |
958 | VOID\r | |
959 | FatComputeFreeInfo (\r | |
960 | IN FAT_VOLUME *Volume\r | |
961 | );\r | |
962 | \r | |
963 | //\r | |
964 | // Init.c\r | |
965 | //\r | |
966 | \r | |
967 | /**\r | |
968 | \r | |
969 | Allocates volume structure, detects FAT file system, installs protocol,\r | |
970 | and initialize cache.\r | |
971 | \r | |
972 | @param Handle - The handle of parent device.\r | |
973 | @param DiskIo - The DiskIo of parent device.\r | |
974 | @param DiskIo2 - The DiskIo2 of parent device.\r | |
975 | @param BlockIo - The BlockIo of parent device.\r | |
976 | \r | |
977 | @retval EFI_SUCCESS - Allocate a new volume successfully.\r | |
978 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r | |
979 | @return Others - Allocating a new volume failed.\r | |
980 | \r | |
981 | **/\r | |
982 | EFI_STATUS\r | |
983 | FatAllocateVolume (\r | |
984 | IN EFI_HANDLE Handle,\r | |
985 | IN EFI_DISK_IO_PROTOCOL *DiskIo,\r | |
986 | IN EFI_DISK_IO2_PROTOCOL *DiskIo2,\r | |
987 | IN EFI_BLOCK_IO_PROTOCOL *BlockIo\r | |
988 | );\r | |
989 | \r | |
990 | /**\r | |
991 | \r | |
992 | Detects FAT file system on Disk and set relevant fields of Volume.\r | |
993 | \r | |
994 | @param Volume - The volume structure.\r | |
995 | \r | |
996 | @retval EFI_SUCCESS - The Fat File System is detected successfully\r | |
997 | @retval EFI_UNSUPPORTED - The volume is not FAT file system.\r | |
998 | @retval EFI_VOLUME_CORRUPTED - The volume is corrupted.\r | |
999 | \r | |
1000 | **/\r | |
1001 | EFI_STATUS\r | |
1002 | FatOpenDevice (\r | |
1003 | IN OUT FAT_VOLUME *Volume\r | |
1004 | );\r | |
1005 | \r | |
1006 | /**\r | |
1007 | \r | |
1008 | Called by FatDriverBindingStop(), Abandon the volume.\r | |
1009 | \r | |
1010 | @param Volume - The volume to be abandoned.\r | |
1011 | \r | |
1012 | @retval EFI_SUCCESS - Abandoned the volume successfully.\r | |
1013 | @return Others - Can not uninstall the protocol interfaces.\r | |
1014 | \r | |
1015 | **/\r | |
1016 | EFI_STATUS\r | |
1017 | FatAbandonVolume (\r | |
1018 | IN FAT_VOLUME *Volume\r | |
1019 | );\r | |
1020 | \r | |
1021 | //\r | |
1022 | // Misc.c\r | |
1023 | //\r | |
1024 | \r | |
1025 | /**\r | |
1026 | \r | |
1027 | Create the task\r | |
1028 | \r | |
1029 | @param IFile - The instance of the open file.\r | |
1030 | @param Token - A pointer to the token associated with the transaction.\r | |
1031 | \r | |
1032 | @return FAT_TASK * - Return the task instance.\r | |
1033 | \r | |
1034 | **/\r | |
1035 | FAT_TASK *\r | |
1036 | FatCreateTask (\r | |
1037 | FAT_IFILE *IFile,\r | |
1038 | EFI_FILE_IO_TOKEN *Token\r | |
1039 | );\r | |
1040 | \r | |
1041 | /**\r | |
1042 | \r | |
1043 | Destroy the task.\r | |
1044 | \r | |
1045 | @param Task - The task to be destroyed.\r | |
1046 | \r | |
1047 | **/\r | |
1048 | VOID\r | |
1049 | FatDestroyTask (\r | |
1050 | FAT_TASK *Task\r | |
1051 | );\r | |
1052 | \r | |
1053 | /**\r | |
1054 | \r | |
1055 | Wait all non-blocking requests complete.\r | |
1056 | \r | |
1057 | @param IFile - The instance of the open file.\r | |
1058 | \r | |
1059 | **/\r | |
1060 | VOID\r | |
1061 | FatWaitNonblockingTask (\r | |
1062 | FAT_IFILE *IFile\r | |
1063 | );\r | |
1064 | \r | |
1065 | /**\r | |
1066 | \r | |
1067 | Remove the subtask from subtask list.\r | |
1068 | \r | |
1069 | @param Subtask - The subtask to be removed.\r | |
1070 | \r | |
1071 | @return LIST_ENTRY * - The next node in the list.\r | |
1072 | \r | |
1073 | **/\r | |
1074 | LIST_ENTRY *\r | |
1075 | FatDestroySubtask (\r | |
1076 | FAT_SUBTASK *Subtask\r | |
1077 | );\r | |
1078 | \r | |
1079 | /**\r | |
1080 | \r | |
1081 | Execute the task.\r | |
1082 | \r | |
1083 | @param IFile - The instance of the open file.\r | |
1084 | @param Task - The task to be executed.\r | |
1085 | \r | |
1086 | @retval EFI_SUCCESS - The task was executed successfully.\r | |
1087 | @return other - An error occurred when executing the task.\r | |
1088 | \r | |
1089 | **/\r | |
1090 | EFI_STATUS\r | |
1091 | FatQueueTask (\r | |
1092 | IN FAT_IFILE *IFile,\r | |
1093 | IN FAT_TASK *Task\r | |
1094 | );\r | |
1095 | \r | |
1096 | /**\r | |
1097 | \r | |
1098 | Set the volume as dirty or not.\r | |
1099 | \r | |
1100 | @param Volume - FAT file system volume.\r | |
1101 | @param IoMode - The access mode.\r | |
1102 | @param DirtyValue - Set the volume as dirty or not.\r | |
1103 | \r | |
1104 | @retval EFI_SUCCESS - Set the new FAT entry value successfully.\r | |
1105 | @return other - An error occurred when operation the FAT entries.\r | |
1106 | \r | |
1107 | **/\r | |
1108 | EFI_STATUS\r | |
1109 | FatAccessVolumeDirty (\r | |
1110 | IN FAT_VOLUME *Volume,\r | |
1111 | IN IO_MODE IoMode,\r | |
1112 | IN VOID *DirtyValue\r | |
1113 | );\r | |
1114 | \r | |
1115 | /**\r | |
1116 | \r | |
1117 | General disk access function.\r | |
1118 | \r | |
1119 | @param Volume - FAT file system volume.\r | |
1120 | @param IoMode - The access mode (disk read/write or cache access).\r | |
1121 | @param Offset - The starting byte offset to read from.\r | |
1122 | @param BufferSize - Size of Buffer.\r | |
1123 | @param Buffer - Buffer containing read data.\r | |
1124 | @param Task point to task instance.\r | |
1125 | \r | |
1126 | @retval EFI_SUCCESS - The operation is performed successfully.\r | |
1127 | @retval EFI_VOLUME_CORRUPTED - The access is\r | |
1128 | @return Others - The status of read/write the disk\r | |
1129 | \r | |
1130 | **/\r | |
1131 | EFI_STATUS\r | |
1132 | FatDiskIo (\r | |
1133 | IN FAT_VOLUME *Volume,\r | |
1134 | IN IO_MODE IoMode,\r | |
1135 | IN UINT64 Offset,\r | |
1136 | IN UINTN BufferSize,\r | |
1137 | IN OUT VOID *Buffer,\r | |
1138 | IN FAT_TASK *Task\r | |
1139 | );\r | |
1140 | \r | |
1141 | /**\r | |
1142 | \r | |
1143 | Lock the volume.\r | |
1144 | \r | |
1145 | **/\r | |
1146 | VOID\r | |
1147 | FatAcquireLock (\r | |
1148 | VOID\r | |
1149 | );\r | |
1150 | \r | |
1151 | /**\r | |
1152 | \r | |
1153 | Unlock the volume.\r | |
1154 | \r | |
1155 | **/\r | |
1156 | VOID\r | |
1157 | FatReleaseLock (\r | |
1158 | VOID\r | |
1159 | );\r | |
1160 | \r | |
1161 | /**\r | |
1162 | \r | |
1163 | Lock the volume.\r | |
1164 | If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned.\r | |
1165 | Otherwise, EFI_SUCCESS is returned.\r | |
1166 | \r | |
1167 | @retval EFI_SUCCESS - The volume is locked.\r | |
1168 | @retval EFI_ACCESS_DENIED - The volume could not be locked because it is already locked.\r | |
1169 | \r | |
1170 | **/\r | |
1171 | EFI_STATUS\r | |
1172 | FatAcquireLockOrFail (\r | |
1173 | VOID\r | |
1174 | );\r | |
1175 | \r | |
1176 | /**\r | |
1177 | \r | |
1178 | Free directory entry.\r | |
1179 | \r | |
1180 | @param DirEnt - The directory entry to be freed.\r | |
1181 | \r | |
1182 | **/\r | |
1183 | VOID\r | |
1184 | FatFreeDirEnt (\r | |
1185 | IN FAT_DIRENT *DirEnt\r | |
1186 | );\r | |
1187 | \r | |
1188 | /**\r | |
1189 | \r | |
1190 | Free volume structure (including the contents of directory cache and disk cache).\r | |
1191 | \r | |
1192 | @param Volume - The volume structure to be freed.\r | |
1193 | \r | |
1194 | **/\r | |
1195 | VOID\r | |
1196 | FatFreeVolume (\r | |
1197 | IN FAT_VOLUME *Volume\r | |
1198 | );\r | |
1199 | \r | |
1200 | /**\r | |
1201 | \r | |
1202 | Translate EFI time to FAT time.\r | |
1203 | \r | |
1204 | @param ETime - The time of EFI_TIME.\r | |
1205 | @param FTime - The time of FAT_DATE_TIME.\r | |
1206 | \r | |
1207 | **/\r | |
1208 | VOID\r | |
1209 | FatEfiTimeToFatTime (\r | |
1210 | IN EFI_TIME *ETime,\r | |
1211 | OUT FAT_DATE_TIME *FTime\r | |
1212 | );\r | |
1213 | \r | |
1214 | /**\r | |
1215 | \r | |
1216 | Translate Fat time to EFI time.\r | |
1217 | \r | |
1218 | @param FTime - The time of FAT_DATE_TIME.\r | |
1219 | @param ETime - The time of EFI_TIME..\r | |
1220 | \r | |
1221 | **/\r | |
1222 | VOID\r | |
1223 | FatFatTimeToEfiTime (\r | |
1224 | IN FAT_DATE_TIME *FTime,\r | |
1225 | OUT EFI_TIME *ETime\r | |
1226 | );\r | |
1227 | \r | |
1228 | /**\r | |
1229 | \r | |
1230 | Get Current FAT time.\r | |
1231 | \r | |
1232 | @param FatTime - Current FAT time.\r | |
1233 | \r | |
1234 | **/\r | |
1235 | VOID\r | |
1236 | FatGetCurrentFatTime (\r | |
1237 | OUT FAT_DATE_TIME *FatTime\r | |
1238 | );\r | |
1239 | \r | |
1240 | /**\r | |
1241 | \r | |
1242 | Check whether a time is valid.\r | |
1243 | \r | |
1244 | @param Time - The time of EFI_TIME.\r | |
1245 | \r | |
1246 | @retval TRUE - The time is valid.\r | |
1247 | @retval FALSE - The time is not valid.\r | |
1248 | \r | |
1249 | **/\r | |
1250 | BOOLEAN\r | |
1251 | FatIsValidTime (\r | |
1252 | IN EFI_TIME *Time\r | |
1253 | );\r | |
1254 | \r | |
1255 | //\r | |
1256 | // UnicodeCollation.c\r | |
1257 | //\r | |
1258 | \r | |
1259 | /**\r | |
1260 | Initialize Unicode Collation support.\r | |
1261 | \r | |
1262 | It tries to locate Unicode Collation 2 protocol and matches it with current\r | |
1263 | platform language code. If for any reason the first attempt fails, it then tries to\r | |
1264 | use Unicode Collation Protocol.\r | |
1265 | \r | |
1266 | @param AgentHandle The handle used to open Unicode Collation (2) protocol.\r | |
1267 | \r | |
1268 | @retval EFI_SUCCESS The Unicode Collation (2) protocol has been successfully located.\r | |
1269 | @retval Others The Unicode Collation (2) protocol has not been located.\r | |
1270 | \r | |
1271 | **/\r | |
1272 | EFI_STATUS\r | |
1273 | InitializeUnicodeCollationSupport (\r | |
1274 | IN EFI_HANDLE AgentHandle\r | |
1275 | );\r | |
1276 | \r | |
1277 | /**\r | |
1278 | Convert FAT string to unicode string.\r | |
1279 | \r | |
1280 | @param FatSize The size of FAT string.\r | |
1281 | @param Fat The FAT string.\r | |
1282 | @param String The unicode string.\r | |
1283 | \r | |
1284 | @return None.\r | |
1285 | \r | |
1286 | **/\r | |
1287 | VOID\r | |
1288 | FatFatToStr (\r | |
1289 | IN UINTN FatSize,\r | |
1290 | IN CHAR8 *Fat,\r | |
1291 | OUT CHAR16 *String\r | |
1292 | );\r | |
1293 | \r | |
1294 | /**\r | |
1295 | Convert unicode string to Fat string.\r | |
1296 | \r | |
1297 | @param String The unicode string.\r | |
1298 | @param FatSize The size of the FAT string.\r | |
1299 | @param Fat The FAT string.\r | |
1300 | \r | |
1301 | @retval TRUE Convert successfully.\r | |
1302 | @retval FALSE Convert error.\r | |
1303 | \r | |
1304 | **/\r | |
1305 | BOOLEAN\r | |
1306 | FatStrToFat (\r | |
1307 | IN CHAR16 *String,\r | |
1308 | IN UINTN FatSize,\r | |
1309 | OUT CHAR8 *Fat\r | |
1310 | );\r | |
1311 | \r | |
1312 | /**\r | |
1313 | Lowercase a string\r | |
1314 | \r | |
1315 | @param Str The string which will be lower-cased.\r | |
1316 | \r | |
1317 | **/\r | |
1318 | VOID\r | |
1319 | FatStrLwr (\r | |
1320 | IN CHAR16 *Str\r | |
1321 | );\r | |
1322 | \r | |
1323 | /**\r | |
1324 | Uppercase a string.\r | |
1325 | \r | |
1326 | @param Str The string which will be upper-cased.\r | |
1327 | \r | |
1328 | **/\r | |
1329 | VOID\r | |
1330 | FatStrUpr (\r | |
1331 | IN CHAR16 *Str\r | |
1332 | );\r | |
1333 | \r | |
1334 | /**\r | |
1335 | Performs a case-insensitive comparison of two Null-terminated Unicode strings.\r | |
1336 | \r | |
1337 | @param Str1 A pointer to a Null-terminated Unicode string.\r | |
1338 | @param Str2 A pointer to a Null-terminated Unicode string.\r | |
1339 | \r | |
1340 | @retval 0 S1 is equivalent to S2.\r | |
1341 | @retval >0 S1 is lexically greater than S2.\r | |
1342 | @retval <0 S1 is lexically less than S2.\r | |
1343 | **/\r | |
1344 | INTN\r | |
1345 | FatStriCmp (\r | |
1346 | IN CHAR16 *Str1,\r | |
1347 | IN CHAR16 *Str2\r | |
1348 | );\r | |
1349 | \r | |
1350 | //\r | |
1351 | // Open.c\r | |
1352 | //\r | |
1353 | \r | |
1354 | /**\r | |
1355 | \r | |
1356 | Open a file for a file name relative to an existing OFile.\r | |
1357 | The IFile of the newly opened file is passed out.\r | |
1358 | \r | |
1359 | @param OFile - The file that serves as a starting reference point.\r | |
1360 | @param NewIFile - The newly generated IFile instance.\r | |
1361 | @param FileName - The file name relative to the OFile.\r | |
1362 | @param OpenMode - Open mode.\r | |
1363 | @param Attributes - Attributes to set if the file is created.\r | |
1364 | \r | |
1365 | \r | |
1366 | @retval EFI_SUCCESS - Open the file successfully.\r | |
1367 | @retval EFI_INVALID_PARAMETER - The open mode is conflict with the attributes\r | |
1368 | or the file name is not valid.\r | |
1369 | @retval EFI_NOT_FOUND - Conflicts between dir intention and attribute.\r | |
1370 | @retval EFI_WRITE_PROTECTED - Can't open for write if the volume is read only.\r | |
1371 | @retval EFI_ACCESS_DENIED - If the file's attribute is read only, and the\r | |
1372 | open is for read-write fail it.\r | |
1373 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r | |
1374 | \r | |
1375 | **/\r | |
1376 | EFI_STATUS\r | |
1377 | FatOFileOpen (\r | |
1378 | IN FAT_OFILE *OFile,\r | |
1379 | OUT FAT_IFILE **NewIFile,\r | |
1380 | IN CHAR16 *FileName,\r | |
1381 | IN UINT64 OpenMode,\r | |
1382 | IN UINT8 Attributes\r | |
1383 | );\r | |
1384 | \r | |
1385 | /**\r | |
1386 | \r | |
1387 | Create an Open instance for the existing OFile.\r | |
1388 | The IFile of the newly opened file is passed out.\r | |
1389 | \r | |
1390 | @param OFile - The file that serves as a starting reference point.\r | |
1391 | @param PtrIFile - The newly generated IFile instance.\r | |
1392 | \r | |
1393 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory for the IFile\r | |
1394 | @retval EFI_SUCCESS - Create the new IFile for the OFile successfully\r | |
1395 | \r | |
1396 | **/\r | |
1397 | EFI_STATUS\r | |
1398 | FatAllocateIFile (\r | |
1399 | IN FAT_OFILE *OFile,\r | |
1400 | OUT FAT_IFILE **PtrIFile\r | |
1401 | );\r | |
1402 | \r | |
1403 | //\r | |
1404 | // OpenVolume.c\r | |
1405 | //\r | |
1406 | \r | |
1407 | /**\r | |
1408 | \r | |
1409 | Implements Simple File System Protocol interface function OpenVolume().\r | |
1410 | \r | |
1411 | @param This - Calling context.\r | |
1412 | @param File - the Root Directory of the volume.\r | |
1413 | \r | |
1414 | @retval EFI_OUT_OF_RESOURCES - Can not allocate the memory.\r | |
1415 | @retval EFI_VOLUME_CORRUPTED - The FAT type is error.\r | |
1416 | @retval EFI_SUCCESS - Open the volume successfully.\r | |
1417 | \r | |
1418 | **/\r | |
1419 | EFI_STATUS\r | |
1420 | EFIAPI\r | |
1421 | FatOpenVolume (\r | |
1422 | IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This,\r | |
1423 | OUT EFI_FILE_PROTOCOL **File\r | |
1424 | );\r | |
1425 | \r | |
1426 | //\r | |
1427 | // ReadWrite.c\r | |
1428 | //\r | |
1429 | \r | |
1430 | /**\r | |
1431 | \r | |
1432 | This function reads data from a file or writes data to a file.\r | |
1433 | It uses OFile->PosRem to determine how much data can be accessed in one time.\r | |
1434 | \r | |
1435 | @param OFile - The open file.\r | |
1436 | @param IoMode - Indicate whether the access mode is reading or writing.\r | |
1437 | @param Position - The position where data will be accessed.\r | |
1438 | @param DataBufferSize - Size of Buffer.\r | |
1439 | @param UserBuffer - Buffer containing data.\r | |
1440 | @param Task point to task instance.\r | |
1441 | \r | |
1442 | @retval EFI_SUCCESS - Access the data successfully.\r | |
1443 | @return other - An error occurred when operating on the disk.\r | |
1444 | \r | |
1445 | **/\r | |
1446 | EFI_STATUS\r | |
1447 | FatAccessOFile (\r | |
1448 | IN FAT_OFILE *OFile,\r | |
1449 | IN IO_MODE IoMode,\r | |
1450 | IN UINTN Position,\r | |
1451 | IN UINTN *DataBufferSize,\r | |
1452 | IN UINT8 *UserBuffer,\r | |
1453 | IN FAT_TASK *Task\r | |
1454 | );\r | |
1455 | \r | |
1456 | /**\r | |
1457 | \r | |
1458 | Expand OFile by appending zero bytes at the end of OFile.\r | |
1459 | \r | |
1460 | @param OFile - The open file.\r | |
1461 | @param ExpandedSize - The number of zero bytes appended at the end of the file.\r | |
1462 | \r | |
1463 | @retval EFI_SUCCESS - The file is expanded successfully.\r | |
1464 | @return other - An error occurred when expanding file.\r | |
1465 | \r | |
1466 | **/\r | |
1467 | EFI_STATUS\r | |
1468 | FatExpandOFile (\r | |
1469 | IN FAT_OFILE *OFile,\r | |
1470 | IN UINT64 ExpandedSize\r | |
1471 | );\r | |
1472 | \r | |
1473 | /**\r | |
1474 | \r | |
1475 | Write zero pool from the WritePos to the end of OFile.\r | |
1476 | \r | |
1477 | @param OFile - The open file to write zero pool.\r | |
1478 | @param WritePos - The number of zero bytes written.\r | |
1479 | \r | |
1480 | @retval EFI_SUCCESS - Write the zero pool successfully.\r | |
1481 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to perform the operation.\r | |
1482 | @return other - An error occurred when writing disk.\r | |
1483 | \r | |
1484 | **/\r | |
1485 | EFI_STATUS\r | |
1486 | FatWriteZeroPool (\r | |
1487 | IN FAT_OFILE *OFile,\r | |
1488 | IN UINTN WritePos\r | |
1489 | );\r | |
1490 | \r | |
1491 | /**\r | |
1492 | \r | |
1493 | Truncate the OFile to smaller file size.\r | |
1494 | \r | |
1495 | @param OFile - The open file.\r | |
1496 | @param TruncatedSize - The new file size.\r | |
1497 | \r | |
1498 | @retval EFI_SUCCESS - The file is truncated successfully.\r | |
1499 | @return other - An error occurred when truncating file.\r | |
1500 | \r | |
1501 | **/\r | |
1502 | EFI_STATUS\r | |
1503 | FatTruncateOFile (\r | |
1504 | IN FAT_OFILE *OFile,\r | |
1505 | IN UINTN TruncatedSize\r | |
1506 | );\r | |
1507 | \r | |
1508 | //\r | |
1509 | // DirectoryManage.c\r | |
1510 | //\r | |
1511 | \r | |
1512 | /**\r | |
1513 | \r | |
1514 | Set the OFile's current directory cursor to the list head.\r | |
1515 | \r | |
1516 | @param OFile - The directory OFile whose directory cursor is reset.\r | |
1517 | \r | |
1518 | **/\r | |
1519 | VOID\r | |
1520 | FatResetODirCursor (\r | |
1521 | IN FAT_OFILE *OFile\r | |
1522 | );\r | |
1523 | \r | |
1524 | /**\r | |
1525 | \r | |
1526 | Set the directory's cursor to the next and get the next directory entry.\r | |
1527 | \r | |
1528 | @param OFile - The parent OFile.\r | |
1529 | @param PtrDirEnt - The next directory entry.\r | |
1530 | \r | |
1531 | @retval EFI_SUCCESS - We get the next directory entry successfully.\r | |
1532 | @return other - An error occurred when get next directory entry.\r | |
1533 | \r | |
1534 | **/\r | |
1535 | EFI_STATUS\r | |
1536 | FatGetNextDirEnt (\r | |
1537 | IN FAT_OFILE *OFile,\r | |
1538 | OUT FAT_DIRENT **PtrDirEnt\r | |
1539 | );\r | |
1540 | \r | |
1541 | /**\r | |
1542 | \r | |
1543 | Remove this directory entry node from the list of directory entries and hash table.\r | |
1544 | \r | |
1545 | @param OFile - The parent OFile.\r | |
1546 | @param DirEnt - The directory entry to be removed.\r | |
1547 | \r | |
1548 | @retval EFI_SUCCESS - The directory entry is successfully removed.\r | |
1549 | @return other - An error occurred when removing the directory entry.\r | |
1550 | \r | |
1551 | **/\r | |
1552 | EFI_STATUS\r | |
1553 | FatRemoveDirEnt (\r | |
1554 | IN FAT_OFILE *OFile,\r | |
1555 | IN FAT_DIRENT *DirEnt\r | |
1556 | );\r | |
1557 | \r | |
1558 | /**\r | |
1559 | \r | |
1560 | Save the directory entry to disk.\r | |
1561 | \r | |
1562 | @param OFile - The parent OFile which needs to update.\r | |
1563 | @param DirEnt - The directory entry to be saved.\r | |
1564 | \r | |
1565 | @retval EFI_SUCCESS - Store the directory entry successfully.\r | |
1566 | @return other - An error occurred when writing the directory entry.\r | |
1567 | \r | |
1568 | **/\r | |
1569 | EFI_STATUS\r | |
1570 | FatStoreDirEnt (\r | |
1571 | IN FAT_OFILE *OFile,\r | |
1572 | IN FAT_DIRENT *DirEnt\r | |
1573 | );\r | |
1574 | \r | |
1575 | /**\r | |
1576 | \r | |
1577 | Create a directory entry in the parent OFile.\r | |
1578 | \r | |
1579 | @param OFile - The parent OFile.\r | |
1580 | @param FileName - The filename of the newly-created directory entry.\r | |
1581 | @param Attributes - The attribute of the newly-created directory entry.\r | |
1582 | @param PtrDirEnt - The pointer to the newly-created directory entry.\r | |
1583 | \r | |
1584 | @retval EFI_SUCCESS - The directory entry is successfully created.\r | |
1585 | @retval EFI_OUT_OF_RESOURCES - Not enough memory to create the directory entry.\r | |
1586 | @return other - An error occurred when creating the directory entry.\r | |
1587 | \r | |
1588 | **/\r | |
1589 | EFI_STATUS\r | |
1590 | FatCreateDirEnt (\r | |
1591 | IN FAT_OFILE *OFile,\r | |
1592 | IN CHAR16 *FileName,\r | |
1593 | IN UINT8 Attributes,\r | |
1594 | OUT FAT_DIRENT **PtrDirEnt\r | |
1595 | );\r | |
1596 | \r | |
1597 | /**\r | |
1598 | \r | |
1599 | Determine whether the directory entry is "." or ".." entry.\r | |
1600 | \r | |
1601 | @param DirEnt - The corresponding directory entry.\r | |
1602 | \r | |
1603 | @retval TRUE - The directory entry is "." or ".." directory entry\r | |
1604 | @retval FALSE - The directory entry is not "." or ".." directory entry\r | |
1605 | \r | |
1606 | **/\r | |
1607 | BOOLEAN\r | |
1608 | FatIsDotDirEnt (\r | |
1609 | IN FAT_DIRENT *DirEnt\r | |
1610 | );\r | |
1611 | \r | |
1612 | /**\r | |
1613 | \r | |
1614 | Set the OFile's cluster and size info in its directory entry.\r | |
1615 | \r | |
1616 | @param OFile - The corresponding OFile.\r | |
1617 | \r | |
1618 | **/\r | |
1619 | VOID\r | |
1620 | FatUpdateDirEntClusterSizeInfo (\r | |
1621 | IN FAT_OFILE *OFile\r | |
1622 | );\r | |
1623 | \r | |
1624 | /**\r | |
1625 | \r | |
1626 | Copy all the information of DirEnt2 to DirEnt1 except for 8.3 name.\r | |
1627 | \r | |
1628 | @param DirEnt1 - The destination directory entry.\r | |
1629 | @param DirEnt2 - The source directory entry.\r | |
1630 | \r | |
1631 | **/\r | |
1632 | VOID\r | |
1633 | FatCloneDirEnt (\r | |
1634 | IN FAT_DIRENT *DirEnt1,\r | |
1635 | IN FAT_DIRENT *DirEnt2\r | |
1636 | );\r | |
1637 | \r | |
1638 | /**\r | |
1639 | \r | |
1640 | Get the directory entry's info into Buffer.\r | |
1641 | \r | |
1642 | @param Volume - FAT file system volume.\r | |
1643 | @param DirEnt - The corresponding directory entry.\r | |
1644 | @param BufferSize - Size of Buffer.\r | |
1645 | @param Buffer - Buffer containing file info.\r | |
1646 | \r | |
1647 | @retval EFI_SUCCESS - Get the file info successfully.\r | |
1648 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
1649 | \r | |
1650 | **/\r | |
1651 | EFI_STATUS\r | |
1652 | FatGetDirEntInfo (\r | |
1653 | IN FAT_VOLUME *Volume,\r | |
1654 | IN FAT_DIRENT *DirEnt,\r | |
1655 | IN OUT UINTN *BufferSize,\r | |
1656 | OUT VOID *Buffer\r | |
1657 | );\r | |
1658 | \r | |
1659 | /**\r | |
1660 | \r | |
1661 | Open the directory entry to get the OFile.\r | |
1662 | \r | |
1663 | @param Parent - The parent OFile.\r | |
1664 | @param DirEnt - The directory entry to be opened.\r | |
1665 | \r | |
1666 | @retval EFI_SUCCESS - The directory entry is successfully opened.\r | |
1667 | @retval EFI_OUT_OF_RESOURCES - not enough memory to allocate a new OFile.\r | |
1668 | @return other - An error occurred when opening the directory entry.\r | |
1669 | \r | |
1670 | **/\r | |
1671 | EFI_STATUS\r | |
1672 | FatOpenDirEnt (\r | |
1673 | IN FAT_OFILE *OFile,\r | |
1674 | IN FAT_DIRENT *DirEnt\r | |
1675 | );\r | |
1676 | \r | |
1677 | /**\r | |
1678 | \r | |
1679 | Create "." and ".." directory entries in the newly-created parent OFile.\r | |
1680 | \r | |
1681 | @param OFile - The parent OFile.\r | |
1682 | \r | |
1683 | @retval EFI_SUCCESS - The dot directory entries are successfully created.\r | |
1684 | @return other - An error occurred when creating the directory entry.\r | |
1685 | \r | |
1686 | **/\r | |
1687 | EFI_STATUS\r | |
1688 | FatCreateDotDirEnts (\r | |
1689 | IN FAT_OFILE *OFile\r | |
1690 | );\r | |
1691 | \r | |
1692 | /**\r | |
1693 | \r | |
1694 | Close the directory entry and free the OFile.\r | |
1695 | \r | |
1696 | @param DirEnt - The directory entry to be closed.\r | |
1697 | \r | |
1698 | **/\r | |
1699 | VOID\r | |
1700 | FatCloseDirEnt (\r | |
1701 | IN FAT_DIRENT *DirEnt\r | |
1702 | );\r | |
1703 | \r | |
1704 | /**\r | |
1705 | \r | |
1706 | Traverse filename and open all OFiles that can be opened.\r | |
1707 | Update filename pointer to the component that can't be opened.\r | |
1708 | If more than one name component remains, returns an error;\r | |
1709 | otherwise, return the remaining name component so that the caller might choose to create it.\r | |
1710 | \r | |
1711 | @param PtrOFile - As input, the reference OFile; as output, the located OFile.\r | |
1712 | @param FileName - The file name relevant to the OFile.\r | |
1713 | @param Attributes - The attribute of the destination OFile.\r | |
1714 | @param NewFileName - The remaining file name.\r | |
1715 | \r | |
1716 | @retval EFI_NOT_FOUND - The file name can't be opened and there is more than one\r | |
1717 | components within the name left (this means the name can\r | |
1718 | not be created either).\r | |
1719 | @retval EFI_INVALID_PARAMETER - The parameter is not valid.\r | |
1720 | @retval EFI_SUCCESS - Open the file successfully.\r | |
1721 | @return other - An error occurred when locating the OFile.\r | |
1722 | \r | |
1723 | **/\r | |
1724 | EFI_STATUS\r | |
1725 | FatLocateOFile (\r | |
1726 | IN OUT FAT_OFILE **PtrOFile,\r | |
1727 | IN CHAR16 *FileName,\r | |
1728 | IN UINT8 Attributes,\r | |
1729 | OUT CHAR16 *NewFileName\r | |
1730 | );\r | |
1731 | \r | |
1732 | /**\r | |
1733 | \r | |
1734 | Get the directory entry for the volume.\r | |
1735 | \r | |
1736 | @param Volume - FAT file system volume.\r | |
1737 | @param Name - The file name of the volume.\r | |
1738 | \r | |
1739 | @retval EFI_SUCCESS - Update the volume with the directory entry successfully.\r | |
1740 | @return others - An error occurred when getting volume label.\r | |
1741 | \r | |
1742 | **/\r | |
1743 | EFI_STATUS\r | |
1744 | FatGetVolumeEntry (\r | |
1745 | IN FAT_VOLUME *Volume,\r | |
1746 | IN CHAR16 *Name\r | |
1747 | );\r | |
1748 | \r | |
1749 | /**\r | |
1750 | \r | |
1751 | Set the relevant directory entry into disk for the volume.\r | |
1752 | \r | |
1753 | @param Volume - FAT file system volume.\r | |
1754 | @param Name - The new file name of the volume.\r | |
1755 | \r | |
1756 | @retval EFI_SUCCESS - Update the Volume successfully.\r | |
1757 | @retval EFI_UNSUPPORTED - The input label is not a valid volume label.\r | |
1758 | @return other - An error occurred when setting volume label.\r | |
1759 | \r | |
1760 | **/\r | |
1761 | EFI_STATUS\r | |
1762 | FatSetVolumeEntry (\r | |
1763 | IN FAT_VOLUME *Volume,\r | |
1764 | IN CHAR16 *Name\r | |
1765 | );\r | |
1766 | \r | |
1767 | //\r | |
1768 | // Hash.c\r | |
1769 | //\r | |
1770 | \r | |
1771 | /**\r | |
1772 | \r | |
1773 | Search the long name hash table for the directory entry.\r | |
1774 | \r | |
1775 | @param ODir - The directory to be searched.\r | |
1776 | @param LongNameString - The long name string to search.\r | |
1777 | \r | |
1778 | @return The previous long name hash node of the directory entry.\r | |
1779 | \r | |
1780 | **/\r | |
1781 | FAT_DIRENT **\r | |
1782 | FatLongNameHashSearch (\r | |
1783 | IN FAT_ODIR *ODir,\r | |
1784 | IN CHAR16 *LongNameString\r | |
1785 | );\r | |
1786 | \r | |
1787 | /**\r | |
1788 | \r | |
1789 | Search the short name hash table for the directory entry.\r | |
1790 | \r | |
1791 | @param ODir - The directory to be searched.\r | |
1792 | @param ShortNameString - The short name string to search.\r | |
1793 | \r | |
1794 | @return The previous short name hash node of the directory entry.\r | |
1795 | \r | |
1796 | **/\r | |
1797 | FAT_DIRENT **\r | |
1798 | FatShortNameHashSearch (\r | |
1799 | IN FAT_ODIR *ODir,\r | |
1800 | IN CHAR8 *ShortNameString\r | |
1801 | );\r | |
1802 | \r | |
1803 | /**\r | |
1804 | \r | |
1805 | Insert directory entry to hash table.\r | |
1806 | \r | |
1807 | @param ODir - The parent directory.\r | |
1808 | @param DirEnt - The directory entry node.\r | |
1809 | \r | |
1810 | **/\r | |
1811 | VOID\r | |
1812 | FatInsertToHashTable (\r | |
1813 | IN FAT_ODIR *ODir,\r | |
1814 | IN FAT_DIRENT *DirEnt\r | |
1815 | );\r | |
1816 | \r | |
1817 | /**\r | |
1818 | \r | |
1819 | Delete directory entry from hash table.\r | |
1820 | \r | |
1821 | @param ODir - The parent directory.\r | |
1822 | @param DirEnt - The directory entry node.\r | |
1823 | \r | |
1824 | **/\r | |
1825 | VOID\r | |
1826 | FatDeleteFromHashTable (\r | |
1827 | IN FAT_ODIR *ODir,\r | |
1828 | IN FAT_DIRENT *DirEnt\r | |
1829 | );\r | |
1830 | \r | |
1831 | //\r | |
1832 | // FileName.c\r | |
1833 | //\r | |
1834 | \r | |
1835 | /**\r | |
1836 | \r | |
1837 | This function checks whether the input FileName is a valid 8.3 short name.\r | |
1838 | If the input FileName is a valid 8.3, the output is the 8.3 short name;\r | |
1839 | otherwise, the output is the base tag of 8.3 short name.\r | |
1840 | \r | |
1841 | @param FileName - The input unicode filename.\r | |
1842 | @param File8Dot3Name - The output ascii 8.3 short name or base tag of 8.3 short name.\r | |
1843 | \r | |
1844 | @retval TRUE - The input unicode filename is a valid 8.3 short name.\r | |
1845 | @retval FALSE - The input unicode filename is not a valid 8.3 short name.\r | |
1846 | \r | |
1847 | **/\r | |
1848 | BOOLEAN\r | |
1849 | FatCheckIs8Dot3Name (\r | |
1850 | IN CHAR16 *FileName,\r | |
1851 | OUT CHAR8 *File8Dot3Name\r | |
1852 | );\r | |
1853 | \r | |
1854 | /**\r | |
1855 | \r | |
1856 | This function generates 8Dot3 name from user specified name for a newly created file.\r | |
1857 | \r | |
1858 | @param Parent - The parent directory.\r | |
1859 | @param DirEnt - The directory entry whose 8Dot3Name needs to be generated.\r | |
1860 | \r | |
1861 | **/\r | |
1862 | VOID\r | |
1863 | FatCreate8Dot3Name (\r | |
1864 | IN FAT_OFILE *Parent,\r | |
1865 | IN FAT_DIRENT *DirEnt\r | |
1866 | );\r | |
1867 | \r | |
1868 | /**\r | |
1869 | \r | |
1870 | Convert the ascii fat name to the unicode string and strip trailing spaces,\r | |
1871 | and if necessary, convert the unicode string to lower case.\r | |
1872 | \r | |
1873 | @param FatName - The Char8 string needs to be converted.\r | |
1874 | @param Len - The length of the fat name.\r | |
1875 | @param LowerCase - Indicate whether to convert the string to lower case.\r | |
1876 | @param Str - The result of the conversion.\r | |
1877 | \r | |
1878 | **/\r | |
1879 | VOID\r | |
1880 | FatNameToStr (\r | |
1881 | IN CHAR8 *FatName,\r | |
1882 | IN UINTN Len,\r | |
1883 | IN UINTN LowerCase,\r | |
1884 | IN CHAR16 *Str\r | |
1885 | );\r | |
1886 | \r | |
1887 | /**\r | |
1888 | \r | |
1889 | Set the caseflag value for the directory entry.\r | |
1890 | \r | |
1891 | @param DirEnt - The logical directory entry whose caseflag value is to be set.\r | |
1892 | \r | |
1893 | **/\r | |
1894 | VOID\r | |
1895 | FatSetCaseFlag (\r | |
1896 | IN FAT_DIRENT *DirEnt\r | |
1897 | );\r | |
1898 | \r | |
1899 | /**\r | |
1900 | \r | |
1901 | Convert the 8.3 ASCII fat name to cased Unicode string according to case flag.\r | |
1902 | \r | |
1903 | @param DirEnt - The corresponding directory entry.\r | |
1904 | @param FileString - The output Unicode file name.\r | |
1905 | @param FileStringMax The max length of FileString.\r | |
1906 | \r | |
1907 | **/\r | |
1908 | VOID\r | |
1909 | FatGetFileNameViaCaseFlag (\r | |
1910 | IN FAT_DIRENT *DirEnt,\r | |
1911 | IN OUT CHAR16 *FileString,\r | |
1912 | IN UINTN FileStringMax\r | |
1913 | );\r | |
1914 | \r | |
1915 | /**\r | |
1916 | \r | |
1917 | Get the Check sum for a short name.\r | |
1918 | \r | |
1919 | @param ShortNameString - The short name for a file.\r | |
1920 | \r | |
1921 | @retval Sum - UINT8 checksum.\r | |
1922 | \r | |
1923 | **/\r | |
1924 | UINT8\r | |
1925 | FatCheckSum (\r | |
1926 | IN CHAR8 *ShortNameString\r | |
1927 | );\r | |
1928 | \r | |
1929 | /**\r | |
1930 | \r | |
1931 | Takes Path as input, returns the next name component\r | |
1932 | in Name, and returns the position after Name (e.g., the\r | |
1933 | start of the next name component)\r | |
1934 | \r | |
1935 | @param Path - The path of one file.\r | |
1936 | @param Name - The next name component in Path.\r | |
1937 | \r | |
1938 | The position after Name in the Path\r | |
1939 | \r | |
1940 | **/\r | |
1941 | CHAR16 *\r | |
1942 | FatGetNextNameComponent (\r | |
1943 | IN CHAR16 *Path,\r | |
1944 | OUT CHAR16 *Name\r | |
1945 | );\r | |
1946 | \r | |
1947 | /**\r | |
1948 | \r | |
1949 | Check whether the IFileName is valid long file name. If the IFileName is a valid\r | |
1950 | long file name, then we trim the possible leading blanks and leading/trailing dots.\r | |
1951 | the trimmed filename is stored in OutputFileName\r | |
1952 | \r | |
1953 | @param InputFileName - The input file name.\r | |
1954 | @param OutputFileName - The output file name.\r | |
1955 | \r | |
1956 | @retval TRUE - The InputFileName is a valid long file name.\r | |
1957 | @retval FALSE - The InputFileName is not a valid long file name.\r | |
1958 | \r | |
1959 | **/\r | |
1960 | BOOLEAN\r | |
1961 | FatFileNameIsValid (\r | |
1962 | IN CHAR16 *InputFileName,\r | |
1963 | OUT CHAR16 *OutputFileName\r | |
1964 | );\r | |
1965 | \r | |
1966 | //\r | |
1967 | // DirectoryCache.c\r | |
1968 | //\r | |
1969 | \r | |
1970 | /**\r | |
1971 | \r | |
1972 | Discard the directory structure when an OFile will be freed.\r | |
1973 | Volume will cache this directory if the OFile does not represent a deleted file.\r | |
1974 | \r | |
1975 | @param OFile - The OFile whose directory structure is to be discarded.\r | |
1976 | \r | |
1977 | **/\r | |
1978 | VOID\r | |
1979 | FatDiscardODir (\r | |
1980 | IN FAT_OFILE *OFile\r | |
1981 | );\r | |
1982 | \r | |
1983 | /**\r | |
1984 | \r | |
1985 | Request the directory structure when an OFile is newly generated.\r | |
1986 | If the directory structure is cached by volume, then just return this directory;\r | |
1987 | Otherwise, allocate a new one for OFile.\r | |
1988 | \r | |
1989 | @param OFile - The OFile which requests directory structure.\r | |
1990 | \r | |
1991 | **/\r | |
1992 | VOID\r | |
1993 | FatRequestODir (\r | |
1994 | IN FAT_OFILE *OFile\r | |
1995 | );\r | |
1996 | \r | |
1997 | /**\r | |
1998 | \r | |
1999 | Clean up all the cached directory structures when the volume is going to be abandoned.\r | |
2000 | \r | |
2001 | @param Volume - FAT file system volume.\r | |
2002 | \r | |
2003 | **/\r | |
2004 | VOID\r | |
2005 | FatCleanupODirCache (\r | |
2006 | IN FAT_VOLUME *Volume\r | |
2007 | );\r | |
2008 | \r | |
2009 | //\r | |
2010 | // Global Variables\r | |
2011 | //\r | |
2012 | extern EFI_DRIVER_BINDING_PROTOCOL gFatDriverBinding;\r | |
2013 | extern EFI_COMPONENT_NAME_PROTOCOL gFatComponentName;\r | |
2014 | extern EFI_COMPONENT_NAME2_PROTOCOL gFatComponentName2;\r | |
2015 | extern EFI_LOCK FatFsLock;\r | |
2016 | extern EFI_LOCK FatTaskLock;\r | |
2017 | extern EFI_FILE_PROTOCOL FatFileInterface;\r | |
2018 | \r | |
2019 | #endif\r |