3 Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials are licensed and made available
5 under the terms and conditions of the BSD License which accompanies this
6 distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
30 IN CHAR16
*LongNameString
36 Get hash value for long name.
40 LongNameString - The long name string to be hashed.
49 CHAR16 UpCasedLongFileName
[EFI_PATH_STRING_LENGTH
];
52 sizeof (UpCasedLongFileName
) / sizeof (UpCasedLongFileName
[0]),
54 sizeof (UpCasedLongFileName
) / sizeof (UpCasedLongFileName
[0]) - 1
56 FatStrUpr (UpCasedLongFileName
);
57 gBS
->CalculateCrc32 (UpCasedLongFileName
, StrSize (UpCasedLongFileName
), &HashValue
);
58 return (HashValue
& HASH_TABLE_MASK
);
64 IN CHAR8
*ShortNameString
70 Get hash value for short name.
74 ShortNameString - The short name string to be hashed.
83 gBS
->CalculateCrc32 (ShortNameString
, FAT_NAME_LEN
, &HashValue
);
84 return (HashValue
& HASH_TABLE_MASK
);
88 FatLongNameHashSearch (
90 IN CHAR16
*LongNameString
96 Search the long name hash table for the directory entry.
100 ODir - The directory to be searched.
101 LongNameString - The long name string to search.
105 The previous long name hash node of the directory entry.
109 FAT_DIRENT
**PreviousHashNode
;
110 for (PreviousHashNode
= &ODir
->LongNameHashTable
[FatHashLongName (LongNameString
)];
111 *PreviousHashNode
!= NULL
;
112 PreviousHashNode
= &(*PreviousHashNode
)->LongNameForwardLink
114 if (FatStriCmp (LongNameString
, (*PreviousHashNode
)->FileString
) == 0) {
119 return PreviousHashNode
;
123 FatShortNameHashSearch (
125 IN CHAR8
*ShortNameString
131 Search the short name hash table for the directory entry.
135 ODir - The directory to be searched.
136 ShortNameString - The short name string to search.
140 The previous short name hash node of the directory entry.
144 FAT_DIRENT
**PreviousHashNode
;
145 for (PreviousHashNode
= &ODir
->ShortNameHashTable
[FatHashShortName (ShortNameString
)];
146 *PreviousHashNode
!= NULL
;
147 PreviousHashNode
= &(*PreviousHashNode
)->ShortNameForwardLink
149 if (CompareMem (ShortNameString
, (*PreviousHashNode
)->Entry
.FileName
, FAT_NAME_LEN
) == 0) {
154 return PreviousHashNode
;
158 FatInsertToHashTable (
160 IN FAT_DIRENT
*DirEnt
166 Insert directory entry to hash table.
170 ODir - The parent directory.
171 DirEnt - The directory entry node.
179 FAT_DIRENT
**HashTable
;
180 UINT32 HashTableIndex
;
183 // Insert hash table index for short name
185 HashTableIndex
= FatHashShortName (DirEnt
->Entry
.FileName
);
186 HashTable
= ODir
->ShortNameHashTable
;
187 DirEnt
->ShortNameForwardLink
= HashTable
[HashTableIndex
];
188 HashTable
[HashTableIndex
] = DirEnt
;
190 // Insert hash table index for long name
192 HashTableIndex
= FatHashLongName (DirEnt
->FileString
);
193 HashTable
= ODir
->LongNameHashTable
;
194 DirEnt
->LongNameForwardLink
= HashTable
[HashTableIndex
];
195 HashTable
[HashTableIndex
] = DirEnt
;
199 FatDeleteFromHashTable (
201 IN FAT_DIRENT
*DirEnt
207 Delete directory entry from hash table.
211 ODir - The parent directory.
212 DirEnt - The directory entry node.
220 *FatShortNameHashSearch (ODir
, DirEnt
->Entry
.FileName
) = DirEnt
->ShortNameForwardLink
;
221 *FatLongNameHashSearch (ODir
, DirEnt
->FileString
) = DirEnt
->LongNameForwardLink
;