]> arthur.barton.de Git - netatalk.git/commitdiff
clustering support: new per volume option cnidserver
authorfranklahm <franklahm>
Wed, 31 Mar 2010 09:47:32 +0000 (09:47 +0000)
committerfranklahm <franklahm>
Wed, 31 Mar 2010 09:47:32 +0000 (09:47 +0000)
16 files changed:
NEWS
bin/uniconv/uniconv.c
config/AppleVolumes.default.tmpl
etc/afpd/volume.c
include/atalk/cnid.h
include/atalk/cnid_dbd_private.h
include/atalk/volume.h
libatalk/cnid/cdb/cnid_cdb.h
libatalk/cnid/cdb/cnid_cdb_open.c
libatalk/cnid/cnid.c
libatalk/cnid/dbd/cnid_dbd.c
libatalk/cnid/dbd/cnid_dbd.h
libatalk/cnid/last/cnid_last.c
libatalk/cnid/last/cnid_last.h
libatalk/cnid/tdb/cnid_tdb.h
libatalk/cnid/tdb/cnid_tdb_open.c

diff --git a/NEWS b/NEWS
index 0c2515f7e749cd30b17fd9e3e90e50d566b71ef8..3f5aca4d2d2257870a151d6795d2cad13756bb16 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Changes in 2.1-beta2
 ====================
 * NEW: afpd: static generated AFP signature stored in afp_signature.conf,
        cf man 5 afp_signature.conf
+* NEW: afpd: clustering support: new per volume option "cnidserver".
 * FIX: afpd: prevent security attack guessing valid server accounts. afpd
        now returns error -5023 for unknown users, as does AppleFileServer.
 
