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 "dsdb/samdb/samdb.h"
33 /* this is the private structure for the posix vfs backend. It is used
34 to hold per-connection (per tree connect) state information */
36 struct ntvfs_module_context *ntvfs;
37 const char *base_directory;
38 struct GUID *base_fs_uuid;
40 const char *share_name;
43 struct pvfs_mangle_context *mangle_ctx;
45 struct brl_context *brl_context;
46 struct odb_context *odb_context;
47 struct notify_context *notify_context;
48 struct sidmap_context *sidmap;
50 /* a list of pending async requests. Needed to support
52 struct pvfs_wait *wait_list;
54 /* the sharing violation timeout */
55 uint_t sharing_violation_delay;
57 /* filesystem attributes (see FS_ATTR_*) */
60 /* if posix:eadb is set, then this gets setup */
61 struct tdb_wrap *ea_db;
63 /* the allocation size rounding */
64 uint32_t alloc_size_rounding;
67 /* the open files as DLINKLIST */
68 struct pvfs_file *list;
72 /* an id tree mapping open search ID to a pvfs_search_state structure */
73 struct idr_context *idtree;
75 /* the open searches as DLINKLIST */
76 struct pvfs_search_state *list;
78 /* how long to keep inactive searches around for */
79 uint_t inactivity_time;
82 /* used to accelerate acl mapping */
84 const struct dom_sid *creator_owner;
85 const struct dom_sid *creator_group;
89 const struct pvfs_acl_ops *acl_ops;
91 /* non-flag share options */
94 mode_t force_dir_mode;
96 mode_t force_create_mode;
100 /* this is the basic information needed about a file from the filesystem */
101 struct pvfs_dos_fileinfo {
115 this is the structure returned by pvfs_resolve_name(). It holds the posix details of
116 a filename passed by the client to any function
118 struct pvfs_filename {
119 const char *original_name;
121 const char *stream_name; /* does not include :$DATA suffix */
122 uint32_t stream_id; /* this uses a hash, so is probabilistic */
124 bool exists; /* true if the base filename exists */
125 bool stream_exists; /* true if the stream exists */
127 struct pvfs_dos_fileinfo dos;
131 /* open file handle state - encapsulates the posix fd
133 Note that this is separated from the pvfs_file structure in order
134 to cope with the openx DENY_DOS semantics where a 2nd DENY_DOS open
135 on the same connection gets the same low level filesystem handle,
136 rather than a new handle
138 struct pvfs_file_handle {
141 struct pvfs_filename *name;
143 /* a unique file key to be used for open file locking */
144 DATA_BLOB odb_locking_key;
146 uint32_t create_options;
148 /* this is set by the mode_information level. What does it do? */
151 /* yes, we need 2 independent positions ... */
152 uint64_t seek_offset;
155 bool have_opendb_entry;
157 /* we need this hook back to our parent for lock destruction */
158 struct pvfs_state *pvfs;
160 /* have we set a sticky write time that we should remove on close */
161 bool sticky_write_time;
163 /* the open went through to completion */
167 /* open file state */
169 struct pvfs_file *next, *prev;
170 struct pvfs_file_handle *handle;
171 struct ntvfs_handle *ntvfs;
173 struct pvfs_state *pvfs;
175 uint32_t impersonation;
176 uint32_t share_access;
177 uint32_t access_mask;
179 /* a list of pending locks - used for locking cancel operations */
180 struct pvfs_pending_lock *pending_list;
182 /* a file handle to be used for byte range locking */
183 struct brl_handle *brl_handle;
185 /* a count of active locks - used to avoid calling brl_close on
189 /* for directories, a buffer of pending notify events */
190 struct pvfs_notify_buffer *notify_buffer;
192 /* for directories, the state of an incomplete SMB2 Find */
193 struct pvfs_search_state *search;
196 /* the state of a search started with pvfs_search_first() */
197 struct pvfs_search_state {
198 struct pvfs_search_state *prev, *next;
199 struct pvfs_state *pvfs;
202 uint16_t search_attrib;
203 uint16_t must_attrib;
204 struct pvfs_dir *dir;
207 struct ea_name *ea_names;
208 struct timed_event *te;
211 /* flags to pvfs_resolve_name() */
212 #define PVFS_RESOLVE_WILDCARD (1<<0)
213 #define PVFS_RESOLVE_STREAMS (1<<1)
215 /* flags in pvfs->flags */
216 #define PVFS_FLAG_CI_FILESYSTEM (1<<0) /* the filesystem is case insensitive */
217 #define PVFS_FLAG_MAP_ARCHIVE (1<<1)
218 #define PVFS_FLAG_MAP_SYSTEM (1<<2)
219 #define PVFS_FLAG_MAP_HIDDEN (1<<3)
220 #define PVFS_FLAG_READONLY (1<<4)
221 #define PVFS_FLAG_STRICT_SYNC (1<<5)
222 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
223 #define PVFS_FLAG_XATTR_ENABLE (1<<7)
224 #define PVFS_FLAG_FAKE_OPLOCKS (1<<8)
225 #define PVFS_FLAG_LINUX_AIO (1<<9)
227 /* forward declare some anonymous structures */
230 /* types of notification for pvfs wait events */
231 enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
233 #define PVFS_EADB "posix:eadb"
234 #define PVFS_XATTR "posix:xattr"
235 #define PVFS_FAKE_OPLOCKS "posix:fakeoplocks"
236 #define PVFS_SHARE_DELAY "posix:sharedelay"
237 #define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
238 #define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
239 #define PVFS_ACL "posix:acl"
240 #define PVFS_AIO "posix:aio"
242 #define PVFS_XATTR_DEFAULT true
243 #define PVFS_FAKE_OPLOCKS_DEFAULT false
244 #define PVFS_SHARE_DELAY_DEFAULT 1000000
245 #define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
246 #define PVFS_SEARCH_INACTIVITY_DEFAULT 300
248 struct pvfs_acl_ops {
250 NTSTATUS (*acl_load)(struct pvfs_state *, struct pvfs_filename *, int , TALLOC_CTX *,
251 struct security_descriptor **);
252 NTSTATUS (*acl_save)(struct pvfs_state *, struct pvfs_filename *, int , struct security_descriptor *);
255 #include "ntvfs/posix/vfs_posix_proto.h"
257 NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
258 struct pvfs_file *f, uint32_t maxcnt);
259 NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr,
260 struct pvfs_file *f);
262 #endif /* _VFS_POSIX_H_ */