diff options
author | Ralph Boehme <slow@samba.org> | 2018-08-30 17:27:08 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2018-09-05 13:35:26 +0200 |
commit | ada216537f9468aa33e5b0258b0b149dd06e4d8c (patch) | |
tree | 8b3902151269ef95ba79aeb9c79f56f4cd86778e | |
parent | fc3d25bb3acb1fc4da33e466a78b8a01d10035f0 (diff) | |
download | samba-ada216537f9468aa33e5b0258b0b149dd06e4d8c.tar.gz |
vfs_delay_inject: adding delay to VFS calls
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13549
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 44840ba5b32a2ce7959fd3d7c87822b3159416d3)
-rw-r--r-- | source3/modules/vfs_delay_inject.c | 58 | ||||
-rw-r--r-- | source3/modules/wscript_build | 7 | ||||
-rw-r--r-- | source3/wscript | 1 |
3 files changed, 66 insertions, 0 deletions
diff --git a/source3/modules/vfs_delay_inject.c b/source3/modules/vfs_delay_inject.c new file mode 100644 index 00000000000..21fea9b10f4 --- /dev/null +++ b/source3/modules/vfs_delay_inject.c @@ -0,0 +1,58 @@ +/* + * Unix SMB/CIFS implementation. + * Samba VFS module for delay injection in VFS calls + * Copyright (C) Ralph Boehme 2018 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see <http://www.gnu.org/licenses/>. + */ + +#include "includes.h" +#include "smbd/smbd.h" + +#undef DBGC_CLASS +#define DBGC_CLASS DBGC_VFS + +static void inject_delay(const char *vfs_func, vfs_handle_struct *handle) +{ + int delay; + + delay = lp_parm_int(SNUM(handle->conn), "delay_inject", vfs_func, 0); + if (delay == 0) { + return; + } + + DBG_DEBUG("Injected delay for [%s] of [%d] ms\n", vfs_func, delay); + + smb_msleep(delay); +} + +static int vfs_delay_inject_ntimes(vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct smb_file_time *ft) +{ + inject_delay("ntimes", handle); + + return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft); +} + +static struct vfs_fn_pointers vfs_delay_inject_fns = { + .ntimes_fn = vfs_delay_inject_ntimes, +}; + +static_decl_vfs; +NTSTATUS vfs_delay_inject_init(TALLOC_CTX *ctx) +{ + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "delay_inject", + &vfs_delay_inject_fns); +} diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build index a6a01f9929f..61b776f9ea4 100644 --- a/source3/modules/wscript_build +++ b/source3/modules/wscript_build @@ -516,3 +516,10 @@ bld.SAMBA3_MODULE('vfs_error_inject', init_function='', internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_error_inject'), enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_error_inject')) + +bld.SAMBA3_MODULE('vfs_delay_inject', + subsystem='vfs', + source='vfs_delay_inject.c', + init_function='', + internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_delay_inject'), + enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_delay_inject')) diff --git a/source3/wscript b/source3/wscript index 921c8bcef70..bc51e184b85 100644 --- a/source3/wscript +++ b/source3/wscript @@ -1718,6 +1718,7 @@ main() { if Options.options.enable_selftest or Options.options.developer: default_shared_modules.extend(TO_LIST('vfs_fake_acls vfs_nfs4acl_xattr')) default_shared_modules.extend(TO_LIST('vfs_error_inject')) + default_shared_modules.extend(TO_LIST('vfs_delay_inject')) if conf.CONFIG_SET('AD_DC_BUILD_IS_ENABLED'): default_static_modules.extend(TO_LIST('pdb_samba_dsdb auth_samba4 vfs_dfs_samba4')) |