]>
Commit | Line | Data |
---|---|---|
cae7420b DB |
1 | /** @file\r |
2 | Routines dealing with setting/getting file/volume info\r | |
b9ec9330 | 3 | \r |
55248f85 | 4 | Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>\r |
eb6cb4ce | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
b9ec9330 QH |
6 | \r |
7 | \r | |
b9ec9330 | 8 | \r |
cae7420b | 9 | **/\r |
b9ec9330 QH |
10 | \r |
11 | #include "Fat.h"\r | |
12 | \r | |
205cc663 DB |
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 | |
b9ec9330 QH |
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 | |
205cc663 DB |
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 | |
b9ec9330 QH |
46 | EFI_STATUS\r |
47 | FatSetVolumeInfo (\r | |
48 | IN FAT_VOLUME *Volume,\r | |
5d7cee9d DB |
49 | IN UINTN BufferSize,\r |
50 | IN VOID *Buffer\r | |
b9ec9330 QH |
51 | );\r |
52 | \r | |
205cc663 DB |
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 | |
b9ec9330 QH |
67 | EFI_STATUS\r |
68 | FatSetOrGetInfo (\r | |
dba03ba1 QH |
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 | |
b9ec9330 QH |
74 | );\r |
75 | \r | |
cae7420b DB |
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 | |
b9ec9330 QH |
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 | |
cae7420b DB |
94 | {\r |
95 | return FatGetDirEntInfo (OFile->Volume, OFile->DirEnt, BufferSize, Buffer);\r | |
96 | }\r | |
b9ec9330 | 97 | \r |
cae7420b | 98 | /**\r |
b9ec9330 | 99 | \r |
cae7420b | 100 | Get the volume's info into Buffer.\r |
b9ec9330 | 101 | \r |
cae7420b DB |
102 | @param Volume - FAT file system volume.\r |
103 | @param BufferSize - Size of Buffer.\r | |
104 | @param Buffer - Buffer containing volume info.\r | |
b9ec9330 | 105 | \r |
cae7420b DB |
106 | @retval EFI_SUCCESS - Get the volume info successfully.\r |
107 | @retval EFI_BUFFER_TOO_SMALL - The buffer is too small.\r | |
b9ec9330 | 108 | \r |
cae7420b | 109 | **/\r |
b9ec9330 QH |
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 | |
b9ec9330 QH |
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 | |
cae7420b DB |
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 | |
b9ec9330 QH |
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 | |
b9ec9330 QH |
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 | |
80d70ac3 | 183 | Size = SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL;\r |
b9ec9330 QH |
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 | |
cae7420b DB |
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 | |
b9ec9330 QH |
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 | |
b9ec9330 QH |
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 | |
cae7420b DB |
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 | |
b9ec9330 QH |
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 | |
b9ec9330 | 250 | {\r |
80d70ac3 | 251 | EFI_FILE_SYSTEM_VOLUME_LABEL *Info;\r |
b9ec9330 | 252 | \r |
80d70ac3 | 253 | Info = (EFI_FILE_SYSTEM_VOLUME_LABEL *) Buffer;\r |
b9ec9330 | 254 | \r |
80d70ac3 | 255 | if (BufferSize < SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL + 2) {\r |
b9ec9330 QH |
256 | return EFI_BAD_BUFFER_SIZE;\r |
257 | }\r | |
258 | \r | |
259 | return FatSetVolumeEntry (Volume, Info->VolumeLabel);\r | |
260 | }\r | |
261 | \r | |
cae7420b DB |
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 | |
b9ec9330 QH |
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 | |
b9ec9330 QH |
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 | // Make sure there's a valid input buffer\r | |
317 | //\r | |
318 | NewInfo = Buffer;\r | |
319 | if (BufferSize < SIZE_OF_EFI_FILE_INFO + 2 || NewInfo->Size > BufferSize) {\r | |
320 | return EFI_BAD_BUFFER_SIZE;\r | |
321 | }\r | |
322 | \r | |
323 | ReadOnly = (BOOLEAN)(IFile->ReadOnly || (DirEnt->Entry.Attributes & EFI_FILE_READ_ONLY));\r | |
324 | //\r | |
325 | // if a zero time is specified, then the original time is preserved\r | |
326 | //\r | |
327 | if (CompareMem (&ZeroTime, &NewInfo->CreateTime, sizeof (EFI_TIME)) != 0) {\r | |
328 | if (!FatIsValidTime (&NewInfo->CreateTime)) {\r | |
329 | return EFI_INVALID_PARAMETER;\r | |
330 | }\r | |
331 | \r | |
332 | if (!ReadOnly) {\r | |
333 | FatEfiTimeToFatTime (&NewInfo->CreateTime, &DirEnt->Entry.FileCreateTime);\r | |
334 | }\r | |
335 | }\r | |
336 | \r | |
337 | if (CompareMem (&ZeroTime, &NewInfo->ModificationTime, sizeof (EFI_TIME)) != 0) {\r | |
338 | if (!FatIsValidTime (&NewInfo->ModificationTime)) {\r | |
339 | return EFI_INVALID_PARAMETER;\r | |
340 | }\r | |
341 | \r | |
342 | if (!ReadOnly) {\r | |
343 | FatEfiTimeToFatTime (&NewInfo->ModificationTime, &DirEnt->Entry.FileModificationTime);\r | |
344 | }\r | |
345 | \r | |
346 | OFile->PreserveLastModification = TRUE;\r | |
347 | }\r | |
348 | \r | |
349 | if (NewInfo->Attribute & (~EFI_FILE_VALID_ATTR)) {\r | |
350 | return EFI_INVALID_PARAMETER;\r | |
351 | }\r | |
352 | \r | |
353 | NewAttribute = (UINT8) NewInfo->Attribute;\r | |
354 | //\r | |
355 | // Can not change the directory attribute bit\r | |
356 | //\r | |
357 | if ((NewAttribute ^ DirEnt->Entry.Attributes) & EFI_FILE_DIRECTORY) {\r | |
358 | return EFI_ACCESS_DENIED;\r | |
359 | }\r | |
360 | //\r | |
361 | // Set the current attributes even if the IFile->ReadOnly is TRUE\r | |
362 | //\r | |
363 | DirEnt->Entry.Attributes = (UINT8) ((DirEnt->Entry.Attributes &~EFI_FILE_VALID_ATTR) | NewAttribute);\r | |
364 | //\r | |
365 | // Open the filename and see if it refers to an existing file\r | |
366 | //\r | |
367 | Status = FatLocateOFile (&Parent, NewInfo->FileName, DirEnt->Entry.Attributes, NewFileName);\r | |
368 | if (EFI_ERROR (Status)) {\r | |
369 | return Status;\r | |
370 | }\r | |
371 | \r | |
372 | if (*NewFileName != 0) {\r | |
373 | //\r | |
374 | // File was not found. We do not allow rename of the current directory if\r | |
375 | // there are open files below the current directory\r | |
376 | //\r | |
377 | if (!IsListEmpty (&OFile->ChildHead) || Parent == OFile) {\r | |
378 | return EFI_ACCESS_DENIED;\r | |
379 | }\r | |
380 | \r | |
381 | if (ReadOnly) {\r | |
382 | return EFI_ACCESS_DENIED;\r | |
383 | }\r | |
384 | \r | |
385 | Status = FatRemoveDirEnt (OFile->Parent, DirEnt);\r | |
386 | if (EFI_ERROR (Status)) {\r | |
387 | return Status;\r | |
388 | }\r | |
389 | //\r | |
390 | // Create new dirent\r | |
391 | //\r | |
392 | Status = FatCreateDirEnt (Parent, NewFileName, DirEnt->Entry.Attributes, &TempDirEnt);\r | |
393 | if (EFI_ERROR (Status)) {\r | |
394 | return Status;\r | |
395 | }\r | |
396 | \r | |
397 | FatCloneDirEnt (TempDirEnt, DirEnt);\r | |
398 | FatFreeDirEnt (DirEnt);\r | |
399 | DirEnt = TempDirEnt;\r | |
400 | DirEnt->OFile = OFile;\r | |
401 | OFile->DirEnt = DirEnt;\r | |
402 | OFile->Parent = Parent;\r | |
403 | RemoveEntryList (&OFile->ChildLink);\r | |
404 | InsertHeadList (&Parent->ChildHead, &OFile->ChildLink);\r | |
405 | //\r | |
406 | // If this is a directory, synchronize its dot directory entry\r | |
407 | //\r | |
408 | if (OFile->ODir != NULL) {\r | |
409 | //\r | |
44c9618a | 410 | // Synchronize its dot entry\r |
b9ec9330 QH |
411 | //\r |
412 | FatResetODirCursor (OFile);\r | |
413 | ASSERT (OFile->Parent != NULL);\r | |
414 | for (DotOFile = OFile; DotOFile != OFile->Parent->Parent; DotOFile = DotOFile->Parent) {\r | |
415 | Status = FatGetNextDirEnt (OFile, &DirEnt);\r | |
416 | if (EFI_ERROR (Status) || DirEnt == NULL || !FatIsDotDirEnt (DirEnt)) {\r | |
417 | return EFI_VOLUME_CORRUPTED;\r | |
418 | }\r | |
419 | \r | |
420 | FatCloneDirEnt (DirEnt, DotOFile->DirEnt);\r | |
421 | Status = FatStoreDirEnt (OFile, DirEnt);\r | |
422 | if (EFI_ERROR (Status)) {\r | |
423 | return Status;\r | |
424 | }\r | |
425 | }\r | |
426 | }\r | |
427 | //\r | |
428 | // If the file is renamed, we should append the ARCHIVE attribute\r | |
429 | //\r | |
430 | OFile->Archive = TRUE;\r | |
431 | } else if (Parent != OFile) {\r | |
432 | //\r | |
433 | // filename is to a different filename that already exists\r | |
434 | //\r | |
435 | return EFI_ACCESS_DENIED;\r | |
436 | }\r | |
437 | //\r | |
438 | // If the file size has changed, apply it\r | |
439 | //\r | |
440 | if (NewInfo->FileSize != OFile->FileSize) {\r | |
441 | if (OFile->ODir != NULL || ReadOnly) {\r | |
442 | //\r | |
443 | // If this is a directory or the file is read only, we can't change the file size\r | |
444 | //\r | |
445 | return EFI_ACCESS_DENIED;\r | |
446 | }\r | |
447 | \r | |
448 | if (NewInfo->FileSize > OFile->FileSize) {\r | |
449 | Status = FatExpandOFile (OFile, NewInfo->FileSize);\r | |
450 | } else {\r | |
451 | Status = FatTruncateOFile (OFile, (UINTN) NewInfo->FileSize);\r | |
452 | }\r | |
453 | \r | |
454 | if (EFI_ERROR (Status)) {\r | |
455 | return Status;\r | |
456 | }\r | |
457 | \r | |
458 | FatUpdateDirEntClusterSizeInfo (OFile);\r | |
459 | }\r | |
460 | \r | |
461 | OFile->Dirty = TRUE;\r | |
462 | return FatOFileFlush (OFile);\r | |
463 | }\r | |
464 | \r | |
cae7420b DB |
465 | /**\r |
466 | \r | |
467 | Set or Get the some types info of the file into Buffer.\r | |
468 | \r | |
469 | @param IsSet - TRUE:The access is set, else is get\r | |
470 | @param FHand - The handle of file\r | |
471 | @param Type - The type of the info\r | |
472 | @param BufferSize - Size of Buffer\r | |
473 | @param Buffer - Buffer containing volume info\r | |
474 | \r | |
475 | @retval EFI_SUCCESS - Get the info successfully\r | |
476 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file\r | |
477 | \r | |
478 | **/\r | |
b9ec9330 QH |
479 | EFI_STATUS\r |
480 | FatSetOrGetInfo (\r | |
dba03ba1 QH |
481 | IN BOOLEAN IsSet,\r |
482 | IN EFI_FILE_PROTOCOL *FHand,\r | |
483 | IN EFI_GUID *Type,\r | |
484 | IN OUT UINTN *BufferSize,\r | |
485 | IN OUT VOID *Buffer\r | |
b9ec9330 | 486 | )\r |
b9ec9330 QH |
487 | {\r |
488 | FAT_IFILE *IFile;\r | |
489 | FAT_OFILE *OFile;\r | |
490 | FAT_VOLUME *Volume;\r | |
491 | EFI_STATUS Status;\r | |
492 | \r | |
493 | IFile = IFILE_FROM_FHAND (FHand);\r | |
494 | OFile = IFile->OFile;\r | |
495 | Volume = OFile->Volume;\r | |
496 | \r | |
497 | Status = OFile->Error;\r | |
498 | if (Status == EFI_NOT_FOUND) {\r | |
499 | return EFI_DEVICE_ERROR;\r | |
500 | }\r | |
501 | \r | |
149d6335 RN |
502 | FatWaitNonblockingTask (IFile);\r |
503 | \r | |
b9ec9330 QH |
504 | FatAcquireLock ();\r |
505 | \r | |
506 | //\r | |
507 | // Verify the file handle isn't in an error state\r | |
508 | //\r | |
509 | if (!EFI_ERROR (Status)) {\r | |
510 | //\r | |
511 | // Get the proper information based on the request\r | |
512 | //\r | |
513 | Status = EFI_UNSUPPORTED;\r | |
514 | if (IsSet) {\r | |
55248f85 RN |
515 | if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r |
516 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetFileInfo (Volume, IFile, OFile, *BufferSize, Buffer);\r | |
517 | }\r | |
b9ec9330 | 518 | \r |
55248f85 RN |
519 | if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r |
520 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeInfo (Volume, *BufferSize, Buffer);\r | |
521 | }\r | |
b9ec9330 | 522 | \r |
55248f85 RN |
523 | if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r |
524 | Status = Volume->ReadOnly ? EFI_WRITE_PROTECTED : FatSetVolumeLabelInfo (Volume, *BufferSize, Buffer);\r | |
b9ec9330 QH |
525 | }\r |
526 | } else {\r | |
527 | if (CompareGuid (Type, &gEfiFileInfoGuid)) {\r | |
528 | Status = FatGetFileInfo (OFile, BufferSize, Buffer);\r | |
529 | }\r | |
530 | \r | |
531 | if (CompareGuid (Type, &gEfiFileSystemInfoGuid)) {\r | |
532 | Status = FatGetVolumeInfo (Volume, BufferSize, Buffer);\r | |
533 | }\r | |
534 | \r | |
535 | if (CompareGuid (Type, &gEfiFileSystemVolumeLabelInfoIdGuid)) {\r | |
536 | Status = FatGetVolumeLabelInfo (Volume, BufferSize, Buffer);\r | |
537 | }\r | |
538 | }\r | |
539 | }\r | |
540 | \r | |
149d6335 | 541 | Status = FatCleanupVolume (Volume, NULL, Status, NULL);\r |
b9ec9330 QH |
542 | \r |
543 | FatReleaseLock ();\r | |
544 | return Status;\r | |
545 | }\r | |
546 | \r | |
cae7420b DB |
547 | /**\r |
548 | \r | |
549 | Get the some types info of the file into Buffer.\r | |
550 | \r | |
551 | @param FHand - The handle of file.\r | |
552 | @param Type - The type of the info.\r | |
553 | @param BufferSize - Size of Buffer.\r | |
554 | @param Buffer - Buffer containing volume info.\r | |
555 | \r | |
556 | @retval EFI_SUCCESS - Get the info successfully.\r | |
557 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
558 | \r | |
559 | **/\r | |
b9ec9330 QH |
560 | EFI_STATUS\r |
561 | EFIAPI\r | |
562 | FatGetInfo (\r | |
dba03ba1 QH |
563 | IN EFI_FILE_PROTOCOL *FHand,\r |
564 | IN EFI_GUID *Type,\r | |
565 | IN OUT UINTN *BufferSize,\r | |
566 | OUT VOID *Buffer\r | |
b9ec9330 | 567 | )\r |
cae7420b DB |
568 | {\r |
569 | return FatSetOrGetInfo (FALSE, FHand, Type, BufferSize, Buffer);\r | |
570 | }\r | |
b9ec9330 | 571 | \r |
cae7420b | 572 | /**\r |
b9ec9330 | 573 | \r |
cae7420b | 574 | Set the some types info of the file into Buffer.\r |
b9ec9330 | 575 | \r |
cae7420b DB |
576 | @param FHand - The handle of file.\r |
577 | @param Type - The type of the info.\r | |
578 | @param BufferSize - Size of Buffer\r | |
579 | @param Buffer - Buffer containing volume info.\r | |
b9ec9330 | 580 | \r |
cae7420b DB |
581 | @retval EFI_SUCCESS - Set the info successfully.\r |
582 | @retval EFI_DEVICE_ERROR - Can not find the OFile for the file.\r | |
b9ec9330 | 583 | \r |
cae7420b | 584 | **/\r |
b9ec9330 QH |
585 | EFI_STATUS\r |
586 | EFIAPI\r | |
587 | FatSetInfo (\r | |
dba03ba1 QH |
588 | IN EFI_FILE_PROTOCOL *FHand,\r |
589 | IN EFI_GUID *Type,\r | |
590 | IN UINTN BufferSize,\r | |
591 | IN VOID *Buffer\r | |
b9ec9330 | 592 | )\r |
b9ec9330 QH |
593 | {\r |
594 | return FatSetOrGetInfo (TRUE, FHand, Type, &BufferSize, Buffer);\r | |
595 | }\r |