2 Unix SMB/CIFS implementation.
4 POSIX NTVFS backend - structure definitions
6 Copyright (C) Andrew Tridgell 2004
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/>.
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 "dsdb/samdb/samdb.h"
35 /* this is the private structure for the posix vfs backend. It is used
36 to hold per-connection (per tree connect) state information */
38 struct ntvfs_module_context *ntvfs;
39 const char *base_directory;
40 struct GUID *base_fs_uuid;
42 const char *share_name;
45 struct pvfs_mangle_context *mangle_ctx;
47 struct brl_context *brl_context;
48 struct odb_context *odb_context;
49 struct notify_context *notify_context;
50 struct wbc_context *wbc_ctx;
52 /* a list of pending async requests. Needed to support
54 struct pvfs_wait *wait_list;
56 /* the sharing violation timeout (nsecs) */
57 uint_t sharing_violation_delay;
59 /* the oplock break timeout (secs) */
60 uint_t oplock_break_timeout;
62 /* filesystem attributes (see FS_ATTR_*) */
65 /* if posix:eadb is set, then this gets setup */
66 struct tdb_wrap *ea_db;
68 /* the allocation size rounding */
69 uint32_t alloc_size_rounding;
72 /* the open files as DLINKLIST */
73 struct pvfs_file *list;
77 /* an id tree mapping open search ID to a pvfs_search_state structure */
78 struct idr_context *idtree;
80 /* the open searches as DLINKLIST */
81 struct pvfs_search_state *list;
83 /* how long to keep inactive searches around for */
84 uint_t inactivity_time;
87 /* used to accelerate acl mapping */
89 const struct dom_sid *creator_owner;
90 const struct dom_sid *creator_group;
94 const struct pvfs_acl_ops *acl_ops;
96 /* non-flag share options */
99 mode_t force_dir_mode;
101 mode_t force_create_mode;
105 /* this is the basic information needed about a file from the filesystem */
106 struct pvfs_dos_fileinfo {
120 this is the structure returned by pvfs_resolve_name(). It holds the posix details of
121 a filename passed by the client to any function
123 struct pvfs_filename {
124 const char *original_name;
126 const char *stream_name; /* does not include :$DATA suffix */
127 uint32_t stream_id; /* this uses a hash, so is probabilistic */
129 bool exists; /* true if the base filename exists */
130 bool stream_exists; /* true if the stream exists */
132 struct pvfs_dos_fileinfo dos;
136 /* open file handle state - encapsulates the posix fd
138 Note that this is separated from the pvfs_file structure in order
139 to cope with the openx DENY_DOS semantics where a 2nd DENY_DOS open
140 on the same connection gets the same low level filesystem handle,
141 rather than a new handle
143 struct pvfs_file_handle {
146 struct pvfs_filename *name;
148 /* a unique file key to be used for open file locking */
149 DATA_BLOB odb_locking_key;
151 uint32_t create_options;
153 /* this is set by the mode_information level. What does it do? */
156 /* yes, we need 2 independent positions ... */
157 uint64_t seek_offset;
160 bool have_opendb_entry;
163 * we need to wait for oplock break requests from other processes,
164 * and we need to remember the pvfs_file so we can correctly
165 * forward the oplock break to the client
167 struct pvfs_oplock *oplock;
169 /* we need this hook back to our parent for lock destruction */
170 struct pvfs_state *pvfs;
172 /* the open went through to completion */
176 /* open file state */
178 struct pvfs_file *next, *prev;
179 struct pvfs_file_handle *handle;
180 struct ntvfs_handle *ntvfs;
182 struct pvfs_state *pvfs;
184 uint32_t impersonation;
185 uint32_t share_access;
186 uint32_t access_mask;
188 /* a list of pending locks - used for locking cancel operations */
189 struct pvfs_pending_lock *pending_list;
191 /* a file handle to be used for byte range locking */
192 struct brl_handle *brl_handle;
194 /* a count of active locks - used to avoid calling brl_close on
198 /* for directories, a buffer of pending notify events */
199 struct pvfs_notify_buffer *notify_buffer;
201 /* for directories, the state of an incomplete SMB2 Find */
202 struct pvfs_search_state *search;
205 /* the state of a search started with pvfs_search_first() */
206 struct pvfs_search_state {
207 struct pvfs_search_state *prev, *next;
208 struct pvfs_state *pvfs;
211 uint16_t search_attrib;
212 uint16_t must_attrib;
213 struct pvfs_dir *dir;
216 struct ea_name *ea_names;
217 struct timed_event *te;
220 /* flags to pvfs_resolve_name() */
221 #define PVFS_RESOLVE_WILDCARD (1<<0)
222 #define PVFS_RESOLVE_STREAMS (1<<1)
224 /* flags in pvfs->flags */
225 #define PVFS_FLAG_CI_FILESYSTEM (1<<0) /* the filesystem is case insensitive */
226 #define PVFS_FLAG_MAP_ARCHIVE (1<<1)
227 #define PVFS_FLAG_MAP_SYSTEM (1<<2)
228 #define PVFS_FLAG_MAP_HIDDEN (1<<3)
229 #define PVFS_FLAG_READONLY (1<<4)
230 #define PVFS_FLAG_STRICT_SYNC (1<<5)
231 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
232 #define PVFS_FLAG_XATTR_ENABLE (1<<7)
233 #define PVFS_FLAG_FAKE_OPLOCKS (1<<8)
234 #define PVFS_FLAG_LINUX_AIO (1<<9)
236 /* forward declare some anonymous structures */
239 /* types of notification for pvfs wait events */
240 enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
243 state of a pending retry
245 struct pvfs_odb_retry;
247 #define PVFS_EADB "posix:eadb"
248 #define PVFS_XATTR "posix:xattr"
249 #define PVFS_FAKE_OPLOCKS "posix:fakeoplocks"
250 #define PVFS_SHARE_DELAY "posix:sharedelay"
251 #define PVFS_OPLOCK_TIMEOUT "posix:oplocktimeout"
252 #define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
253 #define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
254 #define PVFS_ACL "posix:acl"
255 #define PVFS_AIO "posix:aio"
257 #define PVFS_XATTR_DEFAULT true
258 #define PVFS_FAKE_OPLOCKS_DEFAULT false
259 #define PVFS_SHARE_DELAY_DEFAULT 1000000 /* nsecs */
260 #define PVFS_OPLOCK_TIMEOUT_DEFAULT 30 /* secs */
261 #define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
262 #define PVFS_SEARCH_INACTIVITY_DEFAULT 300
264 struct pvfs_acl_ops {
266 NTSTATUS (*acl_load)(struct pvfs_state *, struct pvfs_filename *, int , TALLOC_CTX *,
267 struct security_descriptor **);
268 NTSTATUS (*acl_save)(struct pvfs_state *, struct pvfs_filename *, int , struct security_descriptor *);
271 #include "ntvfs/posix/vfs_posix_proto.h"
273 NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
274 struct pvfs_file *f, uint32_t maxcnt);
275 NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr,
276 struct pvfs_file *f);
278 #endif /* _VFS_POSIX_H_ */