2 * $Id: dbd_dbcheck.c,v 1.1.2.1 2004-12-21 13:36:12 didg 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 int dbd_check(char *dbdir)
27 u_int32_t c_didname = 0, c_devino = 0, c_cnid = 0;
29 char dbdir[MAXPATHLEN];
31 if (NULL == getcwd(dbdir, sizeof(dbdir)) )
35 LOG(log_debug, logtype_cnid, "CNID database at `%s' is being checked (quick)", dbdir);
37 if (dbif_count(DBIF_IDX_CNID, &c_cnid))
40 if (dbif_count(DBIF_IDX_DIDNAME, &c_didname))
43 /* bailout after the first error */
44 if (dbif_count(DBIF_IDX_DEVINO, &c_devino))
47 if ( c_cnid != c_devino) {
48 LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_devino);
52 if ( c_cnid != c_didname) {
53 LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_didname);
57 LOG(log_debug, logtype_cnid, "CNID database at `%s' seems ok, %u entries.", dbdir, c_cnid);