]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Routines dealing with setting/getting file/volume info\r | |
3 | \r | |
4 | Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | \r | |
8 | \r | |
9 | **/\r | |
10 | \r | |
11 | #include "Fat.h"\r | |
12 | \r | |
13 | /**\r | |
14 | \r | |
15 | Get the volume's info into Buffer.\r | |
16 | \r | |
17 | @param Volume - FAT file system volume.\r | |
18 | @param BufferSize - Size of Buffer.\r | |
19 | @param Buffer - Buffer containing volume info.\r | |
20 | \r | |
21 | @retval EFI_SUCCESS - Get the volume info successfully.\r | |
22 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
23 | \r | |
24 | **/\r | |
25 | EFI_STATUS\r | |
26 | FatGetVolumeInfo (\r | |
27 | IN FAT_VOLUME *Volume,\r | |
28 | IN OUT UINTN *BufferSize,\r | |
29 | OUT VOID *Buffer\r | |
30 | );\r | |
31 | \r | |
32 | /**\r | |
33 | \r | |
34 | Set the volume's info.\r | |
35 | \r | |
36 | @param Volume - FAT file system volume.\r | |
37 | @param BufferSize - Size of Buffer.\r | |
38 | @param Buffer - Buffer containing the new volume info.\r | |
39 | \r | |
40 | @retval EFI_SUCCESS - Set the volume info successfully.\r | |
41 | @retval EFI_BAD_BUFFER_SIZE - The buffer size is error.\r | |
42 | @retval EFI_WRITE_PROTECTED - The volume is read only.\r | |
43 | @return other - An error occurred when operation the disk.\r | |
44 | \r | |
45 | **/\r | |
46 | EFI_STATUS\r | |
47 | FatSetVolumeInfo (\r | |
48 | IN FAT_VOLUME *Volume,\r | |
49 | IN UINTN BufferSize,\r | |
50 | IN VOID *Buffer\r | |
51 | );\r | |
52 | \r | |
53 | /**\r | |
54 | \r | |
55 | Set or Get the some types info of the file into Buffer.\r | |
56 | \r | |
57 | @param IsSet - TRUE:The access is set, else is get\r | |
58 | @param FHand - The handle of file\r | |
59 | @param Type - The type of the info\r | |
60 | @param BufferSize - Size of Buffer\r | |
61 | @param Buffer - Buffer containing volume info\r | |
62 | \r | |
63 | @retval EFI_SUCCESS - Get the info successfully\r | |
64 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file\r | |
65 | \r | |
66 | **/\r | |
67 | EFI_STATUS\r | |
68 | FatSetOrGetInfo (\r | |
69 | IN BOOLEAN IsSet,\r | |
70 | IN EFI_FILE_PROTOCOL *FHand,\r | |
71 | IN EFI_GUID *Type,\r | |
72 | IN OUT UINTN *BufferSize,\r | |
73 | IN OUT VOID *Buffer\r | |
74 | );\r | |
75 | \r | |
76 | /**\r | |
77 | \r | |
78 | Get the open file's info into Buffer.\r | |
79 | \r | |
80 | @param OFile - The open file.\r | |
81 | @param BufferSize - Size of Buffer.\r | |
82 | @param Buffer - Buffer containing file info.\r | |
83 | \r | |
84 | @retval EFI_SUCCESS - Get the file info successfully.\r | |
85 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
86 | \r | |
87 | **/\r | |
88 | EFI_STATUS\r | |
89 | FatGetFileInfo (\r | |
90 | IN FAT_OFILE *OFile,\r | |
91 | IN OUT UINTN *BufferSize,\r | |
92 | OUT VOID *Buffer\r | |
93 | )\r | |
94 | {\r | |
95 | return FatGetDirEntInfo (OFile->Volume, OFile->DirEnt, BufferSize, Buffer);\r | |
96 | }\r | |
97 | \r | |
98 | /**\r | |
99 | \r | |
100 | Get the volume's info into Buffer.\r | |
101 | \r | |
102 | @param Volume - FAT file system volume.\r | |
103 | @param BufferSize - Size of Buffer.\r | |
104 | @param Buffer - Buffer containing volume info.\r | |
105 | \r | |
106 | @retval EFI_SUCCESS - Get the volume info successfully.\r | |
107 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
108 | \r | |
109 | **/\r | |
110 | EFI_STATUS\r | |
111 | FatGetVolumeInfo (\r | |
112 | IN FAT_VOLUME *Volume,\r | |
113 | IN OUT UINTN *BufferSize,\r | |
114 | OUT VOID *Buffer\r | |
115 | )\r | |
116 | {\r | |
117 | UINTN Size;\r | |
118 | UINTN NameSize;\r | |
119 | UINTN ResultSize;\r | |
120 | CHAR16 Name[FAT_NAME_LEN + 1];\r | |
121 | EFI_STATUS Status;\r | |
122 | EFI_FILE_SYSTEM_INFO *Info;\r | |
123 | UINT8 ClusterAlignment;\r | |
124 | \r | |
125 | Size = SIZE_OF_EFI_FILE_SYSTEM_INFO;\r | |
126 | Status = FatGetVolumeEntry (Volume, Name);\r | |
127 | NameSize = StrSize (Name);\r | |
128 | ResultSize = Size + NameSize;\r | |
129 | ClusterAlignment = Volume->ClusterAlignment;\r | |
130 | \r | |
131 | //\r | |
132 | // If we don't have valid info, compute it now\r | |
133 | //\r | |
134 | FatComputeFreeInfo (Volume);\r | |
135 | \r | |
136 | Status = EFI_BUFFER_TOO_SMALL;\r | |
137 | if (*BufferSize >= ResultSize) {\r | |
138 | Status = EFI_SUCCESS;\r | |
139 | \r | |
140 | Info = Buffer;\r | |
141 | ZeroMem (Info, SIZE_OF_EFI_FILE_SYSTEM_INFO);\r | |
142 | \r | |
143 | Info->Size = ResultSize;\r | |
144 | Info->ReadOnly = Volume->ReadOnly;\r | |
145 | Info->BlockSize = (UINT32)Volume->ClusterSize;\r | |
146 | Info->VolumeSize = LShiftU64 (Volume->MaxCluster, ClusterAlignment);\r | |
147 | Info->FreeSpace = LShiftU64 (\r | |
148 | Volume->FatInfoSector.FreeInfo.ClusterCount,\r | |
149 | ClusterAlignment\r | |
150 | );\r | |
151 | CopyMem ((CHAR8 *)Buffer + Size, Name, NameSize);\r | |
152 | }\r | |
153 | \r | |
154 | *BufferSize = ResultSize;\r | |
155 | return Status;\r | |
156 | }\r | |
157 | \r | |
158 | /**\r | |
159 | \r | |
160 | Get the volume's label info into Buffer.\r | |
161 | \r | |
162 | @param Volume - FAT file system volume.\r | |
163 | @param BufferSize - Size of Buffer.\r | |
164 | @param Buffer - Buffer containing volume's label info.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS - Get the volume's label info successfully.\r | |
167 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | FatGetVolumeLabelInfo (\r | |
172 | IN FAT_VOLUME *Volume,\r | |
173 | IN OUT UINTN *BufferSize,\r | |
174 | OUT VOID *Buffer\r | |
175 | )\r | |
176 | {\r | |
177 | UINTN Size;\r | |
178 | UINTN NameSize;\r | |
179 | UINTN ResultSize;\r | |
180 | CHAR16 Name[FAT_NAME_LEN + 1];\r | |
181 | EFI_STATUS Status;\r | |
182 | \r | |
183 | Size = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL;\r | |
184 | Status = FatGetVolumeEntry (Volume, Name);\r | |
185 | NameSize = StrSize (Name);\r | |
186 | ResultSize = Size + NameSize;\r | |
187 | \r | |
188 | Status = EFI_BUFFER_TOO_SMALL;\r | |
189 | if (*BufferSize >= ResultSize) {\r | |
190 | Status = EFI_SUCCESS;\r | |
191 | CopyMem ((CHAR8 *)Buffer + Size, Name, NameSize);\r | |
192 | }\r | |
193 | \r | |
194 | *BufferSize = ResultSize;\r | |
195 | return Status;\r | |
196 | }\r | |
197 | \r | |
198 | /**\r | |
199 | \r | |
200 | Set the volume's info.\r | |
201 | \r | |
202 | @param Volume - FAT file system volume.\r | |
203 | @param BufferSize - Size of Buffer.\r | |
204 | @param Buffer - Buffer containing the new volume info.\r | |
205 | \r | |
206 | @retval EFI_SUCCESS - Set the volume info successfully.\r | |
207 | @retval EFI_BAD_BUFFER_SIZE - The buffer size is error.\r | |
208 | @retval EFI_WRITE_PROTECTED - The volume is read only.\r | |
209 | @return other - An error occurred when operation the disk.\r | |
210 | \r | |
211 | **/\r | |
212 | EFI_STATUS\r | |
213 | FatSetVolumeInfo (\r | |
214 | IN FAT_VOLUME *Volume,\r | |
215 | IN UINTN BufferSize,\r | |
216 | IN VOID *Buffer\r | |
217 | )\r | |
218 | {\r | |
219 | EFI_FILE_SYSTEM_INFO *Info;\r | |
220 | \r | |
221 | Info = (EFI_FILE_SYSTEM_INFO *)Buffer;\r | |
222 | \r | |
223 | if ((BufferSize < SIZE_OF_EFI_FILE_SYSTEM_INFO + 2) || (Info->Size > BufferSize)) {\r | |
224 | return EFI_BAD_BUFFER_SIZE;\r | |
225 | }\r | |
226 | \r | |
227 | return FatSetVolumeEntry (Volume, Info->VolumeLabel);\r | |
228 | }\r | |
229 | \r | |
230 | /**\r | |
231 | \r | |
232 | Set the volume's label info.\r | |
233 | \r | |
234 | @param Volume - FAT file system volume.\r | |
235 | @param BufferSize - Size of Buffer.\r | |
236 | @param Buffer - Buffer containing the new volume label info.\r | |
237 | \r | |
238 | @retval EFI_SUCCESS - Set the volume label info successfully.\r | |
239 | @retval EFI_WRITE_PROTECTED - The disk is write protected.\r | |
240 | @retval EFI_BAD_BUFFER_SIZE - The buffer size is error.\r | |
241 | @return other - An error occurred when operation the disk.\r | |
242 | \r | |
243 | **/\r | |
244 | EFI_STATUS\r | |
245 | FatSetVolumeLabelInfo (\r | |
246 | IN FAT_VOLUME *Volume,\r | |
247 | IN UINTN BufferSize,\r | |
248 | IN VOID *Buffer\r | |
249 | )\r | |
250 | {\r | |
251 | EFI_FILE_SYSTEM_VOLUME_LABEL *Info;\r | |
252 | \r | |
253 | Info = (EFI_FILE_SYSTEM_VOLUME_LABEL *)Buffer;\r | |
254 | \r | |
255 | if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL + 2) {\r | |
256 | return EFI_BAD_BUFFER_SIZE;\r | |
257 | }\r | |
258 | \r | |
259 | return FatSetVolumeEntry (Volume, Info->VolumeLabel);\r | |
260 | }\r | |
261 | \r | |
262 | /**\r | |
263 | \r | |
264 | Set the file info.\r | |
265 | \r | |
266 | @param Volume - FAT file system volume.\r | |
267 | @param IFile - The instance of the open file.\r | |
268 | @param OFile - The open file.\r | |
269 | @param BufferSize - Size of Buffer.\r | |
270 | @param Buffer - Buffer containing the new file info.\r | |
271 | \r | |
272 | @retval EFI_SUCCESS - Set the file info successfully.\r | |
273 | @retval EFI_ACCESS_DENIED - It is the root directory\r | |
274 | or the directory attribute bit can not change\r | |
275 | or try to change a directory size\r | |
276 | or something else.\r | |
277 | @retval EFI_UNSUPPORTED - The new file size is larger than 4GB.\r | |
278 | @retval EFI_WRITE_PROTECTED - The disk is write protected.\r | |
279 | @retval EFI_BAD_BUFFER_SIZE - The buffer size is error.\r | |
280 | @retval EFI_INVALID_PARAMETER - The time info or attributes info is error.\r | |
281 | @retval EFI_OUT_OF_RESOURCES - Can not allocate new memory.\r | |
282 | @retval EFI_VOLUME_CORRUPTED - The volume is corrupted.\r | |
283 | @return other - An error occurred when operation the disk.\r | |
284 | \r | |
285 | **/\r | |
286 | EFI_STATUS\r | |
287 | FatSetFileInfo (\r | |
288 | IN FAT_VOLUME *Volume,\r | |
289 | IN FAT_IFILE *IFile,\r | |
290 | IN FAT_OFILE *OFile,\r | |
291 | IN UINTN BufferSize,\r | |
292 | IN VOID *Buffer\r | |
293 | )\r | |
294 | {\r | |
295 | EFI_STATUS Status;\r | |
296 | EFI_FILE_INFO *NewInfo;\r | |
297 | FAT_OFILE *DotOFile;\r | |
298 | FAT_OFILE *Parent;\r | |
299 | CHAR16 NewFileName[EFI_PATH_STRING_LENGTH];\r | |
300 | EFI_TIME ZeroTime;\r | |
301 | FAT_DIRENT *DirEnt;\r | |
302 | FAT_DIRENT *TempDirEnt;\r | |
303 | UINT8 NewAttribute;\r | |
304 | BOOLEAN ReadOnly;\r | |
305 | \r | |
306 | ZeroMem (&ZeroTime, sizeof (EFI_TIME));\r | |
307 | Parent = OFile->Parent;\r | |
308 | DirEnt = OFile->DirEnt;\r | |
309 | //\r | |
310 | // If this is the root directory, we can't make any updates\r | |
311 | //\r | |
312 | if (Parent == NULL) {\r | |
313 | return EFI_ACCESS_DENIED;\r | |
314 | }\r | |
315 | \r | |
316 | //\r | |
317 | // Make sure there's a valid input buffer\r | |
318 | //\r | |
319 | NewInfo = Buffer;\r | |
320 | if ((BufferSize < SIZE_OF_EFI_FILE_INFO + 2) || (NewInfo->Size > BufferSize)) {\r | |
321 | return EFI_BAD_BUFFER_SIZE;\r | |
322 | }\r | |
323 | \r | |
324 | ReadOnly = (BOOLEAN)(IFile->ReadOnly || (DirEnt->Entry.Attributes & EFI_FILE_READ_ONLY));\r | |
325 | //\r | |
326 | // if a zero time is specified, then the original time is preserved\r | |
327 | //\r | |
328 | if (CompareMem (&ZeroTime, &NewInfo->CreateTime, sizeof (EFI_TIME)) != 0) {\r | |
329 | if (!FatIsValidTime (&NewInfo->CreateTime)) {\r | |
330 | return EFI_INVALID_PARAMETER;\r | |
331 | }\r | |
332 | \r | |
333 | if (!ReadOnly) {\r | |
334 | FatEfiTimeToFatTime (&NewInfo->CreateTime, &DirEnt->Entry.FileCreateTime);\r | |
335 | }\r | |
336 | }\r | |
337 | \r | |
338 | if (CompareMem (&ZeroTime, &NewInfo->ModificationTime, sizeof (EFI_TIME)) != 0) {\r | |
339 | if (!FatIsValidTime (&NewInfo->ModificationTime)) {\r | |
340 | return EFI_INVALID_PARAMETER;\r | |
341 | }\r | |
342 | \r | |
343 | if (!ReadOnly) {\r | |
344 | FatEfiTimeToFatTime (&NewInfo->ModificationTime, &DirEnt->Entry.FileModificationTime);\r | |
345 | }\r | |
346 | \r | |
347 | OFile->PreserveLastModification = TRUE;\r | |
348 | }\r | |
349 | \r | |
350 | if (NewInfo->Attribute & (~EFI_FILE_VALID_ATTR)) {\r | |
351 | return EFI_INVALID_PARAMETER;\r | |
352 | }\r | |
353 | \r | |
354 | NewAttribute = (UINT8)NewInfo->Attribute;\r | |
355 | //\r | |
356 | // Can not change the directory attribute bit\r | |
357 | //\r | |
358 | if ((NewAttribute ^ DirEnt->Entry.Attributes) & EFI_FILE_DIRECTORY) {\r | |
359 | return EFI_ACCESS_DENIED;\r | |
360 | }\r | |
361 | \r | |
362 | //\r | |
363 | // Set the current attributes even if the IFile->ReadOnly is TRUE\r | |
364 | //\r | |
365 | DirEnt->Entry.Attributes = (UINT8)((DirEnt->Entry.Attributes &~EFI_FILE_VALID_ATTR) | NewAttribute);\r | |
366 | //\r | |
367 | // Open the filename and see if it refers to an existing file\r | |
368 | //\r | |
369 | Status = FatLocateOFile (&Parent, NewInfo->FileName, DirEnt->Entry.Attributes, NewFileName);\r | |
370 | if (EFI_ERROR (Status)) {\r | |
371 | return Status;\r | |
372 | }\r | |
373 | \r | |
374 | if (*NewFileName != 0) {\r | |
375 | //\r | |
376 | // File was not found. We do not allow rename of the current directory if\r | |
377 | // there are open files below the current directory\r | |
378 | //\r | |
379 | if (!IsListEmpty (&OFile->ChildHead) || (Parent == OFile)) {\r | |
380 | return EFI_ACCESS_DENIED;\r | |
381 | }\r | |
382 | \r | |
383 | if (ReadOnly) {\r | |
384 | return EFI_ACCESS_DENIED;\r | |
385 | }\r | |
386 | \r | |
387 | Status = FatRemoveDirEnt (OFile->Parent, DirEnt);\r | |
388 | if (EFI_ERROR (Status)) {\r | |
389 | return Status;\r | |
390 | }\r | |
391 | \r | |
392 | //\r | |
393 | // Create new dirent\r | |
394 | //\r | |
395 | Status = FatCreateDirEnt (Parent, NewFileName, DirEnt->Entry.Attributes, &TempDirEnt);\r | |
396 | if (EFI_ERROR (Status)) {\r | |
397 | return Status;\r | |
398 | }\r | |
399 | \r | |
400 | FatCloneDirEnt (TempDirEnt, DirEnt);\r | |
401 | FatFreeDirEnt (DirEnt);\r | |
402 | DirEnt = TempDirEnt;\r | |
403 | DirEnt->OFile = OFile;\r | |
404 | OFile->DirEnt = DirEnt;\r | |
405 | OFile->Parent = Parent;\r | |
406 | RemoveEntryList (&OFile->ChildLink);\r | |
407 | InsertHeadList (&Parent->ChildHead, &OFile->ChildLink);\r | |
408 | //\r | |
409 | // If this is a directory, synchronize its dot directory entry\r | |
410 | //\r | |
411 | if (OFile->ODir != NULL) {\r | |
412 | //\r | |
413 | // Synchronize its dot entry\r | |
414 | //\r | |
415 | FatResetODirCursor (OFile);\r | |
416 | ASSERT (OFile->Parent != NULL);\r | |
417 | for (DotOFile = OFile; DotOFile != OFile->Parent->Parent; DotOFile = DotOFile->Parent) {\r | |
418 | Status = FatGetNextDirEnt (OFile, &DirEnt);\r | |
419 | if (EFI_ERROR (Status) || (DirEnt == NULL) || !FatIsDotDirEnt (DirEnt)) {\r | |
420 | return EFI_VOLUME_CORRUPTED;\r | |
421 | }\r | |
422 | \r | |
423 | FatCloneDirEnt (DirEnt, DotOFile->DirEnt);\r | |
424 | Status = FatStoreDirEnt (OFile, DirEnt);\r | |
425 | if (EFI_ERROR (Status)) {\r | |
426 | return Status;\r | |
427 | }\r | |
428 | }\r | |
429 | }\r | |
430 | \r | |
431 | //\r | |
432 | // If the file is renamed, we should append the ARCHIVE attribute\r | |
433 | //\r | |
434 | OFile->Archive = TRUE;\r | |
435 | } else if (Parent != OFile) {\r | |
436 | //\r | |
437 | // filename is to a different filename that already exists\r | |
438 | //\r | |
439 | return EFI_ACCESS_DENIED;\r | |
440 | }\r | |
441 | \r | |
442 | //\r | |
443 | // If the file size has changed, apply it\r | |
444 | //\r | |
445 | if (NewInfo->FileSize != OFile->FileSize) {\r | |
446 | if ((OFile->ODir != NULL) || ReadOnly) {\r | |
447 | //\r | |
448 | // If this is a directory or the file is read only, we can't change the file size\r | |
449 | //\r | |
450 | return EFI_ACCESS_DENIED;\r | |
451 | }\r | |
452 | \r | |
453 | if (NewInfo->FileSize > OFile->FileSize) {\r | |
454 | Status = FatExpandOFile (OFile, NewInfo->FileSize);\r | |
455 | } else {\r | |
456 | Status = FatTruncateOFile (OFile, (UINTN)NewInfo->FileSize);\r | |
457 | }\r | |
458 | \r | |
459 | if (EFI_ERROR (Status)) {\r | |
460 | return Status;\r | |
461 | }\r | |
462 | \r | |
463 | FatUpdateDirEntClusterSizeInfo (OFile);\r | |
464 | }\r | |
465 | \r | |
466 | OFile->Dirty = TRUE;\r | |
467 | return FatOFileFlush (OFile);\r | |
468 | }\r | |
469 | \r | |
470 | /**\r | |
471 | \r | |
472 | Set or Get the some types info of the file into Buffer.\r | |
473 | \r | |
474 | @param IsSet - TRUE:The access is set, else is get\r | |
475 | @param FHand - The handle of file\r | |
476 | @param Type - The type of the info\r | |
477 | @param BufferSize - Size of Buffer\r | |
478 | @param Buffer - Buffer containing volume info\r | |
479 | \r | |
480 | @retval EFI_SUCCESS - Get the info successfully\r | |
481 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file\r | |
482 | \r | |
483 | **/\r | |
484 | EFI_STATUS\r | |
485 | FatSetOrGetInfo (\r | |
486 | IN BOOLEAN IsSet,\r | |
487 | IN EFI_FILE_PROTOCOL *FHand,\r | |
488 | IN EFI_GUID *Type,\r | |
489 | IN OUT UINTN *BufferSize,\r | |
490 | IN OUT VOID *Buffer\r | |
491 | )\r | |
492 | {\r | |
493 | FAT_IFILE *IFile;\r | |
494 | FAT_OFILE *OFile;\r | |
495 | FAT_VOLUME *Volume;\r | |
496 | EFI_STATUS Status;\r | |
497 | \r | |
498 | IFile = IFILE_FROM_FHAND (FHand);\r | |
499 | OFile = IFile->OFile;\r | |
500 | Volume = OFile->Volume;\r | |
501 | \r | |
502 | Status = OFile->Error;\r | |
503 | if (Status == EFI_NOT_FOUND) {\r | |
504 | return EFI_DEVICE_ERROR;\r | |
505 | }\r | |
506 | \r | |
507 | FatWaitNonblockingTask (IFile);\r | |
508 | \r | |
509 | FatAcquireLock ();\r | |
510 | \r | |
511 | //\r | |
512 | // Verify the file handle isn't in an error state\r | |
513 | //\r | |
514 | if (!EFI_ERROR (Status)) {\r | |
515 | //\r | |
516 | // Get the proper information based on the request\r | |
517 | //\r | |
518 | Status = EFI_UNSUPPORTED;\r | |
519 | if (IsSet) {\r | |
520 | if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r | |
521 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r | |
522 | }\r | |
523 | \r | |
524 | if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r | |
525 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r | |
526 | }\r | |
527 | \r | |
528 | if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r | |
529 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r | |
530 | }\r | |
531 | } else {\r | |
532 | if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r | |
533 | Status = FatGetFileInfo (OFile, BufferSize, Buffer);\r | |
534 | }\r | |
535 | \r | |
536 | if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r | |
537 | Status = FatGetVolumeInfo (Volume, BufferSize, Buffer);\r | |
538 | }\r | |
539 | \r | |
540 | if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r | |
541 | Status = FatGetVolumeLabelInfo (Volume, BufferSize, Buffer);\r | |
542 | }\r | |
543 | }\r | |
544 | }\r | |
545 | \r | |
546 | Status = FatCleanupVolume (Volume, NULL, Status, NULL);\r | |
547 | \r | |
548 | FatReleaseLock ();\r | |
549 | return Status;\r | |
550 | }\r | |
551 | \r | |
552 | /**\r | |
553 | \r | |
554 | Get the some types info of the file into Buffer.\r | |
555 | \r | |
556 | @param FHand - The handle of file.\r | |
557 | @param Type - The type of the info.\r | |
558 | @param BufferSize - Size of Buffer.\r | |
559 | @param Buffer - Buffer containing volume info.\r | |
560 | \r | |
561 | @retval EFI_SUCCESS - Get the info successfully.\r | |
562 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
563 | \r | |
564 | **/\r | |
565 | EFI_STATUS\r | |
566 | EFIAPI\r | |
567 | FatGetInfo (\r | |
568 | IN EFI_FILE_PROTOCOL *FHand,\r | |
569 | IN EFI_GUID *Type,\r | |
570 | IN OUT UINTN *BufferSize,\r | |
571 | OUT VOID *Buffer\r | |
572 | )\r | |
573 | {\r | |
574 | return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r | |
575 | }\r | |
576 | \r | |
577 | /**\r | |
578 | \r | |
579 | Set the some types info of the file into Buffer.\r | |
580 | \r | |
581 | @param FHand - The handle of file.\r | |
582 | @param Type - The type of the info.\r | |
583 | @param BufferSize - Size of Buffer\r | |
584 | @param Buffer - Buffer containing volume info.\r | |
585 | \r | |
586 | @retval EFI_SUCCESS - Set the info successfully.\r | |
587 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
588 | \r | |
589 | **/\r | |
590 | EFI_STATUS\r | |
591 | EFIAPI\r | |
592 | FatSetInfo (\r | |
593 | IN EFI_FILE_PROTOCOL *FHand,\r | |
594 | IN EFI_GUID *Type,\r | |
595 | IN UINTN BufferSize,\r | |
596 | IN VOID *Buffer\r | |
597 | )\r | |
598 | {\r | |
599 | return FatSetOrGetInfo (TRUE, FHand, Type, &BufferSize, Buffer);\r | |
600 | }\r |