posix: move ioctl() from fdtable to posix
The ioctl() call should be a part of the _XOPEN_STREAMS Option in posix, so move it there. Create a zephyr-native zvfs_ioctl() in the layer below. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
parent
50fc010f0f
commit
156eaab70e
6 changed files with 31 additions and 17 deletions
|
@ -379,22 +379,6 @@ off_t zvfs_lseek(int fd, off_t offset, int whence)
|
||||||
whence);
|
whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ioctl(int fd, unsigned long request, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
int res;
|
|
||||||
|
|
||||||
if (_check_fd(fd) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(args, request);
|
|
||||||
res = fdtable[fd].vtable->ioctl(fdtable[fd].obj, request, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
int zvfs_fcntl(int fd, int cmd, va_list args)
|
int zvfs_fcntl(int fd, int cmd, va_list args)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
@ -434,6 +418,16 @@ int zvfs_ftruncate(int fd, off_t length)
|
||||||
return zvfs_ftruncate_wrap(fd, ZFD_IOCTL_TRUNCATE, length);
|
return zvfs_ftruncate_wrap(fd, ZFD_IOCTL_TRUNCATE, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int zvfs_ioctl(int fd, unsigned long request, va_list args)
|
||||||
|
{
|
||||||
|
if (_check_fd(fd) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fdtable[fd].vtable->ioctl(fdtable[fd].obj, request, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(CONFIG_POSIX_DEVICE_IO)
|
#if defined(CONFIG_POSIX_DEVICE_IO)
|
||||||
/*
|
/*
|
||||||
* fd operations for stdio/stdout/stderr
|
* fd operations for stdio/stdout/stderr
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr/posix/stropts.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
|
#include <zephyr/posix/stropts.h>
|
||||||
|
|
||||||
int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags)
|
int putmsg(int fildes, const struct strbuf *ctlptr, const struct strbuf *dataptr, int flags)
|
||||||
{
|
{
|
||||||
|
@ -79,3 +81,17 @@ int isastream(int fildes)
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int zvfs_ioctl(int fd, unsigned long request, va_list args);
|
||||||
|
|
||||||
|
int ioctl(int fd, unsigned long request, ...)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, request);
|
||||||
|
ret = zvfs_ioctl(fd, request, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ CONFIG_CPP=y
|
||||||
CONFIG_STD_CPP17=y
|
CONFIG_STD_CPP17=y
|
||||||
CONFIG_CPP_EXCEPTIONS=y
|
CONFIG_CPP_EXCEPTIONS=y
|
||||||
CONFIG_POSIX_API=y
|
CONFIG_POSIX_API=y
|
||||||
|
CONFIG_XOPEN_STREAMS=y
|
||||||
CONFIG_COMMON_LIBC_THRD=y
|
CONFIG_COMMON_LIBC_THRD=y
|
||||||
CONFIG_DYNAMIC_THREAD=y
|
CONFIG_DYNAMIC_THREAD=y
|
||||||
CONFIG_THREAD_STACK_INFO=y
|
CONFIG_THREAD_STACK_INFO=y
|
||||||
|
|
|
@ -6,6 +6,7 @@ CONFIG_CPP=y
|
||||||
CONFIG_STD_CPP17=y
|
CONFIG_STD_CPP17=y
|
||||||
CONFIG_CPP_EXCEPTIONS=y
|
CONFIG_CPP_EXCEPTIONS=y
|
||||||
CONFIG_POSIX_API=y
|
CONFIG_POSIX_API=y
|
||||||
|
CONFIG_XOPEN_STREAMS=y
|
||||||
CONFIG_NET_SOCKETPAIR=y
|
CONFIG_NET_SOCKETPAIR=y
|
||||||
CONFIG_HEAP_MEM_POOL_SIZE=16384
|
CONFIG_HEAP_MEM_POOL_SIZE=16384
|
||||||
CONFIG_EVENTFD=y
|
CONFIG_EVENTFD=y
|
||||||
|
|
|
@ -7,6 +7,7 @@ CONFIG_STD_CPP17=y
|
||||||
CONFIG_CPP_EXCEPTIONS=y
|
CONFIG_CPP_EXCEPTIONS=y
|
||||||
CONFIG_GLIBCXX_LIBCPP=y
|
CONFIG_GLIBCXX_LIBCPP=y
|
||||||
CONFIG_POSIX_API=y
|
CONFIG_POSIX_API=y
|
||||||
|
CONFIG_XOPEN_STREAMS=y
|
||||||
CONFIG_NETWORKING=y
|
CONFIG_NETWORKING=y
|
||||||
CONFIG_NET_TCP=y
|
CONFIG_NET_TCP=y
|
||||||
CONFIG_NET_SOCKETS=y
|
CONFIG_NET_SOCKETS=y
|
||||||
|
|
|
@ -9,4 +9,5 @@ CONFIG_TEST_RANDOM_GENERATOR=y
|
||||||
CONFIG_ZTEST=y
|
CONFIG_ZTEST=y
|
||||||
|
|
||||||
CONFIG_POSIX_API=y
|
CONFIG_POSIX_API=y
|
||||||
|
CONFIG_XOPEN_STREAMS=y
|
||||||
CONFIG_EVENTFD=y
|
CONFIG_EVENTFD=y
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue