1

I am attempting to read and write the RPM database located in /var/lib/rpm under CentOS 5, and eventually other system types (CentOS 6, RHEL, etc.)

The problem is that I don't know what version of Berkeley DB is being used.

The file command on the database file reports "data".

I tried opening the database using Berkeley DB versions 3.3, 4.4 and 6.1, but that fails with "Invalid argument".

Here is the code I am using (this for 4.4/6.1)

int main()
{
    #define DATABASE "__db.001"

    DB *dbp;
    int ret;

    if ((ret = db_create(&dbp, NULL, 0)) != 0) {
        fprintf(stderr, "db_create: %s\n", db_strerror(ret));
        exit (1);
    }

    if ((ret = dbp->open(
        dbp, NULL, DATABASE, NULL, DB_UNKNOWN, 0, 0664)) != 0) {
        dbp->err(dbp, ret, "%s", DATABASE);
        exit(1);
    }
}

Any hints about what is going wrong?

1 Answer 1

1

It turns out that the files in /var/lib/rpm with db in their names are not Berkeley database files. The files with no db in their names are Berkeley database files.

So trying to open a file named __db.001 is the wrong thing to do.

(Thought about just deleting the question, but other people may run into this).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .