1 year ago

#346569

test-img

Anastasisxr

copy_to_user struct with dynamic array

This is the form of the struct

struct mySt{
   int *list;
   int counter;
}

This is the kernel space side

struct mySt = newSt;

copy_to_user((struct mySt*) arg, newSt, sizeof(struct mySt));

A kmalloc has been performed on the *list between the creation of the struct and the copy_to_user

This is the user space side

ioctl(fd, LIST, &newst);

The fd is the variable the has performed the open(). The LIST is the name of the ioctl operation.

On the user side i get the counter just fine but i cant find a way to pass the array *list.

I would like to know a good way to pass a struct with a dynamic array from kernel space to user space.

c

linux-kernel

linux-device-driver

ioctl

0 Answers

Your Answer

Accepted video resources