s3: Add strict lock/unlock calls to the vfs layer to replace is_locked
[ira/wip.git] / source3 / include / vfs.h
index 03b4b8e70623c3e7faa3d8d02261e17528e90ed0..0c0e0938bd823fbaee9b43a1461ad79f171b2dcc 100644 (file)
 /* Changed to version 24 - make security descriptor const in fset_nt_acl. JRA. */
 /* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */
 /* Leave at 25 - not yet released. Add create_file call. -- tprouty. */
+/* Leave at 25 - not yet released. Add create time to ntimes. -- tstecher. */
+/* Leave at 25 - not yet released. Add get_alloc_size call. -- tprouty. */
+/* Leave at 25 - not yet released. Add SMB_STRUCT_STAT to readdir. - sdann */
+/* Leave at 25 - not yet released. Add init_search_op call. - sdann */
+/* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */
+/* Leave at 25 - not yet released. Add strict locking calls. -- drichards. */
 
 #define SMB_VFS_INTERFACE_VERSION 25
 
@@ -137,17 +143,19 @@ struct security_descriptor;
 struct vfs_statvfs_struct;
 struct smb_request;
 struct ea_list;
+struct smb_file_time;
+struct blocking_lock_record;
 
 /*
     Available VFS operations. These values must be in sync with vfs_ops struct
-    (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops). 
+    (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops).
     In particular, if new operations are added to vfs_ops, appropriate constants
     should be added to vfs_op_type so that order of them kept same as in vfs_ops.
 */
 
 typedef enum _vfs_op_type {
        SMB_VFS_OP_NOOP = -1,
-       
+
        /* Disk operations */
 
        SMB_VFS_OP_CONNECT = 0,
@@ -169,6 +177,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_MKDIR,
        SMB_VFS_OP_RMDIR,
        SMB_VFS_OP_CLOSEDIR,
+       SMB_VFS_OP_INIT_SEARCH_OP,
 
        /* File operations */
 
@@ -187,6 +196,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_STAT,
        SMB_VFS_OP_FSTAT,
        SMB_VFS_OP_LSTAT,
+       SMB_VFS_OP_GET_ALLOC_SIZE,
        SMB_VFS_OP_UNLINK,
        SMB_VFS_OP_CHMOD,
        SMB_VFS_OP_FCHMOD,
@@ -210,6 +220,12 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_CHFLAGS,
        SMB_VFS_OP_FILE_ID_CREATE,
        SMB_VFS_OP_STREAMINFO,
+       SMB_VFS_OP_GET_REAL_FILENAME,
+       SMB_VFS_OP_BRL_LOCK_WINDOWS,
+       SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
+       SMB_VFS_OP_BRL_CANCEL_WINDOWS,
+       SMB_VFS_OP_STRICT_LOCK,
+       SMB_VFS_OP_STRICT_UNLOCK,
 
        /* NT ACL operations. */
 
@@ -244,7 +260,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_SYS_ACL_FREE_TEXT,
        SMB_VFS_OP_SYS_ACL_FREE_ACL,
        SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
-       
+
        /* EA operations. */
        SMB_VFS_OP_GETXATTR,
        SMB_VFS_OP_LGETXATTR,
@@ -298,13 +314,16 @@ struct vfs_ops {
                /* Directory operations */
 
                SMB_STRUCT_DIR *(*opendir)(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attributes);
-               SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
+               SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle,
+                                             SMB_STRUCT_DIR *dirp,
+                                             SMB_STRUCT_STAT *sbuf);
                void (*seekdir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset);
                long (*telldir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
                void (*rewind_dir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
                int (*mkdir)(struct vfs_handle_struct *handle, const char *path, mode_t mode);
                int (*rmdir)(struct vfs_handle_struct *handle, const char *path);
                int (*closedir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dir);
+               void (*init_search_op)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
 
                /* File operations */
 
@@ -313,6 +332,7 @@ struct vfs_ops {
                                        struct smb_request *req,
                                        uint16_t root_dir_fid,
                                        const char *fname,
+                                       uint32_t create_file_flags,
                                        uint32_t access_mask,
                                        uint32_t share_access,
                                        uint32_t create_disposition,
@@ -338,6 +358,7 @@ struct vfs_ops {
                int (*stat)(struct vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf);
                int (*fstat)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_STAT *sbuf);
                int (*lstat)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf);
+               uint64_t (*get_alloc_size)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_STAT *sbuf);
                int (*unlink)(struct vfs_handle_struct *handle, const char *path);
                int (*chmod)(struct vfs_handle_struct *handle, const char *path, mode_t mode);
                int (*fchmod)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
@@ -346,7 +367,7 @@ struct vfs_ops {
                int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
                int (*chdir)(struct vfs_handle_struct *handle, const char *path);
                char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
-               int (*ntimes)(struct vfs_handle_struct *handle, const char *path, const struct timespec ts[2]);
+               int (*ntimes)(struct vfs_handle_struct *handle, const char *path, struct smb_file_time *ft);
                int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset);
                bool (*lock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
                int (*kernel_flock)(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 share_mode);
@@ -365,7 +386,8 @@ struct vfs_ops {
                                                          struct notify_event *ev),
                                         void *private_data, void *handle_p);
                int (*chflags)(struct vfs_handle_struct *handle, const char *path, unsigned int flags);
-               struct file_id (*file_id_create)(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode);
+               struct file_id (*file_id_create)(struct vfs_handle_struct *handle,
+                                                const SMB_STRUCT_STAT *sbuf);
 
                NTSTATUS (*streaminfo)(struct vfs_handle_struct *handle,
                                       struct files_struct *fsp,
@@ -374,6 +396,36 @@ struct vfs_ops {
                                       unsigned int *num_streams,
                                       struct stream_struct **streams);
 
+               int (*get_real_filename)(struct vfs_handle_struct *handle,
+                                        const char *path,
+                                        const char *name,
+                                        TALLOC_CTX *mem_ctx,
+                                        char **found_name);
+
+               NTSTATUS (*brl_lock_windows)(struct vfs_handle_struct *handle,
+                                            struct byte_range_lock *br_lck,
+                                            struct lock_struct *plock,
+                                            bool blocking_lock,
+                                            struct blocking_lock_record *blr);
+
+               bool (*brl_unlock_windows)(struct vfs_handle_struct *handle,
+                                          struct messaging_context *msg_ctx,
+                                          struct byte_range_lock *br_lck,
+                                          const struct lock_struct *plock);
+
+               bool (*brl_cancel_windows)(struct vfs_handle_struct *handle,
+                                          struct byte_range_lock *br_lck,
+                                          struct lock_struct *plock,
+                                          struct blocking_lock_record *blr);
+
+               bool (*strict_lock)(struct vfs_handle_struct *handle,
+                                       struct files_struct *fsp,
+                                       struct lock_struct *plock);
+
+               void (*strict_unlock)(struct vfs_handle_struct *handle,
+                                       struct files_struct *fsp,
+                                       struct lock_struct *plock);
+
                /* NT ACL operations. */
 
                NTSTATUS (*fget_nt_acl)(struct vfs_handle_struct *handle,
@@ -468,6 +520,7 @@ struct vfs_ops {
                struct vfs_handle_struct *mkdir;
                struct vfs_handle_struct *rmdir;
                struct vfs_handle_struct *closedir;
+               struct vfs_handle_struct *init_search_op;
 
                /* File operations */
 
@@ -486,6 +539,7 @@ struct vfs_ops {
                struct vfs_handle_struct *stat;
                struct vfs_handle_struct *fstat;
                struct vfs_handle_struct *lstat;
+               struct vfs_handle_struct *get_alloc_size;
                struct vfs_handle_struct *unlink;
                struct vfs_handle_struct *chmod;
                struct vfs_handle_struct *fchmod;
@@ -509,6 +563,12 @@ struct vfs_ops {
                struct vfs_handle_struct *chflags;
                struct vfs_handle_struct *file_id_create;
                struct vfs_handle_struct *streaminfo;
+               struct vfs_handle_struct *get_real_filename;
+               struct vfs_handle_struct *brl_lock_windows;
+               struct vfs_handle_struct *brl_unlock_windows;
+               struct vfs_handle_struct *brl_cancel_windows;
+               struct vfs_handle_struct *strict_lock;
+               struct vfs_handle_struct *strict_unlock;
 
                /* NT ACL operations. */
 
@@ -664,8 +724,8 @@ typedef struct vfs_statvfs_struct {
 /* Add a new FSP extension of the given type. Returns a pointer to the
  * extenstion data.
  */
-#define VFS_ADD_FSP_EXTENSION(handle, fsp, type) \
-    vfs_add_fsp_extension_notype(handle, (fsp), sizeof(type))
+#define VFS_ADD_FSP_EXTENSION(handle, fsp, type, destroy_fn)           \
+    vfs_add_fsp_extension_notype(handle, (fsp), sizeof(type), (destroy_fn))
 
 /* Return a pointer to the existing FSP extension data. */
 #define VFS_FETCH_FSP_EXTENSION(handle, fsp) \