ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am fairly new to linux but not to C (fairly compitent) and understand some about the operating system.
I have been trying to implement some code that has been working well in user space but the overhead is too much and there is no simple way to open its functionality to more user.
I have currently implemented a pipe to allow a user to read the data that I have available in my fifo.
So I get an callback from hardware
memcpy into my fifo
pthread listens via non blocking open on pipe.
I then do non blocking writes to pipe.
I have subsiqently attempted to move the code into a kernel driver so that I can act as a basic char device and using the open close and read functions so I can serve multiple readers.
All is simple I can get the basic framework compiling and I can do the simple cat of the device to show the open read and close in operation.
I then ported accross the code that receives the callback from hardware and copies into a buffer. The problem I am facing is that in order to access the hardware now it is in another kernel driver (which I had hacked into previously but i need to be stand alone)
To access this kernel driver I need to use ioctls but from what I am experiencing I cannot open a dev device from a .ko and I cannot use ioctls from a .ko
I get a problem when linking that there are unknown references;
The Warning is nothing to worry about as long as you know that the appropriate kenel driver will be loaded before you try and instigate the driver with the warning. The linker is just letting you know that it doesn't know where the exported functions are.
I'm sure that this warning could be removed if I included the .ko's at linking stage so that they can be referenced.
With regards to the ioctl calls. DONT DO IT, or at least you shouldnt need to if you are in kernel space you have access the the public functions of the other drivers you should be accessing. If you do have a need to ioctl in user space it can be done by wrapping the calls with the following
fs = get_fs(); /* save previous value */
set_fs (get_ds()); /* use kernel limit */
/* system calls can be invoked */
set_fs(fs); /* restore before returning to user space */
So hopefully this will help someone somewhere who has the same problem.