diff options
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/vfs_default.c | 17 | ||||
-rw-r--r-- | source3/modules/vfs_full_audit.c | 17 | ||||
-rw-r--r-- | source3/modules/vfs_streams_xattr.c | 26 | ||||
-rw-r--r-- | source3/modules/vfs_time_audit.c | 22 |
4 files changed, 80 insertions, 2 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 977a5630ac..63993fed36 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -854,7 +854,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs emulation is being done by the libc (like on AIX with JFS1). In that case we do our own emulation. posix_fallocate implementations can return ENOTSUP or EINVAL in cases like that. */ - ret = sys_posix_fallocate(fsp->fh->fd, st.st_ex_size, space_to_write); + ret = SMB_VFS_POSIX_FALLOCATE(fsp, st.st_ex_size, space_to_write); if (ret == ENOSPC) { errno = ENOSPC; return -1; @@ -862,7 +862,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs if (ret == 0) { return 0; } - DEBUG(10,("strict_allocate_ftruncate: sys_posix_fallocate failed with " + DEBUG(10,("strict_allocate_ftruncate: SMB_VFS_POSIX_FALLOCATE failed with " "error %d. Falling back to slow manual allocation\n", ret)); /* available disk space is enough or not? */ @@ -974,6 +974,19 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_O return result; } +static int vfswrap_posix_fallocate(vfs_handle_struct *handle, + files_struct *fsp, + SMB_OFF_T offset, + SMB_OFF_T len) +{ + int result; + + START_PROFILE(syscall_posix_fallocate); + result = sys_posix_fallocate(fsp->fh->fd, offset, len); + END_PROFILE(syscall_posix_fallocate); + return result; +} + static bool vfswrap_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { bool result; diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 3328128d86..b7c0888a22 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -124,6 +124,7 @@ typedef enum _vfs_op_type { SMB_VFS_OP_GETWD, SMB_VFS_OP_NTIMES, SMB_VFS_OP_FTRUNCATE, + SMB_VFS_OP_POSIX_FALLOCATE, SMB_VFS_OP_LOCK, SMB_VFS_OP_KERNEL_FLOCK, SMB_VFS_OP_LINUX_SETLEASE, @@ -262,6 +263,7 @@ static struct { { SMB_VFS_OP_GETWD, "getwd" }, { SMB_VFS_OP_NTIMES, "ntimes" }, { SMB_VFS_OP_FTRUNCATE, "ftruncate" }, + { SMB_VFS_OP_POSIX_FALLOCATE,"posix_fallocate" }, { SMB_VFS_OP_LOCK, "lock" }, { SMB_VFS_OP_KERNEL_FLOCK, "kernel_flock" }, { SMB_VFS_OP_LINUX_SETLEASE, "linux_setlease" }, @@ -1222,6 +1224,20 @@ static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp return result; } +static int smb_full_audit_posix_fallocate(vfs_handle_struct *handle, files_struct *fsp, + SMB_OFF_T offset, + SMB_OFF_T len) +{ + int result; + + result = SMB_VFS_NEXT_POSIX_FALLOCATE(handle, fsp, offset, len); + + do_log(SMB_VFS_OP_POSIX_FALLOCATE, (result >= 0), handle, + "%s", fsp_str_do_log(fsp)); + + return result; +} + static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) { @@ -2218,6 +2234,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = { .getwd = smb_full_audit_getwd, .ntimes = smb_full_audit_ntimes, .ftruncate = smb_full_audit_ftruncate, + .posix_fallocate = smb_full_audit_posix_fallocate, .lock = smb_full_audit_lock, .kernel_flock = smb_full_audit_kernel_flock, .linux_setlease = smb_full_audit_linux_setlease, diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 218e5ec078..8870c6e471 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -1023,6 +1023,31 @@ static int streams_xattr_ftruncate(struct vfs_handle_struct *handle, return 0; } +static int streams_xattr_posix_fallocate(struct vfs_handle_struct *handle, + struct files_struct *fsp, + SMB_OFF_T offset, + SMB_OFF_T len) +{ + struct stream_io *sio = + (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp); + + DEBUG(10, ("streams_xattr_posix_fallocate called for file %s offset %.0f" + "len = %.0f\n", + fsp_str_dbg(fsp), (double)offset, (double)len)); + + if (sio == NULL) { + return SMB_VFS_NEXT_POSIX_FALLOCATE(handle, fsp, offset, len); + } + + if (!streams_xattr_recheck(sio)) { + return -1; + } + + /* Let the pwrite code path handle it. */ + return ENOSYS; +} + + static struct vfs_fn_pointers vfs_streams_xattr_fns = { .fs_capabilities = streams_xattr_fs_capabilities, .open = streams_xattr_open, @@ -1034,6 +1059,7 @@ static struct vfs_fn_pointers vfs_streams_xattr_fns = { .unlink = streams_xattr_unlink, .rename = streams_xattr_rename, .ftruncate = streams_xattr_ftruncate, + .posix_fallocate = streams_xattr_posix_fallocate, .streaminfo = streams_xattr_streaminfo, }; diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index af4fd3313a..e9481b5d67 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -905,6 +905,27 @@ static int smb_time_audit_ftruncate(vfs_handle_struct *handle, return result; } +static int smb_time_audit_posix_fallocate(vfs_handle_struct *handle, + files_struct *fsp, + SMB_OFF_T offset, + SMB_OFF_T len) +{ + int result; + struct timespec ts1,ts2; + double timediff; + + clock_gettime_mono(&ts1); + result = SMB_VFS_NEXT_POSIX_FALLOCATE(handle, fsp, offset, len); + clock_gettime_mono(&ts2); + timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; + + if (timediff > audit_timeout) { + smb_time_audit_log("posix_fallocate", timediff); + } + + return result; +} + static bool smb_time_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) @@ -2336,6 +2357,7 @@ static struct vfs_fn_pointers vfs_time_audit_fns = { .getwd = smb_time_audit_getwd, .ntimes = smb_time_audit_ntimes, .ftruncate = smb_time_audit_ftruncate, + .posix_fallocate = smb_time_audit_posix_fallocate, .lock = smb_time_audit_lock, .kernel_flock = smb_time_audit_kernel_flock, .linux_setlease = smb_time_audit_linux_setlease, |