2 * Acess2 POSIX Emulation
3 * - By John Hodge (thePowersGang)
10 #include <acess/devices.h> // DRV_TYPE_*
11 #include <acess/devices/pty.h>
13 #include <termios.h> // TIOC*
17 int ioctl(int fd, int request, ...)
20 va_start(args, request);
32 // #1. Get device type (IOCtl 0)
33 int devtype = _SysIOCtl(fd, 0, NULL);
37 // 0: Normal file (no ioctls we care about)
39 _SysDebug("ioctl(%i, %i, ...) (File)", fd, request);
41 // 1: Has the ident set of ioctls, nothing else
43 _SysDebug("ioctl(%i, %i, ...) (Misc Dev)", fd, request);
47 case DRV_TYPE_TERMINAL:
51 struct winsize *ws = va_arg(args, struct winsize*);
52 _SysDebug("ioctl(%i, TIOCGWINSZ, %p", fd, ws);
54 _SysIOCtl(fd, PTY_IOCTL_GETDIMS, &dims);
57 ws->ws_xpixel = dims.PW;
58 ws->ws_ypixel = dims.PH;
61 const struct winsize *ws = va_arg(args, const struct winsize*);
62 _SysDebug("ioctl(%i, TIOCSWINSZ, %p", fd, ws);
66 dims.PW = ws->ws_xpixel;
67 dims.PH = ws->ws_ypixel;
68 _SysIOCtl(fd, PTY_IOCTL_SETDIMS, &dims);
71 _SysDebug("ioctl(%i, TIOC? %i, ...)", fd, request);
78 _SysDebug("ioctl(%i, %i, ...) (DevType %i)", fd, request, devtype);