/*
- * $Id: dbd_add.c,v 1.3 2009-04-21 08:55:44 franklahm Exp $
+ * $Id: dbd_add.c,v 1.4 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
if (rply->result == CNID_DBD_RES_OK) {
/* Found it. rply->cnid is the correct CNID now. */
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "dbd_add: dbd_lookup success, cnid %u", ntohl(rply->cnid));
-#endif
+ LOG(log_debug, logtype_cnid, "dbd_add: dbd_lookup success, cnid %u", ntohl(rply->cnid));
return 1;
}
return -1;
}
}
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "dbd_add: Added dev/ino %s did %u name %s cnid %u",
- stringify_devino(rqst->dev, rqst->ino),
- ntohl(rqst->did), rqst->name, ntohl(rply->cnid));
-#endif
+ LOG(log_info, logtype_cnid, "dbd_add: Added dev/ino 0x%llx/0x%llx did %u name %s cnid %u",
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino),
+ ntohl(rqst->did), rqst->name, ntohl(rply->cnid));
+
rply->result = CNID_DBD_RES_OK;
return 1;
}
/*
- * $Id: dbd_delete.c,v 1.2 2005-04-28 20:49:48 bfernhomberg Exp $
+ * $Id: dbd_delete.c,v 1.3 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
}
if (rc) {
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "cnid_delete: CNID %u deleted", ntohl(rqst->cnid));
-#endif
+ LOG(log_debug, logtype_cnid, "cnid_delete: CNID %u deleted", ntohl(rqst->cnid));
rply->result = CNID_DBD_RES_OK;
} else {
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "cnid_delete: CNID %u not in database", ntohl(rqst->cnid));
-#endif
+ LOG(log_debug, logtype_cnid, "cnid_delete: CNID %u not in database", ntohl(rqst->cnid));
rply->result = CNID_DBD_RES_NOTFOUND;
}
return 1;
/*
- * $Id: dbd_get.c,v 1.2 2005-04-28 20:49:48 bfernhomberg Exp $
+ * $Id: dbd_get.c,v 1.3 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
}
if (rc == 0) {
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "cnid_get: CNID not found for did %u name %s",
+ LOG(log_debug, logtype_cnid, "cnid_get: CNID not found for did %u name %s",
ntohl(rqst->did), rqst->name);
-#endif
- rply->result = CNID_DBD_RES_NOTFOUND;
- return 1;
+ rply->result = CNID_DBD_RES_NOTFOUND;
+ return 1;
}
memcpy(&rply->cnid, data.data, sizeof(rply->cnid));
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "cnid_get: Returning CNID did %u name %s as %u",
+
+ LOG(log_debug, logtype_cnid, "cnid_get: Returning CNID did %u name %s as %u",
ntohl(rqst->did), rqst->name, ntohl(rply->cnid));
-#endif
+
rply->result = CNID_DBD_RES_OK;
return 1;
}
/*
- * $Id: dbd_lookup.c,v 1.4 2009-04-21 08:55:44 franklahm Exp $
+ * $Id: dbd_lookup.c,v 1.5 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
if (!devino && !didname) {
/* not found */
- LOG(log_debug, logtype_cnid, "cnid_lookup: dev/ino %s did %u name %s neither in devino nor didname",
- stringify_devino(rqst->dev, rqst->ino), ntohl(rqst->did), rqst->name);
+ LOG(log_debug, logtype_cnid, "cnid_lookup: dev/ino 0x%llx/0x%llx did %u name %s neither in devino nor didname",
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino), ntohl(rqst->did), rqst->name);
rply->result = CNID_DBD_RES_NOTFOUND;
return 1;
if (devino && didname && id_devino == id_didname && type_devino == rqst->type) {
/* the same */
- LOG(log_debug, logtype_cnid, "cnid_lookup: Looked up dev/ino %s did %u name %s as %u",
- stringify_devino(rqst->dev, rqst->ino), ntohl(rqst->did), rqst->name, ntohl(id_didname));
+ LOG(log_debug, logtype_cnid, "cnid_lookup: Looked up dev/ino 0x%llx/0x%llx did %u name %s as %u",
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino), ntohl(rqst->did), rqst->name, ntohl(id_didname));
rply->cnid = id_didname;
rply->result = CNID_DBD_RES_OK;
rply->cnid = rqst->cnid;
}
- LOG(log_debug, logtype_cnid, "cnid_lookup: Looked up dev/ino %s did %u name %s as %u (needed update)",
- stringify_devino(rqst->dev, rqst->ino), ntohl(rqst->did), rqst->name, ntohl(rply->cnid));
+ LOG(log_debug, logtype_cnid, "cnid_lookup: Looked up dev/ino 0x%llx/0x%llx did %u name %s as %u (needed update)",
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino), ntohl(rqst->did), rqst->name, ntohl(rply->cnid));
return rc;
}
/*
- * $Id: dbd_resolve.c,v 1.2 2005-04-28 20:49:48 bfernhomberg Exp $
+ * $Id: dbd_resolve.c,v 1.3 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
}
if (rc == 0) {
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "dbd_resolve: Could not resolve CNID %u",
- ntohl(rqst->cnid));
-#endif
+
+ LOG(log_debug, logtype_cnid, "dbd_resolve: Could not resolve CNID %u", ntohl(rqst->cnid));
+
rply->result = CNID_DBD_RES_NOTFOUND;
return 1;
}
rply->namelen = data.size - CNID_NAME_OFS;
rply->name = (char *)data.data + CNID_NAME_OFS;
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "dbd_resolve: Resolving CNID %u to did %u name %s",
+ LOG(log_debug, logtype_cnid, "dbd_resolve: Resolving CNID %u to did %u name %s",
ntohl(rqst->cnid), ntohl(rply->did), rply->name);
-#endif
+
rply->result = CNID_DBD_RES_OK;
return 1;
}
/*
- * $Id: dbd_update.c,v 1.3 2005-05-03 14:55:11 didg Exp $
+ * $Id: dbd_update.c,v 1.4 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
unsigned char *buf;
int notfound = 0;
char getbuf[CNID_HEADER_LEN + MAXPATHLEN +1];
-#ifdef DEBUG
cnid_t tmpcnid;
-#endif
memset(&key, 0, sizeof(key));
memset(&pkey, 0, sizeof(pkey));
goto err_db;
}
else if (rc > 0) {
-#ifdef DEBUG
- memcpy(&tmpcnid, pkey.data, sizeof(cnid_t));
- LOG(log_info, logtype_cnid, "dbd_update: Deleting %u corresponding to dev/ino %s from cnid2.db",
- ntohl(tmpcnid), stringify_devino(rqst->dev, rqst->ino));
-#endif
+ memcpy(&tmpcnid, pkey.data, sizeof(cnid_t));
+ LOG(log_debug, logtype_cnid, "dbd_update: Deleting %u corresponding to dev/ino 0x%llx/0x%llx from cnid2.db",
+ ntohl(tmpcnid), ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino));
+
if ((rc = dbif_del(DBIF_IDX_CNID, &pkey, 0)) < 0 ) {
goto err_db;
}
else if (!rc) {
- LOG(log_error, logtype_cnid, "dbd_update: delete DEVINO %u %s", ntohl(rqst->cnid), db_strerror(errno));
+ LOG(log_error, logtype_cnid, "dbd_update: delete DEVINO %u %s", ntohl(rqst->cnid), db_strerror(errno));
}
}
if (!rc) {
goto err_db;
}
else if (rc > 0) {
-#ifdef DEBUG
+
memcpy(&tmpcnid, pkey.data, sizeof(cnid_t));
- LOG(log_info, logtype_cnid, "dbd_update: Deleting %u corresponding to did %u name %s from cnid2.db",
+
+ LOG(log_debug, logtype_cnid, "dbd_update: Deleting %u corresponding to did %u name %s from cnid2.db",
ntohl(tmpcnid), ntohl(rqst->did), rqst->name);
-#endif
+
if ((rc = dbif_del(DBIF_IDX_CNID, &pkey, 0)) < 0) {
goto err_db;
}
if (dbif_put(DBIF_IDX_CNID, &key, &data, 0) < 0)
goto err_db;
-#ifdef DEBUG
- LOG(log_info, logtype_cnid, "dbd_update: Updated cnid2.db with dev/ino %s did %u name %s cnid %u",
- stringify_devino(rqst->dev, rqst->ino),
- ntohl(rqst->did), rqst->name, ntohl(rqst->cnid));
-#endif
+
+ LOG(log_info, logtype_cnid, "dbd_update: Updated cnid2.db with dev/ino 0x%llx/0x%llx did %u name %s cnid %u",
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino),
+ ntohl(rqst->did), rqst->name, ntohl(rqst->cnid));
+
rply->result = CNID_DBD_RES_OK;
return 1;
err_db:
-#ifdef DEBUG
- LOG(log_error, logtype_cnid, "dbd_update: Unable to update CNID %u dev/ino %s, DID %x:%s",
- ntohl(rqst->cnid), stringify_devino(rqst->ino, rqst->did), rqst->name);
-#endif
+ LOG(log_error, logtype_cnid, "dbd_update: Unable to update CNID %u dev/ino 0x%llx/0x%llx, DID %ul: %s",
+ ntohl(rqst->cnid),
+ ntoh64((unsigned long long int)rqst->dev), ntoh64((unsigned long long int)rqst->ino),
+ rqst->did, rqst->name);
+
rply->result = CNID_DBD_RES_ERR_DB;
return -1;
}
/*
- * $Id: pack.c,v 1.4 2009-04-28 13:01:24 franklahm Exp $
+ * $Id: pack.c,v 1.5 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
#include <atalk/cnid_dbd_private.h>
#include "pack.h"
-#ifdef DEBUG
-/*
- * Auxiliary stuff for stringify_devino. See comments below.
- */
-static char hexchars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
-#endif
-
/* --------------- */
/*
* This implementation is portable, but could probably be faster by using htonl
return start;
}
-#ifdef DEBUG
-
-/*
- * Whack 4 or 8 byte dev/ino numbers into something printable for DEBUG
- * logging. This function must not be used more that once per printf() style
- * invocation. This (or something improved) should probably migrate to
- * libatalk logging. Checking for printf() %ll support would be an alternative.
- */
-
-char *stringify_devino(dev_t dev, ino_t ino)
-{
- static char rbuf[CNID_DEV_LEN * 2 + 1 + CNID_INO_LEN * 2 + 1] = {0};
- char buf[CNID_DEV_LEN + CNID_INO_LEN];
- char *c1;
- char *c2;
- char *middle;
- char *end;
- int ci;
-
- pack_devino((unsigned char *)buf, dev, ino);
-
- middle = buf + CNID_DEV_LEN;
- end = buf + CNID_DEV_LEN + CNID_INO_LEN;
- c1 = buf;
- c2 = rbuf;
-
- while (c1 < end) {
- if (c1 == middle) {
- *c2 = '/';
- c2++;
- }
- ci = *c1;
- c2[0] = hexchars[(ci & 0xf0) >> 4];
- c2[1] = hexchars[ci & 0x0f];
- c1++;
- c2 += 2;
- }
- return rbuf;
-}
-#endif
/*
- * $Id: pack.h,v 1.4 2009-04-28 13:01:24 franklahm Exp $
+ * $Id: pack.h,v 1.5 2009-05-04 09:09:43 franklahm Exp $
*
* Copyright (C) Joerg Lenneis 2003
* All Rights Reserved. See COPYING.
extern int didname(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);
extern int devino(DB *dbp, const DBT *pkey, const DBT *pdata, DBT *skey);
-#ifdef DEBUG
-extern char *stringify_devino(dev_t dev, ino_t ino);
-#endif
-
#endif /* CNID_DBD_PACK_H */