On Tue, 4 Oct 2005, Martin Drab wrote:
> Hi,
>
> can anybody tell me why there is no sys_open() exported in kernel/ksyms.c
> in 2.4 kernels while the sys_close() is there? And what is then the
> preferred way of opening files from within a 2.4 kernel module?
>
> Thank you,
> Martin
There is no way to open files within the kernel. Any attempt is
just a hack. The kernel is designed to perform tasks on behalf
of the caller. It doesn't have a context. It uses the caller's
context. A file-descriptor is a number that relates to the
current context. i.e., STDIN_FILENO is __different__ for you
and somebody else, even though it has the same numerical value.
To open a file in the kernel requires either a task with a
context (like a kernel thread) or you have to steal the context
of somebody which can destroy some innocent task's context.
You are never supposed to use files inside the kernel; period!
If you need to obtain file-data for a driver or receive file-
data from a driver, we have read(), write(), mmap(), and ioctl()
to accomplish these things from user-mode. A user-mode program can
write data directly to your driver using mmap(), for instance.
Or it can use a function-code you define to upload/download data
using ioctl().
This is a FAQ. Many persons have rejected this advice, only
to later on modify their drivers to correspond to the correct
way of writing Unix/Linux device drivers. This, after they've
trashed many innocent tasks.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.13 on an i686 machine (5589.55 BogoMips).
Warning : 98.36% of all statistics are fiction.
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.
Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]