3 Copyright (c) 2005 - 2007, Intel Corporation
4 All rights reserved. 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
];
50 StrCpy (UpCasedLongFileName
, LongNameString
);
51 FatStrUpr (UpCasedLongFileName
);
52 gBS
->CalculateCrc32 (UpCasedLongFileName
, StrSize (UpCasedLongFileName
), &HashValue
);
53 return (HashValue
& HASH_TABLE_MASK
);
59 IN CHAR8
*ShortNameString
65 Get hash value for short name.
69 ShortNameString - The short name string to be hashed.
78 gBS
->CalculateCrc32 (ShortNameString
, FAT_NAME_LEN
, &HashValue
);
79 return (HashValue
& HASH_TABLE_MASK
);
83 FatLongNameHashSearch (
85 IN CHAR16
*LongNameString
91 Search the long name hash table for the directory entry.
95 ODir - The directory to be searched.
96 LongNameString - The long name string to search.
100 The previous long name hash node of the directory entry.
104 FAT_DIRENT
**PreviousHashNode
;
105 for (PreviousHashNode
= &ODir
->LongNameHashTable
[FatHashLongName (LongNameString
)];
106 *PreviousHashNode
!= NULL
;
107 PreviousHashNode
= &(*PreviousHashNode
)->LongNameForwardLink
109 if (FatStriCmp (LongNameString
, (*PreviousHashNode
)->FileString
) == 0) {
114 return PreviousHashNode
;
118 FatShortNameHashSearch (
120 IN CHAR8
*ShortNameString
126 Search the short name hash table for the directory entry.
130 ODir - The directory to be searched.
131 ShortNameString - The short name string to search.
135 The previous short name hash node of the directory entry.
139 FAT_DIRENT
**PreviousHashNode
;
140 for (PreviousHashNode
= &ODir
->ShortNameHashTable
[FatHashShortName (ShortNameString
)];
141 *PreviousHashNode
!= NULL
;
142 PreviousHashNode
= &(*PreviousHashNode
)->ShortNameForwardLink
144 if (CompareMem (ShortNameString
, (*PreviousHashNode
)->Entry
.FileName
, FAT_NAME_LEN
) == 0) {
149 return PreviousHashNode
;
153 FatInsertToHashTable (
155 IN FAT_DIRENT
*DirEnt
161 Insert directory entry to hash table.
165 ODir - The parent directory.
166 DirEnt - The directory entry node.
174 FAT_DIRENT
**HashTable
;
175 UINT32 HashTableIndex
;
178 // Insert hash table index for short name
180 HashTableIndex
= FatHashShortName (DirEnt
->Entry
.FileName
);
181 HashTable
= ODir
->ShortNameHashTable
;
182 DirEnt
->ShortNameForwardLink
= HashTable
[HashTableIndex
];
183 HashTable
[HashTableIndex
] = DirEnt
;
185 // Insert hash table index for long name
187 HashTableIndex
= FatHashLongName (DirEnt
->FileString
);
188 HashTable
= ODir
->LongNameHashTable
;
189 DirEnt
->LongNameForwardLink
= HashTable
[HashTableIndex
];
190 HashTable
[HashTableIndex
] = DirEnt
;
194 FatDeleteFromHashTable (
196 IN FAT_DIRENT
*DirEnt
202 Delete directory entry from hash table.
206 ODir - The parent directory.
207 DirEnt - The directory entry node.
215 *FatShortNameHashSearch (ODir
, DirEnt
->Entry
.FileName
) = DirEnt
->ShortNameForwardLink
;
216 *FatLongNameHashSearch (ODir
, DirEnt
->FileString
) = DirEnt
->LongNameForwardLink
;