2 * Unix SMB/CIFS implementation.
3 * Samba VFS module for delay injection in VFS calls
4 * Copyright (C) Ralph Boehme 2018
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "smbd/smbd.h"
24 #define DBGC_CLASS DBGC_VFS
26 static void inject_delay(const char *vfs_func
, vfs_handle_struct
*handle
)
30 delay
= lp_parm_int(SNUM(handle
->conn
), "delay_inject", vfs_func
, 0);
35 DBG_DEBUG("Injected delay for [%s] of [%d] ms\n", vfs_func
, delay
);
40 static int vfs_delay_inject_ntimes(vfs_handle_struct
*handle
,
41 const struct smb_filename
*smb_fname
,
42 struct smb_file_time
*ft
)
44 inject_delay("ntimes", handle
);
46 return SMB_VFS_NEXT_NTIMES(handle
, smb_fname
, ft
);
49 static struct vfs_fn_pointers vfs_delay_inject_fns
= {
50 .ntimes_fn
= vfs_delay_inject_ntimes
,
54 NTSTATUS
vfs_delay_inject_init(TALLOC_CTX
*ctx
)
56 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
, "delay_inject",
57 &vfs_delay_inject_fns
);