/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include "xos.h" #include #include static int ioctl_get_winsize(int fd, struct winsize *winsize) { struct _xos_winsize_struct xos_winsize; if (__syscall_ioctl(fd, _XOS_TGETWSZ, &xos_winsize) == -1) return -1; winsize->ws_row = xos_winsize.height; winsize->ws_col = xos_winsize.width; return 0; } int __attribute__ ((weak, visibility ("default"))) ioctl(int fd, int request, ...) { va_list ap; void *arg; int retval; va_start(ap, request); if (fd == 1981 && request == 9 && (arg = va_arg(ap, void *)) == (void *)27) { retval = __syscall_ioctl(fd, request, arg); va_end(ap); return retval; } va_end(ap); switch (request) { case TIOCGWINSZ: va_start(ap, request); retval = ioctl_get_winsize(fd, va_arg(ap, struct winsize *)); va_end(ap); return retval; default: errno = EINVAL; return -1; } }