index b02943115578b537a84bb54b8a49c1a4eacd3f3b..4b653521c9148f7fe9e394642881c0f166b80aad 100644 (file)
@@ -386,7 +386,7 @@ static int init(char* path)
 {
        DIR* startdir;
 
-        if (NULL == (cdb = cnid_open (path, 0, cnid_type, 0)) ) {
+    if (NULL == (cdb = cnid_open (path, 0, cnid_type, 0, NULL, NULL)) ) {
                 fprintf (stderr, "ERROR: cannot open CNID database in '%s'\n", path);
                 fprintf (stderr, "ERROR: check the logs for reasons, aborting\n");
                return -1;
index 1f85961ba75b0c26c6c90ad85c999a8666eff10c..ce1dc078e5e377dd59bb514900edeb524ccb570c 100644 (file)
@@ -11,6 +11,7 @@
 #   [preexec:cmd] [root_preexec:cmd] [postexec:cmd]  [root_postexec:cmd] \
 #   [allowed_hosts:IPv4 address[/IPv4 netmask bits]] \
 #   [denied_hosts:IPv4 address[/IPv4 netmask bits]] \
+#   ... more, see below ...
 #   
 # name:      volume name. it can't include the ':' character
 #
 #                        OR with the client requested perm
 #
 # dbpath:path         -> store the database stuff in the following path.
+# cnidserver:server[:port]
+#                     -> Query this servername or IP address (default:localhost)
+#                        and port (default: 4700) for CNIDs. Only used with
+#                        CNID backend "dbd". This option here overrides any
+#                        setting from afpd.conf:cnidserver.
 # password:password   -> set a volume password (8 characters max)
 # cnidscheme:scheme   -> set the cnid scheme for the volume,
 #                        default is [:DEFAULT_CNID_SCHEME:]
index 1e6c1da8e938e5ba8b01e5a1039e698de6ee9369..e3b0484bbd9211e88e6179a82f8d3c9e427a2c3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.121 2010-03-01 05:05:46 didg Exp $
+ * $Id: volume.c,v 1.122 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -105,32 +105,33 @@ static void             free_extmap(void);
 #define VOLOPT_VETO          10  /* list of veto filespec */
 #define VOLOPT_PREEXEC       11  /* preexec command */
 #define VOLOPT_ROOTPREEXEC   12  /* root preexec command */
-
 #define VOLOPT_POSTEXEC      13  /* postexec command */
 #define VOLOPT_ROOTPOSTEXEC  14  /* root postexec command */
-
 #define VOLOPT_ENCODING      15  /* mac encoding (pre OSX)*/
 #define VOLOPT_MACCHARSET    16
 #define VOLOPT_CNIDSCHEME    17
 #define VOLOPT_ADOUBLE       18  /* adouble version */
+
 #ifdef FORCE_UIDGID
 #warning UIDGID
 #include "uid.h"
 
-#define VOLOPT_FORCEUID  19  /* force uid for username x */
-#define VOLOPT_FORCEGID  20  /* force gid for group x */
+#define VOLOPT_FORCEUID      19  /* force uid for username x */
+#define VOLOPT_FORCEGID      20  /* force gid for group x */
 #endif /* FORCE_UIDGID */
 
-#define VOLOPT_UMASK     21
+#define VOLOPT_UMASK         21
 #define VOLOPT_ALLOWED_HOSTS 22
 #define VOLOPT_DENIED_HOSTS  23
-#define VOLOPT_DPERM     24  /* dperm default directories perms */
-#define VOLOPT_FPERM     25  /* fperm default files perms */
-#define VOLOPT_DFLTPERM  26  /* perm */
-#define VOLOPT_EA_VFS    27  /* Extended Attributes vfs indirection */
+#define VOLOPT_DPERM         24  /* dperm default directories perms */
+#define VOLOPT_FPERM         25  /* fperm default files perms */
+#define VOLOPT_DFLTPERM      26  /* perm */
+#define VOLOPT_EA_VFS        27  /* Extended Attributes vfs indirection */
+#define VOLOPT_CNIDSERVER    28  /* CNID Server ip address*/
+#define VOLOPT_CNIDPORT      30  /* CNID server tcp port */
 
-#define VOLOPT_MAX       28  /* <== IMPORTANT !!!!!! */
-#define VOLOPT_NUM       (VOLOPT_MAX + 1)
+#define VOLOPT_MAX           31  /* <== IMPORTANT !!!!!! */
+#define VOLOPT_NUM           (VOLOPT_MAX + 1)
 
 #define VOLPASSLEN  8
 #define VOLOPT_DEFAULT     ":DEFAULT:"
@@ -470,6 +471,18 @@ static void volset(struct vol_option *options, struct vol_option *save,
             p = strtok(NULL, ",");
         }
 
+    } else if (optionok(tmp, "cnidserver:", val)) {
+        setoption(options, save, VOLOPT_CNIDSERVER, val);
+
+        char *p = strrchr(val + 1, ':');
+        if (p) {
+            *p = 0;
+            setoption(options, save, VOLOPT_CNIDPORT, p);
+        }
+
+        LOG(log_debug, logtype_afpd, "CNID Server for volume '%s': %s:%s",
+            volname, val + 1, p ? p + 1 : Cnid_port);
+
     } else if (optionok(tmp, "dbpath:", val)) {
         setoption(options, save, VOLOPT_DBPATH, val);
 
@@ -717,6 +730,12 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
         if (options[VOLOPT_CNIDSCHEME].c_value)
             volume->v_cnidscheme = strdup(options[VOLOPT_CNIDSCHEME].c_value);
 
+        if (options[VOLOPT_CNIDSERVER].c_value)
+            volume->v_cnidserver = strdup(options[VOLOPT_CNIDSERVER].c_value);
+
+        if (options[VOLOPT_CNIDPORT].c_value)
+            volume->v_cnidport = strdup(options[VOLOPT_CNIDPORT].c_value);
+
         if (options[VOLOPT_UMASK].i_value)
             volume->v_umask = (mode_t)options[VOLOPT_UMASK].i_value;
 
@@ -1818,15 +1837,20 @@ static int volume_openDB(struct vol *volume)
         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, flags);
-    else
-        volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, volume->v_cnidscheme, flags);
+
+    LOG(log_info, logtype_afpd, "%s:%s", volume->v_cnidserver, volume->v_cnidport);
+    
+    volume->v_cdb = cnid_open(volume->v_dbpath ? volume->v_dbpath : volume->v_path,
+                              volume->v_umask,
+                              volume->v_cnidscheme,
+                              flags,
+                              volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
+                              volume->v_cnidport ? volume->v_cnidport : Cnid_port);
 
     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);
