[Ocfs2-tools-devel] [PATCH 3/9] ocfs2-tools: add xattr_uuid_hash in libocfs2
Tiger Yang
tiger.yang at oracle.com
Sat Jan 24 00:03:01 PST 2009
this function use to calculate uuid hash, this hash value will be
used as random seed to calculate xattr hash.
Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
---
include/ocfs2/ocfs2.h | 2 ++
libocfs2/Makefile | 3 ++-
libocfs2/xattr.c | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 1 deletions(-)
create mode 100644 libocfs2/xattr.c
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 7f00786..7b7f91d 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -1085,4 +1085,6 @@ errcode_t ocfs2_block_iterate_inode(ocfs2_filesys *fs,
void *priv_data),
void *priv_data);
+uint32_t xattr_uuid_hash(unsigned char *uuid);
+
#endif /* _FILESYS_H */
diff --git a/libocfs2/Makefile b/libocfs2/Makefile
index 3add6b4..b75cea6 100644
--- a/libocfs2/Makefile
+++ b/libocfs2/Makefile
@@ -73,7 +73,8 @@ CFILES = \
lockid.c \
backup_super.c \
feature_string.c\
- image.c
+ image.c \
+ xattr.c
HFILES = \
bitmap.h \
diff --git a/libocfs2/xattr.c b/libocfs2/xattr.c
new file mode 100644
index 0000000..287ce0e
--- /dev/null
+++ b/libocfs2/xattr.c
@@ -0,0 +1,34 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * xattr.c
+ *
+ * Copyright (C) 2004, 2008 Oracle. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+#include <string.h>
+#include <inttypes.h>
+
+#include "ocfs2/byteorder.h"
+#include "ocfs2/ocfs2.h"
+
+uint32_t xattr_uuid_hash(unsigned char *uuid)
+{
+ uint32_t i, hash = 0;
+
+ for (i = 0; i < OCFS2_VOL_UUID_LEN; i++) {
+ hash = (hash << OCFS2_HASH_SHIFT) ^
+ (hash >> (8*sizeof(hash) - OCFS2_HASH_SHIFT)) ^
+ *uuid++;
+ }
+ return hash;
+}
+
--
1.5.4.4
More information about the Ocfs2-tools-devel
mailing list