libc: Add ioctl() syscall wrapper
This commit is contained in:
parent
fee33e7a14
commit
3e5957f9fc
@ -20,6 +20,7 @@ set(SOURCES
|
||||
src/sys/stat.cpp
|
||||
src/sys/mman.cpp
|
||||
src/sys/wait.cpp
|
||||
src/sys/ioctl.cpp
|
||||
)
|
||||
|
||||
if(${LUNA_ARCH} STREQUAL "x86_64")
|
||||
|
18
libc/include/sys/ioctl.h
Normal file
18
libc/include/sys/ioctl.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* sys/ioctl.h: IO device control. */
|
||||
|
||||
#ifndef _SYS_IOCTL_H
|
||||
#define _SYS_IOCTL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/* Perform an IO control operation on a device. */
|
||||
int ioctl(int fd, int request, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
22
libc/src/sys/ioctl.cpp
Normal file
22
libc/src/sys/ioctl.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include <bits/errno-return.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
int ioctl(int fd, int request, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
|
||||
void* arg = va_arg(ap, void*);
|
||||
|
||||
long rc = syscall(SYS_ioctl, fd, request, arg);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user