4 Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
13 Get hash value for long name.
15 @param LongNameString - The long name string to be hashed.
23 IN CHAR16
*LongNameString
27 CHAR16 UpCasedLongFileName
[EFI_PATH_STRING_LENGTH
];
30 ARRAY_SIZE (UpCasedLongFileName
),
32 ARRAY_SIZE (UpCasedLongFileName
) - 1
34 FatStrUpr (UpCasedLongFileName
);
35 gBS
->CalculateCrc32 (UpCasedLongFileName
, StrSize (UpCasedLongFileName
), &HashValue
);
36 return (HashValue
& HASH_TABLE_MASK
);
41 Get hash value for short name.
43 @param ShortNameString - The short name string to be hashed.
51 IN CHAR8
*ShortNameString
55 gBS
->CalculateCrc32 (ShortNameString
, FAT_NAME_LEN
, &HashValue
);
56 return (HashValue
& HASH_TABLE_MASK
);
61 Search the long name hash table for the directory entry.
63 @param ODir - The directory to be searched.
64 @param LongNameString - The long name string to search.
66 @return The previous long name hash node of the directory entry.
70 FatLongNameHashSearch (
72 IN CHAR16
*LongNameString
75 FAT_DIRENT
**PreviousHashNode
;
76 for (PreviousHashNode
= &ODir
->LongNameHashTable
[FatHashLongName (LongNameString
)];
77 *PreviousHashNode
!= NULL
;
78 PreviousHashNode
= &(*PreviousHashNode
)->LongNameForwardLink
80 if (FatStriCmp (LongNameString
, (*PreviousHashNode
)->FileString
) == 0) {
85 return PreviousHashNode
;
90 Search the short name hash table for the directory entry.
92 @param ODir - The directory to be searched.
93 @param ShortNameString - The short name string to search.
95 @return The previous short name hash node of the directory entry.
99 FatShortNameHashSearch (
101 IN CHAR8
*ShortNameString
104 FAT_DIRENT
**PreviousHashNode
;
105 for (PreviousHashNode
= &ODir
->ShortNameHashTable
[FatHashShortName (ShortNameString
)];
106 *PreviousHashNode
!= NULL
;
107 PreviousHashNode
= &(*PreviousHashNode
)->ShortNameForwardLink
109 if (CompareMem (ShortNameString
, (*PreviousHashNode
)->Entry
.FileName
, FAT_NAME_LEN
) == 0) {
114 return PreviousHashNode
;
119 Insert directory entry to hash table.
121 @param ODir - The parent directory.
122 @param DirEnt - The directory entry node.
126 FatInsertToHashTable (
128 IN FAT_DIRENT
*DirEnt
131 FAT_DIRENT
**HashTable
;
132 UINT32 HashTableIndex
;
135 // Insert hash table index for short name
137 HashTableIndex
= FatHashShortName (DirEnt
->Entry
.FileName
);
138 HashTable
= ODir
->ShortNameHashTable
;
139 DirEnt
->ShortNameForwardLink
= HashTable
[HashTableIndex
];
140 HashTable
[HashTableIndex
] = DirEnt
;
142 // Insert hash table index for long name
144 HashTableIndex
= FatHashLongName (DirEnt
->FileString
);
145 HashTable
= ODir
->LongNameHashTable
;
146 DirEnt
->LongNameForwardLink
= HashTable
[HashTableIndex
];
147 HashTable
[HashTableIndex
] = DirEnt
;
152 Delete directory entry from hash table.
154 @param ODir - The parent directory.
155 @param DirEnt - The directory entry node.
159 FatDeleteFromHashTable (
161 IN FAT_DIRENT
*DirEnt
164 *FatShortNameHashSearch (ODir
, DirEnt
->Entry
.FileName
) = DirEnt
->ShortNameForwardLink
;
165 *FatLongNameHashSearch (ODir
, DirEnt
->FileString
) = DirEnt
->LongNameForwardLink
;