1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

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>
This commit is contained in:
Ralph Boehme 2018-08-30 17:27:08 +02:00 committed by Jeremy Allison
parent b7d77ce4b3
commit 44840ba5b3
3 changed files with 66 additions and 0 deletions

View File

@ -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);
}

View File

@ -571,3 +571,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'))

View File

@ -1677,6 +1677,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'))