diff -Nurp db4.8-4.8.30-orig/dbinc/db.in db4.8-4.8.30/dbinc/db.in
--- db4.8-4.8.30-orig/dbinc/db.in	2010-04-12 22:25:22.000000000 +0200
+++ db4.8-4.8.30/dbinc/db.in	2013-03-25 09:16:23.173313412 +0100
@@ -2336,6 +2336,15 @@ struct __db_env {
 	int  (*prdbt) __P((DBT *,
 		int, const char *, void *, int (*)(void *, const void *), int));
 	/* DB_ENV PRIVATE HANDLE LIST END */
+
+	/* New configuration, put here at the end to preserve binary
+	 * compatibility. */
+        char    *db_region_dir;         /* Database region file directory */
+        char    *db_region_pfx;         /* Database region file prefix */
+	int  (*get_region_dir) __P((DB_ENV *, const char **));
+	int  (*get_region_pfx) __P((DB_ENV *, const char **));
+	int  (*set_region_dir) __P((DB_ENV *, const char *));
+	int  (*set_region_pfx) __P((DB_ENV *, const char *));
 };
 
 /*
diff -Nurp db4.8-4.8.30-orig/dbinc/db_int.in db4.8-4.8.30/dbinc/db_int.in
--- db4.8-4.8.30-orig/dbinc/db_int.in	2010-04-12 22:25:22.000000000 +0200
+++ db4.8-4.8.30/dbinc/db_int.in	2013-03-25 09:14:37.084074440 +0100
@@ -370,7 +370,8 @@ typedef enum {
 	DB_APP_DATA,			/* Data file. */
 	DB_APP_LOG,			/* Log file. */
 	DB_APP_TMP,			/* Temporary file. */
-	DB_APP_RECOVER			/* We are in recovery. */
+	DB_APP_RECOVER,			/* We are in recovery. */
+	DB_APP_REGION			/* Region file. */
 } APPNAME;
 
 /*
diff -Nurp db4.8-4.8.30-orig/dbinc/region.h db4.8-4.8.30/dbinc/region.h
--- db4.8-4.8.30-orig/dbinc/region.h	2010-04-12 22:25:22.000000000 +0200
+++ db4.8-4.8.30/dbinc/region.h	2013-03-25 09:14:37.084074440 +0100
@@ -113,8 +113,7 @@ extern "C" {
 #endif
 
 #define	DB_REGION_PREFIX	"__db"		/* DB file name prefix. */
-#define	DB_REGION_FMT		"__db.%03d"	/* Region file name format. */
-#define	DB_REGION_ENV		"__db.001"	/* Primary environment name. */
+#define	DB_REGION_ENV		"001"		/* Primary environment name. */
 
 #define	INVALID_REGION_ID	0	/* Out-of-band region ID. */
 #define	REGION_ID_ENV		1	/* Primary environment ID. */