+        volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, "tdb", flags, NULL, NULL);
 #ifdef SERVERTEXT
         /* kill ourself with SIGUSR2 aka msg pending */
         if (volume->v_cdb) {
@@ -2078,7 +2102,9 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
 
         if (!(volume->v_flags & AFPVOL_RO)) {
             handle_special_folders( volume );
-            savevolinfo(volume, Cnid_srv, Cnid_port);
+            savevolinfo(volume,
+                        volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
+                        volume->v_cnidport   ? volume->v_cnidport   : Cnid_port);
         }
 
         /*
index 6fdef75d636ad04e583fc7974bd75663914f6e74..8dcb33fbcae5bdb89d038dbd954f9b7aa29025c3 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: cnid.h,v 1.14 2009-11-28 13:09:25 didg Exp $
+ * $Id: cnid.h,v 1.15 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 2003 the Netatalk Team
  * Copyright (c) 2003 Rafal Lewczuk <rlewczuk@pronet.pl>
@@ -72,13 +72,25 @@ struct _cnid_db {
 };
 typedef struct _cnid_db cnid_db;
 
+/* 
+ * Consolidation of args passedn from main cnid_open to modules cnid_XXX_open, so
+ * that it's easier to add aditional args as required.
+ */
+struct cnid_open_args {
+    const char *dir;
+    mode_t mask;
+    uint32_t flags;
+    const char *cnidserver;      /* for dbd */
+    const char *cnidport;        /* for dbd */
+};
+
 /*
  * CNID module - represents particular CNID implementation
  */
 struct _cnid_module {
        char *name;
        struct list_head db_list;   /* CNID modules are also stored on a bidirectional list. */
-       struct _cnid_db *(*cnid_open)(const char *dir, mode_t mask, u_int32_t flags);
+       struct _cnid_db *(*cnid_open)(struct cnid_open_args *args);
        u_int32_t flags;            /* Flags describing some CNID backend aspects. */
 
 };
@@ -91,7 +103,12 @@ void cnid_init();
 void cnid_register(struct _cnid_module *module);
 
 /* This function opens a CNID database for selected volume. */
-struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int flags);
+struct _cnid_db *cnid_open(const char *volpath,
+                           mode_t mask,
+                           char *type,
+                           int flags,
+                           const char *cnidsrv, /* Only for dbd */
+                           const char *cnidport); /* Only for dbd */
 
 cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, 
                        char *name, const size_t len, cnid_t hint);
@@ -121,7 +138,10 @@ void cnid_close(struct _cnid_db *db);
 
 /*
  * $Log: cnid.h,v $
- * Revision 1.14  2009-11-28 13:09:25  didg
+ * Revision 1.15  2010-03-31 09:47:32  franklahm
+ * clustering support: new per volume option cnidserver
+ *
+ * Revision 1.14  2009/11/28 13:09:25  didg
  * guard against confused DB returning junk values
  *
  * Revision 1.13  2009/11/24 12:18:19  didg
index 10a37784633314d12685edf7c3bb71f9b1a082a6..4e4847a7eb4ab5bb84bd913036e4a784ad928569 100644 (file)
@@ -53,6 +53,8 @@ struct cnid_dbd_rply {
 typedef struct CNID_private {
     u_int32_t magic;
     char      db_dir[MAXPATHLEN + 1]; /* Database directory without /.AppleDB appended */
