//------------------------------------------------------------------- // tryioctl.cpp // // This program exercises our 'ioctl.c' device-driver services. // // programmer: ALLAN CRUSE // written on: 19 NOV 2004 -- for Linux kernel version 2.4.26. // revised on: 16 MAR 2005 -- for Linux kernel version 2.6.10. //------------------------------------------------------------------- #include // for perror() #include // for open() #include // for exit() #include // for close() #include // for ioctl() #define HIDE_CURSOR 0 #define SHOW_CURSOR 1 char devname[] = "/dev/vram"; int main( int argc, char **argv ) { // install driver and open device-file system( " /sbin/insmod ioctl.ko" ); int fd = open( devname, O_RDWR ); if ( fd < 0 ) { perror( devname ); exit(1); } getchar(); // hide the graphics cursor ioctl( fd, HIDE_CURSOR ); getchar(); // show the graphics cursor ioctl( fd, SHOW_CURSOR ); getchar(); // close device-file and remove driver close( fd ); system( "/sbin/rmmod ioctl" ); }