RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 10-Oct-2009 20:55:30 Branch: HEAD Handle: 2009101018553000 Modified files: rpm/rpmdb db3.c librpmdb.vers logio.h logio_rec.c rpmdb.h Log: - dbi: add additional system calls to logs, wired on main RPM code paths. Summary: Revision Changes Path 1.121 +20 -8 rpm/rpmdb/db3.c 1.71 +5 -0 rpm/rpmdb/librpmdb.vers 1.4 +2 -0 rpm/rpmdb/logio.h 1.4 +83 -0 rpm/rpmdb/logio_rec.c 1.112 +91 -0 rpm/rpmdb/rpmdb.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmdb/db3.c ============================================================================ $ cvs diff -u -r1.120 -r1.121 db3.c --- rpm/rpmdb/db3.c 10 Oct 2009 13:58:19 -0000 1.120 +++ rpm/rpmdb/db3.c 10 Oct 2009 18:55:30 -0000 1.121 @@ -29,6 +29,10 @@ #include "debug.h" +extern int logio_dispatch(DB_ENV * dbenv, DBT * dbt, DB_LSN * lsn, db_recops op) + /*...@*/; + + #if !defined(DB_CLIENT) /* XXX db-4.2.42 retrofit */ #define DB_CLIENT DB_RPCCLIENT #endif @@ -550,6 +554,8 @@ /* Try to join, rather than create, the environment. */ /* XXX DB_JOINENV is defined to 0 in db-4.5.20 */ if (eflags & DB_JOINENV) eflags &= DB_JOINENV; + /* XXX DB_RECOVER needs automagic */ + if (!(eflags & DB_INIT_TXN)) eflags &= ~DB_RECOVER; if (dbfile) rpmlog(RPMLOG_DEBUG, D_("opening db environment %s/%s %s\n"), @@ -575,11 +581,6 @@ /*...@-noeffectuncon@*/ /* FIX: annotate db3 methods */ - /* 4.1: dbenv->set_app_dispatch(???) */ - /* 4.1: dbenv->set_alloc(???) */ - /* 4.1: dbenv->set_data_dir(???) */ - /* 4.1: dbenv->set_encrypt(???) */ - /*...@-castfcnptr@*/ dbenv->set_errcall(dbenv, (void *)rpmdb->db_errcall); /*...@=castfcnptr@*/ @@ -587,6 +588,10 @@ dbenv->set_errpfx(dbenv, rpmdb->db_errpfx); /*...@=noeffectuncon@*/ + /* 4.1: dbenv->set_alloc(???) */ + /* 4.1: dbenv->set_data_dir(???) */ + /* 4.1: dbenv->set_encrypt(???) */ + /* 4.1: dbenv->set_feedback(???) */ /* 4.1: dbenv->set_flags(???) */ @@ -639,6 +644,10 @@ /* ==== Replication: */ /* ==== Sequences: */ /* ==== Transactions: */ + if (eflags & DB_INIT_TXN) { + xx = dbenv->set_app_dispatch(dbenv, logio_dispatch); + xx = cvtdberr(dbi, "dbenv->set_app_dispatch", xx, _debug); + } /* ==== Other: */ if (dbi->dbi_no_fsync) { @@ -1965,6 +1974,10 @@ #endif } } + /* ... transactionally protected open's need DB_AUTO_COMMIT ... */ + if (rpmdb->_dbi[0] + && rpmdb->_dbi[0]->dbi_eflags & DB_INIT_TXN) + oflags |= DB_AUTO_COMMIT; dbf = _free(dbf); } } @@ -2255,8 +2268,6 @@ #endif /* PLD_CHROOT */ #endif /* HACK */ - if (rpmdb->_dbi[0]->dbi_eflags & DB_INIT_TXN) - oflags |= DB_AUTO_COMMIT; #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) rc = (db->open)(db, _txnid, dbpath, dbsubfile, dbi_type, oflags, dbi->dbi_perms); @@ -2340,7 +2351,8 @@ } dbi->dbi_db = db; - db->app_private = dbi; + if (db) + 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))); @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/librpmdb.vers ============================================================================ $ cvs diff -u -r1.70 -r1.71 librpmdb.vers --- rpm/rpmdb/librpmdb.vers 10 Oct 2009 15:03:56 -0000 1.70 +++ rpm/rpmdb/librpmdb.vers 10 Oct 2009 18:55:30 -0000 1.71 @@ -81,7 +81,12 @@ headerVerifyInfo; hGetColor; _init; + logio_Link_log; logio_Mkdir_log; + logio_Mkfifo_log; + logio_Mknod_log; + logio_Rmdir_log; + logio_Symlink_log; _pkgio_debug; prDbiOpenFlags; rdbOptions; @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/logio.h ============================================================================ $ cvs diff -u -r1.3 -r1.4 logio.h --- rpm/rpmdb/logio.h 9 Oct 2009 00:06:43 -0000 1.3 +++ rpm/rpmdb/logio.h 10 Oct 2009 18:55:30 -0000 1.4 @@ -69,6 +69,8 @@ #undef _LOGIO_PROTO +int logio_dispatch(DB_ENV * dbenv, DBT * dbt, DB_LSN * lsn, db_recops op); + int logio_init_print __P((DB_ENV *, DB_DISTAB *)); #endif /* !H_LOGIO */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/logio_rec.c ============================================================================ $ cvs diff -u -r1.3 -r1.4 logio_rec.c --- rpm/rpmdb/logio_rec.c 9 Oct 2009 00:06:43 -0000 1.3 +++ rpm/rpmdb/logio_rec.c 10 Oct 2009 18:55:30 -0000 1.4 @@ -5,6 +5,44 @@ #include <rpmio.h> #include <db.h> + +/* XXX hot wire a db_config.h impedance match until RPM AutoFu is fixed. */ +#define HAVE_ISALPHA +#define HAVE_ISDIGIT +#define HAVE_ISPRINT +#define HAVE_ISSPACE +#define HAVE_LOCALTIME +#define HAVE_MEMCMP +#define HAVE_MEMCPY +#define HAVE_MEMMOVE +#define HAVE_PRINTF +#define HAVE_QSORT +#define HAVE_RAISE +#define HAVE_RAND +#define HAVE_STRCASECMP +#define HAVE_STRCAT +#define HAVE_STRCHR +#define HAVE_STRNCAT +#define HAVE_STRNCMP +#define HAVE_STRRCHR +#define HAVE_STRSEP +#define HAVE_TIME + +#define HAVE_ATOI +#define HAVE_ATOL +#define HAVE_GETOPT + +#define HAVE_FCLOSE +#define HAVE_FGETC +#define HAVE_FGETS +#define HAVE_FOPEN +#define HAVE_FWRITE +#define HAVE_LOCALTIME + +#include "db_int.h" + +#include "dbinc/db_swap.h" + #include "logio.h" #include "debug.h" @@ -867,3 +905,48 @@ return ret; } +int +logio_dispatch(DB_ENV * dbenv, DBT * dbt, DB_LSN * lsn, db_recops op) +{ + uint32_t rectype; + + /* Pull the record type out of the log record. */ + LOGCOPY_32(dbenv->env, &rectype, dbt->data); + + switch (rectype) { + case DB_logio_Creat: + return logio_Creat_recover(dbenv, dbt, lsn, op); + case DB_logio_Unlink: + return logio_Unlink_recover(dbenv, dbt, lsn, op); + case DB_logio_Rename: + return logio_Rename_recover(dbenv, dbt, lsn, op); + case DB_logio_Mkdir: + return logio_Mkdir_recover(dbenv, dbt, lsn, op); + case DB_logio_Rmdir: + return logio_Rmdir_recover(dbenv, dbt, lsn, op); +#ifdef NOTYET + case DB_logio_Lsetfilecon: + return logio_Lsetfilecon_recover(dbenv, dbt, lsn, op); +#endif + case DB_logio_Chown: + return logio_Chown_recover(dbenv, dbt, lsn, op); + case DB_logio_Lchown: + return logio_Lchown_recover(dbenv, dbt, lsn, op); + case DB_logio_Chmod: + return logio_Chmod_recover(dbenv, dbt, lsn, op); + case DB_logio_Utime: + return logio_Utime_recover(dbenv, dbt, lsn, op); + case DB_logio_Symlink: + return logio_Symlink_recover(dbenv, dbt, lsn, op); + case DB_logio_Link: + return logio_Link_recover(dbenv, dbt, lsn, op); + case DB_logio_Mknod: + return logio_Mknod_recover(dbenv, dbt, lsn, op); + case DB_logio_Mkfifo: + return logio_Mkfifo_recover(dbenv, dbt, lsn, op); + default: + /* We've hit an unexpected, allegedly user-defined record type. */ + dbenv->errx(dbenv, "Unexpected log record type encountered"); + return EINVAL; + } +} @@ . patch -p0 <<'@@ .' Index: rpm/rpmdb/rpmdb.h ============================================================================ $ cvs diff -u -r1.111 -r1.112 rpmdb.h --- rpm/rpmdb/rpmdb.h 10 Oct 2009 15:03:56 -0000 1.111 +++ rpm/rpmdb/rpmdb.h 10 Oct 2009 18:55:30 -0000 1.112 @@ -1159,6 +1159,97 @@ DNdbt.data = (void *)dn; DNdbt.size = strlen(dn) + 1; /* trailing NUL too */ rc = logio_Mkdir_log(dbenv, _txn, &_lsn, DB_FLUSH, &DNdbt, mode); +fprintf(stderr, "<== %s(%s, 0%o) rc %d\n", __FUNCTION__, dn, mode, rc); + return rc; +} + +/*...@unused@*/ static inline +int rpmlioRmdir(rpmdb rpmdb, const char * dn, mode_t mode) +{ + int rc = 0; + extern int logio_Rmdir_log + __P((DB_ENV *, DB_TXN *, DB_LSN *, uint32_t, const DBT *, mode_t)); + DB_ENV * dbenv = rpmdb->db_dbenv; + DB_TXN * _txn = rpmdb->db_txnid; + DB_LSN _lsn = {0,0}; + DBT DNdbt = {0}; + DNdbt.data = (void *)dn; + DNdbt.size = strlen(dn) + 1; /* trailing NUL too */ + rc = logio_Rmdir_log(dbenv, _txn, &_lsn, DB_FLUSH, &DNdbt, mode); +fprintf(stderr, "<== %s(%s, 0%o) rc %d\n", __FUNCTION__, dn, mode, rc); + return rc; +} + +/*...@unused@*/ static inline +int rpmlioMkfifo(rpmdb rpmdb, const char * fn, mode_t mode) +{ + int rc = 0; + extern int logio_Mkfifo_log + __P((DB_ENV *, DB_TXN *, DB_LSN *, uint32_t, const DBT *, mode_t)); + DB_ENV * dbenv = rpmdb->db_dbenv; + DB_TXN * _txn = rpmdb->db_txnid; + DB_LSN _lsn = {0,0}; + DBT FNdbt = {0}; + FNdbt.data = (void *)fn; + FNdbt.size = strlen(fn) + 1; /* trailing NUL too */ + rc = logio_Mkfifo_log(dbenv, _txn, &_lsn, DB_FLUSH, &FNdbt, mode); +fprintf(stderr, "<== %s(%s, 0%o) rc %d\n", __FUNCTION__, fn, mode, rc); + return rc; +} + +/*...@unused@*/ static inline +int rpmlioMknod(rpmdb rpmdb, const char * fn, mode_t mode, dev_t dev) +{ + int rc = 0; + extern int logio_Mknod_log + __P((DB_ENV *, DB_TXN *, DB_LSN *, uint32_t, const DBT *, mode_t, dev_t)); + DB_ENV * dbenv = rpmdb->db_dbenv; + DB_TXN * _txn = rpmdb->db_txnid; + DB_LSN _lsn = {0,0}; + DBT FNdbt = {0}; + FNdbt.data = (void *)fn; + FNdbt.size = strlen(fn) + 1; /* trailing NUL too */ + rc = logio_Mknod_log(dbenv, _txn, &_lsn, DB_FLUSH, &FNdbt, mode, dev); +fprintf(stderr, "<== %s(%s, 0%o, 0x%x) rc %d\n", __FUNCTION__, fn, mode, (unsigned)dev, rc); + return rc; +} + +/*...@unused@*/ static inline +int rpmlioSymlink(rpmdb rpmdb, const char * ln, const char * fn) +{ + int rc = 0; + extern int logio_Symlink_log + __P((DB_ENV *, DB_TXN *, DB_LSN *, uint32_t, const DBT *, const DBT *)); + DB_ENV * dbenv = rpmdb->db_dbenv; + DB_TXN * _txn = rpmdb->db_txnid; + DB_LSN _lsn = {0,0}; + DBT LNdbt = {0}; + DBT FNdbt = {0}; + LNdbt.data = (void *)ln; + LNdbt.size = strlen(ln) + 1; /* trailing NUL too */ + FNdbt.data = (void *)fn; + FNdbt.size = strlen(fn) + 1; /* trailing NUL too */ + rc = logio_Symlink_log(dbenv, _txn, &_lsn, DB_FLUSH, &LNdbt, &FNdbt); +fprintf(stderr, "<== %s(%s, %s) rc %d\n", __FUNCTION__, ln, fn, rc); + return rc; +} +/*...@unused@*/ static inline +int rpmlioLink(rpmdb rpmdb, const char * ln, const char * fn) +{ + int rc = 0; + extern int logio_Link_log + __P((DB_ENV *, DB_TXN *, DB_LSN *, uint32_t, const DBT *, const DBT *)); + DB_ENV * dbenv = rpmdb->db_dbenv; + DB_TXN * _txn = rpmdb->db_txnid; + DB_LSN _lsn = {0,0}; + DBT LNdbt = {0}; + DBT FNdbt = {0}; + LNdbt.data = (void *)ln; + LNdbt.size = strlen(ln) + 1; /* trailing NUL too */ + FNdbt.data = (void *)fn; + FNdbt.size = strlen(fn) + 1; /* trailing NUL too */ + rc = logio_Link_log(dbenv, _txn, &_lsn, DB_FLUSH, &LNdbt, &FNdbt); +fprintf(stderr, "<== %s(%s, %s) rc %d\n", __FUNCTION__, ln, fn, rc); return rc; } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org