[Ocfs2-tools-devel] [PATCH 4/5] ocfs2-tools: add xattr_uuid_hash in libocfs2

tristan.ye tristan.ye at oracle.com
Sat Oct 25 19:14:53 PDT 2008


On Fri, 2008-10-24 at 17:58 +0800, Coly Li wrote:
> 
> Tiger Yang Wrote:
> > 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 68ba4f5..4aa24f5 100644
> > --- a/include/ocfs2/ocfs2.h
> > +++ b/include/ocfs2/ocfs2.h
> > @@ -1040,4 +1040,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 446c8b4..569d2af 100644
> > --- a/libocfs2/Makefile
> > +++ b/libocfs2/Makefile
> > @@ -72,7 +72,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++;
> Maybe *(uuid ++) is more clear ?

seems it was clear enough here since the '++' operator has higher
priority than '*':)

> 
> > +	}
> > +	return hash;
> > +}
> > +
> 




More information about the Ocfs2-tools-devel mailing list