2 * Time auditing VFS module for samba. Log time taken for VFS call to syslog
5 * Copyright (C) Abhidnya Chirmule <achirmul@in.ibm.com> 2009
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 * This module implements logging for time taken for all Samba VFS operations.
24 * vfs objects = time_audit
29 #include "smbd/smbd.h"
31 #include "lib/util/tevent_unix.h"
32 #include "lib/util/tevent_ntstatus.h"
35 #define DBGC_CLASS DBGC_VFS
37 static double audit_timeout;
39 static void smb_time_audit_log_msg(const char *syscallname, double elapsed,
42 DEBUG(0, ("WARNING: VFS call \"%s\" took unexpectedly long "
43 "(%.2f seconds) %s%s-- Validate that file and storage "
44 "subsystems are operating normally\n", syscallname,
45 elapsed, (msg != NULL) ? msg : "",
46 (msg != NULL) ? " " : ""));
49 static void smb_time_audit_log(const char *syscallname, double elapsed)
51 smb_time_audit_log_msg(syscallname, elapsed, NULL);
54 static void smb_time_audit_log_fsp(const char *syscallname, double elapsed,
55 const struct files_struct *fsp)
57 char *base_name = NULL;
58 char *connectpath = NULL;
62 smb_time_audit_log(syscallname, elapsed);
66 connectpath = fsp->conn->connectpath;
68 base_name = fsp->fsp_name->base_name;
70 if (connectpath != NULL && base_name != NULL) {
71 msg = talloc_asprintf(talloc_tos(), "filename = \"%s/%s\"",
72 connectpath, base_name);
73 } else if (connectpath != NULL && base_name == NULL) {
74 msg = talloc_asprintf(talloc_tos(), "connectpath = \"%s\", "
77 } else if (connectpath == NULL && base_name != NULL) {
78 msg = talloc_asprintf(talloc_tos(), "connectpath = <NULL>, "
81 } else { /* connectpath == NULL && base_name == NULL */
82 msg = talloc_asprintf(talloc_tos(), "connectpath = <NULL>, "
83 "base_name = <NULL>");
85 smb_time_audit_log_msg(syscallname, elapsed, msg);
89 static void smb_time_audit_log_fname(const char *syscallname, double elapsed,
95 if (getcwd(cwd, sizeof(cwd)) == NULL) {
96 snprintf(cwd, sizeof(cwd), "<getcwd() error %d>", errno);
99 msg = talloc_asprintf(talloc_tos(),
100 "cwd = \"%s\", filename = \"%s\"",
103 msg = talloc_asprintf(talloc_tos(),
104 "cwd = \"%s\", filename = <NULL>",
107 smb_time_audit_log_msg(syscallname, elapsed, msg);
111 static void smb_time_audit_log_smb_fname(const char *syscallname, double elapsed,
112 const struct smb_filename *smb_fname)
114 if (smb_fname != NULL) {
115 smb_time_audit_log_fname(syscallname, elapsed,
116 smb_fname->base_name);
118 smb_time_audit_log_fname(syscallname, elapsed,
119 "smb_fname = <NULL>");
123 static int smb_time_audit_connect(vfs_handle_struct *handle,
124 const char *svc, const char *user)
127 struct timespec ts1,ts2;
134 clock_gettime_mono(&ts1);
135 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
136 clock_gettime_mono(&ts2);
137 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
138 if (timediff > audit_timeout) {
139 smb_time_audit_log_msg("connect", timediff, user);
144 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
146 struct timespec ts1,ts2;
149 clock_gettime_mono(&ts1);
150 SMB_VFS_NEXT_DISCONNECT(handle);
151 clock_gettime_mono(&ts2);
152 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
154 if (timediff > audit_timeout) {
155 smb_time_audit_log("disconnect", timediff);
159 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
160 const struct smb_filename *smb_fname,
166 struct timespec ts1,ts2;
169 clock_gettime_mono(&ts1);
170 result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
171 clock_gettime_mono(&ts2);
172 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
174 /* Don't have a reasonable notion of failure here */
175 if (timediff > audit_timeout) {
176 smb_time_audit_log_fname("disk_free",
178 smb_fname->base_name);
184 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
185 const struct smb_filename *smb_fname,
186 enum SMB_QUOTA_TYPE qtype,
191 struct timespec ts1,ts2;
194 clock_gettime_mono(&ts1);
195 result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
196 clock_gettime_mono(&ts2);
197 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
199 if (timediff > audit_timeout) {
200 smb_time_audit_log_fname("get_quota",
202 smb_fname->base_name);
207 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
208 enum SMB_QUOTA_TYPE qtype, unid_t id,
212 struct timespec ts1,ts2;
215 clock_gettime_mono(&ts1);
216 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
217 clock_gettime_mono(&ts2);
218 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
220 if (timediff > audit_timeout) {
221 smb_time_audit_log("set_quota", timediff);
227 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
228 struct files_struct *fsp,
229 struct shadow_copy_data *shadow_copy_data,
233 struct timespec ts1,ts2;
236 clock_gettime_mono(&ts1);
237 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
238 shadow_copy_data, labels);
239 clock_gettime_mono(&ts2);
240 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
242 if (timediff > audit_timeout) {
243 smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp);
249 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
250 const struct smb_filename *smb_fname,
251 struct vfs_statvfs_struct *statbuf)
254 struct timespec ts1,ts2;
257 clock_gettime_mono(&ts1);
258 result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
259 clock_gettime_mono(&ts2);
260 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
262 if (timediff > audit_timeout) {
263 smb_time_audit_log_fname("statvfs", timediff,
264 smb_fname->base_name);
270 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
271 enum timestamp_set_resolution *p_ts_res)
274 struct timespec ts1,ts2;
277 clock_gettime_mono(&ts1);
278 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
279 clock_gettime_mono(&ts2);
280 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
282 if (timediff > audit_timeout) {
283 smb_time_audit_log("fs_capabilities", timediff);
289 static NTSTATUS smb_time_audit_get_dfs_referrals(
290 struct vfs_handle_struct *handle,
291 struct dfs_GetDFSReferral *r)
294 struct timespec ts1,ts2;
297 clock_gettime_mono(&ts1);
298 result = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
299 clock_gettime_mono(&ts2);
300 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
302 if (timediff > audit_timeout) {
303 smb_time_audit_log("get_dfs_referrals(", timediff);
309 static NTSTATUS smb_time_audit_snap_check_path(struct vfs_handle_struct *handle,
311 const char *service_path,
315 struct timespec ts1,ts2;
318 clock_gettime_mono(&ts1);
319 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
321 clock_gettime_mono(&ts2);
322 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
324 if (timediff > audit_timeout) {
325 smb_time_audit_log("snap_check_path", timediff);
331 static NTSTATUS smb_time_audit_snap_create(struct vfs_handle_struct *handle,
333 const char *base_volume,
340 struct timespec ts1,ts2;
343 clock_gettime_mono(&ts1);
344 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
345 rw, base_path, snap_path);
346 clock_gettime_mono(&ts2);
347 timediff = nsec_time_diff(&ts2 ,&ts1) * 1.0e-9;
349 if (timediff > audit_timeout) {
350 smb_time_audit_log("snap_create", timediff);
356 static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
362 struct timespec ts1,ts2;
365 clock_gettime_mono(&ts1);
366 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
368 clock_gettime_mono(&ts2);
369 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
371 if (timediff > audit_timeout) {
372 smb_time_audit_log("snap_delete", timediff);
378 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
379 const struct smb_filename *smb_fname,
380 const char *mask, uint32_t attr)
383 struct timespec ts1,ts2;
386 clock_gettime_mono(&ts1);
387 result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
388 clock_gettime_mono(&ts2);
389 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
391 if (timediff > audit_timeout) {
392 smb_time_audit_log_smb_fname("opendir", timediff, smb_fname);
398 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
400 const char *mask, uint32_t attr)
403 struct timespec ts1,ts2;
406 clock_gettime_mono(&ts1);
407 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
408 clock_gettime_mono(&ts2);
409 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
411 if (timediff > audit_timeout) {
412 smb_time_audit_log_fsp("fdopendir", timediff, fsp);
418 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
420 SMB_STRUCT_STAT *sbuf)
422 struct dirent *result;
423 struct timespec ts1,ts2;
426 clock_gettime_mono(&ts1);
427 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
428 clock_gettime_mono(&ts2);
429 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
431 if (timediff > audit_timeout) {
432 smb_time_audit_log("readdir", timediff);
438 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
439 DIR *dirp, long offset)
441 struct timespec ts1,ts2;
444 clock_gettime_mono(&ts1);
445 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
446 clock_gettime_mono(&ts2);
447 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
449 if (timediff > audit_timeout) {
450 smb_time_audit_log("seekdir", timediff);
455 static long smb_time_audit_telldir(vfs_handle_struct *handle,
459 struct timespec ts1,ts2;
462 clock_gettime_mono(&ts1);
463 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
464 clock_gettime_mono(&ts2);
465 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
467 if (timediff > audit_timeout) {
468 smb_time_audit_log("telldir", timediff);
474 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
477 struct timespec ts1,ts2;
480 clock_gettime_mono(&ts1);
481 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
482 clock_gettime_mono(&ts2);
483 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
485 if (timediff > audit_timeout) {
486 smb_time_audit_log("rewinddir", timediff);
491 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
492 const struct smb_filename *smb_fname,
496 struct timespec ts1,ts2;
499 clock_gettime_mono(&ts1);
500 result = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
501 clock_gettime_mono(&ts2);
502 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
504 if (timediff > audit_timeout) {
505 smb_time_audit_log_smb_fname("mkdir",
513 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
514 const struct smb_filename *smb_fname)
517 struct timespec ts1,ts2;
520 clock_gettime_mono(&ts1);
521 result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
522 clock_gettime_mono(&ts2);
523 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
525 if (timediff > audit_timeout) {
526 smb_time_audit_log_smb_fname("rmdir",
534 static int smb_time_audit_closedir(vfs_handle_struct *handle,
538 struct timespec ts1,ts2;
541 clock_gettime_mono(&ts1);
542 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
543 clock_gettime_mono(&ts2);
544 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
546 if (timediff > audit_timeout) {
547 smb_time_audit_log("closedir", timediff);
553 static void smb_time_audit_init_search_op(vfs_handle_struct *handle,
556 struct timespec ts1,ts2;
559 clock_gettime_mono(&ts1);
560 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
561 clock_gettime_mono(&ts2);
562 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
564 if (timediff > audit_timeout) {
565 smb_time_audit_log("init_search_op", timediff);
569 static int smb_time_audit_open(vfs_handle_struct *handle,
570 struct smb_filename *fname,
572 int flags, mode_t mode)
575 struct timespec ts1,ts2;
578 clock_gettime_mono(&ts1);
579 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
580 clock_gettime_mono(&ts2);
581 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
583 if (timediff > audit_timeout) {
584 smb_time_audit_log_fsp("open", timediff, fsp);
590 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
591 struct smb_request *req,
592 uint16_t root_dir_fid,
593 struct smb_filename *fname,
594 uint32_t access_mask,
595 uint32_t share_access,
596 uint32_t create_disposition,
597 uint32_t create_options,
598 uint32_t file_attributes,
599 uint32_t oplock_request,
600 struct smb2_lease *lease,
601 uint64_t allocation_size,
602 uint32_t private_flags,
603 struct security_descriptor *sd,
604 struct ea_list *ea_list,
605 files_struct **result_fsp,
607 const struct smb2_create_blobs *in_context_blobs,
608 struct smb2_create_blobs *out_context_blobs)
611 struct timespec ts1,ts2;
614 clock_gettime_mono(&ts1);
615 result = SMB_VFS_NEXT_CREATE_FILE(
618 root_dir_fid, /* root_dir_fid */
620 access_mask, /* access_mask */
621 share_access, /* share_access */
622 create_disposition, /* create_disposition*/
623 create_options, /* create_options */
624 file_attributes, /* file_attributes */
625 oplock_request, /* oplock_request */
627 allocation_size, /* allocation_size */
630 ea_list, /* ea_list */
631 result_fsp, /* result */
633 in_context_blobs, out_context_blobs); /* create context */
634 clock_gettime_mono(&ts2);
635 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
637 if (timediff > audit_timeout) {
639 * can't use result_fsp this time, may have
640 * invalid content causing smbd crash
642 smb_time_audit_log_smb_fname("create_file", timediff,
649 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
652 struct timespec ts1,ts2;
655 clock_gettime_mono(&ts1);
656 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
657 clock_gettime_mono(&ts2);
658 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
660 if (timediff > audit_timeout) {
661 smb_time_audit_log_fsp("close", timediff, fsp);
667 static ssize_t smb_time_audit_read(vfs_handle_struct *handle,
668 files_struct *fsp, void *data, size_t n)
671 struct timespec ts1,ts2;
674 clock_gettime_mono(&ts1);
675 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
676 clock_gettime_mono(&ts2);
677 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
679 if (timediff > audit_timeout) {
680 smb_time_audit_log_fsp("read", timediff, fsp);
686 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
688 void *data, size_t n, off_t offset)
691 struct timespec ts1,ts2;
694 clock_gettime_mono(&ts1);
695 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
696 clock_gettime_mono(&ts2);
697 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
699 if (timediff > audit_timeout) {
700 smb_time_audit_log_fsp("pread", timediff, fsp);
706 struct smb_time_audit_pread_state {
707 struct files_struct *fsp;
709 struct vfs_aio_state vfs_aio_state;
712 static void smb_time_audit_pread_done(struct tevent_req *subreq);
714 static struct tevent_req *smb_time_audit_pread_send(
715 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
716 struct tevent_context *ev, struct files_struct *fsp,
717 void *data, size_t n, off_t offset)
719 struct tevent_req *req, *subreq;
720 struct smb_time_audit_pread_state *state;
722 req = tevent_req_create(mem_ctx, &state,
723 struct smb_time_audit_pread_state);
729 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
731 if (tevent_req_nomem(subreq, req)) {
732 return tevent_req_post(req, ev);
734 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
738 static void smb_time_audit_pread_done(struct tevent_req *subreq)
740 struct tevent_req *req = tevent_req_callback_data(
741 subreq, struct tevent_req);
742 struct smb_time_audit_pread_state *state = tevent_req_data(
743 req, struct smb_time_audit_pread_state);
745 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
747 tevent_req_done(req);
750 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req,
751 struct vfs_aio_state *vfs_aio_state)
753 struct smb_time_audit_pread_state *state = tevent_req_data(
754 req, struct smb_time_audit_pread_state);
757 timediff = state->vfs_aio_state.duration * 1.0e-9;
759 if (timediff > audit_timeout) {
760 smb_time_audit_log_fsp("async pread", timediff, state->fsp);
763 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
766 *vfs_aio_state = state->vfs_aio_state;
770 static ssize_t smb_time_audit_write(vfs_handle_struct *handle,
772 const void *data, size_t n)
775 struct timespec ts1,ts2;
778 clock_gettime_mono(&ts1);
779 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
780 clock_gettime_mono(&ts2);
781 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
783 if (timediff > audit_timeout) {
784 smb_time_audit_log_fsp("write", timediff, fsp);
790 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
792 const void *data, size_t n,
796 struct timespec ts1,ts2;
799 clock_gettime_mono(&ts1);
800 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
801 clock_gettime_mono(&ts2);
802 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
804 if (timediff > audit_timeout) {
805 smb_time_audit_log_fsp("pwrite", timediff, fsp);
811 struct smb_time_audit_pwrite_state {
812 struct files_struct *fsp;
814 struct vfs_aio_state vfs_aio_state;
817 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
819 static struct tevent_req *smb_time_audit_pwrite_send(
820 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
821 struct tevent_context *ev, struct files_struct *fsp,
822 const void *data, size_t n, off_t offset)
824 struct tevent_req *req, *subreq;
825 struct smb_time_audit_pwrite_state *state;
827 req = tevent_req_create(mem_ctx, &state,
828 struct smb_time_audit_pwrite_state);
834 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
836 if (tevent_req_nomem(subreq, req)) {
837 return tevent_req_post(req, ev);
839 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
843 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
845 struct tevent_req *req = tevent_req_callback_data(
846 subreq, struct tevent_req);
847 struct smb_time_audit_pwrite_state *state = tevent_req_data(
848 req, struct smb_time_audit_pwrite_state);
850 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
852 tevent_req_done(req);
855 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
856 struct vfs_aio_state *vfs_aio_state)
858 struct smb_time_audit_pwrite_state *state = tevent_req_data(
859 req, struct smb_time_audit_pwrite_state);
862 timediff = state->vfs_aio_state.duration * 1.0e-9;
864 if (timediff > audit_timeout) {
865 smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
868 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
871 *vfs_aio_state = state->vfs_aio_state;
875 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
877 off_t offset, int whence)
880 struct timespec ts1,ts2;
883 clock_gettime_mono(&ts1);
884 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
885 clock_gettime_mono(&ts2);
886 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
888 if (timediff > audit_timeout) {
889 smb_time_audit_log_fsp("lseek", timediff, fsp);
895 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
896 files_struct *fromfsp,
897 const DATA_BLOB *hdr, off_t offset,
901 struct timespec ts1,ts2;
904 clock_gettime_mono(&ts1);
905 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
906 clock_gettime_mono(&ts2);
907 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
909 if (timediff > audit_timeout) {
910 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
916 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
922 struct timespec ts1,ts2;
925 clock_gettime_mono(&ts1);
926 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
927 clock_gettime_mono(&ts2);
928 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
930 if (timediff > audit_timeout) {
931 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
937 static int smb_time_audit_rename(vfs_handle_struct *handle,
938 const struct smb_filename *oldname,
939 const struct smb_filename *newname)
942 struct timespec ts1,ts2;
945 clock_gettime_mono(&ts1);
946 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
947 clock_gettime_mono(&ts2);
948 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
950 if (timediff > audit_timeout) {
951 smb_time_audit_log_smb_fname("rename", timediff, newname);
957 static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
960 struct timespec ts1,ts2;
963 clock_gettime_mono(&ts1);
964 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
965 clock_gettime_mono(&ts2);
966 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
968 if (timediff > audit_timeout) {
969 smb_time_audit_log_fsp("fsync", timediff, fsp);
975 struct smb_time_audit_fsync_state {
976 struct files_struct *fsp;
978 struct vfs_aio_state vfs_aio_state;
981 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
983 static struct tevent_req *smb_time_audit_fsync_send(
984 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
985 struct tevent_context *ev, struct files_struct *fsp)
987 struct tevent_req *req, *subreq;
988 struct smb_time_audit_fsync_state *state;
990 req = tevent_req_create(mem_ctx, &state,
991 struct smb_time_audit_fsync_state);
997 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
998 if (tevent_req_nomem(subreq, req)) {
999 return tevent_req_post(req, ev);
1001 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
1005 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
1007 struct tevent_req *req = tevent_req_callback_data(
1008 subreq, struct tevent_req);
1009 struct smb_time_audit_fsync_state *state = tevent_req_data(
1010 req, struct smb_time_audit_fsync_state);
1012 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1013 TALLOC_FREE(subreq);
1014 tevent_req_done(req);
1017 static int smb_time_audit_fsync_recv(struct tevent_req *req,
1018 struct vfs_aio_state *vfs_aio_state)
1020 struct smb_time_audit_fsync_state *state = tevent_req_data(
1021 req, struct smb_time_audit_fsync_state);
1024 timediff = state->vfs_aio_state.duration * 1.0e-9;
1026 if (timediff > audit_timeout) {
1027 smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
1030 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1033 *vfs_aio_state = state->vfs_aio_state;
1037 static int smb_time_audit_stat(vfs_handle_struct *handle,
1038 struct smb_filename *fname)
1041 struct timespec ts1,ts2;
1044 clock_gettime_mono(&ts1);
1045 result = SMB_VFS_NEXT_STAT(handle, fname);
1046 clock_gettime_mono(&ts2);
1047 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1049 if (timediff > audit_timeout) {
1050 smb_time_audit_log_smb_fname("stat", timediff, fname);
1056 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1057 SMB_STRUCT_STAT *sbuf)
1060 struct timespec ts1,ts2;
1063 clock_gettime_mono(&ts1);
1064 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1065 clock_gettime_mono(&ts2);
1066 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1068 if (timediff > audit_timeout) {
1069 smb_time_audit_log_fsp("fstat", timediff, fsp);
1075 static int smb_time_audit_lstat(vfs_handle_struct *handle,
1076 struct smb_filename *path)
1079 struct timespec ts1,ts2;
1082 clock_gettime_mono(&ts1);
1083 result = SMB_VFS_NEXT_LSTAT(handle, path);
1084 clock_gettime_mono(&ts2);
1085 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1087 if (timediff > audit_timeout) {
1088 smb_time_audit_log_smb_fname("lstat", timediff, path);
1094 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
1096 const SMB_STRUCT_STAT *sbuf)
1099 struct timespec ts1,ts2;
1102 clock_gettime_mono(&ts1);
1103 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1104 clock_gettime_mono(&ts2);
1105 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1107 if (timediff > audit_timeout) {
1108 smb_time_audit_log_fsp("get_alloc_size", timediff, fsp);
1114 static int smb_time_audit_unlink(vfs_handle_struct *handle,
1115 const struct smb_filename *path)
1118 struct timespec ts1,ts2;
1121 clock_gettime_mono(&ts1);
1122 result = SMB_VFS_NEXT_UNLINK(handle, path);
1123 clock_gettime_mono(&ts2);
1124 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1126 if (timediff > audit_timeout) {
1127 smb_time_audit_log_smb_fname("unlink", timediff, path);
1133 static int smb_time_audit_chmod(vfs_handle_struct *handle,
1134 const struct smb_filename *smb_fname,
1138 struct timespec ts1,ts2;
1141 clock_gettime_mono(&ts1);
1142 result = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
1143 clock_gettime_mono(&ts2);
1144 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1146 if (timediff > audit_timeout) {
1147 smb_time_audit_log_fname("chmod",
1149 smb_fname->base_name);
1155 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1159 struct timespec ts1,ts2;
1162 clock_gettime_mono(&ts1);
1163 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1164 clock_gettime_mono(&ts2);
1165 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1167 if (timediff > audit_timeout) {
1168 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1174 static int smb_time_audit_chown(vfs_handle_struct *handle,
1175 const struct smb_filename *smb_fname,
1180 struct timespec ts1,ts2;
1183 clock_gettime_mono(&ts1);
1184 result = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
1185 clock_gettime_mono(&ts2);
1186 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1188 if (timediff > audit_timeout) {
1189 smb_time_audit_log_fname("chown",
1191 smb_fname->base_name);
1197 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1198 uid_t uid, gid_t gid)
1201 struct timespec ts1,ts2;
1204 clock_gettime_mono(&ts1);
1205 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1206 clock_gettime_mono(&ts2);
1207 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1209 if (timediff > audit_timeout) {
1210 smb_time_audit_log_fsp("fchown", timediff, fsp);
1216 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1217 const struct smb_filename *smb_fname,
1222 struct timespec ts1,ts2;
1225 clock_gettime_mono(&ts1);
1226 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1227 clock_gettime_mono(&ts2);
1228 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1230 if (timediff > audit_timeout) {
1231 smb_time_audit_log_fname("lchown",
1233 smb_fname->base_name);
1239 static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
1242 struct timespec ts1,ts2;
1245 clock_gettime_mono(&ts1);
1246 result = SMB_VFS_NEXT_CHDIR(handle, path);
1247 clock_gettime_mono(&ts2);
1248 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1250 if (timediff > audit_timeout) {
1251 smb_time_audit_log_fname("chdir", timediff, path);
1257 static char *smb_time_audit_getwd(vfs_handle_struct *handle)
1260 struct timespec ts1,ts2;
1263 clock_gettime_mono(&ts1);
1264 result = SMB_VFS_NEXT_GETWD(handle);
1265 clock_gettime_mono(&ts2);
1266 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1268 if (timediff > audit_timeout) {
1269 smb_time_audit_log("getwd", timediff);
1275 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
1276 const struct smb_filename *path,
1277 struct smb_file_time *ft)
1280 struct timespec ts1,ts2;
1283 clock_gettime_mono(&ts1);
1284 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
1285 clock_gettime_mono(&ts2);
1286 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1288 if (timediff > audit_timeout) {
1289 smb_time_audit_log_smb_fname("ntimes", timediff, path);
1295 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1300 struct timespec ts1,ts2;
1303 clock_gettime_mono(&ts1);
1304 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1305 clock_gettime_mono(&ts2);
1306 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1308 if (timediff > audit_timeout) {
1309 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1315 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1322 int saved_errno = 0;
1323 struct timespec ts1,ts2;
1326 clock_gettime_mono(&ts1);
1327 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1329 saved_errno = errno;
1331 clock_gettime_mono(&ts2);
1332 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1334 if (timediff > audit_timeout) {
1335 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1338 errno = saved_errno;
1343 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1344 int op, off_t offset, off_t count,
1348 struct timespec ts1,ts2;
1351 clock_gettime_mono(&ts1);
1352 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1353 clock_gettime_mono(&ts2);
1354 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1356 if (timediff > audit_timeout) {
1357 smb_time_audit_log_fsp("lock", timediff, fsp);
1363 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
1364 struct files_struct *fsp,
1365 uint32_t share_mode, uint32_t access_mask)
1368 struct timespec ts1,ts2;
1371 clock_gettime_mono(&ts1);
1372 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
1374 clock_gettime_mono(&ts2);
1375 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1377 if (timediff > audit_timeout) {
1378 smb_time_audit_log_fsp("kernel_flock", timediff, fsp);
1384 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1389 struct timespec ts1,ts2;
1392 clock_gettime_mono(&ts1);
1393 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1394 clock_gettime_mono(&ts2);
1395 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1397 if (timediff > audit_timeout) {
1398 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1404 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1406 off_t *poffset, off_t *pcount,
1407 int *ptype, pid_t *ppid)
1410 struct timespec ts1,ts2;
1413 clock_gettime_mono(&ts1);
1414 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1416 clock_gettime_mono(&ts2);
1417 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1419 if (timediff > audit_timeout) {
1420 smb_time_audit_log_fsp("getlock", timediff, fsp);
1426 static int smb_time_audit_symlink(vfs_handle_struct *handle,
1427 const char *link_contents,
1428 const struct smb_filename *new_smb_fname)
1431 struct timespec ts1,ts2;
1434 clock_gettime_mono(&ts1);
1435 result = SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
1436 clock_gettime_mono(&ts2);
1437 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1439 if (timediff > audit_timeout) {
1440 smb_time_audit_log_fname("symlink", timediff,
1441 new_smb_fname->base_name);
1447 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1448 const struct smb_filename *smb_fname,
1453 struct timespec ts1,ts2;
1456 clock_gettime_mono(&ts1);
1457 result = SMB_VFS_NEXT_READLINK(handle, smb_fname,
1459 clock_gettime_mono(&ts2);
1460 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1462 if (timediff > audit_timeout) {
1463 smb_time_audit_log_fname("readlink", timediff,
1464 smb_fname->base_name);
1470 static int smb_time_audit_link(vfs_handle_struct *handle,
1471 const struct smb_filename *old_smb_fname,
1472 const struct smb_filename *new_smb_fname)
1475 struct timespec ts1,ts2;
1478 clock_gettime_mono(&ts1);
1479 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1480 clock_gettime_mono(&ts2);
1481 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1483 if (timediff > audit_timeout) {
1484 smb_time_audit_log_fname("link", timediff,
1485 new_smb_fname->base_name);
1491 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1492 const struct smb_filename *smb_fname,
1497 struct timespec ts1,ts2;
1500 clock_gettime_mono(&ts1);
1501 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1502 clock_gettime_mono(&ts2);
1503 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1505 if (timediff > audit_timeout) {
1506 smb_time_audit_log_smb_fname("mknod", timediff, smb_fname);
1512 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1516 struct timespec ts1,ts2;
1519 clock_gettime_mono(&ts1);
1520 result = SMB_VFS_NEXT_REALPATH(handle, path);
1521 clock_gettime_mono(&ts2);
1522 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1524 if (timediff > audit_timeout) {
1525 smb_time_audit_log_fname("realpath", timediff, path);
1531 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1532 const struct smb_filename *smb_fname,
1536 struct timespec ts1,ts2;
1539 clock_gettime_mono(&ts1);
1540 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1541 clock_gettime_mono(&ts2);
1542 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1544 if (timediff > audit_timeout) {
1545 smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
1551 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1552 const SMB_STRUCT_STAT *sbuf)
1554 struct file_id id_zero;
1555 struct file_id result;
1556 struct timespec ts1,ts2;
1559 ZERO_STRUCT(id_zero);
1561 clock_gettime_mono(&ts1);
1562 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1563 clock_gettime_mono(&ts2);
1564 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1566 if (timediff > audit_timeout) {
1567 smb_time_audit_log("file_id_create", timediff);
1573 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1574 struct files_struct *fsp,
1575 const struct smb_filename *smb_fname,
1576 TALLOC_CTX *mem_ctx,
1577 unsigned int *pnum_streams,
1578 struct stream_struct **pstreams)
1581 struct timespec ts1,ts2;
1584 clock_gettime_mono(&ts1);
1585 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1586 pnum_streams, pstreams);
1587 clock_gettime_mono(&ts2);
1588 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1590 if (timediff > audit_timeout) {
1591 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1597 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1600 TALLOC_CTX *mem_ctx,
1604 struct timespec ts1,ts2;
1607 clock_gettime_mono(&ts1);
1608 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1610 clock_gettime_mono(&ts2);
1611 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1613 if (timediff > audit_timeout) {
1614 smb_time_audit_log_fname("get_real_filename", timediff, path);
1620 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1624 struct timespec ts1,ts2;
1627 clock_gettime_mono(&ts1);
1628 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1629 clock_gettime_mono(&ts2);
1630 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1632 if (timediff > audit_timeout) {
1633 smb_time_audit_log_fname("connectpath", timediff, fname);
1639 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1640 struct byte_range_lock *br_lck,
1641 struct lock_struct *plock,
1645 struct timespec ts1,ts2;
1648 clock_gettime_mono(&ts1);
1649 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1651 clock_gettime_mono(&ts2);
1652 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1654 if (timediff > audit_timeout) {
1655 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1662 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1663 struct messaging_context *msg_ctx,
1664 struct byte_range_lock *br_lck,
1665 const struct lock_struct *plock)
1668 struct timespec ts1,ts2;
1671 clock_gettime_mono(&ts1);
1672 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1674 clock_gettime_mono(&ts2);
1675 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1677 if (timediff > audit_timeout) {
1678 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1685 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1686 struct byte_range_lock *br_lck,
1687 struct lock_struct *plock)
1690 struct timespec ts1,ts2;
1693 clock_gettime_mono(&ts1);
1694 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1695 clock_gettime_mono(&ts2);
1696 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1698 if (timediff > audit_timeout) {
1699 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1706 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1707 struct files_struct *fsp,
1708 struct lock_struct *plock)
1711 struct timespec ts1,ts2;
1714 clock_gettime_mono(&ts1);
1715 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1716 clock_gettime_mono(&ts2);
1717 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1719 if (timediff > audit_timeout) {
1720 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1726 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1727 struct files_struct *fsp,
1728 struct lock_struct *plock)
1730 struct timespec ts1,ts2;
1733 clock_gettime_mono(&ts1);
1734 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1735 clock_gettime_mono(&ts2);
1736 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1738 if (timediff > audit_timeout) {
1739 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1743 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1745 enum vfs_translate_direction direction,
1746 TALLOC_CTX *mem_ctx,
1750 struct timespec ts1,ts2;
1753 clock_gettime_mono(&ts1);
1754 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1756 clock_gettime_mono(&ts2);
1757 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1759 if (timediff > audit_timeout) {
1760 smb_time_audit_log_fname("translate_name", timediff, name);
1766 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1767 struct files_struct *fsp,
1771 const uint8_t *_in_data,
1773 uint8_t **_out_data,
1774 uint32_t max_out_len,
1778 struct timespec ts1,ts2;
1781 clock_gettime_mono(&ts1);
1782 result = SMB_VFS_NEXT_FSCTL(handle,
1792 clock_gettime_mono(&ts2);
1793 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1795 if (timediff > audit_timeout) {
1796 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1802 static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
1803 struct smb_filename *smb_fname,
1807 struct timespec ts1,ts2;
1810 clock_gettime_mono(&ts1);
1811 result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1814 clock_gettime_mono(&ts2);
1815 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1817 if (timediff > audit_timeout) {
1818 smb_time_audit_log_fname("get_dos_attributes",
1820 smb_fname->base_name);
1826 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1827 struct files_struct *fsp,
1831 struct timespec ts1,ts2;
1834 clock_gettime_mono(&ts1);
1835 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1838 clock_gettime_mono(&ts2);
1839 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1841 if (timediff > audit_timeout) {
1842 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
1848 static NTSTATUS smb_time_set_dos_attributes(struct vfs_handle_struct *handle,
1849 const struct smb_filename *smb_fname,
1853 struct timespec ts1,ts2;
1856 clock_gettime_mono(&ts1);
1857 result = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
1860 clock_gettime_mono(&ts2);
1861 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1863 if (timediff > audit_timeout) {
1864 smb_time_audit_log_fname("set_dos_attributes",
1866 smb_fname->base_name);
1872 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
1873 struct files_struct *fsp,
1877 struct timespec ts1,ts2;
1880 clock_gettime_mono(&ts1);
1881 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
1884 clock_gettime_mono(&ts2);
1885 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1887 if (timediff > audit_timeout) {
1888 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
1894 struct time_audit_cc_state {
1895 struct timespec ts_send;
1896 struct vfs_handle_struct *handle;
1899 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1901 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1902 TALLOC_CTX *mem_ctx,
1903 struct tevent_context *ev,
1904 struct files_struct *src_fsp,
1906 struct files_struct *dest_fsp,
1911 struct tevent_req *req;
1912 struct tevent_req *subreq;
1913 struct time_audit_cc_state *cc_state;
1915 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1920 cc_state->handle = handle;
1921 clock_gettime_mono(&cc_state->ts_send);
1922 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1924 dest_fsp, dest_off, num, flags);
1925 if (tevent_req_nomem(subreq, req)) {
1926 return tevent_req_post(req, ev);
1929 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1933 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1935 struct tevent_req *req = tevent_req_callback_data(
1936 subreq, struct tevent_req);
1937 struct time_audit_cc_state *cc_state
1938 = tevent_req_data(req, struct time_audit_cc_state);
1941 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1944 TALLOC_FREE(subreq);
1945 if (tevent_req_nterror(req, status)) {
1948 tevent_req_done(req);
1951 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1952 struct tevent_req *req,
1955 struct time_audit_cc_state *cc_state
1956 = tevent_req_data(req, struct time_audit_cc_state);
1957 struct timespec ts_recv;
1961 clock_gettime_mono(&ts_recv);
1962 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1963 if (timediff > audit_timeout) {
1964 smb_time_audit_log("copy_chunk", timediff);
1967 *copied = cc_state->copied;
1968 if (tevent_req_is_nterror(req, &status)) {
1969 tevent_req_received(req);
1973 tevent_req_received(req);
1974 return NT_STATUS_OK;
1977 static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
1978 TALLOC_CTX *mem_ctx,
1979 struct files_struct *fsp,
1980 struct smb_filename *smb_fname,
1981 uint16_t *_compression_fmt)
1984 struct timespec ts1,ts2;
1987 clock_gettime_mono(&ts1);
1988 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1990 clock_gettime_mono(&ts2);
1991 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1993 if (timediff > audit_timeout) {
1995 smb_time_audit_log_fsp("get_compression",
1998 smb_time_audit_log_smb_fname("get_compression",
1999 timediff, smb_fname);
2006 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2007 TALLOC_CTX *mem_ctx,
2008 struct files_struct *fsp,
2009 uint16_t compression_fmt)
2012 struct timespec ts1,ts2;
2015 clock_gettime_mono(&ts1);
2016 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2018 clock_gettime_mono(&ts2);
2019 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2021 if (timediff > audit_timeout) {
2022 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2028 static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
2029 const struct smb_filename *fname,
2030 TALLOC_CTX *mem_ctx,
2031 struct readdir_attr_data **pattr_data)
2034 struct timespec ts1,ts2;
2037 clock_gettime_mono(&ts1);
2038 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2039 clock_gettime_mono(&ts2);
2040 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2042 if (timediff > audit_timeout) {
2043 smb_time_audit_log_smb_fname("readdir_attr", timediff, fname);
2049 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2051 uint32_t security_info,
2052 TALLOC_CTX *mem_ctx,
2053 struct security_descriptor **ppdesc)
2056 struct timespec ts1,ts2;
2059 clock_gettime_mono(&ts1);
2060 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2062 clock_gettime_mono(&ts2);
2063 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2065 if (timediff > audit_timeout) {
2066 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2072 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
2073 const struct smb_filename *smb_fname,
2074 uint32_t security_info,
2075 TALLOC_CTX *mem_ctx,
2076 struct security_descriptor **ppdesc)
2079 struct timespec ts1,ts2;
2082 clock_gettime_mono(&ts1);
2083 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2085 clock_gettime_mono(&ts2);
2086 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2088 if (timediff > audit_timeout) {
2089 smb_time_audit_log_fname("get_nt_acl",
2091 smb_fname->base_name);
2097 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2099 uint32_t security_info_sent,
2100 const struct security_descriptor *psd)
2103 struct timespec ts1,ts2;
2106 clock_gettime_mono(&ts1);
2107 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2109 clock_gettime_mono(&ts2);
2110 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2112 if (timediff > audit_timeout) {
2113 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2119 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2120 struct smb_filename *smb_fname,
2121 struct security_acl *sacl,
2122 uint32_t access_requested,
2123 uint32_t access_denied)
2126 struct timespec ts1,ts2;
2129 clock_gettime_mono(&ts1);
2130 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2135 clock_gettime_mono(&ts2);
2136 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2138 if (timediff > audit_timeout) {
2139 smb_time_audit_log_fname("audit_file",
2141 smb_fname->base_name);
2149 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
2150 const struct smb_filename *smb_fname,
2154 struct timespec ts1,ts2;
2157 clock_gettime_mono(&ts1);
2158 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2159 clock_gettime_mono(&ts2);
2160 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2162 if (timediff > audit_timeout) {
2163 smb_time_audit_log_fname("chmod_acl",
2165 smb_fname->base_name);
2171 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
2172 files_struct *fsp, mode_t mode)
2175 struct timespec ts1,ts2;
2178 clock_gettime_mono(&ts1);
2179 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2180 clock_gettime_mono(&ts2);
2181 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2183 if (timediff > audit_timeout) {
2184 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
2190 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
2191 const struct smb_filename *smb_fname,
2192 SMB_ACL_TYPE_T type,
2193 TALLOC_CTX *mem_ctx)
2196 struct timespec ts1,ts2;
2199 clock_gettime_mono(&ts1);
2200 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2202 clock_gettime_mono(&ts2);
2203 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2205 if (timediff > audit_timeout) {
2206 smb_time_audit_log_fname("sys_acl_get_file", timediff,
2207 smb_fname->base_name);
2213 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2215 TALLOC_CTX *mem_ctx)
2218 struct timespec ts1,ts2;
2221 clock_gettime_mono(&ts1);
2222 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2223 clock_gettime_mono(&ts2);
2224 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2226 if (timediff > audit_timeout) {
2227 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2234 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2235 const struct smb_filename *smb_fname,
2236 TALLOC_CTX *mem_ctx,
2237 char **blob_description,
2241 struct timespec ts1,ts2;
2244 clock_gettime_mono(&ts1);
2245 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2246 mem_ctx, blob_description, blob);
2247 clock_gettime_mono(&ts2);
2248 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2250 if (timediff > audit_timeout) {
2251 smb_time_audit_log("sys_acl_blob_get_file", timediff);
2257 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2259 TALLOC_CTX *mem_ctx,
2260 char **blob_description,
2264 struct timespec ts1,ts2;
2267 clock_gettime_mono(&ts1);
2268 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2269 clock_gettime_mono(&ts2);
2270 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2272 if (timediff > audit_timeout) {
2273 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2279 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
2280 const struct smb_filename *smb_fname,
2281 SMB_ACL_TYPE_T acltype,
2285 struct timespec ts1,ts2;
2288 clock_gettime_mono(&ts1);
2289 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2291 clock_gettime_mono(&ts2);
2292 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2294 if (timediff > audit_timeout) {
2295 smb_time_audit_log_fname("sys_acl_set_file", timediff,
2296 smb_fname->base_name);
2302 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2307 struct timespec ts1,ts2;
2310 clock_gettime_mono(&ts1);
2311 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2312 clock_gettime_mono(&ts2);
2313 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2315 if (timediff > audit_timeout) {
2316 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2322 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2323 const struct smb_filename *smb_fname)
2326 struct timespec ts1,ts2;
2329 clock_gettime_mono(&ts1);
2330 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2331 clock_gettime_mono(&ts2);
2332 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2334 if (timediff > audit_timeout) {
2335 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff,
2336 smb_fname->base_name);
2342 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2343 const struct smb_filename *smb_fname,
2349 struct timespec ts1,ts2;
2352 clock_gettime_mono(&ts1);
2353 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2354 clock_gettime_mono(&ts2);
2355 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2357 if (timediff > audit_timeout) {
2358 smb_time_audit_log_fname("getxattr", timediff,
2359 smb_fname->base_name);
2365 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2366 struct files_struct *fsp,
2367 const char *name, void *value,
2371 struct timespec ts1,ts2;
2374 clock_gettime_mono(&ts1);
2375 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2376 clock_gettime_mono(&ts2);
2377 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2379 if (timediff > audit_timeout) {
2380 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2386 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2387 const struct smb_filename *smb_fname,
2392 struct timespec ts1,ts2;
2395 clock_gettime_mono(&ts1);
2396 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2397 clock_gettime_mono(&ts2);
2398 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2400 if (timediff > audit_timeout) {
2401 smb_time_audit_log_fname("listxattr", timediff,
2402 smb_fname->base_name);
2408 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2409 struct files_struct *fsp, char *list,
2413 struct timespec ts1,ts2;
2416 clock_gettime_mono(&ts1);
2417 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2418 clock_gettime_mono(&ts2);
2419 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2421 if (timediff > audit_timeout) {
2422 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2428 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2429 const struct smb_filename *smb_fname,
2433 struct timespec ts1,ts2;
2436 clock_gettime_mono(&ts1);
2437 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2438 clock_gettime_mono(&ts2);
2439 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2441 if (timediff > audit_timeout) {
2442 smb_time_audit_log_fname("removexattr", timediff,
2443 smb_fname->base_name);
2449 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2450 struct files_struct *fsp,
2454 struct timespec ts1,ts2;
2457 clock_gettime_mono(&ts1);
2458 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2459 clock_gettime_mono(&ts2);
2460 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2462 if (timediff > audit_timeout) {
2463 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2469 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2470 const struct smb_filename *smb_fname,
2477 struct timespec ts1,ts2;
2480 clock_gettime_mono(&ts1);
2481 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2483 clock_gettime_mono(&ts2);
2484 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2486 if (timediff > audit_timeout) {
2487 smb_time_audit_log_fname("setxattr", timediff,
2488 smb_fname->base_name);
2494 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2495 struct files_struct *fsp, const char *name,
2496 const void *value, size_t size, int flags)
2499 struct timespec ts1,ts2;
2502 clock_gettime_mono(&ts1);
2503 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2504 clock_gettime_mono(&ts2);
2505 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2507 if (timediff > audit_timeout) {
2508 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2514 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2515 struct files_struct *fsp)
2518 struct timespec ts1,ts2;
2521 clock_gettime_mono(&ts1);
2522 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2523 clock_gettime_mono(&ts2);
2524 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2526 if (timediff > audit_timeout) {
2527 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2533 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2534 struct files_struct *fsp,
2535 TALLOC_CTX *mem_ctx,
2539 struct timespec ts1,ts2;
2542 clock_gettime_mono(&ts1);
2543 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2544 clock_gettime_mono(&ts2);
2545 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2547 if (timediff > audit_timeout) {
2548 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2554 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2555 struct files_struct *fsp,
2556 const DATA_BLOB old_cookie,
2557 TALLOC_CTX *mem_ctx,
2558 DATA_BLOB *new_cookie)
2561 struct timespec ts1,ts2;
2564 clock_gettime_mono(&ts1);
2565 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2566 mem_ctx, new_cookie);
2567 clock_gettime_mono(&ts2);
2568 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2570 if (timediff > audit_timeout) {
2571 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2577 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2578 struct smb_request *smb1req,
2579 struct smbXsrv_open *op,
2580 const DATA_BLOB old_cookie,
2581 TALLOC_CTX *mem_ctx,
2582 struct files_struct **fsp,
2583 DATA_BLOB *new_cookie)
2586 struct timespec ts1,ts2;
2589 clock_gettime_mono(&ts1);
2590 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2591 mem_ctx, fsp, new_cookie);
2592 clock_gettime_mono(&ts2);
2593 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2595 if (timediff > audit_timeout) {
2596 smb_time_audit_log("durable_reconnect", timediff);
2602 /* VFS operations */
2604 static struct vfs_fn_pointers vfs_time_audit_fns = {
2605 .connect_fn = smb_time_audit_connect,
2606 .disconnect_fn = smb_time_audit_disconnect,
2607 .disk_free_fn = smb_time_audit_disk_free,
2608 .get_quota_fn = smb_time_audit_get_quota,
2609 .set_quota_fn = smb_time_audit_set_quota,
2610 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2611 .statvfs_fn = smb_time_audit_statvfs,
2612 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2613 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2614 .opendir_fn = smb_time_audit_opendir,
2615 .fdopendir_fn = smb_time_audit_fdopendir,
2616 .readdir_fn = smb_time_audit_readdir,
2617 .seekdir_fn = smb_time_audit_seekdir,
2618 .telldir_fn = smb_time_audit_telldir,
2619 .rewind_dir_fn = smb_time_audit_rewinddir,
2620 .mkdir_fn = smb_time_audit_mkdir,
2621 .rmdir_fn = smb_time_audit_rmdir,
2622 .closedir_fn = smb_time_audit_closedir,
2623 .init_search_op_fn = smb_time_audit_init_search_op,
2624 .open_fn = smb_time_audit_open,
2625 .create_file_fn = smb_time_audit_create_file,
2626 .close_fn = smb_time_audit_close,
2627 .read_fn = smb_time_audit_read,
2628 .pread_fn = smb_time_audit_pread,
2629 .pread_send_fn = smb_time_audit_pread_send,
2630 .pread_recv_fn = smb_time_audit_pread_recv,
2631 .write_fn = smb_time_audit_write,
2632 .pwrite_fn = smb_time_audit_pwrite,
2633 .pwrite_send_fn = smb_time_audit_pwrite_send,
2634 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2635 .lseek_fn = smb_time_audit_lseek,
2636 .sendfile_fn = smb_time_audit_sendfile,
2637 .recvfile_fn = smb_time_audit_recvfile,
2638 .rename_fn = smb_time_audit_rename,
2639 .fsync_fn = smb_time_audit_fsync,
2640 .fsync_send_fn = smb_time_audit_fsync_send,
2641 .fsync_recv_fn = smb_time_audit_fsync_recv,
2642 .stat_fn = smb_time_audit_stat,
2643 .fstat_fn = smb_time_audit_fstat,
2644 .lstat_fn = smb_time_audit_lstat,
2645 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2646 .unlink_fn = smb_time_audit_unlink,
2647 .chmod_fn = smb_time_audit_chmod,
2648 .fchmod_fn = smb_time_audit_fchmod,
2649 .chown_fn = smb_time_audit_chown,
2650 .fchown_fn = smb_time_audit_fchown,
2651 .lchown_fn = smb_time_audit_lchown,
2652 .chdir_fn = smb_time_audit_chdir,
2653 .getwd_fn = smb_time_audit_getwd,
2654 .ntimes_fn = smb_time_audit_ntimes,
2655 .ftruncate_fn = smb_time_audit_ftruncate,
2656 .fallocate_fn = smb_time_audit_fallocate,
2657 .lock_fn = smb_time_audit_lock,
2658 .kernel_flock_fn = smb_time_audit_kernel_flock,
2659 .linux_setlease_fn = smb_time_audit_linux_setlease,
2660 .getlock_fn = smb_time_audit_getlock,
2661 .symlink_fn = smb_time_audit_symlink,
2662 .readlink_fn = smb_time_audit_readlink,
2663 .link_fn = smb_time_audit_link,
2664 .mknod_fn = smb_time_audit_mknod,
2665 .realpath_fn = smb_time_audit_realpath,
2666 .chflags_fn = smb_time_audit_chflags,
2667 .file_id_create_fn = smb_time_audit_file_id_create,
2668 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2669 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2670 .get_compression_fn = smb_time_audit_get_compression,
2671 .set_compression_fn = smb_time_audit_set_compression,
2672 .snap_check_path_fn = smb_time_audit_snap_check_path,
2673 .snap_create_fn = smb_time_audit_snap_create,
2674 .snap_delete_fn = smb_time_audit_snap_delete,
2675 .streaminfo_fn = smb_time_audit_streaminfo,
2676 .get_real_filename_fn = smb_time_audit_get_real_filename,
2677 .connectpath_fn = smb_time_audit_connectpath,
2678 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2679 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2680 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2681 .strict_lock_fn = smb_time_audit_strict_lock,
2682 .strict_unlock_fn = smb_time_audit_strict_unlock,
2683 .translate_name_fn = smb_time_audit_translate_name,
2684 .fsctl_fn = smb_time_audit_fsctl,
2685 .get_dos_attributes_fn = smb_time_get_dos_attributes,
2686 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2687 .set_dos_attributes_fn = smb_time_set_dos_attributes,
2688 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2689 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2690 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2691 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2692 .audit_file_fn = smb_time_audit_audit_file,
2693 .chmod_acl_fn = smb_time_audit_chmod_acl,
2694 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2695 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2696 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2697 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2698 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2699 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2700 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2701 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2702 .getxattr_fn = smb_time_audit_getxattr,
2703 .fgetxattr_fn = smb_time_audit_fgetxattr,
2704 .listxattr_fn = smb_time_audit_listxattr,
2705 .flistxattr_fn = smb_time_audit_flistxattr,
2706 .removexattr_fn = smb_time_audit_removexattr,
2707 .fremovexattr_fn = smb_time_audit_fremovexattr,
2708 .setxattr_fn = smb_time_audit_setxattr,
2709 .fsetxattr_fn = smb_time_audit_fsetxattr,
2710 .aio_force_fn = smb_time_audit_aio_force,
2711 .durable_cookie_fn = smb_time_audit_durable_cookie,
2712 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2713 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2714 .readdir_attr_fn = smb_time_audit_readdir_attr,
2718 NTSTATUS vfs_time_audit_init(TALLOC_CTX *);
2719 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2721 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2723 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2725 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2726 &vfs_time_audit_fns);