Merging upstream version 1.12.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
8d543389aa
commit
a3d0cc5ebd
1005 changed files with 9469 additions and 1830 deletions
|
@ -1,7 +1,21 @@
|
|||
mock_conf = configuration_data()
|
||||
|
||||
mock_conf.set(
|
||||
'HAVE_GLIBC_IOCTL',
|
||||
cc.compiles(
|
||||
'''#include <sys/ioctl.h>
|
||||
int ioctl(int fd, unsigned long request, ...);
|
||||
''',
|
||||
name: 'ioctl has glibc-style prototype'
|
||||
),
|
||||
description: 'Is ioctl the glibc interface (rather than POSIX)'
|
||||
)
|
||||
|
||||
mock_ioctl = library(
|
||||
'mock-ioctl',
|
||||
['mock.c', 'util.c'],
|
||||
)
|
||||
dependencies: [dl_dep],
|
||||
c_args: ['-DHAVE_GLIBC_IOCTL=' + (mock_conf.get('HAVE_GLIBC_IOCTL') ? '1' : '0')])
|
||||
|
||||
# Add mock-ioctl to the LD_PRELOAD path so it overrides libc.
|
||||
# Append to LD_PRELOAD so existing libraries, e.g. libasan, are kept.
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "../../src/nvme/ioctl.h"
|
||||
#include "util.h"
|
||||
|
@ -118,18 +119,20 @@ void end_mock_cmds(void)
|
|||
})
|
||||
|
||||
#ifdef HAVE_GLIBC_IOCTL
|
||||
typedef int (*ioctl_func_t)(int, unsigned long, void *);
|
||||
int ioctl(int fd, unsigned long request, ...)
|
||||
#else
|
||||
typedef int (*ioctl_func_t)(int, int, void *);
|
||||
int ioctl(int fd, int request, ...)
|
||||
#endif
|
||||
{
|
||||
ioctl_func_t real_ioctl = NULL;
|
||||
struct mock_cmds *mock_cmds;
|
||||
bool result64;
|
||||
const struct mock_cmd *mock_cmd;
|
||||
va_list args;
|
||||
void *cmd;
|
||||
|
||||
check(fd == mock_fd, "got fd %d, expected %d", fd, mock_fd);
|
||||
switch (request) {
|
||||
case NVME_IOCTL_ADMIN_CMD:
|
||||
mock_cmds = &mock_admin_cmds;
|
||||
|
@ -148,16 +151,28 @@ int ioctl(int fd, int request, ...)
|
|||
result64 = true;
|
||||
break;
|
||||
default:
|
||||
fail("unexpected %s %lu", __func__, (unsigned long) request);
|
||||
#if HAVE_LIBC_LDSYM
|
||||
real_ioctl = dlsym(RTLD_NEXT, "ioctl");
|
||||
if (!real_ioctl)
|
||||
fail("Error: dlsym failed to find original ioctl\n");
|
||||
#else
|
||||
fail("Error: unhandled ioctl\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
va_start(args, request);
|
||||
cmd = va_arg(args, void *);
|
||||
va_end(args);
|
||||
|
||||
if (real_ioctl)
|
||||
return real_ioctl(fd, request, cmd);
|
||||
|
||||
check(fd == mock_fd, "got fd %d, expected %d", fd, mock_fd);
|
||||
check(mock_cmds->remaining_cmds,
|
||||
"unexpected %s command", mock_cmds->name);
|
||||
mock_cmd = mock_cmds->cmds++;
|
||||
mock_cmds->remaining_cmds--;
|
||||
|
||||
va_start(args, request);
|
||||
cmd = va_arg(args, void *);
|
||||
va_end(args);
|
||||
if (result64) {
|
||||
execute_ioctl((struct nvme_passthru_cmd64 *)cmd, mock_cmd);
|
||||
} else {
|
||||
|
@ -173,3 +188,9 @@ int ioctl(int fd, int request, ...)
|
|||
|
||||
return mock_cmd->err;
|
||||
}
|
||||
|
||||
/* mock io_uring_get_probe, just fail */
|
||||
struct io_uring_probe *io_uring_get_probe(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue