[rfc] xioctl()
walter harms
wharms at bfs.de
Sun Jun 24 12:59:42 UTC 2007
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
Tito wrote:
> On Sunday 24 June 2007 00:11:01 Denis Vlasenko wrote:
>> static int bb_ioctl(int fd, int request, void *argp, ...)
>>> {
>>> va_list p;
>>> char *string;
>>> va_start(p, request);
>>> string = va_arg(va_list p, (char *));
>>>
>>> int e = ioctl(fd, request, argp);
>>> if (e && string)
>>> bb_perror_msg(" %s", string);
>> Use
>> bb_vperror_msg((string ? string : "ioctl"), p);
>> xfunc_die();
>
> Hi,
> after doing a little testing it seems to me that the va_list solution
> is not doable as there is no way to determine:
>
> string ? string : "ioctl"
>
> this is due to the fact that with va_arg:
> If there is no next argument, random errors will occur.
>
> Another easier solution giving at least a hint of what ioctl failed could be:
>
> void xioctl(int fd, int request, void *argp)
> {
> if (ioctl(fd, request, argp) < 0)
> bb_perror_msg("ioctl %#x failed", request);
> }
>
>
>
> in this case with deallocvt.c,
>
> int deallocvt_main(int argc, char **argv)
> {
> /* num = 0 deallocate all unused consoles */
> int num = 0;
>
> switch (argc) {
> case 2:
> num = xatoul_range(argv[1], 1, 63);
> /* Fallthrough */
> case 1:
> break;
> default:
> bb_show_usage();
> }
>
> xioctl(get_console_fd(), VT_DISALLOCATE, (void *)num);
> return EXIT_SUCCESS;
> }
>
> the output is:
>
> deallocvt: ioctl 0X5608 failed: Device or resource busy
>
> Just an idea.
>
> Ciao,
> Tito
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
More information about the busybox
mailing list