Line data Source code
1 : /*
2 : ldb database library
3 :
4 : Copyright (C) Andrew Tridgell 2004
5 : Copyright (C) Stefan Metzmacher 2004
6 : Copyright (C) Simo Sorce 2006-2008
7 : Copyright (C) Matthias Dieter Wallnöfer 2009-2010
8 :
9 : ** NOTE! The following LGPL license applies to the ldb
10 : ** library. This does NOT imply that all of Samba is released
11 : ** under the LGPL
12 :
13 : This library is free software; you can redistribute it and/or
14 : modify it under the terms of the GNU Lesser General Public
15 : License as published by the Free Software Foundation; either
16 : version 3 of the License, or (at your option) any later version.
17 :
18 : This library is distributed in the hope that it will be useful,
19 : but WITHOUT ANY WARRANTY; without even the implied warranty of
20 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 : Lesser General Public License for more details.
22 :
23 : You should have received a copy of the GNU Lesser General Public
24 : License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 : */
26 :
27 : /*
28 : * Name: ldb_tdb
29 : *
30 : * Component: ldb tdb backend
31 : *
32 : * Description: core functions for tdb backend
33 : *
34 : * Author: Andrew Tridgell
35 : * Author: Stefan Metzmacher
36 : *
37 : * Modifications:
38 : *
39 : * - description: make the module use asynchronous calls
40 : * date: Feb 2006
41 : * Author: Simo Sorce
42 : *
43 : * - description: make it possible to use event contexts
44 : * date: Jan 2008
45 : * Author: Simo Sorce
46 : *
47 : * - description: fix up memory leaks and small bugs
48 : * date: Oct 2009
49 : * Author: Matthias Dieter Wallnöfer
50 : */
51 :
52 : #include "ldb_tdb.h"
53 : #include <tdb.h>
54 :
55 : /*
56 : map a tdb error code to a ldb error code
57 : */
58 37823834 : int ltdb_err_map(enum TDB_ERROR tdb_code)
59 : {
60 37823834 : switch (tdb_code) {
61 0 : case TDB_SUCCESS:
62 0 : return LDB_SUCCESS;
63 0 : case TDB_ERR_CORRUPT:
64 : case TDB_ERR_OOM:
65 : case TDB_ERR_EINVAL:
66 0 : return LDB_ERR_OPERATIONS_ERROR;
67 0 : case TDB_ERR_IO:
68 0 : return LDB_ERR_PROTOCOL_ERROR;
69 0 : case TDB_ERR_LOCK:
70 : case TDB_ERR_NOLOCK:
71 0 : return LDB_ERR_BUSY;
72 0 : case TDB_ERR_LOCK_TIMEOUT:
73 0 : return LDB_ERR_TIME_LIMIT_EXCEEDED;
74 2101 : case TDB_ERR_EXISTS:
75 2101 : return LDB_ERR_ENTRY_ALREADY_EXISTS;
76 37821733 : case TDB_ERR_NOEXIST:
77 37821733 : return LDB_ERR_NO_SUCH_OBJECT;
78 0 : case TDB_ERR_RDONLY:
79 0 : return LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS;
80 0 : default:
81 0 : break;
82 : }
83 0 : return LDB_ERR_OTHER;
84 : }
|