]> arthur.barton.de Git - netatalk.git/commitdiff
Create dbpath if not existent
authorFrank Lahm <franklahm@googlemail.com>
Wed, 8 Dec 2010 07:26:58 +0000 (08:26 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 8 Dec 2010 07:26:58 +0000 (08:26 +0100)
etc/cnid_dbd/cmd_dbd.c

index 6d847a788d24152c911804b38b8067a6f7eabbae..9cafb010a0a7077a399f1bf765fe9bf645c82e80 100644 (file)
@@ -382,6 +382,19 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);        
     }
 
+    /* Enuser dbpath is there, create if necessary */
+    struct stat st;
+    if (stat(volinfo.v_dbpath, &st) != 0) {
+        if (errno != ENOENT) {
+            dbd_log( LOGSTD, "Can't stat dbpath \"%s\": %s", volinfo.v_dbpath, strerror(errno));
+            exit(EXIT_FAILURE);        
+        }
+        if ((mkdir(volinfo.v_dbpath, 0755)) != 0) {
+            dbd_log( LOGSTD, "Can't create dbpath \"%s\": %s", dbpath, strerror(errno));
+            exit(EXIT_FAILURE);
+        }        
+    }
+
     /* Put "/.AppleDB" at end of volpath, get path from volinfo file */
     if ( (strlen(volinfo.v_dbpath) + strlen("/.AppleDB")) > (PATH_MAX - 1) ) {
         dbd_log( LOGSTD, "Volume pathname too long");