s3-vfs: Add pread_send/recv to vfs modules
[Samba/gebeck_regimport.git] / source3 / modules / vfs_time_audit.c
blob140b856acb96565525cd2622f2306d4cc36833f6
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"
33 #undef DBGC_CLASS
34 #define DBGC_CLASS DBGC_VFS
36 static double audit_timeout;
38 static void smb_time_audit_log(const char *syscallname, double elapsed)
40 DEBUG(0, ("WARNING: System call \"%s\" took unexpectedly long "
41 "(%.2f seconds) -- Validate that file and storage "
42 "subsystems are operating normally\n", syscallname,
43 elapsed));
46 static int smb_time_audit_connect(vfs_handle_struct *handle,
47 const char *svc, const char *user)
49 int result;
50 struct timespec ts1,ts2;
51 double timediff;
53 if (!handle) {
54 return -1;
57 clock_gettime_mono(&ts1);
58 result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
59 clock_gettime_mono(&ts2);
60 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
61 if (timediff > audit_timeout) {
62 smb_time_audit_log("connect", timediff);
64 return result;
67 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
69 struct timespec ts1,ts2;
70 double timediff;
72 clock_gettime_mono(&ts1);
73 SMB_VFS_NEXT_DISCONNECT(handle);
74 clock_gettime_mono(&ts2);
75 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
77 if (timediff > audit_timeout) {
78 smb_time_audit_log("disconnect", timediff);
81 return;
84 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
85 const char *path,
86 bool small_query, uint64_t *bsize,
87 uint64_t *dfree, uint64_t *dsize)
89 uint64_t result;
90 struct timespec ts1,ts2;
91 double timediff;
93 clock_gettime_mono(&ts1);
94 result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
95 dfree, dsize);
96 clock_gettime_mono(&ts2);
97 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
99 /* Don't have a reasonable notion of failure here */
100 if (timediff > audit_timeout) {
101 smb_time_audit_log("disk_free", timediff);
104 return result;
107 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
108 enum SMB_QUOTA_TYPE qtype, unid_t id,
109 SMB_DISK_QUOTA *qt)
111 int result;
112 struct timespec ts1,ts2;
113 double timediff;
115 clock_gettime_mono(&ts1);
116 result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
117 clock_gettime_mono(&ts2);
118 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
120 if (timediff > audit_timeout) {
121 smb_time_audit_log("get_quota", timediff);
123 return result;
126 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
127 enum SMB_QUOTA_TYPE qtype, unid_t id,
128 SMB_DISK_QUOTA *qt)
130 int result;
131 struct timespec ts1,ts2;
132 double timediff;
134 clock_gettime_mono(&ts1);
135 result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
136 clock_gettime_mono(&ts2);
137 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
139 if (timediff > audit_timeout) {
140 smb_time_audit_log("set_quota", timediff);
143 return result;
146 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
147 struct files_struct *fsp,
148 struct shadow_copy_data *shadow_copy_data,
149 bool labels)
151 int result;
152 struct timespec ts1,ts2;
153 double timediff;
155 clock_gettime_mono(&ts1);
156 result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
157 shadow_copy_data, labels);
158 clock_gettime_mono(&ts2);
159 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
161 if (timediff > audit_timeout) {
162 smb_time_audit_log("get_shadow_copy_data", timediff);
165 return result;
168 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
169 const char *path,
170 struct vfs_statvfs_struct *statbuf)
172 int result;
173 struct timespec ts1,ts2;
174 double timediff;
176 clock_gettime_mono(&ts1);
177 result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
178 clock_gettime_mono(&ts2);
179 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
181 if (timediff > audit_timeout) {
182 smb_time_audit_log("statvfs", timediff);
185 return result;
188 static uint32_t smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle,
189 enum timestamp_set_resolution *p_ts_res)
191 uint32_t result;
192 struct timespec ts1,ts2;
193 double timediff;
195 clock_gettime_mono(&ts1);
196 result = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
197 clock_gettime_mono(&ts2);
198 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
200 if (timediff > audit_timeout) {
201 smb_time_audit_log("fs_capabilities", timediff);
204 return result;
207 static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
208 const char *fname,
209 const char *mask, uint32 attr)
211 DIR *result;
212 struct timespec ts1,ts2;
213 double timediff;
215 clock_gettime_mono(&ts1);
216 result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
217 clock_gettime_mono(&ts2);
218 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
220 if (timediff > audit_timeout) {
221 smb_time_audit_log("opendir", timediff);
224 return result;
227 static DIR *smb_time_audit_fdopendir(vfs_handle_struct *handle,
228 files_struct *fsp,
229 const char *mask, uint32 attr)
231 DIR *result;
232 struct timespec ts1,ts2;
233 double timediff;
235 clock_gettime_mono(&ts1);
236 result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
237 clock_gettime_mono(&ts2);
238 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
240 if (timediff > audit_timeout) {
241 smb_time_audit_log("fdopendir", timediff);
244 return result;
247 static struct dirent *smb_time_audit_readdir(vfs_handle_struct *handle,
248 DIR *dirp,
249 SMB_STRUCT_STAT *sbuf)
251 struct dirent *result;
252 struct timespec ts1,ts2;
253 double timediff;
255 clock_gettime_mono(&ts1);
256 result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
257 clock_gettime_mono(&ts2);
258 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
260 if (timediff > audit_timeout) {
261 smb_time_audit_log("readdir", timediff);
264 return result;
267 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
268 DIR *dirp, long offset)
270 struct timespec ts1,ts2;
271 double timediff;
273 clock_gettime_mono(&ts1);
274 SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
275 clock_gettime_mono(&ts2);
276 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
278 if (timediff > audit_timeout) {
279 smb_time_audit_log("seekdir", timediff);
282 return;
285 static long smb_time_audit_telldir(vfs_handle_struct *handle,
286 DIR *dirp)
288 long result;
289 struct timespec ts1,ts2;
290 double timediff;
292 clock_gettime_mono(&ts1);
293 result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
294 clock_gettime_mono(&ts2);
295 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
297 if (timediff > audit_timeout) {
298 smb_time_audit_log("telldir", timediff);
301 return result;
304 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
305 DIR *dirp)
307 struct timespec ts1,ts2;
308 double timediff;
310 clock_gettime_mono(&ts1);
311 SMB_VFS_NEXT_REWINDDIR(handle, dirp);
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("rewinddir", timediff);
319 return;
322 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
323 const char *path, mode_t mode)
325 int result;
326 struct timespec ts1,ts2;
327 double timediff;
329 clock_gettime_mono(&ts1);
330 result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
331 clock_gettime_mono(&ts2);
332 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
334 if (timediff > audit_timeout) {
335 smb_time_audit_log("mkdir", timediff);
338 return result;
341 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
342 const char *path)
344 int result;
345 struct timespec ts1,ts2;
346 double timediff;
348 clock_gettime_mono(&ts1);
349 result = SMB_VFS_NEXT_RMDIR(handle, path);
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("rmdir", timediff);
357 return result;
360 static int smb_time_audit_closedir(vfs_handle_struct *handle,
361 DIR *dirp)
363 int result;
364 struct timespec ts1,ts2;
365 double timediff;
367 clock_gettime_mono(&ts1);
368 result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
369 clock_gettime_mono(&ts2);
370 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
372 if (timediff > audit_timeout) {
373 smb_time_audit_log("closedir", timediff);
376 return result;
379 static void smb_time_audit_init_search_op(vfs_handle_struct *handle,
380 DIR *dirp)
382 struct timespec ts1,ts2;
383 double timediff;
385 clock_gettime_mono(&ts1);
386 SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
387 clock_gettime_mono(&ts2);
388 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
390 if (timediff > audit_timeout) {
391 smb_time_audit_log("init_search_op", timediff);
393 return;
396 static int smb_time_audit_open(vfs_handle_struct *handle,
397 struct smb_filename *fname,
398 files_struct *fsp,
399 int flags, mode_t mode)
401 int result;
402 struct timespec ts1,ts2;
403 double timediff;
405 clock_gettime_mono(&ts1);
406 result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
407 clock_gettime_mono(&ts2);
408 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
410 if (timediff > audit_timeout) {
411 smb_time_audit_log("open", timediff);
414 return result;
417 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
418 struct smb_request *req,
419 uint16_t root_dir_fid,
420 struct smb_filename *fname,
421 uint32_t access_mask,
422 uint32_t share_access,
423 uint32_t create_disposition,
424 uint32_t create_options,
425 uint32_t file_attributes,
426 uint32_t oplock_request,
427 uint64_t allocation_size,
428 uint32_t private_flags,
429 struct security_descriptor *sd,
430 struct ea_list *ea_list,
431 files_struct **result_fsp,
432 int *pinfo)
434 NTSTATUS result;
435 struct timespec ts1,ts2;
436 double timediff;
438 clock_gettime_mono(&ts1);
439 result = SMB_VFS_NEXT_CREATE_FILE(
440 handle, /* handle */
441 req, /* req */
442 root_dir_fid, /* root_dir_fid */
443 fname, /* fname */
444 access_mask, /* access_mask */
445 share_access, /* share_access */
446 create_disposition, /* create_disposition*/
447 create_options, /* create_options */
448 file_attributes, /* file_attributes */
449 oplock_request, /* oplock_request */
450 allocation_size, /* allocation_size */
451 private_flags,
452 sd, /* sd */
453 ea_list, /* ea_list */
454 result_fsp, /* result */
455 pinfo);
456 clock_gettime_mono(&ts2);
457 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
459 if (timediff > audit_timeout) {
460 smb_time_audit_log("create_file", timediff);
463 return result;
466 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
468 int result;
469 struct timespec ts1,ts2;
470 double timediff;
472 clock_gettime_mono(&ts1);
473 result = SMB_VFS_NEXT_CLOSE(handle, fsp);
474 clock_gettime_mono(&ts2);
475 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
477 if (timediff > audit_timeout) {
478 smb_time_audit_log("close", timediff);
481 return result;
484 static ssize_t smb_time_audit_read(vfs_handle_struct *handle,
485 files_struct *fsp, void *data, size_t n)
487 ssize_t result;
488 struct timespec ts1,ts2;
489 double timediff;
491 clock_gettime_mono(&ts1);
492 result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
493 clock_gettime_mono(&ts2);
494 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
496 if (timediff > audit_timeout) {
497 smb_time_audit_log("read", timediff);
500 return result;
503 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
504 files_struct *fsp,
505 void *data, size_t n, off_t offset)
507 ssize_t result;
508 struct timespec ts1,ts2;
509 double timediff;
511 clock_gettime_mono(&ts1);
512 result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
513 clock_gettime_mono(&ts2);
514 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
516 if (timediff > audit_timeout) {
517 smb_time_audit_log("pread", timediff);
520 return result;
523 struct smb_time_audit_pread_state {
524 struct timespec ts1;
525 ssize_t ret;
526 int err;
529 static void smb_time_audit_pread_done(struct tevent_req *subreq);
531 static struct tevent_req *smb_time_audit_pread_send(
532 struct vfs_handle_struct *handle, TALLOC_CTX *mem_ctx,
533 struct tevent_context *ev, struct files_struct *fsp,
534 void *data, size_t n, off_t offset)
536 struct tevent_req *req, *subreq;
537 struct smb_time_audit_pread_state *state;
539 req = tevent_req_create(mem_ctx, &state,
540 struct smb_time_audit_pread_state);
541 if (req == NULL) {
542 return NULL;
544 clock_gettime_mono(&state->ts1);
546 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
547 n, offset);
548 if (tevent_req_nomem(subreq, req)) {
549 return tevent_req_post(req, ev);
551 tevent_req_set_callback(subreq, smb_time_audit_pread_done, req);
552 return req;
555 static void smb_time_audit_pread_done(struct tevent_req *subreq)
557 struct tevent_req *req = tevent_req_callback_data(
558 subreq, struct tevent_req);
559 struct smb_time_audit_pread_state *state = tevent_req_data(
560 req, struct smb_time_audit_pread_state);
562 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
563 TALLOC_FREE(subreq);
564 tevent_req_done(req);
567 static ssize_t smb_time_audit_pread_recv(struct tevent_req *req, int *err)
569 struct smb_time_audit_pread_state *state = tevent_req_data(
570 req, struct smb_time_audit_pread_state);
571 struct timespec ts2;
572 double timediff;
574 clock_gettime_mono(&ts2);
575 timediff = nsec_time_diff(&ts2,&state->ts1)*1.0e-9;
577 if (timediff > audit_timeout) {
578 smb_time_audit_log("pread", timediff);
581 if (tevent_req_is_unix_error(req, err)) {
582 return -1;
584 *err = state->err;
585 return state->ret;
588 static ssize_t smb_time_audit_write(vfs_handle_struct *handle,
589 files_struct *fsp,
590 const void *data, size_t n)
592 ssize_t result;
593 struct timespec ts1,ts2;
594 double timediff;
596 clock_gettime_mono(&ts1);
597 result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
598 clock_gettime_mono(&ts2);
599 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
601 if (timediff > audit_timeout) {
602 smb_time_audit_log("write", timediff);
605 return result;
608 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
609 files_struct *fsp,
610 const void *data, size_t n,
611 off_t offset)
613 ssize_t result;
614 struct timespec ts1,ts2;
615 double timediff;
617 clock_gettime_mono(&ts1);
618 result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
619 clock_gettime_mono(&ts2);
620 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
622 if (timediff > audit_timeout) {
623 smb_time_audit_log("pwrite", timediff);
626 return result;
629 static off_t smb_time_audit_lseek(vfs_handle_struct *handle,
630 files_struct *fsp,
631 off_t offset, int whence)
633 off_t result;
634 struct timespec ts1,ts2;
635 double timediff;
637 clock_gettime_mono(&ts1);
638 result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
639 clock_gettime_mono(&ts2);
640 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
642 if (timediff > audit_timeout) {
643 smb_time_audit_log("lseek", timediff);
646 return result;
649 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
650 files_struct *fromfsp,
651 const DATA_BLOB *hdr, off_t offset,
652 size_t n)
654 ssize_t result;
655 struct timespec ts1,ts2;
656 double timediff;
658 clock_gettime_mono(&ts1);
659 result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
660 clock_gettime_mono(&ts2);
661 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
663 if (timediff > audit_timeout) {
664 smb_time_audit_log("sendfile", timediff);
667 return result;
670 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
671 files_struct *tofsp,
672 off_t offset,
673 size_t n)
675 ssize_t result;
676 struct timespec ts1,ts2;
677 double timediff;
679 clock_gettime_mono(&ts1);
680 result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
681 clock_gettime_mono(&ts2);
682 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
684 if (timediff > audit_timeout) {
685 smb_time_audit_log("recvfile", timediff);
688 return result;
691 static int smb_time_audit_rename(vfs_handle_struct *handle,
692 const struct smb_filename *oldname,
693 const struct smb_filename *newname)
695 int result;
696 struct timespec ts1,ts2;
697 double timediff;
699 clock_gettime_mono(&ts1);
700 result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
701 clock_gettime_mono(&ts2);
702 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
704 if (timediff > audit_timeout) {
705 smb_time_audit_log("rename", timediff);
708 return result;
711 static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
713 int result;
714 struct timespec ts1,ts2;
715 double timediff;
717 clock_gettime_mono(&ts1);
718 result = SMB_VFS_NEXT_FSYNC(handle, fsp);
719 clock_gettime_mono(&ts2);
720 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
722 if (timediff > audit_timeout) {
723 smb_time_audit_log("fsync", timediff);
726 return result;
729 static int smb_time_audit_stat(vfs_handle_struct *handle,
730 struct smb_filename *fname)
732 int result;
733 struct timespec ts1,ts2;
734 double timediff;
736 clock_gettime_mono(&ts1);
737 result = SMB_VFS_NEXT_STAT(handle, fname);
738 clock_gettime_mono(&ts2);
739 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
741 if (timediff > audit_timeout) {
742 smb_time_audit_log("stat", timediff);
745 return result;
748 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
749 SMB_STRUCT_STAT *sbuf)
751 int result;
752 struct timespec ts1,ts2;
753 double timediff;
755 clock_gettime_mono(&ts1);
756 result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
757 clock_gettime_mono(&ts2);
758 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
760 if (timediff > audit_timeout) {
761 smb_time_audit_log("fstat", timediff);
764 return result;
767 static int smb_time_audit_lstat(vfs_handle_struct *handle,
768 struct smb_filename *path)
770 int result;
771 struct timespec ts1,ts2;
772 double timediff;
774 clock_gettime_mono(&ts1);
775 result = SMB_VFS_NEXT_LSTAT(handle, path);
776 clock_gettime_mono(&ts2);
777 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
779 if (timediff > audit_timeout) {
780 smb_time_audit_log("lstat", timediff);
783 return result;
786 static uint64_t smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
787 files_struct *fsp,
788 const SMB_STRUCT_STAT *sbuf)
790 uint64_t result;
791 struct timespec ts1,ts2;
792 double timediff;
794 clock_gettime_mono(&ts1);
795 result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
796 clock_gettime_mono(&ts2);
797 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
799 if (timediff > audit_timeout) {
800 smb_time_audit_log("get_alloc_size", timediff);
803 return result;
806 static int smb_time_audit_unlink(vfs_handle_struct *handle,
807 const struct smb_filename *path)
809 int result;
810 struct timespec ts1,ts2;
811 double timediff;
813 clock_gettime_mono(&ts1);
814 result = SMB_VFS_NEXT_UNLINK(handle, path);
815 clock_gettime_mono(&ts2);
816 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
818 if (timediff > audit_timeout) {
819 smb_time_audit_log("unlink", timediff);
822 return result;
825 static int smb_time_audit_chmod(vfs_handle_struct *handle,
826 const char *path, mode_t mode)
828 int result;
829 struct timespec ts1,ts2;
830 double timediff;
832 clock_gettime_mono(&ts1);
833 result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
834 clock_gettime_mono(&ts2);
835 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
837 if (timediff > audit_timeout) {
838 smb_time_audit_log("chmod", timediff);
841 return result;
844 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
845 mode_t mode)
847 int result;
848 struct timespec ts1,ts2;
849 double timediff;
851 clock_gettime_mono(&ts1);
852 result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
853 clock_gettime_mono(&ts2);
854 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
856 if (timediff > audit_timeout) {
857 smb_time_audit_log("fchmod", timediff);
860 return result;
863 static int smb_time_audit_chown(vfs_handle_struct *handle,
864 const char *path, uid_t uid, gid_t gid)
866 int result;
867 struct timespec ts1,ts2;
868 double timediff;
870 clock_gettime_mono(&ts1);
871 result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
872 clock_gettime_mono(&ts2);
873 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
875 if (timediff > audit_timeout) {
876 smb_time_audit_log("chown", timediff);
879 return result;
882 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
883 uid_t uid, gid_t gid)
885 int result;
886 struct timespec ts1,ts2;
887 double timediff;
889 clock_gettime_mono(&ts1);
890 result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
891 clock_gettime_mono(&ts2);
892 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
894 if (timediff > audit_timeout) {
895 smb_time_audit_log("fchown", timediff);
898 return result;
901 static int smb_time_audit_lchown(vfs_handle_struct *handle,
902 const char *path, uid_t uid, gid_t gid)
904 int result;
905 struct timespec ts1,ts2;
906 double timediff;
908 clock_gettime_mono(&ts1);
909 result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
910 clock_gettime_mono(&ts2);
911 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
913 if (timediff > audit_timeout) {
914 smb_time_audit_log("lchown", timediff);
917 return result;
920 static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
922 int result;
923 struct timespec ts1,ts2;
924 double timediff;
926 clock_gettime_mono(&ts1);
927 result = SMB_VFS_NEXT_CHDIR(handle, path);
928 clock_gettime_mono(&ts2);
929 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
931 if (timediff > audit_timeout) {
932 smb_time_audit_log("chdir", timediff);
935 return result;
938 static char *smb_time_audit_getwd(vfs_handle_struct *handle)
940 char *result;
941 struct timespec ts1,ts2;
942 double timediff;
944 clock_gettime_mono(&ts1);
945 result = SMB_VFS_NEXT_GETWD(handle);
946 clock_gettime_mono(&ts2);
947 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
949 if (timediff > audit_timeout) {
950 smb_time_audit_log("getwd", timediff);
953 return result;
956 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
957 const struct smb_filename *path,
958 struct smb_file_time *ft)
960 int result;
961 struct timespec ts1,ts2;
962 double timediff;
964 clock_gettime_mono(&ts1);
965 result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
966 clock_gettime_mono(&ts2);
967 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
969 if (timediff > audit_timeout) {
970 smb_time_audit_log("ntimes", timediff);
973 return result;
976 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
977 files_struct *fsp,
978 off_t len)
980 int result;
981 struct timespec ts1,ts2;
982 double timediff;
984 clock_gettime_mono(&ts1);
985 result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
986 clock_gettime_mono(&ts2);
987 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
989 if (timediff > audit_timeout) {
990 smb_time_audit_log("ftruncate", timediff);
993 return result;
996 static int smb_time_audit_fallocate(vfs_handle_struct *handle,
997 files_struct *fsp,
998 enum vfs_fallocate_mode mode,
999 off_t offset,
1000 off_t len)
1002 int result;
1003 struct timespec ts1,ts2;
1004 double timediff;
1006 clock_gettime_mono(&ts1);
1007 result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
1008 clock_gettime_mono(&ts2);
1009 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1011 if (timediff > audit_timeout) {
1012 smb_time_audit_log("fallocate", timediff);
1015 return result;
1018 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
1019 int op, off_t offset, off_t count,
1020 int type)
1022 bool result;
1023 struct timespec ts1,ts2;
1024 double timediff;
1026 clock_gettime_mono(&ts1);
1027 result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
1028 clock_gettime_mono(&ts2);
1029 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1031 if (timediff > audit_timeout) {
1032 smb_time_audit_log("lock", timediff);
1035 return result;
1038 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
1039 struct files_struct *fsp,
1040 uint32 share_mode, uint32 access_mask)
1042 int result;
1043 struct timespec ts1,ts2;
1044 double timediff;
1046 clock_gettime_mono(&ts1);
1047 result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
1048 access_mask);
1049 clock_gettime_mono(&ts2);
1050 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1052 if (timediff > audit_timeout) {
1053 smb_time_audit_log("kernel_flock", timediff);
1056 return result;
1059 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
1060 files_struct *fsp,
1061 int leasetype)
1063 int result;
1064 struct timespec ts1,ts2;
1065 double timediff;
1067 clock_gettime_mono(&ts1);
1068 result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
1069 clock_gettime_mono(&ts2);
1070 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1072 if (timediff > audit_timeout) {
1073 smb_time_audit_log("linux_setlease", timediff);
1076 return result;
1079 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
1080 files_struct *fsp,
1081 off_t *poffset, off_t *pcount,
1082 int *ptype, pid_t *ppid)
1084 bool result;
1085 struct timespec ts1,ts2;
1086 double timediff;
1088 clock_gettime_mono(&ts1);
1089 result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
1090 ppid);
1091 clock_gettime_mono(&ts2);
1092 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1094 if (timediff > audit_timeout) {
1095 smb_time_audit_log("getlock", timediff);
1098 return result;
1101 static int smb_time_audit_symlink(vfs_handle_struct *handle,
1102 const char *oldpath, const char *newpath)
1104 int result;
1105 struct timespec ts1,ts2;
1106 double timediff;
1108 clock_gettime_mono(&ts1);
1109 result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
1110 clock_gettime_mono(&ts2);
1111 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1113 if (timediff > audit_timeout) {
1114 smb_time_audit_log("symlink", timediff);
1117 return result;
1120 static int smb_time_audit_readlink(vfs_handle_struct *handle,
1121 const char *path, char *buf, size_t bufsiz)
1123 int result;
1124 struct timespec ts1,ts2;
1125 double timediff;
1127 clock_gettime_mono(&ts1);
1128 result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
1129 clock_gettime_mono(&ts2);
1130 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1132 if (timediff > audit_timeout) {
1133 smb_time_audit_log("readlink", timediff);
1136 return result;
1139 static int smb_time_audit_link(vfs_handle_struct *handle,
1140 const char *oldpath, const char *newpath)
1142 int result;
1143 struct timespec ts1,ts2;
1144 double timediff;
1146 clock_gettime_mono(&ts1);
1147 result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
1148 clock_gettime_mono(&ts2);
1149 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1151 if (timediff > audit_timeout) {
1152 smb_time_audit_log("link", timediff);
1155 return result;
1158 static int smb_time_audit_mknod(vfs_handle_struct *handle,
1159 const char *pathname, mode_t mode,
1160 SMB_DEV_T dev)
1162 int result;
1163 struct timespec ts1,ts2;
1164 double timediff;
1166 clock_gettime_mono(&ts1);
1167 result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1168 clock_gettime_mono(&ts2);
1169 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1171 if (timediff > audit_timeout) {
1172 smb_time_audit_log("mknod", timediff);
1175 return result;
1178 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1179 const char *path)
1181 char *result;
1182 struct timespec ts1,ts2;
1183 double timediff;
1185 clock_gettime_mono(&ts1);
1186 result = SMB_VFS_NEXT_REALPATH(handle, path);
1187 clock_gettime_mono(&ts2);
1188 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1190 if (timediff > audit_timeout) {
1191 smb_time_audit_log("realpath", timediff);
1194 return result;
1197 static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
1198 struct sys_notify_context *ctx,
1199 const char *path,
1200 uint32_t *filter,
1201 uint32_t *subdir_filter,
1202 void (*callback)(struct sys_notify_context *ctx,
1203 void *private_data,
1204 struct notify_event *ev),
1205 void *private_data, void *handle_p)
1207 NTSTATUS result;
1208 struct timespec ts1,ts2;
1209 double timediff;
1211 clock_gettime_mono(&ts1);
1212 result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, path,
1213 filter, subdir_filter, callback,
1214 private_data, handle_p);
1215 clock_gettime_mono(&ts2);
1216 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1218 if (timediff > audit_timeout) {
1219 smb_time_audit_log("notify_watch", timediff);
1222 return result;
1225 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1226 const char *path, unsigned int flags)
1228 int result;
1229 struct timespec ts1,ts2;
1230 double timediff;
1232 clock_gettime_mono(&ts1);
1233 result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1234 clock_gettime_mono(&ts2);
1235 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1237 if (timediff > audit_timeout) {
1238 smb_time_audit_log("chflags", timediff);
1241 return result;
1244 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1245 const SMB_STRUCT_STAT *sbuf)
1247 struct file_id id_zero;
1248 struct file_id result;
1249 struct timespec ts1,ts2;
1250 double timediff;
1252 ZERO_STRUCT(id_zero);
1254 clock_gettime_mono(&ts1);
1255 result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1256 clock_gettime_mono(&ts2);
1257 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1259 if (timediff > audit_timeout) {
1260 smb_time_audit_log("file_id_create", timediff);
1263 return result;
1266 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1267 struct files_struct *fsp,
1268 const char *fname,
1269 TALLOC_CTX *mem_ctx,
1270 unsigned int *pnum_streams,
1271 struct stream_struct **pstreams)
1273 NTSTATUS result;
1274 struct timespec ts1,ts2;
1275 double timediff;
1277 clock_gettime_mono(&ts1);
1278 result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1279 pnum_streams, pstreams);
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("streaminfo", timediff);
1287 return result;
1290 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1291 const char *path,
1292 const char *name,
1293 TALLOC_CTX *mem_ctx,
1294 char **found_name)
1296 int result;
1297 struct timespec ts1,ts2;
1298 double timediff;
1300 clock_gettime_mono(&ts1);
1301 result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1302 found_name);
1303 clock_gettime_mono(&ts2);
1304 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1306 if (timediff > audit_timeout) {
1307 smb_time_audit_log("get_real_filename", timediff);
1310 return result;
1313 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1314 const char *fname)
1316 const char *result;
1317 struct timespec ts1,ts2;
1318 double timediff;
1320 clock_gettime_mono(&ts1);
1321 result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1322 clock_gettime_mono(&ts2);
1323 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1325 if (timediff > audit_timeout) {
1326 smb_time_audit_log("connectpath", timediff);
1329 return result;
1332 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1333 struct byte_range_lock *br_lck,
1334 struct lock_struct *plock,
1335 bool blocking_lock,
1336 struct blocking_lock_record *blr)
1338 NTSTATUS result;
1339 struct timespec ts1,ts2;
1340 double timediff;
1342 clock_gettime_mono(&ts1);
1343 result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1344 blocking_lock, blr);
1345 clock_gettime_mono(&ts2);
1346 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1348 if (timediff > audit_timeout) {
1349 smb_time_audit_log("brl_lock_windows", timediff);
1352 return result;
1355 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1356 struct messaging_context *msg_ctx,
1357 struct byte_range_lock *br_lck,
1358 const struct lock_struct *plock)
1360 bool result;
1361 struct timespec ts1,ts2;
1362 double timediff;
1364 clock_gettime_mono(&ts1);
1365 result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1366 plock);
1367 clock_gettime_mono(&ts2);
1368 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1370 if (timediff > audit_timeout) {
1371 smb_time_audit_log("brl_unlock_windows", timediff);
1374 return result;
1377 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1378 struct byte_range_lock *br_lck,
1379 struct lock_struct *plock,
1380 struct blocking_lock_record *blr)
1382 bool result;
1383 struct timespec ts1,ts2;
1384 double timediff;
1386 clock_gettime_mono(&ts1);
1387 result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1388 clock_gettime_mono(&ts2);
1389 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1391 if (timediff > audit_timeout) {
1392 smb_time_audit_log("brl_cancel_windows", timediff);
1395 return result;
1398 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1399 struct files_struct *fsp,
1400 struct lock_struct *plock)
1402 bool result;
1403 struct timespec ts1,ts2;
1404 double timediff;
1406 clock_gettime_mono(&ts1);
1407 result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1408 clock_gettime_mono(&ts2);
1409 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1411 if (timediff > audit_timeout) {
1412 smb_time_audit_log("strict_lock", timediff);
1415 return result;
1418 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1419 struct files_struct *fsp,
1420 struct lock_struct *plock)
1422 struct timespec ts1,ts2;
1423 double timediff;
1425 clock_gettime_mono(&ts1);
1426 SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1427 clock_gettime_mono(&ts2);
1428 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1430 if (timediff > audit_timeout) {
1431 smb_time_audit_log("strict_unlock", timediff);
1434 return;
1437 static NTSTATUS smb_time_audit_translate_name(struct vfs_handle_struct *handle,
1438 const char *name,
1439 enum vfs_translate_direction direction,
1440 TALLOC_CTX *mem_ctx,
1441 char **mapped_name)
1443 NTSTATUS result;
1444 struct timespec ts1,ts2;
1445 double timediff;
1447 clock_gettime_mono(&ts1);
1448 result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, name, direction, mem_ctx,
1449 mapped_name);
1450 clock_gettime_mono(&ts2);
1451 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1453 if (timediff > audit_timeout) {
1454 smb_time_audit_log("translate_name", timediff);
1457 return result;
1460 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
1461 files_struct *fsp,
1462 uint32 security_info,
1463 struct security_descriptor **ppdesc)
1465 NTSTATUS result;
1466 struct timespec ts1,ts2;
1467 double timediff;
1469 clock_gettime_mono(&ts1);
1470 result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1471 clock_gettime_mono(&ts2);
1472 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1474 if (timediff > audit_timeout) {
1475 smb_time_audit_log("fget_nt_acl", timediff);
1478 return result;
1481 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
1482 const char *name,
1483 uint32 security_info,
1484 struct security_descriptor **ppdesc)
1486 NTSTATUS result;
1487 struct timespec ts1,ts2;
1488 double timediff;
1490 clock_gettime_mono(&ts1);
1491 result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1492 clock_gettime_mono(&ts2);
1493 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1495 if (timediff > audit_timeout) {
1496 smb_time_audit_log("get_nt_acl", timediff);
1499 return result;
1502 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
1503 files_struct *fsp,
1504 uint32 security_info_sent,
1505 const struct security_descriptor *psd)
1507 NTSTATUS result;
1508 struct timespec ts1,ts2;
1509 double timediff;
1511 clock_gettime_mono(&ts1);
1512 result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
1513 psd);
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("fset_nt_acl", timediff);
1521 return result;
1524 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
1525 const char *path, mode_t mode)
1527 int result;
1528 struct timespec ts1,ts2;
1529 double timediff;
1531 clock_gettime_mono(&ts1);
1532 result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
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("chmod_acl", timediff);
1540 return result;
1543 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
1544 files_struct *fsp, mode_t mode)
1546 int result;
1547 struct timespec ts1,ts2;
1548 double timediff;
1550 clock_gettime_mono(&ts1);
1551 result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1552 clock_gettime_mono(&ts2);
1553 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1555 if (timediff > audit_timeout) {
1556 smb_time_audit_log("fchmod_acl", timediff);
1559 return result;
1562 static int smb_time_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1563 SMB_ACL_T theacl, int entry_id,
1564 SMB_ACL_ENTRY_T *entry_p)
1566 int result;
1567 struct timespec ts1,ts2;
1568 double timediff;
1570 clock_gettime_mono(&ts1);
1571 result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1572 entry_p);
1573 clock_gettime_mono(&ts2);
1574 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1576 if (timediff > audit_timeout) {
1577 smb_time_audit_log("sys_acl_get_entry", timediff);
1580 return result;
1583 static int smb_time_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1584 SMB_ACL_ENTRY_T entry_d,
1585 SMB_ACL_TAG_T *tag_type_p)
1587 int result;
1588 struct timespec ts1,ts2;
1589 double timediff;
1591 clock_gettime_mono(&ts1);
1592 result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1593 tag_type_p);
1594 clock_gettime_mono(&ts2);
1595 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1597 if (timediff > audit_timeout) {
1598 smb_time_audit_log("sys_acl_get_tag_type", timediff);
1601 return result;
1604 static int smb_time_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1605 SMB_ACL_ENTRY_T entry_d,
1606 SMB_ACL_PERMSET_T *permset_p)
1608 int result;
1609 struct timespec ts1,ts2;
1610 double timediff;
1612 clock_gettime_mono(&ts1);
1613 result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1614 permset_p);
1615 clock_gettime_mono(&ts2);
1616 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1618 if (timediff > audit_timeout) {
1619 smb_time_audit_log("sys_acl_get_permset", timediff);
1622 return result;
1625 static void * smb_time_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1626 SMB_ACL_ENTRY_T entry_d)
1628 void *result;
1629 struct timespec ts1,ts2;
1630 double timediff;
1632 clock_gettime_mono(&ts1);
1633 result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1634 clock_gettime_mono(&ts2);
1635 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1637 if (timediff > audit_timeout) {
1638 smb_time_audit_log("sys_acl_get_qualifier", timediff);
1641 return result;
1644 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
1645 const char *path_p,
1646 SMB_ACL_TYPE_T type)
1648 SMB_ACL_T result;
1649 struct timespec ts1,ts2;
1650 double timediff;
1652 clock_gettime_mono(&ts1);
1653 result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1654 clock_gettime_mono(&ts2);
1655 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1657 if (timediff > audit_timeout) {
1658 smb_time_audit_log("sys_acl_get_file", timediff);
1661 return result;
1664 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1665 files_struct *fsp)
1667 SMB_ACL_T result;
1668 struct timespec ts1,ts2;
1669 double timediff;
1671 clock_gettime_mono(&ts1);
1672 result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
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("sys_acl_get_fd", timediff);
1680 return result;
1683 static int smb_time_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1684 SMB_ACL_PERMSET_T permset)
1686 int result;
1687 struct timespec ts1,ts2;
1688 double timediff;
1690 clock_gettime_mono(&ts1);
1691 result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1692 clock_gettime_mono(&ts2);
1693 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1695 if (timediff > audit_timeout) {
1696 smb_time_audit_log("sys_acl_clear_perms", timediff);
1699 return result;
1702 static int smb_time_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1703 SMB_ACL_PERMSET_T permset,
1704 SMB_ACL_PERM_T perm)
1706 int result;
1707 struct timespec ts1,ts2;
1708 double timediff;
1710 clock_gettime_mono(&ts1);
1711 result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1712 clock_gettime_mono(&ts2);
1713 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1715 if (timediff > audit_timeout) {
1716 smb_time_audit_log("sys_acl_add_perm", timediff);
1719 return result;
1722 static char * smb_time_audit_sys_acl_to_text(vfs_handle_struct *handle,
1723 SMB_ACL_T theacl,
1724 ssize_t *plen)
1726 char * result;
1727 struct timespec ts1,ts2;
1728 double timediff;
1730 clock_gettime_mono(&ts1);
1731 result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1732 clock_gettime_mono(&ts2);
1733 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1735 if (timediff > audit_timeout) {
1736 smb_time_audit_log("sys_acl_to_text", timediff);
1739 return result;
1742 static SMB_ACL_T smb_time_audit_sys_acl_init(vfs_handle_struct *handle,
1743 int count)
1745 SMB_ACL_T result;
1746 struct timespec ts1,ts2;
1747 double timediff;
1749 clock_gettime_mono(&ts1);
1750 result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1751 clock_gettime_mono(&ts2);
1752 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1754 if (timediff > audit_timeout) {
1755 smb_time_audit_log("sys_acl_init", timediff);
1758 return result;
1761 static int smb_time_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1762 SMB_ACL_T *pacl,
1763 SMB_ACL_ENTRY_T *pentry)
1765 int result;
1766 struct timespec ts1,ts2;
1767 double timediff;
1769 clock_gettime_mono(&ts1);
1770 result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1771 clock_gettime_mono(&ts2);
1772 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1774 if (timediff > audit_timeout) {
1775 smb_time_audit_log("sys_acl_create_entry", timediff);
1778 return result;
1781 static int smb_time_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1782 SMB_ACL_ENTRY_T entry,
1783 SMB_ACL_TAG_T tagtype)
1785 int result;
1786 struct timespec ts1,ts2;
1787 double timediff;
1789 clock_gettime_mono(&ts1);
1790 result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1791 tagtype);
1792 clock_gettime_mono(&ts2);
1793 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1795 if (timediff > audit_timeout) {
1796 smb_time_audit_log("sys_acl_set_tag_type", timediff);
1799 return result;
1802 static int smb_time_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1803 SMB_ACL_ENTRY_T entry,
1804 void *qual)
1806 int result;
1807 struct timespec ts1,ts2;
1808 double timediff;
1810 clock_gettime_mono(&ts1);
1811 result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
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("sys_acl_set_qualifier", timediff);
1819 return result;
1822 static int smb_time_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1823 SMB_ACL_ENTRY_T entry,
1824 SMB_ACL_PERMSET_T permset)
1826 int result;
1827 struct timespec ts1,ts2;
1828 double timediff;
1830 clock_gettime_mono(&ts1);
1831 result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
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("sys_acl_set_permset", timediff);
1839 return result;
1842 static int smb_time_audit_sys_acl_valid(vfs_handle_struct *handle,
1843 SMB_ACL_T theacl)
1845 int result;
1846 struct timespec ts1,ts2;
1847 double timediff;
1849 clock_gettime_mono(&ts1);
1850 result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1851 clock_gettime_mono(&ts2);
1852 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1854 if (timediff > audit_timeout) {
1855 smb_time_audit_log("sys_acl_valid", timediff);
1858 return result;
1861 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
1862 const char *name,
1863 SMB_ACL_TYPE_T acltype,
1864 SMB_ACL_T theacl)
1866 int result;
1867 struct timespec ts1,ts2;
1868 double timediff;
1870 clock_gettime_mono(&ts1);
1871 result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1872 theacl);
1873 clock_gettime_mono(&ts2);
1874 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1876 if (timediff > audit_timeout) {
1877 smb_time_audit_log("sys_acl_set_file", timediff);
1880 return result;
1883 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
1884 files_struct *fsp,
1885 SMB_ACL_T theacl)
1887 int result;
1888 struct timespec ts1,ts2;
1889 double timediff;
1891 clock_gettime_mono(&ts1);
1892 result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1893 clock_gettime_mono(&ts2);
1894 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1896 if (timediff > audit_timeout) {
1897 smb_time_audit_log("sys_acl_set_fd", timediff);
1900 return result;
1903 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1904 const char *path)
1906 int result;
1907 struct timespec ts1,ts2;
1908 double timediff;
1910 clock_gettime_mono(&ts1);
1911 result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1912 clock_gettime_mono(&ts2);
1913 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1915 if (timediff > audit_timeout) {
1916 smb_time_audit_log("sys_acl_delete_def_file", timediff);
1919 return result;
1922 static int smb_time_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1923 SMB_ACL_PERMSET_T permset,
1924 SMB_ACL_PERM_T perm)
1926 int result;
1927 struct timespec ts1,ts2;
1928 double timediff;
1930 clock_gettime_mono(&ts1);
1931 result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1932 clock_gettime_mono(&ts2);
1933 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1935 if (timediff > audit_timeout) {
1936 smb_time_audit_log("sys_acl_get_perm", timediff);
1939 return result;
1942 static int smb_time_audit_sys_acl_free_text(vfs_handle_struct *handle,
1943 char *text)
1945 int result;
1946 struct timespec ts1,ts2;
1947 double timediff;
1949 clock_gettime_mono(&ts1);
1950 result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1951 clock_gettime_mono(&ts2);
1952 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1954 if (timediff > audit_timeout) {
1955 smb_time_audit_log("sys_acl_free_text", timediff);
1958 return result;
1961 static int smb_time_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1962 SMB_ACL_T posix_acl)
1964 int result;
1965 struct timespec ts1,ts2;
1966 double timediff;
1968 clock_gettime_mono(&ts1);
1969 result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1970 clock_gettime_mono(&ts2);
1971 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1973 if (timediff > audit_timeout) {
1974 smb_time_audit_log("sys_acl_free_acl", timediff);
1977 return result;
1980 static int smb_time_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1981 void *qualifier,
1982 SMB_ACL_TAG_T tagtype)
1984 int result;
1985 struct timespec ts1,ts2;
1986 double timediff;
1988 clock_gettime_mono(&ts1);
1989 result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1990 tagtype);
1991 clock_gettime_mono(&ts2);
1992 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
1994 if (timediff > audit_timeout) {
1995 smb_time_audit_log("sys_acl_free_qualifier", timediff);
1998 return result;
2001 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
2002 const char *path, const char *name,
2003 void *value, size_t size)
2005 ssize_t result;
2006 struct timespec ts1,ts2;
2007 double timediff;
2009 clock_gettime_mono(&ts1);
2010 result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
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("getxattr", timediff);
2018 return result;
2021 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
2022 struct files_struct *fsp,
2023 const char *name, void *value,
2024 size_t size)
2026 ssize_t result;
2027 struct timespec ts1,ts2;
2028 double timediff;
2030 clock_gettime_mono(&ts1);
2031 result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
2032 clock_gettime_mono(&ts2);
2033 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2035 if (timediff > audit_timeout) {
2036 smb_time_audit_log("fgetxattr", timediff);
2039 return result;
2042 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
2043 const char *path, char *list,
2044 size_t size)
2046 ssize_t result;
2047 struct timespec ts1,ts2;
2048 double timediff;
2050 clock_gettime_mono(&ts1);
2051 result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
2052 clock_gettime_mono(&ts2);
2053 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2055 if (timediff > audit_timeout) {
2056 smb_time_audit_log("listxattr", timediff);
2059 return result;
2062 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
2063 struct files_struct *fsp, char *list,
2064 size_t size)
2066 ssize_t result;
2067 struct timespec ts1,ts2;
2068 double timediff;
2070 clock_gettime_mono(&ts1);
2071 result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
2072 clock_gettime_mono(&ts2);
2073 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2075 if (timediff > audit_timeout) {
2076 smb_time_audit_log("flistxattr", timediff);
2079 return result;
2082 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
2083 const char *path, const char *name)
2085 int result;
2086 struct timespec ts1,ts2;
2087 double timediff;
2089 clock_gettime_mono(&ts1);
2090 result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
2091 clock_gettime_mono(&ts2);
2092 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2094 if (timediff > audit_timeout) {
2095 smb_time_audit_log("removexattr", timediff);
2098 return result;
2101 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
2102 struct files_struct *fsp,
2103 const char *name)
2105 int result;
2106 struct timespec ts1,ts2;
2107 double timediff;
2109 clock_gettime_mono(&ts1);
2110 result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
2111 clock_gettime_mono(&ts2);
2112 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2114 if (timediff > audit_timeout) {
2115 smb_time_audit_log("fremovexattr", timediff);
2118 return result;
2121 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
2122 const char *path, const char *name,
2123 const void *value, size_t size,
2124 int flags)
2126 int result;
2127 struct timespec ts1,ts2;
2128 double timediff;
2130 clock_gettime_mono(&ts1);
2131 result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
2132 flags);
2133 clock_gettime_mono(&ts2);
2134 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2136 if (timediff > audit_timeout) {
2137 smb_time_audit_log("setxattr", timediff);
2140 return result;
2143 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
2144 struct files_struct *fsp, const char *name,
2145 const void *value, size_t size, int flags)
2147 int result;
2148 struct timespec ts1,ts2;
2149 double timediff;
2151 clock_gettime_mono(&ts1);
2152 result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
2153 clock_gettime_mono(&ts2);
2154 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2156 if (timediff > audit_timeout) {
2157 smb_time_audit_log("fsetxattr", timediff);
2160 return result;
2163 static int smb_time_audit_aio_read(struct vfs_handle_struct *handle,
2164 struct files_struct *fsp,
2165 SMB_STRUCT_AIOCB *aiocb)
2167 int result;
2168 struct timespec ts1,ts2;
2169 double timediff;
2171 clock_gettime_mono(&ts1);
2172 result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2173 clock_gettime_mono(&ts2);
2174 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2176 if (timediff > audit_timeout) {
2177 smb_time_audit_log("aio_read", timediff);
2180 return result;
2183 static int smb_time_audit_aio_write(struct vfs_handle_struct *handle,
2184 struct files_struct *fsp,
2185 SMB_STRUCT_AIOCB *aiocb)
2187 int result;
2188 struct timespec ts1,ts2;
2189 double timediff;
2191 clock_gettime_mono(&ts1);
2192 result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2193 clock_gettime_mono(&ts2);
2194 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2196 if (timediff > audit_timeout) {
2197 smb_time_audit_log("aio_write", timediff);
2200 return result;
2203 static ssize_t smb_time_audit_aio_return(struct vfs_handle_struct *handle,
2204 struct files_struct *fsp,
2205 SMB_STRUCT_AIOCB *aiocb)
2207 ssize_t result;
2208 struct timespec ts1,ts2;
2209 double timediff;
2211 clock_gettime_mono(&ts1);
2212 result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2213 clock_gettime_mono(&ts2);
2214 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2216 if (timediff > audit_timeout) {
2217 smb_time_audit_log("aio_return", timediff);
2220 return result;
2223 static int smb_time_audit_aio_cancel(struct vfs_handle_struct *handle,
2224 struct files_struct *fsp,
2225 SMB_STRUCT_AIOCB *aiocb)
2227 int result;
2228 struct timespec ts1,ts2;
2229 double timediff;
2231 clock_gettime_mono(&ts1);
2232 result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2233 clock_gettime_mono(&ts2);
2234 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2236 if (timediff > audit_timeout) {
2237 smb_time_audit_log("aio_cancel", timediff);
2240 return result;
2243 static int smb_time_audit_aio_error(struct vfs_handle_struct *handle,
2244 struct files_struct *fsp,
2245 SMB_STRUCT_AIOCB *aiocb)
2247 int result;
2248 struct timespec ts1,ts2;
2249 double timediff;
2251 clock_gettime_mono(&ts1);
2252 result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2253 clock_gettime_mono(&ts2);
2254 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2256 if (timediff > audit_timeout) {
2257 smb_time_audit_log("aio_error", timediff);
2260 return result;
2263 static int smb_time_audit_aio_fsync(struct vfs_handle_struct *handle,
2264 struct files_struct *fsp, int op,
2265 SMB_STRUCT_AIOCB *aiocb)
2267 int result;
2268 struct timespec ts1,ts2;
2269 double timediff;
2271 clock_gettime_mono(&ts1);
2272 result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2273 clock_gettime_mono(&ts2);
2274 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2276 if (timediff > audit_timeout) {
2277 smb_time_audit_log("aio_fsync", timediff);
2280 return result;
2283 static int smb_time_audit_aio_suspend(struct vfs_handle_struct *handle,
2284 struct files_struct *fsp,
2285 const SMB_STRUCT_AIOCB * const aiocb[],
2286 int n, const struct timespec *ts)
2288 int result;
2289 struct timespec ts1,ts2;
2290 double timediff;
2292 clock_gettime_mono(&ts1);
2293 result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2294 clock_gettime_mono(&ts2);
2295 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2297 if (timediff > audit_timeout) {
2298 smb_time_audit_log("aio_suspend", timediff);
2301 return result;
2304 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2305 struct files_struct *fsp)
2307 bool result;
2308 struct timespec ts1,ts2;
2309 double timediff;
2311 clock_gettime_mono(&ts1);
2312 result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2313 clock_gettime_mono(&ts2);
2314 timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
2316 if (timediff > audit_timeout) {
2317 smb_time_audit_log("aio_force", timediff);
2320 return result;
2325 /* VFS operations */
2327 static struct vfs_fn_pointers vfs_time_audit_fns = {
2328 .connect_fn = smb_time_audit_connect,
2329 .disconnect_fn = smb_time_audit_disconnect,
2330 .disk_free_fn = smb_time_audit_disk_free,
2331 .get_quota_fn = smb_time_audit_get_quota,
2332 .set_quota_fn = smb_time_audit_set_quota,
2333 .get_shadow_copy_data_fn = smb_time_audit_get_shadow_copy_data,
2334 .statvfs_fn = smb_time_audit_statvfs,
2335 .fs_capabilities_fn = smb_time_audit_fs_capabilities,
2336 .opendir_fn = smb_time_audit_opendir,
2337 .fdopendir_fn = smb_time_audit_fdopendir,
2338 .readdir_fn = smb_time_audit_readdir,
2339 .seekdir_fn = smb_time_audit_seekdir,
2340 .telldir_fn = smb_time_audit_telldir,
2341 .rewind_dir_fn = smb_time_audit_rewinddir,
2342 .mkdir_fn = smb_time_audit_mkdir,
2343 .rmdir_fn = smb_time_audit_rmdir,
2344 .closedir_fn = smb_time_audit_closedir,
2345 .init_search_op_fn = smb_time_audit_init_search_op,
2346 .open_fn = smb_time_audit_open,
2347 .create_file_fn = smb_time_audit_create_file,
2348 .close_fn = smb_time_audit_close,
2349 .read_fn = smb_time_audit_read,
2350 .pread_fn = smb_time_audit_pread,
2351 .pread_send_fn = smb_time_audit_pread_send,
2352 .pread_recv_fn = smb_time_audit_pread_recv,
2353 .write_fn = smb_time_audit_write,
2354 .pwrite_fn = smb_time_audit_pwrite,
2355 .lseek_fn = smb_time_audit_lseek,
2356 .sendfile_fn = smb_time_audit_sendfile,
2357 .recvfile_fn = smb_time_audit_recvfile,
2358 .rename_fn = smb_time_audit_rename,
2359 .fsync_fn = smb_time_audit_fsync,
2360 .stat_fn = smb_time_audit_stat,
2361 .fstat_fn = smb_time_audit_fstat,
2362 .lstat_fn = smb_time_audit_lstat,
2363 .get_alloc_size_fn = smb_time_audit_get_alloc_size,
2364 .unlink_fn = smb_time_audit_unlink,
2365 .chmod_fn = smb_time_audit_chmod,
2366 .fchmod_fn = smb_time_audit_fchmod,
2367 .chown_fn = smb_time_audit_chown,
2368 .fchown_fn = smb_time_audit_fchown,
2369 .lchown_fn = smb_time_audit_lchown,
2370 .chdir_fn = smb_time_audit_chdir,
2371 .getwd_fn = smb_time_audit_getwd,
2372 .ntimes_fn = smb_time_audit_ntimes,
2373 .ftruncate_fn = smb_time_audit_ftruncate,
2374 .fallocate_fn = smb_time_audit_fallocate,
2375 .lock_fn = smb_time_audit_lock,
2376 .kernel_flock_fn = smb_time_audit_kernel_flock,
2377 .linux_setlease_fn = smb_time_audit_linux_setlease,
2378 .getlock_fn = smb_time_audit_getlock,
2379 .symlink_fn = smb_time_audit_symlink,
2380 .readlink_fn = smb_time_audit_readlink,
2381 .link_fn = smb_time_audit_link,
2382 .mknod_fn = smb_time_audit_mknod,
2383 .realpath_fn = smb_time_audit_realpath,
2384 .notify_watch_fn = smb_time_audit_notify_watch,
2385 .chflags_fn = smb_time_audit_chflags,
2386 .file_id_create_fn = smb_time_audit_file_id_create,
2387 .streaminfo_fn = smb_time_audit_streaminfo,
2388 .get_real_filename_fn = smb_time_audit_get_real_filename,
2389 .connectpath_fn = smb_time_audit_connectpath,
2390 .brl_lock_windows_fn = smb_time_audit_brl_lock_windows,
2391 .brl_unlock_windows_fn = smb_time_audit_brl_unlock_windows,
2392 .brl_cancel_windows_fn = smb_time_audit_brl_cancel_windows,
2393 .strict_lock_fn = smb_time_audit_strict_lock,
2394 .strict_unlock_fn = smb_time_audit_strict_unlock,
2395 .translate_name_fn = smb_time_audit_translate_name,
2396 .fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
2397 .get_nt_acl_fn = smb_time_audit_get_nt_acl,
2398 .fset_nt_acl_fn = smb_time_audit_fset_nt_acl,
2399 .chmod_acl_fn = smb_time_audit_chmod_acl,
2400 .fchmod_acl_fn = smb_time_audit_fchmod_acl,
2401 .sys_acl_get_entry_fn = smb_time_audit_sys_acl_get_entry,
2402 .sys_acl_get_tag_type_fn = smb_time_audit_sys_acl_get_tag_type,
2403 .sys_acl_get_permset_fn = smb_time_audit_sys_acl_get_permset,
2404 .sys_acl_get_qualifier_fn = smb_time_audit_sys_acl_get_qualifier,
2405 .sys_acl_get_file_fn = smb_time_audit_sys_acl_get_file,
2406 .sys_acl_get_fd_fn = smb_time_audit_sys_acl_get_fd,
2407 .sys_acl_clear_perms_fn = smb_time_audit_sys_acl_clear_perms,
2408 .sys_acl_add_perm_fn = smb_time_audit_sys_acl_add_perm,
2409 .sys_acl_to_text_fn = smb_time_audit_sys_acl_to_text,
2410 .sys_acl_init_fn = smb_time_audit_sys_acl_init,
2411 .sys_acl_create_entry_fn = smb_time_audit_sys_acl_create_entry,
2412 .sys_acl_set_tag_type_fn = smb_time_audit_sys_acl_set_tag_type,
2413 .sys_acl_set_qualifier_fn = smb_time_audit_sys_acl_set_qualifier,
2414 .sys_acl_set_permset_fn = smb_time_audit_sys_acl_set_permset,
2415 .sys_acl_valid_fn = smb_time_audit_sys_acl_valid,
2416 .sys_acl_set_file_fn = smb_time_audit_sys_acl_set_file,
2417 .sys_acl_set_fd_fn = smb_time_audit_sys_acl_set_fd,
2418 .sys_acl_delete_def_file_fn = smb_time_audit_sys_acl_delete_def_file,
2419 .sys_acl_get_perm_fn = smb_time_audit_sys_acl_get_perm,
2420 .sys_acl_free_text_fn = smb_time_audit_sys_acl_free_text,
2421 .sys_acl_free_acl_fn = smb_time_audit_sys_acl_free_acl,
2422 .sys_acl_free_qualifier_fn = smb_time_audit_sys_acl_free_qualifier,
2423 .getxattr_fn = smb_time_audit_getxattr,
2424 .fgetxattr_fn = smb_time_audit_fgetxattr,
2425 .listxattr_fn = smb_time_audit_listxattr,
2426 .flistxattr_fn = smb_time_audit_flistxattr,
2427 .removexattr_fn = smb_time_audit_removexattr,
2428 .fremovexattr_fn = smb_time_audit_fremovexattr,
2429 .setxattr_fn = smb_time_audit_setxattr,
2430 .fsetxattr_fn = smb_time_audit_fsetxattr,
2431 .aio_read_fn = smb_time_audit_aio_read,
2432 .aio_write_fn = smb_time_audit_aio_write,
2433 .aio_return_fn = smb_time_audit_aio_return,
2434 .aio_cancel_fn = smb_time_audit_aio_cancel,
2435 .aio_error_fn = smb_time_audit_aio_error,
2436 .aio_fsync_fn = smb_time_audit_aio_fsync,
2437 .aio_suspend_fn = smb_time_audit_aio_suspend,
2438 .aio_force_fn = smb_time_audit_aio_force,
2442 NTSTATUS vfs_time_audit_init(void);
2443 NTSTATUS vfs_time_audit_init(void)
2445 audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2446 10000) / 1000.0;
2447 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2448 &vfs_time_audit_fns);