[rfc] xioctl()

Tito farmatito at tiscali.it
Sun Jun 24 13:17:19 UTC 2007


On Sunday 24 June 2007 14:59:42 walter harms wrote:
> 
> perhaps this can be fixed using a macro like:
> 
> 
> #define xioctl(fd,req,...)   bb_ioctl(#req,fd,req,__VA_ARGS__)
> 
> static int bb_ioctl(const char *estr, int fd, int request, void *argp, ...)
> ...
> 
> xioctl(get_console_fd(), VT_DISALLOCATE, (void *)num);
> will now call a modified
> bb_ioctl("VT_DISALLOCATE",get_console_fd(), VT_DISALLOCATE, (void *)num);
> 
> the define eats no space and the new bb_ioctl will allow passing a free errormsg.
> 
> 
> beware: I did no real testing an that ...
> 
> 
> re,
>  wh

Hi,
you can fix it the same way also without a macro by adding one more arg to 
the function (eventually set to NULL to trigger the default behaviour):

xioctl(int fd, int request, void *argp, char * emsg)

but the initial idea was to supply a default error message "ioctl" and switch to
an optional error message with printf formatting capabilities only if needed
without increasing the number of args needed by default by the function like:

xioctl(int fd, int request, void *argp,...)

so that we could do:

xioctl(fd, request, argp)
or
xioctl(fd, request, argp, "this ioctl failed %s %s", a, b)

but i found no way to test fot the presence or absence
of args in the va_list......as the behaviour seems to be
undefined if i understand the man page correctly. 

Ciao,
Tito



More information about the busybox mailing list