2 * $Id: dbd_dbcheck.c,v 1.2 2005-04-28 20:49:48 bfernhomberg Exp $
4 * Copyright (C) Joerg Lenneis 2003
5 * All Rights Reserved. See COPYING.
10 #endif /* HAVE_CONFIG_H */
15 #include <sys/param.h>
17 #include <netatalk/endian.h>
18 #include <atalk/logger.h>
19 #include <atalk/cnid_dbd_private.h>
25 #ifndef CNID_BACKEND_DBD_TXN
26 int dbd_check(char *dbdir)
28 u_int32_t c_didname = 0, c_devino = 0, c_cnid = 0;
30 char dbdir[MAXPATHLEN];
32 if (NULL == getcwd(dbdir, sizeof(dbdir)) )
36 LOG(log_debug, logtype_cnid, "CNID database at `%s' is being checked (quick)", dbdir);
38 if (dbif_count(DBIF_IDX_CNID, &c_cnid))
41 if (dbif_count(DBIF_IDX_DEVINO, &c_devino))
44 /* bailout after the first error */
45 if ( c_cnid != c_devino) {
46 LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_devino);
50 if (dbif_count(DBIF_IDX_DIDNAME, &c_didname))
53 if ( c_cnid != c_didname) {
54 LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_didname);
58 LOG(log_debug, logtype_cnid, "CNID database at `%s' seems ok, %u entries.", dbdir, c_cnid);