s3:include bump profile memory area version number
[Samba.git] / source3 / modules / vfs_time_audit.c
blob1b14d650afd3f07b1f5325acd15db93a634b187b
1 /*
2 * Time auditing VFS module for samba. Log time taken for VFS call to syslog
3 * facility.
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
28 #include "includes.h"
29 #include "smbd/smbd.h"
30 #include "ntioctl.h"
31 #include "lib/util/tevent_unix.h"
32 #include "lib/util/tevent_ntstatus.h"
34 #undef DBGC_CLASS
35 #define DBGC_CLASS DBGC_VFS
37 static double audit_timeout;
39 static void smb_time_audit_log_msg(const char *syscallname, double elapsed,
40 const char *msg)
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;
59 char *msg = NULL;
61 if (fsp == NULL) {
62 smb_time_audit_log(syscallname, elapsed);
63 return;
65 if (fsp->conn)
66 connectpath = fsp->conn->connectpath;
67 if (fsp->fsp_name)
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\", "
75 "base_name = <NULL>",
76 connectpath);
77 } else if (connectpath == NULL && base_name != NULL) {
78 msg = talloc_asprintf(talloc_tos(), "connectpath = <NULL>, "
79 "base_name = \"%s\"",
80 base_name);
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);
86 TALLOC_FREE(msg);
89 static void smb_time_audit_log_fname(const char *syscallname, double elapsed,
90 const char *fname)
92 char cwd[PATH_MAX];
93 char *msg = NULL;
95 if (getcwd(cwd, sizeof(cwd)) == NULL) {
96 snprintf(cwd, sizeof(cwd), "<getcwd() error %d>", errno);
98 if (fname != NULL) {
99 msg = talloc_asprintf(talloc_tos(),
100 "cwd = \"%s\", filename = \"%s\"",
101 cwd, fname);
102 } else {
103 msg = talloc_asprintf(talloc_tos(),
104 "cwd = \"%s\", filename = <NULL>",
105 cwd);
107 smb_time_audit_log_msg(syscallname, elapsed, msg);
108 TALLOC_FREE(msg);
111 static void smb_time_audit_log_smb_fname(const char *syscallname, double elapsed,
112 const struct smb_filename *smb_fname)
114 if (smb_fname != NULL) {
115 smb_time_audit_log_fname(syscallname, elapsed,
116 smb_fname->base_name);
117 } else {
118 smb_time_audit_log_fname(syscallname, elapsed,
119 "smb_fname = <NULL>");
123 static int smb_time_audit_connect(vfs_handle_struct *handle,
124 const char *svc, const char *user)
126 int result;
127 struct timespec ts1,ts2;
128 double timediff;
130 if (!handle) {
131 return -1;
134 clock_gettime_mono(&ts1);
135 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
136 clock_gettime_mono(&ts2);
137 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
138 if (timediff > audit_timeout) {
139 smb_time_audit_log_msg("connect", timediff, user);
141 return result;
144 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
146 struct timespec ts1,ts2;
147 double timediff;
149 clock_gettime_mono(&ts1);
150 SMB_VFS_NEXT_DISCONNECT(handle);
151 clock_gettime_mono(&ts2);
152 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
154 if (timediff > audit_timeout) {
155 smb_time_audit_log("disconnect", timediff);
159 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
160 const char *path,
161 bool small_query, uint64_t *bsize,
162 uint64_t *dfree, uint64_t *dsize)
164 uint64_t result;
165 struct timespec ts1,ts2;
166 double timediff;
168 clock_gettime_mono(&ts1);
169 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
170 dfree, dsize);
171 clock_gettime_mono(&ts2);
172 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
174 /* Don't have a reasonable notion of failure here */
175 if (timediff > audit_timeout) {
176 smb_time_audit_log_fname("disk_free", timediff, path);
179 return result;
182 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
183 enum SMB_QUOTA_TYPE qtype, unid_t id,
184 SMB_DISK_QUOTA *qt)
186 int result;
187 struct timespec ts1,ts2;
188 double timediff;
190 clock_gettime_mono(&ts1);
191 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
192 clock_gettime_mono(&ts2);
193 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
195 if (timediff > audit_timeout) {
196 smb_time_audit_log("get_quota", timediff);
198 return result;
201 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
202 enum SMB_QUOTA_TYPE qtype, unid_t id,
203 SMB_DISK_QUOTA *qt)
205 int result;
206 struct timespec ts1,ts2;
207 double timediff;
209 clock_gettime_mono(&ts1);
210 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
211 clock_gettime_mono(&ts2);
212 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
214 if (timediff > audit_timeout) {
215 smb_time_audit_log("set_quota", timediff);
218 return result;
221 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
222 struct files_struct *fsp,
223 struct shadow_copy_data *shadow_copy_data,
224 bool labels)
226 int result;
227 struct timespec ts1,ts2;
228 double timediff;
230 clock_gettime_mono(&ts1);
231 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
232 shadow_copy_data, labels);
233 clock_gettime_mono(&ts2);
234 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
236 if (timediff > audit_timeout) {
237 smb_time_audit_log_fsp("get_shadow_copy_data", timediff, fsp);
240 return result;
243 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
244 const char *path,
245 struct vfs_statvfs_struct *statbuf)
247 int result;
248 struct timespec ts1,ts2;
249 double timediff;
251 clock_gettime_mono(&ts1);
252 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
253 clock_gettime_mono(&ts2);
254 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
256 if (timediff > audit_timeout) {
257 smb_time_audit_log_fname("statvfs", timediff, path);
260 return result;
263 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
264 enum timestamp_set_resolution *p_ts_res)
266 uint32_t result;
267 struct timespec ts1,ts2;
268 double timediff;
270 clock_gettime_mono(&ts1);
271 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
272 clock_gettime_mono(&ts2);
273 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
275 if (timediff > audit_timeout) {
276 smb_time_audit_log("fs_capabilities", timediff);
279 return result;
282 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
283 const char *fname,
284 const char *mask, uint32 attr)
286 DIR *result;
287 struct timespec ts1,ts2;
288 double timediff;
290 clock_gettime_mono(&ts1);
291 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
292 clock_gettime_mono(&ts2);
293 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
295 if (timediff > audit_timeout) {
296 smb_time_audit_log_fname("opendir", timediff, fname);
299 return result;
302 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
303 files_struct *fsp,
304 const char *mask, uint32 attr)
306 DIR *result;
307 struct timespec ts1,ts2;
308 double timediff;
310 clock_gettime_mono(&ts1);
311 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
312 clock_gettime_mono(&ts2);
313 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
315 if (timediff > audit_timeout) {
316 smb_time_audit_log_fsp("fdopendir", timediff, fsp);
319 return result;
322 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
323 DIR *dirp,
324 SMB_STRUCT_STAT *sbuf)
326 struct dirent *result;
327 struct timespec ts1,ts2;
328 double timediff;
330 clock_gettime_mono(&ts1);
331 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
332 clock_gettime_mono(&ts2);
333 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
335 if (timediff > audit_timeout) {
336 smb_time_audit_log("readdir", timediff);
339 return result;
342 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
343 DIR *dirp, long offset)
345 struct timespec ts1,ts2;
346 double timediff;
348 clock_gettime_mono(&ts1);
349 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
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("seekdir", timediff);
359 static long smb_time_audit_telldir(vfs_handle_struct *handle,
360 DIR *dirp)
362 long result;
363 struct timespec ts1,ts2;
364 double timediff;
366 clock_gettime_mono(&ts1);
367 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
368 clock_gettime_mono(&ts2);
369 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
371 if (timediff > audit_timeout) {
372 smb_time_audit_log("telldir", timediff);
375 return result;
378 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
379 DIR *dirp)
381 struct timespec ts1,ts2;
382 double timediff;
384 clock_gettime_mono(&ts1);
385 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
386 clock_gettime_mono(&ts2);
387 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
389 if (timediff > audit_timeout) {
390 smb_time_audit_log("rewinddir", timediff);
395 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
396 const char *path, mode_t mode)
398 int result;
399 struct timespec ts1,ts2;
400 double timediff;
402 clock_gettime_mono(&ts1);
403 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
404 clock_gettime_mono(&ts2);
405 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
407 if (timediff > audit_timeout) {
408 smb_time_audit_log_fname("mkdir", timediff, path);
411 return result;
414 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
415 const char *path)
417 int result;
418 struct timespec ts1,ts2;
419 double timediff;
421 clock_gettime_mono(&ts1);
422 result = SMB_VFS_NEXT_RMDIR(handle, path);
423 clock_gettime_mono(&ts2);
424 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
426 if (timediff > audit_timeout) {
427 smb_time_audit_log_fname("rmdir", timediff, path);
430 return result;
433 static int smb_time_audit_closedir(vfs_handle_struct *handle,
434 DIR *dirp)
436 int result;
437 struct timespec ts1,ts2;
438 double timediff;
440 clock_gettime_mono(&ts1);
441 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
442 clock_gettime_mono(&ts2);
443 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
445 if (timediff > audit_timeout) {
446 smb_time_audit_log("closedir", timediff);
449 return result;
452 static void smb_time_audit_init_search_op(vfs_handle_struct *handle,
453 DIR *dirp)
455 struct timespec ts1,ts2;
456 double timediff;
458 clock_gettime_mono(&ts1);
459 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
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("init_search_op", timediff);
468 static int smb_time_audit_open(vfs_handle_struct *handle,
469 struct smb_filename *fname,
470 files_struct *fsp,
471 int flags, mode_t mode)
473 int result;
474 struct timespec ts1,ts2;
475 double timediff;
477 clock_gettime_mono(&ts1);
478 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
479 clock_gettime_mono(&ts2);
480 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
482 if (timediff > audit_timeout) {
483 smb_time_audit_log_fsp("open", timediff, fsp);
486 return result;
489 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
490 struct smb_request *req,
491 uint16_t root_dir_fid,
492 struct smb_filename *fname,
493 uint32_t access_mask,
494 uint32_t share_access,
495 uint32_t create_disposition,
496 uint32_t create_options,
497 uint32_t file_attributes,
498 uint32_t oplock_request,
499 uint64_t allocation_size,
500 uint32_t private_flags,
501 struct security_descriptor *sd,
502 struct ea_list *ea_list,
503 files_struct **result_fsp,
504 int *pinfo)
506 NTSTATUS result;
507 struct timespec ts1,ts2;
508 double timediff;
510 clock_gettime_mono(&ts1);
511 result = SMB_VFS_NEXT_CREATE_FILE(
512 handle, /* handle */
513 req, /* req */
514 root_dir_fid, /* root_dir_fid */
515 fname, /* fname */
516 access_mask, /* access_mask */
517 share_access, /* share_access */
518 create_disposition, /* create_disposition*/
519 create_options, /* create_options */
520 file_attributes, /* file_attributes */
521 oplock_request, /* oplock_request */
522 allocation_size, /* allocation_size */
523 private_flags,
524 sd, /* sd */
525 ea_list, /* ea_list */
526 result_fsp, /* result */
527 pinfo);
528 clock_gettime_mono(&ts2);
529 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
531 if (timediff > audit_timeout) {
533 * can't use result_fsp this time, may have
534 * invalid content causing smbd crash
536 smb_time_audit_log_smb_fname("create_file", timediff,
537 fname);
540 return result;
543 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
545 int result;
546 struct timespec ts1,ts2;
547 double timediff;
549 clock_gettime_mono(&ts1);
550 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
551 clock_gettime_mono(&ts2);
552 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
554 if (timediff > audit_timeout) {
555 smb_time_audit_log_fsp("close", timediff, fsp);
558 return result;
561 static ssize_t smb_time_audit_read(vfs_handle_struct *handle,
562 files_struct *fsp, void *data, size_t n)
564 ssize_t result;
565 struct timespec ts1,ts2;
566 double timediff;
568 clock_gettime_mono(&ts1);
569 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
570 clock_gettime_mono(&ts2);
571 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
573 if (timediff > audit_timeout) {
574 smb_time_audit_log_fsp("read", timediff, fsp);
577 return result;
580 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
581 files_struct *fsp,
582 void *data, size_t n, off_t offset)
584 ssize_t result;
585 struct timespec ts1,ts2;
586 double timediff;
588 clock_gettime_mono(&ts1);
589 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
590 clock_gettime_mono(&ts2);
591 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
593 if (timediff > audit_timeout) {
594 smb_time_audit_log_fsp("pread", timediff, fsp);
597 return result;
600 struct smb_time_audit_pread_state {
601 struct files_struct *fsp;
602 struct timespec ts1;
603 ssize_t ret;
604 int err;
607 static void smb_time_audit_pread_done(struct tevent_req *subreq);
609 static struct tevent_req *smb_time_audit_pread_send(
610 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
611 struct tevent_context *ev, struct files_struct *fsp,
612 void *data, size_t n, off_t offset)
614 struct tevent_req *req, *subreq;
615 struct smb_time_audit_pread_state *state;
617 req = tevent_req_create(mem_ctx, &state,
618 struct smb_time_audit_pread_state);
619 if (req == NULL) {
620 return NULL;
622 clock_gettime_mono(&state->ts1);
623 state->fsp = fsp;
625 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
626 n, offset);
627 if (tevent_req_nomem(subreq, req)) {
628 return tevent_req_post(req, ev);
630 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
631 return req;
634 static void smb_time_audit_pread_done(struct tevent_req *subreq)
636 struct tevent_req *req = tevent_req_callback_data(
637 subreq, struct tevent_req);
638 struct smb_time_audit_pread_state *state = tevent_req_data(
639 req, struct smb_time_audit_pread_state);
641 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
642 TALLOC_FREE(subreq);
643 tevent_req_done(req);
646 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req, int *err)
648 struct smb_time_audit_pread_state *state = tevent_req_data(
649 req, struct smb_time_audit_pread_state);
650 struct timespec ts2;
651 double timediff;
653 clock_gettime_mono(&ts2);
654 timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
656 if (timediff > audit_timeout) {
657 smb_time_audit_log_fsp("pread", timediff, state->fsp);
660 if (tevent_req_is_unix_error(req, err)) {
661 return -1;
663 *err = state->err;
664 return state->ret;
667 static ssize_t smb_time_audit_write(vfs_handle_struct *handle,
668 files_struct *fsp,
669 const void *data, size_t n)
671 ssize_t result;
672 struct timespec ts1,ts2;
673 double timediff;
675 clock_gettime_mono(&ts1);
676 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
677 clock_gettime_mono(&ts2);
678 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
680 if (timediff > audit_timeout) {
681 smb_time_audit_log_fsp("write", timediff, fsp);
684 return result;
687 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
688 files_struct *fsp,
689 const void *data, size_t n,
690 off_t offset)
692 ssize_t result;
693 struct timespec ts1,ts2;
694 double timediff;
696 clock_gettime_mono(&ts1);
697 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
698 clock_gettime_mono(&ts2);
699 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
701 if (timediff > audit_timeout) {
702 smb_time_audit_log_fsp("pwrite", timediff, fsp);
705 return result;
708 struct smb_time_audit_pwrite_state {
709 struct files_struct *fsp;
710 struct timespec ts1;
711 ssize_t ret;
712 int err;
715 static void smb_time_audit_pwrite_done(struct tevent_req *subreq);
717 static struct tevent_req *smb_time_audit_pwrite_send(
718 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
719 struct tevent_context *ev, struct files_struct *fsp,
720 const void *data, size_t n, off_t offset)
722 struct tevent_req *req, *subreq;
723 struct smb_time_audit_pwrite_state *state;
725 req = tevent_req_create(mem_ctx, &state,
726 struct smb_time_audit_pwrite_state);
727 if (req == NULL) {
728 return NULL;
730 clock_gettime_mono(&state->ts1);
731 state->fsp = fsp;
733 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
734 n, offset);
735 if (tevent_req_nomem(subreq, req)) {
736 return tevent_req_post(req, ev);
738 tevent_req_set_callback(subreq, smb_time_audit_pwrite_done, req);
739 return req;
742 static void smb_time_audit_pwrite_done(struct tevent_req *subreq)
744 struct tevent_req *req = tevent_req_callback_data(
745 subreq, struct tevent_req);
746 struct smb_time_audit_pwrite_state *state = tevent_req_data(
747 req, struct smb_time_audit_pwrite_state);
749 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
750 TALLOC_FREE(subreq);
751 tevent_req_done(req);
754 static ssize_t smb_time_audit_pwrite_recv(struct tevent_req *req, int *err)
756 struct smb_time_audit_pwrite_state *state = tevent_req_data(
757 req, struct smb_time_audit_pwrite_state);
758 struct timespec ts2;
759 double timediff;
761 clock_gettime_mono(&ts2);
762 timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
764 if (timediff > audit_timeout) {
765 smb_time_audit_log_fsp("pwrite", timediff, state->fsp);
768 if (tevent_req_is_unix_error(req, err)) {
769 return -1;
771 *err = state->err;
772 return state->ret;
775 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
776 files_struct *fsp,
777 off_t offset, int whence)
779 off_t result;
780 struct timespec ts1,ts2;
781 double timediff;
783 clock_gettime_mono(&ts1);
784 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
785 clock_gettime_mono(&ts2);
786 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
788 if (timediff > audit_timeout) {
789 smb_time_audit_log_fsp("lseek", timediff, fsp);
792 return result;
795 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
796 files_struct *fromfsp,
797 const DATA_BLOB *hdr, off_t offset,
798 size_t n)
800 ssize_t result;
801 struct timespec ts1,ts2;
802 double timediff;
804 clock_gettime_mono(&ts1);
805 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
806 clock_gettime_mono(&ts2);
807 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
809 if (timediff > audit_timeout) {
810 smb_time_audit_log_fsp("sendfile", timediff, fromfsp);
813 return result;
816 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
817 files_struct *tofsp,
818 off_t offset,
819 size_t n)
821 ssize_t result;
822 struct timespec ts1,ts2;
823 double timediff;
825 clock_gettime_mono(&ts1);
826 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
827 clock_gettime_mono(&ts2);
828 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
830 if (timediff > audit_timeout) {
831 smb_time_audit_log_fsp("recvfile", timediff, tofsp);
834 return result;
837 static int smb_time_audit_rename(vfs_handle_struct *handle,
838 const struct smb_filename *oldname,
839 const struct smb_filename *newname)
841 int result;
842 struct timespec ts1,ts2;
843 double timediff;
845 clock_gettime_mono(&ts1);
846 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
847 clock_gettime_mono(&ts2);
848 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
850 if (timediff > audit_timeout) {
851 smb_time_audit_log_smb_fname("rename", timediff, newname);
854 return result;
857 static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
859 int result;
860 struct timespec ts1,ts2;
861 double timediff;
863 clock_gettime_mono(&ts1);
864 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
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("fsync", timediff, fsp);
872 return result;
875 struct smb_time_audit_fsync_state {
876 struct files_struct *fsp;
877 struct timespec ts1;
878 int ret;
879 int err;
882 static void smb_time_audit_fsync_done(struct tevent_req *subreq);
884 static struct tevent_req *smb_time_audit_fsync_send(
885 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
886 struct tevent_context *ev, struct files_struct *fsp)
888 struct tevent_req *req, *subreq;
889 struct smb_time_audit_fsync_state *state;
891 req = tevent_req_create(mem_ctx, &state,
892 struct smb_time_audit_fsync_state);
893 if (req == NULL) {
894 return NULL;
896 clock_gettime_mono(&state->ts1);
897 state->fsp = fsp;
899 subreq = SMB_VFS_NEXT_FSYNC_SEND(state, ev, handle, fsp);
900 if (tevent_req_nomem(subreq, req)) {
901 return tevent_req_post(req, ev);
903 tevent_req_set_callback(subreq, smb_time_audit_fsync_done, req);
904 return req;
907 static void smb_time_audit_fsync_done(struct tevent_req *subreq)
909 struct tevent_req *req = tevent_req_callback_data(
910 subreq, struct tevent_req);
911 struct smb_time_audit_fsync_state *state = tevent_req_data(
912 req, struct smb_time_audit_fsync_state);
914 state->ret = SMB_VFS_FSYNC_RECV(subreq, &state->err);
915 TALLOC_FREE(subreq);
916 tevent_req_done(req);
919 static int smb_time_audit_fsync_recv(struct tevent_req *req, int *err)
921 struct smb_time_audit_fsync_state *state = tevent_req_data(
922 req, struct smb_time_audit_fsync_state);
923 struct timespec ts2;
924 double timediff;
926 clock_gettime_mono(&ts2);
927 timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
929 if (timediff > audit_timeout) {
930 smb_time_audit_log_fsp("fsync", timediff, state->fsp);
933 if (tevent_req_is_unix_error(req, err)) {
934 return -1;
936 *err = state->err;
937 return state->ret;
940 static int smb_time_audit_stat(vfs_handle_struct *handle,
941 struct smb_filename *fname)
943 int result;
944 struct timespec ts1,ts2;
945 double timediff;
947 clock_gettime_mono(&ts1);
948 result = SMB_VFS_NEXT_STAT(handle, fname);
949 clock_gettime_mono(&ts2);
950 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
952 if (timediff > audit_timeout) {
953 smb_time_audit_log_smb_fname("stat", timediff, fname);
956 return result;
959 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
960 SMB_STRUCT_STAT *sbuf)
962 int result;
963 struct timespec ts1,ts2;
964 double timediff;
966 clock_gettime_mono(&ts1);
967 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
968 clock_gettime_mono(&ts2);
969 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
971 if (timediff > audit_timeout) {
972 smb_time_audit_log_fsp("fstat", timediff, fsp);
975 return result;
978 static int smb_time_audit_lstat(vfs_handle_struct *handle,
979 struct smb_filename *path)
981 int result;
982 struct timespec ts1,ts2;
983 double timediff;
985 clock_gettime_mono(&ts1);
986 result = SMB_VFS_NEXT_LSTAT(handle, path);
987 clock_gettime_mono(&ts2);
988 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
990 if (timediff > audit_timeout) {
991 smb_time_audit_log_smb_fname("lstat", timediff, path);
994 return result;
997 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
998 files_struct *fsp,
999 const SMB_STRUCT_STAT *sbuf)
1001 uint64_t result;
1002 struct timespec ts1,ts2;
1003 double timediff;
1005 clock_gettime_mono(&ts1);
1006 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
1007 clock_gettime_mono(&ts2);
1008 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1010 if (timediff > audit_timeout) {
1011 smb_time_audit_log_fsp("get_alloc_size", timediff, fsp);
1014 return result;
1017 static int smb_time_audit_unlink(vfs_handle_struct *handle,
1018 const struct smb_filename *path)
1020 int result;
1021 struct timespec ts1,ts2;
1022 double timediff;
1024 clock_gettime_mono(&ts1);
1025 result = SMB_VFS_NEXT_UNLINK(handle, path);
1026 clock_gettime_mono(&ts2);
1027 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1029 if (timediff > audit_timeout) {
1030 smb_time_audit_log_smb_fname("unlink", timediff, path);
1033 return result;
1036 static int smb_time_audit_chmod(vfs_handle_struct *handle,
1037 const char *path, mode_t mode)
1039 int result;
1040 struct timespec ts1,ts2;
1041 double timediff;
1043 clock_gettime_mono(&ts1);
1044 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
1045 clock_gettime_mono(&ts2);
1046 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1048 if (timediff > audit_timeout) {
1049 smb_time_audit_log_fname("chmod", timediff, path);
1052 return result;
1055 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
1056 mode_t mode)
1058 int result;
1059 struct timespec ts1,ts2;
1060 double timediff;
1062 clock_gettime_mono(&ts1);
1063 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1064 clock_gettime_mono(&ts2);
1065 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1067 if (timediff > audit_timeout) {
1068 smb_time_audit_log_fsp("fchmod", timediff, fsp);
1071 return result;
1074 static int smb_time_audit_chown(vfs_handle_struct *handle,
1075 const char *path, uid_t uid, gid_t gid)
1077 int result;
1078 struct timespec ts1,ts2;
1079 double timediff;
1081 clock_gettime_mono(&ts1);
1082 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
1083 clock_gettime_mono(&ts2);
1084 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1086 if (timediff > audit_timeout) {
1087 smb_time_audit_log_fname("chown", timediff, path);
1090 return result;
1093 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
1094 uid_t uid, gid_t gid)
1096 int result;
1097 struct timespec ts1,ts2;
1098 double timediff;
1100 clock_gettime_mono(&ts1);
1101 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
1102 clock_gettime_mono(&ts2);
1103 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1105 if (timediff > audit_timeout) {
1106 smb_time_audit_log_fsp("fchown", timediff, fsp);
1109 return result;
1112 static int smb_time_audit_lchown(vfs_handle_struct *handle,
1113 const char *path, uid_t uid, gid_t gid)
1115 int result;
1116 struct timespec ts1,ts2;
1117 double timediff;
1119 clock_gettime_mono(&ts1);
1120 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
1121 clock_gettime_mono(&ts2);
1122 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1124 if (timediff > audit_timeout) {
1125 smb_time_audit_log_fname("lchown", timediff, path);
1128 return result;
1131 static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
1133 int result;
1134 struct timespec ts1,ts2;
1135 double timediff;
1137 clock_gettime_mono(&ts1);
1138 result = SMB_VFS_NEXT_CHDIR(handle, path);
1139 clock_gettime_mono(&ts2);
1140 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1142 if (timediff > audit_timeout) {
1143 smb_time_audit_log_fname("chdir", timediff, path);
1146 return result;
1149 static char *smb_time_audit_getwd(vfs_handle_struct *handle)
1151 char *result;
1152 struct timespec ts1,ts2;
1153 double timediff;
1155 clock_gettime_mono(&ts1);
1156 result = SMB_VFS_NEXT_GETWD(handle);
1157 clock_gettime_mono(&ts2);
1158 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1160 if (timediff > audit_timeout) {
1161 smb_time_audit_log("getwd", timediff);
1164 return result;
1167 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
1168 const struct smb_filename *path,
1169 struct smb_file_time *ft)
1171 int result;
1172 struct timespec ts1,ts2;
1173 double timediff;
1175 clock_gettime_mono(&ts1);
1176 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
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_smb_fname("ntimes", timediff, path);
1184 return result;
1187 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
1188 files_struct *fsp,
1189 off_t len)
1191 int result;
1192 struct timespec ts1,ts2;
1193 double timediff;
1195 clock_gettime_mono(&ts1);
1196 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1197 clock_gettime_mono(&ts2);
1198 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1200 if (timediff > audit_timeout) {
1201 smb_time_audit_log_fsp("ftruncate", timediff, fsp);
1204 return result;
1207 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
1208 files_struct *fsp,
1209 enum vfs_fallocate_mode mode,
1210 off_t offset,
1211 off_t len)
1213 int result;
1214 struct timespec ts1,ts2;
1215 double timediff;
1217 clock_gettime_mono(&ts1);
1218 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
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_fsp("fallocate", timediff, fsp);
1226 return result;
1229 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1230 int op, off_t offset, off_t count,
1231 int type)
1233 bool result;
1234 struct timespec ts1,ts2;
1235 double timediff;
1237 clock_gettime_mono(&ts1);
1238 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1239 clock_gettime_mono(&ts2);
1240 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1242 if (timediff > audit_timeout) {
1243 smb_time_audit_log_fsp("lock", timediff, fsp);
1246 return result;
1249 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
1250 struct files_struct *fsp,
1251 uint32 share_mode, uint32 access_mask)
1253 int result;
1254 struct timespec ts1,ts2;
1255 double timediff;
1257 clock_gettime_mono(&ts1);
1258 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
1259 access_mask);
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("kernel_flock", timediff, fsp);
1267 return result;
1270 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1271 files_struct *fsp,
1272 int leasetype)
1274 int result;
1275 struct timespec ts1,ts2;
1276 double timediff;
1278 clock_gettime_mono(&ts1);
1279 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
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("linux_setlease", timediff, fsp);
1287 return result;
1290 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1291 files_struct *fsp,
1292 off_t *poffset, off_t *pcount,
1293 int *ptype, pid_t *ppid)
1295 bool result;
1296 struct timespec ts1,ts2;
1297 double timediff;
1299 clock_gettime_mono(&ts1);
1300 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1301 ppid);
1302 clock_gettime_mono(&ts2);
1303 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1305 if (timediff > audit_timeout) {
1306 smb_time_audit_log_fsp("getlock", timediff, fsp);
1309 return result;
1312 static int smb_time_audit_symlink(vfs_handle_struct *handle,
1313 const char *oldpath, const char *newpath)
1315 int result;
1316 struct timespec ts1,ts2;
1317 double timediff;
1319 clock_gettime_mono(&ts1);
1320 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1321 clock_gettime_mono(&ts2);
1322 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1324 if (timediff > audit_timeout) {
1325 smb_time_audit_log_fname("symlink", timediff, newpath);
1328 return result;
1331 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1332 const char *path, char *buf, size_t bufsiz)
1334 int result;
1335 struct timespec ts1,ts2;
1336 double timediff;
1338 clock_gettime_mono(&ts1);
1339 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1340 clock_gettime_mono(&ts2);
1341 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1343 if (timediff > audit_timeout) {
1344 smb_time_audit_log_fname("readlink", timediff, path);
1347 return result;
1350 static int smb_time_audit_link(vfs_handle_struct *handle,
1351 const char *oldpath, const char *newpath)
1353 int result;
1354 struct timespec ts1,ts2;
1355 double timediff;
1357 clock_gettime_mono(&ts1);
1358 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1359 clock_gettime_mono(&ts2);
1360 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1362 if (timediff > audit_timeout) {
1363 smb_time_audit_log_fname("link", timediff, newpath);
1366 return result;
1369 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1370 const char *pathname, mode_t mode,
1371 SMB_DEV_T dev)
1373 int result;
1374 struct timespec ts1,ts2;
1375 double timediff;
1377 clock_gettime_mono(&ts1);
1378 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1379 clock_gettime_mono(&ts2);
1380 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1382 if (timediff > audit_timeout) {
1383 smb_time_audit_log_fname("mknod", timediff, pathname);
1386 return result;
1389 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1390 const char *path)
1392 char *result;
1393 struct timespec ts1,ts2;
1394 double timediff;
1396 clock_gettime_mono(&ts1);
1397 result = SMB_VFS_NEXT_REALPATH(handle, path);
1398 clock_gettime_mono(&ts2);
1399 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1401 if (timediff > audit_timeout) {
1402 smb_time_audit_log_fname("realpath", timediff, path);
1405 return result;
1408 static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
1409 struct sys_notify_context *ctx,
1410 const char *path,
1411 uint32_t *filter,
1412 uint32_t *subdir_filter,
1413 void (*callback)(struct sys_notify_context *ctx,
1414 void *private_data,
1415 struct notify_event *ev),
1416 void *private_data, void *handle_p)
1418 NTSTATUS result;
1419 struct timespec ts1,ts2;
1420 double timediff;
1422 clock_gettime_mono(&ts1);
1423 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
1424 filter, subdir_filter, callback,
1425 private_data, handle_p);
1426 clock_gettime_mono(&ts2);
1427 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1429 if (timediff > audit_timeout) {
1430 smb_time_audit_log_fname("notify_watch", timediff, path);
1433 return result;
1436 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1437 const char *path, unsigned int flags)
1439 int result;
1440 struct timespec ts1,ts2;
1441 double timediff;
1443 clock_gettime_mono(&ts1);
1444 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1445 clock_gettime_mono(&ts2);
1446 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1448 if (timediff > audit_timeout) {
1449 smb_time_audit_log_fname("chflags", timediff, path);
1452 return result;
1455 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1456 const SMB_STRUCT_STAT *sbuf)
1458 struct file_id id_zero;
1459 struct file_id result;
1460 struct timespec ts1,ts2;
1461 double timediff;
1463 ZERO_STRUCT(id_zero);
1465 clock_gettime_mono(&ts1);
1466 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1467 clock_gettime_mono(&ts2);
1468 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1470 if (timediff > audit_timeout) {
1471 smb_time_audit_log("file_id_create", timediff);
1474 return result;
1477 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1478 struct files_struct *fsp,
1479 const char *fname,
1480 TALLOC_CTX *mem_ctx,
1481 unsigned int *pnum_streams,
1482 struct stream_struct **pstreams)
1484 NTSTATUS result;
1485 struct timespec ts1,ts2;
1486 double timediff;
1488 clock_gettime_mono(&ts1);
1489 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1490 pnum_streams, pstreams);
1491 clock_gettime_mono(&ts2);
1492 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1494 if (timediff > audit_timeout) {
1495 smb_time_audit_log_fsp("streaminfo", timediff, fsp);
1498 return result;
1501 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1502 const char *path,
1503 const char *name,
1504 TALLOC_CTX *mem_ctx,
1505 char **found_name)
1507 int result;
1508 struct timespec ts1,ts2;
1509 double timediff;
1511 clock_gettime_mono(&ts1);
1512 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1513 found_name);
1514 clock_gettime_mono(&ts2);
1515 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1517 if (timediff > audit_timeout) {
1518 smb_time_audit_log_fname("get_real_filename", timediff, path);
1521 return result;
1524 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1525 const char *fname)
1527 const char *result;
1528 struct timespec ts1,ts2;
1529 double timediff;
1531 clock_gettime_mono(&ts1);
1532 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1533 clock_gettime_mono(&ts2);
1534 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1536 if (timediff > audit_timeout) {
1537 smb_time_audit_log_fname("connectpath", timediff, fname);
1540 return result;
1543 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1544 struct byte_range_lock *br_lck,
1545 struct lock_struct *plock,
1546 bool blocking_lock,
1547 struct blocking_lock_record *blr)
1549 NTSTATUS result;
1550 struct timespec ts1,ts2;
1551 double timediff;
1553 clock_gettime_mono(&ts1);
1554 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1555 blocking_lock, blr);
1556 clock_gettime_mono(&ts2);
1557 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1559 if (timediff > audit_timeout) {
1560 smb_time_audit_log_fsp("brl_lock_windows", timediff,
1561 br_lck->fsp);
1564 return result;
1567 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1568 struct messaging_context *msg_ctx,
1569 struct byte_range_lock *br_lck,
1570 const struct lock_struct *plock)
1572 bool result;
1573 struct timespec ts1,ts2;
1574 double timediff;
1576 clock_gettime_mono(&ts1);
1577 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1578 plock);
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_fsp("brl_unlock_windows", timediff,
1584 br_lck->fsp);
1587 return result;
1590 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1591 struct byte_range_lock *br_lck,
1592 struct lock_struct *plock,
1593 struct blocking_lock_record *blr)
1595 bool result;
1596 struct timespec ts1,ts2;
1597 double timediff;
1599 clock_gettime_mono(&ts1);
1600 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1601 clock_gettime_mono(&ts2);
1602 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1604 if (timediff > audit_timeout) {
1605 smb_time_audit_log_fsp("brl_cancel_windows", timediff,
1606 br_lck->fsp);
1609 return result;
1612 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1613 struct files_struct *fsp,
1614 struct lock_struct *plock)
1616 bool result;
1617 struct timespec ts1,ts2;
1618 double timediff;
1620 clock_gettime_mono(&ts1);
1621 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1622 clock_gettime_mono(&ts2);
1623 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1625 if (timediff > audit_timeout) {
1626 smb_time_audit_log_fsp("strict_lock", timediff, fsp);
1629 return result;
1632 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1633 struct files_struct *fsp,
1634 struct lock_struct *plock)
1636 struct timespec ts1,ts2;
1637 double timediff;
1639 clock_gettime_mono(&ts1);
1640 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1641 clock_gettime_mono(&ts2);
1642 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1644 if (timediff > audit_timeout) {
1645 smb_time_audit_log_fsp("strict_unlock", timediff, fsp);
1649 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1650 const char *name,
1651 enum vfs_translate_direction direction,
1652 TALLOC_CTX *mem_ctx,
1653 char **mapped_name)
1655 NTSTATUS result;
1656 struct timespec ts1,ts2;
1657 double timediff;
1659 clock_gettime_mono(&ts1);
1660 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1661 mapped_name);
1662 clock_gettime_mono(&ts2);
1663 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1665 if (timediff > audit_timeout) {
1666 smb_time_audit_log_fname("translate_name", timediff, name);
1669 return result;
1672 struct time_audit_cc_state {
1673 struct timespec ts_send;
1674 struct vfs_handle_struct *handle;
1675 off_t copied;
1677 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq);
1679 static struct tevent_req *smb_time_audit_copy_chunk_send(struct vfs_handle_struct *handle,
1680 TALLOC_CTX *mem_ctx,
1681 struct tevent_context *ev,
1682 struct files_struct *src_fsp,
1683 off_t src_off,
1684 struct files_struct *dest_fsp,
1685 off_t dest_off,
1686 off_t num)
1688 struct tevent_req *req;
1689 struct tevent_req *subreq;
1690 struct time_audit_cc_state *cc_state;
1692 req = tevent_req_create(mem_ctx, &cc_state, struct time_audit_cc_state);
1693 if (req == NULL) {
1694 return NULL;
1697 cc_state->handle = handle;
1698 clock_gettime_mono(&cc_state->ts_send);
1699 subreq = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, cc_state, ev,
1700 src_fsp, src_off,
1701 dest_fsp, dest_off, num);
1702 if (tevent_req_nomem(subreq, req)) {
1703 return tevent_req_post(req, ev);
1706 tevent_req_set_callback(subreq, smb_time_audit_copy_chunk_done, req);
1707 return req;
1710 static void smb_time_audit_copy_chunk_done(struct tevent_req *subreq)
1712 struct tevent_req *req = tevent_req_callback_data(
1713 subreq, struct tevent_req);
1714 struct time_audit_cc_state *cc_state
1715 = tevent_req_data(req, struct time_audit_cc_state);
1716 NTSTATUS status;
1718 status = SMB_VFS_NEXT_COPY_CHUNK_RECV(cc_state->handle,
1719 subreq,
1720 &cc_state->copied);
1721 TALLOC_FREE(subreq);
1722 if (tevent_req_nterror(req, status)) {
1723 return;
1725 tevent_req_done(req);
1728 static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
1729 struct tevent_req *req,
1730 off_t *copied)
1732 struct time_audit_cc_state *cc_state
1733 = tevent_req_data(req, struct time_audit_cc_state);
1734 struct timespec ts_recv;
1735 double timediff;
1736 NTSTATUS status;
1738 clock_gettime_mono(&ts_recv);
1739 timediff = nsec_time_diff(&ts_recv, &cc_state->ts_send)*1.0e-9;
1740 if (timediff > audit_timeout) {
1741 smb_time_audit_log("copy_chunk", timediff);
1744 *copied = cc_state->copied;
1745 if (tevent_req_is_nterror(req, &status)) {
1746 tevent_req_received(req);
1747 return status;
1750 tevent_req_received(req);
1751 return NT_STATUS_OK;
1754 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
1755 files_struct *fsp,
1756 uint32 security_info,
1757 TALLOC_CTX *mem_ctx,
1758 struct security_descriptor **ppdesc)
1760 NTSTATUS result;
1761 struct timespec ts1,ts2;
1762 double timediff;
1764 clock_gettime_mono(&ts1);
1765 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
1766 mem_ctx, ppdesc);
1767 clock_gettime_mono(&ts2);
1768 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1770 if (timediff > audit_timeout) {
1771 smb_time_audit_log_fsp("fget_nt_acl", timediff, fsp);
1774 return result;
1777 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
1778 const char *name,
1779 uint32 security_info,
1780 TALLOC_CTX *mem_ctx,
1781 struct security_descriptor **ppdesc)
1783 NTSTATUS result;
1784 struct timespec ts1,ts2;
1785 double timediff;
1787 clock_gettime_mono(&ts1);
1788 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info,
1789 mem_ctx, ppdesc);
1790 clock_gettime_mono(&ts2);
1791 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1793 if (timediff > audit_timeout) {
1794 smb_time_audit_log_fname("get_nt_acl", timediff, name);
1797 return result;
1800 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
1801 files_struct *fsp,
1802 uint32 security_info_sent,
1803 const struct security_descriptor *psd)
1805 NTSTATUS result;
1806 struct timespec ts1,ts2;
1807 double timediff;
1809 clock_gettime_mono(&ts1);
1810 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
1811 psd);
1812 clock_gettime_mono(&ts2);
1813 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1815 if (timediff > audit_timeout) {
1816 smb_time_audit_log_fsp("fset_nt_acl", timediff, fsp);
1819 return result;
1822 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
1823 const char *path, mode_t mode)
1825 int result;
1826 struct timespec ts1,ts2;
1827 double timediff;
1829 clock_gettime_mono(&ts1);
1830 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1831 clock_gettime_mono(&ts2);
1832 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1834 if (timediff > audit_timeout) {
1835 smb_time_audit_log_fname("chmod_acl", timediff, path);
1838 return result;
1841 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
1842 files_struct *fsp, mode_t mode)
1844 int result;
1845 struct timespec ts1,ts2;
1846 double timediff;
1848 clock_gettime_mono(&ts1);
1849 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1850 clock_gettime_mono(&ts2);
1851 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1853 if (timediff > audit_timeout) {
1854 smb_time_audit_log_fsp("fchmod_acl", timediff, fsp);
1857 return result;
1860 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
1861 const char *path_p,
1862 SMB_ACL_TYPE_T type,
1863 TALLOC_CTX *mem_ctx)
1865 SMB_ACL_T result;
1866 struct timespec ts1,ts2;
1867 double timediff;
1869 clock_gettime_mono(&ts1);
1870 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type, mem_ctx);
1871 clock_gettime_mono(&ts2);
1872 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1874 if (timediff > audit_timeout) {
1875 smb_time_audit_log_fname("sys_acl_get_file", timediff, path_p);
1878 return result;
1881 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1882 files_struct *fsp,
1883 TALLOC_CTX *mem_ctx)
1885 SMB_ACL_T result;
1886 struct timespec ts1,ts2;
1887 double timediff;
1889 clock_gettime_mono(&ts1);
1890 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
1891 clock_gettime_mono(&ts2);
1892 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1894 if (timediff > audit_timeout) {
1895 smb_time_audit_log_fsp("sys_acl_get_fd", timediff, fsp);
1898 return result;
1902 static int smb_time_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
1903 const char *path_p,
1904 TALLOC_CTX *mem_ctx,
1905 char **blob_description,
1906 DATA_BLOB *blob)
1908 int result;
1909 struct timespec ts1,ts2;
1910 double timediff;
1912 clock_gettime_mono(&ts1);
1913 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx, blob_description, blob);
1914 clock_gettime_mono(&ts2);
1915 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1917 if (timediff > audit_timeout) {
1918 smb_time_audit_log("sys_acl_blob_get_file", timediff);
1921 return result;
1924 static int smb_time_audit_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1925 files_struct *fsp,
1926 TALLOC_CTX *mem_ctx,
1927 char **blob_description,
1928 DATA_BLOB *blob)
1930 int result;
1931 struct timespec ts1,ts2;
1932 double timediff;
1934 clock_gettime_mono(&ts1);
1935 result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx, blob_description, blob);
1936 clock_gettime_mono(&ts2);
1937 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1939 if (timediff > audit_timeout) {
1940 smb_time_audit_log("sys_acl_blob_get_fd", timediff);
1943 return result;
1946 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
1947 const char *name,
1948 SMB_ACL_TYPE_T acltype,
1949 SMB_ACL_T theacl)
1951 int result;
1952 struct timespec ts1,ts2;
1953 double timediff;
1955 clock_gettime_mono(&ts1);
1956 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1957 theacl);
1958 clock_gettime_mono(&ts2);
1959 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1961 if (timediff > audit_timeout) {
1962 smb_time_audit_log_fname("sys_acl_set_file", timediff, name);
1965 return result;
1968 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
1969 files_struct *fsp,
1970 SMB_ACL_T theacl)
1972 int result;
1973 struct timespec ts1,ts2;
1974 double timediff;
1976 clock_gettime_mono(&ts1);
1977 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1978 clock_gettime_mono(&ts2);
1979 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1981 if (timediff > audit_timeout) {
1982 smb_time_audit_log_fsp("sys_acl_set_fd", timediff, fsp);
1985 return result;
1988 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1989 const char *path)
1991 int result;
1992 struct timespec ts1,ts2;
1993 double timediff;
1995 clock_gettime_mono(&ts1);
1996 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1997 clock_gettime_mono(&ts2);
1998 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2000 if (timediff > audit_timeout) {
2001 smb_time_audit_log_fname("sys_acl_delete_def_file", timediff, path);
2004 return result;
2007 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2008 const char *path, const char *name,
2009 void *value, size_t size)
2011 ssize_t result;
2012 struct timespec ts1,ts2;
2013 double timediff;
2015 clock_gettime_mono(&ts1);
2016 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
2017 clock_gettime_mono(&ts2);
2018 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2020 if (timediff > audit_timeout) {
2021 smb_time_audit_log_fname("getxattr", timediff, path);
2024 return result;
2027 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2028 struct files_struct *fsp,
2029 const char *name, void *value,
2030 size_t size)
2032 ssize_t result;
2033 struct timespec ts1,ts2;
2034 double timediff;
2036 clock_gettime_mono(&ts1);
2037 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2038 clock_gettime_mono(&ts2);
2039 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2041 if (timediff > audit_timeout) {
2042 smb_time_audit_log_fsp("fgetxattr", timediff, fsp);
2045 return result;
2048 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2049 const char *path, char *list,
2050 size_t size)
2052 ssize_t result;
2053 struct timespec ts1,ts2;
2054 double timediff;
2056 clock_gettime_mono(&ts1);
2057 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2058 clock_gettime_mono(&ts2);
2059 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2061 if (timediff > audit_timeout) {
2062 smb_time_audit_log_fname("listxattr", timediff, path);
2065 return result;
2068 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2069 struct files_struct *fsp, char *list,
2070 size_t size)
2072 ssize_t result;
2073 struct timespec ts1,ts2;
2074 double timediff;
2076 clock_gettime_mono(&ts1);
2077 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2078 clock_gettime_mono(&ts2);
2079 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2081 if (timediff > audit_timeout) {
2082 smb_time_audit_log_fsp("flistxattr", timediff, fsp);
2085 return result;
2088 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2089 const char *path, const char *name)
2091 int result;
2092 struct timespec ts1,ts2;
2093 double timediff;
2095 clock_gettime_mono(&ts1);
2096 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2097 clock_gettime_mono(&ts2);
2098 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2100 if (timediff > audit_timeout) {
2101 smb_time_audit_log_fname("removexattr", timediff, path);
2104 return result;
2107 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2108 struct files_struct *fsp,
2109 const char *name)
2111 int result;
2112 struct timespec ts1,ts2;
2113 double timediff;
2115 clock_gettime_mono(&ts1);
2116 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2117 clock_gettime_mono(&ts2);
2118 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2120 if (timediff > audit_timeout) {
2121 smb_time_audit_log_fsp("fremovexattr", timediff, fsp);
2124 return result;
2127 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2128 const char *path, const char *name,
2129 const void *value, size_t size,
2130 int flags)
2132 int result;
2133 struct timespec ts1,ts2;
2134 double timediff;
2136 clock_gettime_mono(&ts1);
2137 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2138 flags);
2139 clock_gettime_mono(&ts2);
2140 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2142 if (timediff > audit_timeout) {
2143 smb_time_audit_log_fname("setxattr", timediff, path);
2146 return result;
2149 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2150 struct files_struct *fsp, const char *name,
2151 const void *value, size_t size, int flags)
2153 int result;
2154 struct timespec ts1,ts2;
2155 double timediff;
2157 clock_gettime_mono(&ts1);
2158 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2159 clock_gettime_mono(&ts2);
2160 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2162 if (timediff > audit_timeout) {
2163 smb_time_audit_log_fsp("fsetxattr", timediff, fsp);
2166 return result;
2169 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2170 struct files_struct *fsp)
2172 bool result;
2173 struct timespec ts1,ts2;
2174 double timediff;
2176 clock_gettime_mono(&ts1);
2177 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2178 clock_gettime_mono(&ts2);
2179 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2181 if (timediff > audit_timeout) {
2182 smb_time_audit_log_fsp("aio_force", timediff, fsp);
2185 return result;
2190 /* VFS operations */
2192 static struct vfs_fn_pointers vfs_time_audit_fns = {
2193 .connect_fn = smb_time_audit_connect,
2194 .disconnect_fn = smb_time_audit_disconnect,
2195 .disk_free_fn = smb_time_audit_disk_free,
2196 .get_quota_fn = smb_time_audit_get_quota,
2197 .set_quota_fn = smb_time_audit_set_quota,
2198 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2199 .statvfs_fn = smb_time_audit_statvfs,
2200 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2201 .opendir_fn = smb_time_audit_opendir,
2202 .fdopendir_fn = smb_time_audit_fdopendir,
2203 .readdir_fn = smb_time_audit_readdir,
2204 .seekdir_fn = smb_time_audit_seekdir,
2205 .telldir_fn = smb_time_audit_telldir,
2206 .rewind_dir_fn = smb_time_audit_rewinddir,
2207 .mkdir_fn = smb_time_audit_mkdir,
2208 .rmdir_fn = smb_time_audit_rmdir,
2209 .closedir_fn = smb_time_audit_closedir,
2210 .init_search_op_fn = smb_time_audit_init_search_op,
2211 .open_fn = smb_time_audit_open,
2212 .create_file_fn = smb_time_audit_create_file,
2213 .close_fn = smb_time_audit_close,
2214 .read_fn = smb_time_audit_read,
2215 .pread_fn = smb_time_audit_pread,
2216 .pread_send_fn = smb_time_audit_pread_send,
2217 .pread_recv_fn = smb_time_audit_pread_recv,
2218 .write_fn = smb_time_audit_write,
2219 .pwrite_fn = smb_time_audit_pwrite,
2220 .pwrite_send_fn = smb_time_audit_pwrite_send,
2221 .pwrite_recv_fn = smb_time_audit_pwrite_recv,
2222 .lseek_fn = smb_time_audit_lseek,
2223 .sendfile_fn = smb_time_audit_sendfile,
2224 .recvfile_fn = smb_time_audit_recvfile,
2225 .rename_fn = smb_time_audit_rename,
2226 .fsync_fn = smb_time_audit_fsync,
2227 .fsync_send_fn = smb_time_audit_fsync_send,
2228 .fsync_recv_fn = smb_time_audit_fsync_recv,
2229 .stat_fn = smb_time_audit_stat,
2230 .fstat_fn = smb_time_audit_fstat,
2231 .lstat_fn = smb_time_audit_lstat,
2232 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2233 .unlink_fn = smb_time_audit_unlink,
2234 .chmod_fn = smb_time_audit_chmod,
2235 .fchmod_fn = smb_time_audit_fchmod,
2236 .chown_fn = smb_time_audit_chown,
2237 .fchown_fn = smb_time_audit_fchown,
2238 .lchown_fn = smb_time_audit_lchown,
2239 .chdir_fn = smb_time_audit_chdir,
2240 .getwd_fn = smb_time_audit_getwd,
2241 .ntimes_fn = smb_time_audit_ntimes,
2242 .ftruncate_fn = smb_time_audit_ftruncate,
2243 .fallocate_fn = smb_time_audit_fallocate,
2244 .lock_fn = smb_time_audit_lock,
2245 .kernel_flock_fn = smb_time_audit_kernel_flock,
2246 .linux_setlease_fn = smb_time_audit_linux_setlease,
2247 .getlock_fn = smb_time_audit_getlock,
2248 .symlink_fn = smb_time_audit_symlink,
2249 .readlink_fn = smb_time_audit_readlink,
2250 .link_fn = smb_time_audit_link,
2251 .mknod_fn = smb_time_audit_mknod,
2252 .realpath_fn = smb_time_audit_realpath,
2253 .notify_watch_fn = smb_time_audit_notify_watch,
2254 .chflags_fn = smb_time_audit_chflags,
2255 .file_id_create_fn = smb_time_audit_file_id_create,
2256 .streaminfo_fn = smb_time_audit_streaminfo,
2257 .get_real_filename_fn = smb_time_audit_get_real_filename,
2258 .connectpath_fn = smb_time_audit_connectpath,
2259 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2260 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2261 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2262 .strict_lock_fn = smb_time_audit_strict_lock,
2263 .strict_unlock_fn = smb_time_audit_strict_unlock,
2264 .translate_name_fn = smb_time_audit_translate_name,
2265 .copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
2266 .copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
2267 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2268 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2269 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2270 .chmod_acl_fn = smb_time_audit_chmod_acl,
2271 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2272 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2273 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2274 .sys_acl_blob_get_file_fn = smb_time_audit_sys_acl_blob_get_file,
2275 .sys_acl_blob_get_fd_fn = smb_time_audit_sys_acl_blob_get_fd,
2276 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2277 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2278 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2279 .getxattr_fn = smb_time_audit_getxattr,
2280 .fgetxattr_fn = smb_time_audit_fgetxattr,
2281 .listxattr_fn = smb_time_audit_listxattr,
2282 .flistxattr_fn = smb_time_audit_flistxattr,
2283 .removexattr_fn = smb_time_audit_removexattr,
2284 .fremovexattr_fn = smb_time_audit_fremovexattr,
2285 .setxattr_fn = smb_time_audit_setxattr,
2286 .fsetxattr_fn = smb_time_audit_fsetxattr,
2287 .aio_force_fn = smb_time_audit_aio_force,
2291 NTSTATUS vfs_time_audit_init(void);
2292 NTSTATUS vfs_time_audit_init(void)
2294 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2295 10000) / 1000.0;
2296 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2297 &vfs_time_audit_fns);