mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add ioctl(2).
This commit is contained in:
parent
ade239f18b
commit
dbc6c8c663
5 changed files with 95 additions and 2 deletions
|
@ -198,6 +198,7 @@ gettermmode.o \
|
|||
gettimeofday.o \
|
||||
getuid.o \
|
||||
init.o \
|
||||
ioctl.o \
|
||||
ioleast.o \
|
||||
isatty.o \
|
||||
kernelinfo.o \
|
||||
|
|
36
libc/include/sys/ioctl.h
Normal file
36
libc/include/sys/ioctl.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
sys/ioctl.h
|
||||
Miscellaneous device control interface.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef INCLUDE_SYS_IOCTL_H
|
||||
#define INCLUDE_SYS_IOCTL_H
|
||||
|
||||
#include <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int ioctl(int fd, int request, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
39
libc/ioctl.cpp
Normal file
39
libc/ioctl.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2013.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
ioctl.cpp
|
||||
Miscellaneous device control interface.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
DEFN_SYSCALL3(int, sys_ioctl, SYSCALL_IOCTL, int, int, void*);
|
||||
|
||||
extern "C" int ioctl(int fd, int request, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
void* ptr = va_arg(ap, void*);
|
||||
va_end(ap);
|
||||
return sys_ioctl(fd, request, ptr);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
|
@ -105,6 +105,7 @@
|
|||
#define SYSCALL_GETEGID 81
|
||||
#define SYSCALL_SETEUID 82
|
||||
#define SYSCALL_SETEGID 83
|
||||
#define SYSCALL_MAX_NUM 84 /* index of highest constant + 1 */
|
||||
#define SYSCALL_IOCTL 84
|
||||
#define SYSCALL_MAX_NUM 85 /* index of highest constant + 1 */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -325,6 +325,21 @@ static int sys_fcntl(int fd, int cmd, unsigned long arg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int sys_ioctl(int fd, int cmd, void* /*ptr*/)
|
||||
{
|
||||
Ref<Descriptor> desc = CurrentProcess()->GetDescriptor(fd);
|
||||
if ( !desc )
|
||||
return -1;
|
||||
int ret = -1;
|
||||
switch ( cmd )
|
||||
{
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t sys_readdirents(int fd, kernel_dirent* dirent, size_t size/*,
|
||||
size_t maxcount*/)
|
||||
{
|
||||
|
@ -594,6 +609,7 @@ void Init()
|
|||
Syscall::Register(SYSCALL_FSYNC, (void*) sys_fsync);
|
||||
Syscall::Register(SYSCALL_FTRUNCATE, (void*) sys_ftruncate);
|
||||
Syscall::Register(SYSCALL_GETTERMMODE, (void*) sys_gettermmode);
|
||||
Syscall::Register(SYSCALL_IOCTL, (void*) sys_ioctl);
|
||||
Syscall::Register(SYSCALL_ISATTY, (void*) sys_isatty);
|
||||
Syscall::Register(SYSCALL_LINKAT, (void*) sys_linkat);
|
||||
Syscall::Register(SYSCALL_LINK, (void*) sys_link);
|
||||
|
|
Loading…
Add table
Reference in a new issue