Select Git revision
klist_example.c
Werner Sembach authored
klist_example.c 803 B
#include <stdio.h>
#include <fcntl.h>
#include <stropts.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include <signal.h>
#include <errno.h>
#define LIST_CMD 0x1337
#define LIST_ADD (LIST_CMD + 0)
#define LIST_INSERT (LIST_CMD + 1)
#define LIST_SET (LIST_CMD + 2)
#define LIST_GET (LIST_CMD + 3)
#define LIST_DELETE (LIST_CMD + 4)
struct index_val_t {
unsigned long index;
long value;
};
int main() {
int fd = open("/dev/klist", O_RDWR);
struct index_val_t tmp;
tmp.index = 0;
tmp.value = 0x1337;
if (!ioctl(fd, LIST_INSERT, &tmp)) {
printf("Write successfull\n");
}
tmp.index = 0;
tmp.value = 0;
if (!ioctl(fd, LIST_GET, &tmp)) {
printf("%04x\n", tmp.value);
}
close(fd);
return EXIT_SUCCESS;
}