lib: fdtable: Change ioctl vmethod signature to take va_list

As extend fdtable usage to more cases, there regularly arises a need
to forward ioctl/fcntl arguments to another ioctl vmethod, which is
complicated because it defined as taking variadic arguments. The only
portable solution is to convert variadic arguments to va_list at the
first point of entry from client code, and then pass va_list around.

To facilitate calling ioctl with variadic arguments from system code,
z_fdtable_call_ioctl() helper function is added.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
Paul Sokolovsky 2018-12-11 17:48:47 +03:00 committed by Jukka Rissanen
commit 13b38ed686
5 changed files with 59 additions and 54 deletions

View file

@ -94,7 +94,7 @@ int open(const char *name, int flags)
return fd;
}
static int fs_ioctl_vmeth(void *obj, unsigned int request, ...)
static int fs_ioctl_vmeth(void *obj, unsigned int request, va_list args)
{
int rc;
struct posix_fs_desc *ptr = obj;
@ -105,14 +105,11 @@ static int fs_ioctl_vmeth(void *obj, unsigned int request, ...)
break;
case ZFD_IOCTL_LSEEK: {
va_list args;
off_t offset;
int whence;
va_start(args, request);
offset = va_arg(args, off_t);
whence = va_arg(args, int);
va_end(args);
rc = fs_seek(&ptr->file, offset, whence);
break;