J'essaie de transmettre deux arguments du programme d'espace utilisateur pour modifier la taille de la mémoire tampon et le nombre de tampons sur le périphérique char. J'ai essayé plusieurs casting je suis toujours des erreurs jetaiioct passage d'arguments multiples
error: cannot convert to a pointer type copy_from_user((char *)msg, arg, sizeof(msg));
ou
cannot convert to a pointer typecopy_from_user((char *)msg, (char *)arg, sizeof(msg));
header.h
struct ioctl_arguments {
int block_number;
int block_size;
};
le module du noyau et le programme de c comprennent à la fois la header.h
c programme
#define DEVICE_PATH "/dev/driver"
#define MAGIC_NO 'k'
struct ioctl_arguments args;
#define IOCTL_CMD _IOWR(MAGIC_NO, 0, args)
int main()
{
int fd;
args.block_number = 10;
args.block_size = 10;
fd = open(DEVICE_PATH, O_RDWR);
ioctl(fd, IOCTL_CMD,&args);
close(fd);
return 0;
}
pilote de périphérique
static int BlockNumber = 20;
static int BlockSize = 5;
struct ioctl_arguments msg;
static int sample_ioctl (struct file *filp, unsigned int cmd, unsigned long arg);
static int sample_ioctl (struct file *filp, unsigned int cmd, unsigned long arg)
{
// copy two parameters from outside, we use struct
copy_from_user((char *)msg, (char *)arg, sizeof(msg));
Copie possible de [char device catch multiple (int) ioctl-arguments] (https://stackoverflow.com/questions/8849445/char-device-catch-multiple-int-ioctl-arguments) –