Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion adapter/syscall/ff_declare_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ FF_SYSCALL_DECL(ssize_t, recvfrom, (int, void *, size_t, int,
FF_SYSCALL_DECL(ssize_t, sendmsg, (int, const struct msghdr *, int flags));
FF_SYSCALL_DECL(ssize_t, recvmsg, (int, struct msghdr *, int flags));
FF_SYSCALL_DECL(int, close, (int));
FF_SYSCALL_DECL(int, ioctl, (int, unsigned long, unsigned long));
FF_SYSCALL_DECL(int, fcntl, (int, int, unsigned long));
FF_SYSCALL_DECL(int, epoll_create, (int));
FF_SYSCALL_DECL(int, epoll_ctl, (int, int, int, struct epoll_event *));
Expand Down
20 changes: 20 additions & 0 deletions adapter/syscall/ff_hook_syscall.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <assert.h>
#include <dlfcn.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/epoll.h>
#include <sys/resource.h>
#include <errno.h>
Expand Down Expand Up @@ -1882,6 +1883,25 @@ ff_hook_ioctl(int fd, unsigned long req, unsigned long data)
RETURN_NOFREE();
}

/*
* Public ioctl() entry point with variadic signature matching glibc's
* declaration: int ioctl(int fd, unsigned long request, ...)
* This avoids the 'conflicting types' compile error when strong_alias is
* used against the fixed-arg ff_hook_ioctl prototype (issue #942).
*/
int
ioctl(int fd, unsigned long req, ...)
{
va_list ap;
unsigned long data;

va_start(ap, req);
data = va_arg(ap, unsigned long);
va_end(ap);

return ff_hook_ioctl(fd, req, data);
}

int
ff_hook_fcntl(int fd, int cmd, unsigned long data)
{
Expand Down
4 changes: 4 additions & 0 deletions adapter/syscall/ff_linux_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
struct ff_linux_syscall {
#define FF_SYSCALL_DECL(ret, fn, args) ret (*pf_##fn) args;
#include "ff_declare_syscalls.h"
/* ioctl removed from ff_declare_syscalls.h (issue #942 fix), add manually */
int (*pf_ioctl)(int, unsigned long, unsigned long);
};

static int linux_syscall_inited;
Expand All @@ -44,6 +46,8 @@ linux_syscall_load_symbol()
#define FF_SYSCALL_DECL(ret, fn, args) \
syscalls.pf_##fn = (typeof(syscalls.pf_##fn))dlsym(linux_lib_handle, #fn);
#include <ff_declare_syscalls.h>
/* ioctl removed from ff_declare_syscalls.h (issue #942 fix), load manually */
syscalls.pf_ioctl = (typeof(syscalls.pf_ioctl))dlsym(linux_lib_handle, "ioctl");

return 0;
}
Expand Down
4 changes: 4 additions & 0 deletions adapter/syscall/ff_linux_syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
#define FF_SYSCALL_DECL(ret, fn, args) ret ff_linux_##fn args
#include "ff_declare_syscalls.h"

/* ioctl is removed from ff_declare_syscalls.h (variadic conflict fix, issue #942),
* declare ff_linux_ioctl explicitly here. */
int ff_linux_ioctl(int fd, unsigned long req, unsigned long data);

#endif
Loading