Here's the template I use for wrapping a function using LD_PRELOAD:
int gettimeofday(struct timeval *tv, struct timezone *tz) {
static int (*gettimeofday_real)(struct timeval *tv, struct timezone *tz)=NULL;
if (!gettimeofday_real) gettimeofday_real=dlsym(RTLD_NEXT,"gettimeofday");
return gettimeofday_real(tv, tz);
}
I realized though that ioctl seems to have the following signature:
int ioctl(int d, unsigned long request, ...);
How could I wrap it in a similar way, given the ...
that's in the signature?