diff -Nurp db4.8-4.8.30-orig/dbinc_auto/env_ext.h db4.8-4.8.30/dbinc_auto/env_ext.h
--- db4.8-4.8.30-orig/dbinc_auto/env_ext.h	2010-04-12 22:25:22.000000000 +0200
+++ db4.8-4.8.30/dbinc_auto/env_ext.h	2013-03-25 09:14:37.084074440 +0100
@@ -49,6 +49,8 @@ void __env_set_msgfile __P((DB_ENV *, FI
 int  __env_set_paniccall __P((DB_ENV *, void (*)(DB_ENV *, int)));
 int  __env_set_shm_key __P((DB_ENV *, long));
 int  __env_set_tmp_dir __P((DB_ENV *, const char *));
+int  __env_set_region_dir __P((DB_ENV *, const char *));
+int  __env_set_region_pfx __P((DB_ENV *, const char *));
 int  __env_set_verbose __P((DB_ENV *, u_int32_t, int));
 int __db_mi_env __P((ENV *, const char *));
 int __db_mi_open __P((ENV *, const char *, int));
diff -Nurp db4.8-4.8.30-orig/dbinc_auto/int_def.in db4.8-4.8.30/dbinc_auto/int_def.in
--- db4.8-4.8.30-orig/dbinc_auto/int_def.in	2010-04-12 22:25:22.000000000 +0200
+++ db4.8-4.8.30/dbinc_auto/int_def.in	2013-03-25 09:14:37.084074440 +0100
@@ -751,6 +751,8 @@
 #define	__env_set_paniccall __env_set_paniccall@DB_VERSION_UNIQUE_NAME@
 #define	__env_set_shm_key __env_set_shm_key@DB_VERSION_UNIQUE_NAME@
 #define	__env_set_tmp_dir __env_set_tmp_dir@DB_VERSION_UNIQUE_NAME@
+#define	__env_set_region_dir __env_set_region_dir@DB_VERSION_UNIQUE_NAME@
+#define	__env_set_region_pfx __env_set_region_pfx@DB_VERSION_UNIQUE_NAME@
 #define	__env_set_verbose __env_set_verbose@DB_VERSION_UNIQUE_NAME@
 #define	__db_mi_env __db_mi_env@DB_VERSION_UNIQUE_NAME@
 #define	__db_mi_open __db_mi_open@DB_VERSION_UNIQUE_NAME@
diff -Nurp db4.8-4.8.30-orig/env/env_config.c db4.8-4.8.30/env/env_config.c
--- db4.8-4.8.30-orig/env/env_config.c	2010-04-12 22:25:33.000000000 +0200
+++ db4.8-4.8.30/env/env_config.c	2013-03-25 09:14:37.088074034 +0100
@@ -467,6 +467,17 @@ format:		__db_errx(env,
 		return (__env_set_tmp_dir(dbenv, argv[1]));
 	}
 
+	if (strcasecmp(argv[0], "set_region_dir") == 0) {
+		if (nf != 2)
+			goto format;
+		return (__env_set_region_dir(dbenv, argv[1]));
+	}
+	if (strcasecmp(argv[0], "set_region_pfx") == 0) {
+		if (nf != 2)
+			goto format;
+		return (__env_set_region_pfx(dbenv, argv[1]));
+	}
+
 	CONFIG_UINT32("set_thread_count", __env_set_thread_count);
 	CONFIG_UINT32("set_tx_max", __txn_set_tx_max);
 
diff -Nurp db4.8-4.8.30-orig/env/env_method.c db4.8-4.8.30/env/env_method.c
--- db4.8-4.8.30-orig/env/env_method.c	2010-04-12 22:25:33.000000000 +0200
+++ db4.8-4.8.30/env/env_method.c	2013-03-25 09:14:37.088074034 +0100
@@ -42,6 +42,8 @@ static int  __env_get_thread_id_string_f
 		char * (**)(DB_ENV *, pid_t, db_threadid_t, char *)));
 static int  __env_get_timeout __P((DB_ENV *, db_timeout_t *, u_int32_t));
 static int  __env_get_tmp_dir __P((DB_ENV *, const char **));
+static int  __env_get_region_dir __P((DB_ENV *, const char **));
+static int  __env_get_region_pfx __P((DB_ENV *, const char **));
 static int  __env_get_verbose __P((DB_ENV *, u_int32_t, int *));
 static int  __env_get_app_dispatch
 		__P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
@@ -237,6 +239,8 @@ __db_env_init(dbenv)
 	dbenv->get_thread_id_string_fn = __env_get_thread_id_string_fn;
 	dbenv->get_timeout = __env_get_timeout;
 	dbenv->get_tmp_dir = __env_get_tmp_dir;
+	dbenv->get_region_dir = __env_get_region_dir;
+	dbenv->get_region_pfx = __env_get_region_pfx;
 	dbenv->get_tx_max = __txn_get_tx_max;
 	dbenv->get_tx_timestamp = __txn_get_tx_timestamp;
 	dbenv->get_verbose = __env_get_verbose;
@@ -353,6 +357,8 @@ __db_env_init(dbenv)
 	dbenv->set_thread_id_string = __env_set_thread_id_string;
 	dbenv->set_timeout = __env_set_timeout;
 	dbenv->set_tmp_dir = __env_set_tmp_dir;
+	dbenv->set_region_dir = __env_set_region_dir;
+	dbenv->set_region_pfx = __env_set_region_pfx;
 	dbenv->set_tx_max = __txn_set_tx_max;
 	dbenv->set_tx_timestamp = __txn_set_tx_timestamp;
 	dbenv->set_verbose = __env_set_verbose;
@@ -1387,6 +1393,64 @@ __env_set_tmp_dir(dbenv, dir)
 }
 
 static int
