]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/cnid/cdb/cnid_cdb_rebuild_add.c
Support for using $u username variable in AFP volume definitions
[netatalk.git] / libatalk / cnid / cdb / cnid_cdb_rebuild_add.c
index 7ea872e9545210cb7e85c7f7ba39ea109d0bd5f0..951674656c85931f45edd6cdf7a4fa8c99fe8a4b 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: cnid_cdb_rebuild_add.c,v 1.2 2005-04-28 20:49:59 bfernhomberg Exp $
  *
  * All Rights Reserved. See COPYRIGHT.
  *
 
 #include "cnid_cdb.h"
 
-#ifdef ATACC
-/* FIXME: Enhance for 8 byte dev/inode */
-char *make_cnid_data(const struct stat *st,const cnid_t did,
-                     const char *name, const int len)
-{
-    static char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
-    char *buf = start  +CNID_LEN;
-    u_int32_t i;
-
-    if (len > MAXPATHLEN)
-        return NULL;
-
-    memcpy(buf, &st->st_dev, sizeof(st->st_dev));
-    buf += sizeof(st->st_dev);
-
-    i = htonl(st->st_ino);
-    memcpy(buf , &st->st_ino, sizeof(st->st_ino));
-    buf += sizeof(st->st_ino);
-
-    i = S_ISDIR(st->st_mode)?1:0;
-    i = htonl(i);
-    memcpy(buf, &i, sizeof(i));
-    buf += sizeof(i);
-    
-    /* did is already in network byte order */
-    memcpy(buf, &did, sizeof(did));
-    buf += sizeof(did);
-
-    memcpy(buf, name, len);
-    *(buf + len) = '\0';
-
-    return start;
-}    
-#endif
-
-
 /* ----------------------------- */
 static cnid_t set_max_cnid(CNID_private *db, cnid_t hint)
 {
@@ -109,16 +72,14 @@ cleanup:
     return CNID_INVALID;
 }
 
-/* ------------------------ */
 cnid_t cnid_cdb_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
-                const cnid_t did, const char *name, const int len, 
-               cnid_t hint)
+                            cnid_t did, const char *name, size_t len, cnid_t hint)
 {
     CNID_private *db;
     DBT key, data;
     int rc;
 
-    if (!cdb || !(db = cdb->_private) || !st || !name || hint == CNID_INVALID || hint < CNID_START) {
+    if (!cdb || !(db = cdb->cnid_db_private) || !st || !name || hint == CNID_INVALID || hint < CNID_START) {
         errno = CNID_ERR_PARAM;
         return CNID_INVALID;
     }
@@ -130,7 +91,7 @@ cnid_t cnid_cdb_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
     /* ... Return id if it is valid, or if Rootinfo is read-only. */
     if (id || (db->flags & CNIDFLAG_DB_RO)) {
 #ifdef DEBUG
-        LOG(log_info, logtype_default, "cnid_add: Looked up did %u, name %s as %u", ntohl(did), name, ntohl(id));
+        LOG(log_debug9, logtype_default, "cnid_add: Looked up did %u, name %s as %u", ntohl(did), name, ntohl(id));
 #endif
         return id;
     }
@@ -140,7 +101,7 @@ cnid_t cnid_cdb_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
     memset(&key, 0, sizeof(key));
     memset(&data, 0, sizeof(data));
 
-    if ((data.data = make_cnid_data(st, did, name, len)) == NULL) {
+    if ((data.data = make_cnid_data(cdb->cnid_db_flags, st, did, name, len)) == NULL) {
         LOG(log_error, logtype_default, "cnid_add: Path name is too long");
         errno = CNID_ERR_PATH;
         return CNID_INVALID;
@@ -167,7 +128,7 @@ cnid_t cnid_cdb_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
     }
 
 #ifdef DEBUG
-    LOG(log_info, logtype_default, "cnid_add: Returned CNID for did %u, name %s as %u", ntohl(did), name, ntohl(hint));
+    LOG(log_debug9, logtype_default, "cnid_add: Returned CNID for did %u, name %s as %u", ntohl(did), name, ntohl(hint));
 #endif
 
     return hint;