From 8cf575676133a685317008aa44fde582cf3faaf3 Mon Sep 17 00:00:00 2001 From: franklahm Date: Mon, 4 May 2009 09:09:43 +0000 Subject: [PATCH] Remove #ifdef DEBUG stuff, its not neccessary anymore as we have a fast LOG macro. Also replace stringify devino func with plain printf %ll --- etc/cnid_dbd/dbd_add.c | 15 +++++------- etc/cnid_dbd/dbd_delete.c | 10 +++----- etc/cnid_dbd/dbd_get.c | 16 ++++++------- etc/cnid_dbd/dbd_lookup.c | 14 +++++------ etc/cnid_dbd/dbd_resolve.c | 14 +++++------ etc/cnid_dbd/dbd_update.c | 41 ++++++++++++++++--------------- etc/cnid_dbd/pack.c | 49 +------------------------------------- etc/cnid_dbd/pack.h | 6 +---- 8 files changed, 51 insertions(+), 114 deletions(-) diff --git a/etc/cnid_dbd/dbd_add.c b/etc/cnid_dbd/dbd_add.c index 25a3afce..75d8eefe 100644 --- a/etc/cnid_dbd/dbd_add.c +++ b/etc/cnid_dbd/dbd_add.c @@ -1,5 +1,5 @@ /* - * $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. @@ -169,9 +169,7 @@ int dbd_add(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } @@ -196,11 +194,10 @@ int dbd_add(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } diff --git a/etc/cnid_dbd/dbd_delete.c b/etc/cnid_dbd/dbd_delete.c index d54d2686..49d24860 100644 --- a/etc/cnid_dbd/dbd_delete.c +++ b/etc/cnid_dbd/dbd_delete.c @@ -1,5 +1,5 @@ /* - * $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. @@ -38,14 +38,10 @@ int dbd_delete(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) } 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; diff --git a/etc/cnid_dbd/dbd_get.c b/etc/cnid_dbd/dbd_get.c index c71ab715..59d819ee 100644 --- a/etc/cnid_dbd/dbd_get.c +++ b/etc/cnid_dbd/dbd_get.c @@ -1,5 +1,5 @@ /* - * $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. @@ -50,19 +50,17 @@ int dbd_get(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) } 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; } diff --git a/etc/cnid_dbd/dbd_lookup.c b/etc/cnid_dbd/dbd_lookup.c index 0c7e59a0..4a008beb 100644 --- a/etc/cnid_dbd/dbd_lookup.c +++ b/etc/cnid_dbd/dbd_lookup.c @@ -1,5 +1,5 @@ /* - * $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. @@ -98,8 +98,8 @@ int dbd_lookup(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; @@ -108,8 +108,8 @@ int dbd_lookup(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; @@ -157,8 +157,8 @@ int dbd_lookup(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } diff --git a/etc/cnid_dbd/dbd_resolve.c b/etc/cnid_dbd/dbd_resolve.c index 4be2343d..14f22cf4 100644 --- a/etc/cnid_dbd/dbd_resolve.c +++ b/etc/cnid_dbd/dbd_resolve.c @@ -1,5 +1,5 @@ /* - * $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. @@ -41,10 +41,9 @@ int dbd_resolve(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) } 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; } @@ -54,10 +53,9 @@ int dbd_resolve(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } diff --git a/etc/cnid_dbd/dbd_update.c b/etc/cnid_dbd/dbd_update.c index 184feaab..8fb79622 100644 --- a/etc/cnid_dbd/dbd_update.c +++ b/etc/cnid_dbd/dbd_update.c @@ -1,5 +1,5 @@ /* - * $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. @@ -39,9 +39,7 @@ int dbd_update(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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)); @@ -59,16 +57,15 @@ int dbd_update(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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) { @@ -84,11 +81,12 @@ int dbd_update(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } @@ -112,19 +110,20 @@ int dbd_update(struct cnid_dbd_rqst *rqst, struct cnid_dbd_rply *rply) 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; } diff --git a/etc/cnid_dbd/pack.c b/etc/cnid_dbd/pack.c index 02a73075..039a79cd 100644 --- a/etc/cnid_dbd/pack.c +++ b/etc/cnid_dbd/pack.c @@ -1,5 +1,5 @@ /* - * $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. @@ -22,13 +22,6 @@ #include #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 @@ -111,43 +104,3 @@ unsigned char *pack_cnid_data(struct cnid_dbd_rqst *rqst) 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 diff --git a/etc/cnid_dbd/pack.h b/etc/cnid_dbd/pack.h index 63f18ad4..fb698499 100644 --- a/etc/cnid_dbd/pack.h +++ b/etc/cnid_dbd/pack.h @@ -1,5 +1,5 @@ /* - * $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. @@ -24,8 +24,4 @@ extern unsigned char *pack_cnid_data(struct cnid_dbd_rqst *); 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 */ -- 2.39.2