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