int main(int argc, char *argv[]) { if (argc < 2) { fprintf(stderr, "Usage: test <mtdev>\n"); return -1; } int fd = open(argv[1], O_RDONLY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "error: could not open file\n"); return -1; } loop_device(fd); close(fd); return 0; }
int main(int argc, char *argv[]) { int fd; if (argc < 2) { fprintf(stderr, "Usage: mtdev <device>\n"); return -1; } fd = open(argv[1], O_RDONLY | O_NONBLOCK); if (fd < 0) { fprintf(stderr, "error: could not open device\n"); return -1; } if (ioctl(fd, EVIOCGRAB, 1)) { fprintf(stderr, "error: could not grab the device\n"); return -1; } loop_device(fd); ioctl(fd, EVIOCGRAB, 0); close(fd); return 0; }