Re: ioctl()

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

 



On Sun, Jan 4, 2009 at 5:54 PM, niamathullah sharief
<shariefbe@xxxxxxxxxxx> wrote:
>
> can you tell me what is this sysfs....its general system call?

Yes its a virtual filesystem showing device topology.
sysfs is mounted in '/sys' directory

if not mounted use this command
#mount -t sysfs sysfs /sys

browse to /sys directory to view this topology.
you will see the following things:

block  bus  class  dev  devices  firmware  fs  kernel  module  power

You must be familiar with kobjects to understand sysfs better.
Refer Linux Kernel Development,by Robert Love. ch 17

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