mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-24 10:41:35 +01:00
ioctl begins to work
This commit is contained in:
11
kernel_module/test/init_hello.c
Normal file
11
kernel_module/test/init_hello.c
Normal file
@@ -0,0 +1,11 @@
|
||||
/* Replacement init example for when we feel like running
|
||||
* a single non-interactive single executable Linux distro. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
puts("hello world");
|
||||
while (1)
|
||||
sleep(0xFFFFFFFF);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -6,7 +7,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "../ioctl.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
@@ -21,7 +23,7 @@ int main(int argc, char **argv)
|
||||
perror("open");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
ret = ioctl(fd, strtoul(argv[2], NULL, 10), argv[3]);
|
||||
ret = ioctl(fd, IOCTL0, argv[3]);
|
||||
if (ret == -1) {
|
||||
perror("ioctl");
|
||||
return EXIT_FAILURE;
|
||||
|
||||
Reference in New Issue
Block a user