fcntl v/s ioctl

Hi,

Could some one please explain me the differences and similarities
between fcntl and ioctl? Is one built upon the other? AFAIK, both are
used for handling of very device specific commands by the driver.

Thanks,

Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Rick Brown [ Do, 29 März 2007 18:16 ] [ ID #1671946 ]

Re: fcntl v/s ioctl

On 3/29/07, Rick Brown <rick.brown.3 [at] gmail.com> wrote:
> Hi,
>
> Could some one please explain me the differences and similarities
> between fcntl and ioctl?
>Is one built upon the other?
No

> AFAIK, both are used for handling of very
>device specific commands by the driver.

not both,
this goes well with ioctl

as ioctl is customizable, there is an ioctl method in the
struct file_operations.
so a driver writer can define some device specific tasks
& hook her own method to execute them via an ioctl

http://lxr.linux.no/source/fs/ioctl.c#L159

fcntl is not customizable by a driver
there are some fixed task which it performs

like
setting the close on exec flag
duplicate fd
set/get owner
etc
have a look at

sys_fcntl
http://lxr.linux.no/source/fs/fcntl.c#L385

& its worker
do_fcntl
http://lxr.linux.no/source/fs/fcntl.c#L315


we can say that fcntl dosen't bother if its a regular file
or a device specific file

where as ioctl changes its color in these case

--
Milind Arun Choudhary
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo [at] vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Milind Arun Choudhary [ Fr, 30 März 2007 08:16 ] [ ID #1673197 ]
Linux » gmane.linux.newbie » fcntl v/s ioctl

Vorheriges Thema: Query regarding alloc_chrdev_region()
Nächstes Thema: "struct file" - per process per file?