2004-09-08 07:59:52 +00:00
/*
Unix SMB / CIFS implementation .
2004-09-18 08:16:14 +00:00
POSIX NTVFS backend - structure definitions
2004-09-08 07:59:52 +00:00
Copyright ( C ) Andrew Tridgell 2004
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2004-09-08 07:59:52 +00:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2004-09-08 07:59:52 +00:00
*/
2004-09-18 08:16:14 +00:00
# ifndef _VFS_POSIX_H_
# define _VFS_POSIX_H_
2006-03-16 00:23:11 +00:00
# include "librpc/gen_ndr/xattr.h"
2005-02-10 05:09:35 +00:00
# include "system/filesys.h"
2005-12-27 22:51:30 +00:00
# include "ntvfs/ntvfs.h"
2007-01-19 11:58:03 +00:00
# include "ntvfs/common/ntvfs_common.h"
2008-03-28 23:29:01 +01:00
# include "libcli/wbclient/wbclient.h"
2009-01-29 18:39:30 -05:00
# include "lib/events/events.h"
2004-11-02 07:18:24 +00:00
2008-02-21 09:02:17 +01:00
struct pvfs_wait ;
2008-02-25 08:39:13 +01:00
struct pvfs_oplock ;
2008-02-21 09:02:17 +01:00
2004-09-08 07:59:52 +00:00
/* this is the private structure for the posix vfs backend. It is used
to hold per - connection ( per tree connect ) state information */
struct pvfs_state {
2006-03-15 17:28:46 +00:00
struct ntvfs_module_context * ntvfs ;
2004-09-08 07:59:52 +00:00
const char * base_directory ;
2005-12-02 14:53:56 +00:00
struct GUID * base_fs_uuid ;
2004-09-18 08:16:14 +00:00
2004-09-20 07:28:43 +00:00
const char * share_name ;
2010-01-05 09:42:54 -08:00
unsigned int flags ;
2004-09-18 08:16:14 +00:00
2004-10-12 05:10:43 +00:00
struct pvfs_mangle_context * mangle_ctx ;
2004-10-17 02:55:47 +00:00
2004-10-22 01:14:49 +00:00
struct brl_context * brl_context ;
2004-10-22 01:19:07 +00:00
struct odb_context * odb_context ;
2006-03-21 11:47:24 +00:00
struct notify_context * notify_context ;
2004-10-19 06:39:51 +00:00
2004-11-04 11:28:38 +00:00
/* a list of pending async requests. Needed to support
ntcancel */
struct pvfs_wait * wait_list ;
2004-11-04 13:27:29 +00:00
2008-02-25 19:17:45 +01:00
/* the sharing violation timeout (nsecs) */
2010-01-05 09:42:54 -08:00
unsigned int sharing_violation_delay ;
2004-11-17 06:30:06 +00:00
2008-02-25 19:17:45 +01:00
/* the oplock break timeout (secs) */
2010-01-05 09:42:54 -08:00
unsigned int oplock_break_timeout ;
2008-02-25 19:17:45 +01:00
2008-06-03 11:34:10 +02:00
/* the write time update delay (nsecs) */
2010-01-05 09:42:54 -08:00
unsigned int writetime_delay ;
2008-06-03 11:34:10 +02:00
2004-11-17 06:30:06 +00:00
/* filesystem attributes (see FS_ATTR_*) */
uint32_t fs_attribs ;
2004-12-17 03:39:29 +00:00
/* if posix:eadb is set, then this gets setup */
struct tdb_wrap * ea_db ;
2005-01-01 04:25:46 +00:00
2005-06-21 04:23:05 +00:00
/* the allocation size rounding */
uint32_t alloc_size_rounding ;
2005-07-18 03:35:52 +00:00
2006-03-18 10:38:38 +00:00
struct {
/* the open files as DLINKLIST */
struct pvfs_file * list ;
} files ;
struct {
/* an id tree mapping open search ID to a pvfs_search_state structure */
struct idr_context * idtree ;
/* the open searches as DLINKLIST */
struct pvfs_search_state * list ;
/* how long to keep inactive searches around for */
2010-01-05 09:42:54 -08:00
unsigned int inactivity_time ;
2006-03-18 10:38:38 +00:00
} search ;
2005-01-01 04:25:46 +00:00
/* used to accelerate acl mapping */
struct {
const struct dom_sid * creator_owner ;
const struct dom_sid * creator_group ;
} sid_cache ;
2006-10-09 11:13:49 +00:00
/* the acl backend */
const struct pvfs_acl_ops * acl_ops ;
2007-07-04 04:16:16 +00:00
/* non-flag share options */
struct {
mode_t dir_mask ;
mode_t force_dir_mode ;
mode_t create_mask ;
mode_t force_create_mode ;
} options ;
2004-09-20 07:28:43 +00:00
} ;
/* this is the basic information needed about a file from the filesystem */
struct pvfs_dos_fileinfo {
NTTIME create_time ;
NTTIME access_time ;
NTTIME write_time ;
NTTIME change_time ;
uint32_t attrib ;
uint64_t alloc_size ;
uint32_t nlink ;
uint32_t ea_size ;
uint64_t file_id ;
2004-11-24 06:09:14 +00:00
uint32_t flags ;
2004-09-18 08:16:14 +00:00
} ;
/*
this is the structure returned by pvfs_resolve_name ( ) . It holds the posix details of
a filename passed by the client to any function
*/
struct pvfs_filename {
2009-11-20 11:56:16 +01:00
char * original_name ;
2004-09-18 08:16:14 +00:00
char * full_name ;
2009-11-20 12:00:28 +01:00
char * stream_name ; /* does not include :$DATA suffix */
2004-11-17 05:58:04 +00:00
uint32_t stream_id ; /* this uses a hash, so is probabilistic */
2007-08-27 18:10:19 +00:00
bool has_wildcard ;
bool exists ; /* true if the base filename exists */
bool stream_exists ; /* true if the stream exists */
2011-12-01 13:40:49 +11:00
bool allow_override ;
2004-09-18 08:16:14 +00:00
struct stat st ;
2004-09-20 07:28:43 +00:00
struct pvfs_dos_fileinfo dos ;
2004-09-18 08:16:14 +00:00
} ;
2004-11-08 03:54:12 +00:00
/* open file handle state - encapsulates the posix fd
Note that this is separated from the pvfs_file structure in order
to cope with the openx DENY_DOS semantics where a 2 nd DENY_DOS open
on the same connection gets the same low level filesystem handle ,
rather than a new handle
*/
struct pvfs_file_handle {
int fd ;
struct pvfs_filename * name ;
2004-11-17 05:58:04 +00:00
/* a unique file key to be used for open file locking */
DATA_BLOB odb_locking_key ;
2004-11-08 03:54:12 +00:00
uint32_t create_options ;
/* this is set by the mode_information level. What does it do? */
uint32_t mode ;
/* yes, we need 2 independent positions ... */
uint64_t seek_offset ;
uint64_t position ;
2007-08-27 18:10:19 +00:00
bool have_opendb_entry ;
2004-11-08 03:54:12 +00:00
2008-02-25 08:39:13 +01:00
/*
* we need to wait for oplock break requests from other processes ,
* and we need to remember the pvfs_file so we can correctly
* forward the oplock break to the client
*/
struct pvfs_oplock * oplock ;
2004-11-08 03:54:12 +00:00
/* we need this hook back to our parent for lock destruction */
struct pvfs_state * pvfs ;
2004-11-24 06:09:14 +00:00
2008-04-15 16:00:42 +02:00
struct {
bool update_triggered ;
2008-12-29 20:24:57 +01:00
struct tevent_timer * update_event ;
2008-04-15 16:00:42 +02:00
bool update_on_close ;
NTTIME close_time ;
bool update_forced ;
} write_time ;
2007-05-20 08:01:02 +00:00
/* the open went through to completion */
2007-08-27 18:10:19 +00:00
bool open_completed ;
2010-03-05 14:57:50 +11:00
uint8_t private_flags ;
2004-11-08 03:54:12 +00:00
} ;
2004-10-26 00:59:06 +00:00
/* open file state */
2004-09-20 07:28:43 +00:00
struct pvfs_file {
struct pvfs_file * next , * prev ;
2004-11-08 03:54:12 +00:00
struct pvfs_file_handle * handle ;
2006-05-20 08:15:22 +00:00
struct ntvfs_handle * ntvfs ;
2004-11-08 03:54:12 +00:00
struct pvfs_state * pvfs ;
2004-09-26 11:30:20 +00:00
2004-11-08 11:35:49 +00:00
uint32_t impersonation ;
uint32_t share_access ;
uint32_t access_mask ;
2004-10-18 09:16:55 +00:00
/* a list of pending locks - used for locking cancel operations */
struct pvfs_pending_lock * pending_list ;
2004-10-19 06:39:51 +00:00
2006-05-15 12:22:00 +00:00
/* a file handle to be used for byte range locking */
struct brl_handle * brl_handle ;
2011-05-07 08:12:54 +02:00
/* a count of active locks - used to avoid calling brlock_close on
2004-10-19 06:39:51 +00:00
file close */
uint64_t lock_count ;
2006-03-21 11:47:24 +00:00
/* for directories, a buffer of pending notify events */
struct pvfs_notify_buffer * notify_buffer ;
2006-07-08 12:35:37 +00:00
/* for directories, the state of an incomplete SMB2 Find */
struct pvfs_search_state * search ;
2004-09-08 07:59:52 +00:00
} ;
2004-09-18 08:16:14 +00:00
2006-03-18 10:38:38 +00:00
/* the state of a search started with pvfs_search_first() */
struct pvfs_search_state {
struct pvfs_search_state * prev , * next ;
struct pvfs_state * pvfs ;
uint16_t handle ;
2006-09-10 07:24:41 +00:00
off_t current_index ;
2006-03-18 10:38:38 +00:00
uint16_t search_attrib ;
uint16_t must_attrib ;
struct pvfs_dir * dir ;
2010-09-10 20:46:10 +02:00
time_t last_used ; /* monotonic clock time */
2010-01-05 09:42:54 -08:00
unsigned int num_ea_names ;
2006-03-18 10:38:38 +00:00
struct ea_name * ea_names ;
2008-12-29 20:24:57 +01:00
struct tevent_timer * te ;
2006-03-18 10:38:38 +00:00
} ;
2004-10-18 09:16:55 +00:00
2004-09-18 08:16:14 +00:00
/* flags to pvfs_resolve_name() */
2004-11-15 06:57:26 +00:00
# define PVFS_RESOLVE_WILDCARD (1<<0)
2004-09-18 08:16:14 +00:00
# define PVFS_RESOLVE_STREAMS (1<<1)
2008-05-05 12:18:47 +02:00
# define PVFS_RESOLVE_NO_OPENDB (1<<2)
2004-09-18 08:16:14 +00:00
/* flags in pvfs->flags */
2004-10-17 02:55:47 +00:00
# define PVFS_FLAG_CI_FILESYSTEM (1<<0) /* the filesystem is case insensitive */
# define PVFS_FLAG_MAP_ARCHIVE (1<<1)
# define PVFS_FLAG_MAP_SYSTEM (1<<2)
# define PVFS_FLAG_MAP_HIDDEN (1<<3)
# define PVFS_FLAG_READONLY (1<<4)
# define PVFS_FLAG_STRICT_SYNC (1<<5)
# define PVFS_FLAG_STRICT_LOCKING (1<<6)
2004-11-05 07:29:02 +00:00
# define PVFS_FLAG_XATTR_ENABLE (1<<7)
2004-11-24 06:09:14 +00:00
# define PVFS_FLAG_FAKE_OPLOCKS (1<<8)
2007-01-09 04:04:26 +00:00
# define PVFS_FLAG_LINUX_AIO (1<<9)
2010-03-05 17:50:18 +11:00
# define PVFS_FLAG_PERM_OVERRIDE (1<<10)
2004-09-18 08:16:14 +00:00
2004-10-27 01:11:44 +00:00
/* forward declare some anonymous structures */
struct pvfs_dir ;
2004-11-05 02:22:07 +00:00
/* types of notification for pvfs wait events */
enum pvfs_wait_notice { PVFS_WAIT_EVENT , PVFS_WAIT_TIMEOUT , PVFS_WAIT_CANCEL } ;
2008-02-21 17:48:13 +01:00
/*
state of a pending retry
*/
struct pvfs_odb_retry ;
2006-07-23 18:43:07 +00:00
# define PVFS_EADB "posix:eadb"
# define PVFS_XATTR "posix:xattr"
# define PVFS_FAKE_OPLOCKS "posix:fakeoplocks"
# define PVFS_SHARE_DELAY "posix:sharedelay"
2008-02-25 19:17:45 +01:00
# define PVFS_OPLOCK_TIMEOUT "posix:oplocktimeout"
2008-06-03 11:34:10 +02:00
# define PVFS_WRITETIME_DELAY "posix:writetimeupdatedelay"
2006-07-23 18:43:07 +00:00
# define PVFS_ALLOCATION_ROUNDING "posix:allocationrounding"
# define PVFS_SEARCH_INACTIVITY "posix:searchinactivity"
2006-10-09 11:13:49 +00:00
# define PVFS_ACL "posix:acl"
2007-01-09 04:04:26 +00:00
# define PVFS_AIO "posix:aio"
2010-03-05 17:50:18 +11:00
# define PVFS_PERM_OVERRIDE "posix:permission override"
2006-07-23 18:43:07 +00:00
2007-10-06 22:28:14 +00:00
# define PVFS_XATTR_DEFAULT true
# define PVFS_FAKE_OPLOCKS_DEFAULT false
2008-02-25 19:17:45 +01:00
# define PVFS_SHARE_DELAY_DEFAULT 1000000 /* nsecs */
# define PVFS_OPLOCK_TIMEOUT_DEFAULT 30 /* secs */
2008-06-03 11:34:10 +02:00
# define PVFS_WRITETIME_DELAY_DEFAULT 2000000 /* nsecs */
2006-07-23 18:43:07 +00:00
# define PVFS_ALLOCATION_ROUNDING_DEFAULT 512
# define PVFS_SEARCH_INACTIVITY_DEFAULT 300
2006-10-09 11:13:49 +00:00
struct pvfs_acl_ops {
const char * name ;
NTSTATUS ( * acl_load ) ( struct pvfs_state * , struct pvfs_filename * , int , TALLOC_CTX * ,
struct security_descriptor * * ) ;
NTSTATUS ( * acl_save ) ( struct pvfs_state * , struct pvfs_filename * , int , struct security_descriptor * ) ;
} ;
2005-12-28 15:38:36 +00:00
# include "ntvfs/posix/vfs_posix_proto.h"
2008-06-28 10:28:15 +02:00
# include "ntvfs/posix/vfs_acl_proto.h"
2005-12-28 15:38:36 +00:00
2007-01-09 04:04:26 +00:00
NTSTATUS pvfs_aio_pread ( struct ntvfs_request * req , union smb_read * rd ,
struct pvfs_file * f , uint32_t maxcnt ) ;
2007-01-12 05:47:00 +00:00
NTSTATUS pvfs_aio_pwrite ( struct ntvfs_request * req , union smb_write * wr ,
struct pvfs_file * f ) ;
2007-01-09 04:04:26 +00:00
2004-09-18 08:16:14 +00:00
# endif /* _VFS_POSIX_H_ */