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?