diff options
| author | Amlal <amlal@nekernel.org> | 2025-05-03 11:04:41 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-05-03 11:04:41 +0200 |
| commit | d4d4944362d433146e052c3530e364b7ac6bed05 (patch) | |
| tree | 26d0ff45fc3b50b0de7c67cf584c3902e49c71d2 | |
| parent | ed6b064eb574c53bfc4af878f41052288b2e1001 (diff) | |
FS:HeFS: document hefsi_hash_64.
Signed-off-by: Amlal <amlal@nekernel.org>
| -rw-r--r-- | dev/kernel/src/FS/HeFS+FileSystemParser.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/dev/kernel/src/FS/HeFS+FileSystemParser.cc b/dev/kernel/src/FS/HeFS+FileSystemParser.cc index 2e9e77b7..a262fab0 100644 --- a/dev/kernel/src/FS/HeFS+FileSystemParser.cc +++ b/dev/kernel/src/FS/HeFS+FileSystemParser.cc @@ -80,14 +80,17 @@ namespace Detail { const Utf8Char* dir_name, UInt16 flags, const BOOL delete_or_create); - UInt64 hefsi_hash_64(const Utf8Char* name) { + /// @brief Simple algorithm to hash directory entries for INDs. + /// @param path the directory path. + /// @return The hashed path. + STATIC UInt64 hefsi_hash_64(const Utf8Char* path) { const UInt64 FNV_OFFSET_BASIS = 0x811C9DC5; const UInt64 FNV_PRIME = 0x01000193; UInt64 hash = FNV_OFFSET_BASIS; - while (*name) { - hash ^= (Utf8Char) (*name++); + while (*path) { + hash ^= (Utf8Char) (*path++); hash *= FNV_PRIME; } @@ -342,7 +345,8 @@ namespace Detail { if (!delete_or_create) { expr = (!tmpdir->fCreated && tmpdir->fDeleted) || tmpdir->fHashName == 0; } else { - expr = tmpdir->fCreated && !tmpdir->fDeleted && hefsi_hash_64(dir_name) == tmpdir->fHashName; + expr = + tmpdir->fCreated && !tmpdir->fDeleted && hefsi_hash_64(dir_name) == tmpdir->fHashName; } if (expr) { @@ -351,7 +355,7 @@ namespace Detail { rt_set_memory(dirent, 0, sizeof(HEFS_INDEX_NODE_DIRECTORY)); - dirent->fHashName = delete_or_create ? 0UL : hefsi_hash_64(dir_name); + dirent->fHashName = delete_or_create ? 0UL : hefsi_hash_64(dir_name); dirent->fAccessed = 0UL; dirent->fCreated = delete_or_create ? 0UL : 1UL; dirent->fDeleted = delete_or_create ? 1UL : 0UL; |
