Ejemplo n.º 1
0
/*
 * Hash sum building routine.  Use string hash if the buildpath routine
 * is the standard one, otherwise use binary hashes.  A bit whimsical
 * way to choose the routine, but the binary works for strings also,
 * so don't sweat it.
 */
void
puffs_path_buildhash(struct puffs_usermount *pu, struct puffs_pathobj *po)
{

	if ((pu->pu_flags & PUFFS_FLAG_HASHPATH) == 0)
		return;

	if (pu->pu_pathbuild == puffs_stdpath_buildpath)
		po->po_hash = hash32_strn(po->po_path, po->po_len,
		    HASH32_STR_INIT);
	else
		po->po_hash = hash32_buf(po->po_path, po->po_len,
		    HASH32_BUF_INIT);
}
Ejemplo n.º 2
0
/*
 * Lack of inode numbers leads us to the problem of generating them.
 * Partially this problem can be solved by having a dir/file cache
 * with inode numbers generated from the incremented by one counter.
 * However this way will require too much kernel memory, gives all
 * sorts of locking and consistency problems, not to mentinon counter overflows.
 * So, I'm decided to use a hash function to generate pseudo random (and unique)
 * inode numbers.
 */
static long
smbfs_getino(struct smbnode *dnp, const char *name, int nmlen)
{
#ifdef USE_MD5_HASH
	MD5_CTX md5;
	u_int32_t state[4];
	long ino;
	int i;

	MD5Init(&md5);
	MD5Update(&md5, name, nmlen);
	MD5Final((u_char *)state, &md5);
	for (i = 0, ino = 0; i < 4; i++)
		ino += state[i];
	return dnp->n_ino + ino;
#endif
	u_int32_t ino;

	ino = dnp->n_ino + hash32_strn(name, nmlen, HASH32_STR_INIT);
	if (ino <= 2)
		ino += 3;
	return ino;
}