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

Panu Matilainen pmatilai at laiskiainen.org
Thu May 3 14:04:12 UTC 2012

On 04/24/2012 06:41 PM, Daniel Drake wrote:
> 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.

Fair enough. It's just that env->open() can return EINVAL for quite a 
number of reasons and silently falling back to private environment is 
not really the right thing to do in all the cases.

> ---
>   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 {

I applied a slightly different version that only falls back to 
DB_PRIVATE on system level errors to differentiate from the BDB-level 
logical errors (like invalid/incompatible flags):


Thanks for pointing this out (and the patch). No reason why it couldn't 
be pulled into rpm 4.9.x branch as well, there's quite an obvious need 
for a 4.9.x update once I just get my lazy butt dragged around to do it :)

	- Panu -

More information about the Rpm-maint mailing list