db3.c | db3.c | |||
---|---|---|---|---|
skipping to change at line 410 | skipping to change at line 410 | |||
_ENTRY(GET_BOTH_LTE), /* Dbc.get (internal) */ | _ENTRY(GET_BOTH_LTE), /* Dbc.get (internal) */ | |||
#endif | #endif | |||
_ENTRY(IGNORE_LEASE), | _ENTRY(IGNORE_LEASE), | |||
_ENTRY(READ_COMMITTED), | _ENTRY(READ_COMMITTED), | |||
_ENTRY(READ_UNCOMMITTED), | _ENTRY(READ_UNCOMMITTED), | |||
_ENTRY(MULTIPLE), | _ENTRY(MULTIPLE), | |||
_ENTRY(MULTIPLE_KEY), | _ENTRY(MULTIPLE_KEY), | |||
_ENTRY(RMW), | _ENTRY(RMW), | |||
}; | }; | |||
#undef _ENTRY | ||||
/*@unchecked@*/ | /*@unchecked@*/ | |||
static size_t nDBCflags = sizeof(DBCflags) / sizeof(DBCflags[0]); | static size_t nDBCflags = sizeof(DBCflags) / sizeof(DBCflags[0]); | |||
/*@observer@*/ | /*@observer@*/ | |||
static const char * fmtDBCflags(uint32_t flags) | static const char * fmtDBCflags(uint32_t flags) | |||
/*@*/ | /*@*/ | |||
{ | { | |||
static char buf[BUFSIZ]; | static char buf[BUFSIZ]; | |||
char * te = buf; | char * te = buf; | |||
uint32_t op = (flags & DB_OPFLAGS_MASK); | uint32_t op = (flags & DB_OPFLAGS_MASK); | |||
flags &= ~DB_OPFLAGS_MASK; | flags &= ~DB_OPFLAGS_MASK; | |||
te = stpcpy(te, "\n\tflags: "); | te = stpcpy(te, "\n\tflags: "); | |||
skipping to change at line 446 | skipping to change at line 448 | |||
_DBT_ENTRY(MALLOC), | _DBT_ENTRY(MALLOC), | |||
_DBT_ENTRY(REALLOC), | _DBT_ENTRY(REALLOC), | |||
_DBT_ENTRY(USERMEM), | _DBT_ENTRY(USERMEM), | |||
_DBT_ENTRY(PARTIAL), | _DBT_ENTRY(PARTIAL), | |||
_DBT_ENTRY(APPMALLOC), | _DBT_ENTRY(APPMALLOC), | |||
_DBT_ENTRY(MULTIPLE), | _DBT_ENTRY(MULTIPLE), | |||
#if defined(DB_DBT_READONLY) /* XXX db-5.2.28 */ | #if defined(DB_DBT_READONLY) /* XXX db-5.2.28 */ | |||
_DBT_ENTRY(READONLY), | _DBT_ENTRY(READONLY), | |||
#endif | #endif | |||
}; | }; | |||
#undef _DBT_ENTRY | ||||
/*@unchecked@*/ | /*@unchecked@*/ | |||
static size_t nDBTflags = sizeof(DBTflags) / sizeof(DBTflags[0]); | static size_t nDBTflags = sizeof(DBTflags) / sizeof(DBTflags[0]); | |||
/*@observer@*/ | /*@observer@*/ | |||
static char * fmtDBT(const DBT * K, char * te) | static char * fmtDBT(const DBT * K, char * te) | |||
/*@modifies te @*/ | /*@modifies te @*/ | |||
{ | { | |||
static size_t keymax = 35; | static size_t keymax = 35; | |||
int unprintable; | int unprintable; | |||
uint32_t i; | uint32_t i; | |||
sprintf(te, "%p[%u]\t", K->data, (unsigned)K->size); | sprintf(te, "%p[%u]\t", K->data, (unsigned)K->size); | |||
te += strlen(te); | te += strlen(te); | |||
skipping to change at line 524 | skipping to change at line 528 | |||
if (R) { | if (R) { | |||
te = stpcpy(te, "\n\t res: "); | te = stpcpy(te, "\n\t res: "); | |||
te = fmtDBT(R, te); | te = fmtDBT(R, te); | |||
} | } | |||
*te = '\0'; | *te = '\0'; | |||
return buf; | return buf; | |||
} | } | |||
#define _KEYDATA(_K, _P, _D, _R) fmtKDR(_K, _P, _D, _R) | #define _KEYDATA(_K, _P, _D, _R) fmtKDR(_K, _P, _D, _R) | |||
#undef _ENTRY | ||||
/*@-globuse -mustmod @*/ /* FIX: rpmError not annotated yet. */ | /*@-globuse -mustmod @*/ /* FIX: rpmError not annotated yet. */ | |||
static int Xcvtdberr(/*@unused@*/ dbiIndex dbi, const char * msg, | static int Xcvtdberr(/*@unused@*/ dbiIndex dbi, const char * msg, | |||
int error, int printit, | int error, int printit, | |||
const char * func, const char * fn, unsigned ln) | const char * func, const char * fn, unsigned ln) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
int rc = error; | int rc = error; | |||
if (printit && rc) { | if (printit && rc) { | |||
skipping to change at line 1127 | skipping to change at line 1129 | |||
/*@=moduncon@*/ | /*@=moduncon@*/ | |||
#ifdef NOTYET | #ifdef NOTYET | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3remove(dbiIndex dbi, /*@null@*/ const char * dbfile, | static int db3remove(dbiIndex dbi, /*@null@*/ const char * dbfile, | |||
/*@unused@*/ /*@null@*/ const char * dbsubfile, | /*@unused@*/ /*@null@*/ const char * dbsubfile, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->remove(db, dbfile, dbsubfile, flags); | rc = db->remove(db, dbfile, dbsubfile, flags); | |||
rc = cvtdberr(dbi, "db->remove", rc, _debug); | rc = cvtdberr(dbi, "db->remove", rc, _debug); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%s,0x%x) rc %d\n", __FUNCTION__, dbi, dbfile, dbsubfile, flags, rc)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%s,0x%x) rc %d\n", __FUNCTION__, dbi, dbfile, dbsubfile, flags, rc)); | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3rename(dbiIndex dbi, /*@null@*/ const char * dbfile, | static int db3rename(dbiIndex dbi, /*@null@*/ const char * dbfile, | |||
/*@unused@*/ /*@null@*/ const char * dbsubfile, | /*@unused@*/ /*@null@*/ const char * dbsubfile, | |||
/*@unused@*/ /*@null@*/ const char * newname, | /*@unused@*/ /*@null@*/ const char * newname, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->rename(db, dbfile, dbsubfile, newname, flags); | rc = db->rename(db, dbfile, dbsubfile, newname, flags); | |||
rc = cvtdberr(dbi, "db->rename", rc, _debug); | rc = cvtdberr(dbi, "db->rename", rc, _debug); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%s,%s,0x%x) rc %d %s\n", __FUNCTION__, dbi, dbfile, dbsubfile, newname, flags, rc, _DBCFLAGS(flags))); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%s,%s,0x%x) rc %d %s\n", __FUNCTION__, dbi, dbfile, dbsubfile, newname, flags, rc, _DBCFLAGS(flags))); | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3truncate(dbiIndex dbi, unsigned int * countp, unsigned int fl ags) | static int db3truncate(dbiIndex dbi, unsigned int * countp, unsigned int fl ags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies *countp, fileSystem @*/ | /*@modifies *countp, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->truncate(db, _txnid, countp, flags); | rc = db->truncate(db, _txnid, countp, flags); | |||
rc = cvtdberr(dbi, "db->truncate", rc, _debug); | rc = cvtdberr(dbi, "db->truncate", rc, _debug); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,0x%x) rc %d\n", __FUNCTION__, dbi, cou ntp, flags, rc)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,0x%x) rc %d\n", __FUNCTION__, dbi, cou ntp, flags, rc)); | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3upgrade(dbiIndex dbi, /*@null@*/ const char * dbfile, | static int db3upgrade(dbiIndex dbi, /*@null@*/ const char * dbfile, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->upgrade(db, dbfile, flags); | rc = db->upgrade(db, dbfile, flags); | |||
rc = cvtdberr(dbi, "db->upgrade", rc, _debug); | rc = cvtdberr(dbi, "db->upgrade", rc, _debug); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,0x%x) rc %d\n", __FUNCTION__, dbi, dbf ile, flags, rc)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,0x%x) rc %d\n", __FUNCTION__, dbi, dbf ile, flags, rc)); | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
#endif /* NOTYET */ | #endif /* NOTYET */ | |||
static int db3sync(dbiIndex dbi, unsigned int flags) | static int db3sync(dbiIndex dbi, unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc = 0; | int rc = 0; | |||
int _printit; | int _printit; | |||
if (db != NULL) | if (db != NULL) | |||
rc = db->sync(db, flags); | rc = db->sync(db, flags); | |||
_printit = _debug; | _printit = _debug; | |||
rc = cvtdberr(dbi, "db->sync", rc, _printit); | rc = cvtdberr(dbi, "db->sync", rc, _printit); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,0x%x) rc %d\n", __FUNCTION__, dbi, flags, rc)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,0x%x) rc %d\n", __FUNCTION__, dbi, flags, rc)); | |||
return rc; | return rc; | |||
} | } | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3exists(dbiIndex dbi, DBT * key, unsigned int flags) | static int db3exists(dbiIndex dbi, DBT * key, unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int _printit; | int _printit; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->exists(db, _txnid, key, flags); | rc = db->exists(db, _txnid, key, flags); | |||
/* XXX DB_NOTFOUND can be returned */ | /* XXX DB_NOTFOUND can be returned */ | |||
_printit = (rc == DB_NOTFOUND ? 0 : _debug); | _printit = (rc == DB_NOTFOUND ? 0 : _debug); | |||
rc = cvtdberr(dbi, "db->exists", rc, _printit); | rc = cvtdberr(dbi, "db->exists", rc, _printit); | |||
skipping to change at line 1245 | skipping to change at line 1247 | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3seqno(dbiIndex dbi, int64_t * seqnop, unsigned int flags) | static int db3seqno(dbiIndex dbi, int64_t * seqnop, unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies *seqnop, fileSystem @*/ | /*@modifies *seqnop, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
DB_SEQUENCE * seq = dbi->dbi_seq; | DB_SEQUENCE * seq = (DB_SEQUENCE *) dbi->dbi_seq; | |||
int32_t _delta = 1; | int32_t _delta = 1; | |||
db_seq_t seqno = 0; | db_seq_t seqno = 0; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
assert(seq != NULL); | assert(seq != NULL); | |||
if (seqnop && *seqnop) | if (seqnop && *seqnop) | |||
_delta = *seqnop; | _delta = *seqnop; | |||
skipping to change at line 1323 | skipping to change at line 1325 | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
static int db3copen(dbiIndex dbi, DB_TXN * txnid, | static int db3copen(dbiIndex dbi, DB_TXN * txnid, | |||
/*@null@*/ /*@out@*/ DBC ** dbcp, unsigned int dbiflags) | /*@null@*/ /*@out@*/ DBC ** dbcp, unsigned int dbiflags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, *dbcp, fileSystem @*/ | /*@modifies dbi, *dbcp, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DBC * dbcursor = NULL; | DBC * dbcursor = NULL; | |||
int flags; | int flags; | |||
int rc; | int rc; | |||
/* XXX DB_WRITECURSOR cannot be used with sunrpc dbenv. */ | /* XXX DB_WRITECURSOR cannot be used with sunrpc dbenv. */ | |||
assert(db != NULL); | assert(db != NULL); | |||
if ((dbiflags & DB_WRITECURSOR) && | if ((dbiflags & DB_WRITECURSOR) && | |||
(dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY)) | (dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY)) | |||
{ | { | |||
flags = DB_WRITECURSOR; | flags = DB_WRITECURSOR; | |||
skipping to change at line 1354 | skipping to change at line 1356 | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,0x%x) dbc %p %s rc %d\n", __FUNCTIO N__, dbi, txnid, dbcp, dbiflags, dbcursor, _DBCOFLAGS(flags), rc)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,0x%x) dbc %p %s rc %d\n", __FUNCTIO N__, dbi, txnid, dbcp, dbiflags, dbcursor, _DBCOFLAGS(flags), rc)); | |||
return rc; | return rc; | |||
} | } | |||
static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | |||
/*@unused@*/ unsigned int flags) | /*@unused@*/ unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
if (dbcursor == NULL) { | if (dbcursor == NULL) { | |||
flags = 0; | flags = 0; | |||
rc = db->put(db, _txnid, key, data, flags); | rc = db->put(db, _txnid, key, data, flags); | |||
rc = cvtdberr(dbi, "db->put", rc, _debug); | rc = cvtdberr(dbi, "db->put", rc, _debug); | |||
} else { | } else { | |||
flags = DB_KEYLAST; | flags = DB_KEYLAST; | |||
skipping to change at line 1384 | skipping to change at line 1386 | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,%p,0x%x) rc %d %s%s\n", __FUNCTION_ _, dbi, dbcursor, key, data, flags, rc, _DBCFLAGS(flags), _KEYDATA(key, NUL L, data, NULL))); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,%p,0x%x) rc %d %s%s\n", __FUNCTION_ _, dbi, dbcursor, key, data, flags, rc, _DBCFLAGS(flags), _KEYDATA(key, NUL L, data, NULL))); | |||
return rc; | return rc; | |||
} | } | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies *dbcursor, *key, *data, fileSystem @*/ | /*@modifies *dbcursor, *key, *data, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int _printit; | int _printit; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
if (dbcursor == NULL) { | if (dbcursor == NULL) { | |||
/* XXX duplicates require cursors. */ | /* XXX duplicates require cursors. */ | |||
rc = db->get(db, _txnid, key, data, flags); | rc = db->get(db, _txnid, key, data, flags); | |||
/* XXX DB_NOTFOUND can be returned */ | /* XXX DB_NOTFOUND can be returned */ | |||
_printit = (rc == DB_NOTFOUND ? 0 : _debug); | _printit = (rc == DB_NOTFOUND ? 0 : _debug); | |||
skipping to change at line 1425 | skipping to change at line 1427 | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3cpget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * pkey, | static int db3cpget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * pkey, | |||
DBT * data, unsigned int flags) | DBT * data, unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies *dbcursor, *key, *data, fileSystem @*/ | /*@modifies *dbcursor, *key, *data, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int _printit; | int _printit; | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
if (dbcursor == NULL) { | if (dbcursor == NULL) { | |||
/* XXX duplicates require cursors. */ | /* XXX duplicates require cursors. */ | |||
rc = db->pget(db, _txnid, key, pkey, data, flags); | rc = db->pget(db, _txnid, key, pkey, data, flags); | |||
/* XXX DB_NOTFOUND can be returned */ | /* XXX DB_NOTFOUND can be returned */ | |||
_printit = (rc == DB_NOTFOUND ? 0 : _debug); | _printit = (rc == DB_NOTFOUND ? 0 : _debug); | |||
skipping to change at line 1464 | skipping to change at line 1466 | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3cdel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | static int db3cdel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies *dbcursor, fileSystem @*/ | /*@modifies *dbcursor, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
if (dbcursor == NULL) { | if (dbcursor == NULL) { | |||
rc = db->del(db, _txnid, key, flags); | rc = db->del(db, _txnid, key, flags); | |||
rc = cvtdberr(dbi, "db->del", rc, _debug); | rc = cvtdberr(dbi, "db->del", rc, _debug); | |||
} else { | } else { | |||
/* XXX TODO: insure that cursor is positioned with duplicates */ | /* XXX TODO: insure that cursor is positioned with duplicates */ | |||
skipping to change at line 1519 | skipping to change at line 1521 | |||
#endif | #endif | |||
if (countp) *countp = (!rc ? count : 0); | if (countp) *countp = (!rc ? count : 0); | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,0x%x) count %d\n", __FUNCTION__, db i, dbcursor, countp, flags, count)); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%p,%p,0x%x) count %d\n", __FUNCTION__, db i, dbcursor, countp, flags, count)); | |||
return rc; | return rc; | |||
} | } | |||
static int db3byteswapped(dbiIndex dbi) /*@*/ | static int db3byteswapped(dbiIndex dbi) /*@*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc = 0; | int rc = 0; | |||
if (db != NULL) { | if (db != NULL) { | |||
int isswapped = 0; | int isswapped = 0; | |||
rc = db->get_byteswapped(db, &isswapped); | rc = db->get_byteswapped(db, &isswapped); | |||
if (rc == 0) | if (rc == 0) | |||
rc = isswapped; | rc = isswapped; | |||
} | } | |||
return rc; | return rc; | |||
} | } | |||
static int db3stat(dbiIndex dbi, unsigned int flags) | static int db3stat(dbiIndex dbi, unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3) || (DB_VERSION_MAJOR = = 5) | #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3) || (DB_VERSION_MAJOR = = 5) | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
#endif | #endif | |||
int rc = 0; | int rc = 0; | |||
assert(db != NULL); | assert(db != NULL); | |||
#if defined(DB_FAST_STAT) | #if defined(DB_FAST_STAT) | |||
if (flags) | if (flags) | |||
flags = DB_FAST_STAT; | flags = DB_FAST_STAT; | |||
else | else | |||
skipping to change at line 1570 | skipping to change at line 1572 | |||
return rc; | return rc; | |||
} | } | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3associate(dbiIndex dbi, dbiIndex dbisecondary, | static int db3associate(dbiIndex dbi, dbiIndex dbisecondary, | |||
int (*callback)(DB *, const DBT *, const DBT *, DBT *), | int (*callback)(DB *, const DBT *, const DBT *, DBT *), | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB * secondary = dbisecondary->dbi_db; | DB * secondary = (DB *) dbisecondary->dbi_db; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
int rc; | int rc; | |||
assert(db != NULL); | assert(db != NULL); | |||
/*@-moduncon@*/ /* FIX: annotate db3 methods */ | /*@-moduncon@*/ /* FIX: annotate db3 methods */ | |||
rc = db->associate(db, _txnid, secondary, callback, flags); | rc = db->associate(db, _txnid, secondary, callback, flags); | |||
/*@=moduncon@*/ | /*@=moduncon@*/ | |||
rc = cvtdberr(dbi, "db->associate", rc, _debug); | rc = cvtdberr(dbi, "db->associate", rc, _debug); | |||
skipping to change at line 1604 | skipping to change at line 1606 | |||
int (*callback)(DB *, const DBT *, DBT *, const DBT *, int * ), | int (*callback)(DB *, const DBT *, DBT *, const DBT *, int * ), | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
int rc = ENOTSUP;; | int rc = ENOTSUP;; | |||
#if !defined(__LCLINT__) | #if !defined(__LCLINT__) | |||
/*@-moduncon@*/ /* FIX: annotate db3 methods */ | /*@-moduncon@*/ /* FIX: annotate db3 methods */ | |||
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || (DB_VERSION_MAJOR = = 5) | #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || (DB_VERSION_MAJOR = = 5) | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB * secondary = dbisecondary->dbi_db; | DB * secondary = (DB *) dbisecondary->dbi_db; | |||
assert(db != NULL); | assert(db != NULL); | |||
rc = db->associate_foreign(db, secondary, callback, flags); | rc = db->associate_foreign(db, secondary, callback, flags); | |||
#endif | #endif | |||
/*@=moduncon@*/ | /*@=moduncon@*/ | |||
#endif /* !defined(__LCLINT__) */ | #endif /* !defined(__LCLINT__) */ | |||
rc = cvtdberr(dbi, "db->associate_foreign", rc, _debug); | rc = cvtdberr(dbi, "db->associate_foreign", rc, _debug); | |||
if (dbi->dbi_debug || dbisecondary->dbi_debug) { | if (dbi->dbi_debug || dbisecondary->dbi_debug) { | |||
const char * tag2 = xstrdup(tagName(dbisecondary->dbi_rpmtag)); | const char * tag2 = xstrdup(tagName(dbisecondary->dbi_rpmtag)); | |||
fprintf(stderr, "<-- %s(%p(%s),%p(%s),%p,0x%x) rc %d %s\n", __FUNCTION__, d bi, tagName(dbi->dbi_rpmtag), dbisecondary, tag2, callback, flags, rc, _AFF LAGS(flags)); | fprintf(stderr, "<-- %s(%p(%s),%p(%s),%p,0x%x) rc %d %s\n", __FUNCTION__, d bi, tagName(dbi->dbi_rpmtag), dbisecondary, tag2, callback, flags, rc, _AFF LAGS(flags)); | |||
skipping to change at line 1629 | skipping to change at line 1631 | |||
return rc; | return rc; | |||
} | } | |||
/*@=mustmod@*/ | /*@=mustmod@*/ | |||
/*@-mustmod@*/ | /*@-mustmod@*/ | |||
static int db3join(dbiIndex dbi, DBC ** curslist, DBC ** dbcp, | static int db3join(dbiIndex dbi, DBC ** curslist, DBC ** dbcp, | |||
unsigned int flags) | unsigned int flags) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies dbi, fileSystem @*/ | /*@modifies dbi, fileSystem @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
int rc; | int rc; | |||
DBIDEBUG(dbi, (stderr, "--> %s(%p,%p,%p,0x%x)\n", __FUNCTION__, dbi, cursli st, dbcp, flags)); | DBIDEBUG(dbi, (stderr, "--> %s(%p,%p,%p,0x%x)\n", __FUNCTION__, dbi, cursli st, dbcp, flags)); | |||
assert(db != NULL); | assert(db != NULL); | |||
/*@-moduncon@*/ /* FIX: annotate db3 methods */ | /*@-moduncon@*/ /* FIX: annotate db3 methods */ | |||
rc = db->join(db, curslist, dbcp, flags); | rc = db->join(db, curslist, dbcp, flags); | |||
/*@=moduncon@*/ | /*@=moduncon@*/ | |||
rc = cvtdberr(dbi, "db->join", rc, _debug); | rc = cvtdberr(dbi, "db->join", rc, _debug); | |||
return rc; | return rc; | |||
} | } | |||
skipping to change at line 1655 | skipping to change at line 1657 | |||
fileSystem, internalState @*/ | fileSystem, internalState @*/ | |||
/*@modifies dbi, fileSystem, internalState @*/ | /*@modifies dbi, fileSystem, internalState @*/ | |||
{ | { | |||
rpmdb rpmdb = dbi->dbi_rpmdb; | rpmdb rpmdb = dbi->dbi_rpmdb; | |||
const char * urlfn = NULL; | const char * urlfn = NULL; | |||
const char * root; | const char * root; | |||
const char * home; | const char * home; | |||
const char * dbhome; | const char * dbhome; | |||
const char * dbfile; | const char * dbfile; | |||
const char * dbsubfile; | const char * dbsubfile; | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DB_SEQUENCE * seq = dbi->dbi_seq; | DB_SEQUENCE * seq = (DB_SEQUENCE *) dbi->dbi_seq; | |||
const char * dbiBN = mapTagName(rpmdb, dbi); | const char * dbiBN = mapTagName(rpmdb, dbi); | |||
int _printit; | int _printit; | |||
int rc = 0, xx; | int rc = 0, xx; | |||
flags = 0; /* XXX unused */ | flags = 0; /* XXX unused */ | |||
/* | /* | |||
* Get the prefix/root component and directory path. | * Get the prefix/root component and directory path. | |||
*/ | */ | |||
root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); | root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); | |||
skipping to change at line 1822 | skipping to change at line 1824 | |||
const uint64_t * b = _b; | const uint64_t * b = _b; | |||
return ((*a < *b) ? -1 : | return ((*a < *b) ? -1 : | |||
((*a > *b) ? 1 : 0)); | ((*a > *b) ? 1 : 0)); | |||
} | } | |||
static int | static int | |||
db3Acallback(DB * db, const DBT * key, const DBT * data, DBT * _r) | db3Acallback(DB * db, const DBT * key, const DBT * data, DBT * _r) | |||
/*@globals internalState @*/ | /*@globals internalState @*/ | |||
/*@modifies *_r, internalState @*/ | /*@modifies *_r, internalState @*/ | |||
{ | { | |||
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); | HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he)); | |||
HE_t Fhe = memset(alloca(sizeof(*Fhe)), 0, sizeof(*Fhe)); | HE_t Fhe = (HE_t) memset(alloca(sizeof(*Fhe)), 0, sizeof(*Fhe)); | |||
#ifdef NOTYET | #ifdef NOTYET | |||
HE_t FMhe = memset(alloca(sizeof(*FMhe)), 0, sizeof(*FMhe)); | HE_t FMhe = (HE_t) memset(alloca(sizeof(*FMhe)), 0, sizeof(*FMhe)); | |||
#endif | #endif | |||
dbiIndex dbi = db->app_private; | dbiIndex dbi = db->app_private; | |||
rpmdb rpmdb = NULL; | rpmdb rpmdb = NULL; | |||
Header h = NULL; | Header h = NULL; | |||
uint32_t hdrNum; | uint32_t hdrNum; | |||
DBT * A = NULL; | DBT * A = NULL; | |||
const char * s = NULL; | const char * s = NULL; | |||
size_t ns = 0; | size_t ns = 0; | |||
int rc = DB_DONOTINDEX; /* assume no-op */ | int rc = DB_DONOTINDEX; /* assume no-op */ | |||
uint32_t i; | uint32_t i; | |||
skipping to change at line 1900 | skipping to change at line 1902 | |||
Fhe->tag = RPMTAG_REQUIREFLAGS; | Fhe->tag = RPMTAG_REQUIREFLAGS; | |||
(void) headerGet(h, Fhe, 0); | (void) headerGet(h, Fhe, 0); | |||
break; | break; | |||
} | } | |||
switch (he->t) { | switch (he->t) { | |||
default: | default: | |||
assert(0); | assert(0); | |||
/*@notreached@*/ break; | /*@notreached@*/ break; | |||
case RPM_UINT8_TYPE: /* XXX coerce to uint32_t */ | case RPM_UINT8_TYPE: /* XXX coerce to uint32_t */ | |||
{ uint8_t * _u = he->p.ui8p; | { uint8_t * _u = (uint8_t *) he->p.ui8p; | |||
he->p.ui32p = xmalloc(he->c * sizeof(*he->p.ui32p)); | he->p.ui32p = xmalloc(he->c * sizeof(*he->p.ui32p)); | |||
for (i = 0; i < he->c; i++) | for (i = 0; i < he->c; i++) | |||
he->p.ui32p[i] = _u[i]; | he->p.ui32p[i] = _u[i]; | |||
_u = _free(_u); | _u = _free(_u); | |||
goto _ifill; | goto _ifill; | |||
} /*@notreached@*/ break; | } /*@notreached@*/ break; | |||
case RPM_UINT16_TYPE: /* XXX coerce to uint32_t */ | case RPM_UINT16_TYPE: /* XXX coerce to uint32_t */ | |||
{ uint16_t * _u = he->p.ui16p; | { uint16_t * _u = (uint16_t *) he->p.ui16p; | |||
he->p.ui32p = xmalloc(he->c * sizeof(*he->p.ui32p)); | he->p.ui32p = xmalloc(he->c * sizeof(*he->p.ui32p)); | |||
for (i = 0; i < he->c; i++) | for (i = 0; i < he->c; i++) | |||
he->p.ui32p[i] = _u[i]; | he->p.ui32p[i] = _u[i]; | |||
_u = _free(_u); | _u = _free(_u); | |||
goto _ifill; | goto _ifill; | |||
} /*@notreached@*/ break; | } /*@notreached@*/ break; | |||
case RPM_UINT32_TYPE: | case RPM_UINT32_TYPE: | |||
_ifill: | _ifill: | |||
{ uint32_t * _u = he->p.ui32p; | { uint32_t * _u = (uint32_t *) he->p.ui32p; | |||
size_t _ulen = sizeof(*_u); | size_t _ulen = sizeof(*_u); | |||
uint32_t _ube; /* XXX network order integer keys */ | uint32_t _ube; /* XXX network order integer keys */ | |||
/* Drop the transaction id usecs field (if present) when indexing. * / | /* Drop the transaction id usecs field (if present) when indexing. * / | |||
switch (he->tag) { | switch (he->tag) { | |||
case RPMTAG_INSTALLTID: | case RPMTAG_INSTALLTID: | |||
case RPMTAG_REMOVETID: | case RPMTAG_REMOVETID: | |||
he->c = 1; | he->c = 1; | |||
/*@innerbreak@*/ break; | /*@innerbreak@*/ break; | |||
default: | default: | |||
skipping to change at line 1953 | skipping to change at line 1955 | |||
if (i > 0 && _u[-1] == _u[0]) | if (i > 0 && _u[-1] == _u[0]) | |||
continue; | continue; | |||
_ube = _hton_ui(*_u); /* XXX network order integer keys */ | _ube = _hton_ui(*_u); /* XXX network order integer keys */ | |||
if (!loadDBT(A, he->tag, &_ube, _ulen)) | if (!loadDBT(A, he->tag, &_ube, _ulen)) | |||
continue; | continue; | |||
A++; | A++; | |||
_r->size++; | _r->size++; | |||
} | } | |||
} break; | } break; | |||
case RPM_UINT64_TYPE: | case RPM_UINT64_TYPE: | |||
{ uint64_t * _u = he->p.ui64p; | { uint64_t * _u = (uint64_t *) he->p.ui64p; | |||
size_t _ulen = sizeof(*_u); | size_t _ulen = sizeof(*_u); | |||
uint64_t _ube; /* XXX network order integer keys */ | uint64_t _ube; /* XXX network order integer keys */ | |||
if (he->c == 1) { | if (he->c == 1) { | |||
_ube = _hton_ul(*_u); /* XXX network order integer keys */ | _ube = _hton_ul(*_u); /* XXX network order integer keys */ | |||
/* XXX is it worth avoiding the realloc here? */ | /* XXX is it worth avoiding the realloc here? */ | |||
xx = loadDBT(_r, he->tag, _u, _ulen); | xx = loadDBT(_r, he->tag, _u, _ulen); | |||
break; | break; | |||
} | } | |||
_r->flags = DB_DBT_MULTIPLE | DB_DBT_APPMALLOC; | _r->flags = DB_DBT_MULTIPLE | DB_DBT_APPMALLOC; | |||
_r->data = A = xcalloc(he->c, sizeof(*A)); | _r->data = A = (DBT *) xcalloc(he->c, sizeof(*A)); | |||
_r->size = 0; | _r->size = 0; | |||
if (he->c > 1) | if (he->c > 1) | |||
qsort(_u, he->c, _ulen, uint64Cmp); | qsort(_u, he->c, _ulen, uint64Cmp); | |||
for (i = 0; i < he->c; i++, _u++) { | for (i = 0; i < he->c; i++, _u++) { | |||
/* Don't add identical (key,val) item to secondary. */ | /* Don't add identical (key,val) item to secondary. */ | |||
if (i > 0 && _u[-1] == _u[0]) | if (i > 0 && _u[-1] == _u[0]) | |||
continue; | continue; | |||
_ube = _hton_ul(*_u); /* XXX network order integer keys */ | _ube = _hton_ul(*_u); /* XXX network order integer keys */ | |||
if (!loadDBT(A, he->tag, &_ube, _ulen)) | if (!loadDBT(A, he->tag, &_ube, _ulen)) | |||
continue; | continue; | |||
A++; | A++; | |||
_r->size++; | _r->size++; | |||
} | } | |||
} break; | } break; | |||
case RPM_BIN_TYPE: | case RPM_BIN_TYPE: | |||
s = he->p.ptr; ns = he->c; | s = (char *) he->p.ptr; ns = he->c; | |||
/* XXX is it worth avoiding the realloc here? */ | /* XXX is it worth avoiding the realloc here? */ | |||
if (ns > 0) /* No "" empty keys please. */ | if (ns > 0) /* No "" empty keys please. */ | |||
xx = loadDBT(_r, he->tag, s, ns); | xx = loadDBT(_r, he->tag, s, ns); | |||
break; | break; | |||
case RPM_I18NSTRING_TYPE: /* XXX never occurs */ | case RPM_I18NSTRING_TYPE: /* XXX never occurs */ | |||
case RPM_STRING_TYPE: | case RPM_STRING_TYPE: | |||
s = he->p.str; ns = strlen(s); | s = he->p.str; ns = strlen(s); | |||
/* XXX is it worth avoiding the realloc here? */ | /* XXX is it worth avoiding the realloc here? */ | |||
if (ns > 0) /* No "" empty keys please. */ | if (ns > 0) /* No "" empty keys please. */ | |||
xx = loadDBT(_r, he->tag, s, ns); | xx = loadDBT(_r, he->tag, s, ns); | |||
skipping to change at line 2008 | skipping to change at line 2010 | |||
static double e = 1.0e-5; | static double e = 1.0e-5; | |||
static size_t nmin = 16; | static size_t nmin = 16; | |||
size_t n = 2 * (he->c > nmin ? he->c : nmin); | size_t n = 2 * (he->c > nmin ? he->c : nmin); | |||
size_t m = 0; | size_t m = 0; | |||
size_t k = 0; | size_t k = 0; | |||
rpmbf bf; | rpmbf bf; | |||
rpmbfParams(n, e, &m, &k); | rpmbfParams(n, e, &m, &k); | |||
bf = rpmbfNew(m, k, 0); | bf = rpmbfNew(m, k, 0); | |||
_r->flags = DB_DBT_MULTIPLE | DB_DBT_APPMALLOC; | _r->flags = DB_DBT_MULTIPLE | DB_DBT_APPMALLOC; | |||
_r->data = A = xcalloc(he->c, sizeof(*A)); | _r->data = A = (DBT *) xcalloc(he->c, sizeof(*A)); | |||
_r->size = 0; | _r->size = 0; | |||
for (i = 0; i < he->c; i++) { | for (i = 0; i < he->c; i++) { | |||
s = he->p.argv[i]; ns = strlen(s); | s = he->p.argv[i]; ns = strlen(s); | |||
/* XXX Skip YAML "- ..." lead-in mark up if present. */ | /* XXX Skip YAML "- ..." lead-in mark up if present. */ | |||
if (s[0] == '-' && s[1] == ' ') { | if (s[0] == '-' && s[1] == ' ') { | |||
s += 2, ns -= 2; | s += 2, ns -= 2; | |||
} | } | |||
#ifdef NOTYET | #ifdef NOTYET | |||
skipping to change at line 2073 | skipping to change at line 2075 | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p, %p, %p, %p) rc %d\n\tdbi %p(%s) rpmdb %p h %p %s\n", __FUNCTION__, db, key, data, _r, rc, dbi, tagName(dbi->dbi_rpm tag), rpmdb, h, _KEYDATA(key, NULL, data, _r))); | DBIDEBUG(dbi, (stderr, "<-- %s(%p, %p, %p, %p) rc %d\n\tdbi %p(%s) rpmdb %p h %p %s\n", __FUNCTION__, db, key, data, _r, rc, dbi, tagName(dbi->dbi_rpm tag), rpmdb, h, _KEYDATA(key, NULL, data, _r))); | |||
return rc; | return rc; | |||
} | } | |||
static int seqid_init(dbiIndex dbi, const char * keyp, size_t keylen, | static int seqid_init(dbiIndex dbi, const char * keyp, size_t keylen, | |||
DB_SEQUENCE ** seqp) | DB_SEQUENCE ** seqp) | |||
/*@modifies *seqp @*/ | /*@modifies *seqp @*/ | |||
{ | { | |||
DB * db = dbi->dbi_db; | DB * db = (DB *) dbi->dbi_db; | |||
DBT k = {0}; | DBT k = {0}; | |||
DB_TXN * _txnid = dbiTxnid(dbi); | DB_TXN * _txnid = dbiTxnid(dbi); | |||
DB_SEQUENCE * seq = NULL; | DB_SEQUENCE * seq = NULL; | |||
db_seq_t _rangemin = -922337203685477600LL; | db_seq_t _rangemin = -922337203685477600LL; | |||
db_seq_t _rangemax = 922337203685477600LL; | db_seq_t _rangemax = 922337203685477600LL; | |||
db_seq_t _value = 0; | db_seq_t _value = 0; | |||
int32_t _cachesize = 0; | int32_t _cachesize = 0; | |||
uint32_t _flags = DB_SEQ_INC; | uint32_t _flags = DB_SEQ_INC; | |||
uint32_t _oflags = DB_CREATE; | uint32_t _oflags = DB_CREATE; | |||
int rc; | int rc; | |||
skipping to change at line 2360 | skipping to change at line 2362 | |||
} else { | } else { | |||
dbi->dbi_oflags |= DB_RDONLY; | dbi->dbi_oflags |= DB_RDONLY; | |||
} | } | |||
dbf = _free(dbf); | dbf = _free(dbf); | |||
} | } | |||
/* | /* | |||
* Set db type if creating or truncating. | * Set db type if creating or truncating. | |||
*/ | */ | |||
if (oflags & (DB_CREATE|DB_TRUNCATE)) | if (oflags & (DB_CREATE|DB_TRUNCATE)) | |||
dbi_type = dbi->dbi_type; | dbi_type = (DBTYPE) dbi->dbi_type; | |||
if (dbi->dbi_use_dbenv) { | if (dbi->dbi_use_dbenv) { | |||
/*@-mods@*/ | /*@-mods@*/ | |||
if (rpmdb->db_dbenv == NULL) { | if (rpmdb->db_dbenv == NULL) { | |||
rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv); | rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv); | |||
switch (rc) { | switch (rc) { | |||
default: | default: | |||
break; | break; | |||
case DB_RUNRECOVERY: | case DB_RUNRECOVERY: | |||
if (getuid() != 0) | if (getuid() != 0) | |||
skipping to change at line 2393 | skipping to change at line 2395 | |||
rpmdb->db_dbenv = dbenv; | rpmdb->db_dbenv = dbenv; | |||
rpmdb->db_opens = 1; | rpmdb->db_opens = 1; | |||
break; | break; | |||
#if defined(DB_VERSION_MISMATCH) /* Nuke __db* files and retry open once. * / | #if defined(DB_VERSION_MISMATCH) /* Nuke __db* files and retry open once. * / | |||
case DB_VERSION_MISMATCH: | case DB_VERSION_MISMATCH: | |||
#endif | #endif | |||
case EINVAL: | case EINVAL: | |||
if (getuid() != 0) | if (getuid() != 0) | |||
break; | break; | |||
{ char * filename = alloca(BUFSIZ); | { char * filename = (char *) alloca(BUFSIZ); | |||
struct stat st; | struct stat st; | |||
int i; | int i; | |||
for (i = 0; i < 16; i++) { | for (i = 0; i < 16; i++) { | |||
sprintf(filename, "%s/__db.%03d", dbhome, i); | sprintf(filename, "%s/__db.%03d", dbhome, i); | |||
(void)rpmCleanPath(filename); | (void)rpmCleanPath(filename); | |||
if (Stat(filename, &st) | if (Stat(filename, &st) | |||
&& (errno == ENOENT || errno == EINVAL)) | && (errno == ENOENT || errno == EINVAL)) | |||
continue; | continue; | |||
xx = Unlink(filename); | xx = Unlink(filename); | |||
skipping to change at line 2422 | skipping to change at line 2424 | |||
break; | break; | |||
/*@fallthrough@*/ | /*@fallthrough@*/ | |||
case 0: | case 0: | |||
assert(dbenv); | assert(dbenv); | |||
rpmdb->db_dbenv = dbenv; | rpmdb->db_dbenv = dbenv; | |||
rpmdb->db_opens = 1; | rpmdb->db_opens = 1; | |||
break; | break; | |||
} | } | |||
} else { | } else { | |||
assert(rpmdb && rpmdb->db_dbenv); | assert(rpmdb && rpmdb->db_dbenv); | |||
dbenv = rpmdb->db_dbenv; | dbenv = (DB_ENV *) rpmdb->db_dbenv; | |||
rpmdb->db_opens++; | rpmdb->db_opens++; | |||
} | } | |||
/*@=mods@*/ | /*@=mods@*/ | |||
} | } | |||
rpmlog(RPMLOG_DEBUG, D_("opening db index %s/%s %s mode=0x%x\n") , | rpmlog(RPMLOG_DEBUG, D_("opening db index %s/%s %s mode=0x%x\n") , | |||
dbhome, (dbfile ? dbfile : dbiBN), | dbhome, (dbfile ? dbfile : dbiBN), | |||
prDbiOpenFlags(oflags, 0), dbi->dbi_mode); | prDbiOpenFlags(oflags, 0), dbi->dbi_mode); | |||
if (rc == 0) { | if (rc == 0) { | |||
skipping to change at line 2585 | skipping to change at line 2587 | |||
} | } | |||
if (rc == 0) { | if (rc == 0) { | |||
const char * dbfullpath; | const char * dbfullpath; | |||
const char * dbpath; | const char * dbpath; | |||
char * t; | char * t; | |||
int nb; | int nb; | |||
nb = strlen(dbhome); | nb = strlen(dbhome); | |||
if (dbfile) nb += 1 + strlen(dbfile); | if (dbfile) nb += 1 + strlen(dbfile); | |||
dbfullpath = t = alloca(nb + 1); | dbfullpath = t = (char *) alloca(nb + 1); | |||
t = stpcpy(t, dbhome); | t = stpcpy(t, dbhome); | |||
if (dbfile) | if (dbfile) | |||
t = stpcpy( stpcpy( t, "/"), dbfile); | t = stpcpy( stpcpy( t, "/"), dbfile); | |||
#ifdef HACK /* XXX necessary to support dbsubfile */ | #ifdef HACK /* XXX necessary to support dbsubfile */ | |||
dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary) | dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary) | |||
? dbfullpath : dbfile; | ? dbfullpath : dbfile; | |||
#else | #else | |||
#ifdef PLD_CHROOT | #ifdef PLD_CHROOT | |||
/* XXX Make dbpath relative. */ | /* XXX Make dbpath relative. */ | |||
skipping to change at line 2678 | skipping to change at line 2680 | |||
} else if (dbfile) { | } else if (dbfile) { | |||
rpmlog(RPMLOG_DEBUG, | rpmlog(RPMLOG_DEBUG, | |||
D_("locked db index %s/%s\n"), | D_("locked db index %s/%s\n"), | |||
dbhome, dbfile); | dbhome, dbfile); | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
dbi->dbi_db = db; | dbi->dbi_db = (void *) db; | |||
if (db) | if (db) | |||
db->app_private = dbi; | db->app_private = dbi; | |||
DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%p) dbi %p rc %d %s\n", __FUNCTION__, rpmdb, tagName(rpmtag), dbip, dbi, rc, _OFLAGS(dbi->dbi_oflags))); | DBIDEBUG(dbi, (stderr, "<-- %s(%p,%s,%p) dbi %p rc %d %s\n", __FUNCTION__, rpmdb, tagName(rpmtag), dbip, dbi, rc, _OFLAGS(dbi->dbi_oflags))); | |||
if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) { | if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) { | |||
dbi->dbi_vec = &db3vec; | dbi->dbi_vec = &db3vec; | |||
*dbip = dbi; | *dbip = dbi; | |||
if (dbi->dbi_primary) { | if (dbi->dbi_primary) { | |||
rpmTag Ptag = tagValue(dbi->dbi_primary); | rpmTag Ptag = tagValue(dbi->dbi_primary); | |||
skipping to change at line 2712 | skipping to change at line 2714 | |||
} | } | |||
if (dbi->dbi_seq_id) { | if (dbi->dbi_seq_id) { | |||
char * end = NULL; | char * end = NULL; | |||
uint32_t u = (uint32_t) strtoll(dbi->dbi_seq_id, &end, 0); | uint32_t u = (uint32_t) strtoll(dbi->dbi_seq_id, &end, 0); | |||
/* Reset the Seqno counter to the next primary key */ | /* Reset the Seqno counter to the next primary key */ | |||
if (oflags & (DB_CREATE|DB_TRUNCATE)) | if (oflags & (DB_CREATE|DB_TRUNCATE)) | |||
dbi->dbi_seq_initial = rpmdb->db_maxkey + 1; | dbi->dbi_seq_initial = rpmdb->db_maxkey + 1; | |||
if (*end == '\0') | if (*end == '\0') | |||
xx = seqid_init(dbi,(const char *)&u, sizeof(u), &dbi->dbi_s eq); | xx = seqid_init(dbi,(const char *)&u, sizeof(u), (DB_SEQUENC E **) &dbi->dbi_seq); | |||
else | else | |||
xx = seqid_init(dbi, dbi->dbi_seq_id, 0, &dbi->dbi_seq); | xx = seqid_init(dbi, dbi->dbi_seq_id, 0, (DB_SEQUENCE **) &d bi->dbi_seq); | |||
if (xx) { | if (xx) { | |||
(void) db3close(dbi, 0); | (void) db3close(dbi, 0); | |||
dbi = NULL; | dbi = NULL; | |||
if (dbip) *dbip = dbi; | if (dbip) *dbip = dbi; | |||
} | } | |||
} | } | |||
} else { | } else { | |||
(void) db3close(dbi, 0); | (void) db3close(dbi, 0); | |||
dbi = NULL; | dbi = NULL; | |||
if (dbip) *dbip = dbi; | if (dbip) *dbip = dbi; | |||
End of changes. 41 change blocks. | ||||
42 lines changed or deleted | 44 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |