1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 |
|
---|
4 | POSIX NTVFS backend - structure definitions
|
---|
5 |
|
---|
6 | Copyright (C) Andrew Tridgell 2004
|
---|
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 | #ifndef _VFS_POSIX_H_
|
---|
23 | #define _VFS_POSIX_H_
|
---|
24 |
|
---|
25 | #include "librpc/gen_ndr/xattr.h"
|
---|
26 | #include "system/filesys.h"
|
---|
27 | #include "ntvfs/ntvfs.h"
|
---|
28 | #include "ntvfs/common/ntvfs_common.h"
|
---|
29 | #include "libcli/wbclient/wbclient.h"
|
---|
30 | #include "lib/events/events.h"
|
---|
31 |
|
---|
32 | struct pvfs_wait;
|
---|
33 | struct pvfs_oplock;
|
---|
34 |
|
---|
35 | /* this is the private structure for the posix vfs backend. It is used
|
---|
36 | to hold per-connection (per tree connect) state information */
|
---|
37 | struct pvfs_state {
|
---|
38 | struct ntvfs_module_context *ntvfs;
|
---|
39 | const char *base_directory;
|
---|
40 | struct GUID *base_fs_uuid;
|
---|
41 |
|
---|
42 | const char *share_name;
|
---|
43 | unsigned int flags;
|
---|
44 |
|
---|
45 | struct pvfs_mangle_context *mangle_ctx;
|
---|
46 |
|
---|
47 | struct brl_context *brl_context;
|
---|
48 | struct odb_context *odb_context;
|
---|
49 | struct notify_context *notify_context;
|
---|
50 | struct wbc_context *wbc_ctx;
|
---|
51 |
|
---|
52 | /* a list of pending async requests. Needed to support
|
---|
53 | ntcancel */
|
---|
54 | struct pvfs_wait *wait_list;
|
---|
55 |
|
---|
56 | /* the sharing violation timeout (nsecs) */
|
---|
57 | unsigned int sharing_violation_delay;
|
---|
58 |
|
---|
59 | /* the oplock break timeout (secs) */
|
---|
60 | unsigned int oplock_break_timeout;
|
---|
61 |
|
---|
62 | /* the write time update delay (nsecs) */
|
---|
63 | unsigned int writetime_delay;
|
---|
64 |
|
---|
65 | /* filesystem attributes (see FS_ATTR_*) */
|
---|
66 | uint32_t fs_attribs;
|
---|
67 |
|
---|
68 | /* if posix:eadb is set, then this gets setup */
|
---|
69 | struct tdb_wrap *ea_db;
|
---|
70 |
|
---|
71 | /* the allocation size rounding */
|
---|
72 | uint32_t alloc_size_rounding;
|
---|
73 |
|
---|
74 | struct {
|
---|
75 | /* the open files as DLINKLIST */
|
---|
76 | struct pvfs_file *list;
|
---|
77 | } files;
|
---|
78 |
|
---|
79 | struct {
|
---|
80 | /* an id tree mapping open search ID to a pvfs_search_state structure */
|
---|
81 | struct idr_context *idtree;
|
---|
82 |
|
---|
83 | /* the open searches as DLINKLIST */
|
---|
84 | struct pvfs_search_state *list;
|
---|
85 |
|
---|
86 | /* how long to keep inactive searches around for */
|
---|
87 | unsigned int inactivity_time;
|
---|
88 | } search;
|
---|
89 |
|
---|
90 | /* used to accelerate acl mapping */
|
---|
91 | struct {
|
---|
92 | const struct dom_sid *creator_owner;
|
---|
93 | const struct dom_sid *creator_group;
|
---|
94 | } sid_cache;
|
---|
95 |
|
---|
96 | /* the acl backend */
|
---|
97 | const struct pvfs_acl_ops *acl_ops;
|
---|
98 |
|
---|
99 | /* non-flag share options */
|
---|
100 | struct {
|
---|
101 | mode_t dir_mask;
|
---|
102 | mode_t force_dir_mode;
|
---|
103 | mode_t create_mask;
|
---|
104 | mode_t force_create_mode;
|
---|
105 | } options;
|
---|
106 | };
|
---|
107 |
|
---|
108 | /* this is the basic information needed about a file from the filesystem */
|
---|
109 | struct pvfs_dos_fileinfo {
|
---|
110 | NTTIME create_time;
|
---|
111 | NTTIME access_time;
|
---|
112 | NTTIME write_time;
|
---|
113 | NTTIME change_time;
|
---|
114 | uint32_t attrib;
|
---|
115 | uint64_t alloc_size;
|
---|
116 | uint32_t nlink;
|
---|
117 | uint32_t ea_size;
|
---|
118 | uint64_t file_id;
|
---|
119 | uint32_t flags;
|
---|
120 | };
|
---|
121 |
|
---|
122 | /*
|
---|
123 | this is the structure returned by pvfs_resolve_name(). It holds the posix details of
|
---|
124 | a filename passed by the client to any function
|
---|
125 | */
|
---|
126 | struct pvfs_filename {
|
---|
127 | char *original_name;
|
---|
128 | char *full_name;
|
---|
129 | char *stream_name; /* does not include :$DATA suffix */
|
---|
130 | uint32_t stream_id; /* this uses a hash, so is probabilistic */
|
---|
131 | bool has_wildcard;
|
---|
132 | bool exists; /* true if the base filename exists */
|
---|
133 | bool stream_exists; /* true if the stream exists */
|
---|
134 | struct stat st;
|
---|
135 | struct pvfs_dos_fileinfo dos;
|
---|
136 | };
|
---|
137 |
|
---|
138 |
|
---|
139 | /* open file handle state - encapsulates the posix fd
|
---|
140 |
|
---|
141 | Note that this is separated from the pvfs_file structure in order
|
---|
142 | to cope with the openx DENY_DOS semantics where a 2nd DENY_DOS open
|
---|
143 | on the same connection gets the same low level filesystem handle,
|
---|
144 | rather than a new handle
|
---|
145 | */
|
---|
146 | struct pvfs_file_handle {
|
---|
147 | int fd;
|
---|
148 |
|
---|
149 | struct pvfs_filename *name;
|
---|
150 |
|
---|
151 | /* a unique file key to be used for open file locking */
|
---|
152 | DATA_BLOB odb_locking_key;
|
---|
153 |
|
---|
154 | uint32_t create_options;
|
---|
155 |
|
---|
156 | /* this is set by the mode_information level. What does it do? */
|
---|
157 | uint32_t mode;
|
---|
158 |
|
---|
159 | /* yes, we need 2 independent positions ... */
|
---|
160 | uint64_t seek_offset;
|
---|
161 | uint64_t position;
|
---|
162 |
|
---|
163 | bool have_opendb_entry;
|
---|
164 |
|
---|
165 | /*
|
---|
166 | * we need to wait for oplock break requests from other processes,
|
---|
167 | * and we need to remember the pvfs_file so we can correctly
|
---|
168 | * forward the oplock break to the client
|
---|
169 | */
|
---|
170 | struct pvfs_oplock *oplock;
|
---|
171 |
|
---|
172 | /* we need this hook back to our parent for lock destruction */
|
---|
173 | struct pvfs_state *pvfs;
|
---|
174 |
|
---|
175 | struct {
|
---|
176 | bool update_triggered;
|
---|
177 | struct tevent_timer *update_event;
|
---|
178 | bool update_on_close;
|
---|
179 | NTTIME close_time;
|
---|
180 | bool update_forced;
|
---|
181 | } write_time;
|
---|
182 |
|
---|
183 | /* the open went through to completion */
|
---|
184 | bool open_completed;
|
---|
185 |
|
---|
186 | uint8_t private_flags;
|
---|
187 | };
|
---|
188 |
|
---|
189 | /* open file state */
|
---|
190 | struct pvfs_file {
|
---|
191 | struct pvfs_file *next, *prev;
|
---|
192 | struct pvfs_file_handle *handle;
|
---|
193 | struct ntvfs_handle *ntvfs;
|
---|
194 |
|
---|
195 | struct pvfs_state *pvfs;
|
---|
196 |
|
---|
197 | uint32_t impersonation;
|
---|
198 | uint32_t share_access;
|
---|
199 | uint32_t access_mask;
|
---|
200 |
|
---|
201 | /* a list of pending locks - used for locking cancel operations */
|
---|
202 | struct pvfs_pending_lock *pending_list;
|
---|
203 |
|
---|
204 | /* a file handle to be used for byte range locking */
|
---|
205 | struct brl_handle *brl_handle;
|
---|
206 |
|
---|
207 | /* a count of active locks - used to avoid calling brl_close on
|
---|
208 | file close */
|
---|
209 | uint64_t lock_count;
|
---|
210 |
|
---|
211 | /* for directories, a buffer of pending notify events */
|
---|
212 | struct pvfs_notify_buffer *notify_buffer;
|
---|
213 |
|
---|
214 | /* for directories, the state of an incomplete SMB2 Find */
|
---|
215 | struct pvfs_search_state *search;
|
---|
216 | };
|
---|
217 |
|
---|
218 | /* the state of a search started with pvfs_search_first() */
|
---|
219 | struct pvfs_search_state {
|
---|
220 | struct pvfs_search_state *prev, *next;
|
---|
221 | struct pvfs_state *pvfs;
|
---|
222 | uint16_t handle;
|
---|
223 | off_t current_index;
|
---|
224 | uint16_t search_attrib;
|
---|
225 | uint16_t must_attrib;
|
---|
226 | struct pvfs_dir *dir;
|
---|
227 | time_t last_used; /* monotonic clock time */
|
---|
228 | unsigned int num_ea_names;
|
---|
229 | struct ea_name *ea_names;
|
---|
230 | struct tevent_timer *te;
|
---|
231 | };
|
---|
232 |
|
---|
233 | /* flags to pvfs_resolve_name() */
|
---|
234 | #define PVFS_RESOLVE_WILDCARD (1<<0)
|
---|
235 | #define PVFS_RESOLVE_STREAMS (1<<1)
|
---|
236 | #define PVFS_RESOLVE_NO_OPENDB (1<<2)
|
---|
237 |
|
---|
238 | /* flags in pvfs->flags */
|
---|
239 | #define PVFS_FLAG_CI_FILESYSTEM (1<<0) /* the filesystem is case insensitive */
|
---|
240 | #define PVFS_FLAG_MAP_ARCHIVE (1<<1)
|
---|
241 | #define PVFS_FLAG_MAP_SYSTEM (1<<2)
|
---|
242 | #define PVFS_FLAG_MAP_HIDDEN (1<<3)
|
---|
243 | #define PVFS_FLAG_READONLY (1<<4)
|
---|
244 | #define PVFS_FLAG_STRICT_SYNC (1<<5)
|
---|
245 | #define PVFS_FLAG_STRICT_LOCKING (1<<6)
|
---|
246 | #define PVFS_FLAG_XATTR_ENABLE (1<<7)
|
---|
247 | #define PVFS_FLAG_FAKE_OPLOCKS (1<<8)
|
---|
248 | #define PVFS_FLAG_LINUX_AIO (1<<9)
|
---|
249 | #define PVFS_FLAG_PERM_OVERRIDE (1<<10)
|
---|
250 |
|
---|
251 | /* forward declare some anonymous structures */
|
---|
252 | struct pvfs_dir;
|
---|
253 |
|
---|
254 | /* types of notification for pvfs wait events */
|
---|
255 | enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
|
---|
256 |
|
---|
257 | /*
|
---|
258 | state of a pending retry
|
---|
259 | */
|
---|
260 | struct pvfs_odb_retry;
|
---|
261 |
|
---|
262 | #define PVFS_EADB "posix:eadb"
|
---|
263 | #define PVFS_XATTR "posix:xattr"
|
---|
264 | #define PVFS_FAKE_OPLOCKS "posix:fakeoplocks"
|
---|
265 | #define PVFS_SHARE_DELAY "posix:sharedelay"
|
---|
266 | #define PVFS_OPLOCK_TIMEOUT "posix:oplocktimeout"
|
---|
267 | #define PVFS_WRITETIME_DELAY "posix:writetimeupdatedelay"
|
---|
268 | #define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
|
---|
269 | #define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
|
---|
270 | #define PVFS_ACL "posix:acl"
|
---|
271 | #define PVFS_AIO "posix:aio"
|
---|
272 | #define PVFS_PERM_OVERRIDE "posix:permission override"
|
---|
273 |
|
---|
274 | #define PVFS_XATTR_DEFAULT true
|
---|
275 | #define PVFS_FAKE_OPLOCKS_DEFAULT false
|
---|
276 | #define PVFS_SHARE_DELAY_DEFAULT 1000000 /* nsecs */
|
---|
277 | #define PVFS_OPLOCK_TIMEOUT_DEFAULT 30 /* secs */
|
---|
278 | #define PVFS_WRITETIME_DELAY_DEFAULT 2000000 /* nsecs */
|
---|
279 | #define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
|
---|
280 | #define PVFS_SEARCH_INACTIVITY_DEFAULT 300
|
---|
281 |
|
---|
282 | struct pvfs_acl_ops {
|
---|
283 | const char *name;
|
---|
284 | NTSTATUS (*acl_load)(struct pvfs_state *, struct pvfs_filename *, int , TALLOC_CTX *,
|
---|
285 | struct security_descriptor **);
|
---|
286 | NTSTATUS (*acl_save)(struct pvfs_state *, struct pvfs_filename *, int , struct security_descriptor *);
|
---|
287 | };
|
---|
288 |
|
---|
289 | #include "ntvfs/posix/vfs_posix_proto.h"
|
---|
290 | #include "ntvfs/posix/vfs_acl_proto.h"
|
---|
291 |
|
---|
292 | NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
|
---|
293 | struct pvfs_file *f, uint32_t maxcnt);
|
---|
294 | NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr,
|
---|
295 | struct pvfs_file *f);
|
---|
296 |
|
---|
297 | #endif /* _VFS_POSIX_H_ */
|
---|