#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd, vtnum; struct wsdisplay_addscreendata screendata; struct timeval t0, t1, dt; fd = open("/dev/ttyC0", O_RDWR); if (fd < 0) err(2, "open /dev/ttyC0"); if (argc == 2) { vtnum = atoi(argv[1]); gettimeofday(&t0, NULL); if (ioctl(fd, WSDISPLAYIO_SETSCREEN, &vtnum) < 0) err(2, "SETSCREEN"); gettimeofday(&t1, NULL); timersub(&t1, &t0, &dt); printf("vt switch took %lu %ld %lf ms\n", (unsigned long)dt.tv_sec, (long)dt.tv_usec, dt.tv_usec/1000.0); } screendata.idx = -1; if (ioctl(fd, WSDISPLAYIO_GETSCREEN, &screendata) < 0) err(2, "GETSCREEN"); printf("Current VT: %d %s %s\n", screendata.idx, screendata.screentype, screendata.emul); exit(0); }