/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- local_id
- local_id_string
- local_tdb_tmp_open
- local_backend_handle
- local_message_init
- local_message_send
- cluster_local_init
1 /*
2 Unix SMB/CIFS implementation.
3
4 local (dummy) clustering operations
5
6 Copyright (C) Andrew Tridgell 2006
7
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.
12
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.
17
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/>.
20 */
21
22 #include "includes.h"
23 #include "cluster/cluster.h"
24 #include "cluster/cluster_private.h"
25 #include "../tdb/include/tdb.h"
26 #include "tdb_wrap.h"
27 #include "system/filesys.h"
28 #include "param/param.h"
29 #include "librpc/gen_ndr/server_id.h"
30
31 /*
32 server a server_id for the local node
33 */
34 static struct server_id local_id(struct cluster_ops *ops, uint64_t id, uint32_t id2)
/* [<][>][^][v][top][bottom][index][help] */
35 {
36 struct server_id server_id;
37 ZERO_STRUCT(server_id);
38 server_id.id = id;
39 server_id.id2 = id2;
40 return server_id;
41 }
42
43
44 /*
45 return a server_id as a string
46 */
47 static const char *local_id_string(struct cluster_ops *ops,
/* [<][>][^][v][top][bottom][index][help] */
48 TALLOC_CTX *mem_ctx, struct server_id id)
49 {
50 return talloc_asprintf(mem_ctx, "%u.%llu.%u", id.node, (unsigned long long)id.id, id.id2);
51 }
52
53
54 /*
55 open a tmp tdb for the local node. By using smbd_tmp_path() we don't need
56 TDB_CLEAR_IF_FIRST as the tmp path is wiped at startup
57 */
58 static struct tdb_wrap *local_tdb_tmp_open(struct cluster_ops *ops,
/* [<][>][^][v][top][bottom][index][help] */
59 TALLOC_CTX *mem_ctx,
60 struct loadparm_context *lp_ctx,
61 const char *dbname, int flags)
62 {
63 char *path = smbd_tmp_path(mem_ctx, lp_ctx, dbname);
64 struct tdb_wrap *w;
65 w = tdb_wrap_open(mem_ctx, path, 0, flags,
66 O_RDWR|O_CREAT, 0600);
67 talloc_free(path);
68 return w;
69 }
70
71 /*
72 dummy backend handle function
73 */
74 static void *local_backend_handle(struct cluster_ops *ops)
/* [<][>][^][v][top][bottom][index][help] */
75 {
76 return NULL;
77 }
78
79 /*
80 dummy message init function - not needed as all messages are local
81 */
82 static NTSTATUS local_message_init(struct cluster_ops *ops,
/* [<][>][^][v][top][bottom][index][help] */
83 struct messaging_context *msg,
84 struct server_id server,
85 cluster_message_fn_t handler)
86 {
87 return NT_STATUS_OK;
88 }
89
90 /*
91 dummy message send
92 */
93 static NTSTATUS local_message_send(struct cluster_ops *ops,
/* [<][>][^][v][top][bottom][index][help] */
94 struct server_id server, DATA_BLOB *data)
95 {
96 return NT_STATUS_INVALID_DEVICE_REQUEST;
97 }
98
99 static struct cluster_ops cluster_local_ops = {
100 .cluster_id = local_id,
101 .cluster_id_string = local_id_string,
102 .cluster_tdb_tmp_open = local_tdb_tmp_open,
103 .backend_handle = local_backend_handle,
104 .message_init = local_message_init,
105 .message_send = local_message_send,
106 .private_data = NULL
107 };
108
109 void cluster_local_init(void)
/* [<][>][^][v][top][bottom][index][help] */
110 {
111 cluster_set_ops(&cluster_local_ops);
112 }
113