mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 20:44:26 +01:00
Rename test to user
This commit is contained in:
35
kernel_module/user/ioctl.c
Normal file
35
kernel_module/user/ioctl.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../ioctl.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd, ret;
|
||||
|
||||
if (argc < 4) {
|
||||
puts("Usage: ./prog <ioctl-file> <cmd> <arg>");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
fd = open(argv[1], O_RDONLY);
|
||||
if (fd == -1) {
|
||||
perror("open");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ret = ioctl(fd, IOCTL0, argv[3]);
|
||||
if (ret == -1) {
|
||||
perror("ioctl");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("ret = %d\n", ret);
|
||||
printf("errno = %d\n", errno);
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user