]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/cnid/dbd/cnid_dbd.c
Merge dircache-rewrite
[netatalk.git] / libatalk / cnid / dbd / cnid_dbd.c
index b915c65baea448c86c5ef985df7e458d06fd858b..570da3d9342e4d9d20021b0b6776244e284fa470 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_dbd.c,v 1.16.2.1 2010-02-04 14:34:31 franklahm Exp $
+ * $Id: cnid_dbd.c,v 1.17 2010/03/31 09:47:32 franklahm Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * All Rights Reserved.  See COPYING.
@@ -52,9 +52,6 @@ static void RQST_RESET(struct cnid_dbd_rqst  *r)
 }
 
 /* ----------- */
-extern char *Cnid_srv;
-extern char *Cnid_port;
-
 #define MAX_DELAY 40
 
 /* *MUST* be < afp tickle or it's never triggered (got EINTR first) */
@@ -183,7 +180,10 @@ static int init_tsock(CNID_private *db)
     int len;
     struct iovec iov[2];
 
-    if ((fd = tsock_getfd(Cnid_srv, Cnid_port)) < 0)
+    LOG(log_debug, logtype_cnid, "init_tsock: BEGIN. Opening volume '%s', CNID Server: %s/%s", 
+        db->db_dir, db->cnidserver, db->cnidport);
+
+    if ((fd = tsock_getfd(db->cnidserver, db->cnidport)) < 0)
         return -1;
 
     len = strlen(db->db_dir);
@@ -200,8 +200,7 @@ static int init_tsock(CNID_private *db)
         return -1;
     }
 
-    LOG(log_maxdebug, logtype_cnid, "init_tsock: BEGIN. Opening volume '%s', CNID Server: %s/%s",
-        db->db_dir, Cnid_srv, Cnid_port);
+    LOG(log_debug, logtype_cnid, "init_tsock: ok");
 
     return fd;
 }
@@ -433,16 +432,16 @@ static struct _cnid_db *cnid_dbd_new(const char *volpath)
 }
 
 /* ---------------------- */
-struct _cnid_db *cnid_dbd_open(const char *dir, mode_t mask _U_, u_int32_t flags _U_)
+struct _cnid_db *cnid_dbd_open(struct cnid_open_args *args)
 {
     CNID_private *db = NULL;
     struct _cnid_db *cdb = NULL;
 
-    if (!dir) {
+    if (!args->dir) {
         return NULL;
     }
 
-    if ((cdb = cnid_dbd_new(dir)) == NULL) {
+    if ((cdb = cnid_dbd_new(args->dir)) == NULL) {
         LOG(log_error, logtype_cnid, "cnid_open: Unable to allocate memory for database");
         return NULL;
     }
@@ -456,9 +455,11 @@ struct _cnid_db *cnid_dbd_open(const char *dir, mode_t mask _U_, u_int32_t flags
 
     /* We keep a copy of the directory in the db structure so that we can
        transparently reconnect later. */
-    strcpy(db->db_dir, dir);
+    strcpy(db->db_dir, args->dir);
     db->magic = CNID_DB_MAGIC;
     db->fd = -1;
+    db->cnidserver = strdup(args->cnidserver);
+    db->cnidport = strdup(args->cnidport);
 
     LOG(log_debug, logtype_cnid, "cnid_dbd_open: Finished initializing cnid dbd module for volume '%s'", db->db_dir);