s3: Plumb smb_filename through SMB_VFS_RENAME
[samba.git] / source3 / include / vfs.h
index 9b72f6932893b234f84fb4ce53f784716bfb0678..c3580da5d0fd0589eb9fad2f7a5a4e450cb310c4 100644 (file)
 /* Leave at 22 - not yet released. Remove parameter fd from close_fn. - obnox */
 /* Changed to version 23 - remove set_nt_acl call. This can only be done via an
    open handle. JRA. */
-
-#define SMB_VFS_INTERFACE_VERSION 23
+/* 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. */
+/* Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE,
+                          SMB_VFS_OPEN, SMB_VFS_STAT, SMB_VFS_LSTAT,
+                          SMB_VFS_RENAME.  */
+
+#define SMB_VFS_INTERFACE_VERSION 26
 
 
 /* to bug old modules which are trying to compile with the old functions */
@@ -132,17 +144,22 @@ struct connection_struct;
 struct files_struct;
 struct security_descriptor;
 struct vfs_statvfs_struct;
+struct smb_request;
+struct ea_list;
+struct smb_file_time;
+struct blocking_lock_record;
+struct smb_filename;
 
 /*
     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,
@@ -164,10 +181,12 @@ 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 */
 
        SMB_VFS_OP_OPEN,
+       SMB_VFS_OP_CREATE_FILE,
        SMB_VFS_OP_CLOSE,
        SMB_VFS_OP_READ,
        SMB_VFS_OP_PREAD,
@@ -181,6 +200,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,
@@ -204,6 +224,13 @@ 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_CONNECTPATH,
+       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. */
 
@@ -238,7 +265,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,
@@ -281,8 +308,8 @@ struct vfs_ops {
 
                int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
                void (*disconnect)(struct vfs_handle_struct *handle);
-               SMB_BIG_UINT (*disk_free)(struct vfs_handle_struct *handle, const char *path, bool small_query, SMB_BIG_UINT *bsize,
-                       SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
+               uint64_t (*disk_free)(struct vfs_handle_struct *handle, const char *path, bool small_query, uint64_t *bsize,
+                       uint64_t *dfree, uint64_t *dsize);
                int (*get_quota)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
                int (*set_quota)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
                int (*get_shadow_copy_data)(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels);
@@ -292,17 +319,37 @@ 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 */
 
-               int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
+               int (*open)(struct vfs_handle_struct *handle,
+                           struct smb_filename *smb_fname, files_struct *fsp,
+                           int flags, mode_t mode);
+               NTSTATUS (*create_file)(struct vfs_handle_struct *handle,
+                                       struct smb_request *req,
+                                       uint16_t root_dir_fid,
+                                       struct smb_filename *smb_fname,
+                                       uint32_t access_mask,
+                                       uint32_t share_access,
+                                       uint32_t create_disposition,
+                                       uint32_t create_options,
+                                       uint32_t file_attributes,
+                                       uint32_t oplock_request,
+                                       uint64_t allocation_size,
+                                       struct security_descriptor *sd,
+                                       struct ea_list *ea_list,
+                                       files_struct **result,
+                                       int *pinfo);
                int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
                ssize_t (*vfs_read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
                ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
@@ -311,11 +358,14 @@ struct vfs_ops {
                SMB_OFF_T (*lseek)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset, int whence);
                ssize_t (*sendfile)(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
                ssize_t (*recvfile)(struct vfs_handle_struct *handle, int fromfd, files_struct *tofsp, SMB_OFF_T offset, size_t count);
-               int (*rename)(struct vfs_handle_struct *handle, const char *oldname, const char *newname);
+               int (*rename)(struct vfs_handle_struct *handle,
+                             const struct smb_filename *smb_fname_src,
+                             const struct smb_filename *smb_fname_dst);
                int (*fsync)(struct vfs_handle_struct *handle, struct files_struct *fsp);
-               int (*stat)(struct vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf);
+               int (*stat)(struct vfs_handle_struct *handle, struct smb_filename *smb_fname);
                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);
+               int (*lstat)(struct vfs_handle_struct *handle, struct smb_filename *smb_filename);
+               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);
@@ -324,7 +374,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);
@@ -343,7 +393,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,
@@ -352,6 +403,39 @@ 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);
+
+               const char *(*connectpath)(struct vfs_handle_struct *handle,
+                                          const char *filename);
+
+               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,
@@ -365,7 +449,7 @@ struct vfs_ops {
                NTSTATUS (*fset_nt_acl)(struct vfs_handle_struct *handle,
                                        struct files_struct *fsp,
                                        uint32 security_info_sent,
-                                       struct security_descriptor *psd);
+                                       const struct security_descriptor *psd);
 
                /* POSIX ACL operations. */
 
@@ -446,10 +530,12 @@ 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 */
 
                struct vfs_handle_struct *open;
+               struct vfs_handle_struct *create_file;
                struct vfs_handle_struct *close_hnd;
                struct vfs_handle_struct *vfs_read;
                struct vfs_handle_struct *pread;
@@ -463,6 +549,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;
@@ -486,6 +573,13 @@ 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 *connectpath;
+               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. */
 
@@ -624,14 +718,14 @@ typedef struct vfs_statvfs_struct {
         if no distinction is made return the same value in each.
        */
 
-       SMB_BIG_UINT TotalBlocks;
-       SMB_BIG_UINT BlocksAvail;       /* bfree */
-       SMB_BIG_UINT UserBlocksAvail;   /* bavail */
+       uint64_t TotalBlocks;
+       uint64_t BlocksAvail;       /* bfree */
+       uint64_t UserBlocksAvail;   /* bavail */
 
        /* For undefined Node fields or FSID return -1 */
-       SMB_BIG_UINT TotalFileNodes;
-       SMB_BIG_UINT FreeFileNodes;
-       SMB_BIG_UINT FsIdentifier;   /* fsid */
+       uint64_t TotalFileNodes;
+       uint64_t FreeFileNodes;
+       uint64_t FsIdentifier;   /* fsid */
        /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
        /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call   */
 
@@ -641,8 +735,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) \