summaryrefslogtreecommitdiffstats
path: root/source3/modules/vfs_time_audit.c
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2013-11-18 14:54:30 +0100
committerJeremy Allison <jra@samba.org>2013-11-22 08:56:45 -0800
commitd8d5d4c7428683da04fa4c8b344504e7044f9b1c (patch)
tree5ce00faa4dbb6113f2c6d18ae312dd6dc5bc39fd /source3/modules/vfs_time_audit.c
parent2b435ad4b45ec39b0cf70f55699daba3bcfcee08 (diff)
downloadsamba-d8d5d4c7428683da04fa4c8b344504e7044f9b1c.tar.gz
samba-d8d5d4c7428683da04fa4c8b344504e7044f9b1c.tar.xz
samba-d8d5d4c7428683da04fa4c8b344504e7044f9b1c.zip
vfs: add [GET/SET]_COMPRESSION hooks
The VFS interfaces are sychronous, as the operations only modify meta-data. These hooks are dependent on support for transparent compression by the underlying filesystem - vfs_default returns INVALID_DEVICE_REQUEST. Support for other filesystems providing transparent comression, such as Btrfs and ZFS, can be added in future. The get_compression function takes fsp and smb_fname arguments. The smb_fname argument is needed due to the current dosmode() code-path. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/modules/vfs_time_audit.c')
-rw-r--r--source3/modules/vfs_time_audit.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index a9289536e1c..fd9eb522099 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -1751,6 +1751,57 @@ static NTSTATUS smb_time_audit_copy_chunk_recv(struct vfs_handle_struct *handle,
return NT_STATUS_OK;
}
+static NTSTATUS smb_time_audit_get_compression(vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *fsp,
+ struct smb_filename *smb_fname,
+ uint16_t *_compression_fmt)
+{
+ NTSTATUS result;
+ struct timespec ts1,ts2;
+ double timediff;
+
+ clock_gettime_mono(&ts1);
+ result = SMB_VFS_NEXT_GET_COMPRESSION(handle, mem_ctx, fsp, smb_fname,
+ _compression_fmt);
+ clock_gettime_mono(&ts2);
+ timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
+
+ if (timediff > audit_timeout) {
+ if (fsp != NULL) {
+ smb_time_audit_log_fsp("get_compression",
+ timediff, fsp);
+ } else {
+ smb_time_audit_log_smb_fname("get_compression",
+ timediff, smb_fname);
+ }
+ }
+
+ return result;
+}
+
+static NTSTATUS smb_time_audit_set_compression(vfs_handle_struct *handle,
+ TALLOC_CTX *mem_ctx,
+ struct files_struct *fsp,
+ uint16_t compression_fmt)
+{
+ NTSTATUS result;
+ struct timespec ts1,ts2;
+ double timediff;
+
+ clock_gettime_mono(&ts1);
+ result = SMB_VFS_NEXT_SET_COMPRESSION(handle, mem_ctx, fsp,
+ compression_fmt);
+ clock_gettime_mono(&ts2);
+ timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
+
+ if (timediff > audit_timeout) {
+ smb_time_audit_log_fsp("set_compression", timediff, fsp);
+ }
+
+ return result;
+}
+
static NTSTATUS smb_time_audit_fget_nt_acl(vfs_handle_struct *handle,
files_struct *fsp,
uint32 security_info,
@@ -2370,6 +2421,8 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
.translate_name_fn = smb_time_audit_translate_name,
.copy_chunk_send_fn = smb_time_audit_copy_chunk_send,
.copy_chunk_recv_fn = smb_time_audit_copy_chunk_recv,
+ .get_compression_fn = smb_time_audit_get_compression,
+ .set_compression_fn = smb_time_audit_set_compression,
.fget_nt_acl_fn = smb_time_audit_fget_nt_acl,
.get_nt_acl_fn = smb_time_audit_get_nt_acl,
.fset_nt_acl_fn = smb_time_audit_fset_nt_acl,