From: Michael Adam Date: Wed, 6 Aug 2008 20:22:23 +0000 (+0200) Subject: dbwrap ctdb: add a partial mapping from tdb_error to NTSTATUS and use it for store. X-Git-Tag: samba-3.3.0pre1~162 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eaf76c751f9bde2843174b400c109304831df83e;p=thirdparty%2Fsamba.git dbwrap ctdb: add a partial mapping from tdb_error to NTSTATUS and use it for store. Michael --- diff --git a/source/lib/dbwrap_ctdb.c b/source/lib/dbwrap_ctdb.c index 1cccecbad93..69b3631c04d 100644 --- a/source/lib/dbwrap_ctdb.c +++ b/source/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); } /*