4 Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Get hash value for long name.
21 @param LongNameString - The long name string to be hashed.
29 IN CHAR16
*LongNameString
33 CHAR16 UpCasedLongFileName
[EFI_PATH_STRING_LENGTH
];
36 ARRAY_SIZE (UpCasedLongFileName
),
38 ARRAY_SIZE (UpCasedLongFileName
) - 1
40 FatStrUpr (UpCasedLongFileName
);
41 gBS
->CalculateCrc32 (UpCasedLongFileName
, StrSize (UpCasedLongFileName
), &HashValue
);
42 return (HashValue
& HASH_TABLE_MASK
);
47 Get hash value for short name.
49 @param ShortNameString - The short name string to be hashed.
57 IN CHAR8
*ShortNameString
61 gBS
->CalculateCrc32 (ShortNameString
, FAT_NAME_LEN
, &HashValue
);
62 return (HashValue
& HASH_TABLE_MASK
);
67 Search the long name hash table for the directory entry.
69 @param ODir - The directory to be searched.
70 @param LongNameString - The long name string to search.
72 @return The previous long name hash node of the directory entry.
76 FatLongNameHashSearch (
78 IN CHAR16
*LongNameString
81 FAT_DIRENT
**PreviousHashNode
;
82 for (PreviousHashNode
= &ODir
->LongNameHashTable
[FatHashLongName (LongNameString
)];
83 *PreviousHashNode
!= NULL
;
84 PreviousHashNode
= &(*PreviousHashNode
)->LongNameForwardLink
86 if (FatStriCmp (LongNameString
, (*PreviousHashNode
)->FileString
) == 0) {
91 return PreviousHashNode
;
96 Search the short name hash table for the directory entry.
98 @param ODir - The directory to be searched.
99 @param ShortNameString - The short name string to search.
101 @return The previous short name hash node of the directory entry.
105 FatShortNameHashSearch (
107 IN CHAR8
*ShortNameString
110 FAT_DIRENT
**PreviousHashNode
;
111 for (PreviousHashNode
= &ODir
->ShortNameHashTable
[FatHashShortName (ShortNameString
)];
112 *PreviousHashNode
!= NULL
;
113 PreviousHashNode
= &(*PreviousHashNode
)->ShortNameForwardLink
115 if (CompareMem (ShortNameString
, (*PreviousHashNode
)->Entry
.FileName
, FAT_NAME_LEN
) == 0) {
120 return PreviousHashNode
;
125 Insert directory entry to hash table.
127 @param ODir - The parent directory.
128 @param DirEnt - The directory entry node.
132 FatInsertToHashTable (
134 IN FAT_DIRENT
*DirEnt
137 FAT_DIRENT
**HashTable
;
138 UINT32 HashTableIndex
;
141 // Insert hash table index for short name
143 HashTableIndex
= FatHashShortName (DirEnt
->Entry
.FileName
);
144 HashTable
= ODir
->ShortNameHashTable
;
145 DirEnt
->ShortNameForwardLink
= HashTable
[HashTableIndex
];
146 HashTable
[HashTableIndex
] = DirEnt
;
148 // Insert hash table index for long name
150 HashTableIndex
= FatHashLongName (DirEnt
->FileString
);
151 HashTable
= ODir
->LongNameHashTable
;
152 DirEnt
->LongNameForwardLink
= HashTable
[HashTableIndex
];
153 HashTable
[HashTableIndex
] = DirEnt
;
158 Delete directory entry from hash table.
160 @param ODir - The parent directory.
161 @param DirEnt - The directory entry node.
165 FatDeleteFromHashTable (
167 IN FAT_DIRENT
*DirEnt
170 *FatShortNameHashSearch (ODir
, DirEnt
->Entry
.FileName
) = DirEnt
->ShortNameForwardLink
;
171 *FatLongNameHashSearch (ODir
, DirEnt
->FileString
) = DirEnt
->LongNameForwardLink
;