+    char      *cnidserver;
+    char      *cnidport;
     int       fd;              /* File descriptor to cnid_dbd */
     char      stamp[ADEDLEN_PRIVSYN]; /* db timestamp */
     char      *client_stamp;
index e2458ec4c9a077eb02ab9f5cc52609f082d06f89..6d2bccc6584cf5d2ab941440df7a2f4b3a09f867 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.15 2010-02-19 10:51:59 franklahm Exp $
+ * $Id: volume.h,v 1.16 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -73,6 +73,8 @@ struct vol {
     char            *v_password;
     char            *v_cnidscheme;
     char            *v_dbpath;
+    char            *v_cnidserver;
+    char            *v_cnidport;
     int             v_hide;       /* new volume wait until old volume is closed */
     int             v_new;        /* volume deleted but there's a new one with the same name */
     int             v_deleted;    /* volume open but deleted in new config file */
index 25c2d32bcd5c032250e97cb15b6569e6b0bc3069..97649a7cb2b589f289a6aa7ea0062670b0b65de7 100644 (file)
@@ -16,7 +16,7 @@
 
 /* cnid_open.c */
 extern struct _cnid_module cnid_cdb_module;
-extern struct _cnid_db *cnid_cdb_open (const char *, mode_t, u_int32_t flags);
+extern struct _cnid_db *cnid_cdb_open (struct cnid_open_args *args);
 
 /* cnid_close.c */
 extern void cnid_cdb_close (struct _cnid_db *);
index 90e16d8ea22a84932d662e1f34179082c48b9089..bf501fd5e9e52aa5bcc9fd7c85314771b5379307 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * $Id: cnid_cdb_open.c,v 1.4 2009-11-24 12:18:19 didg Exp $
+
+ * $Id: cnid_cdb_open.c,v 1.5 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -201,7 +202,7 @@ static int upgrade_required(char *dbdir)
 }
 
 /* --------------- */
-struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_)
+struct _cnid_db *cnid_cdb_open(struct cnid_open_args *args)
 {
     struct stat st;
     char path[MAXPATHLEN + 1];
@@ -211,18 +212,18 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
     static int first = 0;
     int rc;
 
-    if (!dir || *dir == 0) {
+    if (!args->dir || *args->dir == 0) {
         return NULL;
     }
 
     /* this checks .AppleDB.
        We need space for dir + '/' + DBHOMELEN + '/' + DBLEN */
-    if ((len = strlen(dir)) > (MAXPATHLEN - DBHOMELEN - DBLEN - 2)) {
-        LOG(log_error, logtype_default, "cnid_open: Pathname too large: %s", dir);
+    if ((len = strlen(args->dir)) > (MAXPATHLEN - DBHOMELEN - DBLEN - 2)) {
+        LOG(log_error, logtype_default, "cnid_open: Pathname too large: %s", args->dir);
         return NULL;
     }
 
-    if ((cdb = cnid_cdb_new(dir)) == NULL) {
+    if ((cdb = cnid_cdb_new(args->dir)) == NULL) {
         LOG(log_error, logtype_default, "cnid_open: Unable to allocate memory for database");
         return NULL;
     }
@@ -235,14 +236,14 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
     cdb->_private = (void *) db;
     db->magic = CNID_DB_MAGIC;
 
-    strcpy(path, dir);
+    strcpy(path, args->dir);
     if (path[len - 1] != '/') {
         strcat(path, "/");
         len++;
     }
 
     strcpy(path + len, DBHOME);
-    if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777 & ~mask) < 0)) {
+    if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777 & ~args->mask) < 0)) {
         LOG(log_error, logtype_default, "cnid_open: DBHOME mkdir failed for %s", path);
         goto fail_adouble;
     }
@@ -269,7 +270,7 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
     }
 
     /* Open the database environment. */
