summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-08-06 22:22:23 +0200
committerMichael Adam <obnox@samba.org>2008-08-13 11:54:07 +0200
commitb45305b5d850de286878eda98a6eaa0b0553595d (patch)
tree0468c807c356b6eadb81296502fc9d454103efa0 /source3/lib
parent8ac9cd8a3215aacfd750a352819fb2516afd2a10 (diff)
downloadsamba-b45305b5d850de286878eda98a6eaa0b0553595d.tar.gz
samba-b45305b5d850de286878eda98a6eaa0b0553595d.tar.bz2
samba-b45305b5d850de286878eda98a6eaa0b0553595d.zip
dbwrap ctdb: add a partial mapping from tdb_error to NTSTATUS and use it for store.
Michael (This used to be commit eaf76c751f9bde2843174b400c109304831df83e)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap_ctdb.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 1cccecbad9..69b3631c04 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -38,6 +38,26 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
TDB_DATA key,
bool persistent);
+static NTSTATUS tdb_error_to_ntstatus(struct tdb_context *tdb)
+{
+ NTSTATUS status;
+ enum TDB_ERROR tret = tdb_error(tdb);
+
+ switch (tret) {
+ case TDB_ERR_EXISTS:
+ status = NT_STATUS_OBJECT_NAME_COLLISION;
+ break;
+ case TDB_ERR_NOEXIST:
+ status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
+ break;
+ default:
+ status = NT_STATUS_INTERNAL_DB_CORRUPTION;
+ break;
+ }
+
+ return status;
+}
+
static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
{
struct db_ctdb_rec *crec = talloc_get_type_abort(
@@ -58,7 +78,8 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
SAFE_FREE(cdata.dptr);
- return (ret == 0) ? NT_STATUS_OK : NT_STATUS_INTERNAL_DB_CORRUPTION;
+ return (ret == 0) ? NT_STATUS_OK
+ : tdb_error_to_ntstatus(crec->ctdb_ctx->wtdb->tdb);
}
@@ -125,8 +146,10 @@ static NTSTATUS db_ctdb_store_persistent(struct db_record *rec, TDB_DATA data, i
if (NT_STATUS_IS_OK(status)) {
ret = tdb_store(crec->ctdb_ctx->wtdb->tdb, rec->key,
cdata, TDB_REPLACE);
- status = (ret == 0) ? NT_STATUS_OK
- : NT_STATUS_INTERNAL_DB_CORRUPTION;
+ status = (ret == 0)
+ ? NT_STATUS_OK
+ : tdb_error_to_ntstatus(
+ crec->ctdb_ctx->wtdb->tdb);
}
/*