fcntl v/s ioctl
am 29.03.2007 18:16:04 von Rick Brown
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@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
Re: fcntl v/s ioctl
am 30.03.2007 08:16:13 von Milind Arun Choudhary
On 3/29/07, Rick Brown 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@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