/*
- * $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)
{
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;
}
/* ... 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;
}
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;
}
#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;