summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2019-10-18 14:27:42 +0200
committerPanu Matilainen <pmatilai@redhat.com>2019-11-18 12:46:29 +0200
commit6323eab05d40e9d357cfe7bf5c2da215ffdd05d0 (patch)
tree933a66f483206e6b28510241a8e2ac78857bf8c2
parentc67f3b133abf180de356d63c8bc489468b8cbf6b (diff)
downloadrpm-6323eab05d40e9d357cfe7bf5c2da215ffdd05d0.tar.gz
Use xdb's pagesize instead of sysconf(_SC_PAGE_SIZE)
Our xdb may use a different page size for some reason. (cherry picked from commit 20fd80802098fe91e85dbe37d1857f6af1e91193)
-rw-r--r--lib/backend/ndb/rpmidx.c7
-rw-r--r--lib/backend/ndb/rpmxdb.c5
-rw-r--r--lib/backend/ndb/rpmxdb.h1
3 files changed, 9 insertions, 4 deletions
diff --git a/lib/backend/ndb/rpmidx.c b/lib/backend/ndb/rpmidx.c
index 25d2502f2..0ec8c8d11 100644
--- a/lib/backend/ndb/rpmidx.c
+++ b/lib/backend/ndb/rpmidx.c
@@ -483,7 +483,7 @@ static int rpmidxRebuildInternal(rpmidxdb idxdb)
nidxdb = &nidxdb_s;
memset(nidxdb, 0, sizeof(*nidxdb));
- nidxdb->pagesize = sysconf(_SC_PAGE_SIZE);
+ nidxdb->pagesize = rpmxdbPagesize(idxdb->xdb);
/* calculate nslots the hard way, don't trust usedslots */
nslots = 0;
@@ -906,9 +906,8 @@ int rpmidxOpenXdb(rpmidxdb *idxdbp, rpmpkgdb pkgdb, rpmxdb xdb, unsigned int xdb
idxdb->xdbtag = xdbtag;
idxdb->xdbid = id;
idxdb->pkgdb = pkgdb;
- idxdb->pagesize = sysconf(_SC_PAGE_SIZE);
- if (rpmxdbIsRdonly(xdb))
- idxdb->rdonly = 1;
+ idxdb->pagesize = rpmxdbPagesize(xdb);
+ idxdb->rdonly = rpmxdbIsRdonly(xdb) ? 1 : 0;
if (!id) {
if (rpmidxInit(idxdb)) {
free(idxdb);
diff --git a/lib/backend/ndb/rpmxdb.c b/lib/backend/ndb/rpmxdb.c
index f7c6ebd91..c67c80cfd 100644
--- a/lib/backend/ndb/rpmxdb.c
+++ b/lib/backend/ndb/rpmxdb.c
@@ -1151,6 +1151,11 @@ int rpmxdbIsRdonly(rpmxdb xdb)
return xdb->rdonly;
}
+unsigned int rpmxdbPagesize(rpmxdb xdb)
+{
+ return xdb->pagesize;
+}
+
static int rpmxdbFsync(rpmxdb xdb)
{
#ifdef HAVE_FDATASYNC
diff --git a/lib/backend/ndb/rpmxdb.h b/lib/backend/ndb/rpmxdb.h
index 4358536ef..88a3e617a 100644
--- a/lib/backend/ndb/rpmxdb.h
+++ b/lib/backend/ndb/rpmxdb.h
@@ -7,6 +7,7 @@ int rpmxdbOpen(rpmxdb *xdbp, rpmpkgdb pkgdb, const char *filename, int flags, in
void rpmxdbClose(rpmxdb xdb);
void rpmxdbSetFsync(rpmxdb xdb, int dofsync);
int rpmxdbIsRdonly(rpmxdb xdb);
+unsigned int rpmxdbPagesize(rpmxdb xdb);
int rpmxdbLock(rpmxdb xdb, int excl);
int rpmxdbUnlock(rpmxdb xdb, int excl);