Skip to content

Commit 4e2eded

Browse files
committed
test hash code
1 parent d7e0c9b commit 4e2eded

File tree

6 files changed

+330
-222
lines changed

6 files changed

+330
-222
lines changed

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
obj-m += simplefs.o
2-
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o
3-
2+
simplefs-objs := fs.o super.o inode.o file.o dir.o extent.o symlink.o hash.o
43
KDIR ?= /lib/modules/$(shell uname -r)/build
54

65
MKFS = mkfs.simplefs

hash.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <linux/types.h>
2+
#include "simplefs.h"
3+
4+
uint64_t fnv1a_64(const char *str)
5+
{
6+
uint64_t h = 0xcbf29ce484222325ULL;
7+
while (*str) {
8+
h ^= (unsigned char)(*str++);
9+
h *= 0x100000001b3ULL;
10+
}
11+
return h;
12+
}
13+

0 commit comments

Comments
 (0)