From 670b83a1e6d19e1920fdba09d39c6b0743546a3b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 19 Feb 2020 14:44:11 +0100 Subject: [PATCH] test: Intercept open in vfs_error_inject Bug: https://bugzilla.samba.org/show_bug.cgi?id=14285 Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison (cherry picked from commit 305204a241b74c599f4f6a064cac6608afd9c893) --- source3/modules/vfs_error_inject.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source3/modules/vfs_error_inject.c b/source3/modules/vfs_error_inject.c index c8c3ea4701f..c7a99370b2a 100644 --- a/source3/modules/vfs_error_inject.c +++ b/source3/modules/vfs_error_inject.c @@ -29,6 +29,7 @@ struct unix_error_map { } unix_error_map_array[] = { { "ESTALE", ESTALE }, { "EBADF", EBADF }, + { "EINTR", EINTR }, }; static int find_unix_error_from_string(const char *err_str) @@ -106,9 +107,25 @@ static ssize_t vfs_error_inject_pwrite(vfs_handle_struct *handle, return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); } +static int vfs_error_inject_open( + struct vfs_handle_struct *handle, + struct smb_filename *smb_fname, + files_struct *fsp, + int flags, + mode_t mode) +{ + int error = inject_unix_error("open", handle); + if (error != 0) { + errno = error; + return -1; + } + return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); +} + static struct vfs_fn_pointers vfs_error_inject_fns = { .chdir_fn = vfs_error_inject_chdir, .pwrite_fn = vfs_error_inject_pwrite, + .open_fn = vfs_error_inject_open, }; static_decl_vfs; -- 2.11.4.GIT