What is use of "char __user *buf"?

I have seen several function containing "char __user *buf" as parameter.
this is disturbing my basic knowledge of c

the basic syntax says
char *buf means buf is a pointer which points to a char

now what does
char __user *buf means?

Please reply

This is not regular C and won't compile as is.

You have to look elsewhere to find __user definition. It is very likely a macro that expands to something else, possibly nothing.

The use of char __user *buf is typically found in the linux kernel...denoting that this address is in the user space. For example when writing to disk the kernel copies the contents of *buf into a kernel space buffer before writing it out to disk. Similarly when a process requests a read operation...the device driver at the behest of the kernel reads the desired disk blocks into a kernel space buffer...and then copies them into the user space buffer pointed to by *buf.

3 Likes