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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "librpc/gen_ndr/xattr.h"
27 #include "system/filesys.h"
28 #include "ntvfs/ntvfs.h"
29 #include "ntvfs/common/ntvfs_common.h"
30 #include "dsdb/samdb/samdb.h"
32 /* this is the private structure for the posix vfs backend. It is used
33 to hold per-connection (per tree connect) state information */
35 struct ntvfs_module_context *ntvfs;
36 const char *base_directory;
37 struct GUID *base_fs_uuid;
39 const char *share_name;
42 struct pvfs_mangle_context *mangle_ctx;
44 struct brl_context *brl_context;
45 struct odb_context *odb_context;
46 struct notify_context *notify_context;
47 struct sidmap_context *sidmap;
49 /* a list of pending async requests. Needed to support
51 struct pvfs_wait *wait_list;
53 /* the sharing violation timeout */
54 uint_t sharing_violation_delay;
56 /* filesystem attributes (see FS_ATTR_*) */
59 /* if posix:eadb is set, then this gets setup */
60 struct tdb_wrap *ea_db;
62 /* the allocation size rounding */
63 uint32_t alloc_size_rounding;
66 /* the open files as DLINKLIST */
67 struct pvfs_file *list;
71 /* an id tree mapping open search ID to a pvfs_search_state structure */
72 struct idr_context *idtree;
74 /* the open searches as DLINKLIST */
75 struct pvfs_search_state *list;
77 /* how long to keep inactive searches around for */
78 uint_t inactivity_time;
81 /* used to accelerate acl mapping */
83 const struct dom_sid *creator_owner;
84 const struct dom_sid *creator_group;
88 const struct pvfs_acl_ops *acl_ops;
90 /* non-flag share options */
93 mode_t force_dir_mode;
95 mode_t force_create_mode;
99 /* this is the basic information needed about a file from the filesystem */
100 struct pvfs_dos_fileinfo {
114 this is the structure returned by pvfs_resolve_name(). It holds the posix details of
115 a filename passed by the client to any function
117 struct pvfs_filename {
118 const char *original_name;
120 const char *stream_name; /* does not include :$DATA suffix */
121 uint32_t stream_id; /* this uses a hash, so is probabilistic */
123 BOOL exists; /* true if the base filename exists */
124 BOOL stream_exists; /* true if the stream exists */
126 struct pvfs_dos_fileinfo dos;
130 /* open file handle state - encapsulates the posix fd
132 Note that this is separated from the pvfs_file structure in order
133 to cope with the openx DENY_DOS semantics where a 2nd DENY_DOS open
134 on the same connection gets the same low level filesystem handle,
135 rather than a new handle
137 struct pvfs_file_handle {
140 struct pvfs_filename *name;
142 /* a unique file key to be used for open file locking */
143 DATA_BLOB odb_locking_key;
145 uint32_t create_options;
147 /* this is set by the mode_information level. What does it do? */
150 /* yes, we need 2 independent positions ... */
151 uint64_t seek_offset;
154 BOOL have_opendb_entry;
156 /* we need this hook back to our parent for lock destruction */
157 struct pvfs_state *pvfs;
159 /* have we set a sticky write time that we should remove on close */
160 BOOL sticky_write_time;
162 /* the open went through to completion */
166 /* open file state */
168 struct pvfs_file *next, *prev;
169 struct pvfs_file_handle *handle;
170 struct ntvfs_handle *ntvfs;
172 struct pvfs_state *pvfs;
174 uint32_t impersonation;
175 uint32_t share_access;
176 uint32_t access_mask;
178 /* a list of pending locks - used for locking cancel operations */
179 struct pvfs_pending_lock *pending_list;
181 /* a file handle to be used for byte range locking */
182 struct brl_handle *brl_handle;
184 /* a count of active locks - used to avoid calling brl_close on
188 /* for directories, a buffer of pending notify events */
189 struct pvfs_notify_buffer *notify_buffer;
191 /* for directories, the state of an incomplete SMB2 Find */
192 struct pvfs_search_state *search;
195 /* the state of a search started with pvfs_search_first() */
196 struct pvfs_search_state {
197 struct pvfs_search_state *prev, *next;
198 struct pvfs_state *pvfs;
201 uint16_t search_attrib;
202 uint16_t must_attrib;
203 struct pvfs_dir *dir;
206 struct ea_name *ea_names;
207 struct timed_event *te;
210 /* flags to pvfs_resolve_name() */
211 #define PVFS_RESOLVE_WILDCARD (1<<0)
212 #define PVFS_RESOLVE_STREAMS (1<<1)
214 /* flags in pvfs->flags */
215 #define PVFS_FLAG_CI_FILESYSTEM (1<<0) /* the filesystem is case insensitive */
216 #define PVFS_FLAG_MAP_ARCHIVE (1<<1)
217 #define PVFS_FLAG_MAP_SYSTEM (1<<2)
218 #define PVFS_FLAG_MAP_HIDDEN (1<<3)
219 #define PVFS_FLAG_READONLY (1<<4)
220 #define PVFS_FLAG_STRICT_SYNC (1<<5)
221 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
222 #define PVFS_FLAG_XATTR_ENABLE (1<<7)
223 #define PVFS_FLAG_FAKE_OPLOCKS (1<<8)
224 #define PVFS_FLAG_LINUX_AIO (1<<9)
226 /* forward declare some anonymous structures */
229 /* types of notification for pvfs wait events */
230 enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
232 #define PVFS_EADB "posix:eadb"
233 #define PVFS_XATTR "posix:xattr"
234 #define PVFS_FAKE_OPLOCKS "posix:fakeoplocks"
235 #define PVFS_SHARE_DELAY "posix:sharedelay"
236 #define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
237 #define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
238 #define PVFS_ACL "posix:acl"
239 #define PVFS_AIO "posix:aio"
241 #define PVFS_XATTR_DEFAULT True
242 #define PVFS_FAKE_OPLOCKS_DEFAULT False
243 #define PVFS_SHARE_DELAY_DEFAULT 1000000
244 #define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
245 #define PVFS_SEARCH_INACTIVITY_DEFAULT 300
247 struct pvfs_acl_ops {
249 NTSTATUS (*acl_load)(struct pvfs_state *, struct pvfs_filename *, int , TALLOC_CTX *,
250 struct security_descriptor **);
251 NTSTATUS (*acl_save)(struct pvfs_state *, struct pvfs_filename *, int , struct security_descriptor *);
254 #include "ntvfs/posix/vfs_posix_proto.h"
256 NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
257 struct pvfs_file *f, uint32_t maxcnt);
258 NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr,
259 struct pvfs_file *f);
261 #endif /* _VFS_POSIX_H_ */