summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2011-08-16 14:39:19 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:55 +0200
commitdc4a5f532392bb7e047b11017fa7916a68d67192 (patch)
treec0bb7fc304a4de24e342cb682d86624b20ee1434 /source3/lib
parent63c5c0eccf3df89135c4e18f5660e6f94978e3d3 (diff)
downloadsamba-dc4a5f532392bb7e047b11017fa7916a68d67192.tar.gz
samba-dc4a5f532392bb7e047b11017fa7916a68d67192.tar.bz2
samba-dc4a5f532392bb7e047b11017fa7916a68d67192.zip
s3:dbwrap: add function dbwrap_wipe()
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/dbwrap/dbwrap.c22
-rw-r--r--source3/lib/dbwrap/dbwrap.h2
-rw-r--r--source3/lib/dbwrap/dbwrap_open.c3
-rw-r--r--source3/lib/dbwrap/dbwrap_private.h2
4 files changed, 29 insertions, 0 deletions
diff --git a/source3/lib/dbwrap/dbwrap.c b/source3/lib/dbwrap/dbwrap.c
index af8e28cb7e..ad3f914e41 100644
--- a/source3/lib/dbwrap/dbwrap.c
+++ b/source3/lib/dbwrap/dbwrap.c
@@ -77,6 +77,23 @@ int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
}
+static int delete_record(struct db_record *rec, void *data)
+{
+ NTSTATUS status = rec->delete_rec(rec);
+ return NT_STATUS_IS_OK(status) ? 0 : -1;
+}
+
+/*
+ * Fallback wipe ipmlementation using traverse and delete if no genuine
+ * wipe operation is provided
+ */
+int dbwrap_fallback_wipe(struct db_context *db)
+{
+ NTSTATUS status = dbwrap_trans_traverse(db, &delete_record, NULL);
+ return NT_STATUS_IS_OK(status) ? 0 : -1;
+}
+
+
TDB_DATA dbwrap_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
TDB_DATA key)
{
@@ -186,3 +203,8 @@ int dbwrap_parse_record(struct db_context *db, TDB_DATA key,
return dbwrap_fallback_parse_record(db, key, parser, private_data);
}
}
+
+int dbwrap_wipe(struct db_context *db)
+{
+ return db->wipe(db);
+}
diff --git a/source3/lib/dbwrap/dbwrap.h b/source3/lib/dbwrap/dbwrap.h
index 0672de1f50..0ddc9e145f 100644
--- a/source3/lib/dbwrap/dbwrap.h
+++ b/source3/lib/dbwrap/dbwrap.h
@@ -53,6 +53,7 @@ struct db_context {
void *private_data),
void *private_data);
int (*exists)(struct db_context *db,TDB_DATA key);
+ int (*wipe)(struct db_context *db);
void *private_data;
bool persistent;
};
@@ -77,6 +78,7 @@ int dbwrap_parse_record(struct db_context *db, TDB_DATA key,
int (*parser)(TDB_DATA key, TDB_DATA data,
void *private_data),
void *private_data);
+int dbwrap_wipe(struct db_context *db);
/* The following definitions come from lib/dbwrap_util.c */
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index b605e5f66c..ef500e19a8 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -116,6 +116,9 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
if ((result != NULL) && (result->parse_record == NULL)) {
result->parse_record = dbwrap_fallback_parse_record;
}
+ if ((result != NULL) && (result->wipe == NULL)) {
+ result->wipe = dbwrap_fallback_wipe;
+ }
return result;
}
diff --git a/source3/lib/dbwrap/dbwrap_private.h b/source3/lib/dbwrap/dbwrap_private.h
index c8f3a1062f..1e221878f5 100644
--- a/source3/lib/dbwrap/dbwrap_private.h
+++ b/source3/lib/dbwrap/dbwrap_private.h
@@ -34,5 +34,7 @@ int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
void *private_data),
void *private_data);
+int dbwrap_fallback_wipe(struct db_context *db);
+
#endif /* __DBWRAP_PRIVATE_H__ */