mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
lib: Make g_lock_dump use TDB_DATA
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
parent
a6c749e76c
commit
67fcc7dbb9
@ -58,7 +58,7 @@ NTSTATUS g_lock_do(TDB_DATA key, enum g_lock_type lock_type,
|
||||
int g_lock_locks(struct g_lock_ctx *ctx,
|
||||
int (*fn)(const char *name, void *private_data),
|
||||
void *private_data);
|
||||
NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name,
|
||||
NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, TDB_DATA key,
|
||||
void (*fn)(const struct g_lock_rec *locks,
|
||||
size_t num_locks,
|
||||
const uint8_t *data,
|
||||
|
@ -662,7 +662,7 @@ int g_lock_locks(struct g_lock_ctx *ctx,
|
||||
|
||||
struct g_lock_dump_state {
|
||||
TALLOC_CTX *mem_ctx;
|
||||
const char *name;
|
||||
TDB_DATA key;
|
||||
void (*fn)(const struct g_lock_rec *locks,
|
||||
size_t num_locks,
|
||||
const uint8_t *data,
|
||||
@ -684,7 +684,9 @@ static void g_lock_dump_fn(TDB_DATA key, TDB_DATA data,
|
||||
ok = g_lock_parse(data.dptr, data.dsize, &lck);
|
||||
if (!ok) {
|
||||
DBG_DEBUG("g_lock_parse failed for %s\n",
|
||||
state->name);
|
||||
hex_encode_talloc(talloc_tos(),
|
||||
state->key.dptr,
|
||||
state->key.dsize));
|
||||
state->status = NT_STATUS_INTERNAL_DB_CORRUPTION;
|
||||
return;
|
||||
}
|
||||
@ -708,7 +710,7 @@ static void g_lock_dump_fn(TDB_DATA key, TDB_DATA data,
|
||||
state->status = NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name,
|
||||
NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, TDB_DATA key,
|
||||
void (*fn)(const struct g_lock_rec *locks,
|
||||
size_t num_locks,
|
||||
const uint8_t *data,
|
||||
@ -717,13 +719,12 @@ NTSTATUS g_lock_dump(struct g_lock_ctx *ctx, const char *name,
|
||||
void *private_data)
|
||||
{
|
||||
struct g_lock_dump_state state = {
|
||||
.mem_ctx = ctx, .name = name,
|
||||
.mem_ctx = ctx, .key = key,
|
||||
.fn = fn, .private_data = private_data
|
||||
};
|
||||
NTSTATUS status;
|
||||
|
||||
status = dbwrap_parse_record(ctx->db, string_term_tdb_data(name),
|
||||
g_lock_dump_fn, &state);
|
||||
status = dbwrap_parse_record(ctx->db, key, g_lock_dump_fn, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DBG_DEBUG("dbwrap_parse_record returned %s\n",
|
||||
nt_errstr(status));
|
||||
|
@ -1491,7 +1491,8 @@ static NTSTATUS smbd_claim_version(struct messaging_context *msg,
|
||||
|
||||
state = (struct smbd_claim_version_state) { .mem_ctx = ctx };
|
||||
|
||||
status = g_lock_dump(ctx, name, smbd_claim_version_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(name),
|
||||
smbd_claim_version_parser, &state);
|
||||
if (!NT_STATUS_IS_OK(status) &&
|
||||
!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
|
||||
DBG_ERR("Could not read samba_version_string\n");
|
||||
|
@ -179,7 +179,8 @@ bool run_g_lock2(int dummy)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock2_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock2_parser, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr, "g_lock_dump failed: %s\n",
|
||||
nt_errstr(status));
|
||||
@ -283,7 +284,8 @@ bool run_g_lock3(int dummy)
|
||||
state.lock_type = G_LOCK_READ;
|
||||
state.ok = false;
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock3_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock3_parser, &state);
|
||||
if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
|
||||
fprintf(stderr, "g_lock_dump returned %s\n",
|
||||
nt_errstr(status));
|
||||
@ -304,7 +306,8 @@ bool run_g_lock3(int dummy)
|
||||
state.lock_type = G_LOCK_WRITE;
|
||||
state.ok = false;
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock3_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock3_parser, &state);
|
||||
if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
|
||||
fprintf(stderr, "g_lock_dump returned %s\n",
|
||||
nt_errstr(status));
|
||||
@ -537,7 +540,8 @@ bool run_g_lock4(int dummy)
|
||||
.me = messaging_server_id(msg)
|
||||
};
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock4_check, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock4_check, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr, "g_lock_dump failed: %s\n",
|
||||
nt_errstr(status));
|
||||
@ -669,7 +673,8 @@ bool run_g_lock5(int dummy)
|
||||
for (i=0; i<nprocs; i++) {
|
||||
struct lock5_parser_state state;
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock5_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock5_parser, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr, "g_lock_dump returned %s\n",
|
||||
nt_errstr(status));
|
||||
@ -819,7 +824,8 @@ bool run_g_lock6(int dummy)
|
||||
{
|
||||
struct lock6_parser_state state;
|
||||
|
||||
status = g_lock_dump(ctx, lockname, lock6_parser, &state);
|
||||
status = g_lock_dump(ctx, string_term_tdb_data(lockname),
|
||||
lock6_parser, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr, "g_lock_dump returned %s\n",
|
||||
nt_errstr(status));
|
||||
|
@ -143,7 +143,8 @@ static int net_g_lock_dump(struct net_context *c, int argc, const char **argv)
|
||||
goto done;
|
||||
}
|
||||
|
||||
(void)g_lock_dump(g_ctx, argv[0], net_g_lock_dump_fn, NULL);
|
||||
(void)g_lock_dump(g_ctx, string_term_tdb_data(argv[0]),
|
||||
net_g_lock_dump_fn, NULL);
|
||||
|
||||
ret = 0;
|
||||
done:
|
||||
|
Loading…
Reference in New Issue
Block a user