r14464: Don't include ndr_BASENAME.h files unless strictly required, instead
[kai/samba-autobuild/.git] / source4 / ntvfs / posix / vfs_posix.h
index 5b6685b753c7579dbc40e4be5823c3f55fa43ecc..71120965c2fcf5f2588d7c89f440dea21f0c621f 100644 (file)
 #ifndef _VFS_POSIX_H_
 #define _VFS_POSIX_H_
 
+#include "librpc/gen_ndr/xattr.h"
+#include "system/filesys.h"
+#include "smb_server/smb_server.h"
+#include "ntvfs/ntvfs.h"
+
 /* 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 {
-       struct smbsrv_tcon *tcon;
+       struct ntvfs_module_context *ntvfs;
        const char *base_directory;
+       struct GUID *base_fs_uuid;
 
        const char *share_name;
        uint_t flags;
@@ -38,14 +44,39 @@ struct pvfs_state {
 
        struct brl_context *brl_context;
        struct odb_context *odb_context;
+       struct sidmap_context *sidmap;
 
        /* an id tree mapping open search ID to a pvfs_search_state structure */
-       void *idtree_search;
+       struct idr_context *idtree_search;
 
        /* an id tree mapping open file handle -> struct pvfs_file */
-       void *idtree_fnum;
-};
+       struct idr_context *idtree_fnum;
+
+       /* a list of pending async requests. Needed to support
+          ntcancel */
+       struct pvfs_wait *wait_list;
+
+       /* the sharing violation timeout */
+       uint_t sharing_violation_delay;
+
+       /* filesystem attributes (see FS_ATTR_*) */
+       uint32_t fs_attribs;
+
+       /* if posix:eadb is set, then this gets setup */
+       struct tdb_wrap *ea_db;
 
+       /* the allocation size rounding */
+       uint32_t alloc_size_rounding;
+
+       /* how long to keep inactive searches around for */
+       uint_t search_inactivity_time;
+       
+       /* used to accelerate acl mapping */
+       struct {
+               const struct dom_sid *creator_owner;
+               const struct dom_sid *creator_group;            
+       } sid_cache;
+};
 
 /* this is the basic information needed about a file from the filesystem */
 struct pvfs_dos_fileinfo {
@@ -58,6 +89,7 @@ struct pvfs_dos_fileinfo {
        uint32_t nlink;
        uint32_t ea_size;
        uint64_t file_id;
+       uint32_t flags;
 };
 
 /*
@@ -67,39 +99,63 @@ struct pvfs_dos_fileinfo {
 struct pvfs_filename {
        const char *original_name;
        char *full_name;
-       const char *stream_name;
+       const char *stream_name; /* does not include :$DATA suffix */
+       uint32_t stream_id;      /* this uses a hash, so is probabilistic */
        BOOL has_wildcard;
-       BOOL exists;
+       BOOL exists;          /* true if the base filename exists */
+       BOOL stream_exists;   /* true if the stream exists */
        struct stat st;
        struct pvfs_dos_fileinfo dos;
 };
 
 
-/* this holds a list of file names for a search. We deliberately do
-   not hold the file stat information here to minimise the memory
-   overhead of idle searches */
-struct pvfs_dir {
-       uint_t count;
-       const char *unix_path;
-       const char **names;
-};
+/* open file handle state - encapsulates the posix fd
 
-/* the state of a search started with pvfs_search_first() */
-struct pvfs_search_state {
+   Note that this is separated from the pvfs_file structure in order
+   to cope with the openx DENY_DOS semantics where a 2nd 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;
+
+       /* a unique file key to be used for open file locking */
+       DATA_BLOB odb_locking_key;
+
+       /* a unique file key to be used for byte range locking */
+       DATA_BLOB brl_locking_key;
+
+       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;
+
+       BOOL have_opendb_entry;
+
+       /* we need this hook back to our parent for lock destruction */
        struct pvfs_state *pvfs;
-       uint16_t handle;
-       uint_t current_index;
-       uint16_t search_attrib;
-       struct pvfs_dir *dir;
+
+       /* have we set a sticky write time that we should remove on close */
+       BOOL sticky_write_time;
 };
 
-/* open file state - this is a temporary implementation
-   to allow some tests to work */
+/* open file state */
 struct pvfs_file {
        struct pvfs_file *next, *prev;
-       int fd;
+       struct pvfs_file_handle *handle;
        uint16_t fnum;
-       struct pvfs_filename *name;
+
+       struct pvfs_state *pvfs;
+
+       uint32_t impersonation;
+       uint32_t share_access;
+       uint32_t access_mask;
 
        /* we need to remember the session it was opened on,
           as it is illegal to operate on someone elses fnum */
@@ -109,12 +165,6 @@ struct pvfs_file {
           opened the file so SMBexit works */
        uint16_t smbpid;
 
-       /* a unique file key to be used for file locking */
-       DATA_BLOB locking_key;
-
-       /* we need this hook back to our parent for lock destruction */
-       struct pvfs_state *pvfs;
-
        /* a list of pending locks - used for locking cancel operations */
        struct pvfs_pending_lock *pending_list;
 
@@ -124,33 +174,8 @@ struct pvfs_file {
 };
 
 
-struct pvfs_mangle_context {
-       uint8_t char_flags[256];
-       /*
-         this determines how many characters are used from the original
-         filename in the 8.3 mangled name. A larger value leads to a weaker
-         hash and more collisions.  The largest possible value is 6.
-       */
-       int mangle_prefix;
-       uint32_t mangle_modulus;
-
-       /* we will use a very simple direct mapped prefix cache. The big
-          advantage of this cache structure is speed and low memory usage 
-
-          The cache is indexed by the low-order bits of the hash, and confirmed by
-          hashing the resulting cache entry to match the known hash
-       */
-       char **prefix_cache;
-       uint32_t *prefix_cache_hashes;
-
-       /* this is used to reverse the base 36 mapping */
-       unsigned char base_reverse[256];
-};
-
-
-
 /* flags to pvfs_resolve_name() */
-#define PVFS_RESOLVE_NO_WILDCARD (1<<0)
+#define PVFS_RESOLVE_WILDCARD    (1<<0)
 #define PVFS_RESOLVE_STREAMS     (1<<1)
 
 /* flags in pvfs->flags */
@@ -161,5 +186,15 @@ struct pvfs_mangle_context {
 #define PVFS_FLAG_READONLY       (1<<4)
 #define PVFS_FLAG_STRICT_SYNC    (1<<5)
 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
+#define PVFS_FLAG_XATTR_ENABLE   (1<<7)
+#define PVFS_FLAG_FAKE_OPLOCKS   (1<<8)
+
+/* forward declare some anonymous structures */
+struct pvfs_dir;
+
+/* types of notification for pvfs wait events */
+enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
+
+#include "ntvfs/posix/vfs_posix_proto.h"
 
 #endif /* _VFS_POSIX_H_ */