source3: Replace ccan hash calls with tdb_jenkins_hash
authorVolker Lendecke <vl@samba.org>
Thu, 12 Mar 2015 15:00:58 +0000 (15:00 +0000)
committerMichael Adam <obnox@samba.org>
Tue, 17 Mar 2015 10:30:52 +0000 (11:30 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/lib/util.c
source3/libsmb/smb_share_modes.c
source3/modules/vfs_shadow_copy2.c
source3/smbd/files.c
source3/smbd/smbXsrv_open.c

index e53953b085f0388438c5c79b38a9eeae21d39e32..e296fd5e0f9f87585237094a630b80b37080df27 100644 (file)
@@ -28,7 +28,6 @@
 #include "ctdbd_conn.h"
 #include "../lib/util/util_pw.h"
 #include "messages.h"
-#include <ccan/hash/hash.h>
 #include "libcli/security/security.h"
 #include "serverid.h"
 #include "lib/sys_rw.h"
@@ -1321,9 +1320,14 @@ const char *tab_depth(int level, int depth)
 
 int str_checksum(const char *s)
 {
+       TDB_DATA key;
        if (s == NULL)
                return 0;
-       return hash(s, strlen(s), 0);
+
+       key = (TDB_DATA) { .dptr = discard_const_p(uint8_t, s),
+                          .dsize = strlen(s) };
+
+       return tdb_jenkins_hash(&key);
 }
 
 /*****************************************************************
index ddab0ca1279a1de8b1cf443ac2def33118255dea..d42ebc61400e6abbe01654a60d3b713f83a8c648 100644 (file)
@@ -37,7 +37,6 @@
 #include "smb_share_modes.h"
 #include <tdb.h>
 #include "librpc/gen_ndr/open_files.h"
-#include <ccan/hash/hash.h>
 
 /* Database context handle. */
 struct smbdb_ctx {
@@ -307,6 +306,7 @@ static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *
        size_t sharepath_size = strlen(sharepath);
        size_t filename_size = strlen(filename);
        uint32_t name_hash;
+       TDB_DATA key;
 
        *err = 0;
        fullpath = (char *)malloc(sharepath_size + filename_size + 2);
@@ -318,7 +318,9 @@ static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *
        fullpath[sharepath_size] = '/';
        memcpy(&fullpath[sharepath_size + 1], filename, filename_size + 1);
 
-       name_hash = hash(fullpath, strlen(fullpath) + 1, 0);
+       key = (TDB_DATA) { .dptr = (uint8_t *)fullpath,
+                          .dsize = strlen(fullpath) + 1 };
+       name_hash = tdb_jenkins_hash(&key);
        free(fullpath);
        return name_hash;
 }
index 2a7a3a954b81fbbaba29e8be4402893528a7cc23..6b4f8ed8475fd4601ca116e829556bfaef39a8fd 100644 (file)
@@ -32,7 +32,6 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "include/ntioctl.h"
-#include <ccan/hash/hash.h>
 #include "util_tdb.h"
 
 struct shadow_copy2_config {
@@ -647,9 +646,11 @@ static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
                   number collision, but I can't see a better approach
                   without significant VFS changes
                */
+               TDB_DATA key = { .dptr = discard_const_p(uint8_t, fname),
+                                .dsize = strlen(fname) };
                uint32_t shash;
 
-               shash = hash(fname, strlen(fname), 0) & 0xFF000000;
+               shash = tdb_jenkins_hash(&key) & 0xFF000000;
                if (shash == 0) {
                        shash = 1;
                }
index 5b3741bb8658a487da72ea76649a363b028a9e60..829423e2e3013d5647900fcb9990c7dad577fb7d 100644 (file)
@@ -22,7 +22,6 @@
 #include "smbd/globals.h"
 #include "libcli/security/security.h"
 #include "util_tdb.h"
-#include <ccan/hash/hash.h>
 #include "lib/util/bitmap.h"
 
 #define FILE_HANDLE_OFFSET 0x1000
@@ -729,6 +728,7 @@ NTSTATUS file_name_hash(connection_struct *conn,
        char tmpbuf[PATH_MAX];
        char *fullpath, *to_free;
        ssize_t len;
+       TDB_DATA key;
 
        /* Set the hash of the full pathname. */
 
@@ -737,7 +737,8 @@ NTSTATUS file_name_hash(connection_struct *conn,
        if (len == -1) {
                return NT_STATUS_NO_MEMORY;
        }
-       *p_name_hash = hash(fullpath, len+1, 0);
+       key = (TDB_DATA) { .dptr = (uint8_t *)fullpath, .dsize = len+1 };
+       *p_name_hash = tdb_jenkins_hash(&key);
 
        DEBUG(10,("file_name_hash: %s hash 0x%x\n",
                  fullpath,
index 03b0123bba9120c212a0ae90946669cf1d38346f..2440ecb26410b9420333ce181491cbc05ed1e08d 100644 (file)
@@ -29,7 +29,6 @@
 #include "messages.h"
 #include "lib/util/util_tdb.h"
 #include "librpc/gen_ndr/ndr_smbXsrv.h"
-#include <ccan/hash/hash.h>
 #include "serverid.h"
 
 struct smbXsrv_open_table {
@@ -889,12 +888,14 @@ uint32_t smbXsrv_open_hash(struct smbXsrv_open *_open)
 {
        uint8_t buf[8+8+8];
        uint32_t ret;
+       TDB_DATA key;
 
        SBVAL(buf,  0, _open->global->open_persistent_id);
        SBVAL(buf,  8, _open->global->open_volatile_id);
        SBVAL(buf, 16, _open->global->open_time);
 
-       ret = hash(buf, sizeof(buf), 0);
+       key = (TDB_DATA) { .dptr = buf, .dsize = sizeof(buf) };
+       ret = tdb_jenkins_hash(&key);
 
        if (ret == 0) {
                ret = 1;