• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/netatalk-2.2.5/etc/cnid_dbd/
1/*
2 * $Id: dbd_dbcheck.c,v 1.4 2009-05-06 11:54:24 franklahm Exp $
3 *
4 * Copyright (C) Joerg Lenneis 2003
5 * All Rights Reserved.  See COPYING.
6 */
7
8#ifdef HAVE_CONFIG_H
9#include "config.h"
10#endif /* HAVE_CONFIG_H */
11
12
13#include <stdio.h>
14#include <string.h>
15#include <sys/param.h>
16#include <errno.h>
17#include <netatalk/endian.h>
18#include <atalk/logger.h>
19#include <atalk/cnid_dbd_private.h>
20
21#include "pack.h"
22#include "dbif.h"
23#include "dbd.h"
24
25int dbd_check_indexes(DBD *dbd, char *dbdir)
26{
27    u_int32_t c_didname = 0, c_devino = 0, c_cnid = 0;
28
29    LOG(log_note, logtype_cnid, "CNID database at `%s' is being checked (quick)", dbdir);
30
31    if (dbif_count(dbd, DBIF_CNID, &c_cnid))
32        return -1;
33
34    if (dbif_count(dbd, DBIF_IDX_DEVINO, &c_devino))
35        return -1;
36
37    /* bailout after the first error */
38    if ( c_cnid != c_devino) {
39        LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_devino);
40        return 1;
41    }
42
43    if (dbif_count(dbd, DBIF_IDX_DIDNAME, &c_didname))
44        return -1;
45
46    if ( c_cnid != c_didname) {
47        LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_didname);
48        return 1;
49    }
50
51    LOG(log_note, logtype_cnid, "CNID database at `%s' seems ok, %u entries.", dbdir, c_cnid);
52    return 0;
53}
54
55
56