s3: VFS: Modify mkdir to take a const struct smb_filename * instead of const char *
[samba.git] / source3 / modules / vfs_time_audit.c
index 45e30acfd17b398ebeb67058e1b5ceb2bb3a5698..8516c98390c56055f3ae481ecd0231b73d91c155 100644 (file)
@@ -178,15 +178,15 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
-                                   enum SMB_QUOTA_TYPE qtype, unid_t id,
-                                   SMB_DISK_QUOTA *qt)
+                                   const char *path, enum SMB_QUOTA_TYPE qtype,
+                                   unid_t id, SMB_DISK_QUOTA *qt)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
+       result = SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, qt);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
@@ -277,9 +277,78 @@ static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
        return result;
 }
 
+static NTSTATUS smb_time_audit_snap_check_path(struct vfs_handle_struct *handle,
+                                              TALLOC_CTX *mem_ctx,
+                                              const char *service_path,
+                                              char **base_volume)
+{
+       NTSTATUS status;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
+                                             base_volume);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log("snap_check_path", timediff);
+       }
+
+       return status;
+}
+
+static NTSTATUS smb_time_audit_snap_create(struct vfs_handle_struct *handle,
+                                          TALLOC_CTX *mem_ctx,
+                                          const char *base_volume,
+                                          time_t *tstamp,
+                                          bool rw,
+                                          char **base_path,
+                                          char **snap_path)
+{
+       NTSTATUS status;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
+                                         rw, base_path, snap_path);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2 ,&ts1) * 1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log("snap_create", timediff);
+       }
+
+       return status;
+}
+
+static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
+                                          TALLOC_CTX *mem_ctx,
+                                          char *base_path,
+                                          char *snap_path)
+{
+       NTSTATUS status;
+       struct timespec ts1,ts2;
+       double timediff;
+
+       clock_gettime_mono(&ts1);
+       status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
+                                         snap_path);
+       clock_gettime_mono(&ts2);
+       timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log("snap_delete", timediff);
+       }
+
+       return status;
+}
+
 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
-                                             const char *fname,
-                                             const char *mask, uint32 attr)
+                                  const char *fname,
+                                  const char *mask, uint32_t attr)
 {
        DIR *result;
        struct timespec ts1,ts2;
@@ -299,7 +368,7 @@ static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
 
 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
                                              files_struct *fsp,
-                                             const char *mask, uint32 attr)
+                                             const char *mask, uint32_t attr)
 {
        DIR *result;
        struct timespec ts1,ts2;
@@ -391,19 +460,22 @@ static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
-                               const char *path, mode_t mode)
+                               const struct smb_filename *smb_fname,
+                               mode_t mode)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
+       result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("mkdir", timediff, path);
+               smb_time_audit_log_smb_fname("mkdir",
+                       timediff,
+                       smb_fname);
        }
 
        return result;
@@ -1257,7 +1329,7 @@ static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
 
 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
                                       struct files_struct *fsp,
-                                      uint32 share_mode, uint32 access_mask)
+                                      uint32_t share_mode, uint32_t access_mask)
 {
        int result;
        struct timespec ts1,ts2;
@@ -1414,34 +1486,6 @@ static char *smb_time_audit_realpath(vfs_handle_struct *handle,
        return result;
 }
 
-static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
-                       struct sys_notify_context *ctx,
-                       const char *path,
-                       uint32_t *filter,
-                       uint32_t *subdir_filter,
-                       void (*callback)(struct sys_notify_context *ctx,
-                                       void *private_data,
-                                       struct notify_event *ev),
-                       void *private_data, void *handle_p)
-{
-       NTSTATUS result;
-       struct timespec ts1,ts2;
-       double timediff;
-
-       clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
-                                          filter, subdir_filter, callback,
-                                          private_data, handle_p);
-       clock_gettime_mono(&ts2);
-       timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
-
-       if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("notify_watch", timediff, path);
-       }
-
-       return result;
-}
-
 static int smb_time_audit_chflags(vfs_handle_struct *handle,
                                  const char *path, unsigned int flags)
 {
@@ -1832,7 +1876,7 @@ static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
 
 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
                                           files_struct *fsp,
-                                          uint32 security_info,
+                                          uint32_t security_info,
                                           TALLOC_CTX *mem_ctx,
                                           struct security_descriptor **ppdesc)
 {
@@ -1854,8 +1898,8 @@ static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
 }
 
 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
-                                         const char *name,
-                                         uint32 security_info,
+                                         const struct smb_filename *smb_fname,
+                                         uint32_t security_info,
                                          TALLOC_CTX *mem_ctx,
                                          struct security_descriptor **ppdesc)
 {
@@ -1864,13 +1908,15 @@ static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info,
+       result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
                                         mem_ctx, ppdesc);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("get_nt_acl", timediff, name);
+               smb_time_audit_log_fname("get_nt_acl",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;
@@ -1878,7 +1924,7 @@ static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
 
 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
                                           files_struct *fsp,
-                                          uint32 security_info_sent,
+                                          uint32_t security_info_sent,
                                           const struct security_descriptor *psd)
 {
        NTSTATUS result;
@@ -2383,6 +2429,9 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
        .statvfs_fn = smb_time_audit_statvfs,
        .fs_capabilities_fn = smb_time_audit_fs_capabilities,
+       .snap_check_path_fn = smb_time_audit_snap_check_path,
+       .snap_create_fn = smb_time_audit_snap_create,
+       .snap_delete_fn = smb_time_audit_snap_delete,
        .opendir_fn = smb_time_audit_opendir,
        .fdopendir_fn = smb_time_audit_fdopendir,
        .readdir_fn = smb_time_audit_readdir,
@@ -2435,7 +2484,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .link_fn = smb_time_audit_link,
        .mknod_fn = smb_time_audit_mknod,
        .realpath_fn = smb_time_audit_realpath,
-       .notify_watch_fn = smb_time_audit_notify_watch,
        .chflags_fn = smb_time_audit_chflags,
        .file_id_create_fn = smb_time_audit_file_id_create,
        .streaminfo_fn = smb_time_audit_streaminfo,