Re: Ioctls for data transfer

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

 



2009/9/18 Leonidas . <leonidas137@xxxxxxxxx>:
>
>
> On Fri, Sep 18, 2009 at 7:32 AM, Pei Lin <telent997@xxxxxxxxx> wrote:
>>
>> 2009/9/17 Leonidas . <leonidas137@xxxxxxxxx>:
>> >
>> >
>> > Hi list,
>> >
>> > I know that introducing/using new ioctls is frawned upon by the
>> > community.
>> > They might still be needed for controlling various hw parameters, Just
>> > wanted
>> > to understand the data transfer side of ioctls with a use case.
>> >
>> > E.g. My kernel module needs to pass a buffer of 1-2Mb to userspace
>> > whenever user requests. The buffer will contain different kind of data
>> > depending
>> > on different commands i.e. assume that I maintain 3 types of buffers in
>> > my
>> > module.
>> >
>> > Now, with ioctls it is much easiler to get the buffer to userspace
>> > simply by
>> > issusing
>> > different commands. But if I have to achive the same functionality using
>> > read() call
>> > how would I do it? Meaning ioctl kind of multiplexes the things which
>> > might
>> > be
>> > needed in some cases. How would I do this kind of stuff with read()? By
>> > having 3
>> > different minor devices and issuing read() on 3 devices for getting 3
>> > buffers?
>> >
>> hi, leo
>> just implement your ioctl function, create the command, and decode
>> command,deliver your command and buffer point (user) into your
>> module,then use copy_from_user /copy_to_user deliver your buffer from
>> user to kernel or vice versa.
>>
>> > I am not looking for anyother mechanism of trasnfering data to userspace
>> > as
>> > of now
>> > since this data would be really sporadic. I have to choose between ioctl
>> > and
>> > read.
>> >
>> > -Leo.
>> >
>>
>>
>>
>> --
>> Best Regards
>> Lin
>
> Peter,
>
> No it is going to be a simple char device. Actually a pseudo device since it
> is not going
> to be associated with any hw buffers. The buffers which I need to transfer
> are some
> bookkeeping buffers I would maintain in my module. So the usd stuff which
> you mention
> might not be appropriate.
>
> Lin,
>
> I think you are talking about ioctl on a single minor number device, my
> concern is more
> about choice here. Meaning whether using ioctls with different commands on a
> single dev
> node be preferable to issuing reads on 3 different minor number device
> nodes.
i think u just need read the codes in the kernel driver char/tty*
especially tty_ioctl.c and Document devices.txt and files in ioctl
folder.

>
>
> -Leo.
>
>



-- 
Best Regards
Lin

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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