Skip to content

Commit 2958b02

Browse files
authored
Merge PR #1048: adapter/syscall: fix ioctl conflicting types compile error on older glibc
adapter/syscall: fix ioctl conflicting types compile error on older glibc
2 parents a43e84e + ddb1811 commit 2958b02

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

adapter/syscall/ff_declare_syscalls.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ FF_SYSCALL_DECL(ssize_t, recvfrom, (int, void *, size_t, int,
2222
FF_SYSCALL_DECL(ssize_t, sendmsg, (int, const struct msghdr *, int flags));
2323
FF_SYSCALL_DECL(ssize_t, recvmsg, (int, struct msghdr *, int flags));
2424
FF_SYSCALL_DECL(int, close, (int));
25-
FF_SYSCALL_DECL(int, ioctl, (int, unsigned long, unsigned long));
2625
FF_SYSCALL_DECL(int, fcntl, (int, int, unsigned long));
2726
FF_SYSCALL_DECL(int, epoll_create, (int));
2827
FF_SYSCALL_DECL(int, epoll_ctl, (int, int, int, struct epoll_event *));

adapter/syscall/ff_hook_syscall.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <assert.h>
22
#include <dlfcn.h>
33
#include <unistd.h>
4+
#include <stdarg.h>
45
#include <sys/epoll.h>
56
#include <sys/resource.h>
67
#include <errno.h>
@@ -1882,6 +1883,25 @@ ff_hook_ioctl(int fd, unsigned long req, unsigned long data)
18821883
RETURN_NOFREE();
18831884
}
18841885

1886+
/*
1887+
* Public ioctl() entry point with variadic signature matching glibc's
1888+
* declaration: int ioctl(int fd, unsigned long request, ...)
1889+
* This avoids the 'conflicting types' compile error when strong_alias is
1890+
* used against the fixed-arg ff_hook_ioctl prototype (issue #942).
1891+
*/
1892+
int
1893+
ioctl(int fd, unsigned long req, ...)
1894+
{
1895+
va_list ap;
1896+
unsigned long data;
1897+
1898+
va_start(ap, req);
1899+
data = va_arg(ap, unsigned long);
1900+
va_end(ap);
1901+
1902+
return ff_hook_ioctl(fd, req, data);
1903+
}
1904+
18851905
int
18861906
ff_hook_fcntl(int fd, int cmd, unsigned long data)
18871907
{

adapter/syscall/ff_linux_syscall.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
struct ff_linux_syscall {
2323
#define FF_SYSCALL_DECL(ret, fn, args) ret (*pf_##fn) args;
2424
#include "ff_declare_syscalls.h"
25+
/* ioctl removed from ff_declare_syscalls.h (issue #942 fix), add manually */
26+
int (*pf_ioctl)(int, unsigned long, unsigned long);
2527
};
2628

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

4852
return 0;
4953
}

adapter/syscall/ff_linux_syscall.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@
1010
#define FF_SYSCALL_DECL(ret, fn, args) ret ff_linux_##fn args
1111
#include "ff_declare_syscalls.h"
1212

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

0 commit comments

Comments
 (0)