-    if ((rc = db->dbenv->open(db->dbenv, path, DBOPTIONS, 0666 & ~mask)) != 0) {
+    if ((rc = db->dbenv->open(db->dbenv, path, DBOPTIONS, 0666 & ~args->mask)) != 0) {
        LOG(log_error, logtype_default, "cnid_open: dbenv->open (rw) of %s failed: %s", path, db_strerror(rc));
        /* FIXME: This should probably go. Even if it worked, any use for a read-only DB? Didier? */
         if (rc == DB_RUNRECOVERY) {
@@ -282,10 +283,10 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
         /* We can't get a full transactional environment, so multi-access
          * is out of the question.  Let's assume a read-only environment,
          * and try to at least get a shared memory pool. */
-        if ((rc = db->dbenv->open(db->dbenv, path, DB_INIT_MPOOL, 0666 & ~mask)) != 0) {
+        if ((rc = db->dbenv->open(db->dbenv, path, DB_INIT_MPOOL, 0666 & ~args->mask)) != 0) {
             /* Nope, not a MPOOL, either.  Last-ditch effort: we'll try to
              * open the environment with no flags. */
-            if ((rc = db->dbenv->open(db->dbenv, path, 0, 0666 & ~mask)) != 0) {
+            if ((rc = db->dbenv->open(db->dbenv, path, 0, 0666 & ~args->mask)) != 0) {
                 LOG(log_error, logtype_default, "cnid_open: dbenv->open of %s failed: %s", path, db_strerror(rc));
                 goto fail_lock;
             }
@@ -304,7 +305,7 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
         goto fail_appinit;
     }
 
-    if ((rc = my_open(db->db_cnid, DBCNID, DBCNID, DB_BTREE, open_flag, 0666 & ~mask)) != 0) {
+    if ((rc = my_open(db->db_cnid, DBCNID, DBCNID, DB_BTREE, open_flag, 0666 & ~args->mask)) != 0) {
         LOG(log_error, logtype_default, "cnid_open: Failed to open dev/ino database: %s",
             db_strerror(rc));
         goto fail_appinit;
@@ -319,7 +320,7 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
         goto fail_appinit;
     }
 
-    if ((rc = my_open(db->db_didname, DBCNID, DBDIDNAME, DB_BTREE, open_flag, 0666 & ~mask))) {
+    if ((rc = my_open(db->db_didname, DBCNID, DBDIDNAME, DB_BTREE, open_flag, 0666 & ~args->mask))) {
         LOG(log_error, logtype_default, "cnid_open: Failed to open did/name database: %s",
             db_strerror(rc));
         goto fail_appinit;
@@ -334,7 +335,7 @@ struct _cnid_db *cnid_cdb_open(const char *dir, mode_t mask, u_int32_t flags _U_
         goto fail_appinit;
     }
 
-    if ((rc = my_open(db->db_devino, DBCNID, DBDEVINO, DB_BTREE, open_flag, 0666 & ~mask)) != 0) {
+    if ((rc = my_open(db->db_devino, DBCNID, DBDEVINO, DB_BTREE, open_flag, 0666 & ~args->mask)) != 0) {
         LOG(log_error, logtype_default, "cnid_open: Failed to open devino database: %s",
             db_strerror(rc));
         goto fail_appinit;
index 9a1a8921c898948cb42fa296785d5cedea1a6b79..9231cf5508f72648af2dd114da9143879cb0b978 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: cnid.c,v 1.12 2009-12-08 22:33:33 didg Exp $
+ * $Id: cnid.c,v 1.13 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 2003 the Netatalk Team
  * Copyright (c) 2003 Rafal Lewczuk <rlewczuk@pronet.pl>
@@ -92,14 +92,15 @@ static int cnid_dir(const char *dir, mode_t mask)
 }
 
 /* Opens CNID database using particular back-end */
-struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int flags)
+struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int flags,
+                           const char *cnidsrv, const char *cnidport)
 {
     struct _cnid_db *db;
     cnid_module *mod = NULL;
     struct list_head *ptr;
     uid_t uid = -1;  
     gid_t gid = -1;
-    
+
     list_for_each(ptr, &modules) {
         if (0 == strcmp(list_entry(ptr, cnid_module, db_list)->name, type)) {
            mod = list_entry(ptr, cnid_module, db_list);
@@ -128,7 +129,8 @@ struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int fla
         }
     }
 
-    db = mod->cnid_open(volpath, mask, flags);
+    struct cnid_open_args args = {volpath, mask, flags, cnidsrv, cnidport};
+    db = mod->cnid_open(&args);
 
     if ((mod->flags & CNID_FLAG_SETUID) && !(flags & CNID_FLAG_MEMORY)) {
         seteuid(0);
index 2f12b2f0d695235c95466b90dd2e0ef53ca1f418..13d5a6ebe4e0b6f9e86de995337569b523aba8a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_dbd.c,v 1.16 2010-01-21 14:14:49 didg 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) */
@@ -185,9 +182,10 @@ static int init_tsock(CNID_private *db)
     int len;
     struct iovec iov[2];
 
-    LOG(log_debug, 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: BEGIN. Opening volume '%s', CNID Server: %s/%s", 
+        db->db_dir, db->cnidserver, db->cnidport);
 
-    if ((fd = tsock_getfd(Cnid_srv, Cnid_port)) < 0)
+    if ((fd = tsock_getfd(db->cnidserver, db->cnidport)) < 0)
         return -1;
 
     len = strlen(db->db_dir);
@@ -442,16 +440,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;
     }
@@ -465,9 +463,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);
 
index 20a737c9b95b29375f92540270c821f31468843e..6d43f9a0a27ccd1bfc5bd7dad71a3572fc72e719 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_dbd.h,v 1.5 2009-11-24 12:18:19 didg Exp $
+ * $Id: cnid_dbd.h,v 1.6 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (C) Joerg Lenneis 2003
  * All Rights Reserved.  See COPYING.
@@ -18,7 +18,7 @@
 #include <atalk/cnid.h>
 
 extern struct _cnid_module cnid_dbd_module;
-extern struct _cnid_db *cnid_dbd_open (const char *, mode_t, u_int32_t flags);
+extern struct _cnid_db *cnid_dbd_open (struct cnid_open_args *args);
 extern void cnid_dbd_close (struct _cnid_db *);
 extern cnid_t cnid_dbd_add (struct _cnid_db *, const struct stat *, const cnid_t,
                            char *, const size_t, cnid_t);
index 7c5c941f2aba24e533360ef6b1f801328ea4e4e1..5502fb60f94c49836b9de1cd62005ebdeec7f841 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cnid_last.c,v 1.4 2009-11-24 12:18:20 didg Exp $
+ * $Id: cnid_last.c,v 1.5 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -144,15 +144,15 @@ static struct _cnid_db *cnid_last_new(const char *volpath)
     return cdb;
 }
 
-struct _cnid_db *cnid_last_open(const char *dir, mode_t mask _U_, u_int32_t flags _U_)
+struct _cnid_db *cnid_last_open(struct cnid_open_args *args)
 {
     struct _cnid_db *cdb;
 
-    if (!dir) {
+    if (!args->dir) {
         return NULL;
     }
 
-    if ((cdb = cnid_last_new(dir)) == NULL) {
+    if ((cdb = cnid_last_new(args->dir)) == NULL) {
         LOG(log_error, logtype_default, "cnid_open: Unable to allocate memory for database");
         return NULL;
     }
index b3277c54e441e2337c497e3d6b2626f6ef351db9..fdcf32a5cc524fc74e4abba68670d4ef792b20a4 100644 (file)
@@ -20,7 +20,7 @@ struct _cnid_last_private {
 };
 
 extern struct _cnid_module cnid_last_module;
-extern struct _cnid_db *cnid_last_open (const char *, mode_t, u_int32_t flags);
+extern struct _cnid_db *cnid_last_open (struct cnid_open_args *args);
 extern void cnid_last_close (struct _cnid_db *);
 extern cnid_t cnid_last_add (struct _cnid_db *, const struct stat *, const cnid_t,
                                  char *, const size_t, cnid_t);
index c54cf431ed29f93e9a81dad064a8229502edd562..1f7a08e6336dfb2ad6274dbac77c165c0e9fd11d 100644 (file)
@@ -47,7 +47,7 @@ struct _cnid_tdb_private {
 
 /* cnid_open.c */
 extern struct _cnid_module cnid_tdb_module;
-extern struct _cnid_db *cnid_tdb_open (const char *, mode_t, u_int32_t flags);
+extern struct _cnid_db *cnid_tdb_open (struct cnid_open_args *args);
 
 /* cnid_close.c */
 extern void cnid_tdb_close (struct _cnid_db *);
index 70a79653cd505bc2a9d320156d76660d300969bb..d658b94ae25f785399da7175bd3cc67a5f206d69 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cnid_tdb_open.c,v 1.7 2009-11-24 15:44:56 didg Exp $
+ * $Id: cnid_tdb_open.c,v 1.8 2010-03-31 09:47:32 franklahm Exp $
  *
  * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved. See COPYRIGHT.
@@ -63,7 +63,7 @@ static struct _cnid_db *cnid_tdb_new(const char *volpath)
 }
 
 /* ---------------------------- */
-struct _cnid_db *cnid_tdb_open(const char *dir, mode_t mask, u_int32_t flags)
+struct _cnid_db *cnid_tdb_open(struct cnid_open_args *args)
 {
     struct stat               st;
     struct _cnid_db           *cdb;
@@ -74,30 +74,30 @@ struct _cnid_db *cnid_tdb_open(const char *dir, mode_t mask, u_int32_t flags)
     int                      hash_size = 131071;
     int                       tdb_flags = 0;
 
-    if (!dir) {
+    if (!args->dir) {
         /* note: dir and path are not used for in memory db */
         return NULL;
     }
 
-    if ((len = strlen(dir)) > (MAXPATHLEN - DBLEN - 1)) {
-        LOG(log_error, logtype_default, "tdb_open: Pathname too large: %s", dir);
+    if ((len = strlen(args->dir)) > (MAXPATHLEN - DBLEN - 1)) {
+        LOG(log_error, logtype_default, "tdb_open: Pathname too large: %s", args->dir);
         return NULL;
     }
     
-    if ((cdb = cnid_tdb_new(dir)) == NULL) {
+    if ((cdb = cnid_tdb_new(args->dir)) == NULL) {
         LOG(log_error, logtype_default, "tdb_open: Unable to allocate memory for tdb");
         return NULL;
     }
     
-    strcpy(path, dir);
+    strcpy(path, args->dir);
     if (path[len - 1] != '/') {
         strcat(path, "/");
         len++;
     }
  
     strcpy(path + len, DBHOME);
-    if (!(flags & CNID_FLAG_MEMORY)) {
-        if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777 & ~mask) < 0)) {
+    if (!(args->flags & CNID_FLAG_MEMORY)) {
+        if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777 & ~args->mask) < 0)) {
             LOG(log_error, logtype_default, "tdb_open: DBHOME mkdir failed for %s", path);
             goto fail;
         }
@@ -113,7 +113,7 @@ struct _cnid_db *cnid_tdb_open(const char *dir, mode_t mask, u_int32_t flags)
     path[len + DBHOMELEN] = '\0';
     strcat(path, DBCNID);
 
-    db->tdb_cnid = tdb_open(path, hash_size, tdb_flags , O_RDWR | O_CREAT, 0666 & ~mask);
+    db->tdb_cnid = tdb_open(path, hash_size, tdb_flags , O_RDWR | O_CREAT, 0666 & ~args->mask);
     if (!db->tdb_cnid) {
         LOG(log_error, logtype_default, "tdb_open: unable to open tdb", path);
         goto fail;