Re: ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/13/05, raja <vnagaraju@xxxxxxxxxxxx> wrote:
> Hi,
>     I am implementing the ioctl function for my own character device driver.
> In that I want to get the size of the device.
> ioctl takes the last argument as long int.
> i have to use the copy_to_user()  symbol
> 
> the second and third arguments for this symbol is the address of the
> device size and the size of the long int.
> (i.e)
> copy_to_user(,&DEVICE_SIZE,sizeof(long int));
> where DEVICE_SIZE is the size of my device.How can i use the first argument?
> 

In ioctl (kernel) you got four arguments in which 3rd one is for the
command and 4th one is the pointer/address of the user space buffer
(in unsigned long arg) ....

so for call copy_to_user in this manner :

copy_to_user((void __user *)arg, &DEVICE_SIZE, sizeof(long));

-- 
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux