Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/FatPkg/EnhancedFatDxe/DirectoryManage.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (23 months ago)
- svn:sync-xref-src-repo-rev:
- 156854
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/FatPkg/EnhancedFatDxe/DirectoryManage.c
r85718 r99404 25 25 EFI_STATUS 26 26 FatAccessEntry ( 27 IN FAT_OFILE 28 IN IO_MODE 29 IN UINTN 30 IN OUT VOID 31 ) 32 { 33 UINTN Position;34 UINTN BufferSize;27 IN FAT_OFILE *Parent, 28 IN IO_MODE IoMode, 29 IN UINTN EntryPos, 30 IN OUT VOID *Entry 31 ) 32 { 33 UINTN Position; 34 UINTN BufferSize; 35 35 36 36 Position = EntryPos * sizeof (FAT_DIRECTORY_ENTRY); … … 40 40 // 41 41 ASSERT (IoMode == ReadData); 42 ((FAT_DIRECTORY_ENTRY *) 43 ((FAT_DIRECTORY_ENTRY *) 42 ((FAT_DIRECTORY_ENTRY *)Entry)->FileName[0] = EMPTY_ENTRY_MARK; 43 ((FAT_DIRECTORY_ENTRY *)Entry)->Attributes = 0; 44 44 return EFI_SUCCESS; 45 45 } … … 62 62 EFI_STATUS 63 63 FatStoreDirEnt ( 64 IN FAT_OFILE 65 IN FAT_DIRENT 66 ) 67 { 68 EFI_STATUS Status;69 FAT_DIRECTORY_LFN LfnEntry;70 UINTN EntryPos;71 CHAR16 *LfnBufferPointer;72 CHAR16 LfnBuffer[MAX_LFN_ENTRIES * LFN_CHAR_TOTAL + 1];73 UINT8 EntryCount;74 UINT8 LfnOrdinal;64 IN FAT_OFILE *OFile, 65 IN FAT_DIRENT *DirEnt 66 ) 67 { 68 EFI_STATUS Status; 69 FAT_DIRECTORY_LFN LfnEntry; 70 UINTN EntryPos; 71 CHAR16 *LfnBufferPointer; 72 CHAR16 LfnBuffer[MAX_LFN_ENTRIES * LFN_CHAR_TOTAL + 1]; 73 UINT8 EntryCount; 74 UINT8 LfnOrdinal; 75 75 76 76 EntryPos = DirEnt->EntryPos; … … 146 146 { 147 147 CHAR16 *FileString; 148 148 149 FileString = DirEnt->FileString; 149 if ( StrCmp (FileString, L".") == 0 || StrCmp (FileString, L"..") == 0) {150 if ((StrCmp (FileString, L".") == 0) || (StrCmp (FileString, L"..") == 0)) { 150 151 return TRUE; 151 152 } … … 164 165 VOID 165 166 FatSetDirEntCluster ( 166 IN FAT_OFILE 167 IN FAT_OFILE *OFile 167 168 ) 168 169 { … … 172 173 DirEnt = OFile->DirEnt; 173 174 Cluster = OFile->FileCluster; 174 DirEnt->Entry.FileClusterHigh = (UINT16) 175 DirEnt->Entry.FileCluster = (UINT16) 175 DirEnt->Entry.FileClusterHigh = (UINT16)(Cluster >> 16); 176 DirEnt->Entry.FileCluster = (UINT16)Cluster; 176 177 } 177 178 … … 185 186 VOID 186 187 FatUpdateDirEntClusterSizeInfo ( 187 IN FAT_OFILE 188 IN FAT_OFILE *OFile 188 189 ) 189 190 { 190 191 ASSERT (OFile->ODir == NULL); 191 OFile->DirEnt->Entry.FileSize = (UINT32) 192 OFile->DirEnt->Entry.FileSize = (UINT32)OFile->FileSize; 192 193 FatSetDirEntCluster (OFile); 193 194 } … … 203 204 VOID 204 205 FatCloneDirEnt ( 205 IN FAT_DIRENT *DirEnt1, 206 IN FAT_DIRENT *DirEnt2 207 ) 208 { 209 UINT8 *Entry1; 210 UINT8 *Entry2; 211 Entry1 = (UINT8 *) &DirEnt1->Entry; 212 Entry2 = (UINT8 *) &DirEnt2->Entry; 206 IN FAT_DIRENT *DirEnt1, 207 IN FAT_DIRENT *DirEnt2 208 ) 209 { 210 UINT8 *Entry1; 211 UINT8 *Entry2; 212 213 Entry1 = (UINT8 *)&DirEnt1->Entry; 214 Entry2 = (UINT8 *)&DirEnt2->Entry; 213 215 CopyMem ( 214 216 Entry1 + FAT_ENTRY_INFO_OFFSET, … … 229 231 VOID 230 232 FatLoadLongNameEntry ( 231 IN FAT_OFILE 232 IN FAT_DIRENT 233 ) 234 { 235 CHAR16 LfnBuffer[MAX_LFN_ENTRIES * LFN_CHAR_TOTAL + 1];236 CHAR16 *LfnBufferPointer;237 CHAR8 *File8Dot3Name;238 UINTN EntryPos;239 UINT8 LfnOrdinal;240 UINT8 LfnChecksum;241 FAT_DIRECTORY_LFN LfnEntry;242 EFI_STATUS Status;243 244 EntryPos 245 File8Dot3Name 246 LfnBufferPointer 233 IN FAT_OFILE *Parent, 234 IN FAT_DIRENT *DirEnt 235 ) 236 { 237 CHAR16 LfnBuffer[MAX_LFN_ENTRIES * LFN_CHAR_TOTAL + 1]; 238 CHAR16 *LfnBufferPointer; 239 CHAR8 *File8Dot3Name; 240 UINTN EntryPos; 241 UINT8 LfnOrdinal; 242 UINT8 LfnChecksum; 243 FAT_DIRECTORY_LFN LfnEntry; 244 EFI_STATUS Status; 245 246 EntryPos = DirEnt->EntryPos; 247 File8Dot3Name = DirEnt->Entry.FileName; 248 LfnBufferPointer = LfnBuffer; 247 249 // 248 250 // Computes checksum for LFN … … 259 261 Status = FatAccessEntry (Parent, ReadData, EntryPos, &LfnEntry); 260 262 if (EFI_ERROR (Status) || 261 LfnEntry.Attributes != FAT_ATTRIBUTE_LFN || 262 LfnEntry.MustBeZero != 0 || 263 LfnEntry.Checksum != LfnChecksum || 264 (LfnEntry.Ordinal & (~FAT_LFN_LAST)) != LfnOrdinal || 265 LfnOrdinal > MAX_LFN_ENTRIES 266 ) { 263 (LfnEntry.Attributes != FAT_ATTRIBUTE_LFN) || 264 (LfnEntry.MustBeZero != 0) || 265 (LfnEntry.Checksum != LfnChecksum) || 266 ((LfnEntry.Ordinal & (~FAT_LFN_LAST)) != LfnOrdinal) || 267 (LfnOrdinal > MAX_LFN_ENTRIES) 268 ) 269 { 267 270 // 268 271 // The directory entry does not have a long file name or … … 282 285 LfnOrdinal++; 283 286 } while ((LfnEntry.Ordinal & FAT_LFN_LAST) == 0); 287 284 288 DirEnt->EntryCount = LfnOrdinal; 285 289 // … … 313 317 VOID 314 318 FatAddDirEnt ( 315 IN FAT_ODIR 316 IN FAT_DIRENT 319 IN FAT_ODIR *ODir, 320 IN FAT_DIRENT *DirEnt 317 321 ) 318 322 { … … 320 324 DirEnt->Link.BackLink = &ODir->ChildList; 321 325 } 326 322 327 InsertTailList (DirEnt->Link.BackLink, &DirEnt->Link); 323 328 FatInsertToHashTable (ODir, DirEnt); … … 339 344 EFI_STATUS 340 345 FatLoadNextDirEnt ( 341 IN FAT_OFILE 342 OUT FAT_DIRENT 343 ) 344 { 345 EFI_STATUS Status;346 FAT_DIRENT *DirEnt;347 FAT_ODIR *ODir;348 FAT_DIRECTORY_ENTRY Entry;346 IN FAT_OFILE *OFile, 347 OUT FAT_DIRENT **PtrDirEnt 348 ) 349 { 350 EFI_STATUS Status; 351 FAT_DIRENT *DirEnt; 352 FAT_ODIR *ODir; 353 FAT_DIRECTORY_ENTRY Entry; 349 354 350 355 ODir = OFile->ODir; … … 359 364 DirEnt = NULL; 360 365 361 for ( ;;) {366 for ( ; ;) { 362 367 // 363 368 // Read the next directory entry until we find a valid directory entry (excluding lfn entry) … … 368 373 } 369 374 370 if (((UINT8) Entry.FileName[0] != DELETE_ENTRY_MARK) && (Entry.Attributes & FAT_ATTRIBUTE_VOLUME_ID) == 0) {375 if (((UINT8)Entry.FileName[0] != DELETE_ENTRY_MARK) && ((Entry.Attributes & FAT_ATTRIBUTE_VOLUME_ID) == 0)) { 371 376 // 372 377 // We get a valid directory entry, then handle it … … 399 404 // Remember the directory's entry position on disk 400 405 // 401 DirEnt->EntryPos = (UINT16) 406 DirEnt->EntryPos = (UINT16)ODir->CurrentEndPos; 402 407 CopyMem (&DirEnt->Entry, &Entry, sizeof (FAT_DIRECTORY_ENTRY)); 403 408 FatLoadLongNameEntry (OFile, DirEnt); … … 406 411 goto Done; 407 412 } 413 408 414 // 409 415 // Add this directory entry to directory … … 441 447 EFI_STATUS 442 448 FatGetDirEntInfo ( 443 IN FAT_VOLUME 444 IN FAT_DIRENT 445 IN OUT UINTN 446 OUT VOID*Buffer447 ) 448 { 449 UINTN Size;450 UINTN NameSize;451 UINTN ResultSize;452 UINTN Cluster;453 EFI_STATUS Status;454 EFI_FILE_INFO *Info;455 FAT_DIRECTORY_ENTRY *Entry;456 FAT_DATE_TIME FatLastAccess;449 IN FAT_VOLUME *Volume, 450 IN FAT_DIRENT *DirEnt, 451 IN OUT UINTN *BufferSize, 452 OUT VOID *Buffer 453 ) 454 { 455 UINTN Size; 456 UINTN NameSize; 457 UINTN ResultSize; 458 UINTN Cluster; 459 EFI_STATUS Status; 460 EFI_FILE_INFO *Info; 461 FAT_DIRECTORY_ENTRY *Entry; 462 FAT_DATE_TIME FatLastAccess; 457 463 458 464 ASSERT_VOLUME_LOCKED (Volume); 459 465 460 Size 461 NameSize 462 ResultSize 463 464 Status 466 Size = SIZE_OF_EFI_FILE_INFO; 467 NameSize = StrSize (DirEnt->FileString); 468 ResultSize = Size + NameSize; 469 470 Status = EFI_BUFFER_TOO_SMALL; 465 471 if (*BufferSize >= ResultSize) { 466 Status 467 Entry 468 Info 469 Info->Size 472 Status = EFI_SUCCESS; 473 Entry = &DirEnt->Entry; 474 Info = Buffer; 475 Info->Size = ResultSize; 470 476 if ((Entry->Attributes & FAT_ATTRIBUTE_DIRECTORY) != 0) { 471 Cluster 472 Info->PhysicalSize 473 Info->FileSize 477 Cluster = (Entry->FileClusterHigh << 16) | Entry->FileCluster; 478 Info->PhysicalSize = FatPhysicalDirSize (Volume, Cluster); 479 Info->FileSize = Info->PhysicalSize; 474 480 } else { 475 Info->FileSize 476 Info->PhysicalSize 481 Info->FileSize = Entry->FileSize; 482 Info->PhysicalSize = FatPhysicalFileSize (Volume, Entry->FileSize); 477 483 } 478 484 … … 483 489 FatFatTimeToEfiTime (&Entry->FileModificationTime, &Info->ModificationTime); 484 490 Info->Attribute = Entry->Attributes & EFI_FILE_VALID_ATTR; 485 CopyMem ((CHAR8 *) 491 CopyMem ((CHAR8 *)Buffer + Size, DirEnt->FileString, NameSize); 486 492 } 487 493 … … 505 511 EFI_STATUS 506 512 FatSearchODir ( 507 IN FAT_OFILE 508 IN CHAR16 509 OUT FAT_DIRENT 513 IN FAT_OFILE *OFile, 514 IN CHAR16 *FileNameString, 515 OUT FAT_DIRENT **PtrDirEnt 510 516 ) 511 517 { … … 526 532 // 527 533 DirEnt = *FatLongNameHashSearch (ODir, FileNameString); 528 if (DirEnt == NULL && PossibleShortName) { 529 DirEnt = *FatShortNameHashSearch (ODir, File8Dot3Name); 530 } 534 if ((DirEnt == NULL) && PossibleShortName) { 535 DirEnt = *FatShortNameHashSearch (ODir, File8Dot3Name); 536 } 537 531 538 if (DirEnt == NULL) { 532 539 // … … 545 552 } 546 553 547 if (PossibleShortName && CompareMem (File8Dot3Name, DirEnt->Entry.FileName, FAT_NAME_LEN) == 0) {554 if (PossibleShortName && (CompareMem (File8Dot3Name, DirEnt->Entry.FileName, FAT_NAME_LEN) == 0)) { 548 555 break; 549 556 } … … 565 572 VOID 566 573 FatResetODirCursor ( 567 IN FAT_OFILE 574 IN FAT_OFILE *OFile 568 575 ) 569 576 { … … 589 596 EFI_STATUS 590 597 FatGetNextDirEnt ( 591 IN FAT_OFILE 592 OUT FAT_DIRENT 598 IN FAT_OFILE *OFile, 599 OUT FAT_DIRENT **PtrDirEnt 593 600 ) 594 601 { … … 618 625 // End of directory, return NULL 619 626 // 620 DirEnt 621 ODir->CurrentPos 627 DirEnt = NULL; 628 ODir->CurrentPos = ODir->CurrentEndPos; 622 629 } else { 623 630 ODir->CurrentCursor = ODir->CurrentCursor->ForwardLink; … … 641 648 VOID 642 649 FatSetEntryCount ( 643 IN FAT_OFILE 644 IN FAT_DIRENT 650 IN FAT_OFILE *OFile, 651 IN FAT_DIRENT *DirEnt 645 652 ) 646 653 { … … 651 658 // Get new entry count and set the 8.3 name 652 659 // 653 DirEnt->EntryCount 654 FileString 655 File8Dot3Name 660 DirEnt->EntryCount = 1; 661 FileString = DirEnt->FileString; 662 File8Dot3Name = DirEnt->Entry.FileName; 656 663 SetMem (File8Dot3Name, FAT_NAME_LEN, ' '); 657 664 if (StrCmp (FileString, L".") == 0) { … … 665 672 // ".." entry 666 673 // 667 File8Dot3Name[0] 668 File8Dot3Name[1] 674 File8Dot3Name[0] = '.'; 675 File8Dot3Name[1] = '.'; 669 676 FatCloneDirEnt (DirEnt, OFile->Parent->DirEnt); 670 677 } else { … … 720 727 EFI_STATUS 721 728 FatSeekVolumeId ( 722 IN FAT_OFILE 723 OUT FAT_DIRENT 724 ) 725 { 726 EFI_STATUS Status;727 UINTN EntryPos;728 FAT_DIRECTORY_ENTRY *Entry;729 IN FAT_OFILE *Root, 730 OUT FAT_DIRENT *DirEnt 731 ) 732 { 733 EFI_STATUS Status; 734 UINTN EntryPos; 735 FAT_DIRECTORY_ENTRY *Entry; 729 736 730 737 EntryPos = 0; … … 737 744 } 738 745 739 if (((UINT8) 740 DirEnt->EntryPos = (UINT16) 746 if (((UINT8)Entry->FileName[0] != DELETE_ENTRY_MARK) && (((Entry->Attributes) & (~FAT_ATTRIBUTE_ARCHIVE)) == FAT_ATTRIBUTE_VOLUME_ID)) { 747 DirEnt->EntryPos = (UINT16)EntryPos; 741 748 DirEnt->EntryCount = 1; 742 749 DirEnt->Invalid = FALSE; … … 746 753 EntryPos++; 747 754 } while (Entry->FileName[0] != EMPTY_ENTRY_MARK); 755 748 756 return EFI_SUCCESS; 749 757 } … … 767 775 EFI_STATUS 768 776 FatFirstFitInsertDirEnt ( 769 IN FAT_OFILE 770 IN FAT_DIRENT 771 ) 772 { 773 EFI_STATUS 774 FAT_ODIR 775 LIST_ENTRY 776 FAT_DIRENT 777 UINT32 778 UINT32 779 UINT32 780 UINT16 781 FAT_DIRENT 777 IN FAT_OFILE *OFile, 778 IN FAT_DIRENT *DirEnt 779 ) 780 { 781 EFI_STATUS Status; 782 FAT_ODIR *ODir; 783 LIST_ENTRY *CurrentEntry; 784 FAT_DIRENT *CurrentDirEnt; 785 UINT32 CurrentPos; 786 UINT32 LabelPos; 787 UINT32 NewEntryPos; 788 UINT16 EntryCount; 789 FAT_DIRENT LabelDirEnt; 782 790 783 791 LabelPos = 0; … … 800 808 CurrentEntry != &ODir->ChildList; 801 809 CurrentEntry = CurrentEntry->ForwardLink 802 ) { 810 ) 811 { 803 812 CurrentDirEnt = DIRENT_FROM_LINK (CurrentEntry); 804 813 if (NewEntryPos + CurrentDirEnt->EntryCount <= CurrentDirEnt->EntryPos) { 805 if ( LabelPos > NewEntryPos || LabelPos <= CurrentPos) {814 if ((LabelPos > NewEntryPos) || (LabelPos <= CurrentPos)) { 806 815 // 807 816 // first fit succeeded … … 820 829 821 830 Done: 822 DirEnt->EntryPos = (UINT16)NewEntryPos;831 DirEnt->EntryPos = (UINT16)NewEntryPos; 823 832 DirEnt->Link.BackLink = CurrentEntry; 824 833 return EFI_SUCCESS; … … 840 849 EFI_STATUS 841 850 FatNewEntryPos ( 842 IN FAT_OFILE 843 IN FAT_DIRENT 851 IN FAT_OFILE *OFile, 852 IN FAT_DIRENT *DirEnt 844 853 ) 845 854 { … … 860 869 } 861 870 } 871 862 872 // 863 873 // We will append this entry to the end of directory … … 874 884 return FatFirstFitInsertDirEnt (OFile, DirEnt); 875 885 } 886 876 887 // 877 888 // We should allocate a new cluster for this directory … … 882 893 } 883 894 } 895 884 896 // 885 897 // We append our directory entry at the end of directory file 886 898 // 887 899 ODir->CurrentEndPos = NewEndPos; 888 DirEnt->EntryPos = (UINT16)(ODir->CurrentEndPos - 1);900 DirEnt->EntryPos = (UINT16)(ODir->CurrentEndPos - 1); 889 901 return EFI_SUCCESS; 890 902 } … … 903 915 EFI_STATUS 904 916 FatGetVolumeEntry ( 905 IN FAT_VOLUME 906 IN CHAR16 917 IN FAT_VOLUME *Volume, 918 IN CHAR16 *Name 907 919 ) 908 920 { … … 910 922 FAT_DIRENT LabelDirEnt; 911 923 912 *Name 913 Status 924 *Name = 0; 925 Status = FatSeekVolumeId (Volume->Root, &LabelDirEnt); 914 926 if (!EFI_ERROR (Status)) { 915 927 if (!LabelDirEnt.Invalid) { … … 935 947 EFI_STATUS 936 948 FatSetVolumeEntry ( 937 IN FAT_VOLUME 938 IN CHAR16 949 IN FAT_VOLUME *Volume, 950 IN CHAR16 *Name 939 951 ) 940 952 { … … 943 955 FAT_OFILE *Root; 944 956 945 Root 946 Status 957 Root = Volume->Root; 958 Status = FatSeekVolumeId (Volume->Root, &LabelDirEnt); 947 959 if (EFI_ERROR (Status)) { 948 960 return Status; … … 984 996 EFI_STATUS 985 997 FatCreateDotDirEnts ( 986 IN FAT_OFILE 998 IN FAT_OFILE *OFile 987 999 ) 988 1000 { … … 1003 1015 return Status; 1004 1016 } 1017 1005 1018 // 1006 1019 // Create ".." … … 1026 1039 EFI_STATUS 1027 1040 FatCreateDirEnt ( 1028 IN FAT_OFILE 1029 IN CHAR16 1030 IN UINT8 1031 OUT FAT_DIRENT 1041 IN FAT_OFILE *OFile, 1042 IN CHAR16 *FileName, 1043 IN UINT8 Attributes, 1044 OUT FAT_DIRENT **PtrDirEnt 1032 1045 ) 1033 1046 { … … 1044 1057 } 1045 1058 1046 DirEnt->Signature 1047 DirEnt->FileString 1059 DirEnt->Signature = FAT_DIRENT_SIGNATURE; 1060 DirEnt->FileString = AllocateCopyPool (StrSize (FileName), FileName); 1048 1061 if (DirEnt->FileString == NULL) { 1049 1062 Status = EFI_OUT_OF_RESOURCES; 1050 1063 goto Done; 1051 1064 } 1065 1052 1066 // 1053 1067 // Determine how many directory entries we need … … 1065 1079 DirEnt->Entry.Attributes = Attributes; 1066 1080 *PtrDirEnt = DirEnt; 1067 DEBUG (( EFI_D_INFO, "FSOpen: Created new directory entry '%S'\n", DirEnt->FileString));1081 DEBUG ((DEBUG_INFO, "FSOpen: Created new directory entry '%S'\n", DirEnt->FileString)); 1068 1082 return FatStoreDirEnt (OFile, DirEnt); 1069 1083 … … 1086 1100 EFI_STATUS 1087 1101 FatRemoveDirEnt ( 1088 IN FAT_OFILE 1089 IN FAT_DIRENT 1102 IN FAT_OFILE *OFile, 1103 IN FAT_DIRENT *DirEnt 1090 1104 ) 1091 1105 { … … 1099 1113 ODir->CurrentCursor = ODir->CurrentCursor->BackLink; 1100 1114 } 1115 1101 1116 // 1102 1117 // Remove from directory entry list … … 1126 1141 EFI_STATUS 1127 1142 FatOpenDirEnt ( 1128 IN FAT_OFILE 1129 IN FAT_DIRENT 1143 IN FAT_OFILE *Parent, 1144 IN FAT_DIRENT *DirEnt 1130 1145 ) 1131 1146 { … … 1159 1174 // The newly created OFile is root 1160 1175 // 1161 Volume 1162 Volume->Root 1163 OFile->FileCluster 1176 Volume = VOLUME_FROM_ROOT_DIRENT (DirEnt); 1177 Volume->Root = OFile; 1178 OFile->FileCluster = Volume->RootCluster; 1164 1179 if (Volume->FatType != Fat32) { 1165 OFile->IsFixedRootDir 1180 OFile->IsFixedRootDir = TRUE; 1166 1181 } 1167 1182 } 1168 1183 1169 OFile->FileCurrentCluster 1170 OFile->Volume 1184 OFile->FileCurrentCluster = OFile->FileCluster; 1185 OFile->Volume = Volume; 1171 1186 InsertHeadList (&Volume->CheckRef, &OFile->CheckLink); 1172 1187 … … 1200 1215 VOID 1201 1216 FatCloseDirEnt ( 1202 IN FAT_DIRENT 1217 IN FAT_DIRENT *DirEnt 1203 1218 ) 1204 1219 { … … 1206 1221 FAT_VOLUME *Volume; 1207 1222 1208 OFile 1223 OFile = DirEnt->OFile; 1209 1224 ASSERT (OFile != NULL); 1210 Volume 1225 Volume = OFile->Volume; 1211 1226 1212 1227 if (OFile->ODir != NULL) { … … 1252 1267 EFI_STATUS 1253 1268 FatLocateOFile ( 1254 IN OUT FAT_OFILE 1255 IN CHAR16 1256 IN UINT8 1257 OUT CHAR16*NewFileName1269 IN OUT FAT_OFILE **PtrOFile, 1270 IN CHAR16 *FileName, 1271 IN UINT8 Attributes, 1272 OUT CHAR16 *NewFileName 1258 1273 ) 1259 1274 { … … 1274 1289 } 1275 1290 1276 OFile 1277 Volume 1291 OFile = *PtrOFile; 1292 Volume = OFile->Volume; 1278 1293 1279 1294 DirIntended = FALSE; … … 1281 1296 DirIntended = TRUE; 1282 1297 } 1298 1283 1299 // 1284 1300 // If name starts with path name separator, then move to root OFile … … 1289 1305 FileNameLen--; 1290 1306 } 1307 1291 1308 // 1292 1309 // Per FAT Spec the file name should meet the following criteria: … … 1301 1318 return EFI_INVALID_PARAMETER; 1302 1319 } 1320 1303 1321 // 1304 1322 // Start at current location 1305 1323 // 1306 1324 Next = FileName; 1307 for ( ;;) {1325 for ( ; ;) { 1308 1326 // 1309 1327 // Get the next component name … … 1316 1334 // 1317 1335 if (ComponentName[0] == 0) { 1318 if (DirIntended && OFile->ODir == NULL) {1336 if (DirIntended && (OFile->ODir == NULL)) { 1319 1337 return EFI_NOT_FOUND; 1320 1338 } … … 1323 1341 break; 1324 1342 } 1343 1325 1344 // 1326 1345 // If "dot", then current … … 1329 1348 continue; 1330 1349 } 1350 1331 1351 // 1332 1352 // If "dot dot", then parent … … 1336 1356 return EFI_INVALID_PARAMETER; 1337 1357 } 1358 1338 1359 OFile = OFile->Parent; 1339 1360 continue; … … 1343 1364 return EFI_INVALID_PARAMETER; 1344 1365 } 1366 1345 1367 // 1346 1368 // We have a component name, try to open it … … 1352 1374 return EFI_NOT_FOUND; 1353 1375 } 1376 1354 1377 // 1355 1378 // Search the compName in the directory … … 1368 1391 } 1369 1392 1370 if (DirIntended && ( Attributes & FAT_ATTRIBUTE_DIRECTORY) == 0) {1393 if (DirIntended && ((Attributes & FAT_ATTRIBUTE_DIRECTORY) == 0)) { 1371 1394 return EFI_INVALID_PARAMETER; 1372 1395 } 1396 1373 1397 // 1374 1398 // It's the last component name - return with the open … … 1389 1413 return EFI_SUCCESS; 1390 1414 } 1391
Note:
See TracChangeset
for help on using the changeset viewer.