Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / ntvfs / posix / vfs_posix.h
index a788ddd19c10feb5d1ffda076643026e4c06cf45..b032ab3f931a9965ec232eae275513eb98a0e0d2 100644 (file)
@@ -7,7 +7,7 @@
 
    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
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #ifndef _VFS_POSIX_H_
 #include "librpc/gen_ndr/xattr.h"
 #include "system/filesys.h"
 #include "ntvfs/ntvfs.h"
-#include "ntvfs/common/proto.h"
-#include "dsdb/samdb/samdb.h"
+#include "ntvfs/common/ntvfs_common.h"
+#include "libcli/wbclient/wbclient.h"
+#include "lib/events/events.h"
+
+struct pvfs_wait;
+struct pvfs_oplock;
 
 /* this is the private structure for the posix vfs backend. It is used
    to hold per-connection (per tree connect) state information */
@@ -44,15 +47,21 @@ struct pvfs_state {
        struct brl_context *brl_context;
        struct odb_context *odb_context;
        struct notify_context *notify_context;
-       struct sidmap_context *sidmap;
+       struct wbc_context *wbc_ctx;
 
        /* a list of pending async requests. Needed to support
           ntcancel */
        struct pvfs_wait *wait_list;
 
-       /* the sharing violation timeout */
+       /* the sharing violation timeout (nsecs) */
        uint_t sharing_violation_delay;
 
+       /* the oplock break timeout (secs) */
+       uint_t oplock_break_timeout;
+
+       /* the write time update delay (nsecs) */
+       uint_t writetime_delay;
+
        /* filesystem attributes (see FS_ATTR_*) */
        uint32_t fs_attribs;
 
@@ -83,6 +92,17 @@ struct pvfs_state {
                const struct dom_sid *creator_owner;
                const struct dom_sid *creator_group;            
        } sid_cache;
+
+       /* the acl backend */
+       const struct pvfs_acl_ops *acl_ops;
+
+       /* non-flag share options */
+       struct {
+               mode_t dir_mask;
+               mode_t force_dir_mode;
+               mode_t create_mask;
+               mode_t force_create_mode;
+       } options;
 };
 
 /* this is the basic information needed about a file from the filesystem */
@@ -108,9 +128,9 @@ struct pvfs_filename {
        char *full_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;          /* true if the base filename exists */
-       BOOL stream_exists;   /* true if the stream exists */
+       bool has_wildcard;
+       bool exists;          /* true if the base filename exists */
+       bool stream_exists;   /* true if the stream exists */
        struct stat st;
        struct pvfs_dos_fileinfo dos;
 };
@@ -140,13 +160,28 @@ struct pvfs_file_handle {
        uint64_t seek_offset;
        uint64_t position;
 
-       BOOL have_opendb_entry;
+       bool have_opendb_entry;
+
+       /*
+        * 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;
 
        /* we need this hook back to our parent for lock destruction */
        struct pvfs_state *pvfs;
 
-       /* have we set a sticky write time that we should remove on close */
-       BOOL sticky_write_time;
+       struct {
+               bool update_triggered;
+               struct tevent_timer *update_event;
+               bool update_on_close;
+               NTTIME close_time;
+               bool update_forced;
+       } write_time;
+
+       /* the open went through to completion */
+       bool open_completed;
 };
 
 /* open file state */
@@ -183,19 +218,20 @@ struct pvfs_search_state {
        struct pvfs_search_state *prev, *next;
        struct pvfs_state *pvfs;
        uint16_t handle;
-       uint_t current_index;
+       off_t current_index;
        uint16_t search_attrib;
        uint16_t must_attrib;
        struct pvfs_dir *dir;
        time_t last_used;
        uint_t num_ea_names;
        struct ea_name *ea_names;
-       struct timed_event *te;
+       struct tevent_timer *te;
 };
 
 /* flags to pvfs_resolve_name() */
 #define PVFS_RESOLVE_WILDCARD    (1<<0)
 #define PVFS_RESOLVE_STREAMS     (1<<1)
+#define PVFS_RESOLVE_NO_OPENDB   (1<<2)
 
 /* flags in pvfs->flags */
 #define PVFS_FLAG_CI_FILESYSTEM  (1<<0) /* the filesystem is case insensitive */
@@ -207,6 +243,7 @@ struct pvfs_search_state {
 #define PVFS_FLAG_STRICT_LOCKING (1<<6)
 #define PVFS_FLAG_XATTR_ENABLE   (1<<7)
 #define PVFS_FLAG_FAKE_OPLOCKS   (1<<8)
+#define PVFS_FLAG_LINUX_AIO      (1<<9)
 
 /* forward declare some anonymous structures */
 struct pvfs_dir;
@@ -214,19 +251,43 @@ struct pvfs_dir;
 /* types of notification for pvfs wait events */
 enum pvfs_wait_notice {PVFS_WAIT_EVENT, PVFS_WAIT_TIMEOUT, PVFS_WAIT_CANCEL};
 
+/*
+  state of a pending retry
+*/
+struct pvfs_odb_retry;
+
 #define PVFS_EADB                      "posix:eadb"
 #define PVFS_XATTR                     "posix:xattr"
 #define PVFS_FAKE_OPLOCKS              "posix:fakeoplocks"
 #define PVFS_SHARE_DELAY               "posix:sharedelay"
+#define PVFS_OPLOCK_TIMEOUT            "posix:oplocktimeout"
+#define PVFS_WRITETIME_DELAY           "posix:writetimeupdatedelay"
 #define PVFS_ALLOCATION_ROUNDING       "posix:allocationrounding"
 #define PVFS_SEARCH_INACTIVITY         "posix:searchinactivity"
-
-#define PVFS_XATTR_DEFAULT                     True
-#define PVFS_FAKE_OPLOCKS_DEFAULT              False
-#define PVFS_SHARE_DELAY_DEFAULT               1000000
+#define PVFS_ACL                       "posix:acl"
+#define PVFS_AIO                       "posix:aio"
+
+#define PVFS_XATTR_DEFAULT                     true
+#define PVFS_FAKE_OPLOCKS_DEFAULT              false
+#define PVFS_SHARE_DELAY_DEFAULT               1000000 /* nsecs */
+#define PVFS_OPLOCK_TIMEOUT_DEFAULT            30 /* secs */
+#define PVFS_WRITETIME_DELAY_DEFAULT           2000000 /* nsecs */
 #define PVFS_ALLOCATION_ROUNDING_DEFAULT       512
 #define PVFS_SEARCH_INACTIVITY_DEFAULT         300
 
+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 *);
+};
+
 #include "ntvfs/posix/vfs_posix_proto.h"
+#include "ntvfs/posix/vfs_acl_proto.h"
+
+NTSTATUS pvfs_aio_pread(struct ntvfs_request *req, union smb_read *rd,
+                       struct pvfs_file *f, uint32_t maxcnt);
+NTSTATUS pvfs_aio_pwrite(struct ntvfs_request *req, union smb_write *wr,
+                        struct pvfs_file *f);
 
 #endif /* _VFS_POSIX_H_ */