|
| 1 | +/* |
| 2 | + Copyright (C) 2025 cr4zyengineer |
| 3 | +
|
| 4 | + This file is part of Nyxian. |
| 5 | +
|
| 6 | + Nyxian is free software: you can redistribute it and/or modify |
| 7 | + it under the terms of the GNU General Public License as published by |
| 8 | + the Free Software Foundation, either version 3 of the License, or |
| 9 | + (at your option) any later version. |
| 10 | +
|
| 11 | + Nyxian is distributed in the hope that it will be useful, |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + GNU General Public License for more details. |
| 15 | +
|
| 16 | + You should have received a copy of the GNU General Public License |
| 17 | + along with Nyxian. If not, see <https://www.gnu.org/licenses/>. |
| 18 | +*/ |
| 19 | + |
| 20 | +#import <LindChain/ProcEnvironment/Surface/sys/host/ioctl.h> |
| 21 | +#import <LindChain/ProcEnvironment/Surface/tty/tty.h> |
| 22 | +#include <termios.h> |
| 23 | + |
| 24 | +DEFINE_SYSCALL_HANDLER(ioctl) |
| 25 | +{ |
| 26 | + sys_name("SYS_ioctl"); |
| 27 | + sys_need_in_ports_with_cnt(1); |
| 28 | + |
| 29 | + /* prepare arguments */ |
| 30 | + fileport_t port = in_ports[0]; |
| 31 | + int flag = (int)args[1]; |
| 32 | + /* userspace_pointer_t termios_ptr = (userspace_pointer_t)args[2]; MARK: coming later */ |
| 33 | + |
| 34 | + /* compatibility flag */ |
| 35 | + if(flag != TIOCGETA) |
| 36 | + { |
| 37 | + sys_return_failure(ENOSYS); |
| 38 | + } |
| 39 | + |
| 40 | + /* looking up tty */ |
| 41 | + ksurface_tty_t *tty = NULL; |
| 42 | + ksurface_return_t ksr = tty_for_port(port, &tty); |
| 43 | + |
| 44 | + /* final check */ |
| 45 | + if(ksr != SURFACE_SUCCESS) |
| 46 | + { |
| 47 | + sys_return_failure(ENOTTY); |
| 48 | + } |
| 49 | + |
| 50 | + sys_return; |
| 51 | +} |
0 commit comments