[Rpm-maint] [PATCH] Use private environment on EINVAL error code for JFFS2

Daniel Drake dsd at laptop.org
Tue Apr 24 15:41:25 UTC 2012


JFFS2 is an embedded filesystem used by the OLPC XO-1. It does
not support writable mmap.

When opening a non-private environment, libdb uses a writable disk-backed
mmap, even if the DB_NOMMAP flag is passed. This fails with EINVAL on
JFFS2.

Detect the EINVAL condition and fall back to a private environment,
as is already done in response to other error codes.
This makes it possible to use recent rpm versions on JFFS2.
---
 lib/backend/db3.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

If the 4.9 branch is still open for this kind of thing it would be great
to see this patch land there in addition to master. I'll later be working
to get this included in Fedora 17 if it is accepted by upstream rpm.org.

diff --git a/lib/backend/db3.c b/lib/backend/db3.c
index 30ed7ac..50f5b21 100644
--- a/lib/backend/db3.c
+++ b/lib/backend/db3.c
@@ -185,7 +185,7 @@ static int db_init(rpmdb rdb, const char * dbhome)
 	free(fstr);
 
 	rc = (dbenv->open)(dbenv, dbhome, eflags, rdb->db_perms);
-	if (rc == EACCES || rc == EROFS) {
+	if (rc == EACCES || rc == EROFS || rc == EINVAL) {
 	    eflags |= DB_PRIVATE;
 	    retry_open--;
 	} else {
-- 
1.7.10



More information about the Rpm-maint mailing list