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 *oldpath, const char *newpath)
1430 struct timespec ts1,ts2;
1433 clock_gettime_mono(&ts1);
1434 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1435 clock_gettime_mono(&ts2);
1436 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1438 if (timediff > audit_timeout) {
1439 smb_time_audit_log_fname("symlink", timediff, newpath);
1445 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1446 const char *path, char *buf, size_t bufsiz)
1449 struct timespec ts1,ts2;
1452 clock_gettime_mono(&ts1);
1453 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1454 clock_gettime_mono(&ts2);
1455 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1457 if (timediff > audit_timeout) {
1458 smb_time_audit_log_fname("readlink", timediff, path);
1464 static int smb_time_audit_link(vfs_handle_struct *handle,
1465 const struct smb_filename *old_smb_fname,
1466 const struct smb_filename *new_smb_fname)
1469 struct timespec ts1,ts2;
1472 clock_gettime_mono(&ts1);
1473 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1474 clock_gettime_mono(&ts2);
1475 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1477 if (timediff > audit_timeout) {
1478 smb_time_audit_log_fname("link", timediff,
1479 new_smb_fname->base_name);
1485 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1486 const struct smb_filename *smb_fname,
1491 struct timespec ts1,ts2;
1494 clock_gettime_mono(&ts1);
1495 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1496 clock_gettime_mono(&ts2);
1497 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1499 if (timediff > audit_timeout) {
1500 smb_time_audit_log_smb_fname("mknod", timediff, smb_fname);
1506 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1510 struct timespec ts1,ts2;
1513 clock_gettime_mono(&ts1);
1514 result = SMB_VFS_NEXT_REALPATH(handle, path);
1515 clock_gettime_mono(&ts2);
1516 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1518 if (timediff > audit_timeout) {
1519 smb_time_audit_log_fname("realpath", timediff, path);
1525 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1526 const struct smb_filename *smb_fname,
1530 struct timespec ts1,ts2;
1533 clock_gettime_mono(&ts1);
1534 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1535 clock_gettime_mono(&ts2);
1536 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1538 if (timediff > audit_timeout) {
1539 smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
1545 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1546 const SMB_STRUCT_STAT *sbuf)
1548 struct file_id id_zero;
1549 struct file_id result;
1550 struct timespec ts1,ts2;
1553 ZERO_STRUCT(id_zero);
1555 clock_gettime_mono(&ts1);
1556 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1557 clock_gettime_mono(&ts2);
1558 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1560 if (timediff > audit_timeout) {
1561 smb_time_audit_log("file_id_create", timediff);
1567 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1568 struct files_struct *fsp,
1569 const struct smb_filename *smb_fname,
1570 TALLOC_CTX *mem_ctx,
1571 unsigned int *pnum_streams,
1572 struct stream_struct **pstreams)
1575 struct timespec ts1,ts2;
1578 clock_gettime_mono(&ts1);
1579 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1580 pnum_streams, pstreams);
1581 clock_gettime_mono(&ts2);
1582 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1584 if (timediff > audit_timeout) {
1585 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1591 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1594 TALLOC_CTX *mem_ctx,
1598 struct timespec ts1,ts2;
1601 clock_gettime_mono(&ts1);
1602 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1604 clock_gettime_mono(&ts2);
1605 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1607 if (timediff > audit_timeout) {
1608 smb_time_audit_log_fname("get_real_filename", timediff, path);
1614 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1618 struct timespec ts1,ts2;
1621 clock_gettime_mono(&ts1);
1622 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1623 clock_gettime_mono(&ts2);
1624 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1626 if (timediff > audit_timeout) {
1627 smb_time_audit_log_fname("connectpath", timediff, fname);
1633 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1634 struct byte_range_lock *br_lck,
1635 struct lock_struct *plock,
1639 struct timespec ts1,ts2;
1642 clock_gettime_mono(&ts1);
1643 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1645 clock_gettime_mono(&ts2);
1646 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1648 if (timediff > audit_timeout) {
1649 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1656 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1657 struct messaging_context *msg_ctx,
1658 struct byte_range_lock *br_lck,
1659 const struct lock_struct *plock)
1662 struct timespec ts1,ts2;
1665 clock_gettime_mono(&ts1);
1666 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1668 clock_gettime_mono(&ts2);
1669 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1671 if (timediff > audit_timeout) {
1672 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1679 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1680 struct byte_range_lock *br_lck,
1681 struct lock_struct *plock)
1684 struct timespec ts1,ts2;
1687 clock_gettime_mono(&ts1);
1688 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1689 clock_gettime_mono(&ts2);
1690 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1692 if (timediff > audit_timeout) {
1693 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1700 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1701 struct files_struct *fsp,
1702 struct lock_struct *plock)
1705 struct timespec ts1,ts2;
1708 clock_gettime_mono(&ts1);
1709 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1710 clock_gettime_mono(&ts2);
1711 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1713 if (timediff > audit_timeout) {
1714 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1720 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1721 struct files_struct *fsp,
1722 struct lock_struct *plock)
1724 struct timespec ts1,ts2;
1727 clock_gettime_mono(&ts1);
1728 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1729 clock_gettime_mono(&ts2);
1730 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1732 if (timediff > audit_timeout) {
1733 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1737 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1739 enum vfs_translate_direction direction,
1740 TALLOC_CTX *mem_ctx,
1744 struct timespec ts1,ts2;
1747 clock_gettime_mono(&ts1);
1748 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1750 clock_gettime_mono(&ts2);
1751 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1753 if (timediff > audit_timeout) {
1754 smb_time_audit_log_fname("translate_name", timediff, name);
1760 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1761 struct files_struct *fsp,
1765 const uint8_t *_in_data,
1767 uint8_t **_out_data,
1768 uint32_t max_out_len,
1772 struct timespec ts1,ts2;
1775 clock_gettime_mono(&ts1);
1776 result = SMB_VFS_NEXT_FSCTL(handle,
1786 clock_gettime_mono(&ts2);
1787 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1789 if (timediff > audit_timeout) {
1790 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1796 static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
1797 struct smb_filename *smb_fname,
1801 struct timespec ts1,ts2;
1804 clock_gettime_mono(&ts1);
1805 result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1808 clock_gettime_mono(&ts2);
1809 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1811 if (timediff > audit_timeout) {
1812 smb_time_audit_log_fname("get_dos_attributes",
1814 smb_fname->base_name);
1820 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1821 struct files_struct *fsp,
1825 struct timespec ts1,ts2;
1828 clock_gettime_mono(&ts1);
1829 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1832 clock_gettime_mono(&ts2);
1833 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1835 if (timediff > audit_timeout) {
1836 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
1842 static NTSTATUS smb_time_set_dos_attributes(struct vfs_handle_struct *handle,
1843 const struct smb_filename *smb_fname,
1847 struct timespec ts1,ts2;
1850 clock_gettime_mono(&ts1);
1851 result = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
1854 clock_gettime_mono(&ts2);
1855 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1857 if (timediff > audit_timeout) {
1858 smb_time_audit_log_fname("set_dos_attributes",
1860 smb_fname->base_name);
1866 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
1867 struct files_struct *fsp,
1871 struct timespec ts1,ts2;
1874 clock_gettime_mono(&ts1);
1875 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
1878 clock_gettime_mono(&ts2);
1879 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1881 if (timediff > audit_timeout) {
1882 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
1888 struct time_audit_cc_state {
1889 struct timespec ts_send;
1890 struct vfs_handle_struct *handle;
1893 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1895 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1896 TALLOC_CTX *mem_ctx,
1897 struct tevent_context *ev,
1898 struct files_struct *src_fsp,
1900 struct files_struct *dest_fsp,
1905 struct tevent_req *req;
1906 struct tevent_req *subreq;
1907 struct time_audit_cc_state *cc_state;
1909 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1914 cc_state->handle = handle;
1915 clock_gettime_mono(&cc_state->ts_send);
1916 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1918 dest_fsp, dest_off, num, flags);
1919 if (tevent_req_nomem(subreq, req)) {
1920 return tevent_req_post(req, ev);
1923 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1927 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1929 struct tevent_req *req = tevent_req_callback_data(
1930 subreq, struct tevent_req);
1931 struct time_audit_cc_state *cc_state
1932 = tevent_req_data(req, struct time_audit_cc_state);
1935 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1938 TALLOC_FREE(subreq);
1939 if (tevent_req_nterror(req, status)) {
1942 tevent_req_done(req);
1945 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1946 struct tevent_req *req,
1949 struct time_audit_cc_state *cc_state
1950 = tevent_req_data(req, struct time_audit_cc_state);
1951 struct timespec ts_recv;
1955 clock_gettime_mono(&ts_recv);
1956 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1957 if (timediff > audit_timeout) {
1958 smb_time_audit_log("copy_chunk", timediff);
1961 *copied = cc_state->copied;
1962 if (tevent_req_is_nterror(req, &status)) {
1963 tevent_req_received(req);
1967 tevent_req_received(req);
1968 return NT_STATUS_OK;
1971 static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
1972 TALLOC_CTX *mem_ctx,
1973 struct files_struct *fsp,
1974 struct smb_filename *smb_fname,
1975 uint16_t *_compression_fmt)
1978 struct timespec ts1,ts2;
1981 clock_gettime_mono(&ts1);
1982 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1984 clock_gettime_mono(&ts2);
1985 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1987 if (timediff > audit_timeout) {
1989 smb_time_audit_log_fsp("get_compression",
1992 smb_time_audit_log_smb_fname("get_compression",
1993 timediff, smb_fname);
2000 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2001 TALLOC_CTX *mem_ctx,
2002 struct files_struct *fsp,
2003 uint16_t compression_fmt)
2006 struct timespec ts1,ts2;
2009 clock_gettime_mono(&ts1);
2010 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2012 clock_gettime_mono(&ts2);
2013 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2015 if (timediff > audit_timeout) {
2016 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2022 static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
2023 const struct smb_filename *fname,
2024 TALLOC_CTX *mem_ctx,
2025 struct readdir_attr_data **pattr_data)
2028 struct timespec ts1,ts2;
2031 clock_gettime_mono(&ts1);
2032 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2033 clock_gettime_mono(&ts2);
2034 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2036 if (timediff > audit_timeout) {
2037 smb_time_audit_log_smb_fname("readdir_attr", timediff, fname);
2043 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2045 uint32_t security_info,
2046 TALLOC_CTX *mem_ctx,
2047 struct security_descriptor **ppdesc)
2050 struct timespec ts1,ts2;
2053 clock_gettime_mono(&ts1);
2054 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2056 clock_gettime_mono(&ts2);
2057 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2059 if (timediff > audit_timeout) {
2060 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2066 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
2067 const struct smb_filename *smb_fname,
2068 uint32_t security_info,
2069 TALLOC_CTX *mem_ctx,
2070 struct security_descriptor **ppdesc)
2073 struct timespec ts1,ts2;
2076 clock_gettime_mono(&ts1);
2077 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2079 clock_gettime_mono(&ts2);
2080 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2082 if (timediff > audit_timeout) {
2083 smb_time_audit_log_fname("get_nt_acl",
2085 smb_fname->base_name);
2091 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2093 uint32_t security_info_sent,
2094 const struct security_descriptor *psd)
2097 struct timespec ts1,ts2;
2100 clock_gettime_mono(&ts1);
2101 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2103 clock_gettime_mono(&ts2);
2104 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2106 if (timediff > audit_timeout) {
2107 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2113 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2114 struct smb_filename *smb_fname,
2115 struct security_acl *sacl,
2116 uint32_t access_requested,
2117 uint32_t access_denied)
2120 struct timespec ts1,ts2;
2123 clock_gettime_mono(&ts1);
2124 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2129 clock_gettime_mono(&ts2);
2130 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2132 if (timediff > audit_timeout) {
2133 smb_time_audit_log_fname("audit_file",
2135 smb_fname->base_name);
2143 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
2144 const struct smb_filename *smb_fname,
2148 struct timespec ts1,ts2;
2151 clock_gettime_mono(&ts1);
2152 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2153 clock_gettime_mono(&ts2);
2154 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2156 if (timediff > audit_timeout) {
2157 smb_time_audit_log_fname("chmod_acl",
2159 smb_fname->base_name);
2165 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
2166 files_struct *fsp, mode_t mode)
2169 struct timespec ts1,ts2;
2172 clock_gettime_mono(&ts1);
2173 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2174 clock_gettime_mono(&ts2);
2175 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2177 if (timediff > audit_timeout) {
2178 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
2184 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
2185 const struct smb_filename *smb_fname,
2186 SMB_ACL_TYPE_T type,
2187 TALLOC_CTX *mem_ctx)
2190 struct timespec ts1,ts2;
2193 clock_gettime_mono(&ts1);
2194 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2196 clock_gettime_mono(&ts2);
2197 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2199 if (timediff > audit_timeout) {
2200 smb_time_audit_log_fname("sys_acl_get_file", timediff,
2201 smb_fname->base_name);
2207 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2209 TALLOC_CTX *mem_ctx)
2212 struct timespec ts1,ts2;
2215 clock_gettime_mono(&ts1);
2216 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2217 clock_gettime_mono(&ts2);
2218 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2220 if (timediff > audit_timeout) {
2221 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2228 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2229 const struct smb_filename *smb_fname,
2230 TALLOC_CTX *mem_ctx,
2231 char **blob_description,
2235 struct timespec ts1,ts2;
2238 clock_gettime_mono(&ts1);
2239 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2240 mem_ctx, blob_description, blob);
2241 clock_gettime_mono(&ts2);
2242 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2244 if (timediff > audit_timeout) {
2245 smb_time_audit_log("sys_acl_blob_get_file", timediff);
2251 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2253 TALLOC_CTX *mem_ctx,
2254 char **blob_description,
2258 struct timespec ts1,ts2;
2261 clock_gettime_mono(&ts1);
2262 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2263 clock_gettime_mono(&ts2);
2264 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2266 if (timediff > audit_timeout) {
2267 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2273 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
2274 const struct smb_filename *smb_fname,
2275 SMB_ACL_TYPE_T acltype,
2279 struct timespec ts1,ts2;
2282 clock_gettime_mono(&ts1);
2283 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2285 clock_gettime_mono(&ts2);
2286 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2288 if (timediff > audit_timeout) {
2289 smb_time_audit_log_fname("sys_acl_set_file", timediff,
2290 smb_fname->base_name);
2296 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2301 struct timespec ts1,ts2;
2304 clock_gettime_mono(&ts1);
2305 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2306 clock_gettime_mono(&ts2);
2307 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2309 if (timediff > audit_timeout) {
2310 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2316 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2317 const struct smb_filename *smb_fname)
2320 struct timespec ts1,ts2;
2323 clock_gettime_mono(&ts1);
2324 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2325 clock_gettime_mono(&ts2);
2326 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2328 if (timediff > audit_timeout) {
2329 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff,
2330 smb_fname->base_name);
2336 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2337 const struct smb_filename *smb_fname,
2343 struct timespec ts1,ts2;
2346 clock_gettime_mono(&ts1);
2347 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2348 clock_gettime_mono(&ts2);
2349 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2351 if (timediff > audit_timeout) {
2352 smb_time_audit_log_fname("getxattr", timediff,
2353 smb_fname->base_name);
2359 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2360 struct files_struct *fsp,
2361 const char *name, void *value,
2365 struct timespec ts1,ts2;
2368 clock_gettime_mono(&ts1);
2369 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2370 clock_gettime_mono(&ts2);
2371 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2373 if (timediff > audit_timeout) {
2374 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2380 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2381 const struct smb_filename *smb_fname,
2386 struct timespec ts1,ts2;
2389 clock_gettime_mono(&ts1);
2390 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2391 clock_gettime_mono(&ts2);
2392 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2394 if (timediff > audit_timeout) {
2395 smb_time_audit_log_fname("listxattr", timediff,
2396 smb_fname->base_name);
2402 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2403 struct files_struct *fsp, char *list,
2407 struct timespec ts1,ts2;
2410 clock_gettime_mono(&ts1);
2411 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2412 clock_gettime_mono(&ts2);
2413 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2415 if (timediff > audit_timeout) {
2416 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2422 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2423 const struct smb_filename *smb_fname,
2427 struct timespec ts1,ts2;
2430 clock_gettime_mono(&ts1);
2431 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2432 clock_gettime_mono(&ts2);
2433 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2435 if (timediff > audit_timeout) {
2436 smb_time_audit_log_fname("removexattr", timediff,
2437 smb_fname->base_name);
2443 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2444 struct files_struct *fsp,
2448 struct timespec ts1,ts2;
2451 clock_gettime_mono(&ts1);
2452 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2453 clock_gettime_mono(&ts2);
2454 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2456 if (timediff > audit_timeout) {
2457 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2463 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2464 const struct smb_filename *smb_fname,
2471 struct timespec ts1,ts2;
2474 clock_gettime_mono(&ts1);
2475 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2477 clock_gettime_mono(&ts2);
2478 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2480 if (timediff > audit_timeout) {
2481 smb_time_audit_log_fname("setxattr", timediff,
2482 smb_fname->base_name);
2488 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2489 struct files_struct *fsp, const char *name,
2490 const void *value, size_t size, int flags)
2493 struct timespec ts1,ts2;
2496 clock_gettime_mono(&ts1);
2497 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2498 clock_gettime_mono(&ts2);
2499 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2501 if (timediff > audit_timeout) {
2502 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2508 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2509 struct files_struct *fsp)
2512 struct timespec ts1,ts2;
2515 clock_gettime_mono(&ts1);
2516 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2517 clock_gettime_mono(&ts2);
2518 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2520 if (timediff > audit_timeout) {
2521 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2527 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2528 struct files_struct *fsp,
2529 TALLOC_CTX *mem_ctx,
2533 struct timespec ts1,ts2;
2536 clock_gettime_mono(&ts1);
2537 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2538 clock_gettime_mono(&ts2);
2539 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2541 if (timediff > audit_timeout) {
2542 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2548 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2549 struct files_struct *fsp,
2550 const DATA_BLOB old_cookie,
2551 TALLOC_CTX *mem_ctx,
2552 DATA_BLOB *new_cookie)
2555 struct timespec ts1,ts2;
2558 clock_gettime_mono(&ts1);
2559 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2560 mem_ctx, new_cookie);
2561 clock_gettime_mono(&ts2);
2562 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2564 if (timediff > audit_timeout) {
2565 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2571 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2572 struct smb_request *smb1req,
2573 struct smbXsrv_open *op,
2574 const DATA_BLOB old_cookie,
2575 TALLOC_CTX *mem_ctx,
2576 struct files_struct **fsp,
2577 DATA_BLOB *new_cookie)
2580 struct timespec ts1,ts2;
2583 clock_gettime_mono(&ts1);
2584 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2585 mem_ctx, fsp, new_cookie);
2586 clock_gettime_mono(&ts2);
2587 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2589 if (timediff > audit_timeout) {
2590 smb_time_audit_log("durable_reconnect", timediff);
2596 /* VFS operations */
2598 static struct vfs_fn_pointers vfs_time_audit_fns = {
2599 .connect_fn = smb_time_audit_connect,
2600 .disconnect_fn = smb_time_audit_disconnect,
2601 .disk_free_fn = smb_time_audit_disk_free,
2602 .get_quota_fn = smb_time_audit_get_quota,
2603 .set_quota_fn = smb_time_audit_set_quota,
2604 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2605 .statvfs_fn = smb_time_audit_statvfs,
2606 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2607 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2608 .opendir_fn = smb_time_audit_opendir,
2609 .fdopendir_fn = smb_time_audit_fdopendir,
2610 .readdir_fn = smb_time_audit_readdir,
2611 .seekdir_fn = smb_time_audit_seekdir,
2612 .telldir_fn = smb_time_audit_telldir,
2613 .rewind_dir_fn = smb_time_audit_rewinddir,
2614 .mkdir_fn = smb_time_audit_mkdir,
2615 .rmdir_fn = smb_time_audit_rmdir,
2616 .closedir_fn = smb_time_audit_closedir,
2617 .init_search_op_fn = smb_time_audit_init_search_op,
2618 .open_fn = smb_time_audit_open,
2619 .create_file_fn = smb_time_audit_create_file,
2620 .close_fn = smb_time_audit_close,
2621 .read_fn = smb_time_audit_read,
2622 .pread_fn = smb_time_audit_pread,
2623 .pread_send_fn = smb_time_audit_pread_send,
2624 .pread_recv_fn = smb_time_audit_pread_recv,
2625 .write_fn = smb_time_audit_write,
2626 .pwrite_fn = smb_time_audit_pwrite,
2627 .pwrite_send_fn = smb_time_audit_pwrite_send,
2628 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2629 .lseek_fn = smb_time_audit_lseek,
2630 .sendfile_fn = smb_time_audit_sendfile,
2631 .recvfile_fn = smb_time_audit_recvfile,
2632 .rename_fn = smb_time_audit_rename,
2633 .fsync_fn = smb_time_audit_fsync,
2634 .fsync_send_fn = smb_time_audit_fsync_send,
2635 .fsync_recv_fn = smb_time_audit_fsync_recv,
2636 .stat_fn = smb_time_audit_stat,
2637 .fstat_fn = smb_time_audit_fstat,
2638 .lstat_fn = smb_time_audit_lstat,
2639 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2640 .unlink_fn = smb_time_audit_unlink,
2641 .chmod_fn = smb_time_audit_chmod,
2642 .fchmod_fn = smb_time_audit_fchmod,
2643 .chown_fn = smb_time_audit_chown,
2644 .fchown_fn = smb_time_audit_fchown,
2645 .lchown_fn = smb_time_audit_lchown,
2646 .chdir_fn = smb_time_audit_chdir,
2647 .getwd_fn = smb_time_audit_getwd,
2648 .ntimes_fn = smb_time_audit_ntimes,
2649 .ftruncate_fn = smb_time_audit_ftruncate,
2650 .fallocate_fn = smb_time_audit_fallocate,
2651 .lock_fn = smb_time_audit_lock,
2652 .kernel_flock_fn = smb_time_audit_kernel_flock,
2653 .linux_setlease_fn = smb_time_audit_linux_setlease,
2654 .getlock_fn = smb_time_audit_getlock,
2655 .symlink_fn = smb_time_audit_symlink,
2656 .readlink_fn = smb_time_audit_readlink,
2657 .link_fn = smb_time_audit_link,
2658 .mknod_fn = smb_time_audit_mknod,
2659 .realpath_fn = smb_time_audit_realpath,
2660 .chflags_fn = smb_time_audit_chflags,
2661 .file_id_create_fn = smb_time_audit_file_id_create,
2662 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2663 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2664 .get_compression_fn = smb_time_audit_get_compression,
2665 .set_compression_fn = smb_time_audit_set_compression,
2666 .snap_check_path_fn = smb_time_audit_snap_check_path,
2667 .snap_create_fn = smb_time_audit_snap_create,
2668 .snap_delete_fn = smb_time_audit_snap_delete,
2669 .streaminfo_fn = smb_time_audit_streaminfo,
2670 .get_real_filename_fn = smb_time_audit_get_real_filename,
2671 .connectpath_fn = smb_time_audit_connectpath,
2672 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2673 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2674 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2675 .strict_lock_fn = smb_time_audit_strict_lock,
2676 .strict_unlock_fn = smb_time_audit_strict_unlock,
2677 .translate_name_fn = smb_time_audit_translate_name,
2678 .fsctl_fn = smb_time_audit_fsctl,
2679 .get_dos_attributes_fn = smb_time_get_dos_attributes,
2680 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2681 .set_dos_attributes_fn = smb_time_set_dos_attributes,
2682 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2683 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2684 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2685 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2686 .audit_file_fn = smb_time_audit_audit_file,
2687 .chmod_acl_fn = smb_time_audit_chmod_acl,
2688 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2689 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2690 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2691 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2692 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2693 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2694 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2695 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2696 .getxattr_fn = smb_time_audit_getxattr,
2697 .fgetxattr_fn = smb_time_audit_fgetxattr,
2698 .listxattr_fn = smb_time_audit_listxattr,
2699 .flistxattr_fn = smb_time_audit_flistxattr,
2700 .removexattr_fn = smb_time_audit_removexattr,
2701 .fremovexattr_fn = smb_time_audit_fremovexattr,
2702 .setxattr_fn = smb_time_audit_setxattr,
2703 .fsetxattr_fn = smb_time_audit_fsetxattr,
2704 .aio_force_fn = smb_time_audit_aio_force,
2705 .durable_cookie_fn = smb_time_audit_durable_cookie,
2706 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2707 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2708 .readdir_attr_fn = smb_time_audit_readdir_attr,
2712 NTSTATUS vfs_time_audit_init(TALLOC_CTX *);
2713 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2715 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2717 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2719 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2720 &vfs_time_audit_fns);