s3:smbd: move tcon specific globals to struct smbd_server_connection
[samba.git] / source3 / smbd / globals.c
1 /*
2    Unix SMB/Netbios implementation.
3    smbd globals
4    Copyright (C) Stefan Metzmacher 2009
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "smbd/globals.h"
22
23 #if defined(WITH_AIO)
24 struct aio_extra *aio_list_head = NULL;
25 struct tevent_signal *aio_signal_event = NULL;
26 int aio_pending_size = 0;
27 int outstanding_aio_calls = 0;
28 #endif
29
30 /* dlink list we store pending lock records on. */
31 struct blocking_lock_record *blocking_lock_queue = NULL;
32
33 /* dlink list we move cancelled lock records onto. */
34 struct blocking_lock_record *blocking_lock_cancelled_queue = NULL;
35
36 /* The event that makes us process our blocking lock queue */
37 struct timed_event *brl_timeout = NULL;
38
39 bool blocking_lock_unlock_state = false;
40 bool blocking_lock_cancel_state = false;
41
42 #ifdef USE_DMAPI
43 struct smbd_dmapi_context *dmapi_ctx = NULL;
44 #endif
45
46
47 bool dfree_broken = false;
48
49 struct bitmap *dptr_bmap = NULL;
50 struct dptr_struct *dirptrs = NULL;
51 int dirhandles_open = 0;
52
53 /* how many write cache buffers have been allocated */
54 unsigned int allocated_write_caches = 0;
55
56 int real_max_open_files = 0;
57 struct bitmap *file_bmap = NULL;
58 files_struct *Files = NULL;
59 int files_used = 0;
60 struct fsp_singleton_cache fsp_fi_cache = {
61         .fsp = NULL,
62         .id = {
63                 .devid = 0,
64                 .inode = 0,
65                 .extid = 0
66         }
67 };
68 unsigned long file_gen_counter = 0;
69 int first_file = 0;
70
71 const struct mangle_fns *mangle_fns = NULL;
72
73 unsigned char *chartest = NULL;
74 TDB_CONTEXT *tdb_mangled_cache = NULL;
75
76 /* these tables are used to provide fast tests for characters */
77 unsigned char char_flags[256];
78 /*
79   this determines how many characters are used from the original filename
80   in the 8.3 mangled name. A larger value leads to a weaker hash and more collisions.
81   The largest possible value is 6.
82 */
83 unsigned mangle_prefix = 0;
84 unsigned char base_reverse[256];
85
86 char *last_from = NULL;
87 char *last_to = NULL;
88
89 struct msg_state *smbd_msg_state = NULL;
90
91 bool logged_ioctl_message = false;
92
93 int trans_num = 0;
94 pid_t mypid = 0;
95 time_t last_smb_conf_reload_time = 0;
96 time_t last_printer_reload_time = 0;
97 /****************************************************************************
98  structure to hold a linked list of queued messages.
99  for processing.
100 ****************************************************************************/
101 struct pending_message_list *deferred_open_queue = NULL;
102 uint32_t common_flags2 = FLAGS2_LONG_PATH_COMPONENTS|FLAGS2_32_BIT_ERROR_CODES;
103
104 struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx = NULL;
105 struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx = NULL;
106
107 /* A stack of security contexts.  We include the current context as being
108    the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
109 struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
110 int sec_ctx_stack_ndx = 0;
111 bool become_uid_done = false;
112 bool become_gid_done = false;
113
114 connection_struct *last_conn = NULL;
115 uint16_t last_flags = 0;
116
117 struct db_context *session_db_ctx_ptr = NULL;
118
119 uint32_t global_client_caps = 0;
120
121 uint16_t fnf_handle = 257;
122
123 /* A stack of current_user connection contexts. */
124 struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
125 int conn_ctx_stack_ndx = 0;
126
127 struct vfs_init_function_entry *backends = NULL;
128 char *sparse_buf = NULL;
129 char *LastDir = NULL;
130
131 /* Current number of oplocks we have outstanding. */
132 int32_t exclusive_oplocks_open = 0;
133 int32_t level_II_oplocks_open = 0;
134 bool global_client_failed_oplock_break = false;
135 struct kernel_oplocks *koplocks = NULL;
136
137 struct notify_mid_map *notify_changes_by_mid = NULL;
138
139 int am_parent = 1;
140 int server_fd = -1;
141 struct event_context *smbd_event_ctx = NULL;
142 struct messaging_context *smbd_msg_ctx = NULL;
143 struct memcache *smbd_memcache_ctx = NULL;
144 bool exit_firsttime = true;
145 struct child_pid *children = 0;
146 int num_children = 0;
147
148 struct smbd_server_connection *smbd_server_conn = NULL;
149
150 void smbd_init_globals(void)
151 {
152         ZERO_STRUCT(char_flags);
153         ZERO_STRUCT(base_reverse);
154
155         ZERO_STRUCT(conn_ctx_stack);
156
157         ZERO_STRUCT(sec_ctx_stack);
158 }