Further refine the time_audit warning message
[metze/samba/wip.git] / source3 / modules / vfs_time_audit.c
1 /*
2  * Time auditing VFS module for samba.  Log time taken for VFS call to syslog
3  * facility.
4  *
5  * Copyright (C) Abhidnya Chirmule <achirmul@in.ibm.com> 2009
6  *
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.
11  *
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.
16  *
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/>.
19  */
20
21 /*
22  * This module implements logging for time taken for all Samba VFS operations.
23  *
24  * vfs objects = time_audit
25  */
26
27
28 #include "includes.h"
29
30 #undef DBGC_CLASS
31 #define DBGC_CLASS DBGC_VFS
32
33 static double audit_timeout;
34
35 static void smb_time_audit_log(const char *syscallname, double elapsed)
36 {
37         DEBUG(0, ("WARNING: System call \"%s\" took unexpectedly long "
38                   "(%.2f seconds) -- Validate that file and storage "
39                   "subsystems are operating normally\n", syscallname,
40                   elapsed));
41 }
42
43 static int smb_time_audit_connect(vfs_handle_struct *handle,
44                                   const char *svc, const char *user)
45 {
46         int result;
47         struct timeval tv;
48         double timediff;
49
50         if (!handle) {
51                 return -1;
52         }
53
54         GetTimeOfDay(&tv);
55         result = SMB_VFS_NEXT_CONNECT(handle, svc, user);
56         timediff = timeval_elapsed(&tv);
57         if (timediff > audit_timeout) {
58                 smb_time_audit_log("connect", timediff);
59         }
60         return result;
61 }
62
63 static void smb_time_audit_disconnect(vfs_handle_struct *handle)
64 {
65         struct timeval tv;
66         double timediff;
67
68         GetTimeOfDay(&tv);
69         SMB_VFS_NEXT_DISCONNECT(handle);
70         timediff = timeval_elapsed(&tv);
71
72         if (timediff > audit_timeout) {
73                 smb_time_audit_log("disconnect", timediff);
74         }
75
76         return;
77 }
78
79 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
80                                          const char *path,
81                                          bool small_query, uint64_t *bsize,
82                                          uint64_t *dfree, uint64_t *dsize)
83 {
84         uint64_t result;
85         struct timeval tv;
86         double timediff;
87
88         GetTimeOfDay(&tv);
89         result = SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize,
90                                         dfree, dsize);
91         timediff = timeval_elapsed(&tv);
92
93         /* Don't have a reasonable notion of failure here */
94         if (timediff > audit_timeout) {
95                 smb_time_audit_log("disk_free", timediff);
96         }
97
98         return result;
99 }
100
101 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
102                                     enum SMB_QUOTA_TYPE qtype, unid_t id,
103                                     SMB_DISK_QUOTA *qt)
104 {
105         int result;
106         struct timeval tv;
107         double timediff;
108
109         GetTimeOfDay(&tv);
110         result = SMB_VFS_NEXT_GET_QUOTA(handle, qtype, id, qt);
111         timediff = timeval_elapsed(&tv);
112
113         if (timediff > audit_timeout) {
114                 smb_time_audit_log("get_quota", timediff);
115         }
116         return result;
117 }
118
119 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
120                                     enum SMB_QUOTA_TYPE qtype, unid_t id,
121                                     SMB_DISK_QUOTA *qt)
122 {
123         int result;
124         struct timeval tv;
125         double timediff;
126
127         GetTimeOfDay(&tv);
128         result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
129         timediff = timeval_elapsed(&tv);
130
131         if (timediff > audit_timeout) {
132                 smb_time_audit_log("set_quota", timediff);
133         }
134
135         return result;
136 }
137
138 static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle,
139                                                struct files_struct *fsp,
140                                                SHADOW_COPY_DATA *shadow_copy_data,
141                                                bool labels)
142 {
143         int result;
144         struct timeval tv;
145         double timediff;
146
147         GetTimeOfDay(&tv);
148         result = SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp,
149                                                    shadow_copy_data, labels);
150         timediff = timeval_elapsed(&tv);
151
152         if (timediff > audit_timeout) {
153                 smb_time_audit_log("get_shadow_copy_data", timediff);
154         }
155
156         return result;
157 }
158
159 static int smb_time_audit_statvfs(struct vfs_handle_struct *handle,
160                                   const char *path,
161                                   struct vfs_statvfs_struct *statbuf)
162 {
163         int result;
164         struct timeval tv;
165         double timediff;
166
167         GetTimeOfDay(&tv);
168         result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf);
169         timediff = timeval_elapsed(&tv);
170
171         if (timediff > audit_timeout) {
172                 smb_time_audit_log("statvfs", timediff);
173         }
174
175         return result;
176 }
177
178 static int smb_time_audit_fs_capabilities(struct vfs_handle_struct *handle)
179 {
180         int result;
181         struct timeval tv;
182         double timediff;
183
184         GetTimeOfDay(&tv);
185         result = SMB_VFS_NEXT_FS_CAPABILITIES(handle);
186         timediff = timeval_elapsed(&tv);
187
188         if (timediff > audit_timeout) {
189                 smb_time_audit_log("fs_capabilities", timediff);
190         }
191
192         return result;
193 }
194
195 static SMB_STRUCT_DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
196                                               const char *fname,
197                                               const char *mask, uint32 attr)
198 {
199         SMB_STRUCT_DIR *result;
200         struct timeval tv;
201         double timediff;
202
203         GetTimeOfDay(&tv);
204         result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
205         timediff = timeval_elapsed(&tv);
206
207         if (timediff > audit_timeout) {
208                 smb_time_audit_log("opendir", timediff);
209         }
210
211         return result;
212 }
213
214 static SMB_STRUCT_DIRENT *smb_time_audit_readdir(vfs_handle_struct *handle,
215                                                  SMB_STRUCT_DIR *dirp,
216                                                  SMB_STRUCT_STAT *sbuf)
217 {
218         SMB_STRUCT_DIRENT *result;
219         struct timeval tv;
220         double timediff;
221
222         GetTimeOfDay(&tv);
223         result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
224         timediff = timeval_elapsed(&tv);
225
226         if (timediff > audit_timeout) {
227                 smb_time_audit_log("readdir", timediff);
228         }
229
230         return result;
231 }
232
233 static void smb_time_audit_seekdir(vfs_handle_struct *handle,
234                                    SMB_STRUCT_DIR *dirp, long offset)
235 {
236         struct timeval tv;
237         double timediff;
238
239         GetTimeOfDay(&tv);
240         SMB_VFS_NEXT_SEEKDIR(handle, dirp, offset);
241         timediff = timeval_elapsed(&tv);
242
243         if (timediff > audit_timeout) {
244                 smb_time_audit_log("seekdir", timediff);
245         }
246
247         return;
248 }
249
250 static long smb_time_audit_telldir(vfs_handle_struct *handle,
251                                    SMB_STRUCT_DIR *dirp)
252 {
253         long result;
254         struct timeval tv;
255         double timediff;
256
257         GetTimeOfDay(&tv);
258         result = SMB_VFS_NEXT_TELLDIR(handle, dirp);
259         timediff = timeval_elapsed(&tv);
260
261         if (timediff > audit_timeout) {
262                 smb_time_audit_log("telldir", timediff);
263         }
264
265         return result;
266 }
267
268 static void smb_time_audit_rewinddir(vfs_handle_struct *handle,
269                                      SMB_STRUCT_DIR *dirp)
270 {
271         struct timeval tv;
272         double timediff;
273
274         GetTimeOfDay(&tv);
275         SMB_VFS_NEXT_REWINDDIR(handle, dirp);
276         timediff = timeval_elapsed(&tv);
277
278         if (timediff > audit_timeout) {
279                 smb_time_audit_log("rewinddir", timediff);
280         }
281
282         return;
283 }
284
285 static int smb_time_audit_mkdir(vfs_handle_struct *handle,
286                                 const char *path, mode_t mode)
287 {
288         int result;
289         struct timeval tv;
290         double timediff;
291
292         GetTimeOfDay(&tv);
293         result = SMB_VFS_NEXT_MKDIR(handle, path, mode);
294         timediff = timeval_elapsed(&tv);
295
296         if (timediff > audit_timeout) {
297                 smb_time_audit_log("mkdir", timediff);
298         }
299
300         return result;
301 }
302
303 static int smb_time_audit_rmdir(vfs_handle_struct *handle,
304                                 const char *path)
305 {
306         int result;
307         struct timeval tv;
308         double timediff;
309
310         GetTimeOfDay(&tv);
311         result = SMB_VFS_NEXT_RMDIR(handle, path);
312         timediff = timeval_elapsed(&tv);
313
314         if (timediff > audit_timeout) {
315                 smb_time_audit_log("rmdir", timediff);
316         }
317
318         return result;
319 }
320
321 static int smb_time_audit_closedir(vfs_handle_struct *handle,
322                                    SMB_STRUCT_DIR *dirp)
323 {
324         int result;
325         struct timeval tv;
326         double timediff;
327
328         GetTimeOfDay(&tv);
329         result = SMB_VFS_NEXT_CLOSEDIR(handle, dirp);
330         timediff = timeval_elapsed(&tv);
331
332         if (timediff > audit_timeout) {
333                 smb_time_audit_log("closedir", timediff);
334         }
335
336         return result;
337 }
338
339 static void smb_time_audit_init_search_op(vfs_handle_struct *handle,
340                                           SMB_STRUCT_DIR *dirp)
341 {
342         struct timeval tv;
343         double timediff;
344
345         GetTimeOfDay(&tv);
346         SMB_VFS_NEXT_INIT_SEARCH_OP(handle, dirp);
347         timediff = timeval_elapsed(&tv);
348
349         if (timediff > audit_timeout) {
350                 smb_time_audit_log("init_search_op", timediff);
351         }
352         return;
353 }
354
355 static int smb_time_audit_open(vfs_handle_struct *handle,
356                                const char *fname, files_struct *fsp,
357                                int flags, mode_t mode)
358 {
359         int result;
360         struct timeval tv;
361         double timediff;
362
363         GetTimeOfDay(&tv);
364         result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode);
365         timediff = timeval_elapsed(&tv);
366
367         if (timediff > audit_timeout) {
368                 smb_time_audit_log("open", timediff);
369         }
370
371         return result;
372 }
373
374 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
375                                            struct smb_request *req,
376                                            uint16_t root_dir_fid,
377                                            const char *fname,
378                                            uint32_t create_file_flags,
379                                            uint32_t access_mask,
380                                            uint32_t share_access,
381                                            uint32_t create_disposition,
382                                            uint32_t create_options,
383                                            uint32_t file_attributes,
384                                            uint32_t oplock_request,
385                                            uint64_t allocation_size,
386                                            struct security_descriptor *sd,
387                                            struct ea_list *ea_list,
388                                            files_struct **result_fsp,
389                                            int *pinfo,
390                                            SMB_STRUCT_STAT *psbuf)
391 {
392         NTSTATUS result;
393         struct timeval tv;
394         double timediff;
395
396         GetTimeOfDay(&tv);
397         result = SMB_VFS_NEXT_CREATE_FILE(
398                 handle,                                 /* handle */
399                 req,                                    /* req */
400                 root_dir_fid,                           /* root_dir_fid */
401                 fname,                                  /* fname */
402                 create_file_flags,                      /* create_file_flags */
403                 access_mask,                            /* access_mask */
404                 share_access,                           /* share_access */
405                 create_disposition,                     /* create_disposition*/
406                 create_options,                         /* create_options */
407                 file_attributes,                        /* file_attributes */
408                 oplock_request,                         /* oplock_request */
409                 allocation_size,                        /* allocation_size */
410                 sd,                                     /* sd */
411                 ea_list,                                /* ea_list */
412                 result_fsp,                             /* result */
413                 pinfo,                                  /* pinfo */
414                 psbuf);                                 /* psbuf */
415         timediff = timeval_elapsed(&tv);
416
417         if (timediff > audit_timeout) {
418                 smb_time_audit_log("create_file", timediff);
419         }
420
421         return result;
422 }
423
424 static int smb_time_audit_close(vfs_handle_struct *handle, files_struct *fsp)
425 {
426         int result;
427         struct timeval tv;
428         double timediff;
429
430         GetTimeOfDay(&tv);
431         result = SMB_VFS_NEXT_CLOSE(handle, fsp);
432         timediff = timeval_elapsed(&tv);
433
434         if (timediff > audit_timeout) {
435                 smb_time_audit_log("close", timediff);
436         }
437
438         return result;
439 }
440
441 static ssize_t smb_time_audit_read(vfs_handle_struct *handle,
442                                    files_struct *fsp, void *data, size_t n)
443 {
444         ssize_t result;
445         struct timeval tv;
446         double timediff;
447
448         GetTimeOfDay(&tv);
449         result = SMB_VFS_NEXT_READ(handle, fsp, data, n);
450         timediff = timeval_elapsed(&tv);
451
452         if (timediff > audit_timeout) {
453                 smb_time_audit_log("read", timediff);
454         }
455
456         return result;
457 }
458
459 static ssize_t smb_time_audit_pread(vfs_handle_struct *handle,
460                                     files_struct *fsp,
461                                     void *data, size_t n, SMB_OFF_T offset)
462 {
463         ssize_t result;
464         struct timeval tv;
465         double timediff;
466
467         GetTimeOfDay(&tv);
468         result = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
469         timediff = timeval_elapsed(&tv);
470
471         if (timediff > audit_timeout) {
472                 smb_time_audit_log("pread", timediff);
473         }
474
475         return result;
476 }
477
478 static ssize_t smb_time_audit_write(vfs_handle_struct *handle,
479                                     files_struct *fsp,
480                                     const void *data, size_t n)
481 {
482         ssize_t result;
483         struct timeval tv;
484         double timediff;
485
486         GetTimeOfDay(&tv);
487         result = SMB_VFS_NEXT_WRITE(handle, fsp, data, n);
488         timediff = timeval_elapsed(&tv);
489
490         if (timediff > audit_timeout) {
491                 smb_time_audit_log("write", timediff);
492         }
493
494         return result;
495 }
496
497 static ssize_t smb_time_audit_pwrite(vfs_handle_struct *handle,
498                                      files_struct *fsp,
499                                      const void *data, size_t n,
500                                      SMB_OFF_T offset)
501 {
502         ssize_t result;
503         struct timeval tv;
504         double timediff;
505
506         GetTimeOfDay(&tv);
507         result = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
508         timediff = timeval_elapsed(&tv);
509
510         if (timediff > audit_timeout) {
511                 smb_time_audit_log("pwrite", timediff);
512         }
513
514         return result;
515 }
516
517 static SMB_OFF_T smb_time_audit_lseek(vfs_handle_struct *handle,
518                                       files_struct *fsp,
519                                       SMB_OFF_T offset, int whence)
520 {
521         ssize_t result;
522         struct timeval tv;
523         double timediff;
524
525         GetTimeOfDay(&tv);
526         result = SMB_VFS_NEXT_LSEEK(handle, fsp, offset, whence);
527         timediff = timeval_elapsed(&tv);
528
529         if (timediff > audit_timeout) {
530                 smb_time_audit_log("lseek", timediff);
531         }
532
533         return result;
534 }
535
536 static ssize_t smb_time_audit_sendfile(vfs_handle_struct *handle, int tofd,
537                                        files_struct *fromfsp,
538                                        const DATA_BLOB *hdr, SMB_OFF_T offset,
539                                        size_t n)
540 {
541         ssize_t result;
542         struct timeval tv;
543         double timediff;
544
545         GetTimeOfDay(&tv);
546         result = SMB_VFS_NEXT_SENDFILE(handle, tofd, fromfsp, hdr, offset, n);
547         timediff = timeval_elapsed(&tv);
548
549         if (timediff > audit_timeout) {
550                 smb_time_audit_log("sendfile", timediff);
551         }
552
553         return result;
554 }
555
556 static ssize_t smb_time_audit_recvfile(vfs_handle_struct *handle, int fromfd,
557                                        files_struct *tofsp,
558                                        SMB_OFF_T offset,
559                                        size_t n)
560 {
561         ssize_t result;
562         struct timeval tv;
563         double timediff;
564
565         GetTimeOfDay(&tv);
566         result = SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, n);
567         timediff = timeval_elapsed(&tv);
568
569         if (timediff > audit_timeout) {
570                 smb_time_audit_log("recvfile", timediff);
571         }
572
573         return result;
574 }
575
576 static int smb_time_audit_rename(vfs_handle_struct *handle,
577                                  const char *oldname, const char *newname)
578 {
579         int result;
580         struct timeval tv;
581         double timediff;
582
583         GetTimeOfDay(&tv);
584         result = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
585         timediff = timeval_elapsed(&tv);
586
587         if (timediff > audit_timeout) {
588                 smb_time_audit_log("rename", timediff);
589         }
590
591         return result;
592 }
593
594 static int smb_time_audit_fsync(vfs_handle_struct *handle, files_struct *fsp)
595 {
596         int result;
597         struct timeval tv;
598         double timediff;
599
600         GetTimeOfDay(&tv);
601         result = SMB_VFS_NEXT_FSYNC(handle, fsp);
602         timediff = timeval_elapsed(&tv);
603
604         if (timediff > audit_timeout) {
605                 smb_time_audit_log("fsync", timediff);
606         }
607
608         return result;
609 }
610
611 static int smb_time_audit_stat(vfs_handle_struct *handle,
612                                const char *fname, SMB_STRUCT_STAT *sbuf)
613 {
614         int result;
615         struct timeval tv;
616         double timediff;
617
618         GetTimeOfDay(&tv);
619         result = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
620         timediff = timeval_elapsed(&tv);
621
622         if (timediff > audit_timeout) {
623                 smb_time_audit_log("stat", timediff);
624         }
625
626         return result;
627 }
628
629 static int smb_time_audit_fstat(vfs_handle_struct *handle, files_struct *fsp,
630                                 SMB_STRUCT_STAT *sbuf)
631 {
632         int result;
633         struct timeval tv;
634         double timediff;
635
636         GetTimeOfDay(&tv);
637         result = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
638         timediff = timeval_elapsed(&tv);
639
640         if (timediff > audit_timeout) {
641                 smb_time_audit_log("fstat", timediff);
642         }
643
644         return result;
645 }
646
647 static int smb_time_audit_lstat(vfs_handle_struct *handle,
648                        const char *path, SMB_STRUCT_STAT *sbuf)
649 {
650         int result;
651         struct timeval tv;
652         double timediff;
653
654         GetTimeOfDay(&tv);
655         result = SMB_VFS_NEXT_LSTAT(handle, path, sbuf);
656         timediff = timeval_elapsed(&tv);
657
658         if (timediff > audit_timeout) {
659                 smb_time_audit_log("lstat", timediff);
660         }
661
662         return result;
663 }
664
665 static int smb_time_audit_get_alloc_size(vfs_handle_struct *handle,
666                                          files_struct *fsp,
667                                          const SMB_STRUCT_STAT *sbuf)
668 {
669         int result;
670         struct timeval tv;
671         double timediff;
672
673         GetTimeOfDay(&tv);
674         result = SMB_VFS_NEXT_GET_ALLOC_SIZE(handle, fsp, sbuf);
675         timediff = timeval_elapsed(&tv);
676
677         if (timediff > audit_timeout) {
678                 smb_time_audit_log("get_alloc_size", timediff);
679         }
680
681         return result;
682 }
683
684 static int smb_time_audit_unlink(vfs_handle_struct *handle,
685                                  const char *path)
686 {
687         int result;
688         struct timeval tv;
689         double timediff;
690
691         GetTimeOfDay(&tv);
692         result = SMB_VFS_NEXT_UNLINK(handle, path);
693         timediff = timeval_elapsed(&tv);
694
695         if (timediff > audit_timeout) {
696                 smb_time_audit_log("unlink", timediff);
697         }
698
699         return result;
700 }
701
702 static int smb_time_audit_chmod(vfs_handle_struct *handle,
703                                 const char *path, mode_t mode)
704 {
705         int result;
706         struct timeval tv;
707         double timediff;
708
709         GetTimeOfDay(&tv);
710         result = SMB_VFS_NEXT_CHMOD(handle, path, mode);
711         timediff = timeval_elapsed(&tv);
712
713         if (timediff > audit_timeout) {
714                 smb_time_audit_log("chmod", timediff);
715         }
716
717         return result;
718 }
719
720 static int smb_time_audit_fchmod(vfs_handle_struct *handle, files_struct *fsp,
721                                  mode_t mode)
722 {
723         int result;
724         struct timeval tv;
725         double timediff;
726
727         GetTimeOfDay(&tv);
728         result = SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
729         timediff = timeval_elapsed(&tv);
730
731         if (timediff > audit_timeout) {
732                 smb_time_audit_log("fchmod", timediff);
733         }
734
735         return result;
736 }
737
738 static int smb_time_audit_chown(vfs_handle_struct *handle,
739                                 const char *path, uid_t uid, gid_t gid)
740 {
741         int result;
742         struct timeval tv;
743         double timediff;
744
745         GetTimeOfDay(&tv);
746         result = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
747         timediff = timeval_elapsed(&tv);
748
749         if (timediff > audit_timeout) {
750                 smb_time_audit_log("chown", timediff);
751         }
752
753         return result;
754 }
755
756 static int smb_time_audit_fchown(vfs_handle_struct *handle, files_struct *fsp,
757                                  uid_t uid, gid_t gid)
758 {
759         int result;
760         struct timeval tv;
761         double timediff;
762
763         GetTimeOfDay(&tv);
764         result = SMB_VFS_NEXT_FCHOWN(handle, fsp, uid, gid);
765         timediff = timeval_elapsed(&tv);
766
767         if (timediff > audit_timeout) {
768                 smb_time_audit_log("fchown", timediff);
769         }
770
771         return result;
772 }
773
774 static int smb_time_audit_lchown(vfs_handle_struct *handle,
775                                  const char *path, uid_t uid, gid_t gid)
776 {
777         int result;
778         struct timeval tv;
779         double timediff;
780
781         GetTimeOfDay(&tv);
782         result = SMB_VFS_NEXT_LCHOWN(handle, path, uid, gid);
783         timediff = timeval_elapsed(&tv);
784
785         if (timediff > audit_timeout) {
786                 smb_time_audit_log("lchown", timediff);
787         }
788
789         return result;
790 }
791
792 static int smb_time_audit_chdir(vfs_handle_struct *handle, const char *path)
793 {
794         int result;
795         struct timeval tv;
796         double timediff;
797
798         GetTimeOfDay(&tv);
799         result = SMB_VFS_NEXT_CHDIR(handle, path);
800         timediff = timeval_elapsed(&tv);
801
802         if (timediff > audit_timeout) {
803                 smb_time_audit_log("chdir", timediff);
804         }
805
806         return result;
807 }
808
809 static char *smb_time_audit_getwd(vfs_handle_struct *handle, char *path)
810 {
811         char *result;
812         struct timeval tv;
813         double timediff;
814
815         GetTimeOfDay(&tv);
816         result = SMB_VFS_NEXT_GETWD(handle, path);
817         timediff = timeval_elapsed(&tv);
818
819         if (timediff > audit_timeout) {
820                 smb_time_audit_log("getwd", timediff);
821         }
822
823         return result;
824 }
825
826 static int smb_time_audit_ntimes(vfs_handle_struct *handle,
827                                  const char *path, struct smb_file_time *ft)
828 {
829         int result;
830         struct timeval tv;
831         double timediff;
832
833         GetTimeOfDay(&tv);
834         result = SMB_VFS_NEXT_NTIMES(handle, path, ft);
835         timediff = timeval_elapsed(&tv);
836
837         if (timediff > audit_timeout) {
838                 smb_time_audit_log("ntimes", timediff);
839         }
840
841         return result;
842 }
843
844 static int smb_time_audit_ftruncate(vfs_handle_struct *handle,
845                                     files_struct *fsp,
846                                     SMB_OFF_T len)
847 {
848         int result;
849         struct timeval tv;
850         double timediff;
851
852         GetTimeOfDay(&tv);
853         result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
854         timediff = timeval_elapsed(&tv);
855
856         if (timediff > audit_timeout) {
857                 smb_time_audit_log("ftruncate", timediff);
858         }
859
860         return result;
861 }
862
863 static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp,
864                                 int op, SMB_OFF_T offset, SMB_OFF_T count,
865                                 int type)
866 {
867         bool result;
868         struct timeval tv;
869         double timediff;
870
871         GetTimeOfDay(&tv);
872         result = SMB_VFS_NEXT_LOCK(handle, fsp, op, offset, count, type);
873         timediff = timeval_elapsed(&tv);
874
875         if (timediff > audit_timeout) {
876                 smb_time_audit_log("lock", timediff);
877         }
878
879         return result;
880 }
881
882 static int smb_time_audit_kernel_flock(struct vfs_handle_struct *handle,
883                                        struct files_struct *fsp,
884                                        uint32 share_mode, uint32 access_mask)
885 {
886         int result;
887         struct timeval tv;
888         double timediff;
889
890         GetTimeOfDay(&tv);
891         result = SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, share_mode,
892                                            access_mask);
893         timediff = timeval_elapsed(&tv);
894
895         if (timediff > audit_timeout) {
896                 smb_time_audit_log("kernel_flock", timediff);
897         }
898
899         return result;
900 }
901
902 static int smb_time_audit_linux_setlease(vfs_handle_struct *handle,
903                                          files_struct *fsp,
904                                          int leasetype)
905 {
906         int result;
907         struct timeval tv;
908         double timediff;
909
910         GetTimeOfDay(&tv);
911         result = SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, leasetype);
912         timediff = timeval_elapsed(&tv);
913
914         if (timediff > audit_timeout) {
915                 smb_time_audit_log("linux_setlease", timediff);
916         }
917
918         return result;
919 }
920
921 static bool smb_time_audit_getlock(vfs_handle_struct *handle,
922                                    files_struct *fsp,
923                                    SMB_OFF_T *poffset, SMB_OFF_T *pcount,
924                                    int *ptype, pid_t *ppid)
925 {
926         bool result;
927         struct timeval tv;
928         double timediff;
929
930         GetTimeOfDay(&tv);
931         result = SMB_VFS_NEXT_GETLOCK(handle, fsp, poffset, pcount, ptype,
932                                       ppid);
933         timediff = timeval_elapsed(&tv);
934
935         if (timediff > audit_timeout) {
936                 smb_time_audit_log("getlock", timediff);
937         }
938
939         return result;
940 }
941
942 static int smb_time_audit_symlink(vfs_handle_struct *handle,
943                                   const char *oldpath, const char *newpath)
944 {
945         int result;
946         struct timeval tv;
947         double timediff;
948
949         GetTimeOfDay(&tv);
950         result = SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
951         timediff = timeval_elapsed(&tv);
952
953         if (timediff > audit_timeout) {
954                 smb_time_audit_log("symlink", timediff);
955         }
956
957         return result;
958 }
959
960 static int smb_time_audit_readlink(vfs_handle_struct *handle,
961                           const char *path, char *buf, size_t bufsiz)
962 {
963         int result;
964         struct timeval tv;
965         double timediff;
966
967         GetTimeOfDay(&tv);
968         result = SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
969         timediff = timeval_elapsed(&tv);
970
971         if (timediff > audit_timeout) {
972                 smb_time_audit_log("readlink", timediff);
973         }
974
975         return result;
976 }
977
978 static int smb_time_audit_link(vfs_handle_struct *handle,
979                                const char *oldpath, const char *newpath)
980 {
981         int result;
982         struct timeval tv;
983         double timediff;
984
985         GetTimeOfDay(&tv);
986         result = SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
987         timediff = timeval_elapsed(&tv);
988
989         if (timediff > audit_timeout) {
990                 smb_time_audit_log("link", timediff);
991         }
992
993         return result;
994 }
995
996 static int smb_time_audit_mknod(vfs_handle_struct *handle,
997                                 const char *pathname, mode_t mode,
998                                 SMB_DEV_T dev)
999 {
1000         int result;
1001         struct timeval tv;
1002         double timediff;
1003
1004         GetTimeOfDay(&tv);
1005         result = SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
1006         timediff = timeval_elapsed(&tv);
1007
1008         if (timediff > audit_timeout) {
1009                 smb_time_audit_log("mknod", timediff);
1010         }
1011
1012         return result;
1013 }
1014
1015 static char *smb_time_audit_realpath(vfs_handle_struct *handle,
1016                                      const char *path, char *resolved_path)
1017 {
1018         char *result;
1019         struct timeval tv;
1020         double timediff;
1021
1022         GetTimeOfDay(&tv);
1023         result = SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
1024         timediff = timeval_elapsed(&tv);
1025
1026         if (timediff > audit_timeout) {
1027                 smb_time_audit_log("realpath", timediff);
1028         }
1029
1030         return result;
1031 }
1032
1033 static NTSTATUS smb_time_audit_notify_watch(struct vfs_handle_struct *handle,
1034                         struct sys_notify_context *ctx,
1035                         struct notify_entry *e,
1036                         void (*callback)(struct sys_notify_context *ctx,
1037                                         void *private_data,
1038                                         struct notify_event *ev),
1039                         void *private_data, void *handle_p)
1040 {
1041         NTSTATUS result;
1042         struct timeval tv;
1043         double timediff;
1044
1045         GetTimeOfDay(&tv);
1046         result = SMB_VFS_NEXT_NOTIFY_WATCH(handle, ctx, e, callback,
1047                                            private_data, handle_p);
1048         timediff = timeval_elapsed(&tv);
1049
1050         if (timediff > audit_timeout) {
1051                 smb_time_audit_log("notify_watch", timediff);
1052         }
1053
1054         return result;
1055 }
1056
1057 static int smb_time_audit_chflags(vfs_handle_struct *handle,
1058                                   const char *path, unsigned int flags)
1059 {
1060         int result;
1061         struct timeval tv;
1062         double timediff;
1063
1064         GetTimeOfDay(&tv);
1065         result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
1066         timediff = timeval_elapsed(&tv);
1067
1068         if (timediff > audit_timeout) {
1069                 smb_time_audit_log("chflags", timediff);
1070         }
1071
1072         return result;
1073 }
1074
1075 static struct file_id smb_time_audit_file_id_create(struct vfs_handle_struct *handle,
1076                                                     const SMB_STRUCT_STAT *sbuf)
1077 {
1078         struct file_id id_zero;
1079         struct file_id result;
1080         struct timeval tv;
1081         double timediff;
1082
1083         ZERO_STRUCT(id_zero);
1084
1085         GetTimeOfDay(&tv);
1086         result = SMB_VFS_NEXT_FILE_ID_CREATE(handle, sbuf);
1087         timediff = timeval_elapsed(&tv);
1088
1089         if (timediff > audit_timeout) {
1090                 smb_time_audit_log("file_id_create", timediff);
1091         }
1092
1093         return result;
1094 }
1095
1096 static NTSTATUS smb_time_audit_streaminfo(vfs_handle_struct *handle,
1097                                           struct files_struct *fsp,
1098                                           const char *fname,
1099                                           TALLOC_CTX *mem_ctx,
1100                                           unsigned int *pnum_streams,
1101                                           struct stream_struct **pstreams)
1102 {
1103         NTSTATUS result;
1104         struct timeval tv;
1105         double timediff;
1106
1107         GetTimeOfDay(&tv);
1108         result = SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx,
1109                                          pnum_streams, pstreams);
1110         timediff = timeval_elapsed(&tv);
1111
1112         if (timediff > audit_timeout) {
1113                 smb_time_audit_log("streaminfo", timediff);
1114         }
1115
1116         return result;
1117 }
1118
1119 static int smb_time_audit_get_real_filename(struct vfs_handle_struct *handle,
1120                                             const char *path,
1121                                             const char *name,
1122                                             TALLOC_CTX *mem_ctx,
1123                                             char **found_name)
1124 {
1125         int result;
1126         struct timeval tv;
1127         double timediff;
1128
1129         GetTimeOfDay(&tv);
1130         result = SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx,
1131                                                 found_name);
1132         timediff = timeval_elapsed(&tv);
1133
1134         if (timediff > audit_timeout) {
1135                 smb_time_audit_log("get_real_filename", timediff);
1136         }
1137
1138         return result;
1139 }
1140
1141 static const char *smb_time_audit_connectpath(vfs_handle_struct *handle,
1142                                               const char *fname)
1143 {
1144         const char *result;
1145         struct timeval tv;
1146         double timediff;
1147
1148         GetTimeOfDay(&tv);
1149         result = SMB_VFS_NEXT_CONNECTPATH(handle, fname);
1150         timediff = timeval_elapsed(&tv);
1151
1152         if (timediff > audit_timeout) {
1153                 smb_time_audit_log("connectpath", timediff);
1154         }
1155
1156         return result;
1157 }
1158
1159 static NTSTATUS smb_time_audit_brl_lock_windows(struct vfs_handle_struct *handle,
1160                                                 struct byte_range_lock *br_lck,
1161                                                 struct lock_struct *plock,
1162                                                 bool blocking_lock,
1163                                                 struct blocking_lock_record *blr)
1164 {
1165         NTSTATUS result;
1166         struct timeval tv;
1167         double timediff;
1168
1169         GetTimeOfDay(&tv);
1170         result = SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock,
1171                                                blocking_lock, blr);
1172         timediff = timeval_elapsed(&tv);
1173
1174         if (timediff > audit_timeout) {
1175                 smb_time_audit_log("brl_lock_windows", timediff);
1176         }
1177
1178         return result;
1179 }
1180
1181 static bool smb_time_audit_brl_unlock_windows(struct vfs_handle_struct *handle,
1182                                               struct messaging_context *msg_ctx,
1183                                               struct byte_range_lock *br_lck,
1184                                               const struct lock_struct *plock)
1185 {
1186         bool result;
1187         struct timeval tv;
1188         double timediff;
1189
1190         GetTimeOfDay(&tv);
1191         result = SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck,
1192                                                  plock);
1193         timediff = timeval_elapsed(&tv);
1194
1195         if (timediff > audit_timeout) {
1196                 smb_time_audit_log("brl_unlock_windows", timediff);
1197         }
1198
1199         return result;
1200 }
1201
1202 static bool smb_time_audit_brl_cancel_windows(struct vfs_handle_struct *handle,
1203                                               struct byte_range_lock *br_lck,
1204                                               struct lock_struct *plock,
1205                                               struct blocking_lock_record *blr)
1206 {
1207         bool result;
1208         struct timeval tv;
1209         double timediff;
1210
1211         GetTimeOfDay(&tv);
1212         result = SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr);
1213         timediff = timeval_elapsed(&tv);
1214
1215         if (timediff > audit_timeout) {
1216                 smb_time_audit_log("brl_cancel_windows", timediff);
1217         }
1218
1219         return result;
1220 }
1221
1222 static bool smb_time_audit_strict_lock(struct vfs_handle_struct *handle,
1223                                        struct files_struct *fsp,
1224                                        struct lock_struct *plock)
1225 {
1226         bool result;
1227         struct timeval tv;
1228         double timediff;
1229
1230         GetTimeOfDay(&tv);
1231         result = SMB_VFS_NEXT_STRICT_LOCK(handle, fsp, plock);
1232         timediff = timeval_elapsed(&tv);
1233
1234         if (timediff > audit_timeout) {
1235                 smb_time_audit_log("strict_lock", timediff);
1236         }
1237
1238         return result;
1239 }
1240
1241 static void smb_time_audit_strict_unlock(struct vfs_handle_struct *handle,
1242                                          struct files_struct *fsp,
1243                                          struct lock_struct *plock)
1244 {
1245         struct timeval tv;
1246         double timediff;
1247
1248         GetTimeOfDay(&tv);
1249         SMB_VFS_NEXT_STRICT_UNLOCK(handle, fsp, plock);
1250         timediff = timeval_elapsed(&tv);
1251
1252         if (timediff > audit_timeout) {
1253                 smb_time_audit_log("strict_unlock", timediff);
1254         }
1255
1256         return;
1257 }
1258
1259 static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
1260                                            files_struct *fsp,
1261                                            uint32 security_info,
1262                                            SEC_DESC **ppdesc)
1263 {
1264         NTSTATUS result;
1265         struct timeval tv;
1266         double timediff;
1267
1268         GetTimeOfDay(&tv);
1269         result = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc);
1270         timediff = timeval_elapsed(&tv);
1271
1272         if (timediff > audit_timeout) {
1273                 smb_time_audit_log("fget_nt_acl", timediff);
1274         }
1275
1276         return result;
1277 }
1278
1279 static NTSTATUS smb_time_audit_get_nt_acl(vfs_handle_struct *handle,
1280                                           const char *name,
1281                                           uint32 security_info,
1282                                           SEC_DESC **ppdesc)
1283 {
1284         NTSTATUS result;
1285         struct timeval tv;
1286         double timediff;
1287
1288         GetTimeOfDay(&tv);
1289         result = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
1290         timediff = timeval_elapsed(&tv);
1291
1292         if (timediff > audit_timeout) {
1293                 smb_time_audit_log("get_nt_acl", timediff);
1294         }
1295
1296         return result;
1297 }
1298
1299 static NTSTATUS smb_time_audit_fset_nt_acl(vfs_handle_struct *handle,
1300                                            files_struct *fsp,
1301                                            uint32 security_info_sent,
1302                                            const SEC_DESC *psd)
1303 {
1304         NTSTATUS result;
1305         struct timeval tv;
1306         double timediff;
1307
1308         GetTimeOfDay(&tv);
1309         result = SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent,
1310                                           psd);
1311         timediff = timeval_elapsed(&tv);
1312
1313         if (timediff > audit_timeout) {
1314                 smb_time_audit_log("fset_nt_acl", timediff);
1315         }
1316
1317         return result;
1318 }
1319
1320 static int smb_time_audit_chmod_acl(vfs_handle_struct *handle,
1321                                     const char *path, mode_t mode)
1322 {
1323         int result;
1324         struct timeval tv;
1325         double timediff;
1326
1327         GetTimeOfDay(&tv);
1328         result = SMB_VFS_NEXT_CHMOD_ACL(handle, path, mode);
1329         timediff = timeval_elapsed(&tv);
1330
1331         if (timediff > audit_timeout) {
1332                 smb_time_audit_log("chmod_acl", timediff);
1333         }
1334
1335         return result;
1336 }
1337
1338 static int smb_time_audit_fchmod_acl(vfs_handle_struct *handle,
1339                                      files_struct *fsp, mode_t mode)
1340 {
1341         int result;
1342         struct timeval tv;
1343         double timediff;
1344
1345         GetTimeOfDay(&tv);
1346         result = SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
1347         timediff = timeval_elapsed(&tv);
1348
1349         if (timediff > audit_timeout) {
1350                 smb_time_audit_log("fchmod_acl", timediff);
1351         }
1352
1353         return result;
1354 }
1355
1356 static int smb_time_audit_sys_acl_get_entry(vfs_handle_struct *handle,
1357                                             SMB_ACL_T theacl, int entry_id,
1358                                             SMB_ACL_ENTRY_T *entry_p)
1359 {
1360         int result;
1361         struct timeval tv;
1362         double timediff;
1363
1364         GetTimeOfDay(&tv);
1365         result = SMB_VFS_NEXT_SYS_ACL_GET_ENTRY(handle, theacl, entry_id,
1366                                                 entry_p);
1367         timediff = timeval_elapsed(&tv);
1368
1369         if (timediff > audit_timeout) {
1370                 smb_time_audit_log("sys_acl_get_entry", timediff);
1371         }
1372
1373         return result;
1374 }
1375
1376 static int smb_time_audit_sys_acl_get_tag_type(vfs_handle_struct *handle,
1377                                                SMB_ACL_ENTRY_T entry_d,
1378                                                SMB_ACL_TAG_T *tag_type_p)
1379 {
1380         int result;
1381         struct timeval tv;
1382         double timediff;
1383
1384         GetTimeOfDay(&tv);
1385         result = SMB_VFS_NEXT_SYS_ACL_GET_TAG_TYPE(handle, entry_d,
1386                                                    tag_type_p);
1387         timediff = timeval_elapsed(&tv);
1388
1389         if (timediff > audit_timeout) {
1390                 smb_time_audit_log("sys_acl_get_tag_type", timediff);
1391         }
1392
1393         return result;
1394 }
1395
1396 static int smb_time_audit_sys_acl_get_permset(vfs_handle_struct *handle,
1397                                               SMB_ACL_ENTRY_T entry_d,
1398                                               SMB_ACL_PERMSET_T *permset_p)
1399 {
1400         int result;
1401         struct timeval tv;
1402         double timediff;
1403
1404         GetTimeOfDay(&tv);
1405         result = SMB_VFS_NEXT_SYS_ACL_GET_PERMSET(handle, entry_d,
1406                                                   permset_p);
1407         timediff = timeval_elapsed(&tv);
1408
1409         if (timediff > audit_timeout) {
1410                 smb_time_audit_log("sys_acl_get_permset", timediff);
1411         }
1412
1413         return result;
1414 }
1415
1416 static void * smb_time_audit_sys_acl_get_qualifier(vfs_handle_struct *handle,
1417                                                    SMB_ACL_ENTRY_T entry_d)
1418 {
1419         void *result;
1420         struct timeval tv;
1421         double timediff;
1422
1423         GetTimeOfDay(&tv);
1424         result = SMB_VFS_NEXT_SYS_ACL_GET_QUALIFIER(handle, entry_d);
1425         timediff = timeval_elapsed(&tv);
1426
1427         if (timediff > audit_timeout) {
1428                 smb_time_audit_log("sys_acl_get_qualifier", timediff);
1429         }
1430
1431         return result;
1432 }
1433
1434 static SMB_ACL_T smb_time_audit_sys_acl_get_file(vfs_handle_struct *handle,
1435                                                  const char *path_p,
1436                                                  SMB_ACL_TYPE_T type)
1437 {
1438         SMB_ACL_T result;
1439         struct timeval tv;
1440         double timediff;
1441
1442         GetTimeOfDay(&tv);
1443         result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type);
1444         timediff = timeval_elapsed(&tv);
1445
1446         if (timediff > audit_timeout) {
1447                 smb_time_audit_log("sys_acl_get_file", timediff);
1448         }
1449
1450         return result;
1451 }
1452
1453 static SMB_ACL_T smb_time_audit_sys_acl_get_fd(vfs_handle_struct *handle,
1454                                                files_struct *fsp)
1455 {
1456         SMB_ACL_T result;
1457         struct timeval tv;
1458         double timediff;
1459
1460         GetTimeOfDay(&tv);
1461         result = SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp);
1462         timediff = timeval_elapsed(&tv);
1463
1464         if (timediff > audit_timeout) {
1465                 smb_time_audit_log("sys_acl_get_fd", timediff);
1466         }
1467
1468         return result;
1469 }
1470
1471 static int smb_time_audit_sys_acl_clear_perms(vfs_handle_struct *handle,
1472                                               SMB_ACL_PERMSET_T permset)
1473 {
1474         int result;
1475         struct timeval tv;
1476         double timediff;
1477
1478         GetTimeOfDay(&tv);
1479         result = SMB_VFS_NEXT_SYS_ACL_CLEAR_PERMS(handle, permset);
1480         timediff = timeval_elapsed(&tv);
1481
1482         if (timediff > audit_timeout) {
1483                 smb_time_audit_log("sys_acl_clear_perms", timediff);
1484         }
1485
1486         return result;
1487 }
1488
1489 static int smb_time_audit_sys_acl_add_perm(vfs_handle_struct *handle,
1490                                            SMB_ACL_PERMSET_T permset,
1491                                            SMB_ACL_PERM_T perm)
1492 {
1493         int result;
1494         struct timeval tv;
1495         double timediff;
1496
1497         GetTimeOfDay(&tv);
1498         result = SMB_VFS_NEXT_SYS_ACL_ADD_PERM(handle, permset, perm);
1499         timediff = timeval_elapsed(&tv);
1500
1501         if (timediff > audit_timeout) {
1502                 smb_time_audit_log("sys_acl_add_perm", timediff);
1503         }
1504
1505         return result;
1506 }
1507
1508 static char * smb_time_audit_sys_acl_to_text(vfs_handle_struct *handle,
1509                                              SMB_ACL_T theacl,
1510                                              ssize_t *plen)
1511 {
1512         char * result;
1513         struct timeval tv;
1514         double timediff;
1515
1516         GetTimeOfDay(&tv);
1517         result = SMB_VFS_NEXT_SYS_ACL_TO_TEXT(handle, theacl, plen);
1518         timediff = timeval_elapsed(&tv);
1519
1520         if (timediff > audit_timeout) {
1521                 smb_time_audit_log("sys_acl_to_text", timediff);
1522         }
1523
1524         return result;
1525 }
1526
1527 static SMB_ACL_T smb_time_audit_sys_acl_init(vfs_handle_struct *handle,
1528                                              int count)
1529 {
1530         SMB_ACL_T result;
1531         struct timeval tv;
1532         double timediff;
1533
1534         GetTimeOfDay(&tv);
1535         result = SMB_VFS_NEXT_SYS_ACL_INIT(handle, count);
1536         timediff = timeval_elapsed(&tv);
1537
1538         if (timediff > audit_timeout) {
1539                 smb_time_audit_log("sys_acl_init", timediff);
1540         }
1541
1542         return result;
1543 }
1544
1545 static int smb_time_audit_sys_acl_create_entry(vfs_handle_struct *handle,
1546                                                SMB_ACL_T *pacl,
1547                                                SMB_ACL_ENTRY_T *pentry)
1548 {
1549         int result;
1550         struct timeval tv;
1551         double timediff;
1552
1553         GetTimeOfDay(&tv);
1554         result = SMB_VFS_NEXT_SYS_ACL_CREATE_ENTRY(handle, pacl, pentry);
1555         timediff = timeval_elapsed(&tv);
1556
1557         if (timediff > audit_timeout) {
1558                 smb_time_audit_log("sys_acl_create_entry", timediff);
1559         }
1560
1561         return result;
1562 }
1563
1564 static int smb_time_audit_sys_acl_set_tag_type(vfs_handle_struct *handle,
1565                                                SMB_ACL_ENTRY_T entry,
1566                                                SMB_ACL_TAG_T tagtype)
1567 {
1568         int result;
1569         struct timeval tv;
1570         double timediff;
1571
1572         GetTimeOfDay(&tv);
1573         result = SMB_VFS_NEXT_SYS_ACL_SET_TAG_TYPE(handle, entry,
1574                                                    tagtype);
1575         timediff = timeval_elapsed(&tv);
1576
1577         if (timediff > audit_timeout) {
1578                 smb_time_audit_log("sys_acl_set_tag_type", timediff);
1579         }
1580
1581         return result;
1582 }
1583
1584 static int smb_time_audit_sys_acl_set_qualifier(vfs_handle_struct *handle,
1585                                                 SMB_ACL_ENTRY_T entry,
1586                                                 void *qual)
1587 {
1588         int result;
1589         struct timeval tv;
1590         double timediff;
1591
1592         GetTimeOfDay(&tv);
1593         result = SMB_VFS_NEXT_SYS_ACL_SET_QUALIFIER(handle, entry, qual);
1594         timediff = timeval_elapsed(&tv);
1595
1596         if (timediff > audit_timeout) {
1597                 smb_time_audit_log("sys_acl_set_qualifier", timediff);
1598         }
1599
1600         return result;
1601 }
1602
1603 static int smb_time_audit_sys_acl_set_permset(vfs_handle_struct *handle,
1604                                               SMB_ACL_ENTRY_T entry,
1605                                               SMB_ACL_PERMSET_T permset)
1606 {
1607         int result;
1608         struct timeval tv;
1609         double timediff;
1610
1611         GetTimeOfDay(&tv);
1612         result = SMB_VFS_NEXT_SYS_ACL_SET_PERMSET(handle, entry, permset);
1613         timediff = timeval_elapsed(&tv);
1614
1615         if (timediff > audit_timeout) {
1616                 smb_time_audit_log("sys_acl_set_permset", timediff);
1617         }
1618
1619         return result;
1620 }
1621
1622 static int smb_time_audit_sys_acl_valid(vfs_handle_struct *handle,
1623                                         SMB_ACL_T theacl)
1624 {
1625         int result;
1626         struct timeval tv;
1627         double timediff;
1628
1629         GetTimeOfDay(&tv);
1630         result = SMB_VFS_NEXT_SYS_ACL_VALID(handle, theacl);
1631         timediff = timeval_elapsed(&tv);
1632
1633         if (timediff > audit_timeout) {
1634                 smb_time_audit_log("sys_acl_valid", timediff);
1635         }
1636
1637         return result;
1638 }
1639
1640 static int smb_time_audit_sys_acl_set_file(vfs_handle_struct *handle,
1641                                            const char *name,
1642                                            SMB_ACL_TYPE_T acltype,
1643                                            SMB_ACL_T theacl)
1644 {
1645         int result;
1646         struct timeval tv;
1647         double timediff;
1648
1649         GetTimeOfDay(&tv);
1650         result = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, acltype,
1651                                                theacl);
1652         timediff = timeval_elapsed(&tv);
1653
1654         if (timediff > audit_timeout) {
1655                 smb_time_audit_log("sys_acl_set_file", timediff);
1656         }
1657
1658         return result;
1659 }
1660
1661 static int smb_time_audit_sys_acl_set_fd(vfs_handle_struct *handle,
1662                                          files_struct *fsp,
1663                                          SMB_ACL_T theacl)
1664 {
1665         int result;
1666         struct timeval tv;
1667         double timediff;
1668
1669         GetTimeOfDay(&tv);
1670         result = SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1671         timediff = timeval_elapsed(&tv);
1672
1673         if (timediff > audit_timeout) {
1674                 smb_time_audit_log("sys_acl_set_fd", timediff);
1675         }
1676
1677         return result;
1678 }
1679
1680 static int smb_time_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
1681                                                   const char *path)
1682 {
1683         int result;
1684         struct timeval tv;
1685         double timediff;
1686
1687         GetTimeOfDay(&tv);
1688         result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1689         timediff = timeval_elapsed(&tv);
1690
1691         if (timediff > audit_timeout) {
1692                 smb_time_audit_log("sys_acl_delete_def_file", timediff);
1693         }
1694
1695         return result;
1696 }
1697
1698 static int smb_time_audit_sys_acl_get_perm(vfs_handle_struct *handle,
1699                                            SMB_ACL_PERMSET_T permset,
1700                                            SMB_ACL_PERM_T perm)
1701 {
1702         int result;
1703         struct timeval tv;
1704         double timediff;
1705
1706         GetTimeOfDay(&tv);
1707         result = SMB_VFS_NEXT_SYS_ACL_GET_PERM(handle, permset, perm);
1708         timediff = timeval_elapsed(&tv);
1709
1710         if (timediff > audit_timeout) {
1711                 smb_time_audit_log("sys_acl_get_perm", timediff);
1712         }
1713
1714         return result;
1715 }
1716
1717 static int smb_time_audit_sys_acl_free_text(vfs_handle_struct *handle,
1718                                             char *text)
1719 {
1720         int result;
1721         struct timeval tv;
1722         double timediff;
1723
1724         GetTimeOfDay(&tv);
1725         result = SMB_VFS_NEXT_SYS_ACL_FREE_TEXT(handle, text);
1726         timediff = timeval_elapsed(&tv);
1727
1728         if (timediff > audit_timeout) {
1729                 smb_time_audit_log("sys_acl_free_text", timediff);
1730         }
1731
1732         return result;
1733 }
1734
1735 static int smb_time_audit_sys_acl_free_acl(vfs_handle_struct *handle,
1736                                            SMB_ACL_T posix_acl)
1737 {
1738         int result;
1739         struct timeval tv;
1740         double timediff;
1741
1742         GetTimeOfDay(&tv);
1743         result = SMB_VFS_NEXT_SYS_ACL_FREE_ACL(handle, posix_acl);
1744         timediff = timeval_elapsed(&tv);
1745
1746         if (timediff > audit_timeout) {
1747                 smb_time_audit_log("sys_acl_free_acl", timediff);
1748         }
1749
1750         return result;
1751 }
1752
1753 static int smb_time_audit_sys_acl_free_qualifier(vfs_handle_struct *handle,
1754                                                  void *qualifier,
1755                                                  SMB_ACL_TAG_T tagtype)
1756 {
1757         int result;
1758         struct timeval tv;
1759         double timediff;
1760
1761         GetTimeOfDay(&tv);
1762         result = SMB_VFS_NEXT_SYS_ACL_FREE_QUALIFIER(handle, qualifier,
1763                                                      tagtype);
1764         timediff = timeval_elapsed(&tv);
1765
1766         if (timediff > audit_timeout) {
1767                 smb_time_audit_log("sys_acl_free_qualifier", timediff);
1768         }
1769
1770         return result;
1771 }
1772
1773 static ssize_t smb_time_audit_getxattr(struct vfs_handle_struct *handle,
1774                                        const char *path, const char *name,
1775                                        void *value, size_t size)
1776 {
1777         ssize_t result;
1778         struct timeval tv;
1779         double timediff;
1780
1781         GetTimeOfDay(&tv);
1782         result = SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
1783         timediff = timeval_elapsed(&tv);
1784
1785         if (timediff > audit_timeout) {
1786                 smb_time_audit_log("getxattr", timediff);
1787         }
1788
1789         return result;
1790 }
1791
1792 static ssize_t smb_time_audit_lgetxattr(struct vfs_handle_struct *handle,
1793                                         const char *path, const char *name,
1794                                         void *value, size_t size)
1795 {
1796         ssize_t result;
1797         struct timeval tv;
1798         double timediff;
1799
1800         GetTimeOfDay(&tv);
1801         result = SMB_VFS_NEXT_LGETXATTR(handle, path, name, value, size);
1802         timediff = timeval_elapsed(&tv);
1803
1804         if (timediff > audit_timeout) {
1805                 smb_time_audit_log("lgetxattr", timediff);
1806         }
1807
1808         return result;
1809 }
1810
1811 static ssize_t smb_time_audit_fgetxattr(struct vfs_handle_struct *handle,
1812                                         struct files_struct *fsp,
1813                                         const char *name, void *value,
1814                                         size_t size)
1815 {
1816         ssize_t result;
1817         struct timeval tv;
1818         double timediff;
1819
1820         GetTimeOfDay(&tv);
1821         result = SMB_VFS_NEXT_FGETXATTR(handle, fsp, name, value, size);
1822         timediff = timeval_elapsed(&tv);
1823
1824         if (timediff > audit_timeout) {
1825                 smb_time_audit_log("fgetxattr", timediff);
1826         }
1827
1828         return result;
1829 }
1830
1831 static ssize_t smb_time_audit_listxattr(struct vfs_handle_struct *handle,
1832                                         const char *path, char *list,
1833                                         size_t size)
1834 {
1835         ssize_t result;
1836         struct timeval tv;
1837         double timediff;
1838
1839         GetTimeOfDay(&tv);
1840         result = SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
1841         timediff = timeval_elapsed(&tv);
1842
1843         if (timediff > audit_timeout) {
1844                 smb_time_audit_log("listxattr", timediff);
1845         }
1846
1847         return result;
1848 }
1849
1850 static ssize_t smb_time_audit_llistxattr(struct vfs_handle_struct *handle,
1851                                          const char *path, char *list,
1852                                          size_t size)
1853 {
1854         ssize_t result;
1855         struct timeval tv;
1856         double timediff;
1857
1858         GetTimeOfDay(&tv);
1859         result = SMB_VFS_NEXT_LLISTXATTR(handle, path, list, size);
1860         timediff = timeval_elapsed(&tv);
1861
1862         if (timediff > audit_timeout) {
1863                 smb_time_audit_log("llistxattr", timediff);
1864         }
1865
1866         return result;
1867 }
1868
1869 static ssize_t smb_time_audit_flistxattr(struct vfs_handle_struct *handle,
1870                                          struct files_struct *fsp, char *list,
1871                                          size_t size)
1872 {
1873         ssize_t result;
1874         struct timeval tv;
1875         double timediff;
1876
1877         GetTimeOfDay(&tv);
1878         result = SMB_VFS_NEXT_FLISTXATTR(handle, fsp, list, size);
1879         timediff = timeval_elapsed(&tv);
1880
1881         if (timediff > audit_timeout) {
1882                 smb_time_audit_log("flistxattr", timediff);
1883         }
1884
1885         return result;
1886 }
1887
1888 static int smb_time_audit_removexattr(struct vfs_handle_struct *handle,
1889                                       const char *path, const char *name)
1890 {
1891         int result;
1892         struct timeval tv;
1893         double timediff;
1894
1895         GetTimeOfDay(&tv);
1896         result = SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
1897         timediff = timeval_elapsed(&tv);
1898
1899         if (timediff > audit_timeout) {
1900                 smb_time_audit_log("removexattr", timediff);
1901         }
1902
1903         return result;
1904 }
1905
1906 static int smb_time_audit_lremovexattr(struct vfs_handle_struct *handle,
1907                                        const char *path, const char *name)
1908 {
1909         int result;
1910         struct timeval tv;
1911         double timediff;
1912
1913         GetTimeOfDay(&tv);
1914         result = SMB_VFS_NEXT_LREMOVEXATTR(handle, path, name);
1915         timediff = timeval_elapsed(&tv);
1916
1917         if (timediff > audit_timeout) {
1918                 smb_time_audit_log("lremovexattr", timediff);
1919         }
1920
1921         return result;
1922 }
1923
1924 static int smb_time_audit_fremovexattr(struct vfs_handle_struct *handle,
1925                                        struct files_struct *fsp,
1926                                        const char *name)
1927 {
1928         int result;
1929         struct timeval tv;
1930         double timediff;
1931
1932         GetTimeOfDay(&tv);
1933         result = SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, name);
1934         timediff = timeval_elapsed(&tv);
1935
1936         if (timediff > audit_timeout) {
1937                 smb_time_audit_log("fremovexattr", timediff);
1938         }
1939
1940         return result;
1941 }
1942
1943 static int smb_time_audit_setxattr(struct vfs_handle_struct *handle,
1944                                    const char *path, const char *name,
1945                                    const void *value, size_t size,
1946                                    int flags)
1947 {
1948         int result;
1949         struct timeval tv;
1950         double timediff;
1951
1952         GetTimeOfDay(&tv);
1953         result = SMB_VFS_NEXT_SETXATTR(handle, path, name, value, size,
1954                                        flags);
1955         timediff = timeval_elapsed(&tv);
1956
1957         if (timediff > audit_timeout) {
1958                 smb_time_audit_log("setxattr", timediff);
1959         }
1960
1961         return result;
1962 }
1963
1964 static int smb_time_audit_lsetxattr(struct vfs_handle_struct *handle,
1965                                     const char *path, const char *name,
1966                                     const void *value, size_t size,
1967                                     int flags)
1968 {
1969         int result;
1970         struct timeval tv;
1971         double timediff;
1972
1973         GetTimeOfDay(&tv);
1974         result = SMB_VFS_NEXT_LSETXATTR(handle, path, name, value, size,
1975                                         flags);
1976         timediff = timeval_elapsed(&tv);
1977
1978         if (timediff > audit_timeout) {
1979                 smb_time_audit_log("lsetxattr", timediff);
1980         }
1981
1982         return result;
1983 }
1984
1985 static int smb_time_audit_fsetxattr(struct vfs_handle_struct *handle,
1986                                     struct files_struct *fsp, const char *name,
1987                                     const void *value, size_t size, int flags)
1988 {
1989         int result;
1990         struct timeval tv;
1991         double timediff;
1992
1993         GetTimeOfDay(&tv);
1994         result = SMB_VFS_NEXT_FSETXATTR(handle, fsp, name, value, size, flags);
1995         timediff = timeval_elapsed(&tv);
1996
1997         if (timediff > audit_timeout) {
1998                 smb_time_audit_log("fsetxattr", timediff);
1999         }
2000
2001         return result;
2002 }
2003
2004 static int smb_time_audit_aio_read(struct vfs_handle_struct *handle,
2005                                    struct files_struct *fsp,
2006                                    SMB_STRUCT_AIOCB *aiocb)
2007 {
2008         int result;
2009         struct timeval tv;
2010         double timediff;
2011
2012         GetTimeOfDay(&tv);
2013         result = SMB_VFS_NEXT_AIO_READ(handle, fsp, aiocb);
2014         timediff = timeval_elapsed(&tv);
2015
2016         if (timediff > audit_timeout) {
2017                 smb_time_audit_log("aio_read", timediff);
2018         }
2019
2020         return result;
2021 }
2022
2023 static int smb_time_audit_aio_write(struct vfs_handle_struct *handle,
2024                                     struct files_struct *fsp,
2025                                     SMB_STRUCT_AIOCB *aiocb)
2026 {
2027         int result;
2028         struct timeval tv;
2029         double timediff;
2030
2031         GetTimeOfDay(&tv);
2032         result = SMB_VFS_NEXT_AIO_WRITE(handle, fsp, aiocb);
2033         timediff = timeval_elapsed(&tv);
2034
2035         if (timediff > audit_timeout) {
2036                 smb_time_audit_log("aio_write", timediff);
2037         }
2038
2039         return result;
2040 }
2041
2042 static ssize_t smb_time_audit_aio_return(struct vfs_handle_struct *handle,
2043                                          struct files_struct *fsp,
2044                                          SMB_STRUCT_AIOCB *aiocb)
2045 {
2046         int result;
2047         struct timeval tv;
2048         double timediff;
2049
2050         GetTimeOfDay(&tv);
2051         result = SMB_VFS_NEXT_AIO_RETURN(handle, fsp, aiocb);
2052         timediff = timeval_elapsed(&tv);
2053
2054         if (timediff > audit_timeout) {
2055                 smb_time_audit_log("aio_return", timediff);
2056         }
2057
2058         return result;
2059 }
2060
2061 static int smb_time_audit_aio_cancel(struct vfs_handle_struct *handle,
2062                                      struct files_struct *fsp,
2063                                      SMB_STRUCT_AIOCB *aiocb)
2064 {
2065         int result;
2066         struct timeval tv;
2067         double timediff;
2068
2069         GetTimeOfDay(&tv);
2070         result = SMB_VFS_NEXT_AIO_CANCEL(handle, fsp, aiocb);
2071         timediff = timeval_elapsed(&tv);
2072
2073         if (timediff > audit_timeout) {
2074                 smb_time_audit_log("aio_cancel", timediff);
2075         }
2076
2077         return result;
2078 }
2079
2080 static int smb_time_audit_aio_error(struct vfs_handle_struct *handle,
2081                                     struct files_struct *fsp,
2082                                     SMB_STRUCT_AIOCB *aiocb)
2083 {
2084         int result;
2085         struct timeval tv;
2086         double timediff;
2087
2088         GetTimeOfDay(&tv);
2089         result = SMB_VFS_NEXT_AIO_ERROR(handle, fsp, aiocb);
2090         timediff = timeval_elapsed(&tv);
2091
2092         if (timediff > audit_timeout) {
2093                 smb_time_audit_log("aio_error", timediff);
2094         }
2095
2096         return result;
2097 }
2098
2099 static int smb_time_audit_aio_fsync(struct vfs_handle_struct *handle,
2100                                     struct files_struct *fsp, int op,
2101                                     SMB_STRUCT_AIOCB *aiocb)
2102 {
2103         int result;
2104         struct timeval tv;
2105         double timediff;
2106
2107         GetTimeOfDay(&tv);
2108         result = SMB_VFS_NEXT_AIO_FSYNC(handle, fsp, op, aiocb);
2109         timediff = timeval_elapsed(&tv);
2110
2111         if (timediff > audit_timeout) {
2112                 smb_time_audit_log("aio_fsync", timediff);
2113         }
2114
2115         return result;
2116 }
2117
2118 static int smb_time_audit_aio_suspend(struct vfs_handle_struct *handle,
2119                                       struct files_struct *fsp,
2120                                       const SMB_STRUCT_AIOCB * const aiocb[],
2121                                       int n, const struct timespec *ts)
2122 {
2123         int result;
2124         struct timeval tv;
2125         double timediff;
2126
2127         GetTimeOfDay(&tv);
2128         result = SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
2129         timediff = timeval_elapsed(&tv);
2130
2131         if (timediff > audit_timeout) {
2132                 smb_time_audit_log("aio_suspend", timediff);
2133         }
2134
2135         return result;
2136 }
2137
2138 static bool smb_time_audit_aio_force(struct vfs_handle_struct *handle,
2139                                      struct files_struct *fsp)
2140 {
2141         bool result;
2142         struct timeval tv;
2143         double timediff;
2144
2145         GetTimeOfDay(&tv);
2146         result = SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
2147         timediff = timeval_elapsed(&tv);
2148
2149         if (timediff > audit_timeout) {
2150                 smb_time_audit_log("aio_force", timediff);
2151         }
2152
2153         return result;
2154 }
2155
2156
2157
2158 /* VFS operations */
2159
2160 static vfs_op_tuple audit_op_tuples[] = {
2161
2162         /* Disk operations */
2163
2164         {SMB_VFS_OP(smb_time_audit_connect),    SMB_VFS_OP_CONNECT,
2165          SMB_VFS_LAYER_LOGGER},
2166         {SMB_VFS_OP(smb_time_audit_disconnect), SMB_VFS_OP_DISCONNECT,
2167          SMB_VFS_LAYER_LOGGER},
2168         {SMB_VFS_OP(smb_time_audit_disk_free),  SMB_VFS_OP_DISK_FREE,
2169          SMB_VFS_LAYER_LOGGER},
2170         {SMB_VFS_OP(smb_time_audit_get_quota),  SMB_VFS_OP_GET_QUOTA,
2171          SMB_VFS_LAYER_LOGGER},
2172         {SMB_VFS_OP(smb_time_audit_set_quota),  SMB_VFS_OP_SET_QUOTA,
2173          SMB_VFS_LAYER_LOGGER},
2174         {SMB_VFS_OP(smb_time_audit_get_shadow_copy_data),
2175          SMB_VFS_OP_GET_SHADOW_COPY_DATA,
2176          SMB_VFS_LAYER_LOGGER},
2177         {SMB_VFS_OP(smb_time_audit_statvfs),    SMB_VFS_OP_STATVFS,
2178          SMB_VFS_LAYER_LOGGER},
2179         {SMB_VFS_OP(smb_time_audit_fs_capabilities),
2180          SMB_VFS_OP_FS_CAPABILITIES,
2181          SMB_VFS_LAYER_LOGGER},
2182
2183         /* Directory operations */
2184
2185         {SMB_VFS_OP(smb_time_audit_opendir),    SMB_VFS_OP_OPENDIR,
2186          SMB_VFS_LAYER_LOGGER},
2187         {SMB_VFS_OP(smb_time_audit_readdir),    SMB_VFS_OP_READDIR,
2188          SMB_VFS_LAYER_LOGGER},
2189         {SMB_VFS_OP(smb_time_audit_seekdir),    SMB_VFS_OP_SEEKDIR,
2190          SMB_VFS_LAYER_LOGGER},
2191         {SMB_VFS_OP(smb_time_audit_telldir),    SMB_VFS_OP_TELLDIR,
2192          SMB_VFS_LAYER_LOGGER},
2193         {SMB_VFS_OP(smb_time_audit_rewinddir),  SMB_VFS_OP_REWINDDIR,
2194          SMB_VFS_LAYER_LOGGER},
2195         {SMB_VFS_OP(smb_time_audit_mkdir),      SMB_VFS_OP_MKDIR,
2196          SMB_VFS_LAYER_LOGGER},
2197         {SMB_VFS_OP(smb_time_audit_rmdir),      SMB_VFS_OP_RMDIR,
2198          SMB_VFS_LAYER_LOGGER},
2199         {SMB_VFS_OP(smb_time_audit_closedir),   SMB_VFS_OP_CLOSEDIR,
2200          SMB_VFS_LAYER_LOGGER},
2201         {SMB_VFS_OP(smb_time_audit_init_search_op), SMB_VFS_OP_INIT_SEARCH_OP,
2202          SMB_VFS_LAYER_LOGGER},
2203
2204         /* File operations */
2205
2206         {SMB_VFS_OP(smb_time_audit_open),       SMB_VFS_OP_OPEN,
2207          SMB_VFS_LAYER_LOGGER},
2208         {SMB_VFS_OP(smb_time_audit_create_file),SMB_VFS_OP_CREATE_FILE,
2209          SMB_VFS_LAYER_LOGGER},
2210         {SMB_VFS_OP(smb_time_audit_close),      SMB_VFS_OP_CLOSE,
2211          SMB_VFS_LAYER_LOGGER},
2212         {SMB_VFS_OP(smb_time_audit_read),       SMB_VFS_OP_READ,
2213          SMB_VFS_LAYER_LOGGER},
2214         {SMB_VFS_OP(smb_time_audit_pread),      SMB_VFS_OP_PREAD,
2215          SMB_VFS_LAYER_LOGGER},
2216         {SMB_VFS_OP(smb_time_audit_write),      SMB_VFS_OP_WRITE,
2217          SMB_VFS_LAYER_LOGGER},
2218         {SMB_VFS_OP(smb_time_audit_pwrite),     SMB_VFS_OP_PWRITE,
2219          SMB_VFS_LAYER_LOGGER},
2220         {SMB_VFS_OP(smb_time_audit_lseek),      SMB_VFS_OP_LSEEK,
2221          SMB_VFS_LAYER_LOGGER},
2222         {SMB_VFS_OP(smb_time_audit_sendfile),   SMB_VFS_OP_SENDFILE,
2223          SMB_VFS_LAYER_LOGGER},
2224         {SMB_VFS_OP(smb_time_audit_recvfile),   SMB_VFS_OP_RECVFILE,
2225          SMB_VFS_LAYER_LOGGER},
2226         {SMB_VFS_OP(smb_time_audit_rename),     SMB_VFS_OP_RENAME,
2227          SMB_VFS_LAYER_LOGGER},
2228         {SMB_VFS_OP(smb_time_audit_fsync),      SMB_VFS_OP_FSYNC,
2229          SMB_VFS_LAYER_LOGGER},
2230         {SMB_VFS_OP(smb_time_audit_stat),       SMB_VFS_OP_STAT,
2231          SMB_VFS_LAYER_LOGGER},
2232         {SMB_VFS_OP(smb_time_audit_fstat),      SMB_VFS_OP_FSTAT,
2233          SMB_VFS_LAYER_LOGGER},
2234         {SMB_VFS_OP(smb_time_audit_lstat),      SMB_VFS_OP_LSTAT,
2235          SMB_VFS_LAYER_LOGGER},
2236         {SMB_VFS_OP(smb_time_audit_get_alloc_size),
2237          SMB_VFS_OP_GET_ALLOC_SIZE,
2238          SMB_VFS_LAYER_LOGGER},
2239         {SMB_VFS_OP(smb_time_audit_unlink),     SMB_VFS_OP_UNLINK,
2240          SMB_VFS_LAYER_LOGGER},
2241         {SMB_VFS_OP(smb_time_audit_chmod),      SMB_VFS_OP_CHMOD,
2242          SMB_VFS_LAYER_LOGGER},
2243         {SMB_VFS_OP(smb_time_audit_fchmod),     SMB_VFS_OP_FCHMOD,
2244          SMB_VFS_LAYER_LOGGER},
2245         {SMB_VFS_OP(smb_time_audit_chown),      SMB_VFS_OP_CHOWN,
2246          SMB_VFS_LAYER_LOGGER},
2247         {SMB_VFS_OP(smb_time_audit_fchown),     SMB_VFS_OP_FCHOWN,
2248          SMB_VFS_LAYER_LOGGER},
2249         {SMB_VFS_OP(smb_time_audit_lchown),     SMB_VFS_OP_LCHOWN,
2250          SMB_VFS_LAYER_LOGGER},
2251         {SMB_VFS_OP(smb_time_audit_chdir),      SMB_VFS_OP_CHDIR,
2252          SMB_VFS_LAYER_LOGGER},
2253         {SMB_VFS_OP(smb_time_audit_getwd),      SMB_VFS_OP_GETWD,
2254          SMB_VFS_LAYER_LOGGER},
2255         {SMB_VFS_OP(smb_time_audit_ntimes),     SMB_VFS_OP_NTIMES,
2256          SMB_VFS_LAYER_LOGGER},
2257         {SMB_VFS_OP(smb_time_audit_ftruncate),  SMB_VFS_OP_FTRUNCATE,
2258          SMB_VFS_LAYER_LOGGER},
2259         {SMB_VFS_OP(smb_time_audit_lock),       SMB_VFS_OP_LOCK,
2260          SMB_VFS_LAYER_LOGGER},
2261         {SMB_VFS_OP(smb_time_audit_kernel_flock),
2262          SMB_VFS_OP_KERNEL_FLOCK,
2263          SMB_VFS_LAYER_LOGGER},
2264         {SMB_VFS_OP(smb_time_audit_linux_setlease),
2265          SMB_VFS_OP_LINUX_SETLEASE,
2266          SMB_VFS_LAYER_LOGGER},
2267         {SMB_VFS_OP(smb_time_audit_getlock),    SMB_VFS_OP_GETLOCK,
2268          SMB_VFS_LAYER_LOGGER},
2269         {SMB_VFS_OP(smb_time_audit_symlink),    SMB_VFS_OP_SYMLINK,
2270          SMB_VFS_LAYER_LOGGER},
2271         {SMB_VFS_OP(smb_time_audit_readlink),   SMB_VFS_OP_READLINK,
2272          SMB_VFS_LAYER_LOGGER},
2273         {SMB_VFS_OP(smb_time_audit_link),       SMB_VFS_OP_LINK,
2274          SMB_VFS_LAYER_LOGGER},
2275         {SMB_VFS_OP(smb_time_audit_mknod),      SMB_VFS_OP_MKNOD,
2276          SMB_VFS_LAYER_LOGGER},
2277         {SMB_VFS_OP(smb_time_audit_realpath),   SMB_VFS_OP_REALPATH,
2278          SMB_VFS_LAYER_LOGGER},
2279         {SMB_VFS_OP(smb_time_audit_notify_watch),SMB_VFS_OP_NOTIFY_WATCH,
2280          SMB_VFS_LAYER_LOGGER},
2281         {SMB_VFS_OP(smb_time_audit_chflags),    SMB_VFS_OP_CHFLAGS,
2282          SMB_VFS_LAYER_LOGGER},
2283         {SMB_VFS_OP(smb_time_audit_file_id_create),
2284          SMB_VFS_OP_FILE_ID_CREATE,
2285          SMB_VFS_LAYER_LOGGER},
2286         {SMB_VFS_OP(smb_time_audit_streaminfo), SMB_VFS_OP_STREAMINFO,
2287          SMB_VFS_LAYER_LOGGER},
2288         {SMB_VFS_OP(smb_time_audit_get_real_filename),
2289          SMB_VFS_OP_GET_REAL_FILENAME,
2290          SMB_VFS_LAYER_LOGGER},
2291         {SMB_VFS_OP(smb_time_audit_connectpath), SMB_VFS_OP_CONNECTPATH,
2292          SMB_VFS_LAYER_LOGGER},
2293         {SMB_VFS_OP(smb_time_audit_brl_lock_windows),
2294          SMB_VFS_OP_BRL_LOCK_WINDOWS,
2295          SMB_VFS_LAYER_LOGGER},
2296         {SMB_VFS_OP(smb_time_audit_brl_unlock_windows),
2297          SMB_VFS_OP_BRL_UNLOCK_WINDOWS,
2298          SMB_VFS_LAYER_LOGGER},
2299         {SMB_VFS_OP(smb_time_audit_brl_cancel_windows),
2300          SMB_VFS_OP_BRL_CANCEL_WINDOWS,
2301          SMB_VFS_LAYER_LOGGER},
2302         {SMB_VFS_OP(smb_time_audit_strict_lock), SMB_VFS_OP_STRICT_LOCK,
2303          SMB_VFS_LAYER_LOGGER},
2304         {SMB_VFS_OP(smb_time_audit_strict_unlock), SMB_VFS_OP_STRICT_UNLOCK,
2305          SMB_VFS_LAYER_LOGGER},
2306
2307         /* NT ACL operations. */
2308
2309         {SMB_VFS_OP(smb_time_audit_fget_nt_acl),        SMB_VFS_OP_FGET_NT_ACL,
2310          SMB_VFS_LAYER_LOGGER},
2311         {SMB_VFS_OP(smb_time_audit_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
2312          SMB_VFS_LAYER_LOGGER},
2313         {SMB_VFS_OP(smb_time_audit_fset_nt_acl),        SMB_VFS_OP_FSET_NT_ACL,
2314          SMB_VFS_LAYER_LOGGER},
2315
2316         /* POSIX ACL operations. */
2317
2318         {SMB_VFS_OP(smb_time_audit_chmod_acl),  SMB_VFS_OP_CHMOD_ACL,
2319          SMB_VFS_LAYER_LOGGER},
2320         {SMB_VFS_OP(smb_time_audit_fchmod_acl), SMB_VFS_OP_FCHMOD_ACL,
2321          SMB_VFS_LAYER_LOGGER},
2322         {SMB_VFS_OP(smb_time_audit_sys_acl_get_entry),
2323          SMB_VFS_OP_SYS_ACL_GET_ENTRY,
2324          SMB_VFS_LAYER_LOGGER},
2325         {SMB_VFS_OP(smb_time_audit_sys_acl_get_tag_type),
2326          SMB_VFS_OP_SYS_ACL_GET_TAG_TYPE,
2327          SMB_VFS_LAYER_LOGGER},
2328         {SMB_VFS_OP(smb_time_audit_sys_acl_get_permset),
2329          SMB_VFS_OP_SYS_ACL_GET_PERMSET,
2330          SMB_VFS_LAYER_LOGGER},
2331         {SMB_VFS_OP(smb_time_audit_sys_acl_get_qualifier),
2332          SMB_VFS_OP_SYS_ACL_GET_QUALIFIER,
2333          SMB_VFS_LAYER_LOGGER},
2334         {SMB_VFS_OP(smb_time_audit_sys_acl_get_file),
2335          SMB_VFS_OP_SYS_ACL_GET_FILE,
2336          SMB_VFS_LAYER_LOGGER},
2337         {SMB_VFS_OP(smb_time_audit_sys_acl_get_fd),
2338          SMB_VFS_OP_SYS_ACL_GET_FD,
2339          SMB_VFS_LAYER_LOGGER},
2340         {SMB_VFS_OP(smb_time_audit_sys_acl_clear_perms),
2341          SMB_VFS_OP_SYS_ACL_CLEAR_PERMS,
2342          SMB_VFS_LAYER_LOGGER},
2343         {SMB_VFS_OP(smb_time_audit_sys_acl_add_perm),
2344          SMB_VFS_OP_SYS_ACL_ADD_PERM,
2345          SMB_VFS_LAYER_LOGGER},
2346         {SMB_VFS_OP(smb_time_audit_sys_acl_to_text),
2347          SMB_VFS_OP_SYS_ACL_TO_TEXT,
2348          SMB_VFS_LAYER_LOGGER},
2349         {SMB_VFS_OP(smb_time_audit_sys_acl_init),
2350          SMB_VFS_OP_SYS_ACL_INIT,
2351          SMB_VFS_LAYER_LOGGER},
2352         {SMB_VFS_OP(smb_time_audit_sys_acl_create_entry),
2353          SMB_VFS_OP_SYS_ACL_CREATE_ENTRY,
2354          SMB_VFS_LAYER_LOGGER},
2355         {SMB_VFS_OP(smb_time_audit_sys_acl_set_tag_type),
2356          SMB_VFS_OP_SYS_ACL_SET_TAG_TYPE,
2357          SMB_VFS_LAYER_LOGGER},
2358         {SMB_VFS_OP(smb_time_audit_sys_acl_set_qualifier),
2359          SMB_VFS_OP_SYS_ACL_SET_QUALIFIER,
2360          SMB_VFS_LAYER_LOGGER},
2361         {SMB_VFS_OP(smb_time_audit_sys_acl_set_permset),
2362          SMB_VFS_OP_SYS_ACL_SET_PERMSET,
2363          SMB_VFS_LAYER_LOGGER},
2364         {SMB_VFS_OP(smb_time_audit_sys_acl_valid),
2365          SMB_VFS_OP_SYS_ACL_VALID,
2366          SMB_VFS_LAYER_LOGGER},
2367         {SMB_VFS_OP(smb_time_audit_sys_acl_set_file),
2368          SMB_VFS_OP_SYS_ACL_SET_FILE,
2369          SMB_VFS_LAYER_LOGGER},
2370         {SMB_VFS_OP(smb_time_audit_sys_acl_set_fd),
2371          SMB_VFS_OP_SYS_ACL_SET_FD,
2372          SMB_VFS_LAYER_LOGGER},
2373         {SMB_VFS_OP(smb_time_audit_sys_acl_delete_def_file),
2374          SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
2375          SMB_VFS_LAYER_LOGGER},
2376         {SMB_VFS_OP(smb_time_audit_sys_acl_get_perm),
2377          SMB_VFS_OP_SYS_ACL_GET_PERM,
2378          SMB_VFS_LAYER_LOGGER},
2379         {SMB_VFS_OP(smb_time_audit_sys_acl_free_text),
2380          SMB_VFS_OP_SYS_ACL_FREE_TEXT,
2381          SMB_VFS_LAYER_LOGGER},
2382         {SMB_VFS_OP(smb_time_audit_sys_acl_free_acl),
2383          SMB_VFS_OP_SYS_ACL_FREE_ACL,
2384          SMB_VFS_LAYER_LOGGER},
2385         {SMB_VFS_OP(smb_time_audit_sys_acl_free_qualifier),
2386          SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER,
2387          SMB_VFS_LAYER_LOGGER},
2388
2389         /* EA operations. */
2390
2391         {SMB_VFS_OP(smb_time_audit_getxattr),   SMB_VFS_OP_GETXATTR,
2392          SMB_VFS_LAYER_LOGGER},
2393         {SMB_VFS_OP(smb_time_audit_lgetxattr),  SMB_VFS_OP_LGETXATTR,
2394          SMB_VFS_LAYER_LOGGER},
2395         {SMB_VFS_OP(smb_time_audit_fgetxattr),  SMB_VFS_OP_FGETXATTR,
2396          SMB_VFS_LAYER_LOGGER},
2397         {SMB_VFS_OP(smb_time_audit_listxattr),  SMB_VFS_OP_LISTXATTR,
2398          SMB_VFS_LAYER_LOGGER},
2399         {SMB_VFS_OP(smb_time_audit_llistxattr), SMB_VFS_OP_LLISTXATTR,
2400          SMB_VFS_LAYER_LOGGER},
2401         {SMB_VFS_OP(smb_time_audit_flistxattr), SMB_VFS_OP_FLISTXATTR,
2402          SMB_VFS_LAYER_LOGGER},
2403         {SMB_VFS_OP(smb_time_audit_removexattr),
2404          SMB_VFS_OP_REMOVEXATTR,
2405          SMB_VFS_LAYER_LOGGER},
2406         {SMB_VFS_OP(smb_time_audit_lremovexattr),
2407          SMB_VFS_OP_LREMOVEXATTR,
2408          SMB_VFS_LAYER_LOGGER},
2409         {SMB_VFS_OP(smb_time_audit_fremovexattr),
2410          SMB_VFS_OP_FREMOVEXATTR,
2411          SMB_VFS_LAYER_LOGGER},
2412         {SMB_VFS_OP(smb_time_audit_setxattr),   SMB_VFS_OP_SETXATTR,
2413          SMB_VFS_LAYER_LOGGER},
2414         {SMB_VFS_OP(smb_time_audit_lsetxattr),  SMB_VFS_OP_LSETXATTR,
2415          SMB_VFS_LAYER_LOGGER},
2416         {SMB_VFS_OP(smb_time_audit_fsetxattr),  SMB_VFS_OP_FSETXATTR,
2417          SMB_VFS_LAYER_LOGGER},
2418
2419         {SMB_VFS_OP(smb_time_audit_aio_read),   SMB_VFS_OP_AIO_READ,
2420          SMB_VFS_LAYER_LOGGER},
2421         {SMB_VFS_OP(smb_time_audit_aio_write),  SMB_VFS_OP_AIO_WRITE,
2422          SMB_VFS_LAYER_LOGGER},
2423         {SMB_VFS_OP(smb_time_audit_aio_return), SMB_VFS_OP_AIO_RETURN,
2424          SMB_VFS_LAYER_LOGGER},
2425         {SMB_VFS_OP(smb_time_audit_aio_cancel), SMB_VFS_OP_AIO_CANCEL,
2426          SMB_VFS_LAYER_LOGGER},
2427         {SMB_VFS_OP(smb_time_audit_aio_error),  SMB_VFS_OP_AIO_ERROR,
2428          SMB_VFS_LAYER_LOGGER},
2429         {SMB_VFS_OP(smb_time_audit_aio_fsync),  SMB_VFS_OP_AIO_FSYNC,
2430          SMB_VFS_LAYER_LOGGER},
2431         {SMB_VFS_OP(smb_time_audit_aio_suspend),SMB_VFS_OP_AIO_SUSPEND,
2432          SMB_VFS_LAYER_LOGGER},
2433         {SMB_VFS_OP(smb_time_audit_aio_force),SMB_VFS_OP_AIO_FORCE,
2434          SMB_VFS_LAYER_LOGGER},
2435
2436         /* Finish VFS operations definition */
2437
2438         {SMB_VFS_OP(NULL),              SMB_VFS_OP_NOOP,
2439          SMB_VFS_LAYER_NOOP}
2440 };
2441
2442
2443 NTSTATUS vfs_time_audit_init(void);
2444 NTSTATUS vfs_time_audit_init(void)
2445 {
2446         audit_timeout = (double)lp_parm_int(-1, "time_audit", "timeout",
2447                                             10000) / 1000.0;
2448         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "time_audit",
2449                                 audit_op_tuples);
2450 }