]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/volume.c
fallback to a in memory temporary cnid db if we can't open the real one, doesn't...
[netatalk.git] / etc / afpd / volume.c
index 0a69bf9a675d32f1d449f1095b4a6d4115b19c35..feb3b09e82d30a2d2005ba2a66c6dd28ea48c504 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.104 2009-11-24 11:18:38 didg Exp $
+ * $Id: volume.c,v 1.106 2009-11-24 15:44:40 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1831,14 +1831,35 @@ static int volume_codepage(AFPObj *obj, struct vol *volume)
 /* ------------------------- */
 static int volume_openDB(struct vol *volume)
 {
+    int flags = 0;
+
+    if ((volume->v_flags & AFPVOL_NODEV)) {
+        flags |= CNID_FLAG_NODEV;
+    }
+
     if (volume->v_cnidscheme == NULL) {
         volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
         LOG(log_info, logtype_afpd, "Volume %s use CNID scheme %s.", volume->v_path, volume->v_cnidscheme);
     }
     if (volume->v_dbpath)
-        volume->v_cdb = cnid_open (volume->v_dbpath, volume->v_umask, volume->v_cnidscheme, (volume->v_flags & AFPVOL_NODEV));
+        volume->v_cdb = cnid_open (volume->v_dbpath, volume->v_umask, volume->v_cnidscheme, flags);
     else
-        volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, volume->v_cnidscheme, (volume->v_flags & AFPVOL_NODEV));
+        volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, volume->v_cnidscheme, flags);
+
+    if (!volume->v_cdb) {
+        flags |= CNID_FLAG_MEMORY;
+        LOG(log_error, logtype_afpd, "Reopen volume %s using in memory temporary CNID DB.", volume->v_path);
+        volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, "tdb", flags);
+#ifdef SERVERTEXT
+        /* kill ourself with SIGUSR2 aka msg pending */
+        if (volume->v_cdb) {
+            setmessage("Something wrong with the volume's DB ... FIXME with a better msg");
+            kill(getpid(), SIGUSR2);
+            /* XXX desactivate cachecnid ? */
+        }
+#endif        
+    }
+
     return (!volume->v_cdb)?-1:0;
 }