RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 08-Feb-2008 18:42:48
Branch: HEAD Handle: 2008020817424701
Modified files:
rpm CHANGES
rpm/rpmio librpmio.vers rpmdav.c rpmhash.c rpmhash.h
rpmrpc.c
Log:
- jbj: use hashFunctionString on URI path for st->st_ino/dp->d_ino values.
- jbj: rpmhash: expose hash{Equality,Function}String routines.
Summary:
Revision Changes Path
1.2153 +2 -0 rpm/CHANGES
2.36 +2 -0 rpm/rpmio/librpmio.vers
2.58 +24 -17 rpm/rpmio/rpmdav.c
1.10 +8 -23 rpm/rpmio/rpmhash.c
1.5 +24 -5 rpm/rpmio/rpmhash.h
2.65 +22 -16 rpm/rpmio/rpmrpc.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2152 -r1.2153 CHANGES
--- rpm/CHANGES 8 Feb 2008 16:31:43 -0000 1.2152
+++ rpm/CHANGES 8 Feb 2008 17:42:47 -0000 1.2153
@@ -1,4 +1,6 @@
5.0.0 -> 5.1a1:
+ - jbj: use hashFunctionString on URI path for st->st_ino/dp->d_ino values.
+ - jbj: rpmhash: expose hash{Equality,Function}String routines.
- jbj: tweak up tdir debugging spew, add a Fts(3) stopwatch, append pesky /.
- jbj: tweak up tfts debugging spew, add a Fts(3) stopwatch, append pesky /.
- jbj: rpmsw: add rpmswPrint to display stopwtch results.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/librpmio.vers
============================================================================
$ cvs diff -u -r2.35 -r2.36 librpmio.vers
--- rpm/rpmio/librpmio.vers 8 Feb 2008 15:08:14 -0000 2.35
+++ rpm/rpmio/librpmio.vers 8 Feb 2008 17:42:48 -0000 2.36
@@ -114,6 +114,8 @@
_Glob_pattern_p;
gnameToGid;
gzdio;
+ hashEqualityString;
+ hashFunctionString;
htAddEntry;
htCreate;
htFree;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmdav.c
============================================================================
$ cvs diff -u -r2.57 -r2.58 rpmdav.c
--- rpm/rpmio/rpmdav.c 8 Feb 2008 15:08:14 -0000 2.57
+++ rpm/rpmio/rpmdav.c 8 Feb 2008 17:42:48 -0000 2.58
@@ -63,8 +63,10 @@
#define _RPMDAV_INTERNAL
#include <rpmdav.h>
-#include "argv.h"
-#include "ugid.h"
+#include <rpmhash.h>
+#include <argv.h>
+#include <ugid.h>
+
#include "debug.h"
/* Should http OPTIONS be run only once? */
@@ -1469,12 +1471,9 @@
return buf;
}
-/*@unchecked@*/
-static unsigned int dav_st_ino = 0xdead0000;
-
int davStat(const char * path, /*@out@*/ struct stat *st)
- /*@globals dav_st_ino, fileSystem, internalState @*/
- /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies *st, fileSystem, internalState @*/
{
struct fetch_context_s * ctx = NULL;
char buf[1024];
@@ -1507,9 +1506,10 @@
st->st_mode |= 0644;
}
- /* XXX fts(3) needs/uses st_ino, make something up for now. */
+ /* XXX Fts(3) needs/uses st_ino. */
+ /* Hash the path to generate a st_ino analogue. */
if (st->st_ino == 0)
- st->st_ino = dav_st_ino++;
+ st->st_ino = hashFunctionString(0, path, 0);
exit:
if (_dav_debug < 0)
@@ -1519,8 +1519,8 @@
}
int davLstat(const char * path, /*@out@*/ struct stat *st)
- /*@globals dav_st_ino, fileSystem, internalState @*/
- /*@modifies *st, dav_st_ino, fileSystem, internalState @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies *st, fileSystem, internalState @*/
{
struct fetch_context_s * ctx = NULL;
char buf[1024];
@@ -1552,9 +1552,11 @@
st->st_mode |= 0644;
}
- /* XXX fts(3) needs/uses st_ino, make something up for now. */
+ /* XXX fts(3) needs/uses st_ino. */
+ /* Hash the path to generate a st_ino analogue. */
if (st->st_ino == 0)
- st->st_ino = dav_st_ino++;
+ st->st_ino = hashFunctionString(0, path, 0);
+
if (_dav_debug < 0)
fprintf(stderr, "*** davLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
exit:
@@ -1673,7 +1675,9 @@
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
- dp->d_ino = i + 1; /* W2DO? */
+ /* Hash the name (starting with parent hash) for a d_ino analogue. */
+ dp->d_ino = hashFunctionString(avdir->filepos, dp->d_name, 0);
+
#if !defined(__DragonFly__) && !defined(__CYGWIN__)
dp->d_reclen = 0; /* W2DO? */
#endif
@@ -1724,7 +1728,8 @@
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
- avdir->filepos = 0;
+ /* Hash the directory path for a d_ino analogue. */
+ avdir->filepos = hashFunctionString(0, path, 0);
#if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon -nullpass @*/
@@ -1795,7 +1800,8 @@
/* XXX glob(3) uses REAL_DIR_ENTRY(dp) test on d_ino */
/*@-type@*/
- dp->d_ino = i + 1; /* W2DO? */
+ /* Hash the name (starting with parent hash) for a d_ino analogue. */
+ dp->d_ino = hashFunctionString(avdir->filepos, dp->d_name, 0);
#if !defined(__DragonFly__) && !defined(__CYGWIN__)
dp->d_reclen = 0; /* W2DO? */
#endif
@@ -1876,7 +1882,8 @@
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
- avdir->filepos = 0;
+ /* Hash the directory path for a d_ino analogue. */
+ avdir->filepos = hashFunctionString(0, path, 0);
#if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon -nullpass @*/
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmhash.c
============================================================================
$ cvs diff -u -r1.9 -r1.10 rpmhash.c
--- rpm/rpmio/rpmhash.c 16 Dec 2007 22:54:40 -0000 1.9
+++ rpm/rpmio/rpmhash.c 8 Feb 2008 17:42:48 -0000 1.10
@@ -67,15 +67,14 @@
return b;
}
-/**
- * Return hash value of a string.
- * @param h hash initial value
- * @param data data on which to calculate hash value
- * @param size size of data in bytes
- * @return hash value
- */
-static uint32_t hashFunctionString(uint32_t h, const void * data, size_t size)
- /*@*/
+int hashEqualityString(const void * key1, const void * key2)
+{
+ const char *k1 = (const char *)key1;
+ const char *k2 = (const char *)key2;
+ return strcmp(k1, k2);
+}
+
+uint32_t hashFunctionString(uint32_t h, const void * data, size_t size)
{
const char *key = data;
@@ -142,20 +141,6 @@
return h;
}
-/**
- * Compare two hash table entries for equality.
- * @param key1 entry 1
- * @param key2 entry 2
- * @return 0 if entries are equal
- */
-static int hashEqualityString(const void * key1, const void * key2)
- /*@*/
-{
- const char *k1 = (const char *)key1;
- const char *k2 = (const char *)key2;
- return strcmp(k1, k2);
-}
-
hashTable htCreate(int numBuckets, size_t keySize, int freeData,
hashFunctionType fn, hashEqualityType eq)
{
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmhash.h
============================================================================
$ cvs diff -u -r1.4 -r1.5 rpmhash.h
--- rpm/rpmio/rpmhash.h 4 Nov 2007 01:14:29 -0000 1.4
+++ rpm/rpmio/rpmhash.h 8 Feb 2008 17:42:48 -0000 1.5
@@ -15,6 +15,24 @@
#endif
/**
+ * Compare two hash table entries for equality.
+ * @param key1 entry 1
+ * @param key2 entry 2
+ * @return 0 if entries are equal
+ */
+typedef int (*hashEqualityType) (const void * key1, const void * key2)
+ /*@*/;
+
+/**
+ * Compare two hash table entries for equality.
+ * @param key1 entry 1
+ * @param key2 entry 2
+ * @return 0 if entries are equal
+ */
+int hashEqualityString(const void * key1, const void * key2)
+ /*@*/;
+
+/**
* Return hash value.
* @param h hash initial value
* @param data data on which to calculate hash value
@@ -25,12 +43,13 @@
/*@*/;
/**
- * Compare two hash table entries for equality.
- * @param key1 entry 1
- * @param key2 entry 2
- * @return 0 if entries are equal
+ * Return hash value of a string.
+ * @param h hash initial value
+ * @param data data on which to calculate hash value
+ * @param size size of data in bytes (0 will use strlen(data))
+ * @return hash value
*/
-typedef int (*hashEqualityType) (const void * key1, const void * key2)
+uint32_t hashFunctionString(uint32_t h, const void * data, size_t size)
/*@*/;
/**
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmio/rpmrpc.c
============================================================================
$ cvs diff -u -r2.64 -r2.65 rpmrpc.c
--- rpm/rpmio/rpmrpc.c 7 Feb 2008 19:29:33 -0000 2.64
+++ rpm/rpmio/rpmrpc.c 8 Feb 2008 17:42:48 -0000 2.65
@@ -4,13 +4,15 @@
#include "system.h"
-#include "rpmio_internal.h"
-#include "rpmmacro.h"
+#include <rpmio_internal.h>
+#include <rpmmacro.h>
#define _RPMDAV_INTERNAL
-#include "rpmdav.h"
+#include <rpmdav.h>
+
+#include <rpmhash.h>
+#include <ugid.h>
-#include "ugid.h"
#include "debug.h"
/*@access DIR @*/
@@ -1157,20 +1159,20 @@
return buf;
}
-/*@unchecked@*/
-static int ftp_st_ino = 0xdead0000;
-
/* FIXME: borked for path with trailing '/' */
static int ftpStat(const char * path, /*@out@*/ struct stat *st)
- /*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
- /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
+ /*@globals h_errno, fileSystem, internalState @*/
+ /*@modifies *st, fileSystem, internalState @*/
{
char buf[1024];
int rc;
rc = ftpNLST(path, DO_FTP_STAT, st, NULL, 0);
- /* XXX fts(3) needs/uses st_ino, make something up for now. */
+
+ /* XXX fts(3) needs/uses st_ino. */
+ /* Hash the path to generate a st_ino analogue. */
if (st->st_ino == 0)
- st->st_ino = ftp_st_ino++;
+ st->st_ino = hashFunctionString(0, path, 0);
+
if (_ftp_debug)
fprintf(stderr, "*** ftpStat(%s) rc %d\n%s", path, rc, statstr(st, buf));
return rc;
@@ -1178,15 +1180,18 @@
/* FIXME: borked for path with trailing '/' */
static int ftpLstat(const char * path, /*@out@*/ struct stat *st)
- /*@globals ftp_st_ino, h_errno, fileSystem, internalState @*/
- /*@modifies *st, ftp_st_ino, fileSystem, internalState @*/
+ /*@globals h_errno, fileSystem, internalState @*/
+ /*@modifies *st, fileSystem, internalState @*/
{
char buf[1024];
int rc;
rc = ftpNLST(path, DO_FTP_LSTAT, st, NULL, 0);
- /* XXX fts(3) needs/uses st_ino, make something up for now. */
+
+ /* XXX fts(3) needs/uses st_ino. */
+ /* Hash the path to generate a st_ino analogue. */
if (st->st_ino == 0)
- st->st_ino = ftp_st_ino++;
+ st->st_ino = hashFunctionString(0, path, 0);
+
if (_ftp_debug)
fprintf(stderr, "*** ftpLstat(%s) rc %d\n%s\n", path, rc, statstr(st, buf));
return rc;
@@ -1272,7 +1277,8 @@
avdir->allocation = nb;
avdir->size = ac;
avdir->offset = -1;
- avdir->filepos = 0;
+ /* Hash the directory path for a d_ino analogue. */
+ avdir->filepos = hashFunctionString(0, path, 0);
#if defined(HAVE_PTHREAD_H)
/*@-moduncon -noeffectuncon@*/
@@ .
Received on Fri Feb 8 18:42:48 2008