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,
494 struct dirent *result;
495 struct timespec ts1,ts2;
498 clock_gettime_mono(&ts1);
499 result = SMB_VFS_NEXT_READDIR(handle, dirfsp, dirp);
500 clock_gettime_mono(&ts2);
501 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
503 if (timediff > audit_timeout) {
504 smb_time_audit_log("readdir", timediff);
510 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
513 struct timespec ts1,ts2;
516 clock_gettime_mono(&ts1);
517 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
518 clock_gettime_mono(&ts2);
519 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
521 if (timediff > audit_timeout) {
522 smb_time_audit_log("rewinddir", timediff);
527 static int smb_time_audit_mkdirat(vfs_handle_struct *handle,
528 struct files_struct *dirfsp,
529 const struct smb_filename *smb_fname,
532 struct smb_filename *full_fname = NULL;
534 struct timespec ts1,ts2;
537 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
540 if (full_fname == NULL) {
545 clock_gettime_mono(&ts1);
546 result = SMB_VFS_NEXT_MKDIRAT(handle,
550 clock_gettime_mono(&ts2);
551 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
553 if (timediff > audit_timeout) {
554 smb_time_audit_log_smb_fname("mkdirat",
559 TALLOC_FREE(full_fname);
564 static int smb_time_audit_closedir(vfs_handle_struct *handle,
568 struct timespec ts1,ts2;
571 clock_gettime_mono(&ts1);
572 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
573 clock_gettime_mono(&ts2);
574 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
576 if (timediff > audit_timeout) {
577 smb_time_audit_log("closedir", timediff);
583 static int smb_time_audit_openat(vfs_handle_struct *handle,
584 const struct files_struct *dirfsp,
585 const struct smb_filename *smb_fname,
586 struct files_struct *fsp,
587 const struct vfs_open_how *how)
590 struct timespec ts1,ts2;
593 clock_gettime_mono(&ts1);
594 result = SMB_VFS_NEXT_OPENAT(handle,
599 clock_gettime_mono(&ts2);
600 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
602 if (timediff > audit_timeout) {
603 smb_time_audit_log_fsp("openat", timediff, fsp);
609 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
610 struct smb_request *req,
611 struct files_struct *dirfsp,
612 struct smb_filename *fname,
613 uint32_t access_mask,
614 uint32_t share_access,
615 uint32_t create_disposition,
616 uint32_t create_options,
617 uint32_t file_attributes,
618 uint32_t oplock_request,
619 const struct smb2_lease *lease,
620 uint64_t allocation_size,
621 uint32_t private_flags,
622 struct security_descriptor *sd,
623 struct ea_list *ea_list,
624 files_struct **result_fsp,
626 const struct smb2_create_blobs *in_context_blobs,
627 struct smb2_create_blobs *out_context_blobs)
630 struct timespec ts1,ts2;
633 clock_gettime_mono(&ts1);
634 result = SMB_VFS_NEXT_CREATE_FILE(
639 access_mask, /* access_mask */
640 share_access, /* share_access */
641 create_disposition, /* create_disposition*/
642 create_options, /* create_options */
643 file_attributes, /* file_attributes */
644 oplock_request, /* oplock_request */
646 allocation_size, /* allocation_size */
649 ea_list, /* ea_list */
650 result_fsp, /* result */
652 in_context_blobs, out_context_blobs); /* create context */
653 clock_gettime_mono(&ts2);
654 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
656 if (timediff > audit_timeout) {
658 * can't use result_fsp this time, may have
659 * invalid content causing smbd crash
661 smb_time_audit_log_smb_fname("create_file", timediff,
668 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
671 struct timespec ts1,ts2;
674 clock_gettime_mono(&ts1);
675 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
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("close", 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_pwrite(vfs_handle_struct *handle,
772 const void *data, size_t n,
776 struct timespec ts1,ts2;
779 clock_gettime_mono(&ts1);
780 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
781 clock_gettime_mono(&ts2);
782 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
784 if (timediff > audit_timeout) {
785 smb_time_audit_log_fsp("pwrite", timediff, fsp);
791 struct smb_time_audit_pwrite_state {
792 struct files_struct *fsp;
794 struct vfs_aio_state vfs_aio_state;
797 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
799 static struct tevent_req *smb_time_audit_pwrite_send(
800 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
801 struct tevent_context *ev, struct files_struct *fsp,
802 const void *data, size_t n, off_t offset)
804 struct tevent_req *req, *subreq;
805 struct smb_time_audit_pwrite_state *state;
807 req = tevent_req_create(mem_ctx, &state,
808 struct smb_time_audit_pwrite_state);
814 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
816 if (tevent_req_nomem(subreq, req)) {
817 return tevent_req_post(req, ev);
819 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
823 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
825 struct tevent_req *req = tevent_req_callback_data(
826 subreq, struct tevent_req);
827 struct smb_time_audit_pwrite_state *state = tevent_req_data(
828 req, struct smb_time_audit_pwrite_state);
830 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->vfs_aio_state);
832 tevent_req_done(req);
835 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req,
836 struct vfs_aio_state *vfs_aio_state)
838 struct smb_time_audit_pwrite_state *state = tevent_req_data(
839 req, struct smb_time_audit_pwrite_state);
842 timediff = state->vfs_aio_state.duration * 1.0e-9;
844 if (timediff > audit_timeout) {
845 smb_time_audit_log_fsp("async pwrite", timediff, state->fsp);
848 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
851 *vfs_aio_state = state->vfs_aio_state;
855 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
857 off_t offset, int whence)
860 struct timespec ts1,ts2;
863 clock_gettime_mono(&ts1);
864 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
865 clock_gettime_mono(&ts2);
866 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
868 if (timediff > audit_timeout) {
869 smb_time_audit_log_fsp("lseek", timediff, fsp);
875 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
876 files_struct *fromfsp,
877 const DATA_BLOB *hdr, off_t offset,
881 struct timespec ts1,ts2;
884 clock_gettime_mono(&ts1);
885 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
886 clock_gettime_mono(&ts2);
887 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
889 if (timediff > audit_timeout) {
890 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
896 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
902 struct timespec ts1,ts2;
905 clock_gettime_mono(&ts1);
906 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
907 clock_gettime_mono(&ts2);
908 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
910 if (timediff > audit_timeout) {
911 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
917 static int smb_time_audit_renameat(vfs_handle_struct *handle,
918 files_struct *srcfsp,
919 const struct smb_filename *oldname,
920 files_struct *dstfsp,
921 const struct smb_filename *newname)
924 struct timespec ts1,ts2;
926 struct smb_filename *new_full_fname = NULL;
928 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
931 if (new_full_fname == NULL) {
935 clock_gettime_mono(&ts1);
936 result = SMB_VFS_NEXT_RENAMEAT(handle,
941 clock_gettime_mono(&ts2);
942 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
944 if (timediff > audit_timeout) {
945 smb_time_audit_log_smb_fname("renameat",
950 TALLOC_FREE(new_full_fname);
954 struct smb_time_audit_fsync_state {
955 struct files_struct *fsp;
957 struct vfs_aio_state vfs_aio_state;
960 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
962 static struct tevent_req *smb_time_audit_fsync_send(
963 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
964 struct tevent_context *ev, struct files_struct *fsp)
966 struct tevent_req *req, *subreq;
967 struct smb_time_audit_fsync_state *state;
969 req = tevent_req_create(mem_ctx, &state,
970 struct smb_time_audit_fsync_state);
976 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
977 if (tevent_req_nomem(subreq, req)) {
978 return tevent_req_post(req, ev);
980 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
984 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
986 struct tevent_req *req = tevent_req_callback_data(
987 subreq, struct tevent_req);
988 struct smb_time_audit_fsync_state *state = tevent_req_data(
989 req, struct smb_time_audit_fsync_state);
991 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->vfs_aio_state);
993 tevent_req_done(req);
996 static int smb_time_audit_fsync_recv(struct tevent_req *req,
997 struct vfs_aio_state *vfs_aio_state)
999 struct smb_time_audit_fsync_state *state = tevent_req_data(
1000 req, struct smb_time_audit_fsync_state);
1003 timediff = state->vfs_aio_state.duration * 1.0e-9;
1005 if (timediff > audit_timeout) {
1006 smb_time_audit_log_fsp("async fsync", timediff, state->fsp);
1009 if (tevent_req_is_unix_error(req, &vfs_aio_state->error)) {
1012 *vfs_aio_state = state->vfs_aio_state;
1016 static int smb_time_audit_stat(vfs_handle_struct *handle,
1017 struct smb_filename *fname)
1020 struct timespec ts1,ts2;
1023 clock_gettime_mono(&ts1);
1024 result = SMB_VFS_NEXT_STAT(handle, fname);
1025 clock_gettime_mono(&ts2);
1026 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1028 if (timediff > audit_timeout) {
1029 smb_time_audit_log_smb_fname("stat", timediff, fname);
1035 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
1036 SMB_STRUCT_STAT *sbuf)
1039 struct timespec ts1,ts2;
1042 clock_gettime_mono(&ts1);
1043 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1044 clock_gettime_mono(&ts2);
1045 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1047 if (timediff > audit_timeout) {
1048 smb_time_audit_log_fsp("fstat", timediff, fsp);
1054 static int smb_time_audit_lstat(vfs_handle_struct *handle,
1055 struct smb_filename *path)
1058 struct timespec ts1,ts2;
1061 clock_gettime_mono(&ts1);
1062 result = SMB_VFS_NEXT_LSTAT(handle, path);
1063 clock_gettime_mono(&ts2);
1064 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1066 if (timediff > audit_timeout) {
1067 smb_time_audit_log_smb_fname("lstat", timediff, path);
1073 static int smb_time_audit_fstatat(
1074 struct vfs_handle_struct *handle,
1075 const struct files_struct *dirfsp,
1076 const struct smb_filename *smb_fname,
1077 SMB_STRUCT_STAT *sbuf,
1081 struct timespec ts1,ts2;
1084 clock_gettime_mono(&ts1);
1085 result = SMB_VFS_NEXT_FSTATAT(handle, dirfsp, smb_fname, sbuf, flags);
1086 clock_gettime_mono(&ts2);
1087 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1089 if (timediff > audit_timeout) {
1090 smb_time_audit_log_smb_fname("fstatat", timediff, smb_fname);
1096 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
1098 const SMB_STRUCT_STAT *sbuf)
1101 struct timespec ts1,ts2;
1104 clock_gettime_mono(&ts1);
1105 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1106 clock_gettime_mono(&ts2);
1107 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1109 if (timediff > audit_timeout) {
1110 smb_time_audit_log_fsp("get_alloc_size", timediff, fsp);
1116 static int smb_time_audit_unlinkat(vfs_handle_struct *handle,
1117 struct files_struct *dirfsp,
1118 const struct smb_filename *path,
1121 struct smb_filename *full_fname = NULL;
1123 struct timespec ts1,ts2;
1126 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1129 if (full_fname == NULL) {
1133 clock_gettime_mono(&ts1);
1134 result = SMB_VFS_NEXT_UNLINKAT(handle,
1138 clock_gettime_mono(&ts2);
1139 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1141 if (timediff > audit_timeout) {
1142 smb_time_audit_log_smb_fname("unlinkat", timediff, full_fname);
1145 TALLOC_FREE(full_fname);
1149 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1153 struct timespec ts1,ts2;
1156 clock_gettime_mono(&ts1);
1157 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1158 clock_gettime_mono(&ts2);
1159 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1161 if (timediff > audit_timeout) {
1162 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1168 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1169 uid_t uid, gid_t gid)
1172 struct timespec ts1,ts2;
1175 clock_gettime_mono(&ts1);
1176 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1177 clock_gettime_mono(&ts2);
1178 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1180 if (timediff > audit_timeout) {
1181 smb_time_audit_log_fsp("fchown", timediff, fsp);
1187 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1188 const struct smb_filename *smb_fname,
1193 struct timespec ts1,ts2;
1196 clock_gettime_mono(&ts1);
1197 result = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
1198 clock_gettime_mono(&ts2);
1199 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1201 if (timediff > audit_timeout) {
1202 smb_time_audit_log_fname("lchown",
1204 smb_fname->base_name);
1210 static int smb_time_audit_chdir(vfs_handle_struct *handle,
1211 const struct smb_filename *smb_fname)
1214 struct timespec ts1,ts2;
1217 clock_gettime_mono(&ts1);
1218 result = SMB_VFS_NEXT_CHDIR(handle, smb_fname);
1219 clock_gettime_mono(&ts2);
1220 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1222 if (timediff > audit_timeout) {
1223 smb_time_audit_log_fname("chdir",
1225 smb_fname->base_name);
1231 static struct smb_filename *smb_time_audit_getwd(vfs_handle_struct *handle,
1232 TALLOC_CTX *mem_ctx)
1234 struct smb_filename *result;
1235 struct timespec ts1,ts2;
1238 clock_gettime_mono(&ts1);
1239 result = SMB_VFS_NEXT_GETWD(handle, mem_ctx);
1240 clock_gettime_mono(&ts2);
1241 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1243 if (timediff > audit_timeout) {
1244 smb_time_audit_log("getwd", timediff);
1250 static int smb_time_audit_fntimes(vfs_handle_struct *handle,
1252 struct smb_file_time *ft)
1255 struct timespec ts1,ts2;
1258 clock_gettime_mono(&ts1);
1259 result = SMB_VFS_NEXT_FNTIMES(handle, fsp, ft);
1260 clock_gettime_mono(&ts2);
1261 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
1263 if (timediff > audit_timeout) {
1264 smb_time_audit_log_fsp("fntimes", timediff, fsp);
1270 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1275 struct timespec ts1,ts2;
1278 clock_gettime_mono(&ts1);
1279 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1280 clock_gettime_mono(&ts2);
1281 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1283 if (timediff > audit_timeout) {
1284 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1290 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1297 int saved_errno = 0;
1298 struct timespec ts1,ts2;
1301 clock_gettime_mono(&ts1);
1302 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1304 saved_errno = errno;
1306 clock_gettime_mono(&ts2);
1307 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1309 if (timediff > audit_timeout) {
1310 smb_time_audit_log_fsp("fallocate", timediff, fsp);
1313 errno = saved_errno;
1318 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1319 int op, off_t offset, off_t count,
1323 struct timespec ts1,ts2;
1326 clock_gettime_mono(&ts1);
1327 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1328 clock_gettime_mono(&ts2);
1329 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1331 if (timediff > audit_timeout) {
1332 smb_time_audit_log_fsp("lock", timediff, fsp);
1338 static int smb_time_audit_filesystem_sharemode(struct vfs_handle_struct *handle,
1339 struct files_struct *fsp,
1340 uint32_t share_access,
1341 uint32_t access_mask)
1344 struct timespec ts1,ts2;
1347 clock_gettime_mono(&ts1);
1348 result = SMB_VFS_NEXT_FILESYSTEM_SHAREMODE(handle,
1352 clock_gettime_mono(&ts2);
1353 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1355 if (timediff > audit_timeout) {
1356 smb_time_audit_log_fsp("filesystem_sharemode", timediff, fsp);
1362 static int smb_time_audit_fcntl(struct vfs_handle_struct *handle,
1363 struct files_struct *fsp,
1364 int cmd, va_list cmd_arg)
1367 va_list dup_cmd_arg;
1369 struct timespec ts1,ts2;
1372 va_copy(dup_cmd_arg, cmd_arg);
1373 arg = va_arg(dup_cmd_arg, void *);
1374 clock_gettime_mono(&ts1);
1375 result = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
1376 clock_gettime_mono(&ts2);
1377 va_end(dup_cmd_arg);
1379 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1380 if (timediff > audit_timeout) {
1381 smb_time_audit_log_fsp("fcntl", timediff, fsp);
1387 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1392 struct timespec ts1,ts2;
1395 clock_gettime_mono(&ts1);
1396 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1397 clock_gettime_mono(&ts2);
1398 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1400 if (timediff > audit_timeout) {
1401 smb_time_audit_log_fsp("linux_setlease", timediff, fsp);
1407 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1409 off_t *poffset, off_t *pcount,
1410 int *ptype, pid_t *ppid)
1413 struct timespec ts1,ts2;
1416 clock_gettime_mono(&ts1);
1417 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1419 clock_gettime_mono(&ts2);
1420 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1422 if (timediff > audit_timeout) {
1423 smb_time_audit_log_fsp("getlock", timediff, fsp);
1429 static int smb_time_audit_symlinkat(vfs_handle_struct *handle,
1430 const struct smb_filename *link_contents,
1431 struct files_struct *dirfsp,
1432 const struct smb_filename *new_smb_fname)
1434 struct smb_filename *full_fname = NULL;
1436 struct timespec ts1,ts2;
1439 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1442 if (full_fname == NULL) {
1447 clock_gettime_mono(&ts1);
1448 result = SMB_VFS_NEXT_SYMLINKAT(handle,
1452 clock_gettime_mono(&ts2);
1453 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1455 if (timediff > audit_timeout) {
1456 smb_time_audit_log_fname("symlinkat", timediff,
1457 full_fname->base_name);
1460 TALLOC_FREE(full_fname);
1464 static int smb_time_audit_readlinkat(vfs_handle_struct *handle,
1465 const struct files_struct *dirfsp,
1466 const struct smb_filename *smb_fname,
1470 struct smb_filename *full_fname = NULL;
1472 struct timespec ts1,ts2;
1475 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1478 if (full_fname == NULL) {
1483 clock_gettime_mono(&ts1);
1484 result = SMB_VFS_NEXT_READLINKAT(handle,
1489 clock_gettime_mono(&ts2);
1490 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1492 if (timediff > audit_timeout) {
1493 smb_time_audit_log_fname("readlinkat", timediff,
1494 full_fname->base_name);
1497 TALLOC_FREE(full_fname);
1501 static int smb_time_audit_linkat(vfs_handle_struct *handle,
1502 files_struct *srcfsp,
1503 const struct smb_filename *old_smb_fname,
1504 files_struct *dstfsp,
1505 const struct smb_filename *new_smb_fname,
1508 struct smb_filename *new_full_fname = NULL;
1510 struct timespec ts1,ts2;
1513 new_full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1516 if (new_full_fname == NULL) {
1521 clock_gettime_mono(&ts1);
1522 result = SMB_VFS_NEXT_LINKAT(handle,
1528 clock_gettime_mono(&ts2);
1529 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1531 if (timediff > audit_timeout) {
1532 smb_time_audit_log_fname("linkat", timediff,
1533 new_full_fname->base_name);
1536 TALLOC_FREE(new_full_fname);
1540 static int smb_time_audit_mknodat(vfs_handle_struct *handle,
1541 files_struct *dirfsp,
1542 const struct smb_filename *smb_fname,
1546 struct smb_filename *full_fname = NULL;
1548 struct timespec ts1,ts2;
1551 full_fname = full_path_from_dirfsp_atname(talloc_tos(),
1554 if (full_fname == NULL) {
1559 clock_gettime_mono(&ts1);
1560 result = SMB_VFS_NEXT_MKNODAT(handle,
1565 clock_gettime_mono(&ts2);
1566 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1568 if (timediff > audit_timeout) {
1569 smb_time_audit_log_smb_fname("mknodat", timediff, full_fname);
1572 TALLOC_FREE(full_fname);
1576 static struct smb_filename *smb_time_audit_realpath(vfs_handle_struct *handle,
1578 const struct smb_filename *smb_fname)
1580 struct smb_filename *result_fname;
1581 struct timespec ts1,ts2;
1584 clock_gettime_mono(&ts1);
1585 result_fname = SMB_VFS_NEXT_REALPATH(handle, ctx, smb_fname);
1586 clock_gettime_mono(&ts2);
1587 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1589 if (timediff > audit_timeout) {
1590 smb_time_audit_log_fname("realpath", timediff,
1591 smb_fname->base_name);
1594 return result_fname;
1597 static int smb_time_audit_fchflags(vfs_handle_struct *handle,
1598 struct files_struct *fsp,
1602 struct timespec ts1,ts2;
1605 clock_gettime_mono(&ts1);
1606 result = SMB_VFS_NEXT_FCHFLAGS(handle, fsp, flags);
1607 clock_gettime_mono(&ts2);
1608 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1610 if (timediff > audit_timeout) {
1611 smb_time_audit_log_smb_fname("chflags",
1619 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1620 const SMB_STRUCT_STAT *sbuf)
1622 struct file_id id_zero;
1623 struct file_id result;
1624 struct timespec ts1,ts2;
1627 ZERO_STRUCT(id_zero);
1629 clock_gettime_mono(&ts1);
1630 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1631 clock_gettime_mono(&ts2);
1632 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1634 if (timediff > audit_timeout) {
1635 smb_time_audit_log("file_id_create", timediff);
1641 static uint64_t smb_time_audit_fs_file_id(struct vfs_handle_struct *handle,
1642 const SMB_STRUCT_STAT *sbuf)
1645 struct timespec ts1,ts2;
1648 clock_gettime_mono(&ts1);
1649 result = SMB_VFS_NEXT_FS_FILE_ID(handle, sbuf);
1650 clock_gettime_mono(&ts2);
1651 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1653 if (timediff > audit_timeout) {
1654 smb_time_audit_log("fs_file_id", timediff);
1660 static NTSTATUS smb_time_audit_fstreaminfo(vfs_handle_struct *handle,
1661 struct files_struct *fsp,
1662 TALLOC_CTX *mem_ctx,
1663 unsigned int *pnum_streams,
1664 struct stream_struct **pstreams)
1667 struct timespec ts1,ts2;
1670 clock_gettime_mono(&ts1);
1671 result = SMB_VFS_NEXT_FSTREAMINFO(handle, fsp, mem_ctx,
1672 pnum_streams, pstreams);
1673 clock_gettime_mono(&ts2);
1674 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1676 if (timediff > audit_timeout) {
1677 smb_time_audit_log_fsp("fstreaminfo", timediff, fsp);
1683 static NTSTATUS smb_time_audit_get_real_filename_at(
1684 struct vfs_handle_struct *handle,
1685 struct files_struct *dirfsp,
1687 TALLOC_CTX *mem_ctx,
1691 struct timespec ts1,ts2;
1694 clock_gettime_mono(&ts1);
1695 result = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
1696 handle, dirfsp, name, mem_ctx, found_name);
1697 clock_gettime_mono(&ts2);
1698 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1700 if (timediff > audit_timeout) {
1701 smb_time_audit_log_fname("get_real_filename_at",
1703 fsp_str_dbg(dirfsp));
1709 static const char *smb_time_audit_connectpath(
1710 vfs_handle_struct *handle,
1711 const struct files_struct *dirfsp,
1712 const struct smb_filename *smb_fname)
1715 struct timespec ts1,ts2;
1718 clock_gettime_mono(&ts1);
1719 result = SMB_VFS_NEXT_CONNECTPATH(handle, dirfsp, smb_fname);
1720 clock_gettime_mono(&ts2);
1721 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1723 if (timediff > audit_timeout) {
1724 smb_time_audit_log_fname("connectpath", timediff,
1725 smb_fname->base_name);
1731 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1732 struct byte_range_lock *br_lck,
1733 struct lock_struct *plock)
1736 struct timespec ts1,ts2;
1739 clock_gettime_mono(&ts1);
1740 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock);
1741 clock_gettime_mono(&ts2);
1742 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1744 if (timediff > audit_timeout) {
1745 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1752 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1753 struct byte_range_lock *br_lck,
1754 const struct lock_struct *plock)
1757 struct timespec ts1,ts2;
1760 clock_gettime_mono(&ts1);
1761 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, br_lck, plock);
1762 clock_gettime_mono(&ts2);
1763 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1765 if (timediff > audit_timeout) {
1766 smb_time_audit_log_fsp("brl_unlock_windows", timediff,
1773 static bool smb_time_audit_strict_lock_check(struct vfs_handle_struct *handle,
1774 struct files_struct *fsp,
1775 struct lock_struct *plock)
1778 struct timespec ts1,ts2;
1781 clock_gettime_mono(&ts1);
1782 result = SMB_VFS_NEXT_STRICT_LOCK_CHECK(handle, fsp, plock);
1783 clock_gettime_mono(&ts2);
1784 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1786 if (timediff > audit_timeout) {
1787 smb_time_audit_log_fsp("strict_lock_check", timediff, fsp);
1793 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1795 enum vfs_translate_direction direction,
1796 TALLOC_CTX *mem_ctx,
1800 struct timespec ts1,ts2;
1803 clock_gettime_mono(&ts1);
1804 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1806 clock_gettime_mono(&ts2);
1807 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1809 if (timediff > audit_timeout) {
1810 smb_time_audit_log_fname("translate_name", timediff, name);
1816 static NTSTATUS smb_time_audit_parent_pathname(struct vfs_handle_struct *handle,
1817 TALLOC_CTX *mem_ctx,
1818 const struct smb_filename *smb_fname_in,
1819 struct smb_filename **parent_dir_out,
1820 struct smb_filename **atname_out)
1823 struct timespec ts1,ts2;
1826 clock_gettime_mono(&ts1);
1827 result = SMB_VFS_NEXT_PARENT_PATHNAME(handle,
1832 clock_gettime_mono(&ts2);
1833 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1835 if (timediff > audit_timeout) {
1836 smb_time_audit_log_fname("parent_pathname",
1838 smb_fname_in->base_name);
1844 static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
1845 struct files_struct *fsp,
1849 const uint8_t *_in_data,
1851 uint8_t **_out_data,
1852 uint32_t max_out_len,
1856 struct timespec ts1,ts2;
1859 clock_gettime_mono(&ts1);
1860 result = SMB_VFS_NEXT_FSCTL(handle,
1870 clock_gettime_mono(&ts2);
1871 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1873 if (timediff > audit_timeout) {
1874 smb_time_audit_log_fsp("fsctl", timediff, fsp);
1880 struct smb_time_audit_get_dos_attributes_state {
1881 struct vfs_aio_state aio_state;
1882 files_struct *dir_fsp;
1883 const struct smb_filename *smb_fname;
1887 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq);
1889 static struct tevent_req *smb_time_audit_get_dos_attributes_send(
1890 TALLOC_CTX *mem_ctx,
1891 struct tevent_context *ev,
1892 struct vfs_handle_struct *handle,
1893 files_struct *dir_fsp,
1894 struct smb_filename *smb_fname)
1896 struct tevent_req *req = NULL;
1897 struct smb_time_audit_get_dos_attributes_state *state = NULL;
1898 struct tevent_req *subreq = NULL;
1900 req = tevent_req_create(mem_ctx, &state,
1901 struct smb_time_audit_get_dos_attributes_state);
1905 *state = (struct smb_time_audit_get_dos_attributes_state) {
1907 .smb_fname = smb_fname,
1910 subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
1915 if (tevent_req_nomem(subreq, req)) {
1916 return tevent_req_post(req, ev);
1918 tevent_req_set_callback(subreq,
1919 smb_time_audit_get_dos_attributes_done,
1925 static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq)
1927 struct tevent_req *req =
1928 tevent_req_callback_data(subreq,
1930 struct smb_time_audit_get_dos_attributes_state *state =
1931 tevent_req_data(req,
1932 struct smb_time_audit_get_dos_attributes_state);
1935 status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
1938 TALLOC_FREE(subreq);
1939 if (tevent_req_nterror(req, status)) {
1943 tevent_req_done(req);
1947 static NTSTATUS smb_time_audit_get_dos_attributes_recv(struct tevent_req *req,
1948 struct vfs_aio_state *aio_state,
1951 struct smb_time_audit_get_dos_attributes_state *state =
1952 tevent_req_data(req,
1953 struct smb_time_audit_get_dos_attributes_state);
1957 timediff = state->aio_state.duration * 1.0e-9;
1959 if (timediff > audit_timeout) {
1960 smb_time_audit_log_at("async get_dos_attributes",
1966 if (tevent_req_is_nterror(req, &status)) {
1967 tevent_req_received(req);
1971 *aio_state = state->aio_state;
1972 *dosmode = state->dosmode;
1973 tevent_req_received(req);
1974 return NT_STATUS_OK;
1977 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
1978 struct files_struct *fsp,
1982 struct timespec ts1,ts2;
1985 clock_gettime_mono(&ts1);
1986 result = SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle,
1989 clock_gettime_mono(&ts2);
1990 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1992 if (timediff > audit_timeout) {
1993 smb_time_audit_log_fsp("fget_dos_attributes", timediff, fsp);
1999 static NTSTATUS smb_time_fset_dos_attributes(struct vfs_handle_struct *handle,
2000 struct files_struct *fsp,
2004 struct timespec ts1,ts2;
2007 clock_gettime_mono(&ts1);
2008 result = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle,
2011 clock_gettime_mono(&ts2);
2012 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2014 if (timediff > audit_timeout) {
2015 smb_time_audit_log_fsp("fset_dos_attributes", timediff, fsp);
2021 struct time_audit_offload_read_state {
2022 struct vfs_handle_struct *handle;
2023 struct timespec ts_send;
2026 DATA_BLOB token_blob;
2029 static void smb_time_audit_offload_read_done(struct tevent_req *subreq);
2031 static struct tevent_req *smb_time_audit_offload_read_send(
2032 TALLOC_CTX *mem_ctx,
2033 struct tevent_context *ev,
2034 struct vfs_handle_struct *handle,
2035 struct files_struct *fsp,
2041 struct tevent_req *req = NULL;
2042 struct tevent_req *subreq = NULL;
2043 struct time_audit_offload_read_state *state = NULL;
2045 req = tevent_req_create(mem_ctx, &state,
2046 struct time_audit_offload_read_state);
2050 state->handle = handle;
2051 clock_gettime_mono(&state->ts_send);
2053 subreq = SMB_VFS_NEXT_OFFLOAD_READ_SEND(mem_ctx, ev,
2057 if (tevent_req_nomem(subreq, req)) {
2058 return tevent_req_post(req, ev);
2061 tevent_req_set_callback(subreq, smb_time_audit_offload_read_done, req);
2065 static void smb_time_audit_offload_read_done(struct tevent_req *subreq)
2067 struct tevent_req *req = tevent_req_callback_data(
2068 subreq, struct tevent_req);
2069 struct time_audit_offload_read_state *state = tevent_req_data(
2070 req, struct time_audit_offload_read_state);
2073 status = SMB_VFS_NEXT_OFFLOAD_READ_RECV(subreq,
2078 &state->token_blob);
2079 TALLOC_FREE(subreq);
2080 if (tevent_req_nterror(req, status)) {
2083 tevent_req_done(req);
2086 static NTSTATUS smb_time_audit_offload_read_recv(
2087 struct tevent_req *req,
2088 struct vfs_handle_struct *handle,
2089 TALLOC_CTX *mem_ctx,
2092 DATA_BLOB *token_blob)
2094 struct time_audit_offload_read_state *state = tevent_req_data(
2095 req, struct time_audit_offload_read_state);
2096 struct timespec ts_recv;
2100 clock_gettime_mono(&ts_recv);
2101 timediff = nsec_time_diff(&ts_recv, &state->ts_send) * 1.0e-9;
2102 if (timediff > audit_timeout) {
2103 smb_time_audit_log("offload_read", timediff);
2106 if (tevent_req_is_nterror(req, &status)) {
2107 tevent_req_received(req);
2111 *flags = state->flags;
2112 *xferlen = state->xferlen;
2113 token_blob->length = state->token_blob.length;
2114 token_blob->data = talloc_move(mem_ctx, &state->token_blob.data);
2116 tevent_req_received(req);
2117 return NT_STATUS_OK;
2120 struct time_audit_offload_write_state {
2121 struct timespec ts_send;
2122 struct vfs_handle_struct *handle;
2125 static void smb_time_audit_offload_write_done(struct tevent_req *subreq);
2127 static struct tevent_req *smb_time_audit_offload_write_send(struct vfs_handle_struct *handle,
2128 TALLOC_CTX *mem_ctx,
2129 struct tevent_context *ev,
2132 off_t transfer_offset,
2133 struct files_struct *dest_fsp,
2137 struct tevent_req *req;
2138 struct tevent_req *subreq;
2139 struct time_audit_offload_write_state *state;
2141 req = tevent_req_create(mem_ctx, &state,
2142 struct time_audit_offload_write_state);
2147 state->handle = handle;
2148 clock_gettime_mono(&state->ts_send);
2149 subreq = SMB_VFS_NEXT_OFFLOAD_WRITE_SEND(handle, state, ev,
2150 fsctl, token, transfer_offset,
2151 dest_fsp, dest_off, num);
2152 if (tevent_req_nomem(subreq, req)) {
2153 return tevent_req_post(req, ev);
2156 tevent_req_set_callback(subreq, smb_time_audit_offload_write_done, req);
2160 static void smb_time_audit_offload_write_done(struct tevent_req *subreq)
2162 struct tevent_req *req = tevent_req_callback_data(
2163 subreq, struct tevent_req);
2164 struct time_audit_offload_write_state *state = tevent_req_data(
2165 req, struct time_audit_offload_write_state);
2168 status = SMB_VFS_NEXT_OFFLOAD_WRITE_RECV(state->handle,
2171 TALLOC_FREE(subreq);
2172 if (tevent_req_nterror(req, status)) {
2175 tevent_req_done(req);
2178 static NTSTATUS smb_time_audit_offload_write_recv(struct vfs_handle_struct *handle,
2179 struct tevent_req *req,
2182 struct time_audit_offload_write_state *state = tevent_req_data(
2183 req, struct time_audit_offload_write_state);
2184 struct timespec ts_recv;
2188 clock_gettime_mono(&ts_recv);
2189 timediff = nsec_time_diff(&ts_recv, &state->ts_send)*1.0e-9;
2190 if (timediff > audit_timeout) {
2191 smb_time_audit_log("offload_write", timediff);
2194 *copied = state->copied;
2195 if (tevent_req_is_nterror(req, &status)) {
2196 tevent_req_received(req);
2200 tevent_req_received(req);
2201 return NT_STATUS_OK;
2204 static NTSTATUS smb_time_audit_fget_compression(vfs_handle_struct *handle,
2205 TALLOC_CTX *mem_ctx,
2206 struct files_struct *fsp,
2207 uint16_t *_compression_fmt)
2210 struct timespec ts1,ts2;
2213 clock_gettime_mono(&ts1);
2214 result = SMB_VFS_NEXT_FGET_COMPRESSION(handle, mem_ctx, fsp,
2216 clock_gettime_mono(&ts2);
2217 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2219 if (timediff > audit_timeout) {
2220 smb_time_audit_log_fsp("get_compression",
2227 static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
2228 TALLOC_CTX *mem_ctx,
2229 struct files_struct *fsp,
2230 uint16_t compression_fmt)
2233 struct timespec ts1,ts2;
2236 clock_gettime_mono(&ts1);
2237 result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
2239 clock_gettime_mono(&ts2);
2240 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2242 if (timediff > audit_timeout) {
2243 smb_time_audit_log_fsp("set_compression", timediff, fsp);
2249 static NTSTATUS smb_time_audit_freaddir_attr(struct vfs_handle_struct *handle,
2250 struct files_struct *fsp,
2251 TALLOC_CTX *mem_ctx,
2252 struct readdir_attr_data **pattr_data)
2255 struct timespec ts1, ts2;
2258 clock_gettime_mono(&ts1);
2259 status = SMB_VFS_NEXT_FREADDIR_ATTR(handle, fsp, mem_ctx, pattr_data);
2260 clock_gettime_mono(&ts2);
2261 timediff = nsec_time_diff(&ts2, &ts1) * 1.0e-9;
2263 if (timediff > audit_timeout) {
2264 smb_time_audit_log_fsp("freaddir_attr", timediff, fsp);
2270 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
2272 uint32_t security_info,
2273 TALLOC_CTX *mem_ctx,
2274 struct security_descriptor **ppdesc)
2277 struct timespec ts1,ts2;
2280 clock_gettime_mono(&ts1);
2281 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
2283 clock_gettime_mono(&ts2);
2284 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2286 if (timediff > audit_timeout) {
2287 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
2293 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
2295 uint32_t security_info_sent,
2296 const struct security_descriptor *psd)
2299 struct timespec ts1,ts2;
2302 clock_gettime_mono(&ts1);
2303 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
2305 clock_gettime_mono(&ts2);
2306 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2308 if (timediff > audit_timeout) {
2309 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
2315 static NTSTATUS smb_time_audit_audit_file(struct vfs_handle_struct *handle,
2316 struct smb_filename *smb_fname,
2317 struct security_acl *sacl,
2318 uint32_t access_requested,
2319 uint32_t access_denied)
2322 struct timespec ts1,ts2;
2325 clock_gettime_mono(&ts1);
2326 result = SMB_VFS_NEXT_AUDIT_FILE(handle,
2331 clock_gettime_mono(&ts2);
2332 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2334 if (timediff > audit_timeout) {
2335 smb_time_audit_log_fname("audit_file",
2337 smb_fname->base_name);
2343 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
2345 SMB_ACL_TYPE_T type,
2346 TALLOC_CTX *mem_ctx)
2349 struct timespec ts1,ts2;
2352 clock_gettime_mono(&ts1);
2353 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, type, mem_ctx);
2354 clock_gettime_mono(&ts2);
2355 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2357 if (timediff > audit_timeout) {
2358 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
2364 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
2366 TALLOC_CTX *mem_ctx,
2367 char **blob_description,
2371 struct timespec ts1,ts2;
2374 clock_gettime_mono(&ts1);
2375 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
2376 clock_gettime_mono(&ts2);
2377 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2379 if (timediff > audit_timeout) {
2380 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
2386 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
2388 SMB_ACL_TYPE_T type,
2392 struct timespec ts1,ts2;
2395 clock_gettime_mono(&ts1);
2396 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, type, theacl);
2397 clock_gettime_mono(&ts2);
2398 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2400 if (timediff > audit_timeout) {
2401 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
2407 static int smb_time_audit_sys_acl_delete_def_fd(vfs_handle_struct *handle,
2411 struct timespec ts1,ts2;
2414 clock_gettime_mono(&ts1);
2415 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FD(handle, fsp);
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("sys_acl_delete_def_fd", timediff, fsp);
2426 struct smb_time_audit_getxattrat_state {
2427 struct vfs_aio_state aio_state;
2428 files_struct *dir_fsp;
2429 const struct smb_filename *smb_fname;
2430 const char *xattr_name;
2432 uint8_t *xattr_value;
2435 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq);
2437 static struct tevent_req *smb_time_audit_getxattrat_send(
2438 TALLOC_CTX *mem_ctx,
2439 struct tevent_context *ev,
2440 struct vfs_handle_struct *handle,
2441 files_struct *dir_fsp,
2442 const struct smb_filename *smb_fname,
2443 const char *xattr_name,
2446 struct tevent_req *req = NULL;
2447 struct tevent_req *subreq = NULL;
2448 struct smb_time_audit_getxattrat_state *state = NULL;
2450 req = tevent_req_create(mem_ctx, &state,
2451 struct smb_time_audit_getxattrat_state);
2455 *state = (struct smb_time_audit_getxattrat_state) {
2457 .smb_fname = smb_fname,
2458 .xattr_name = xattr_name,
2461 subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,
2468 if (tevent_req_nomem(subreq, req)) {
2469 return tevent_req_post(req, ev);
2471 tevent_req_set_callback(subreq, smb_time_audit_getxattrat_done, req);
2476 static void smb_time_audit_getxattrat_done(struct tevent_req *subreq)
2478 struct tevent_req *req = tevent_req_callback_data(
2479 subreq, struct tevent_req);
2480 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2481 req, struct smb_time_audit_getxattrat_state);
2483 state->xattr_size = SMB_VFS_NEXT_GETXATTRAT_RECV(subreq,
2486 &state->xattr_value);
2487 TALLOC_FREE(subreq);
2488 if (state->xattr_size == -1) {
2489 tevent_req_error(req, state->aio_state.error);
2493 tevent_req_done(req);
2496 static ssize_t smb_time_audit_getxattrat_recv(struct tevent_req *req,
2497 struct vfs_aio_state *aio_state,
2498 TALLOC_CTX *mem_ctx,
2499 uint8_t **xattr_value)
2501 struct smb_time_audit_getxattrat_state *state = tevent_req_data(
2502 req, struct smb_time_audit_getxattrat_state);
2506 timediff = state->aio_state.duration * 1.0e-9;
2508 if (timediff > audit_timeout) {
2509 smb_time_audit_log_at("async getxattrat",
2515 if (tevent_req_is_unix_error(req, &aio_state->error)) {
2516 tevent_req_received(req);
2520 *aio_state = state->aio_state;
2521 xattr_size = state->xattr_size;
2522 if (xattr_value != NULL) {
2523 *xattr_value = talloc_move(mem_ctx, &state->xattr_value);
2526 tevent_req_received(req);
2530 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2531 struct files_struct *fsp,
2532 const char *name, void *value,
2536 struct timespec ts1,ts2;
2539 clock_gettime_mono(&ts1);
2540 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2541 clock_gettime_mono(&ts2);
2542 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2544 if (timediff > audit_timeout) {
2545 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2551 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2552 struct files_struct *fsp, char *list,
2556 struct timespec ts1,ts2;
2559 clock_gettime_mono(&ts1);
2560 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2561 clock_gettime_mono(&ts2);
2562 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2564 if (timediff > audit_timeout) {
2565 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2571 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2572 struct files_struct *fsp,
2576 struct timespec ts1,ts2;
2579 clock_gettime_mono(&ts1);
2580 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2581 clock_gettime_mono(&ts2);
2582 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2584 if (timediff > audit_timeout) {
2585 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2591 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2592 struct files_struct *fsp, const char *name,
2593 const void *value, size_t size, int flags)
2596 struct timespec ts1,ts2;
2599 clock_gettime_mono(&ts1);
2600 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2601 clock_gettime_mono(&ts2);
2602 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2604 if (timediff > audit_timeout) {
2605 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2611 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2612 struct files_struct *fsp)
2615 struct timespec ts1,ts2;
2618 clock_gettime_mono(&ts1);
2619 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2620 clock_gettime_mono(&ts2);
2621 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2623 if (timediff > audit_timeout) {
2624 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2630 static NTSTATUS smb_time_audit_durable_cookie(struct vfs_handle_struct *handle,
2631 struct files_struct *fsp,
2632 TALLOC_CTX *mem_ctx,
2636 struct timespec ts1,ts2;
2639 clock_gettime_mono(&ts1);
2640 result = SMB_VFS_NEXT_DURABLE_COOKIE(handle, fsp, mem_ctx, cookie);
2641 clock_gettime_mono(&ts2);
2642 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2644 if (timediff > audit_timeout) {
2645 smb_time_audit_log_fsp("durable_cookie", timediff, fsp);
2651 static NTSTATUS smb_time_audit_durable_disconnect(struct vfs_handle_struct *handle,
2652 struct files_struct *fsp,
2653 const DATA_BLOB old_cookie,
2654 TALLOC_CTX *mem_ctx,
2655 DATA_BLOB *new_cookie)
2658 struct timespec ts1,ts2;
2661 clock_gettime_mono(&ts1);
2662 result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle, fsp, old_cookie,
2663 mem_ctx, new_cookie);
2664 clock_gettime_mono(&ts2);
2665 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2667 if (timediff > audit_timeout) {
2668 smb_time_audit_log_fsp("durable_disconnect", timediff, fsp);
2674 static NTSTATUS smb_time_audit_durable_reconnect(struct vfs_handle_struct *handle,
2675 struct smb_request *smb1req,
2676 struct smbXsrv_open *op,
2677 const DATA_BLOB old_cookie,
2678 TALLOC_CTX *mem_ctx,
2679 struct files_struct **fsp,
2680 DATA_BLOB *new_cookie)
2683 struct timespec ts1,ts2;
2686 clock_gettime_mono(&ts1);
2687 result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle, smb1req, op, old_cookie,
2688 mem_ctx, fsp, new_cookie);
2689 clock_gettime_mono(&ts2);
2690 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2692 if (timediff > audit_timeout) {
2693 smb_time_audit_log("durable_reconnect", timediff);
2699 /* VFS operations */
2701 static struct vfs_fn_pointers vfs_time_audit_fns = {
2702 .connect_fn = smb_time_audit_connect,
2703 .disconnect_fn = smb_time_audit_disconnect,
2704 .disk_free_fn = smb_time_audit_disk_free,
2705 .get_quota_fn = smb_time_audit_get_quota,
2706 .set_quota_fn = smb_time_audit_set_quota,
2707 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2708 .statvfs_fn = smb_time_audit_statvfs,
2709 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2710 .get_dfs_referrals_fn = smb_time_audit_get_dfs_referrals,
2711 .create_dfs_pathat_fn = smb_time_audit_create_dfs_pathat,
2712 .read_dfs_pathat_fn = smb_time_audit_read_dfs_pathat,
2713 .fdopendir_fn = smb_time_audit_fdopendir,
2714 .readdir_fn = smb_time_audit_readdir,
2715 .rewind_dir_fn = smb_time_audit_rewinddir,
2716 .mkdirat_fn = smb_time_audit_mkdirat,
2717 .closedir_fn = smb_time_audit_closedir,
2718 .openat_fn = smb_time_audit_openat,
2719 .create_file_fn = smb_time_audit_create_file,
2720 .close_fn = smb_time_audit_close,
2721 .pread_fn = smb_time_audit_pread,
2722 .pread_send_fn = smb_time_audit_pread_send,
2723 .pread_recv_fn = smb_time_audit_pread_recv,
2724 .pwrite_fn = smb_time_audit_pwrite,
2725 .pwrite_send_fn = smb_time_audit_pwrite_send,
2726 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2727 .lseek_fn = smb_time_audit_lseek,
2728 .sendfile_fn = smb_time_audit_sendfile,
2729 .recvfile_fn = smb_time_audit_recvfile,
2730 .renameat_fn = smb_time_audit_renameat,
2731 .fsync_send_fn = smb_time_audit_fsync_send,
2732 .fsync_recv_fn = smb_time_audit_fsync_recv,
2733 .stat_fn = smb_time_audit_stat,
2734 .fstat_fn = smb_time_audit_fstat,
2735 .lstat_fn = smb_time_audit_lstat,
2736 .fstatat_fn = smb_time_audit_fstatat,
2737 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2738 .unlinkat_fn = smb_time_audit_unlinkat,
2739 .fchmod_fn = smb_time_audit_fchmod,
2740 .fchown_fn = smb_time_audit_fchown,
2741 .lchown_fn = smb_time_audit_lchown,
2742 .chdir_fn = smb_time_audit_chdir,
2743 .getwd_fn = smb_time_audit_getwd,
2744 .fntimes_fn = smb_time_audit_fntimes,
2745 .ftruncate_fn = smb_time_audit_ftruncate,
2746 .fallocate_fn = smb_time_audit_fallocate,
2747 .lock_fn = smb_time_audit_lock,
2748 .filesystem_sharemode_fn = smb_time_audit_filesystem_sharemode,
2749 .fcntl_fn = smb_time_audit_fcntl,
2750 .linux_setlease_fn = smb_time_audit_linux_setlease,
2751 .getlock_fn = smb_time_audit_getlock,
2752 .symlinkat_fn = smb_time_audit_symlinkat,
2753 .readlinkat_fn = smb_time_audit_readlinkat,
2754 .linkat_fn = smb_time_audit_linkat,
2755 .mknodat_fn = smb_time_audit_mknodat,
2756 .realpath_fn = smb_time_audit_realpath,
2757 .fchflags_fn = smb_time_audit_fchflags,
2758 .file_id_create_fn = smb_time_audit_file_id_create,
2759 .fs_file_id_fn = smb_time_audit_fs_file_id,
2760 .offload_read_send_fn = smb_time_audit_offload_read_send,
2761 .offload_read_recv_fn = smb_time_audit_offload_read_recv,
2762 .offload_write_send_fn = smb_time_audit_offload_write_send,
2763 .offload_write_recv_fn = smb_time_audit_offload_write_recv,
2764 .fget_compression_fn = smb_time_audit_fget_compression,
2765 .set_compression_fn = smb_time_audit_set_compression,
2766 .snap_check_path_fn = smb_time_audit_snap_check_path,
2767 .snap_create_fn = smb_time_audit_snap_create,
2768 .snap_delete_fn = smb_time_audit_snap_delete,
2769 .fstreaminfo_fn = smb_time_audit_fstreaminfo,
2770 .get_real_filename_at_fn = smb_time_audit_get_real_filename_at,
2771 .connectpath_fn = smb_time_audit_connectpath,
2772 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2773 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2774 .strict_lock_check_fn = smb_time_audit_strict_lock_check,
2775 .translate_name_fn = smb_time_audit_translate_name,
2776 .parent_pathname_fn = smb_time_audit_parent_pathname,
2777 .fsctl_fn = smb_time_audit_fsctl,
2778 .get_dos_attributes_send_fn = smb_time_audit_get_dos_attributes_send,
2779 .get_dos_attributes_recv_fn = smb_time_audit_get_dos_attributes_recv,
2780 .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
2781 .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
2782 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2783 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2784 .audit_file_fn = smb_time_audit_audit_file,
2785 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2786 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2787 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2788 .sys_acl_delete_def_fd_fn = smb_time_audit_sys_acl_delete_def_fd,
2789 .getxattrat_send_fn = smb_time_audit_getxattrat_send,
2790 .getxattrat_recv_fn = smb_time_audit_getxattrat_recv,
2791 .fgetxattr_fn = smb_time_audit_fgetxattr,
2792 .flistxattr_fn = smb_time_audit_flistxattr,
2793 .fremovexattr_fn = smb_time_audit_fremovexattr,
2794 .fsetxattr_fn = smb_time_audit_fsetxattr,
2795 .aio_force_fn = smb_time_audit_aio_force,
2796 .durable_cookie_fn = smb_time_audit_durable_cookie,
2797 .durable_disconnect_fn = smb_time_audit_durable_disconnect,
2798 .durable_reconnect_fn = smb_time_audit_durable_reconnect,
2799 .freaddir_attr_fn = smb_time_audit_freaddir_attr,
2804 NTSTATUS vfs_time_audit_init(TALLOC_CTX *ctx)
2806 smb_vfs_assert_all_fns(&vfs_time_audit_fns, "time_audit");
2808 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2810 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2811 &vfs_time_audit_fns);