1 /* 2 * Copyright 2007 The Android Open Source Project 3 * 4 * Console tty device. 5 */ 6 #include "Common.h" 7 8 #include <string.h> 9 10 #include <sys/ioctl.h> 11 #include <linux/vt.h> 12 13 14 /* 15 * Handle the various console ioctls, most of which we can just ignore. 16 */ 17 static int ioctlConsoleTty(FakeDev* dev, int fd, int request, void* argp) 18 { 19 wsLog("%s: ioctl(0x%x, %p)\n", dev->debugName, request, argp); 20 switch (request) { 21 case VT_GETSTATE: // struct vt_stat* 22 /* 23 * Looks like they want vs.v_active. This just gets fed back into 24 * another console ioctl, so we don't really need to do anything. 25 * We zero out the struct so the data will at least appear to be 26 * initialized. 27 */ 28 memset(argp, 0, sizeof(struct vt_stat)); 29 break; 30 case VT_OPENQRY: // int* 31 /* they want the console number */ 32 *(int*)argp = 123; 33 break; 34 default: 35 /* ignore anything we don't understand */ 36 break; 37 } 38 39 return 0; 40 } 41 42 /* 43 * Open the console TTY device, which responds to a collection of ioctl()s. 44 */ 45 FakeDev* wsOpenDevConsoleTty(const char* pathName, int flags) 46 { 47 FakeDev* newDev = wsCreateFakeDev(pathName); 48 if (newDev != NULL) { 49 newDev->ioctl = ioctlConsoleTty; 50 } 51 return newDev; 52 } 53 54