copy_to_user question

linux
2005-05-05T12:41:25Z

Hi all, i have a question about copy_to_user function.
I have a module which declares a struct test { int size; char *name; int
value_add };
I like to transfer that struct to userspace through an ioctl command like
that:

struct test test_struct;
memset(&test_struct,0,sizeof(test_struct);
test_struct.size= 100;
test_struct.name = "test name";
test_struct.value_add = 2;
copy_to_user((void __user *)arg,&test_struct,sizeof(struct test));

When i use the ioctl command in user-space and try to get the name item a
segfault occurs.Can u tell me why??
Can we transfer from kernel-space to user-space pointers like the one i use
or this is a fault approach???

Best regards,
Chris.