+__env_get_region_dir(dbenv, dirp)
+	DB_ENV *dbenv;
+	const char **dirp;
+{
+	*dirp = dbenv->db_region_dir;
+	return (0);
+}
+
+/*
+ * __env_set_region_dir --
+ *	DB_ENV->set_region_dir.
+ *
+ * PUBLIC: int  __env_set_region_dir __P((DB_ENV *, const char *));
+ */
+int
+__env_set_region_dir(dbenv, dir)
+	DB_ENV *dbenv;
+	const char *dir;
+{
+	ENV *env;
+
+	env = dbenv->env;
+
+	if (dbenv->db_region_dir != NULL)
+		__os_free(env, dbenv->db_region_dir);
+	return (__os_strdup(env, dir, &dbenv->db_region_dir));
+}
+
+static int
+__env_get_region_pfx(dbenv, pfxp)
+	DB_ENV *dbenv;
+	const char **pfxp;
+{
+	*pfxp = dbenv->db_region_pfx;
+	return (0);
+}
+
+/*
+ * __env_set_region_pfx --
+ *	DB_ENV->set_region_pfx.
+ *
+ * PUBLIC: int  __env_set_region_pfx __P((DB_ENV *, const char *));
+ */
+int
+__env_set_region_pfx(dbenv, pfx)
+	DB_ENV *dbenv;
+	const char *pfx;
+{
+	ENV *env;
+
+	env = dbenv->env;
+
+	if (dbenv->db_region_pfx != NULL)
+		__os_free(env, dbenv->db_region_pfx);
+	return (__os_strdup(env, pfx, &dbenv->db_region_pfx));
+}
+
+static int
 __env_get_verbose(dbenv, which, onoffp)
 	DB_ENV *dbenv;
 	u_int32_t which;
diff -Nurp db4.8-4.8.30-orig/env/env_name.c db4.8-4.8.30/env/env_name.c
--- db4.8-4.8.30-orig/env/env_name.c	2010-04-12 22:25:33.000000000 +0200
+++ db4.8-4.8.30/env/env_name.c	2013-03-25 09:14:37.088074034 +0100
@@ -184,6 +184,10 @@ __db_appname(env, appname, file, dirp, n
 		if (dbenv != NULL)
 			dir = dbenv->db_tmp_dir;
 		break;
+	case DB_APP_REGION:
+		if (dbenv != NULL)
+			dir = dbenv->db_region_dir;
+		break;
 	}
 
 	/*
diff -Nurp db4.8-4.8.30-orig/env/env_open.c db4.8-4.8.30/env/env_open.c
--- db4.8-4.8.30-orig/env/env_open.c	2010-04-12 22:25:33.000000000 +0200
+++ db4.8-4.8.30/env/env_open.c	2013-03-25 09:14:37.092073628 +0100
@@ -532,6 +532,12 @@ __env_close(dbenv, rep_check)
 	if (dbenv->db_tmp_dir != NULL)
 		__os_free(env, dbenv->db_tmp_dir);
 	dbenv->db_tmp_dir = NULL;
+	if (dbenv->db_region_dir != NULL)
+		__os_free(env, dbenv->db_region_dir);
+	dbenv->db_region_dir = NULL;
+	if (dbenv->db_region_pfx != NULL)
+		__os_free(env, dbenv->db_region_pfx);
+	dbenv->db_region_pfx = NULL;
 	if (dbenv->db_data_dir != NULL) {
 		for (p = dbenv->db_data_dir; *p != NULL; ++p)
 			__os_free(env, *p);
diff -Nurp db4.8-4.8.30-orig/env/env_region.c db4.8-4.8.30/env/env_region.c
--- db4.8-4.8.30-orig/env/env_region.c	2010-04-12 22:25:33.000000000 +0200
+++ db4.8-4.8.30/env/env_region.c	2013-03-25 09:14:37.092073628 +0100
@@ -39,7 +39,8 @@ __env_attach(env, init_flagsp, create_ok
 	u_int32_t bytes, i, mbytes, nregions, signature;
 	u_int retry_cnt;
 	int majver, minver, patchver, ret, segid;
-	char buf[sizeof(DB_REGION_FMT) + 20];
+	const char *prefix;
+	char buf[256];
 
 	/* Initialization */
 	dbenv = env->dbenv;
