missing directories when using berkeley for seenstate_db

Thilo Uttendorfer t.uttendorfer at linux-ag.com
Wed Jan 11 09:54:29 EST 2012


Hi,

I recently switched the seenstate_db from skiplist to berkeley. It seems that
the creation of directories is missing. I'm getting errors like this:

DBERROR: opening /var/lib/cyrus/domain/c/coreboso.de/user/d/demo.seen: cyrusdb error
DBERROR: opening /var/lib/cyrus/domain/c/coreboso.de/user/d/demo.seen: No such file or directory

If I manually create /var/lib/cyrus/domain/c/coreboso.de/user/d/ everything
works as expected. I hacked a (not so nice) patch for lib/cyrusdb_berkeley.c to fix this
issue. Feel free to include it.

Regards,
Thilo Uttendorfer


--- lib/cyrusdb_berkeley.c.orig     2012-01-11 15:21:59.000000000 +0100
+++ lib/cyrusdb_berkeley.c  2012-01-11 15:32:56.000000000 +0100
@@ -417,6 +417,16 @@
     r = (db->open)(db, fname, NULL, type, dbflags, 0664);
 #endif
 
+    if (r == ENOENT && (flags & CYRUSDB_CREATE)) {
+        if (cyrus_mkdir(fname, 0755) != -1) {
+#if ((DB_VERSION_MAJOR > 4) || ((DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR >= 1)))
+        r = (db->open)(db, NULL, fname, NULL, type, dbflags | DB_AUTO_COMMIT, 0664);
+#else
+        r = (db->open)(db, fname, NULL, type, dbflags, 0664);
+        }
+#endif
+    }
+
     if (r != 0) {
        int level = (flags & CYRUSDB_CREATE) ? LOG_ERR : LOG_DEBUG;
        syslog(level, "DBERROR: opening %s: %s", fname, db_strerror(r));


-- 
Thilo Uttendorfer
Linux Information Systems AG
Putzbrunner Str. 71, 81739 München

Fon: +49 89 993412-11, Fax: +49 89 993412-99
t.uttendorfer at linux-ag.com, http://www.linux-ag.com


More information about the Cyrus-devel mailing list