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_at(const char *syscallname,
91 const struct files_struct *dir_fsp,
92 const struct smb_filename *smb_fname)
96 msg = talloc_asprintf(talloc_tos(),
97 "filename = \"%s/%s/%s\"",
98 dir_fsp->conn->connectpath,
99 dir_fsp->fsp_name->base_name,
100 smb_fname->base_name);
102 smb_time_audit_log_msg(syscallname, elapsed, msg);
106 static void smb_time_audit_log_fname(const char *syscallname, double elapsed,
112 if (getcwd(cwd, sizeof(cwd)) == NULL) {
113 snprintf(cwd, sizeof(cwd), "<getcwd() error %d>", errno);
116 msg = talloc_asprintf(talloc_tos(),
117 "cwd = \"%s\", filename = \"%s\"",
120 msg = talloc_asprintf(talloc_tos(),
121 "cwd = \"%s\", filename = <NULL>",
124 smb_time_audit_log_msg(syscallname, elapsed, msg);
128 static void smb_time_audit_log_smb_fname(const char *syscallname, double elapsed,
129 const struct smb_filename *smb_fname)
131 if (smb_fname != NULL) {
132 smb_time_audit_log_fname(syscallname, elapsed,
133 smb_fname->base_name);
135 smb_time_audit_log_fname(syscallname, elapsed,
136 "smb_fname = <NULL>");
140 static int smb_time_audit_connect(vfs_handle_struct *handle,
141 const char *svc, const char *user)
144 struct timespec ts1,ts2;
151 clock_gettime_mono(&ts1);
152 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
153 clock_gettime_mono(&ts2);
154 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
155 if (timediff > audit_timeout) {
156 smb_time_audit_log_msg("connect", timediff, user);
161 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
163 struct timespec ts1,ts2;
166 clock_gettime_mono(&ts1);
167 SMB_VFS_NEXT_DISCONNECT(handle);
168 clock_gettime_mono(&ts2);
169 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
171 if (timediff > audit_timeout) {
172 smb_time_audit_log("disconnect", timediff);
176 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
177 const struct smb_filename *smb_fname,
183 struct timespec ts1,ts2;
186 clock_gettime_mono(&ts1);
187 result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
188 clock_gettime_mono(&ts2);
189 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
191 /* Don't have a reasonable notion of failure here */
192 if (timediff > audit_timeout) {
193 smb_time_audit_log_fname("disk_free",
195 smb_fname->base_name);
201 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
202 const struct smb_filename *smb_fname,
203 enum SMB_QUOTA_TYPE qtype,
208 struct timespec ts1,ts2;
211 clock_gettime_mono(&ts1);
212 result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
213 clock_gettime_mono(&ts2);
214 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
216 if (timediff > audit_timeout) {
217 smb_time_audit_log_fname("get_quota",
219 smb_fname->base_name);
224 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
225 enum SMB_QUOTA_TYPE qtype, unid_t id,
229 struct timespec ts1,ts2;
232 clock_gettime_mono(&ts1);
233 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
234 clock_gettime_mono(&ts2);
235 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
237 if (timediff > audit_timeout) {
238 smb_time_audit_log("set_quota", timediff);
244 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
245 struct files_struct *fsp,
246 struct shadow_copy_data *shadow_copy_data,
250 struct timespec ts1,ts2;
253 clock_gettime_mono(&ts1);
254 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
255 shadow_copy_data, labels);
256 clock_gettime_mono(&ts2);
257 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
259 if (timediff > audit_timeout) {
260 smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp);
266 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
267 const struct smb_filename *smb_fname,
268 struct vfs_statvfs_struct *statbuf)
271 struct timespec ts1,ts2;
274 clock_gettime_mono(&ts1);
275 result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf);
276 clock_gettime_mono(&ts2);
277 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
279 if (timediff > audit_timeout) {
280 smb_time_audit_log_fname("statvfs", timediff,
281 smb_fname->base_name);
287 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
288 enum timestamp_set_resolution *p_ts_res)
291 struct timespec ts1,ts2;
294 clock_gettime_mono(&ts1);
295 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
296 clock_gettime_mono(&ts2);
297 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
299 if (timediff > audit_timeout) {
300 smb_time_audit_log("fs_capabilities", timediff);
306 static NTSTATUS smb_time_audit_get_dfs_referrals(
307 struct vfs_handle_struct *handle,
308 struct dfs_GetDFSReferral *r)
311 struct timespec ts1,ts2;
314 clock_gettime_mono(&ts1);
315 result = SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
316 clock_gettime_mono(&ts2);
317 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
319 if (timediff > audit_timeout) {
320 smb_time_audit_log("get_dfs_referrals", timediff);
326 static NTSTATUS smb_time_audit_create_dfs_pathat(struct vfs_handle_struct *handle,
327 struct files_struct *dirfsp,
328 const struct smb_filename *smb_fname,
329 const struct referral *reflist,
330 size_t referral_count)
333 struct timespec ts1,ts2;
335 struct smb_filename *full_fname = NULL;
337 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
340 if (full_fname == NULL) {
341 return NT_STATUS_NO_MEMORY;
344 clock_gettime_mono(&ts1);
345 result = SMB_VFS_NEXT_CREATE_DFS_PATHAT(handle,
350 clock_gettime_mono(&ts2);
351 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
353 if (timediff > audit_timeout) {
354 smb_time_audit_log_smb_fname("create_dfs_pathat",
358 TALLOC_FREE(full_fname);
362 static NTSTATUS smb_time_audit_read_dfs_pathat(struct vfs_handle_struct *handle,
364 struct files_struct *dirfsp,
365 struct smb_filename *smb_fname,
366 struct referral **ppreflist,
367 size_t *preferral_count)
370 struct timespec ts1,ts2;
372 struct smb_filename *full_fname = NULL;
374 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
377 if (full_fname == NULL) {
378 return NT_STATUS_NO_MEMORY;
381 clock_gettime_mono(&ts1);
382 result = SMB_VFS_NEXT_READ_DFS_PATHAT(handle,
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("read_dfs_pathat",
397 TALLOC_FREE(full_fname);
401 static NTSTATUS smb_time_audit_snap_check_path(struct vfs_handle_struct *handle,
403 const char *service_path,
407 struct timespec ts1,ts2;
410 clock_gettime_mono(&ts1);
411 status = SMB_VFS_NEXT_SNAP_CHECK_PATH(handle, mem_ctx, service_path,
413 clock_gettime_mono(&ts2);
414 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
416 if (timediff > audit_timeout) {
417 smb_time_audit_log("snap_check_path", timediff);
423 static NTSTATUS smb_time_audit_snap_create(struct vfs_handle_struct *handle,
425 const char *base_volume,
432 struct timespec ts1,ts2;
435 clock_gettime_mono(&ts1);
436 status = SMB_VFS_NEXT_SNAP_CREATE(handle, mem_ctx, base_volume, tstamp,
437 rw, base_path, snap_path);
438 clock_gettime_mono(&ts2);
439 timediff = nsec_time_diff(&ts2 ,&ts1) * 1.0e-9;
441 if (timediff > audit_timeout) {
442 smb_time_audit_log("snap_create", timediff);
448 static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
454 struct timespec ts1,ts2;
457 clock_gettime_mono(&ts1);
458 status = SMB_VFS_NEXT_SNAP_DELETE(handle, mem_ctx, base_path,
460 clock_gettime_mono(&ts2);
461 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
463 if (timediff > audit_timeout) {
464 smb_time_audit_log("snap_delete", timediff);
470 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
472 const char *mask, uint32_t attr)
475 struct timespec ts1,ts2;
478 clock_gettime_mono(&ts1);
479 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
480 clock_gettime_mono(&ts2);
481 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
483 if (timediff > audit_timeout) {
484 smb_time_audit_log_fsp("fdopendir", timediff, fsp);
490 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
491 struct files_struct *dirfsp,
493 SMB_STRUCT_STAT *sbuf)
495 struct dirent *result;
496 struct timespec ts1,ts2;
499 clock_gettime_mono(&ts1);
500 result = SMB_VFS_NEXT_READDIR(handle, dirfsp, dirp, sbuf);
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("readdir", timediff);
511 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
512 DIR *dirp, long offset)
514 struct timespec ts1,ts2;
517 clock_gettime_mono(&ts1);
518 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
519 clock_gettime_mono(&ts2);
520 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
522 if (timediff > audit_timeout) {
523 smb_time_audit_log("seekdir", timediff);
528 static long smb_time_audit_telldir(vfs_handle_struct *handle,
532 struct timespec ts1,ts2;
535 clock_gettime_mono(&ts1);
536 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
537 clock_gettime_mono(&ts2);
538 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
540 if (timediff > audit_timeout) {
541 smb_time_audit_log("telldir", timediff);
547 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
550 struct timespec ts1,ts2;
553 clock_gettime_mono(&ts1);
554 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
555 clock_gettime_mono(&ts2);
556 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
558 if (timediff > audit_timeout) {
559 smb_time_audit_log("rewinddir", timediff);
564 static int smb_time_audit_mkdirat(vfs_handle_struct *handle,
565 struct files_struct *dirfsp,
566 const struct smb_filename *smb_fname,
569 struct smb_filename *full_fname = NULL;
571 struct timespec ts1,ts2;
574 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
577 if (full_fname == NULL) {
582 clock_gettime_mono(&ts1);
583 result = SMB_VFS_NEXT_MKDIRAT(handle,
587 clock_gettime_mono(&ts2);
588 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
590 if (timediff > audit_timeout) {
591 smb_time_audit_log_smb_fname("mkdirat",
596 TALLOC_FREE(full_fname);
601 static int smb_time_audit_closedir(vfs_handle_struct *handle,
605 struct timespec ts1,ts2;
608 clock_gettime_mono(&ts1);
609 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
610 clock_gettime_mono(&ts2);
611 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
613 if (timediff > audit_timeout) {
614 smb_time_audit_log("closedir", timediff);
620 static int smb_time_audit_openat(vfs_handle_struct *handle,
621 const struct files_struct *dirfsp,
622 const struct smb_filename *smb_fname,
623 struct files_struct *fsp,
628 struct timespec ts1,ts2;
631 clock_gettime_mono(&ts1);
632 result = SMB_VFS_NEXT_OPENAT(handle,
638 clock_gettime_mono(&ts2);
639 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
641 if (timediff > audit_timeout) {
642 smb_time_audit_log_fsp("openat", timediff, fsp);
648 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
649 struct smb_request *req,
650 struct smb_filename *fname,
651 uint32_t access_mask,
652 uint32_t share_access,
653 uint32_t create_disposition,
654 uint32_t create_options,
655 uint32_t file_attributes,
656 uint32_t oplock_request,
657 const struct smb2_lease *lease,
658 uint64_t allocation_size,
659 uint32_t private_flags,
660 struct security_descriptor *sd,
661 struct ea_list *ea_list,
662 files_struct **result_fsp,
664 const struct smb2_create_blobs *in_context_blobs,
665 struct smb2_create_blobs *out_context_blobs)
668 struct timespec ts1,ts2;
671 clock_gettime_mono(&ts1);
672 result = SMB_VFS_NEXT_CREATE_FILE(
676 access_mask, /* access_mask */
677 share_access, /* share_access */
678 create_disposition, /* create_disposition*/
679 create_options, /* create_options */
680 file_attributes, /* file_attributes */
681 oplock_request, /* oplock_request */
683 allocation_size, /* allocation_size */
686 ea_list, /* ea_list */
687 result_fsp, /* result */
689 in_context_blobs, out_context_blobs); /* create context */
690 clock_gettime_mono(&ts2);
691 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
693 if (timediff > audit_timeout) {
695 * can't use result_fsp this time, may have
696 * invalid content causing smbd crash
698 smb_time_audit_log_smb_fname("create_file", timediff,
705 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
708 struct timespec ts1,ts2;
711 clock_gettime_mono(&ts1);
712 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
713 clock_gettime_mono(&ts2);
714 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
716 if (timediff > audit_timeout) {
717 smb_time_audit_log_fsp("close", timediff, fsp);
723 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
725 void *data, size_t n, off_t offset)
728 struct timespec ts1,ts2;
731 clock_gettime_mono(&ts1);
732 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
733 clock_gettime_mono(&ts2);
734 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
736 if (timediff > audit_timeout) {
737 smb_time_audit_log_fsp("pread", timediff, fsp);
743 struct smb_time_audit_pread_state {
744 struct files_struct *fsp;
746 struct vfs_aio_state vfs_aio_state;
749 static void smb_time_audit_pread_done(struct tevent_req *subreq);
751 static struct tevent_req *smb_time_audit_pread_send(
752 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
753 struct tevent_context *ev, struct files_struct *fsp,
754 void *data, size_t n, off_t offset)
756 struct tevent_req *req, *subreq;
757 struct smb_time_audit_pread_state *state;
759 req = tevent_req_create(mem_ctx, &state,
760 struct smb_time_audit_pread_state);
766 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
768 if (tevent_req_nomem(subreq, req)) {
769 return tevent_req_post(req, ev);
771 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
775 static void smb_time_audit_pread_done(struct tevent_req *subreq)
777 struct tevent_req *req = tevent_req_callback_data(
778 subreq, struct tevent_req);
779 struct smb_time_audit_pread_state *state = tevent_req_data(
780 req, struct smb_time_audit_pread_state);
782 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->vfs_aio_state);
784 tevent_req_done(req);
787 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req,
788 struct vfs_aio_state *vfs_aio_state)
790 struct smb_time_audit_pread_state *state = tevent_req_data(
791 req, struct smb_time_audit_pread_state);
794 timediff = state->vfs_aio_state.duration * 1.0e-9;
796 if (timediff > audit_timeout) {
797 smb_time_audit_log_fsp("async pread", timediff, state->fsp);
800 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
803 *vfs_aio_state = state->vfs_aio_state;
807 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
809 const void *data, size_t n,
813 struct timespec ts1,ts2;
816 clock_gettime_mono(&ts1);
817 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
818 clock_gettime_mono(&ts2);
819 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
821 if (timediff > audit_timeout) {
822 smb_time_audit_log_fsp("pwrite", timediff, fsp);
828 struct smb_time_audit_pwrite_state {
829 struct files_struct *fsp;
831 struct vfs_aio_state vfs_aio_state;
834 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
836 static struct tevent_req *smb_time_audit_pwrite_send(
837 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
838 struct tevent_context *ev, struct files_struct *fsp,
839 const void *data, size_t n, off_t offset)
841 struct tevent_req *req, *subreq;
842 struct smb_time_audit_pwrite_state *state;
844 req = tevent_req_create(mem_ctx, &state,
845 struct smb_time_audit_pwrite_state);
851 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
853 if (tevent_req_nomem(subreq, req)) {
854 return tevent_req_post(req, ev);
856 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
860 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
862 struct tevent_req *req = tevent_req_callback_data(
863 subreq, struct tevent_req);
864 struct smb_time_audit_pwrite_state *state = tevent_req_data(
865 req, struct smb_time_audit_pwrite_state);
867 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
869 tevent_req_done(req);
872 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
873 struct vfs_aio_state *vfs_aio_state)
875 struct smb_time_audit_pwrite_state *state = tevent_req_data(
876 req, struct smb_time_audit_pwrite_state);
879 timediff = state->vfs_aio_state.duration * 1.0e-9;
881 if (timediff > audit_timeout) {
882 smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
885 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
888 *vfs_aio_state = state->vfs_aio_state;
892 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
894 off_t offset, int whence)
897 struct timespec ts1,ts2;
900 clock_gettime_mono(&ts1);
901 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
902 clock_gettime_mono(&ts2);
903 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
905 if (timediff > audit_timeout) {
906 smb_time_audit_log_fsp("lseek", timediff, fsp);
912 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
913 files_struct *fromfsp,
914 const DATA_BLOB *hdr, off_t offset,
918 struct timespec ts1,ts2;
921 clock_gettime_mono(&ts1);
922 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
923 clock_gettime_mono(&ts2);
924 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
926 if (timediff > audit_timeout) {
927 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
933 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
939 struct timespec ts1,ts2;
942 clock_gettime_mono(&ts1);
943 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
944 clock_gettime_mono(&ts2);
945 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
947 if (timediff > audit_timeout) {
948 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
954 static int smb_time_audit_renameat(vfs_handle_struct *handle,
955 files_struct *srcfsp,
956 const struct smb_filename *oldname,
957 files_struct *dstfsp,
958 const struct smb_filename *newname)
961 struct timespec ts1,ts2;
963 struct smb_filename *new_full_fname = NULL;
965 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
968 if (new_full_fname == NULL) {
972 clock_gettime_mono(&ts1);
973 result = SMB_VFS_NEXT_RENAMEAT(handle,
978 clock_gettime_mono(&ts2);
979 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
981 if (timediff > audit_timeout) {
982 smb_time_audit_log_smb_fname("renameat",
987 TALLOC_FREE(new_full_fname);
991 struct smb_time_audit_fsync_state {
992 struct files_struct *fsp;
994 struct vfs_aio_state vfs_aio_state;
997 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
999 static struct tevent_req *smb_time_audit_fsync_send(
1000 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
1001 struct tevent_context *ev, struct files_struct *fsp)
1003 struct tevent_req *req, *subreq;
1004 struct smb_time_audit_fsync_state *state;
1006 req = tevent_req_create(mem_ctx, &state,
1007 struct smb_time_audit_fsync_state);
1013 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
1014 if (tevent_req_nomem(subreq, req)) {
1015 return tevent_req_post(req, ev);
1017 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
1021 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
1023 struct tevent_req *req = tevent_req_callback_data(
1024 subreq, struct tevent_req);
1025 struct smb_time_audit_fsync_state *state = tevent_req_data(
1026 req, struct smb_time_audit_fsync_state);
1028 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
1029 TALLOC_FREE(subreq);
1030 tevent_req_done(req);
1033 static int smb_time_audit_fsync_recv(struct tevent_req *req,
1034 struct vfs_aio_state *vfs_aio_state)
1036 struct smb_time_audit_fsync_state *state = tevent_req_data(
1037 req, struct smb_time_audit_fsync_state);
1040 timediff = state->vfs_aio_state.duration * 1.0e-9;
1042 if (timediff > audit_timeout) {
1043 smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
1046 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1049 *vfs_aio_state = state->vfs_aio_state;
1053 static int smb_time_audit_stat(vfs_handle_struct *handle,
1054 struct smb_filename *fname)
1057 struct timespec ts1,ts2;
1060 clock_gettime_mono(&ts1);
1061 result = SMB_VFS_NEXT_STAT(handle, fname);
1062 clock_gettime_mono(&ts2);
1063 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1065 if (timediff > audit_timeout) {
1066 smb_time_audit_log_smb_fname("stat", timediff, fname);
1072 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1073 SMB_STRUCT_STAT *sbuf)
1076 struct timespec ts1,ts2;
1079 clock_gettime_mono(&ts1);
1080 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1081 clock_gettime_mono(&ts2);
1082 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1084 if (timediff > audit_timeout) {
1085 smb_time_audit_log_fsp("fstat", timediff, fsp);
1091 static int smb_time_audit_lstat(vfs_handle_struct *handle,
1092 struct smb_filename *path)
1095 struct timespec ts1,ts2;
1098 clock_gettime_mono(&ts1);
1099 result = SMB_VFS_NEXT_LSTAT(handle, path);
1100 clock_gettime_mono(&ts2);
1101 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1103 if (timediff > audit_timeout) {
1104 smb_time_audit_log_smb_fname("lstat", timediff, path);
1110 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
1112 const SMB_STRUCT_STAT *sbuf)
1115 struct timespec ts1,ts2;
1118 clock_gettime_mono(&ts1);
1119 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1120 clock_gettime_mono(&ts2);
1121 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1123 if (timediff > audit_timeout) {
1124 smb_time_audit_log_fsp("get_alloc_size", timediff, fsp);
1130 static int smb_time_audit_unlinkat(vfs_handle_struct *handle,
1131 struct files_struct *dirfsp,
1132 const struct smb_filename *path,
1135 struct smb_filename *full_fname = NULL;
1137 struct timespec ts1,ts2;
1140 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1143 if (full_fname == NULL) {
1147 clock_gettime_mono(&ts1);
1148 result = SMB_VFS_NEXT_UNLINKAT(handle,
1152 clock_gettime_mono(&ts2);
1153 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1155 if (timediff > audit_timeout) {
1156 smb_time_audit_log_smb_fname("unlinkat", timediff, full_fname);
1159 TALLOC_FREE(full_fname);
1163 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1167 struct timespec ts1,ts2;
1170 clock_gettime_mono(&ts1);
1171 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1172 clock_gettime_mono(&ts2);
1173 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1175 if (timediff > audit_timeout) {
1176 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1182 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1183 uid_t uid, gid_t gid)
1186 struct timespec ts1,ts2;
1189 clock_gettime_mono(&ts1);
1190 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1191 clock_gettime_mono(&ts2);
1192 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1194 if (timediff > audit_timeout) {
1195 smb_time_audit_log_fsp("fchown", timediff, fsp);
1201 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1202 const struct smb_filename *smb_fname,
1207 struct timespec ts1,ts2;
1210 clock_gettime_mono(&ts1);
1211 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1212 clock_gettime_mono(&ts2);
1213 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1215 if (timediff > audit_timeout) {
1216 smb_time_audit_log_fname("lchown",
1218 smb_fname->base_name);
1224 static int smb_time_audit_chdir(vfs_handle_struct *handle,
1225 const struct smb_filename *smb_fname)
1228 struct timespec ts1,ts2;
1231 clock_gettime_mono(&ts1);
1232 result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
1233 clock_gettime_mono(&ts2);
1234 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1236 if (timediff > audit_timeout) {
1237 smb_time_audit_log_fname("chdir",
1239 smb_fname->base_name);
1245 static struct smb_filename *smb_time_audit_getwd(vfs_handle_struct *handle,
1246 TALLOC_CTX *mem_ctx)
1248 struct smb_filename *result;
1249 struct timespec ts1,ts2;
1252 clock_gettime_mono(&ts1);
1253 result = SMB_VFS_NEXT_GETWD(handle, mem_ctx);
1254 clock_gettime_mono(&ts2);
1255 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1257 if (timediff > audit_timeout) {
1258 smb_time_audit_log("getwd", timediff);
1264 static int smb_time_audit_fntimes(vfs_handle_struct *handle,
1266 struct smb_file_time *ft)
1269 struct timespec ts1,ts2;
1272 clock_gettime_mono(&ts1);
1273 result = SMB_VFS_NEXT_FNTIMES(handle, fsp, ft);
1274 clock_gettime_mono(&ts2);
1275 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
1277 if (timediff > audit_timeout) {
1278 smb_time_audit_log_fsp("fntimes", timediff, fsp);
1284 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1289 struct timespec ts1,ts2;
1292 clock_gettime_mono(&ts1);
1293 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1294 clock_gettime_mono(&ts2);
1295 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1297 if (timediff > audit_timeout) {
1298 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1304 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1311 int saved_errno = 0;
1312 struct timespec ts1,ts2;
1315 clock_gettime_mono(&ts1);
1316 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1318 saved_errno = errno;
1320 clock_gettime_mono(&ts2);
1321 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1323 if (timediff > audit_timeout) {
1324 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1327 errno = saved_errno;
1332 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1333 int op, off_t offset, off_t count,
1337 struct timespec ts1,ts2;
1340 clock_gettime_mono(&ts1);
1341 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1342 clock_gettime_mono(&ts2);
1343 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1345 if (timediff > audit_timeout) {
1346 smb_time_audit_log_fsp("lock", timediff, fsp);
1352 static int smb_time_audit_filesystem_sharemode(struct vfs_handle_struct *handle,
1353 struct files_struct *fsp,
1354 uint32_t share_access,
1355 uint32_t access_mask)
1358 struct timespec ts1,ts2;
1361 clock_gettime_mono(&ts1);
1362 result = SMB_VFS_NEXT_FILESYSTEM_SHAREMODE(handle,
1366 clock_gettime_mono(&ts2);
1367 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1369 if (timediff > audit_timeout) {
1370 smb_time_audit_log_fsp("filesystem_sharemode", timediff, fsp);
1376 static int smb_time_audit_fcntl(struct vfs_handle_struct *handle,
1377 struct files_struct *fsp,
1378 int cmd, va_list cmd_arg)
1381 va_list dup_cmd_arg;
1383 struct timespec ts1,ts2;
1386 va_copy(dup_cmd_arg, cmd_arg);
1387 arg = va_arg(dup_cmd_arg, void *);
1388 clock_gettime_mono(&ts1);
1389 result = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
1390 clock_gettime_mono(&ts2);
1391 va_end(dup_cmd_arg);
1393 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1394 if (timediff > audit_timeout) {
1395 smb_time_audit_log_fsp("fcntl", timediff, fsp);
1401 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1406 struct timespec ts1,ts2;
1409 clock_gettime_mono(&ts1);
1410 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1411 clock_gettime_mono(&ts2);
1412 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1414 if (timediff > audit_timeout) {
1415 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1421 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1423 off_t *poffset, off_t *pcount,
1424 int *ptype, pid_t *ppid)
1427 struct timespec ts1,ts2;
1430 clock_gettime_mono(&ts1);
1431 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1433 clock_gettime_mono(&ts2);
1434 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1436 if (timediff > audit_timeout) {
1437 smb_time_audit_log_fsp("getlock", timediff, fsp);
1443 static int smb_time_audit_symlinkat(vfs_handle_struct *handle,
1444 const struct smb_filename *link_contents,
1445 struct files_struct *dirfsp,
1446 const struct smb_filename *new_smb_fname)
1448 struct smb_filename *full_fname = NULL;
1450 struct timespec ts1,ts2;
1453 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1456 if (full_fname == NULL) {
1461 clock_gettime_mono(&ts1);
1462 result = SMB_VFS_NEXT_SYMLINKAT(handle,
1466 clock_gettime_mono(&ts2);
1467 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1469 if (timediff > audit_timeout) {
1470 smb_time_audit_log_fname("symlinkat", timediff,
1471 full_fname->base_name);
1474 TALLOC_FREE(full_fname);
1478 static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
1479 const struct files_struct *dirfsp,
1480 const struct smb_filename *smb_fname,
1484 struct smb_filename *full_fname = NULL;
1486 struct timespec ts1,ts2;
1489 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1492 if (full_fname == NULL) {
1497 clock_gettime_mono(&ts1);
1498 result = SMB_VFS_NEXT_READLINKAT(handle,
1503 clock_gettime_mono(&ts2);
1504 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1506 if (timediff > audit_timeout) {
1507 smb_time_audit_log_fname("readlinkat", timediff,
1508 full_fname->base_name);
1511 TALLOC_FREE(full_fname);
1515 static int smb_time_audit_linkat(vfs_handle_struct *handle,
1516 files_struct *srcfsp,
1517 const struct smb_filename *old_smb_fname,
1518 files_struct *dstfsp,
1519 const struct smb_filename *new_smb_fname,
1522 struct smb_filename *new_full_fname = NULL;
1524 struct timespec ts1,ts2;
1527 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1530 if (new_full_fname == NULL) {
1535 clock_gettime_mono(&ts1);
1536 result = SMB_VFS_NEXT_LINKAT(handle,
1542 clock_gettime_mono(&ts2);
1543 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1545 if (timediff > audit_timeout) {
1546 smb_time_audit_log_fname("linkat", timediff,
1547 new_full_fname->base_name);
1550 TALLOC_FREE(new_full_fname);
1554 static int smb_time_audit_mknodat(vfs_handle_struct *handle,
1555 files_struct *dirfsp,
1556 const struct smb_filename *smb_fname,
1560 struct smb_filename *full_fname = NULL;
1562 struct timespec ts1,ts2;
1565 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1568 if (full_fname == NULL) {
1573 clock_gettime_mono(&ts1);
1574 result = SMB_VFS_NEXT_MKNODAT(handle,
1579 clock_gettime_mono(&ts2);
1580 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1582 if (timediff > audit_timeout) {
1583 smb_time_audit_log_smb_fname("mknodat", timediff, full_fname);
1586 TALLOC_FREE(full_fname);
1590 static struct smb_filename *smb_time_audit_realpath(vfs_handle_struct *handle,
1592 const struct smb_filename *smb_fname)
1594 struct smb_filename *result_fname;
1595 struct timespec ts1,ts2;
1598 clock_gettime_mono(&ts1);
1599 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1600 clock_gettime_mono(&ts2);
1601 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1603 if (timediff > audit_timeout) {
1604 smb_time_audit_log_fname("realpath", timediff,
1605 smb_fname->base_name);
1608 return result_fname;
1611 static int smb_time_audit_fchflags(vfs_handle_struct *handle,
1612 struct files_struct *fsp,
1616 struct timespec ts1,ts2;
1619 clock_gettime_mono(&ts1);
1620 result = SMB_VFS_NEXT_FCHFLAGS(handle, fsp, flags);
1621 clock_gettime_mono(&ts2);
1622 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1624 if (timediff > audit_timeout) {
1625 smb_time_audit_log_smb_fname("chflags",
1633 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1634 const SMB_STRUCT_STAT *sbuf)
1636 struct file_id id_zero;
1637 struct file_id result;
1638 struct timespec ts1,ts2;
1641 ZERO_STRUCT(id_zero);
1643 clock_gettime_mono(&ts1);
1644 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
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("file_id_create", timediff);
1655 static uint64_t smb_time_audit_fs_file_id(struct vfs_handle_struct *handle,
1656 const SMB_STRUCT_STAT *sbuf)
1659 struct timespec ts1,ts2;
1662 clock_gettime_mono(&ts1);
1663 result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
1664 clock_gettime_mono(&ts2);
1665 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1667 if (timediff > audit_timeout) {
1668 smb_time_audit_log("fs_file_id", timediff);
1674 static NTSTATUS smb_time_audit_fstreaminfo(vfs_handle_struct *handle,
1675 struct files_struct *fsp,
1676 TALLOC_CTX *mem_ctx,
1677 unsigned int *pnum_streams,
1678 struct stream_struct **pstreams)
1681 struct timespec ts1,ts2;
1684 clock_gettime_mono(&ts1);
1685 result = SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx,
1686 pnum_streams, pstreams);
1687 clock_gettime_mono(&ts2);
1688 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1690 if (timediff > audit_timeout) {
1691 smb_time_audit_log_fsp("fstreaminfo", timediff, fsp);
1697 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1698 const struct smb_filename *path,
1700 TALLOC_CTX *mem_ctx,
1704 struct timespec ts1,ts2;
1707 clock_gettime_mono(&ts1);
1708 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
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_fname("get_real_filename",
1715 timediff, path->base_name);
1721 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1722 const struct smb_filename *smb_fname)
1725 struct timespec ts1,ts2;
1728 clock_gettime_mono(&ts1);
1729 result = SMB_VFS_NEXT_CONNECTPATH(handle, smb_fname);
1730 clock_gettime_mono(&ts2);
1731 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1733 if (timediff > audit_timeout) {
1734 smb_time_audit_log_fname("connectpath", timediff,
1735 smb_fname->base_name);
1741 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1742 struct byte_range_lock *br_lck,
1743 struct lock_struct *plock)
1746 struct timespec ts1,ts2;
1749 clock_gettime_mono(&ts1);
1750 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock);
1751 clock_gettime_mono(&ts2);
1752 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1754 if (timediff > audit_timeout) {
1755 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1762 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1763 struct byte_range_lock *br_lck,
1764 const struct lock_struct *plock)
1767 struct timespec ts1,ts2;
1770 clock_gettime_mono(&ts1);
1771 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, br_lck, plock);
1772 clock_gettime_mono(&ts2);
1773 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1775 if (timediff > audit_timeout) {
1776 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1783 static bool smb_time_audit_strict_lock_check(struct vfs_handle_struct *handle,
1784 struct files_struct *fsp,
1785 struct lock_struct *plock)
1788 struct timespec ts1,ts2;
1791 clock_gettime_mono(&ts1);
1792 result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
1793 clock_gettime_mono(&ts2);
1794 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1796 if (timediff > audit_timeout) {
1797 smb_time_audit_log_fsp("strict_lock_check", timediff, fsp);
1803 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1805 enum vfs_translate_direction direction,
1806 TALLOC_CTX *mem_ctx,
1810 struct timespec ts1,ts2;
1813 clock_gettime_mono(&ts1);
1814 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1816 clock_gettime_mono(&ts2);
1817 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1819 if (timediff > audit_timeout) {
1820 smb_time_audit_log_fname("translate_name", timediff, name);
1826 static NTSTATUS smb_time_audit_parent_pathname(struct vfs_handle_struct *handle,
1827 TALLOC_CTX *mem_ctx,
1828 const struct smb_filename *smb_fname_in,
1829 struct smb_filename **parent_dir_out,
1830 struct smb_filename **atname_out)
1833 struct timespec ts1,ts2;
1836 clock_gettime_mono(&ts1);
1837 result = SMB_VFS_NEXT_PARENT_PATHNAME(handle,
1842 clock_gettime_mono(&ts2);
1843 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1845 if (timediff > audit_timeout) {
1846 smb_time_audit_log_fname("parent_pathname",
1848 smb_fname_in->base_name);
1854 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1855 struct files_struct *fsp,
1859 const uint8_t *_in_data,
1861 uint8_t **_out_data,
1862 uint32_t max_out_len,
1866 struct timespec ts1,ts2;
1869 clock_gettime_mono(&ts1);
1870 result = SMB_VFS_NEXT_FSCTL(handle,
1880 clock_gettime_mono(&ts2);
1881 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1883 if (timediff > audit_timeout) {
1884 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1890 struct smb_time_audit_get_dos_attributes_state {
1891 struct vfs_aio_state aio_state;
1892 files_struct *dir_fsp;
1893 const struct smb_filename *smb_fname;
1897 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq);
1899 static struct tevent_req *smb_time_audit_get_dos_attributes_send(
1900 TALLOC_CTX *mem_ctx,
1901 struct tevent_context *ev,
1902 struct vfs_handle_struct *handle,
1903 files_struct *dir_fsp,
1904 struct smb_filename *smb_fname)
1906 struct tevent_req *req = NULL;
1907 struct smb_time_audit_get_dos_attributes_state *state = NULL;
1908 struct tevent_req *subreq = NULL;
1910 req = tevent_req_create(mem_ctx, &state,
1911 struct smb_time_audit_get_dos_attributes_state);
1915 *state = (struct smb_time_audit_get_dos_attributes_state) {
1917 .smb_fname = smb_fname,
1920 subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
1925 if (tevent_req_nomem(subreq, req)) {
1926 return tevent_req_post(req, ev);
1928 tevent_req_set_callback(subreq,
1929 smb_time_audit_get_dos_attributes_done,
1935 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq)
1937 struct tevent_req *req =
1938 tevent_req_callback_data(subreq,
1940 struct smb_time_audit_get_dos_attributes_state *state =
1941 tevent_req_data(req,
1942 struct smb_time_audit_get_dos_attributes_state);
1945 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
1948 TALLOC_FREE(subreq);
1949 if (tevent_req_nterror(req, status)) {
1953 tevent_req_done(req);
1957 static NTSTATUS smb_time_audit_get_dos_attributes_recv(struct tevent_req *req,
1958 struct vfs_aio_state *aio_state,
1961 struct smb_time_audit_get_dos_attributes_state *state =
1962 tevent_req_data(req,
1963 struct smb_time_audit_get_dos_attributes_state);
1967 timediff = state->aio_state.duration * 1.0e-9;
1969 if (timediff > audit_timeout) {
1970 smb_time_audit_log_at("async get_dos_attributes",
1976 if (tevent_req_is_nterror(req, &status)) {
1977 tevent_req_received(req);
1981 *aio_state = state->aio_state;
1982 *dosmode = state->dosmode;
1983 tevent_req_received(req);
1984 return NT_STATUS_OK;
1987 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1988 struct files_struct *fsp,
1992 struct timespec ts1,ts2;
1995 clock_gettime_mono(&ts1);
1996 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1999 clock_gettime_mono(&ts2);
2000 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2002 if (timediff > audit_timeout) {
2003 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
2009 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
2010 struct files_struct *fsp,
2014 struct timespec ts1,ts2;
2017 clock_gettime_mono(&ts1);
2018 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
2021 clock_gettime_mono(&ts2);
2022 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2024 if (timediff > audit_timeout) {
2025 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
2031 struct time_audit_offload_read_state {
2032 struct vfs_handle_struct *handle;
2033 struct timespec ts_send;
2036 DATA_BLOB token_blob;
2039 static void smb_time_audit_offload_read_done(struct tevent_req *subreq);
2041 static struct tevent_req *smb_time_audit_offload_read_send(
2042 TALLOC_CTX *mem_ctx,
2043 struct tevent_context *ev,
2044 struct vfs_handle_struct *handle,
2045 struct files_struct *fsp,
2051 struct tevent_req *req = NULL;
2052 struct tevent_req *subreq = NULL;
2053 struct time_audit_offload_read_state *state = NULL;
2055 req = tevent_req_create(mem_ctx, &state,
2056 struct time_audit_offload_read_state);
2060 state->handle = handle;
2061 clock_gettime_mono(&state->ts_send);
2063 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev,
2067 if (tevent_req_nomem(subreq, req)) {
2068 return tevent_req_post(req, ev);
2071 tevent_req_set_callback(subreq, smb_time_audit_offload_read_done, req);
2075 static void smb_time_audit_offload_read_done(struct tevent_req *subreq)
2077 struct tevent_req *req = tevent_req_callback_data(
2078 subreq, struct tevent_req);
2079 struct time_audit_offload_read_state *state = tevent_req_data(
2080 req, struct time_audit_offload_read_state);
2083 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
2088 &state->token_blob);
2089 TALLOC_FREE(subreq);
2090 if (tevent_req_nterror(req, status)) {
2093 tevent_req_done(req);
2096 static NTSTATUS smb_time_audit_offload_read_recv(
2097 struct tevent_req *req,
2098 struct vfs_handle_struct *handle,
2099 TALLOC_CTX *mem_ctx,
2102 DATA_BLOB *token_blob)
2104 struct time_audit_offload_read_state *state = tevent_req_data(
2105 req, struct time_audit_offload_read_state);
2106 struct timespec ts_recv;
2110 clock_gettime_mono(&ts_recv);
2111 timediff = nsec_time_diff(&ts_recv, &state->ts_send) * 1.0e-9;
2112 if (timediff > audit_timeout) {
2113 smb_time_audit_log("offload_read", timediff);
2116 if (tevent_req_is_nterror(req, &status)) {
2117 tevent_req_received(req);
2121 *flags = state->flags;
2122 *xferlen = state->xferlen;
2123 token_blob->length = state->token_blob.length;
2124 token_blob->data = talloc_move(mem_ctx, &state->token_blob.data);
2126 tevent_req_received(req);
2127 return NT_STATUS_OK;
2130 struct time_audit_offload_write_state {
2131 struct timespec ts_send;
2132 struct vfs_handle_struct *handle;
2135 static void smb_time_audit_offload_write_done(struct tevent_req *subreq);
2137 static struct tevent_req *smb_time_audit_offload_write_send(struct vfs_handle_struct *handle,
2138 TALLOC_CTX *mem_ctx,
2139 struct tevent_context *ev,
2142 off_t transfer_offset,
2143 struct files_struct *dest_fsp,
2147 struct tevent_req *req;
2148 struct tevent_req *subreq;
2149 struct time_audit_offload_write_state *state;
2151 req = tevent_req_create(mem_ctx, &state,
2152 struct time_audit_offload_write_state);
2157 state->handle = handle;
2158 clock_gettime_mono(&state->ts_send);
2159 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
2160 fsctl, token, transfer_offset,
2161 dest_fsp, dest_off, num);
2162 if (tevent_req_nomem(subreq, req)) {
2163 return tevent_req_post(req, ev);
2166 tevent_req_set_callback(subreq, smb_time_audit_offload_write_done, req);
2170 static void smb_time_audit_offload_write_done(struct tevent_req *subreq)
2172 struct tevent_req *req = tevent_req_callback_data(
2173 subreq, struct tevent_req);
2174 struct time_audit_offload_write_state *state = tevent_req_data(
2175 req, struct time_audit_offload_write_state);
2178 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
2181 TALLOC_FREE(subreq);
2182 if (tevent_req_nterror(req, status)) {
2185 tevent_req_done(req);
2188 static NTSTATUS smb_time_audit_offload_write_recv(struct vfs_handle_struct *handle,
2189 struct tevent_req *req,
2192 struct time_audit_offload_write_state *state = tevent_req_data(
2193 req, struct time_audit_offload_write_state);
2194 struct timespec ts_recv;
2198 clock_gettime_mono(&ts_recv);
2199 timediff = nsec_time_diff(&ts_recv, &state->ts_send)*1.0e-9;
2200 if (timediff > audit_timeout) {
2201 smb_time_audit_log("offload_write", timediff);
2204 *copied = state->copied;
2205 if (tevent_req_is_nterror(req, &status)) {
2206 tevent_req_received(req);
2210 tevent_req_received(req);
2211 return NT_STATUS_OK;
2214 static NTSTATUS smb_time_audit_fget_compression(vfs_handle_struct *handle,
2215 TALLOC_CTX *mem_ctx,
2216 struct files_struct *fsp,
2217 uint16_t *_compression_fmt)
2220 struct timespec ts1,ts2;
2223 clock_gettime_mono(&ts1);
2224 result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
2226 clock_gettime_mono(&ts2);
2227 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2229 if (timediff > audit_timeout) {
2230 smb_time_audit_log_fsp("get_compression",
2237 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2238 TALLOC_CTX *mem_ctx,
2239 struct files_struct *fsp,
2240 uint16_t compression_fmt)
2243 struct timespec ts1,ts2;
2246 clock_gettime_mono(&ts1);
2247 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2249 clock_gettime_mono(&ts2);
2250 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2252 if (timediff > audit_timeout) {
2253 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2259 static NTSTATUS smb_time_audit_freaddir_attr(struct vfs_handle_struct *handle,
2260 struct files_struct *fsp,
2261 TALLOC_CTX *mem_ctx,
2262 struct readdir_attr_data **pattr_data)
2265 struct timespec ts1, ts2;
2268 clock_gettime_mono(&ts1);
2269 status = SMB_VFS_NEXT_FREADDIR_ATTR(handle, fsp, mem_ctx, pattr_data);
2270 clock_gettime_mono(&ts2);
2271 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
2273 if (timediff > audit_timeout) {
2274 smb_time_audit_log_fsp("freaddir_attr", timediff, fsp);
2280 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2282 uint32_t security_info,
2283 TALLOC_CTX *mem_ctx,
2284 struct security_descriptor **ppdesc)
2287 struct timespec ts1,ts2;
2290 clock_gettime_mono(&ts1);
2291 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2293 clock_gettime_mono(&ts2);
2294 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2296 if (timediff > audit_timeout) {
2297 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2303 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2305 uint32_t security_info_sent,
2306 const struct security_descriptor *psd)
2309 struct timespec ts1,ts2;
2312 clock_gettime_mono(&ts1);
2313 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2315 clock_gettime_mono(&ts2);
2316 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2318 if (timediff > audit_timeout) {
2319 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2325 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2326 struct smb_filename *smb_fname,
2327 struct security_acl *sacl,
2328 uint32_t access_requested,
2329 uint32_t access_denied)
2332 struct timespec ts1,ts2;
2335 clock_gettime_mono(&ts1);
2336 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2341 clock_gettime_mono(&ts2);
2342 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2344 if (timediff > audit_timeout) {
2345 smb_time_audit_log_fname("audit_file",
2347 smb_fname->base_name);
2353 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2355 SMB_ACL_TYPE_T type,
2356 TALLOC_CTX *mem_ctx)
2359 struct timespec ts1,ts2;
2362 clock_gettime_mono(&ts1);
2363 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, type, mem_ctx);
2364 clock_gettime_mono(&ts2);
2365 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2367 if (timediff > audit_timeout) {
2368 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2374 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2376 TALLOC_CTX *mem_ctx,
2377 char **blob_description,
2381 struct timespec ts1,ts2;
2384 clock_gettime_mono(&ts1);
2385 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2386 clock_gettime_mono(&ts2);
2387 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2389 if (timediff > audit_timeout) {
2390 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2396 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2398 SMB_ACL_TYPE_T type,
2402 struct timespec ts1,ts2;
2405 clock_gettime_mono(&ts1);
2406 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, type, theacl);
2407 clock_gettime_mono(&ts2);
2408 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2410 if (timediff > audit_timeout) {
2411 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2417 static int smb_time_audit_sys_acl_delete_def_fd(vfs_handle_struct *handle,
2421 struct timespec ts1,ts2;
2424 clock_gettime_mono(&ts1);
2425 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FD(handle, fsp);
2426 clock_gettime_mono(&ts2);
2427 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2429 if (timediff > audit_timeout) {
2430 smb_time_audit_log_fsp("sys_acl_delete_def_fd", timediff, fsp);
2436 struct smb_time_audit_getxattrat_state {
2437 struct vfs_aio_state aio_state;
2438 files_struct *dir_fsp;
2439 const struct smb_filename *smb_fname;
2440 const char *xattr_name;
2442 uint8_t *xattr_value;
2445 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq);
2447 static struct tevent_req *smb_time_audit_getxattrat_send(
2448 TALLOC_CTX *mem_ctx,
2449 struct tevent_context *ev,
2450 struct vfs_handle_struct *handle,
2451 files_struct *dir_fsp,
2452 const struct smb_filename *smb_fname,
2453 const char *xattr_name,
2456 struct tevent_req *req = NULL;
2457 struct tevent_req *subreq = NULL;
2458 struct smb_time_audit_getxattrat_state *state = NULL;
2460 req = tevent_req_create(mem_ctx, &state,
2461 struct smb_time_audit_getxattrat_state);
2465 *state = (struct smb_time_audit_getxattrat_state) {
2467 .smb_fname = smb_fname,
2468 .xattr_name = xattr_name,
2471 subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
2478 if (tevent_req_nomem(subreq, req)) {
2479 return tevent_req_post(req, ev);
2481 tevent_req_set_callback(subreq, smb_time_audit_getxattrat_done, req);
2486 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq)
2488 struct tevent_req *req = tevent_req_callback_data(
2489 subreq, struct tevent_req);
2490 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2491 req, struct smb_time_audit_getxattrat_state);
2493 state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
2496 &state->xattr_value);
2497 TALLOC_FREE(subreq);
2498 if (state->xattr_size == -1) {
2499 tevent_req_error(req, state->aio_state.error);
2503 tevent_req_done(req);
2506 static ssize_t smb_time_audit_getxattrat_recv(struct tevent_req *req,
2507 struct vfs_aio_state *aio_state,
2508 TALLOC_CTX *mem_ctx,
2509 uint8_t **xattr_value)
2511 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2512 req, struct smb_time_audit_getxattrat_state);
2516 timediff = state->aio_state.duration * 1.0e-9;
2518 if (timediff > audit_timeout) {
2519 smb_time_audit_log_at("async getxattrat",
2525 if (tevent_req_is_unix_error(req, &aio_state->error)) {
2526 tevent_req_received(req);
2530 *aio_state = state->aio_state;
2531 xattr_size = state->xattr_size;
2532 if (xattr_value != NULL) {
2533 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
2536 tevent_req_received(req);
2540 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2541 struct files_struct *fsp,
2542 const char *name, void *value,
2546 struct timespec ts1,ts2;
2549 clock_gettime_mono(&ts1);
2550 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2551 clock_gettime_mono(&ts2);
2552 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2554 if (timediff > audit_timeout) {
2555 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2561 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2562 struct files_struct *fsp, char *list,
2566 struct timespec ts1,ts2;
2569 clock_gettime_mono(&ts1);
2570 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2571 clock_gettime_mono(&ts2);
2572 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2574 if (timediff > audit_timeout) {
2575 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2581 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2582 struct files_struct *fsp,
2586 struct timespec ts1,ts2;
2589 clock_gettime_mono(&ts1);
2590 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2591 clock_gettime_mono(&ts2);
2592 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2594 if (timediff > audit_timeout) {
2595 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2601 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2602 struct files_struct *fsp, const char *name,
2603 const void *value, size_t size, int flags)
2606 struct timespec ts1,ts2;
2609 clock_gettime_mono(&ts1);
2610 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2611 clock_gettime_mono(&ts2);
2612 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2614 if (timediff > audit_timeout) {
2615 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2621 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2622 struct files_struct *fsp)
2625 struct timespec ts1,ts2;
2628 clock_gettime_mono(&ts1);
2629 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2630 clock_gettime_mono(&ts2);
2631 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2633 if (timediff > audit_timeout) {
2634 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2640 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2641 struct files_struct *fsp,
2642 TALLOC_CTX *mem_ctx,
2646 struct timespec ts1,ts2;
2649 clock_gettime_mono(&ts1);
2650 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2651 clock_gettime_mono(&ts2);
2652 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2654 if (timediff > audit_timeout) {
2655 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2661 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2662 struct files_struct *fsp,
2663 const DATA_BLOB old_cookie,
2664 TALLOC_CTX *mem_ctx,
2665 DATA_BLOB *new_cookie)
2668 struct timespec ts1,ts2;
2671 clock_gettime_mono(&ts1);
2672 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2673 mem_ctx, new_cookie);
2674 clock_gettime_mono(&ts2);
2675 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2677 if (timediff > audit_timeout) {
2678 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2684 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2685 struct smb_request *smb1req,
2686 struct smbXsrv_open *op,
2687 const DATA_BLOB old_cookie,
2688 TALLOC_CTX *mem_ctx,
2689 struct files_struct **fsp,
2690 DATA_BLOB *new_cookie)
2693 struct timespec ts1,ts2;
2696 clock_gettime_mono(&ts1);
2697 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2698 mem_ctx, fsp, new_cookie);
2699 clock_gettime_mono(&ts2);
2700 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2702 if (timediff > audit_timeout) {
2703 smb_time_audit_log("durable_reconnect", timediff);
2709 /* VFS operations */
2711 static struct vfs_fn_pointers vfs_time_audit_fns = {
2712 .connect_fn = smb_time_audit_connect,
2713 .disconnect_fn = smb_time_audit_disconnect,
2714 .disk_free_fn = smb_time_audit_disk_free,
2715 .get_quota_fn = smb_time_audit_get_quota,
2716 .set_quota_fn = smb_time_audit_set_quota,
2717 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2718 .statvfs_fn = smb_time_audit_statvfs,
2719 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2720 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2721 .create_dfs_pathat_fn = smb_time_audit_create_dfs_pathat,
2722 .read_dfs_pathat_fn = smb_time_audit_read_dfs_pathat,
2723 .fdopendir_fn = smb_time_audit_fdopendir,
2724 .readdir_fn = smb_time_audit_readdir,
2725 .seekdir_fn = smb_time_audit_seekdir,
2726 .telldir_fn = smb_time_audit_telldir,
2727 .rewind_dir_fn = smb_time_audit_rewinddir,
2728 .mkdirat_fn = smb_time_audit_mkdirat,
2729 .closedir_fn = smb_time_audit_closedir,
2730 .openat_fn = smb_time_audit_openat,
2731 .create_file_fn = smb_time_audit_create_file,
2732 .close_fn = smb_time_audit_close,
2733 .pread_fn = smb_time_audit_pread,
2734 .pread_send_fn = smb_time_audit_pread_send,
2735 .pread_recv_fn = smb_time_audit_pread_recv,
2736 .pwrite_fn = smb_time_audit_pwrite,
2737 .pwrite_send_fn = smb_time_audit_pwrite_send,
2738 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2739 .lseek_fn = smb_time_audit_lseek,
2740 .sendfile_fn = smb_time_audit_sendfile,
2741 .recvfile_fn = smb_time_audit_recvfile,
2742 .renameat_fn = smb_time_audit_renameat,
2743 .fsync_send_fn = smb_time_audit_fsync_send,
2744 .fsync_recv_fn = smb_time_audit_fsync_recv,
2745 .stat_fn = smb_time_audit_stat,
2746 .fstat_fn = smb_time_audit_fstat,
2747 .lstat_fn = smb_time_audit_lstat,
2748 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2749 .unlinkat_fn = smb_time_audit_unlinkat,
2750 .fchmod_fn = smb_time_audit_fchmod,
2751 .fchown_fn = smb_time_audit_fchown,
2752 .lchown_fn = smb_time_audit_lchown,
2753 .chdir_fn = smb_time_audit_chdir,
2754 .getwd_fn = smb_time_audit_getwd,
2755 .fntimes_fn = smb_time_audit_fntimes,
2756 .ftruncate_fn = smb_time_audit_ftruncate,
2757 .fallocate_fn = smb_time_audit_fallocate,
2758 .lock_fn = smb_time_audit_lock,
2759 .filesystem_sharemode_fn = smb_time_audit_filesystem_sharemode,
2760 .fcntl_fn = smb_time_audit_fcntl,
2761 .linux_setlease_fn = smb_time_audit_linux_setlease,
2762 .getlock_fn = smb_time_audit_getlock,
2763 .symlinkat_fn = smb_time_audit_symlinkat,
2764 .readlinkat_fn = smb_time_audit_readlinkat,
2765 .linkat_fn = smb_time_audit_linkat,
2766 .mknodat_fn = smb_time_audit_mknodat,
2767 .realpath_fn = smb_time_audit_realpath,
2768 .fchflags_fn = smb_time_audit_fchflags,
2769 .file_id_create_fn = smb_time_audit_file_id_create,
2770 .fs_file_id_fn = smb_time_audit_fs_file_id,
2771 .offload_read_send_fn = smb_time_audit_offload_read_send,
2772 .offload_read_recv_fn = smb_time_audit_offload_read_recv,
2773 .offload_write_send_fn = smb_time_audit_offload_write_send,
2774 .offload_write_recv_fn = smb_time_audit_offload_write_recv,
2775 .fget_compression_fn = smb_time_audit_fget_compression,
2776 .set_compression_fn = smb_time_audit_set_compression,
2777 .snap_check_path_fn = smb_time_audit_snap_check_path,
2778 .snap_create_fn = smb_time_audit_snap_create,
2779 .snap_delete_fn = smb_time_audit_snap_delete,
2780 .fstreaminfo_fn = smb_time_audit_fstreaminfo,
2781 .get_real_filename_fn = smb_time_audit_get_real_filename,
2782 .connectpath_fn = smb_time_audit_connectpath,
2783 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2784 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2785 .strict_lock_check_fn = smb_time_audit_strict_lock_check,
2786 .translate_name_fn = smb_time_audit_translate_name,
2787 .parent_pathname_fn = smb_time_audit_parent_pathname,
2788 .fsctl_fn = smb_time_audit_fsctl,
2789 .get_dos_attributes_send_fn = smb_time_audit_get_dos_attributes_send,
2790 .get_dos_attributes_recv_fn = smb_time_audit_get_dos_attributes_recv,
2791 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2792 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2793 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2794 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2795 .audit_file_fn = smb_time_audit_audit_file,
2796 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2797 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2798 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2799 .sys_acl_delete_def_fd_fn = smb_time_audit_sys_acl_delete_def_fd,
2800 .getxattrat_send_fn = smb_time_audit_getxattrat_send,
2801 .getxattrat_recv_fn = smb_time_audit_getxattrat_recv,
2802 .fgetxattr_fn = smb_time_audit_fgetxattr,
2803 .flistxattr_fn = smb_time_audit_flistxattr,
2804 .fremovexattr_fn = smb_time_audit_fremovexattr,
2805 .fsetxattr_fn = smb_time_audit_fsetxattr,
2806 .aio_force_fn = smb_time_audit_aio_force,
2807 .durable_cookie_fn = smb_time_audit_durable_cookie,
2808 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2809 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2810 .freaddir_attr_fn = smb_time_audit_freaddir_attr,
2815 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2817 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2819 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2821 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2822 &vfs_time_audit_fns);