Fix the local-memcache test for 64-bit
[Samba/id10ts.git] / source4 / cluster / local.c
blobc62c5cf405e7de22614552352de393dd17340a29
1 /*
2 Unix SMB/CIFS implementation.
4 local (dummy) clustering operations
6 Copyright (C) Andrew Tridgell 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "cluster/cluster.h"
24 #include "cluster/cluster_private.h"
25 #include "tdb_compat.h"
26 #include "lib/util/tdb_wrap.h"
27 #include "system/filesys.h"
28 #include "param/param.h"
29 #include "librpc/gen_ndr/server_id.h"
32 server a server_id for the local node
34 static struct server_id local_id(struct cluster_ops *ops, uint64_t pid, uint32_t task_id)
36 struct server_id server_id;
37 ZERO_STRUCT(server_id);
38 server_id.pid = pid;
39 server_id.task_id = task_id;
40 return server_id;
45 open a tmp tdb for the local node. By using smbd_tmp_path() we don't need
46 TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup
48 static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,
49 TALLOC_CTX *mem_ctx,
50 struct loadparm_context *lp_ctx,
51 const char *dbname, int flags)
53 char *path = smbd_tmp_path(mem_ctx, lp_ctx, dbname);
54 struct tdb_wrap *w;
55 w = tdb_wrap_open(mem_ctx, path, 0, flags,
56 O_RDWR|O_CREAT, 0600, lp_ctx);
57 talloc_free(path);
58 return w;
62 dummy backend handle function
64 static void *local_backend_handle(struct cluster_ops *ops)
66 return NULL;
70 dummy message init function - not needed as all messages are local
72 static NTSTATUS local_message_init(struct cluster_ops *ops,
73 struct imessaging_context *msg,
74 struct server_id server,
75 cluster_message_fn_t handler)
77 return NT_STATUS_OK;
81 dummy message send
83 static NTSTATUS local_message_send(struct cluster_ops *ops,
84 struct server_id server, DATA_BLOB *data)
86 return NT_STATUS_INVALID_DEVICE_REQUEST;
89 static struct cluster_ops cluster_local_ops = {
90 .cluster_id = local_id,
91 .cluster_tdb_tmp_open = local_tdb_tmp_open,
92 .backend_handle = local_backend_handle,
93 .message_init = local_message_init,
94 .message_send = local_message_send,
95 .private_data = NULL
98 void cluster_local_init(void)
100 cluster_set_ops(&cluster_local_ops);