RE: _IOWR ioctl

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

 



Does anyone has an working example of using _IOWR()?

Am Di, den 27.07.2004 schrieb Dhiman, Gaurav um 11:52:
> It is always a better idea to use copy_to_user() function for writing
> something back to user space buffer. As mentioned in Rubini's books, it
> take cares of all the issues related to coping across the kernel and
> user space.
> 
> If you are doing direct copying to the user buffer without any kernel
> function used for this purpose, theoretically there should not be any
> problem except that you can get a page fault, but in case if you are not
> getting any page fault and the control is returning to user space
> successfully, then there should be no problem in copying directly, but
> again saying it is not a preferred way.
> 
> Use copy_to_user() for smooth execution.
> 
> Regards,
> Gaurav.
> 
> 
> -----Original Message-----
> From: kernelnewbies-bounce@xxxxxxxxxxxx
> [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Danilo Reinhardt
> Sent: Tuesday, July 27, 2004 3:02 PM
> To: Kernel Newbies
> Subject: _IOWR ioctl
> 
> Hi,
> 
> i want to use an read and write ioctl. My problem is that i dont know
> what i have to do to write something back from kernel to the userland
> app that has called ioctl()?
> 
> To exchange data i've a struct with one parameter used as input for the
> kernel and another as output to the userspace.
> 
> struct st_cmd_getBridgeInfo {
>   __u32 bridge;	// param for kernel
>   char	info[4092]; // result to userspace
> };
> 
> #define TIS_IOC_GETBRIDGEINFO	_IOWR(0x88, 1, struct
> st_cmd_getBridgeInfo)
> 
> I guessed that i have to do it this way, but if i write something to the
> info array in kernel ive got nothing at userspace. The input to kernel
> works very well. Do i have to use copy_to_user or something?
> 
> Any suggestions?
> 
> Bye Dan
> 
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 


--
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