How can we access driver function using system call ?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can we access driver function using system call ?
Dear Friends,
As per my knowledge, one can use systemcall to call the driver functions for example using open, close... Now is there any way to call driver functions directly from application without using system call?
Using system call is the conventional way to call driver functionalities such as the driver open, close, and ioctls. If your application or program is running in kernel space, then you can directly call your driver functions by exporting them in the driver. But if your program is running in user space, then you have to go through system calls.
Thank you for the response. I had one question pertaining to it, Is there any reason why we can access the kernel space device driver function from user space through system call only ?
In my opinion, as devices are treated as file, thats why its must to use systemcall to access device driver present in kernel space?
Because you really cannot access them. Kernel space driver functions are only visible on kernel space. This is important to ensure the stability of the system. Kernel space functions do not share their process address space with the user space programs. So an address of variable being used in a kernel space, cannot be accessed, used, or supplied by a user space program, because if it is possible to do that, it would be easy to destroy the kernel by passing invalid addresses. This separation of user and kernel space is to prevent invalid executions in the kernel space. Kernel space modules or drivers are designed (ideally) to always work, never fail. Because any failure of kernel space functions such as segmentation fault are not recoverable and will cause kernel panic or kernel oops. It is not safe to fail in the kernel space, whereas in the user space it is ok since it does not control the whole system.
So by providing a way or means of accessing the kernel space modules or drivers through system calls, the possible errors that can be committed are reduced or restricted. System calls return proper error codes and the driver also do proper error handling in cases of invalid arguments.
Sorry for the messy explanation, but to summarize it, you cannot afford to fail in the kernel space, so you should go through the proper way of accessing the kernel space driver functionality.
By the way, device files are not ordinary files like text files which can be accessed by fopen, fprintf, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.