Re: ioctl()

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

 



On Mon, Jan 5, 2009 at 7:06 PM, niamathullah sharief
<shariefbe@xxxxxxxxxxx> wrote:
> you told that
>
>> fd = open("/dev/mydev", O_RDONLY);
>
> but i found that extra one parameter...see
That was just an example dear.
And even the example i gave you works fine. Have you tried it.?
>
> fd = open (dev_name, O_RDWR /*required*/| O_NONBLOCK,0);
>
> can you explain this?

in case of non block if a device is already being used
then i suppose that open call will not block.
And the third parameter you see is access permissions.

>
>
>
> --- On Sat, 3/1/09, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
>
> From: Robert P. J. Day <rpjday@xxxxxxxxxxxxxx>
> Subject: Re: ioctl()
> To: "Rohit Sharma" <imreckless@xxxxxxxxx>
> Cc: "rishi agrawal" <postrishi@xxxxxxxxx>, shariefbe@xxxxxxxxxxx, "Kernel
> newbies" <kernelnewbies@xxxxxxxxxxxx>
> Date: Saturday, 3 January, 2009, 8:42 PM
>
> On Sat, 3 Jan 2009, Rohit Sharma wrote:
>
>> ioctls are also known as generic system calls. Its a simple switch
>> case implementation inside a device.
>> you send command and argument through ioctls as parameters.
>> Its a way you use to interact with the device itself.
>>
>> for using it just open the device and use its fd to invoke ioctls.
>>
>> for eg.
>>
>> fd = open("/dev/mydev", O_RDONLY);
>>
>> ioctl(fd, cmd, argument);
>>
>>
>> its internal representation is something like:
>>
>> ioctl( struct file *, struct inode*, unsigned int cmd, unsigned long arg)
>> {
>>     switch(cmd) {
>>                          case 1:  .......
>>                          case 2:  .........
>>      }
>> }
>>
>> for more details refer Beginning Linux Programming.
>> I hope that helps.
>
>   the last i heard, while ioctl's aren't going away any time soon,
> they're deprecated in favour of ... uh, files under /sys?  am i
> remembering that correctly?  in short, if you're already working with
> an ioctl-based code base, keep doing that.  but if you have the
> opportunity to design some kernel code from scratch, use the sysfs.
>
>   or am i way off base here?
>
> rday
> --
>
> ========================================================================
> Robert P. J. Day
> Linux Consulting, Training and Annoying Kernel Pedantry:
>     Have classroom, will lecture.
>
> http://crashcourse.ca                          Waterloo, Ontario, CANADA
> ============================================================
> ============
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>
> ________________________________
> Add more friends to your messenger and enjoy! Invite them now.

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