I want to call kernel module driver.ko
ioctl
from user space with c program. when compiling I got this error
header.h:13:38: error: expected expression before ‘char’
#define IOCTL_CMD _IORW(MAGIC_NO, 0, char *)
by definition I put the right arguments : _IORW(int type, int number, data_type)
main.c
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include "header.h"
int main()
{
int fd;
char * msg = "5";
fd = open(DEVICE_PATH, O_RDWR);
ioctl(fd, IOCTL_CMD, msg);
printf("ioctl executed\n");
close(fd);
return 0;
}
header.h
#include <linux/ioctl.h>
#include <linux/kdev_t.h> /* for MKDEV */
#define DEVICE_NAME "driver"
#define DEVICE_PATH "/dev/driver"
#define WRITE 0
static int major_no;
#define MAGIC_NO '4'
/*
* Set the message of the device driver
*/
#define IOCTL_CMD _IORW(MAGIC_NO, 0, char *)