@@ -63,8 +64,12 @@ loop:	renv = NULL;
 	if (F_ISSET(env, ENV_PRIVATE))
 		ret = __os_strdup(env, "process-private", &infop->name);
 	else {
-		(void)snprintf(buf, sizeof(buf), "%s", DB_REGION_ENV);
-		ret = __db_appname(env, DB_APP_NONE, buf, NULL, &infop->name);
+		if(dbenv && dbenv->db_region_pfx)
+			prefix = dbenv->db_region_pfx;
+		else
+			prefix = DB_REGION_PREFIX;
+		(void)snprintf(buf, sizeof(buf), "%s.%s", prefix, DB_REGION_ENV);
+		ret = __db_appname(env, DB_APP_REGION, buf, NULL, &infop->name);
 	}
 	if (ret != 0)
 		goto err;
@@ -891,14 +896,21 @@ static void
 __env_remove_file(env)
 	ENV *env;
 {
+	DB_ENV *dbenv;
 	int cnt, fcnt, lastrm, ret;
-	const char *dir;
-	char saved_char, *p, **names, *path, buf[sizeof(DB_REGION_FMT) + 20];
+	const char *dir, *prefix;
+	char saved_char, *p, **names, *path, buf[256];
+
+	dbenv = env->dbenv;
 
 	/* Get the full path of a file in the environment. */
-	(void)snprintf(buf, sizeof(buf), "%s", DB_REGION_ENV);
+	if(dbenv && dbenv->db_region_pfx)
+		prefix = dbenv->db_region_pfx;
+	else
+		prefix = DB_REGION_PREFIX;
+	(void)snprintf(buf, sizeof(buf), "%s.%s", prefix, DB_REGION_ENV);
 	if ((ret = __db_appname(env,
-	    DB_APP_NONE, buf, NULL, &path)) != 0)
+	    DB_APP_REGION, buf, NULL, &path)) != 0)
 		return;
 
 	/* Get the parent directory for the environment. */
@@ -931,7 +943,7 @@ __env_remove_file(env)
 	for (lastrm = -1, cnt = fcnt; --cnt >= 0;) {
 		/* Skip anything outside our name space. */
 		if (strncmp(names[cnt],
-		    DB_REGION_PREFIX, sizeof(DB_REGION_PREFIX) - 1))
+		    prefix, strlen(prefix)))
 			continue;
 
 		/* Skip queue extent files. */
@@ -952,14 +964,14 @@ __env_remove_file(env)
 		 * Remove the primary environment region last, because it's
 		 * the key to this whole mess.
 		 */
-		if (strcmp(names[cnt], DB_REGION_ENV) == 0) {
+		if (strcmp(names[cnt], buf) == 0) {
 			lastrm = cnt;
 			continue;
 		}
 
 		/* Remove the file. */
 		if (__db_appname(env,
-		    DB_APP_NONE, names[cnt], NULL, &path) == 0) {
+		    DB_APP_REGION, names[cnt], NULL, &path) == 0) {
 			/*
 			 * Overwrite region files.  Temporary files would have
 			 * been maintained in encrypted format, so there's no
@@ -976,7 +988,7 @@ __env_remove_file(env)
 
 	if (lastrm != -1)
 		if (__db_appname(env,
-		    DB_APP_NONE, names[lastrm], NULL, &path) == 0) {
+		    DB_APP_REGION, names[lastrm], NULL, &path) == 0) {
 			(void)__os_unlink(env, path, 1);
 			__os_free(env, path);
 		}
@@ -995,9 +1007,13 @@ __env_region_attach(env, infop, size)
 	REGINFO *infop;
 	size_t size;
 {
+	DB_ENV *dbenv;
 	REGION *rp;
 	int ret;
-	char buf[sizeof(DB_REGION_FMT) + 20];
+	const char *prefix;
+	char buf[256];
+
+	dbenv = env->dbenv;
 
 	/*
 	 * Find or create a REGION structure for this region.  If we create
@@ -1019,9 +1035,13 @@ __env_region_attach(env, infop, size)
 		rp->size = (roff_t)size;
 
 	/* Join/create the underlying region. */
-	(void)snprintf(buf, sizeof(buf), DB_REGION_FMT, infop->id);
+	if(dbenv && dbenv->db_region_pfx)
+		prefix = dbenv->db_region_pfx;
+	else
+		prefix = DB_REGION_PREFIX;
+	(void)snprintf(buf, sizeof(buf), "%s.%03d", prefix, infop->id);
 	if ((ret = __db_appname(env,
-	    DB_APP_NONE, buf, NULL, &infop->name)) != 0)
+	    DB_APP_REGION, buf, NULL, &infop->name)) != 0)
 		goto err;
 	if ((ret = __env_sys_attach(env, infop, rp)) != 0)
 		goto err;
