s3: smbd: Change open_streams_for_delete() to take a struct smb_filename *.
[samba.git] / source3 / modules / vfs_time_audit.c
index 8516c98390c56055f3ae481ecd0231b73d91c155..3bdc98b4fd695f339dab67b89025d83e455d5664 100644 (file)
@@ -347,7 +347,7 @@ static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
 }
 
 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
-                                  const char *fname,
+                                  const struct smb_filename *smb_fname,
                                   const char *mask, uint32_t attr)
 {
        DIR *result;
@@ -355,12 +355,12 @@ static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+       result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("opendir", timediff, fname);
+               smb_time_audit_log_smb_fname("opendir", timediff, smb_fname);
        }
 
        return result;
@@ -482,19 +482,21 @@ static int smb_time_audit_mkdir(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
-                               const char *path)
+                               const struct smb_filename *smb_fname)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_RMDIR(handle, path);
+       result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("rmdir", timediff, path);
+               smb_time_audit_log_smb_fname("rmdir",
+                       timediff,
+                       smb_fname);
        }
 
        return result;
@@ -674,9 +676,8 @@ static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
 
 struct smb_time_audit_pread_state {
        struct files_struct *fsp;
-       struct timespec ts1;
        ssize_t ret;
-       int err;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_time_audit_pread_done(struct tevent_req *subreq);
@@ -694,7 +695,6 @@ static struct tevent_req *smb_time_audit_pread_send(
        if (req == NULL) {
                return NULL;
        }
-       clock_gettime_mono(&state->ts1);
        state->fsp = fsp;
 
        subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
@@ -713,29 +713,28 @@ static void smb_time_audit_pread_done(struct tevent_req *subreq)
        struct smb_time_audit_pread_state *state = tevent_req_data(
                req, struct smb_time_audit_pread_state);
 
-       state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
+       state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        tevent_req_done(req);
 }
 
-static ssize_t smb_time_audit_pread_recv(struct tevent_req *req, int *err)
+static ssize_t smb_time_audit_pread_recv(struct tevent_req *req,
+                                        struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_time_audit_pread_state *state = tevent_req_data(
                req, struct smb_time_audit_pread_state);
-       struct timespec ts2;
        double timediff;
 
-       clock_gettime_mono(&ts2);
-       timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
+       timediff = state->vfs_aio_state.duration * 1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fsp("pread", timediff, state->fsp);
+               smb_time_audit_log_fsp("async pread", timediff, state->fsp);
        }
 
-       if (tevent_req_is_unix_error(req, err)) {
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
-       *err = state->err;
+       *vfs_aio_state = state->vfs_aio_state;
        return state->ret;
 }
 
@@ -782,9 +781,8 @@ static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
 
 struct smb_time_audit_pwrite_state {
        struct files_struct *fsp;
-       struct timespec ts1;
        ssize_t ret;
-       int err;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
@@ -802,7 +800,6 @@ static struct tevent_req *smb_time_audit_pwrite_send(
        if (req == NULL) {
                return NULL;
        }
-       clock_gettime_mono(&state->ts1);
        state->fsp = fsp;
 
        subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
@@ -821,29 +818,28 @@ static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
        struct smb_time_audit_pwrite_state *state = tevent_req_data(
                req, struct smb_time_audit_pwrite_state);
 
-       state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
+       state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        tevent_req_done(req);
 }
 
-static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req, int *err)
+static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
+                                         struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_time_audit_pwrite_state *state = tevent_req_data(
                req, struct smb_time_audit_pwrite_state);
-       struct timespec ts2;
        double timediff;
 
-       clock_gettime_mono(&ts2);
-       timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
+       timediff = state->vfs_aio_state.duration * 1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fsp("pwrite", timediff, state->fsp);
+               smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
        }
 
-       if (tevent_req_is_unix_error(req, err)) {
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
-       *err = state->err;
+       *vfs_aio_state = state->vfs_aio_state;
        return state->ret;
 }
 
@@ -949,9 +945,8 @@ static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
 
 struct smb_time_audit_fsync_state {
        struct files_struct *fsp;
-       struct timespec ts1;
        int ret;
-       int err;
+       struct vfs_aio_state vfs_aio_state;
 };
 
 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
@@ -968,7 +963,6 @@ static struct tevent_req *smb_time_audit_fsync_send(
        if (req == NULL) {
                return NULL;
        }
-       clock_gettime_mono(&state->ts1);
        state->fsp = fsp;
 
        subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
@@ -986,29 +980,28 @@ static void smb_time_audit_fsync_done(struct tevent_req *subreq)
        struct smb_time_audit_fsync_state *state = tevent_req_data(
                req, struct smb_time_audit_fsync_state);
 
-       state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->err);
+       state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
        TALLOC_FREE(subreq);
        tevent_req_done(req);
 }
 
-static int smb_time_audit_fsync_recv(struct tevent_req *req, int *err)
+static int smb_time_audit_fsync_recv(struct tevent_req *req,
+                                    struct vfs_aio_state *vfs_aio_state)
 {
        struct smb_time_audit_fsync_state *state = tevent_req_data(
                req, struct smb_time_audit_fsync_state);
-       struct timespec ts2;
        double timediff;
 
-       clock_gettime_mono(&ts2);
-       timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
+       timediff = state->vfs_aio_state.duration * 1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fsp("fsync", timediff, state->fsp);
+               smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
        }
 
-       if (tevent_req_is_unix_error(req, err)) {
+       if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
                return -1;
        }
-       *err = state->err;
+       *vfs_aio_state = state->vfs_aio_state;
        return state->ret;
 }
 
@@ -1109,19 +1102,22 @@ static int smb_time_audit_unlink(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_chmod(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_CHMOD(handle, path, mode);
+       result = SMB_VFS_NEXT_CHMOD(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("chmod", timediff, path);
+               smb_time_audit_log_fname("chmod",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;
@@ -1147,19 +1143,23 @@ static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static int smb_time_audit_chown(vfs_handle_struct *handle,
-                               const char *path, uid_t uid, gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
+       result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("chown", timediff, path);
+               smb_time_audit_log_fname("chown",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;
@@ -1185,19 +1185,23 @@ static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
 }
 
 static int smb_time_audit_lchown(vfs_handle_struct *handle,
-                                const char *path, uid_t uid, gid_t gid)
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
+       result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("lchown", timediff, path);
+               smb_time_audit_log_fname("lchown",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;
@@ -1529,7 +1533,7 @@ static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *ha
 
 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
                                          struct files_struct *fsp,
-                                         const char *fname,
+                                         const struct smb_filename *smb_fname,
                                          TALLOC_CTX *mem_ctx,
                                          unsigned int *pnum_streams,
                                          struct stream_struct **pstreams)
@@ -1539,7 +1543,7 @@ static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
+       result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
                                         pnum_streams, pstreams);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
@@ -1945,19 +1949,22 @@ static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_chmod_acl(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_CHMOD_ACL(handle, path, mode);
+       result = SMB_VFS_NEXT_CHMOD_ACL(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("chmod_acl", timediff, path);
+               smb_time_audit_log_fname("chmod_acl",
+                       timediff,
+                       smb_fname->base_name);
        }
 
        return result;