]> arthur.barton.de Git - netatalk.git/blob - etc/cnid_dbd/dbd_dbcheck.c
remove gcc warning
[netatalk.git] / etc / cnid_dbd / dbd_dbcheck.c
1 /*
2  * $Id: dbd_dbcheck.c,v 1.2 2005-04-28 20:49:48 bfernhomberg 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
25 #ifndef CNID_BACKEND_DBD_TXN
26 int dbd_check(char *dbdir)
27 {
28     u_int32_t c_didname = 0, c_devino = 0, c_cnid = 0;
29 #if 0
30     char dbdir[MAXPATHLEN];
31
32     if (NULL == getcwd(dbdir, sizeof(dbdir)) )
33         return -1;
34 #endif
35
36     LOG(log_debug, logtype_cnid, "CNID database at `%s' is being checked (quick)", dbdir);
37
38     if (dbif_count(DBIF_IDX_CNID, &c_cnid)) 
39         return -1;
40
41     if (dbif_count(DBIF_IDX_DEVINO, &c_devino))
42         return -1;
43
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);
47         return 1;
48     }
49
50     if (dbif_count(DBIF_IDX_DIDNAME, &c_didname)) 
51         return -1;
52     
53     if ( c_cnid != c_didname) {
54         LOG(log_error, logtype_cnid, "CNID database at `%s' corrupted (%u/%u)", dbdir, c_cnid, c_didname);
55         return 1;
56     }
57
58     LOG(log_debug, logtype_cnid, "CNID database at `%s' seems ok, %u entries.", dbdir, c_cnid);
59     return 0;  
60 }
61
62 #endif
63