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 struct smb_filename *smb_fname,
1451 struct timespec ts1,ts2;
1454 clock_gettime_mono(&ts1);
1455 result = SMB_VFS_NEXT_READLINK(handle, smb_fname,
1457 clock_gettime_mono(&ts2);
1458 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1460 if (timediff > audit_timeout) {
1461 smb_time_audit_log_fname("readlink", timediff,
1462 smb_fname->base_name);
1468 static int smb_time_audit_link(vfs_handle_struct *handle,
1469 const struct smb_filename *old_smb_fname,
1470 const struct smb_filename *new_smb_fname)
1473 struct timespec ts1,ts2;
1476 clock_gettime_mono(&ts1);
1477 result = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
1478 clock_gettime_mono(&ts2);
1479 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1481 if (timediff > audit_timeout) {
1482 smb_time_audit_log_fname("link", timediff,
1483 new_smb_fname->base_name);
1489 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1490 const struct smb_filename *smb_fname,
1495 struct timespec ts1,ts2;
1498 clock_gettime_mono(&ts1);
1499 result = SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
1500 clock_gettime_mono(&ts2);
1501 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1503 if (timediff > audit_timeout) {
1504 smb_time_audit_log_smb_fname("mknod", timediff, smb_fname);
1510 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1514 struct timespec ts1,ts2;
1517 clock_gettime_mono(&ts1);
1518 result = SMB_VFS_NEXT_REALPATH(handle, path);
1519 clock_gettime_mono(&ts2);
1520 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1522 if (timediff > audit_timeout) {
1523 smb_time_audit_log_fname("realpath", timediff, path);
1529 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1530 const struct smb_filename *smb_fname,
1534 struct timespec ts1,ts2;
1537 clock_gettime_mono(&ts1);
1538 result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
1539 clock_gettime_mono(&ts2);
1540 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1542 if (timediff > audit_timeout) {
1543 smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
1549 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1550 const SMB_STRUCT_STAT *sbuf)
1552 struct file_id id_zero;
1553 struct file_id result;
1554 struct timespec ts1,ts2;
1557 ZERO_STRUCT(id_zero);
1559 clock_gettime_mono(&ts1);
1560 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1561 clock_gettime_mono(&ts2);
1562 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1564 if (timediff > audit_timeout) {
1565 smb_time_audit_log("file_id_create", timediff);
1571 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1572 struct files_struct *fsp,
1573 const struct smb_filename *smb_fname,
1574 TALLOC_CTX *mem_ctx,
1575 unsigned int *pnum_streams,
1576 struct stream_struct **pstreams)
1579 struct timespec ts1,ts2;
1582 clock_gettime_mono(&ts1);
1583 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, smb_fname, mem_ctx,
1584 pnum_streams, pstreams);
1585 clock_gettime_mono(&ts2);
1586 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1588 if (timediff > audit_timeout) {
1589 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1595 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1598 TALLOC_CTX *mem_ctx,
1602 struct timespec ts1,ts2;
1605 clock_gettime_mono(&ts1);
1606 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1608 clock_gettime_mono(&ts2);
1609 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1611 if (timediff > audit_timeout) {
1612 smb_time_audit_log_fname("get_real_filename", timediff, path);
1618 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1622 struct timespec ts1,ts2;
1625 clock_gettime_mono(&ts1);
1626 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1627 clock_gettime_mono(&ts2);
1628 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1630 if (timediff > audit_timeout) {
1631 smb_time_audit_log_fname("connectpath", timediff, fname);
1637 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1638 struct byte_range_lock *br_lck,
1639 struct lock_struct *plock,
1643 struct timespec ts1,ts2;
1646 clock_gettime_mono(&ts1);
1647 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1649 clock_gettime_mono(&ts2);
1650 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1652 if (timediff > audit_timeout) {
1653 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1660 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1661 struct messaging_context *msg_ctx,
1662 struct byte_range_lock *br_lck,
1663 const struct lock_struct *plock)
1666 struct timespec ts1,ts2;
1669 clock_gettime_mono(&ts1);
1670 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1672 clock_gettime_mono(&ts2);
1673 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1675 if (timediff > audit_timeout) {
1676 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1683 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1684 struct byte_range_lock *br_lck,
1685 struct lock_struct *plock)
1688 struct timespec ts1,ts2;
1691 clock_gettime_mono(&ts1);
1692 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock);
1693 clock_gettime_mono(&ts2);
1694 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1696 if (timediff > audit_timeout) {
1697 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1704 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1705 struct files_struct *fsp,
1706 struct lock_struct *plock)
1709 struct timespec ts1,ts2;
1712 clock_gettime_mono(&ts1);
1713 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1714 clock_gettime_mono(&ts2);
1715 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1717 if (timediff > audit_timeout) {
1718 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1724 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1725 struct files_struct *fsp,
1726 struct lock_struct *plock)
1728 struct timespec ts1,ts2;
1731 clock_gettime_mono(&ts1);
1732 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1733 clock_gettime_mono(&ts2);
1734 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1736 if (timediff > audit_timeout) {
1737 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1741 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1743 enum vfs_translate_direction direction,
1744 TALLOC_CTX *mem_ctx,
1748 struct timespec ts1,ts2;
1751 clock_gettime_mono(&ts1);
1752 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1754 clock_gettime_mono(&ts2);
1755 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1757 if (timediff > audit_timeout) {
1758 smb_time_audit_log_fname("translate_name", timediff, name);
1764 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1765 struct files_struct *fsp,
1769 const uint8_t *_in_data,
1771 uint8_t **_out_data,
1772 uint32_t max_out_len,
1776 struct timespec ts1,ts2;
1779 clock_gettime_mono(&ts1);
1780 result = SMB_VFS_NEXT_FSCTL(handle,
1790 clock_gettime_mono(&ts2);
1791 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1793 if (timediff > audit_timeout) {
1794 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1800 static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
1801 struct smb_filename *smb_fname,
1805 struct timespec ts1,ts2;
1808 clock_gettime_mono(&ts1);
1809 result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
1812 clock_gettime_mono(&ts2);
1813 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1815 if (timediff > audit_timeout) {
1816 smb_time_audit_log_fname("get_dos_attributes",
1818 smb_fname->base_name);
1824 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1825 struct files_struct *fsp,
1829 struct timespec ts1,ts2;
1832 clock_gettime_mono(&ts1);
1833 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1836 clock_gettime_mono(&ts2);
1837 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1839 if (timediff > audit_timeout) {
1840 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
1846 static NTSTATUS smb_time_set_dos_attributes(struct vfs_handle_struct *handle,
1847 const struct smb_filename *smb_fname,
1851 struct timespec ts1,ts2;
1854 clock_gettime_mono(&ts1);
1855 result = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle,
1858 clock_gettime_mono(&ts2);
1859 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1861 if (timediff > audit_timeout) {
1862 smb_time_audit_log_fname("set_dos_attributes",
1864 smb_fname->base_name);
1870 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
1871 struct files_struct *fsp,
1875 struct timespec ts1,ts2;
1878 clock_gettime_mono(&ts1);
1879 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
1882 clock_gettime_mono(&ts2);
1883 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1885 if (timediff > audit_timeout) {
1886 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
1892 struct time_audit_cc_state {
1893 struct timespec ts_send;
1894 struct vfs_handle_struct *handle;
1897 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1899 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1900 TALLOC_CTX *mem_ctx,
1901 struct tevent_context *ev,
1902 struct files_struct *src_fsp,
1904 struct files_struct *dest_fsp,
1909 struct tevent_req *req;
1910 struct tevent_req *subreq;
1911 struct time_audit_cc_state *cc_state;
1913 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1918 cc_state->handle = handle;
1919 clock_gettime_mono(&cc_state->ts_send);
1920 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1922 dest_fsp, dest_off, num, flags);
1923 if (tevent_req_nomem(subreq, req)) {
1924 return tevent_req_post(req, ev);
1927 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1931 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1933 struct tevent_req *req = tevent_req_callback_data(
1934 subreq, struct tevent_req);
1935 struct time_audit_cc_state *cc_state
1936 = tevent_req_data(req, struct time_audit_cc_state);
1939 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1942 TALLOC_FREE(subreq);
1943 if (tevent_req_nterror(req, status)) {
1946 tevent_req_done(req);
1949 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1950 struct tevent_req *req,
1953 struct time_audit_cc_state *cc_state
1954 = tevent_req_data(req, struct time_audit_cc_state);
1955 struct timespec ts_recv;
1959 clock_gettime_mono(&ts_recv);
1960 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1961 if (timediff > audit_timeout) {
1962 smb_time_audit_log("copy_chunk", timediff);
1965 *copied = cc_state->copied;
1966 if (tevent_req_is_nterror(req, &status)) {
1967 tevent_req_received(req);
1971 tevent_req_received(req);
1972 return NT_STATUS_OK;
1975 static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
1976 TALLOC_CTX *mem_ctx,
1977 struct files_struct *fsp,
1978 struct smb_filename *smb_fname,
1979 uint16_t *_compression_fmt)
1982 struct timespec ts1,ts2;
1985 clock_gettime_mono(&ts1);
1986 result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
1988 clock_gettime_mono(&ts2);
1989 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1991 if (timediff > audit_timeout) {
1993 smb_time_audit_log_fsp("get_compression",
1996 smb_time_audit_log_smb_fname("get_compression",
1997 timediff, smb_fname);
2004 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2005 TALLOC_CTX *mem_ctx,
2006 struct files_struct *fsp,
2007 uint16_t compression_fmt)
2010 struct timespec ts1,ts2;
2013 clock_gettime_mono(&ts1);
2014 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2016 clock_gettime_mono(&ts2);
2017 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2019 if (timediff > audit_timeout) {
2020 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2026 static NTSTATUS smb_time_audit_readdir_attr(struct vfs_handle_struct *handle,
2027 const struct smb_filename *fname,
2028 TALLOC_CTX *mem_ctx,
2029 struct readdir_attr_data **pattr_data)
2032 struct timespec ts1,ts2;
2035 clock_gettime_mono(&ts1);
2036 status = SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
2037 clock_gettime_mono(&ts2);
2038 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2040 if (timediff > audit_timeout) {
2041 smb_time_audit_log_smb_fname("readdir_attr", timediff, fname);
2047 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2049 uint32_t security_info,
2050 TALLOC_CTX *mem_ctx,
2051 struct security_descriptor **ppdesc)
2054 struct timespec ts1,ts2;
2057 clock_gettime_mono(&ts1);
2058 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2060 clock_gettime_mono(&ts2);
2061 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2063 if (timediff > audit_timeout) {
2064 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2070 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
2071 const struct smb_filename *smb_fname,
2072 uint32_t security_info,
2073 TALLOC_CTX *mem_ctx,
2074 struct security_descriptor **ppdesc)
2077 struct timespec ts1,ts2;
2080 clock_gettime_mono(&ts1);
2081 result = SMB_VFS_NEXT_GET_NT_ACL(handle, smb_fname, security_info,
2083 clock_gettime_mono(&ts2);
2084 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2086 if (timediff > audit_timeout) {
2087 smb_time_audit_log_fname("get_nt_acl",
2089 smb_fname->base_name);
2095 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2097 uint32_t security_info_sent,
2098 const struct security_descriptor *psd)
2101 struct timespec ts1,ts2;
2104 clock_gettime_mono(&ts1);
2105 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2107 clock_gettime_mono(&ts2);
2108 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2110 if (timediff > audit_timeout) {
2111 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2117 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2118 struct smb_filename *smb_fname,
2119 struct security_acl *sacl,
2120 uint32_t access_requested,
2121 uint32_t access_denied)
2124 struct timespec ts1,ts2;
2127 clock_gettime_mono(&ts1);
2128 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2133 clock_gettime_mono(&ts2);
2134 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2136 if (timediff > audit_timeout) {
2137 smb_time_audit_log_fname("audit_file",
2139 smb_fname->base_name);
2147 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
2148 const struct smb_filename *smb_fname,
2152 struct timespec ts1,ts2;
2155 clock_gettime_mono(&ts1);
2156 result = SMB_VFS_NEXT_CHMOD_ACL(handle, smb_fname, mode);
2157 clock_gettime_mono(&ts2);
2158 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2160 if (timediff > audit_timeout) {
2161 smb_time_audit_log_fname("chmod_acl",
2163 smb_fname->base_name);
2169 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
2170 files_struct *fsp, mode_t mode)
2173 struct timespec ts1,ts2;
2176 clock_gettime_mono(&ts1);
2177 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
2178 clock_gettime_mono(&ts2);
2179 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2181 if (timediff > audit_timeout) {
2182 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
2188 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
2189 const struct smb_filename *smb_fname,
2190 SMB_ACL_TYPE_T type,
2191 TALLOC_CTX *mem_ctx)
2194 struct timespec ts1,ts2;
2197 clock_gettime_mono(&ts1);
2198 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
2200 clock_gettime_mono(&ts2);
2201 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2203 if (timediff > audit_timeout) {
2204 smb_time_audit_log_fname("sys_acl_get_file", timediff,
2205 smb_fname->base_name);
2211 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2213 TALLOC_CTX *mem_ctx)
2216 struct timespec ts1,ts2;
2219 clock_gettime_mono(&ts1);
2220 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
2221 clock_gettime_mono(&ts2);
2222 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2224 if (timediff > audit_timeout) {
2225 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2232 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
2233 const struct smb_filename *smb_fname,
2234 TALLOC_CTX *mem_ctx,
2235 char **blob_description,
2239 struct timespec ts1,ts2;
2242 clock_gettime_mono(&ts1);
2243 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
2244 mem_ctx, blob_description, blob);
2245 clock_gettime_mono(&ts2);
2246 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2248 if (timediff > audit_timeout) {
2249 smb_time_audit_log("sys_acl_blob_get_file", timediff);
2255 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2257 TALLOC_CTX *mem_ctx,
2258 char **blob_description,
2262 struct timespec ts1,ts2;
2265 clock_gettime_mono(&ts1);
2266 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2267 clock_gettime_mono(&ts2);
2268 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2270 if (timediff > audit_timeout) {
2271 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2277 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
2278 const struct smb_filename *smb_fname,
2279 SMB_ACL_TYPE_T acltype,
2283 struct timespec ts1,ts2;
2286 clock_gettime_mono(&ts1);
2287 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname, acltype,
2289 clock_gettime_mono(&ts2);
2290 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2292 if (timediff > audit_timeout) {
2293 smb_time_audit_log_fname("sys_acl_set_file", timediff,
2294 smb_fname->base_name);
2300 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2305 struct timespec ts1,ts2;
2308 clock_gettime_mono(&ts1);
2309 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
2310 clock_gettime_mono(&ts2);
2311 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2313 if (timediff > audit_timeout) {
2314 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2320 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
2321 const struct smb_filename *smb_fname)
2324 struct timespec ts1,ts2;
2327 clock_gettime_mono(&ts1);
2328 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
2329 clock_gettime_mono(&ts2);
2330 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2332 if (timediff > audit_timeout) {
2333 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff,
2334 smb_fname->base_name);
2340 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2341 const struct smb_filename *smb_fname,
2347 struct timespec ts1,ts2;
2350 clock_gettime_mono(&ts1);
2351 result = SMB_VFS_NEXT_GETXATTR(handle, smb_fname, name, value, size);
2352 clock_gettime_mono(&ts2);
2353 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2355 if (timediff > audit_timeout) {
2356 smb_time_audit_log_fname("getxattr", timediff,
2357 smb_fname->base_name);
2363 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2364 struct files_struct *fsp,
2365 const char *name, void *value,
2369 struct timespec ts1,ts2;
2372 clock_gettime_mono(&ts1);
2373 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2374 clock_gettime_mono(&ts2);
2375 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2377 if (timediff > audit_timeout) {
2378 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2384 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2385 const struct smb_filename *smb_fname,
2390 struct timespec ts1,ts2;
2393 clock_gettime_mono(&ts1);
2394 result = SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
2395 clock_gettime_mono(&ts2);
2396 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2398 if (timediff > audit_timeout) {
2399 smb_time_audit_log_fname("listxattr", timediff,
2400 smb_fname->base_name);
2406 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2407 struct files_struct *fsp, char *list,
2411 struct timespec ts1,ts2;
2414 clock_gettime_mono(&ts1);
2415 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2416 clock_gettime_mono(&ts2);
2417 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2419 if (timediff > audit_timeout) {
2420 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2426 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2427 const struct smb_filename *smb_fname,
2431 struct timespec ts1,ts2;
2434 clock_gettime_mono(&ts1);
2435 result = SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
2436 clock_gettime_mono(&ts2);
2437 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2439 if (timediff > audit_timeout) {
2440 smb_time_audit_log_fname("removexattr", timediff,
2441 smb_fname->base_name);
2447 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2448 struct files_struct *fsp,
2452 struct timespec ts1,ts2;
2455 clock_gettime_mono(&ts1);
2456 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2457 clock_gettime_mono(&ts2);
2458 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2460 if (timediff > audit_timeout) {
2461 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2467 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2468 const struct smb_filename *smb_fname,
2475 struct timespec ts1,ts2;
2478 clock_gettime_mono(&ts1);
2479 result = SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value, size,
2481 clock_gettime_mono(&ts2);
2482 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2484 if (timediff > audit_timeout) {
2485 smb_time_audit_log_fname("setxattr", timediff,
2486 smb_fname->base_name);
2492 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2493 struct files_struct *fsp, const char *name,
2494 const void *value, size_t size, int flags)
2497 struct timespec ts1,ts2;
2500 clock_gettime_mono(&ts1);
2501 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2502 clock_gettime_mono(&ts2);
2503 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2505 if (timediff > audit_timeout) {
2506 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2512 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2513 struct files_struct *fsp)
2516 struct timespec ts1,ts2;
2519 clock_gettime_mono(&ts1);
2520 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2521 clock_gettime_mono(&ts2);
2522 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2524 if (timediff > audit_timeout) {
2525 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2531 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2532 struct files_struct *fsp,
2533 TALLOC_CTX *mem_ctx,
2537 struct timespec ts1,ts2;
2540 clock_gettime_mono(&ts1);
2541 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2542 clock_gettime_mono(&ts2);
2543 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2545 if (timediff > audit_timeout) {
2546 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2552 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2553 struct files_struct *fsp,
2554 const DATA_BLOB old_cookie,
2555 TALLOC_CTX *mem_ctx,
2556 DATA_BLOB *new_cookie)
2559 struct timespec ts1,ts2;
2562 clock_gettime_mono(&ts1);
2563 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2564 mem_ctx, new_cookie);
2565 clock_gettime_mono(&ts2);
2566 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2568 if (timediff > audit_timeout) {
2569 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2575 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2576 struct smb_request *smb1req,
2577 struct smbXsrv_open *op,
2578 const DATA_BLOB old_cookie,
2579 TALLOC_CTX *mem_ctx,
2580 struct files_struct **fsp,
2581 DATA_BLOB *new_cookie)
2584 struct timespec ts1,ts2;
2587 clock_gettime_mono(&ts1);
2588 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2589 mem_ctx, fsp, new_cookie);
2590 clock_gettime_mono(&ts2);
2591 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2593 if (timediff > audit_timeout) {
2594 smb_time_audit_log("durable_reconnect", timediff);
2600 /* VFS operations */
2602 static struct vfs_fn_pointers vfs_time_audit_fns = {
2603 .connect_fn = smb_time_audit_connect,
2604 .disconnect_fn = smb_time_audit_disconnect,
2605 .disk_free_fn = smb_time_audit_disk_free,
2606 .get_quota_fn = smb_time_audit_get_quota,
2607 .set_quota_fn = smb_time_audit_set_quota,
2608 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2609 .statvfs_fn = smb_time_audit_statvfs,
2610 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2611 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2612 .opendir_fn = smb_time_audit_opendir,
2613 .fdopendir_fn = smb_time_audit_fdopendir,
2614 .readdir_fn = smb_time_audit_readdir,
2615 .seekdir_fn = smb_time_audit_seekdir,
2616 .telldir_fn = smb_time_audit_telldir,
2617 .rewind_dir_fn = smb_time_audit_rewinddir,
2618 .mkdir_fn = smb_time_audit_mkdir,
2619 .rmdir_fn = smb_time_audit_rmdir,
2620 .closedir_fn = smb_time_audit_closedir,
2621 .init_search_op_fn = smb_time_audit_init_search_op,
2622 .open_fn = smb_time_audit_open,
2623 .create_file_fn = smb_time_audit_create_file,
2624 .close_fn = smb_time_audit_close,
2625 .read_fn = smb_time_audit_read,
2626 .pread_fn = smb_time_audit_pread,
2627 .pread_send_fn = smb_time_audit_pread_send,
2628 .pread_recv_fn = smb_time_audit_pread_recv,
2629 .write_fn = smb_time_audit_write,
2630 .pwrite_fn = smb_time_audit_pwrite,
2631 .pwrite_send_fn = smb_time_audit_pwrite_send,
2632 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2633 .lseek_fn = smb_time_audit_lseek,
2634 .sendfile_fn = smb_time_audit_sendfile,
2635 .recvfile_fn = smb_time_audit_recvfile,
2636 .rename_fn = smb_time_audit_rename,
2637 .fsync_fn = smb_time_audit_fsync,
2638 .fsync_send_fn = smb_time_audit_fsync_send,
2639 .fsync_recv_fn = smb_time_audit_fsync_recv,
2640 .stat_fn = smb_time_audit_stat,
2641 .fstat_fn = smb_time_audit_fstat,
2642 .lstat_fn = smb_time_audit_lstat,
2643 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2644 .unlink_fn = smb_time_audit_unlink,
2645 .chmod_fn = smb_time_audit_chmod,
2646 .fchmod_fn = smb_time_audit_fchmod,
2647 .chown_fn = smb_time_audit_chown,
2648 .fchown_fn = smb_time_audit_fchown,
2649 .lchown_fn = smb_time_audit_lchown,
2650 .chdir_fn = smb_time_audit_chdir,
2651 .getwd_fn = smb_time_audit_getwd,
2652 .ntimes_fn = smb_time_audit_ntimes,
2653 .ftruncate_fn = smb_time_audit_ftruncate,
2654 .fallocate_fn = smb_time_audit_fallocate,
2655 .lock_fn = smb_time_audit_lock,
2656 .kernel_flock_fn = smb_time_audit_kernel_flock,
2657 .linux_setlease_fn = smb_time_audit_linux_setlease,
2658 .getlock_fn = smb_time_audit_getlock,
2659 .symlink_fn = smb_time_audit_symlink,
2660 .readlink_fn = smb_time_audit_readlink,
2661 .link_fn = smb_time_audit_link,
2662 .mknod_fn = smb_time_audit_mknod,
2663 .realpath_fn = smb_time_audit_realpath,
2664 .chflags_fn = smb_time_audit_chflags,
2665 .file_id_create_fn = smb_time_audit_file_id_create,
2666 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2667 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2668 .get_compression_fn = smb_time_audit_get_compression,
2669 .set_compression_fn = smb_time_audit_set_compression,
2670 .snap_check_path_fn = smb_time_audit_snap_check_path,
2671 .snap_create_fn = smb_time_audit_snap_create,
2672 .snap_delete_fn = smb_time_audit_snap_delete,
2673 .streaminfo_fn = smb_time_audit_streaminfo,
2674 .get_real_filename_fn = smb_time_audit_get_real_filename,
2675 .connectpath_fn = smb_time_audit_connectpath,
2676 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2677 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2678 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2679 .strict_lock_fn = smb_time_audit_strict_lock,
2680 .strict_unlock_fn = smb_time_audit_strict_unlock,
2681 .translate_name_fn = smb_time_audit_translate_name,
2682 .fsctl_fn = smb_time_audit_fsctl,
2683 .get_dos_attributes_fn = smb_time_get_dos_attributes,
2684 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2685 .set_dos_attributes_fn = smb_time_set_dos_attributes,
2686 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2687 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2688 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2689 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2690 .audit_file_fn = smb_time_audit_audit_file,
2691 .chmod_acl_fn = smb_time_audit_chmod_acl,
2692 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2693 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2694 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2695 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2696 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2697 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2698 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2699 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2700 .getxattr_fn = smb_time_audit_getxattr,
2701 .fgetxattr_fn = smb_time_audit_fgetxattr,
2702 .listxattr_fn = smb_time_audit_listxattr,
2703 .flistxattr_fn = smb_time_audit_flistxattr,
2704 .removexattr_fn = smb_time_audit_removexattr,
2705 .fremovexattr_fn = smb_time_audit_fremovexattr,
2706 .setxattr_fn = smb_time_audit_setxattr,
2707 .fsetxattr_fn = smb_time_audit_fsetxattr,
2708 .aio_force_fn = smb_time_audit_aio_force,
2709 .durable_cookie_fn = smb_time_audit_durable_cookie,
2710 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2711 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2712 .readdir_attr_fn = smb_time_audit_readdir_attr,
2716 NTSTATUS vfs_time_audit_init(TALLOC_CTX *);
2717 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2719 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2721 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2723 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2724 &vfs_time_audit_fns);